[ << Musical notation ] | [Top][Contents][Index] | [ Specialist notation >> ] |
[ < Octave checks ] | [ Up : Changing multiple pitches ] | [ Inversion > ] |
Transpose
A music expression can be transposed with \transpose
. The
syntax is
\transpose frompitch topitch musicexpr
This means that musicexpr
is transposed by the
interval between the pitches frompitch
and
topitch
: any note with pitch frompitch
is changed to topitch
and any other note is
transposed by the same interval. Both pitches are entered in
absolute mode.
Note: Music inside a \transpose
block is absolute
unless a \relative
is included in the block.
Consider a piece written in the key of D-major. It can be transposed up to E-major; note that the key signature is automatically transposed as well.
\transpose d e { \relative { \key d \major d'4 fis a d } }
If a part written in C (normal concert pitch) is to be played on the A clarinet (for which an A is notated as a C and thus sounds a minor third lower than notated), the appropriate part will be produced with:
\transpose a c' { \relative { \key c \major c'4 d e g } }
Note that we specify \key c \major
explicitly. If we
do not specify a key signature, the notes will be transposed but
no key signature will be printed.
\transpose
distinguishes between enharmonic pitches: both
\transpose c cis
or \transpose c des
will
transpose up a semitone. The first version will print sharps and
the notes will remain on the same scale step, the second version
will print flats on the scale step above.
music = \relative { c' d e f } \new Staff { \transpose c cis { \music } \transpose c des { \music } }
\transpose
may also be used in a different way, to input
written notes for a transposing instrument. The previous examples
show how to enter pitches in C (or concert pitch) and
typeset them for a transposing instrument, but the opposite is
also possible if you for example have a set of instrumental parts
and want to print a conductor’s score. For example, when entering
music for a B-flat trumpet that begins on a notated E (concert D),
one would write:
musicInBflat = { e4 … } \transpose c bes, \musicInBflat
To print this music in F (e.g., rearranging to a French horn) you
could wrap the existing music with another \transpose
:
musicInBflat = { e4 … } \transpose f c' { \transpose c bes, \musicInBflat }
For more information about transposing instruments, see Instrument transpositions.
Selected Snippets
Transposing pitches with minimum accidentals ("Smart" transpose)
This example uses some Scheme code to enforce enharmonic modifications for notes in order to have the minimum number of accidentals. In this case, the following rules apply:
Double accidentals should be removed
B sharp -> C
E sharp -> F
C flat -> B
F flat -> E
In this manner, the most natural enharmonic notes are chosen.
#(define (naturalize-pitch p) (let ((o (ly:pitch-octave p)) (a (* 4 (ly:pitch-alteration p))) ;; alteration, a, in quarter tone steps, ;; for historical reasons (n (ly:pitch-notename p))) (cond ((and (> a 1) (or (eqv? n 6) (eqv? n 2))) (set! a (- a 2)) (set! n (+ n 1))) ((and (< a -1) (or (eqv? n 0) (eqv? n 3))) (set! a (+ a 2)) (set! n (- n 1)))) (cond ((> a 2) (set! a (- a 4)) (set! n (+ n 1))) ((< a -2) (set! a (+ a 4)) (set! n (- n 1)))) (if (< n 0) (begin (set! o (- o 1)) (set! n (+ n 7)))) (if (> n 6) (begin (set! o (+ o 1)) (set! n (- n 7)))) (ly:make-pitch o n (/ a 4)))) #(define (naturalize music) (let ((es (ly:music-property music 'elements)) (e (ly:music-property music 'element)) (p (ly:music-property music 'pitch))) (if (pair? es) (ly:music-set-property! music 'elements (map naturalize es))) (if (ly:music? e) (ly:music-set-property! music 'element (naturalize e))) (if (ly:pitch? p) (begin (set! p (naturalize-pitch p)) (ly:music-set-property! music 'pitch p))) music)) naturalizeMusic = #(define-music-function (m) (ly:music?) (naturalize m)) music = \relative c' { c4 d e g } \score { \new Staff { \transpose c ais { \music } \naturalizeMusic \transpose c ais { \music } \transpose c deses { \music } \naturalizeMusic \transpose c deses { \music } } \layout { } }
See also
Notation Reference: Instrument transpositions, Inversion, Modal transformations, Relative octave entry, Retrograde.
Snippets: Pitches.
Internals Reference: TransposedMusic.
Known issues and warnings
The relative conversion will not affect \transpose
,
\chordmode
or \relative
sections in its argument. To use
relative mode within transposed music, an additional \relative
must be placed inside \transpose
.
Triple accidentals will not be printed if using \transpose
. An
‘enharmonically equivalent’ pitch will be used instead (e.g., d-flat
rather than e-triple-flat).
[ << Musical notation ] | [Top][Contents][Index] | [ Specialist notation >> ] |
[ < Octave checks ] | [ Up : Changing multiple pitches ] | [ Inversion > ] |