Keyboards
Keyboard and other multi-staff instruments
Accordion-discant symbols
This snippet has been obsoleted by predefined markup commands, see
’Discant symbols’ in the Notation Reference. It’s still useful as a
simple demonstration of how to combine symbols: the placement of the
symbols added with \markup can be tweaked by changing the
\translate-scaled arguments. \translate-scaled is used
here rather than \translate in order to let the positioning of
the symbol parts adapt to changes of font-size.
discant=\markup{ \musicglyph"accordion.discant" } dot=\markup{ \musicglyph"accordion.dot" } \layout{ragged-right=##t} % 16 voets register accBasson=^\markup{ \combine \discant \translate-scaled#'(0.0.5)\dot } % een korig 8 en 16 voets register accBandon=^\markup{ \combine \discant \combine \translate-scaled#'(0.0.5)\dot \translate-scaled#'(0.1.5)\dot } accVCello=^\markup{ \combine \discant \combine \translate-scaled#'(0.0.5)\dot \combine \translate-scaled#'(0.1.5)\dot \translate-scaled#'(1.1.5)\dot } % 4-8-16 voets register accHarmon=^\markup{ \combine \discant \combine \translate-scaled#'(0.0.5)\dot \combine \translate-scaled#'(0.1.5)\dot \translate-scaled#'(0.2.5)\dot } accTrombon=^\markup{ \combine \discant \combine \translate-scaled#'(0.0.5)\dot \combine \translate-scaled#'(0.1.5)\dot \combine \translate-scaled#'(1.1.5)\dot \translate-scaled#'(-1.1.5)\dot } % eenkorig 4 en 16 voets register accOrgan=^\markup{ \combine \discant \combine \translate-scaled#'(0.0.5)\dot \translate-scaled#'(0.2.5)\dot } accMaster=^\markup{ \combine \discant \combine \translate-scaled#'(0.0.5)\dot \combine \translate-scaled#'(0.1.5)\dot \combine \translate-scaled#'(1.1.5)\dot \combine \translate-scaled#'(-1.1.5)\dot \translate-scaled#'(0.2.5)\dot } accAccord=^\markup{ \combine \discant \combine \translate-scaled#'(0.1.5)\dot \combine \translate-scaled#'(1.1.5)\dot \combine \translate-scaled#'(-1.1.5)\dot \translate-scaled#'(0.2.5)\dot } accMusette=^\markup{ \combine \discant \combine \translate-scaled#'(0.1.5)\dot \combine \translate-scaled#'(1.1.5)\dot \translate-scaled#'(-1.1.5)\dot } accCeleste=^\markup{ \combine \discant \combine \translate-scaled#'(0.1.5)\dot \translate-scaled#'(-1.1.5)\dot } accOboe=^\markup{ \combine \discant \combine \translate-scaled#'(0.1.5)\dot \translate-scaled#'(0.2.5)\dot } accClarin=^\markup{ \combine \discant \translate-scaled#'(0.1.5)\dot } accPiccolo=^\markup{ \combine \discant \translate-scaled#'(0.2.5)\dot } accViolin=^\markup{ \combine \discant \combine \translate-scaled#'(0.1.5)\dot \combine \translate-scaled#'(1.1.5)\dot \translate-scaled#'(0.2.5)\dot } \relativec''{ c4d\accBassonef c4d\accBandonef c4d\accVCelloef c4d\accHarmonef c4d\accTrombonef \break c4d\accOrganef c4d\accMasteref c4d\accAccordef c4d\accMusetteef c4d\accCelesteef \break c4d\accOboeef c4d\accClarinef c4d\accPiccoloef c4d\accViolinef }
Accordion register symbols
Accordion register symbols are available as \markup as well as
as standalone music events (as register changes tend to occur between
actual music events). Bass registers are not overly standardized. The
available commands can be found in ’Discant symbols’ in the Notation
Reference.
#(use-modules(lilyaccreg)) \newPianoStaff << \newStaff\relative{ \cleftreble \discant"10" r8s32f'[besf]se[ae]sd[gd]s16e32[a] << {r16<fbes>r<ea>r<dg>} \\ {drarbesr} >>| <cisea>1 } \newStaff\relative{ \cleftreble \freeBass"1" r8d'32s16.c32s16.bes32s16.a32[cis]s16 \clefbass\stdBass"Master" << {r16<f,besd>^"b"r<eac>^"am"r<dgbes>^"gm"| <eacis>1^"a"} \\ {d8_"D"c_"C"bes_"B"|a1_"A"} >> } >>
Changing the text for sustain markings
Staff.pedalSustainStrings can be used to set the text used for
pedal down and up. Note that the only valid strings are those found in
the list of pedal glyphs - the values used this snippet constitute an
exhaustive list.
sustainNotes={c4\sustainOnde\sustainOff\sustainOnf\sustainOff} \relativec'{ \sustainNotes \setStaff.pedalSustainStrings=#'("P""P-""-") \sustainNotes \setStaff.pedalSustainStrings=#'("d""de""e") \sustainNotes \setStaff.pedalSustainStrings=#'("M""M-""-") \sustainNotes \setStaff.pedalSustainStrings=#'("Ped""*Ped""*") \sustainNotes }
Clusters
Clusters are a device to denote that a complete range of notes is to be played.
fragment=\relativec'{ c4f<ed'>4 <ga>8<ea>a4c2<db>4 e2c } << \newStaff\fragment \newStaff\makeClusters\fragment >>
Controlling the placement of chord fingerings
The placement of fingering numbers can be controlled precisely. For fingering orientation to apply, it must be used within a chord construct <>, even for single notes. Orientation for string numbers and right-hand fingerings may be set in a similar way.
\relativec'{ \setfingeringOrientations=#'(left) <c-1e-3a-5>4 \setfingeringOrientations=#'(down) <c-1e-3a-5>4 \setfingeringOrientations=#'(downrightup) <c-1e-3a-5>4 \setfingeringOrientations=#'(up) <c-1e-3a-5>4 \setfingeringOrientations=#'(left) <c-1>2 \setfingeringOrientations=#'(down) <e-3>2 \setstringNumberOrientations=#'(upleftdown) <f3円a2円c1円>1 \setstrokeFingerOrientations=#'(downrightup) <c\rightHandFinger#1e\rightHandFinger#2c'\rightHandFinger#4> }
Creating slurs across voices
In some situations, it may be necessary to create slurs between notes
from different voices. The solution is to add invisible notes to one of
the voices, using \hideNotes.
This example is measure 235 of the Ciaconna from Bach’s 2nd Partita for solo violin, BWV 1004.
\relativec'{ << { d16(a')sasa[sa]sa[sa] } \\ { \slurUp bes,16[se]( \hideNotesa) \unHideNotesf[( \hideNotesa) \unHideNotesfis]( \hideNotesa) \unHideNotesg[( \hideNotesa) \unHideNotesgis]( \hideNotesa) } >> }
Cross-staff chords - beaming problems workaround
Sometimes it is better to use stems from the upper staff for creating
cross-staff chords, because no problems with automatic beam collision
avoidance then arise. If the stems from the lower staff were used in
the following example, it would be necessary to change the automatic
beam collision avoidance settings so that it doesn’t detect collisions
between staves using
\override Staff.Beam.collision-voice-only = ##t
\newPianoStaff<< \newStaff=up \relativec'{ << {r4 \overrideStem.cross-staff=##t \overrideStem.length=#19% this is in half-spaces, % so it makes stems 9.5 staffspaces long \overrideStem.Y-offset=#-6% stems are normally lengthened % upwards, so here we must lower the stem by the amount % equal to the lengthening - in this case (19 - 7) / 2 % (7 is default stem length) eee} {s4 \changeStaff="bottom" \overrideNoteColumn.ignore-collision=##t c,cc } >> } \newStaff=bottom \relativec'{ \clefbass \voiceOne g8agagaga } >>
Cross-staff tremolos
Since \repeat tremolo expects exactly two musical arguments for
chord tremolos, the note or chord which changes staff within a
cross-staff tremolo should be placed inside curly braces together with
its \change Staff command.
\newPianoStaff<< \newStaff="up"\relativec''{ \keya\major \time3/8 s4. } \newStaff="down"\relativec''{ \keya\major \time3/8 \voiceOne \repeattremolo6{ <ae'>32 { \changeStaff="up" \voiceTwo <cisa'dis>32 } } } >>
Fine-tuning pedal brackets
The appearance of pedal brackets may be altered in different ways.
\paper{ragged-right=##f} \relativec''{ c2\sostenutoOnc c2\sostenutoOffc \once\overrideStaff.PianoPedalBracket.shorten-pair=#'(-7.-2) c2\sostenutoOnc c2\sostenutoOffc \once\overrideStaff.PianoPedalBracket.edge-height=#'(0.3) c2\sostenutoOnc c2\sostenutoOffc }
Indicating cross-staff chords with arpeggio bracket
An arpeggio bracket can indicate that notes on two different staves are
to be played with the same hand. In order to do this, the
PianoStaff must be set to accept cross-staff arpeggios and the
arpeggios must be set to the bracket shape in the PianoStaff
context.
(Debussy, Les collines d’Anacapri, m. 65)
\newPianoStaff<< \setPianoStaff.connectArpeggios=##t \overridePianoStaff.Arpeggio.stencil= #ly:arpeggio::brew-chord-bracket \newStaff{ \relativec'{ \keyb\major \time6/8 b8-.(\arpeggiofis'-.\>cis-. e-.gis-.b-.)\!\fermata^\laissezVibrer\bar"||" } } \newStaff{ \relativec'{ \clefbass \keyb\major << { <aecis>2.\arpeggio } \\ { <a,ea,>2. } >> } } >>
Jazz combo template
This is quite an advanced template, for a jazz ensemble. Note that all
instruments are notated in \key c \major. This refers to the
key in concert pitch; the key will be automatically transposed if the
music is within a \transpose section.
\header{ title="Song" subtitle="(tune)" composer="Me" meter="moderato" piece="Swing" tagline=\markup{ \column{ "LilyPond example file by Amelie Zapf," "Berlin 07/07/2003" } } } % To make the example display in the documentation \paper{ paper-width=130 } %#(set-global-staff-size 16) \include"english.ly" %%%%%%%%%%%% Some macros %%%%%%%%%%%%%%%%%%% sl={ \overrideNoteHead.style=#'slash \hideStem } nsl={ \revertNoteHead.style \undo\hideStem } crOn=\overrideNoteHead.style=#'cross crOff=\revertNoteHead.style %% insert chord name style stuff here. jazzChords={} %%%%%%%%%%%% Keys'n'thangs %%%%%%%%%%%%%%%%% global={\time4/4} Key={\keyc\major} % ############ Horns ############ % ------ Trumpet ------ trpt=\transposecd\relativec''{ \Key c1|c|c| } trpHarmony=\transposec'd{ \jazzChords } trumpet={ \global \cleftreble << \trpt >> } % ------ Alto Saxophone ------ alto=\transposeca\relativec'{ \Key c1|c|c| } altoHarmony=\transposec'a{ \jazzChords } altoSax={ \global \cleftreble << \alto >> } % ------ Baritone Saxophone ------ bari=\transposeca'\relativec{ \Key c1 c1 \sl d4^"Solo"ddd \nsl } bariHarmony=\transposec'a\chordmode{ \jazzChordss1sd2:maje:m7 } bariSax={ \global \cleftreble << \bari >> } % ------ Trombone ------ tbone=\relativec{ \Key c1|c|c } tboneHarmony=\chordmode{ \jazzChords } trombone={ \global \clefbass << \tbone >> } % ############ Rhythm Section ############# % ------ Guitar ------ gtr=\relativec''{ \Key c1 \sl b4bbb \nsl c1 } gtrHarmony=\chordmode{ \jazzChords s1c2:min7+d2:maj9 } guitar={ \global \cleftreble << \gtr >> } %% ------ Piano ------ rhUpper=\relativec''{ \voiceOne \Key c1|c|c } rhLower=\relativec'{ \voiceTwo \Key e1|e|e } lhUpper=\relativec'{ \voiceOne \Key g1|g|g } lhLower=\relativec{ \voiceTwo \Key c1|c|c } PianoRH={ \cleftreble \global << \newVoice="one"\rhUpper \newVoice="two"\rhLower >> } PianoLH={ \clefbass \global << \newVoice="one"\lhUpper \newVoice="two"\lhLower >> } piano={ << \newStaff="upper"\PianoRH \newStaff="lower"\PianoLH >> } % ------ Bass Guitar ------ Bass=\relativec{ \Key c1|c|c } bass={ \global \clefbass << \Bass >> } % ------ Drums ------ up=\drummode{ \voiceOne hh4<hhsn>hh<hhsn> hh4<hhsn>hh<hhsn> hh4<hhsn>hh<hhsn> } down=\drummode{ \voiceTwo bd4sbds bd4sbds bd4sbds } drumContents={ \global << \newDrumVoice\up \newDrumVoice\down >> } %%%%%%%%% It All Goes Together Here %%%%%%%%%%%%%%%%%%%%%% \score{ << \newStaffGroup="horns"<< \newStaff="trumpet"\with{instrumentName="Trumpet"} \trumpet \newStaff="altosax"\with{instrumentName="Alto Sax"} \altoSax \newChordNames="barichords"\with{instrumentName="Trumpet"} \bariHarmony \newStaff="barisax"\with{instrumentName="Bari Sax"} \bariSax \newStaff="trombone"\with{instrumentName="Trombone"} \trombone >> \newStaffGroup="rhythm"<< \newChordNames="chords"\gtrHarmony \newStaff="guitar"\with{instrumentName="Guitar"} \guitar \newPianoStaff="piano"\with{ instrumentName="Piano" midiInstrument="acoustic grand" } \piano \newStaff="bass"\with{instrumentName="Bass"} \bass \newDrumStaff\with{instrumentName="Drums"} \drumContents >> >> \layout{ \context{\Staff\RemoveEmptyStaves} \context{ \Score \overrideBarNumber.padding=#3 \overrideRehearsalMark.padding=#2 skipBars=##t } } \midi{} }
Laissez vibrer ties
Laissez vibrer ties have a fixed size. Their formatting can be tuned
using 'tie-configuration.
\relativec'{ <ceg>4\laissezVibrerr<cfg>\laissezVibrerr <cdfg>4\laissezVibrerr<cdfg>4.\laissezVibrerr8 <cdef>4\laissezVibrerr \overrideLaissezVibrerTieColumn.tie-configuration =#`((-7.,DOWN) (-5.,DOWN) (-3.,UP) (-1.,UP)) <cdef>4\laissezVibrerr }
Piano template (simple)
Here is a simple piano staff with some notes.
upper=\relativec''{ \cleftreble \keyc\major \time4/4 a4bcd } lower=\relativec{ \clefbass \keyc\major \time4/4 a2c } \score{ \newPianoStaff\with{instrumentName="Piano"} << \newStaff="upper"\upper \newStaff="lower"\lower >> \layout{} \midi{} }
Piano template with centered lyrics
Instead of having a full staff for the melody and lyrics, lyrics can be centered between the staves of a piano staff.
upper=\relativec''{ \cleftreble \keyc\major \time4/4 a4bcd } lower=\relativec{ \clefbass \keyc\major \time4/4 a2c } text=\lyricmode{ AaaBeeCeeDee } \score{ \newPianoStaff<< \newStaff=upper{\newVoice="singer"\upper} \newLyrics\lyricsto"singer"\text \newStaff=lower{\lower} >> \layout{} \midi{} }
Piano template with melody and lyrics
Here is a typical song format: one staff with the melody and lyrics, with piano accompaniment underneath.
melody=\relativec''{ \cleftreble \keyc\major \time4/4 abcd } text=\lyricmode{ AaaBeeCeeDee } upper=\relativec''{ \cleftreble \keyc\major \time4/4 a4bcd } lower=\relativec{ \clefbass \keyc\major \time4/4 a2c } \score{ << \newVoice="mel"{\autoBeamOff\melody} \newLyrics\lyricstomel\text \newPianoStaff<< \newStaff="upper"\upper \newStaff="lower"\lower >> >> \layout{ \context{\Staff\RemoveEmptyStaves} } \midi{} }
Removing brace on first line of piano score
This snippet removes the first brace from a PianoStaff or a
GrandStaff.
It may be useful when cutting and pasting the engraved image into existing music.
It uses \alterBroken.
someMusic={ \once\overrideStaff.Clef.stencil=##f \once\overrideStaff.TimeSignature.stencil=##f \repeatunfold3c1\break \repeatunfold5c1\break \repeatunfold5c1 } \score{ \newPianoStaff << \newStaff="right"\relativec''\someMusic \newStaff="left"\relativec'{\clefF\someMusic} >> \layout{ indent=75 \context{ \PianoStaff \alterBrokentransparent#'(#t)SystemStartBrace } } }
Using autochange with more than one voice
Using autochange with more than one voice.
\score { \newPianoStaff << \newStaff="up"{ << \setTiming.beamExceptions=#'() \setTiming.beatStructure=#'(4) \newVoice{ \voiceOne \autoChange \relativec'{ g8abcdefg g,8abcdefg } } \newVoice{ \voiceTwo \autoChange \relativec'{ g8abcdefg g,,8abcdefg } } >> } \newStaff="down"{ \clefbass } >> }
Vocal ensemble template with automatic piano reduction
This template adds an automatic piano reduction to the standard SATB
vocal score demonstrated in “Vocal ensemble template”. This
demonstrates one of the strengths of LilyPond – you can use a music
definition more than once. If any changes are made to the vocal notes
(say, tenorMusic), then the changes will also apply to the piano
reduction.
\paper{ top-system-spacing.basic-distance=#10 score-system-spacing.basic-distance=#20 system-system-spacing.basic-distance=#20 last-bottom-spacing.basic-distance=#10 } global={ \keyc\major \time4/4 } sopMusic=\relative{ c''4cc8[(b)]c4 } sopWords=\lyricmode{ hihihihi } altoMusic=\relative{ e'4fde } altoWords=\lyricmode{ hahahaha } tenorMusic=\relative{ g4afg } tenorWords=\lyricmode{ huhuhuhu } bassMusic=\relative{ c4cgc } bassWords=\lyricmode{ hohohoho } \score{ << \newChoirStaff<< \newLyrics="sopranos"\with{ % This is needed for lyrics above a staff \overrideVerticalAxisGroup.staff-affinity=#DOWN } \newStaff="women"<< \newVoice="sopranos"{\voiceOne<<\global\sopMusic>>} \newVoice="altos"{\voiceTwo<<\global\altoMusic>>} >> \newLyrics="altos" \newLyrics="tenors"\with{ % This is needed for lyrics above a staff \overrideVerticalAxisGroup.staff-affinity=#DOWN } \newStaff="men"<< \clefbass \newVoice="tenors"{\voiceOne<<\global\tenorMusic>>} \newVoice="basses"{\voiceTwo<<\global\bassMusic>>} >> \newLyrics="basses" \contextLyrics="sopranos"\lyricsto"sopranos"\sopWords \contextLyrics="altos"\lyricsto"altos"\altoWords \contextLyrics="tenors"\lyricsto"tenors"\tenorWords \contextLyrics="basses"\lyricsto"basses"\bassWords >> \newPianoStaff<< \newStaff<< \setStaff.printPartCombineTexts=##f \partCombine <<\global\sopMusic>> <<\global\altoMusic>> >> \newStaff<< \clefbass \setStaff.printPartCombineTexts=##f \partCombine <<\global\tenorMusic>> <<\global\bassMusic>> >> >> >> }