Transposition
Transposition in Verovio uses the base-40 system that allows for an arbitrary maximum sharp/flat count (where base-40 can handle up to double sharps/flats). The option --transpose
can be given two types of data: (1) a chromatic interval, or (2) a tonic pitch in the new key with optional direction and octave of transposition added.
Transposition by chromatic interval
For transposition by chromatic intervals, the format is an optional sign, followed by a chromatic quality followed by a diatonic number of steps. Examples: +M2
= up major second, -d5
= down diminished fifth
The direction of the interval, with -
indicating down and no sign or a +
means up. A special cases is P1
which is a perfect unison, so +P1
and -P1
are equivalent since there is no movement up or down.
For the chromatic quality of the interval, P
means perfect, M
means major, m
means minor, d
means diminished, A
means augmented, dd
means doubly diminished (and so on), AA
means doubly augmented (and so on). For [PdA]
the case of the letter does not matter so [pDa]
should be interpreted as equivalent. M
and m
are case-sensitive (major and minor).
The diatonic interval is any (reasonable) positive integer. A unison is 1
, a second is 2
, and so on. Compound intervals an octave and above can also be represented, such as 8
for an octave, a 9
for a ninth (octave plus a second), 10
for a tenth (octave plus a third), 15
is two octaves, and 16
is two octaves plus a second.
Verovio will print an error message if the string option is not formatted correctly, and it will return an error interval which is a very large interval going down.
Example interval names:
name | meaning |
---|---|
P1 | perfect unison |
M2 | major second up |
+M2 | major second up |
-M2 | major second down |
m2 | minor second up |
d2 | diminished second up |
dd2 | doubly diminished second up |
A2 | augmented second up |
AA2 | doubly augmented second up |
M3 | major third up |
P4 | perfect fourth up |
d4 | diminished fourth up |
A4 | augmented fourth up |
P8 | perfect octave up |
P15 | two perfect octaves up |
m10 | perfect octave plus minor third up |
Transposition by tonic pitch
For transposition by tonic pitch names, the format is made up of an optional direction, a pname
and an accid
.
If no direction is given, then the smallest interval will be chosen. For example if starting from C major and transposing to G major, the calculated interval will be down a perfect fourth, since the G below C is closer than the G above C.
When the direction is +
, the next higher pitch that matches the new tonic will define the interval. For C major to G major, this is a perfect fifth up. When the direction is -
, the next lowest pitch that matches the new tonic will define the interval. For C major to G major, this is a perfect fourth down.
The +
or -
direction can be doubled/tripled/etc. to indicate additional octave transpositions. For example --g
from C major means to transpose down an octave and a fourth: The fourth to the G below, and then the octave to the next lower G. Likewise, +++g
from C major means to transpose up two octaves and a fifth: A fifth to the G above, then ++
means two octaves above that G.
When using a case-insensitive @pname
for the tonic of the new key, use ([A-Ga-g])
followed by an optional accid
for the new key tonic. This is also case-insensitive: ([Ss]*|[Ff]*)
.
Examples:
tonic parameter | meaning |
---|---|
g |
transpose current tonic to closest G tonic note (up or down a fourth from current tonic) |
+g |
transpose to the next higher G tonic |
-g |
transpose down to next lower G tonic |
++g |
transpose to second next higher G tonic |
--g |
transpose to second next lower G tonic |
ff |
transpose to nearest F-flat |
-cs |
transpose to next lower C-sharp |
++BF |
transpose up to second next higher B-flat |
Illustrated examples
Here is a test example music to transpose - note the @key.sig
is expected for transposition to work properly:
<score>
<scoreDef>
<staffGrp>
<staffDef n="1" lines="5" clef.shape="G" clef.line="2" meter.sym="common" keysig="0"/>
</staffGrp>
</scoreDef>
<section>
<measure right="end" n="1">
<staff n="1">
<layer n="1">
<chord dur="1">
<note oct="4" pname="c"/>
<note oct="4" pname="e"/>
<note oct="4" pname="g"/>
</chord>
</layer>
</staff>
</measure>
</section>
</score>
Setting transpose: "M2"
will transpose the music up a major second from C to D:
Setting transpose: "-m2"
To go down a minor second from C to B:
Common intervals: m3
= minor third, M3
= major 3rd, P4
= perfect fourth, P5
= perfect fifth, d5
= diminished fifth, A4
= augmented fourth.
It is also possible to give semitone steps, with 1 being one semitone, 2 being two semitones, etc. This method is less precise, and the computer will make an automatic calculating to minimize the number of accidentals in the target key signature.
For example transpose: "1"
will display in D-flat major:
This is equivalent to going up a minor second with transpose: "-m2"
:
If you need to transpose to C-sharp major, then you cannot use integers, but must use the full musical interval, which in this case is transpose: "A1"
for an augmented unison:
(a1
and A1
are the same, but m2
and M2
are not equivalent).
It is also possible to give the tonic note of the new key. For example transpose: "E"
means to transpose to E major (or minor, since the mode will not be changed). This feature requires that the music contain key information which is not always present in MusicXML data. It can also be incorrect, which may cause problems, so use this option with care in an automatic situation.
F-sharp major with transpose: "F#"
, which is equivalent to a transposition of A4
:
G-flat major with transpose: "Gb"
, which is equivalent to d5
:
Notice that this method moves to the closest tonic. To force G-flat major above, add a +
with transpose: "+Gb"
:
To go another octave above, add two ++
with transpose: "++Gb"
:
Algorithm for transposition by tonic
The algorithm for transposition by tonic proceeds as follow:
-
Find the key information at the start of the music in each part. If all parts have the same transposition (or no parts have transposition), then use the
@pname
and@accid
as the reference pitch for which an interval will be calculated for the input transposition target tonic. -
If all parts do not have the same transposition, then choose a part that does not have a transposition from which to extract the key information. If all parts have transpositions, but the transpositions are different, then apply transposition to the key information to get it to sounding pitch for one of those instruments and use this transposed pitch as the basis for the key transposition.
-
The key information may be stored in one of two main locations:
staffDef@key.pname
/staffDef@key.accid
(the most common currently) orkeySig@pname
/keySig@accid
. ThestaffDef@key.mode
/keySig@mode
is not needed. This key information must come before the first notes on the staff.keySig
may be found as a child ofstaffDef
, or may be found outside of thestaffDef
(at the startlayer
) or inscoreDef
if it applies to all staves in the score (or the majority of staves in the score?). -
If there is no key information found before the first notes of the music, print an error warning and do not transpose.
-
Once the original key is known, then the interval necessary for transposition can be calculated. The next step is to identify the closest new tonic’s octave. For extra
+
or-
in the tonic string, add an octave to the interval to calculate the final interval for transposition.
At this point the key transposition process becomes equivalent to the interval transposition process.