Convert alternative representations of music notation to tabr
syntax.
character, suffix of from_*
function, e.g., "chorrrds"
arguments passed to the function matched by id
.
character, general syntax input. See details and examples for how inputs are structured for each converter.
key signature, used to enforce consistent use of flats or sharps.
logical, attempt to match input chords to known guitar chords
in guitarChords()
. Otherwise by default standard piano chords of
consecutive pitches covering minimum pitch range are returned.
named list of additional arguments passed to gc_info()
, used
when guitar = TRUE
.
character, represent accidentals, "flat"
or "sharp"
.
character, type of output when multiple options are available.
noteworthy string for chorrrds; music string or list for music21.
These functions convert music notation from other data sources into the style
used by tabr
for music analysis and sheet music transcription.
The input x
is a character vector of chords output from the chorrrds
package, as shown in the examples. Output is a noteworthy string object.
Some sources do not offer as complete or explicit information in order to
make sheet music. However, what is available in those formats is converted
to the extent possible and available function arguments can allow the user
to add some additional specification. Different input syntax makes use of a
different syntax converter. Depending on the format, different arguments
may be available and/or required. The general wrapper function for all of
the available syntax converters is to_tabr()
. This function takes an
id
argument for the appropriate converter function. See examples.
For example, output from the chorrrds
package that scrapes chord
information from the Cifraclub website only provides chords, not note for
note transcription data for any particular instrument. This means the result
of syntax conversion still yields only chords, which is fine for data
analysis but doesn't add anything useful for sheet music transcription.
The input in this case also does not specify distinct pitches by assigning octaves numbers to a chord's notes, not even the root note. It remains up to the user if they want to apply the information. By default, every chord starts in octave three. It is also ambiguous how the chord is played since all that is provided is a generic chord symbol. By default a standard chord is constructed if it can be determined.
Setting guitar = TRUE
switches to using the guitarChords()
dataset to
find matching guitar chords using gc_info()
, which can be provided
additional arguments in a named list to gc_args
. For guitar, this allows
some additional control over the actual structure of the chord, its shape and
position on the guitar neck. The options will never work perfectly for all
chords in chords
, but at a minimum, typical default component pitches
will be determined and returned in tabr
notation style.
The input x
is a character vector of in music21 tiny notation syntax,
as shown in the examples. Default output is a music object. Setting
output = "list"
returns a list of three elements: a noteworthy string,
a note info string, and the time signature.
The recommendation for music21 syntax is to keep it simple. Do not use the
letter n
for explicit natural notes. Do not add text annotations such
as lyrics. Double flats and sharps are not supported. The examples
demonstrate what is currently supported.
# chorrrds package output
chords <- c("Bb", "Bbm", "Bbm7", "Bbm7(b5)", "Bb7(#5)/G", "Bb7(#5)/Ab")
from_chorrrds(chords)
#> <Noteworthy string>
#> Format: space-delimited time
#> Values: <b_d'f'> <b_d_'f'> <b_d_'f'a_'> <b_d_'e'a_'> <gb_d'g_'a_'> <a_b_d'g_'>
to_tabr(id = "chorrrds", x = chords)
#> <Noteworthy string>
#> Format: space-delimited time
#> Values: <b_d'f'> <b_d_'f'> <b_d_'f'a_'> <b_d_'e'a_'> <gb_d'g_'a_'> <a_b_d'g_'>
from_chorrrds(chords, guitar = TRUE)
#> Warning: Alternate bass note detected, but ignored when `guitar = TRUE`.
#> <Noteworthy string>
#> Format: space-delimited time
#> Values: <b_,fb_d'f'> <b_,fb_d_'f'> <b_,fa_d_'f'> <b_,a_d_'e'> <b_,g_a_d'> <b_,g_a_d'>
to_tabr(id = "chorrrds", x = chords, guitar = TRUE)
#> Warning: Alternate bass note detected, but ignored when `guitar = TRUE`.
#> <Noteworthy string>
#> Format: space-delimited time
#> Values: <b_,fb_d'f'> <b_,fb_d_'f'> <b_,fa_d_'f'> <b_,a_d_'e'> <b_,g_a_d'> <b_,g_a_d'>
# music21 tiny notation
x <- "4/4 CC#FF4.. trip{c#8eg# d'- e-' f g a'} D4~# D E F r B16"
from_music21(x)
#> <Music string>
#> Format: space-delimited time
#> Values: <d_,,f,,>4.. <d_ea_>t8 d_'t8 e_'t8 ft8 gt8 a't8 e_,~4 d,4 e,4 f,4 r4 b,16
from_music21(x, accidentals = "sharp")
#> <Music string>
#> Format: space-delimited time
#> Values: <c#,,f,,>4.. <c#eg#>t8 c#'t8 d#'t8 ft8 gt8 a't8 d#,~4 d,4 e,4 f,4 r4 b,16
from_music21(x, output = "list")
#> $notes
#> <Noteworthy string>
#> Format: space-delimited time
#> Values: <d_,,f,,> <d_ea_> d_' e_' f g a' e_,~ d, e, f, r b,
#>
#> $info
#> <Note info string>
#> Format: space-delimited time
#> Values: 4.. t8 t8 t8 t8 t8 t8 4 4 4 4 4 16
#>
#> $lyrics
#> [1] NA
#>
#> $key
#> [1] "c"
#>
#> $time
#> [1] "4/4"
#>
#> $tempo
#> [1] "2 = 60"
#>