Transpose pitch by a number of semitones.

transpose(notes, n = 0, octaves = NULL, accidentals = NULL, key = NULL)

tp(notes, n = 0, octaves = NULL, accidentals = NULL, key = NULL)

Arguments

notes

character, a noteworthy string.

n

integer, positive or negative number of semitones to transpose.

octaves

NULL or character, "tick" or "integer" octave numbering in result.

accidentals

NULL or character, represent accidentals, "flat" or "sharp".

key

NULL or character, use a key signature to specify and override accidentals. Ignored if c or am.

Value

character

Details

This function transposes the pitch of notes in a noteworthy string.

Transposing is not currently supported on a phrase object. The notes in a phrase object have already been transformed to LilyPond syntax and mixed with other potentially complex information. Transposing is intended to be done on a string of notes prior to passing it to phrase. It will work on strings that use either integer or tick mark octave numbering formats and flats or sharps, in any combination. The transposed result conforms according to the function arguments. When integer octaves are returned, all 3s are dropped since the third octave is implicit in LilyPond.

When octaves, accidentals and key are NULL, formatting is inferred from notes. When mixed formats are present, tick format is the default for octave numbering and flats are the default for accidentals.

Examples

transpose("a_3 b_4 c5", 0)
#> <Noteworthy string> #> Format: space-delimited time #> Values: a_ b_4 c5
tp("a_3 b_4 c5", -1)
#> <Noteworthy string> #> Format: space-delimited time #> Values: g a4 b4
tp("a_3 b_4 c5", 1)
#> <Noteworthy string> #> Format: space-delimited time #> Values: a b4 d_5
tp("a#3 b4 c#5", 11)
#> <Noteworthy string> #> Format: space-delimited time #> Values: a4 a#5 c6
tp("a#3 b4 c#5", 12)
#> <Noteworthy string> #> Format: space-delimited time #> Values: a#4 b5 c#6
tp("r s a#3 b4 c#5", 13)
#> <Noteworthy string> #> Format: space-delimited time #> Values: r s b4 c6 d6
tp("a b' c#''", 2, "integer", "flat")
#> <Noteworthy string> #> Format: space-delimited time #> Values: b d_5 e_5
tp("a, b ceg", 2, "tick", "sharp")
#> <Noteworthy string> #> Format: space-delimited time #> Values: b, c#' <df#a>