The LilyPond Snippet Repository ♪♫

What's this? Searching the LSR Browse by title Contributing Snippet database Browsing items 170−179 out of 940

Aligning and centering instrument names

The horizontal alignment of instrument names is tweaked by changing the Staff.InstrumentName.self-alignment-X property. The \layout variables indent and short-indent define the space in which the instrument names are aligned before the first and the following systems, respectively.

Aligning and centering instrument names

Automatic spacing behavior

By default, LilyPond takes stem directions and head positions into account to correctly handle optical spacing. This feature is what makes LilyPond-engraved scores so beautiful to see, to read, and to play :-)

Automatic spacing behavior

Creating text spanners

The \startTextSpan and \stopTextSpan commands allow the creation of text spanners as easily as pedal indications or octavations. Override some properties of the TextSpanner object to modify its output.

Creating text spanners

Time Signatures on top of the score using a separate staff

In 20th century music, where time signatures tend to change a lot, it is sometimes recommended to put the time signatures on top of the score (or above each StaffGroup in the case of an orchestral score). This can be achieved by creating a dummy staff which only contains the Time_signature_engraver.

In this specific example, a separate identifier is used to define every time signature change, which saves the bother of entering them again when typing the actual music (careful though: it makes getting lost easier!).

Notice the overriding of the X-offset property: a specific trick to make the time signatures align with the barlines, thanks to Han-Wen.

Time Signatures on top of the score using a separate staff

Using a custom \elseTag command to replace several \tag commands

The purpose of the \elseTag command is to make the use of tagged music easier.

This exemple shows the same music, without and with \elseTag.

In the old manner (first exemple), you have to write all the tag names you want,and to omit only the one you don't want.

In the second exemple, \elseTag exclude automatically the tag you don't want, and keep all the others.

\elseTag has the same syntaxe than \tag and has to be use in conjonction with \keepWithTag.

Using a custom \elseTag command to replace several \tag commands

Displaying grob ancestry

When working with grob callbacks, it can be helpful to understand a grob's ancestry. Most grobs have parents which influence the positioning of the grob. X- and Y-parents influence the horizontal and vertical positions for the grob, respectively. Additionally, each parent may have parents of its own.

Unfortunately, there are several aspects of a grob's ancestry that can lead to confusion:

For example, the System grob can be both parent (on the Y-side) and grandparent (twice on the X-side) to a VerticalAlignment grob.

This macro prints (to the console) a textual representation of a grob's ancestry.

When called this way:

{ \once \override NoteHead.before-line-breaking = #display-ancestry c }

The following output is generated:

NoteHead
X,Y: NoteColumn
     X: PaperColumn
        X,Y: System
     Y: VerticalAxisGroup
        X: NonMusicalPaperColumn
           X,Y: System
        Y: VerticalAlignment
           X: NonMusicalPaperColumn
              X,Y: System
           Y: System

Displaying grob ancestry

Marking notes of spoken parts with a cross on the stem (Sprechstimme)

This example shows how to put crosses on stems. Mark the beginning of a spoken section with the \speakOn keyword, and end it with the \speakOff keyword.

Marking notes of spoken parts with a cross on the stem (Sprechstimme)

Extracting unmodified fragments of a music expression

This snippet provides an \extractMusic function that can be used as follows:
\extractMusic music from during
For example, in the second Staff of the score below, the following has been used :
\extractMusic \music s1 s1*2
This has kept the music beginning after the first measure (i.e., at the second measure) for two measures.

All data (notes, scripts, dynamics and various \overrides) outside this range have been deleted.

Note that this function should also work with multiple voices, \repeat structures etc.

A full and updated version of \extractMusic can be found here. There are some additional useful features and other enhancement functions on that page, with a description of each of them in a small document (in pdf format) with multiple voices, \repeat structures etc.

Extracting unmodified fragments of a music expression

Automatic beam subdivisions

Beams can be subdivided automatically. By setting the property subdivideBeams, beams are subdivided at beat positions (as specified in baseMoment).

Automatic beam subdivisions

Changing the size of note heads

It is possible to change the fontsize of note heads.

Changing the size of note heads

⇦ Previous 11 12 13 14 15 16 17 18 19 20 Next ⇨