tabr (version 0.3.5)

transpose: Transpose pitch

Description

Transpose pitch by a number of semitones.

Usage

transpose(notes, n = 0, key = NA, style = c("default", "tick",
  "integer", "strip"))

tp(notes, n = 0, key = NA, style = c("default", "tick", "integer", "strip"))

Arguments

notes

character, a noteworthy string.

n

integer, positive or negative number of semitones to transpose.

key

character, the new key signature after transposing notes. See details.

style

character, specify tick or integer style octave numbering in result. See details.

Value

character

Details

This function transposes the pitch of notes in a valid character string. The string must be of the form passed to the info argument to phrase.

Transposing is not done on a phrase object. The notes in a phrase object have already been transformed to LilyPond syntax and mixed with other potentially complex and variable 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. The transposed result will be a string with integer octave numbering.

If key is provided, this helps ensure proper use of sharps vs. flats. Alternatively, you can simply provide key = "sharp" or key = "flat". The exact key signature is not required, just more clear and informative for the user. If not provided (key = NA), transposition lacks full information and simply defaults to sharping any resulting accidentals for positive n and flattening for negative n. n = 0 returns the input without any modification.

The only element other pitch that occurs in a valid notes string is a rest, "r" or "s" (silent rest). Rests are ignored by transpose.

The default style is to use tick style if no integers occur in notes. The "tick" and "integer" options force the respective styles. When integer style is returned, all 3s are dropped since the third octave is the implicit center in LilyPond. style = "strip" removes any explicit octave information.

Examples

Run this code
# NOT RUN {
transpose("a_3 b_4 c5", 0)
tp("a_3 b_4 c5", -1)
tp("a_3 b_4 c5", 1)
tp("a#3 b4 c#5", 11)
tp("a#3 b4 c#5", 12)
tp("a#3 b4 c#5", 13)
tp("a3 b4 c5", 2, key = "f")
tp("a3 b4 c5", 2, key = "g")
tp("a b' c''", 2, key = "flat")
tp("a, b ceg", 2, key = "sharp")
# }

Run the code above in your browser using DataCamp Workspace