extractTandem
extracts tandem interpretations from the raw Tandem
spine in humdrumR object.
Arguments
- regex
A regular expression to match tandem interpretations.
Must be a single
character
string.You should not include a
*
at the beginning---the*
marker for tandem interpretations are already removed from theTandem
field.- Tandem
Parsed tandem interpretation data.
Must be
atomic
.Should always be the
Tandem
field from a humdrumR object.
Details
Every humdrumR object has a field called
Tandem
, which is a vector of strings which accumulates
tandem interpretations in each Spine.
At each record, all the previous tandems that occured in each spine
are listed (comma separated), with the most recent appearing first.
For example, consider this file:
The Tandem
field for these two spines would look like this:
""
"C:" "C:"
"Ibass,C:" "Isoprn,C:"
"Ibass,C:" "Isoprn,C:"
"Ibass,C:" "Isoprn,C:"
"Ibass,C:" "Isoprn,C:"
"G:,Ibass,C:" "G:,Isoprn,C:"
"G:,Ibass,C:" "G:,Isoprn,C:"
"G:,Ibass,C:" "G:,Isoprn,C:"
"G:,Ibass,C:" "G:,Isoprn,C:"
Notice that the "C:"
isn't erased by the appearance of "G:"
---this is a naive parser
that doesn't "know" that "C:"
and "G:"
are related.
The earlier tandem ("C:"
) is just pushed further back onto the stack.
Don't worry, the humdrumR data parser does recognize many
common tandem interpretations (like *C:
and *G:
) and will automatically parse
them if they are present---in this case, they are put into the Key
field automatically.
However, the Tandem
field is retained in case your data contains any novel tandem intepretations
that humdrumR
does not recognize.
extractTandem
If your data does contain novel/unknown tandem interpretations, you can use the
extractTandem
function to pull them out of the Tandem
field.
The first argument to extractTandem
must be the Tandem
field from a
humdrumR object.
The second argument (regex
) is a regular expression which is matched against
the the tandem interpretations.
For each token in Tandem
, the most recent match (if any) is retained.
For example, if we wanted to manually extract the key information from the Tandem
field
(which humdrumR
automatically does for you), we could call extractTandem(Tandem, "[A-Ga-g][#-]*:")
.
See also
Read more about tandem interpretations in humdrumR
in the
humdrum table docs. readHumdrum()
also preprocesses
some "known" tandem interpretations.