7

I've written a score for a short piece for violin and cello in Lilypond.

\version "2.20"

\header {
  title =   "Transpose Example"
}

main =  {
  \key g \major
  \numericTimeSignature \time 3/4
  \clef "treble"
  \tempo 4 = 84
  \relative g' {
  % motif primary sequence
  g8\mf d'8 b8 d4 b8 | d8~ d16 b16 g16 r16 g16 a16~ a4 | 
  g8 d'8 b8 d4 b8 | d16 c16 b16 r16 g8 b4~ b8 |
    \bar "||"
  }
}

cello = {
  \key g \major
  \clef "bass"
  \relative g' {
  R2.*4
  }
}

\score {
  \new StaffGroup = "StaffGroup" <<
    \context Staff = "clarinet" \with { instrumentName = "Violin" }<<
      \main
      \set Staff.midiInstrument = "violin"
    >>
    \context Staff = "cello" \with { instrumentName = "Cello" } <<
      \cello
      \set Staff.midiInstrument = "cello"
    >>
  >>
  \layout { }
  \midi { }
}

enter image description here

But I now want to set the Violin staff for a B-flat clarinet (which is a transposing instrument). Is there any easy way to have Lilypond produce the B-flat Clarinet staff when the notes are written in the target sound (concert pitch)?

The \transposition pitch command seems to be for when you have written for the instrument and you want the midi output to be correct.

6

Add \transpose c d { ... }. Make sure you are including all parts that need to be transposed within that \transpose block. The c and the d are just telling you how far to transpose — in this case, up two semitones (down two semitones would be c bes,).

global = {
 \key g \major
 \time 3/4
}
main = \relative c' {
 c4 d e
}
cello = \relative c {
 \clef bass
 c4 d e
}
\score {
 <<
  \new StaffGroup <<
   \new Staff \with {
    instrumentName = "Violin"
   } {
    \global
    \main
   }
   \new Staff \with {
    instrumentName = "Cello"
   } {
    \global
    \cello
   }
  >>
 >>
 \layout {}
}
\score {
 <<
  \new StaffGroup <<
   \new Staff \with {
    instrumentName = "Clarinet"
   } \transpose c d {
    \global
    \main
   }
   \new Staff \with {
    instrumentName = "Cello"
   } {
    \global
    \cello
   }
  >>
 >>
 \layout {}
}

Showing LilyPond transposition is easy

3
  • Thankyou! I also added \transposition bes so that the midi file sounds the clarinet correctly – timbo Mar 26 at 21:55
  • 3
    Perhaps \transpose bes, c {...} makes more sense than \transpose c d {...} for a B-flat instrument. – Elements in Space Mar 27 at 6:02
  • Just depends on how you look at it. Whatever helps. – Neal Mar 27 at 18:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.