Next: Expressive marks, Previous: Pitches, Up: Top
adding-beams,-slurs,-ties-etc.-when-using-tuplet-and-non-tuplet-rythms..ly
LilyPond syntax can involve many unusual placements for parentheses, brackets etc., which might sometimes have to be interleaved.For example, when entering a manual beam, the left square bracket has to be placed after the starting note and its duration, not before. Similarly, the right square bracket should directly follow the note which is to be at the end of the requested beaming, even if this note happens to be inside a tuplet section. This snippet demonstrates how to superpose manual beaming, manual slurs, ties, and phrasing slurs, while using tuplet sections (enclosed with curly braces).
{ r16[ g16 \times 2/3 {r16 e'8] } g16( a \times 2/3 {b d e') } g8[( a \times 2/3 {b d') e'~]} \times 4/5 {e'32\( a b d' e'} a'4.\) }
LilyPond makes drums input quite easy, with powerful pre-configured tools such as the \drummode function and the DrumStaff context: drums are placed to their own staff positions (with a special clef symbol) and have note heads according to the drum. You can easily attach an extra symbol to the drum, and restrict the number of lines.
drh = \drummode { cymc4.^"crash" hhc16^"h.h." hh \repeat "unfold" 5 {hhc8 hho hhc8 hh16 hh} hhc4 r4 r2 } drl = \drummode {\repeat "unfold" 3 {bd4 sn8 bd bd4 << bd ss >> } bd8 tommh tommh bd toml toml bd tomfh16 tomfh } timb = \drummode { \repeat "unfold" 2 {timh4 ssh timl8 ssh r timh r4 ssh8 timl r4 cb8 cb} } \score { \repeat "volta" 2 { << \new DrumStaff \with { drumStyleTable = #timbales-style \override StaffSymbol #'line-count = #2 \override BarLine #'bar-size = #2 } << \set Staff.instrumentName = "timbales" \timb >> \new DrumStaff << \set Staff.instrumentName = "drums" \new DrumVoice {\stemUp \drh } \new DrumVoice {\stemDown \drl } >> >> } \layout {} \midi { \context { \Score tempoWholesPerMinute = #(ly:make-moment 120 4) } } }
altering-the-number-of-stems-in-a-beam.ly
You can alter the number of stems in a beam. In this example, two sets of four 32nds are joined, as if they were 8th notes.
\relative { #(override-auto-beam-setting '(end * * * *) 1 4) f32 g a b b a g f f32 g a \set stemRightBeamCount = #1 b \set stemLeftBeamCount = #1 b a g f }
automatic-beam-subdivisions.ly
Lilypond can subdivide beams automatically. Set the property subdivideBeams, and beams are subdivided at beat positions (as specified in beat length)
\relative{ b'32^"default"[ a g f c' b a g f e d' c b a g f ] \set subdivideBeams = ##t b32^"subdivision enabled"[ a g f c' b a g f e d' c b a g f ] \set Score.beatLength = #(ly:make-moment 1 8) b32^"beatLength 1 8"[ a g f c' b a g f e d' c b a g f ] \set Score.beatLength = #(ly:make-moment 1 16) b32^"beatLength 1 16"[ a g f c' b a g f e d' c b a g f ] }
automatic-beams-two-per-two-in-4-4-or-2-2-time-signature.ly
In time signature 2/2 or 4/4 the beam are _____
_ _ Default | | | | I want | | | |.
Use a "macro" with
#(override-auto-beam-setting '.....
% Automatic beams two per two in 4/4 or 2/2 time signature % _____ % Default | | | | % _ _ % I want | | | | % The good way adapted from David Bobrof % macro for beamed two per two in 2/2 and 4/4 time signature qbeam={ #(override-auto-beam-setting '(end 1 8 * *) 1 4 'Staff) #(override-auto-beam-setting '(end 1 8 * *) 2 4 'Staff) #(override-auto-beam-setting '(end 1 8 * *) 3 4 'Staff) } % other macros timeFractionstyle={ \override Staff.TimeSignature #'style = #'()} textn = ^\markup{ without the macro } texty = ^\markup{ with the macro } \score { << \new Staff << \relative c'' { \timeFractionstyle \time 4/4 g8\textn g g g g g g g g g g g4 g8 g g } >> %Use the macro \new Staff << \relative c'' { \timeFractionstyle \time 4/4 \qbeam g8\texty g g g g g g g g g g g4 g8 g g } >> >> \layout{ raggedright = ##t } }
By default, beams can't be printed across line breaks. Here's a way to
force the line break, by setting the #'breakable
property. See
also in the manual the "Line Breaking" and "Manual beams" sections.
\layout { ragged-right= ##t } \relative c'' { \override Score.Beam #'breakable = ##t \time 3/16 c16-[ d e \break f-] }
changing-time-signatures-inside-a-polymetric-section-using--compressmusic.ly
The measureLength variable, together with measurePosition, determines when a barline is needed. However, when using \compressMusic, the scaling of durations makes it difficult to change time signatures without making a mess of it.
Therefore, measureLength has to be set manually, using the ly:make-moment callback. The second argument has to be the same as the second argument of \compressMusic.
\layout { \context { \Score \remove "Timing_translator" \remove "Default_bar_line_engraver" } \context { \Staff \consists "Timing_translator" \consists "Default_bar_line_engraver" } } << \new Staff { \compressMusic #'( 8 . 5 ) { \time 6/8 \set Timing.measureLength = #(ly:make-moment 3 5) b8 b b b b b \time 2/4 \set Timing.measureLength = #(ly:make-moment 2 5) b4 b } } \new Staff { \clef bass \time 2/4 c2 d e f } >>
This form of notation is used for the chant of the Psalms, where verses aren't always the same length.
stemon = { \override Staff.Stem #'transparent = ##f } stemoff = { \override Staff.Stem #'transparent = ##t } \score { \new Staff \with {\remove "Time_signature_engraver" } { \key g \minor \set Score.timing = ##f \stemoff a'\breve bes'4 g'4 \stemon a'2 \bar "||" \stemoff a'\breve g'4 a'4 \stemon f'2 \bar "||" \stemoff a'\breve^\markup { \italic flexe } \stemon g'2 \bar "||" } \layout { raggedright = ##t} }
Odd 20th century time signatures (such as "5/8") can often be played as compound time signatures (e.g. "3/8 + 2/8"), which combine two or more inequal metrics. LilyPond can make such musics quite easy to read and play, by explicitly printing the compound time signatures and adapting the automatic beaming behaviour. (You can even add graphic measure grouping indications, see the appropriate snippet in this database.)
#(define (compound-time one two num) (markup #:override '(baseline-skip . 0) #:number (#:line ((#:column (one num)) #:vcenter "+" (#:column (two num)))))) \relative { %% compound time signature hack \time 5/8 \override Staff.TimeSignature #'stencil = #ly:text-interface::print \override Staff.TimeSignature #'text = #(compound-time "2" "3" "8" ) #(override-auto-beam-setting '(end 1 8 5 8) 1 4) c8 d e fis gis | c fis, gis e d | c8 d e4 gis8 }
conducting-signs,-measure-grouping-signs.ly
The Scheme function set-time-signature
, in combination with the
Measure grouping engraver, it will create MeasureGrouping signs. Such
signs ease reading rhythmically complex modern music. In the following
example, the 9/8 measure is subdivided in 2, 2, 2 and 3. This is
passed to set-time-signature
as the third argument (2 2 2
3)
\score { \relative c'' { #(set-time-signature 9 8 '(2 2 2 3)) g8[ g] d[ d] g[ g] a8[( bes g]) | #(set-time-signature 5 8 '(3 2)) a4. g4 } \layout { \context { \Staff \consists "Measure_grouping_engraver" } } }
controlling-tuplet-bracket-visibility.ly
Default behaviour of tuplet-bracket visibility is to print a bracket unless there is a beam of the same length as the tuplet. To control the visibility of tuplet brackets, you can set the property TupletBracket #'bracket-visibility to either ##t (always print a bracket), ##f (never print a bracket) or #'if-no-beam (only print a bracket if there is no beam).
mus = \relative c'' { \times 2/3 {c16 [ d e } f8] \times 2/3 {c8 d e } \times 2/3 { c4 d e } } \new Voice \relative c'{ << \mus s4^"default" >> \override TupletBracket #'bracket-visibility = #'if-no-beam << \mus s4^"'if-no-beam" >> \override TupletBracket #'bracket-visibility = ##t << \mus s4^"#t" >> \override TupletBracket #'bracket-visibility = ##f << \mus s4^"#f" >> }
entering-several-tuplets-using-only-one--times-command.ly
This example shows how to specify how long each of the tuplets
contained within the bracket after \times
should last. Many
consecutive tuplets can then be contained within a single \times
{ ... }
, thus saving typing.
In the example, two triplets are shown, while \times
was
entered only once.
For more information about make-moment
, see "Time
administration".
\relative { \set tupletSpannerDuration = #(ly:make-moment 1 4) \times 2/3 { c8 c c c c c } }
forcing-rehearsal-marks-to-start-from-a-given-letter-or-number.ly
This snippet demonstrates how to obtain automatic ordered rehearsal marks, but from the letter or number you want.
\relative c''{ c1 \mark \default c1 \mark \default c1 \mark \default c1 \mark #14 c1 \mark \default c1 \mark \default c1 \mark \default c1 \mark \default \break \set Score.markFormatter = #format-mark-numbers c1 \mark #1 c1 \mark \default c1 \mark \default c1 \mark \default c1 \mark #14 c1 \mark \default c1 \mark \default c1 \mark \default c1 \mark \default }
heavily-customized-polymetric-time-signatures.ly
Though the set-time-signature thing was not the most essential here, it has been included to show the beat of this piece (which is a template of a real balkan song!).
#(define (compound-time one two three four five six seven eight nine ten num) (markup #:override '(baseline-skip . 0) #:number (#:line ((#:column (one num)) #:vcenter "+" (#:column (two num)) #:vcenter "+" (#:column (three num)) #:vcenter "+" (#:column (four num)) #:vcenter "+" (#:column (five num)) #:vcenter "+" (#:column (six num)) #:vcenter "+" (#:column (seven num)) #:vcenter "+" (#:column (eight num)) #:vcenter "+" (#:column (nine num)) #:vcenter "+" (#:column (ten num)))))) melody = { \relative c'' { \set Staff.instrumentName = "Bb Sop." \key g \major \time 25/8 \override Staff.TimeSignature #'stencil = #ly:text-interface::print \override Staff.TimeSignature #'text = #(compound-time "3" "2" "2" "3" "2" "2" "2" "3" "2" "2" "8" ) c8[ c c] d4 c8[ c] b[ c b] a4 g fis8[ e d c] b'[ c d] e4-^ fis8[ g] | \break c,4. d4 c4 d4. c4 d c2 d4. e4-^ d4 | c4. d4 c4 d4. c4 d c2 d4. e4-^ d4 | \break c4. d4 c4 d4. c4 d c2 d4. e4-^ d4 | c4. d4 c4 d4. c4 d c2 d4. e4-^ d4 | \break } } drum = { \new DrumStaff \drummode { \bar "|:" bd4. ^\markup { "Drums" } sn4 bd \bar ":" sn4. bd4 sn \bar ":" bd sn bd4. sn4 bd \bar ":|" } } { \melody \drum }
making-an-object-invisible-with-the-transparent-property.ly
Setting the transparent
property will cause an object to be
printed in `invisible ink': the object is not printed, but all its
other behavior is retained. The object still takes up space, it takes
part in collisions, and slurs, and ties and beams can be attached to it.
The snippet demonstrates how to connect different voices using ties. Normally, ties only connect two notes in the same voice. By introducing a tie in a different voice, and blanking the first up-stem in that voice, the tie appears to cross voices.
\relative c'' << { \once \override Stem #'transparent = ##t b8~ b8\noBeam } \\ { b[ g8] } >>
manually-controlling-beam-positions.ly
Beam positions may be controlled manually, by overriding the
positions
setting of the Beam
grob.
\score { \context Voice \relative c { %% from upper staffline (position 4) to centre (position 0) \override Beam #'positions = #'(2 . 0) c'8[ c] %% from center to one above centre (position 2) \override Beam #'positions = #'(0 . 1) c[ c] } }
printing-music-with-different-time-signatures.ly
In the following snippet, two parts have a completely different time signature, and yet keep synchronized.
This can be achieved with the \compressMusic command, as demonstrated here.
The barlines can't be printed at the Score level anymore, so you have to remove the Barline_engraver and put it in the Staff context.
% Thanks to Adam James Wilson for this snippet \paper { indent = #0 ragged-right = ##t } global = { \time 3/4 { s2. * 3 } \bar "" \break { s2. * 3 }} \layout { \context { \Score \remove "Timing_translator" \remove "Time_signature_engraver" \remove "Default_bar_line_engraver" \override SpacingSpanner #'uniform-stretching = ##t \override SpacingSpanner #'strict-note-spacing = ##t proportionalNotationDuration = #(ly:make-moment 1 64) } \context { \Staff \consists "Timing_translator" \consists "Default_bar_line_engraver" \consists "Time_signature_engraver" } \context { \Voice \remove Forbid_line_break_engraver tupletFullLength = ##t } } Bassklarinette = \new Staff << \global { \bar "|" \clef treble \time 3/8 d''4. \bar "|" \time 3/4 r8 des''2( c''8) \bar "|" \time 7/8 r4. ees''2 ~ \bar "|" \time 2/4 \tupletUp \times 2/3 {ees''4 r4 d''4 ~} \bar "|" \time 3/8 \tupletUp \times 3/4 {d''4 r4} \bar "|" \time 2/4 e''2 \bar "|" \time 3/8 es''4. \bar "|" \time 3/4 r8 d''2 r8 \bar "|" } >> Perkussion = \new StaffGroup << \new Staff << \global { \bar "|" \clef percussion \time 3/4 r4 c'2 ~ \bar "|" c'2. \bar "|" R2. \bar "|" r2 g'4 ~ \bar "|" g'2. ~ \bar "|" g'2. } >> \new Staff << \global { \bar "|" \clef percussion \time 3/4 R2. \bar "|" g'2. ~ \bar "|" g'2. \bar "|" r4 g'2 ~ \bar "|" g'2 r4 \bar "|" g'2. } >> >> \score { << \Bassklarinette \Perkussion >> }
Rests may be used in various styles.
\layout { indent = 0.0 raggedright = ##t } \context Staff \relative c { \set Score.timing = ##f \override Staff.Rest #'style = #'mensural r\maxima^\markup \typewriter { mensural } r\longa r\breve r1 r2 r4 r8 r16 r32 r64 r128 r128 \bar "" \override Staff.Rest #'style = #'neomensural r\maxima^\markup \typewriter { neomensural } r\longa r\breve r1 r2 r4 r8 r16 r32 r64 r128 r128 \bar "" \override Staff.Rest #'style = #'classical r\maxima^\markup \typewriter { classical } r\longa r\breve r1 r2 r4 r8 r16 r32 r64 r128 r128 \bar "" \override Staff.Rest #'style = #'default r\maxima^\markup \typewriter { default } r\longa r\breve r1 r2 r4 r8 r16 r32 r64 r128 r128 }
In "simple" lead-sheets, sometimes no actual notes are written, instead only "rhythmic patterns" and chords above the measures are noted giving the structure of a song. Such a feature is for example useful while creating/transcribing the structure of a song and also when sharing lead sheets with guitarists or jazz musicians.
The standard support for this is described in section "Measure repeats", but then the first beat has to be an ordinary note or rest.
This example shows two solutions to this problem, by redefining ordinary rests to be printed as slashes. (If the duration of each beat is not a quarter note, replace the r4 in the definitions by a rest of the appropriate duration).
% Macro to print single slash rs = { \once \override Rest #'stencil = #ly:percent-repeat-item-interface::beat-slash \once \override Rest #'thickness = #'0.48 \once \override Rest #'slope = #'1.7 r4 } % Function to print a specified number of slashes comp = #(define-music-function (parser location count) ( integer?) #{ \override Rest #'stencil = #ly:percent-repeat-item-interface::beat-slash \override Rest #'thickness = #'0.48 \override Rest #'slope = #'1.7 \repeat unfold $count { r4 } \revert Rest #'stencil #} ) \score{ \relative c'{ c d e f | \rs \rs \rs \rs | \comp #4 | } }
Although you can't use `s' in lyric mode (it's taken to be a literal s, not a space) you can use either "" or _.
So for example:
<< \relative c'' { a4 b c d } \new Lyrics \lyricmode { a4 _2 gap4 } >>
The s syntax is only available in note mode and chord mode. In other situations, for example, when entering lyrics, you should use the \skip command.
<< \relative { a'2 a1 } \new Lyrics \lyricmode { \skip 2 bla1 } >>
Next: Expressive marks, Previous: Pitches, Up: Top
This page is for LilyPond-2.11.40 (development-branch).
Report errors to http://post.gmane.org/post.php?group=gmane.comp.gnu.lilypond.bugs.
Your suggestions for the documentation are welcome.