The LilyPond Snippet Repository ♪♫

What's this? Searching the LSR Browse by date Contributing Snippet database Browsing items 240−249 out of 940

Combining pedal notes with clef changes

In piano music, you may occasionally come across a staff in which a held (pedal) note is followed by a clef change and further polyphonic notation.

With a little bit of work involving clef settings, you can overcome this problematic situation.

In the first figure, we can see that a clef change in one voice messes with the pedal note in a lower voice; the tie appears to have changed voices.

You can create a fake treble clef which has the properties of a bass clef by overriding the following properties:

\set Staff.clefGlyph = #"clefs.G" - show a G clef

\set Staff.clefPosition = #-2 - set the staff position two half spaces below centre line (i.e., on G)

\set Staff.middleCPosition = #6 - set middle C to the same position as a bass clef

The second figure shows the solution as applied to the final bar of a Wolf lied. The pedal note E flat is followed by a treble clef and a high octave E flat. Since we are effectively still in the bass clef, we have to input the octave E flat as an octave G to produce the required output. Using \tag splits the musical layout and MIDI so you can use \keepWithTag #'midi in a MIDI \score block.

The third figure shows a more extended example from Debussy's L'Isle joyeuse in which the bass clef is faked.

Finally, the fourth figure shows the same Debussy excerpt with an additional feature you may encounter: the pedal note is preceded by a small cautionary clef printed after the barline.

Combining pedal notes with clef changes

Combining two parts on the same staff

The part combiner tool (i.e., the \partCombine command) allows the combination of several different parts on the same staff. Text directions such as solo or a2 are added by default; to remove them, simply set the property printPartCombineTexts to #f.

For vocal scores (hymns), there is no need to add solo/a2 texts, so they should be switched off. However, it might be better not to use them if there are any solos, as they won't be indicated. In such cases, standard polyphonic notation may be preferable.

This snippet presents the three ways two parts can be printed on a same staff: standard polyphony, \partCombine without texts, and \partCombine with texts.

Combining two parts on the same staff

Compare and adjust parts with different volta settings to create a score

If you have a set of parts to build a score, but they differ in the \repeat volta and \alternative layout, it is a good idea to display them parallel in one score, but still isolated.

This is achieved by moving a couple engravers from the Score context to the Staff context.

Compare and adjust parts with different volta settings to create a score

Compilation error on music overflow

When you have multiple overflowing measures, the music flows off the page. This snippet forces an error when this happens by checking the width of each system and checking it against the paper width.

Compilation error on music overflow

Complex compound time signatures

This snippets implements complex compound time signatures (e.g. (1+3)/8 or (1+3)/8 + 2/4). The function \compoundMeter (defined in the snippet) can be used instead of \time to create those time signatures. The argument is a Scheme list of lists. Each list describes one fraction, with the last entry being the denominator, while the first entries describe the summands in the enumerator. If the time signature consists of just one fraction, the list can be given directly, i.e. not as a list containing a single list. For example, a time signature of (3+1)/8 + 2/4 would be created as \compoundMeter #'((3 1 8) (2 4)), and a time signature of (3+2)/8 as \compoundMeter #'((3 2 8)) or shorter \compoundMeter #'(3 2 8). The beat structure (and thus the automatic beaming) will be derived from the given meter automatically.

Complex compound time signatures

Compound time signatures

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 music quite easy to read and play, by explicitly printing the compound time signatures and adapting the automatic beaming behavior.

Compound time signatures

Conducting signs, measure grouping signs

Beat grouping within a measure is controlled by the beatStructure context property. Values of beatStructure are established for many time signatures in file scm/time-signature-settings.scm. Values of beatStructure can be changed or set with \set. Alternatively, \time can be used to both set the time signature and establish the beat structure. For this, you specify the internal grouping of beats in a measure as a list of numbers (in Scheme syntax) before the time signature.

\time applies to the Timing context, so it will not reset values of beatStructure or baseMoment that are set in other lower-level contexts, such as Voice.

If the Measure_grouping_engraver is included in one of the display contexts, measure grouping signs will be created. Such signs ease reading rhythmically complex modern music. In the example, the 9/8 measure is grouped in two different patterns using the two different methods, while the 5/8 measure is grouped according to the default setting in scm/time-signature-settings.scm:

Conducting signs, measure grouping signs

Connecting groups of beamed notes with a single beam

Groups of beamed notes can be connected with a settable number of beams using the stemRightBeamCount and stemLeftBeamCount properties.

Connecting groups of beamed notes with a single beam

Consecutive tremolos

Typing music for many consecutive tremolos with the same base duration becomes tedious. This is a function to make this easier.

By default LilyPond does not unfold tremolo repeats for midi. A function for unfolding only tremolo repeats is also included.

Consecutive tremolos

Consistently left-aligned bar numbers

When left-aligning bar numbers, overlapping problems may occur with staff brackets.

The snippet solves this by keeping the first bar number right-aligned that follows a line break.

Consistently left-aligned bar numbers

⇦ Previous 21 22 23 24 25 26 27 28 29 30 Next ⇨