The LilyPond Snippet Repository ♪♫

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

Inserting large plain text sections, as independent \markup blocks

LilyPond can handle text almost as well as music notation: in a \book block, you can enter different \score blocks, but also independent \markup sections. This snippet also demonstrates some interesting text formatting features such as \justify-string or \wordwrap-string (do not forget the # character when using them). The \fill-line command produces centered text, and you can define margins using \override #'(line-width . X), where X is the width in staff spaces.

Inserting large plain text sections, as independent \markup blocks

Creating a sequence of notes on various pitches

In music that contains many occurrences of the same sequence of notes at different pitches, the following music function may prove useful. It takes a note, of which only the pitch is used.

This example creates the rhythm used throughout Mars, from Gustav Holst's The Planets.

Creating a sequence of notes on various pitches

Changing \flageolet mark size

To make the \flageolet circle smaller use the following tweak.

As of 2.23.12 the \flageolet is smaller by default, thus this snippet will be deleted with next LSR upgrade.

Changing \flageolet mark size

PianoStaff without Braces

Sometimes you want to encode staffs without braces which has the effect that the bar lines are aligned.

See also snippet 873: Vertical aligned StaffGroups without connecting SystemStartBar

PianoStaff without Braces

Forcing visibility of systems with multi-bar rests when using \RemoveEmptyStaffContext

In an orchestral score, you may find it useful to hide multi-bar rests using \RemoveEmptyStaffContext to produce a Frenched score, but this can prove problematic when you want to make such bars visible.

For example, imagine you are using a PianoStaff for a harp part. When there is music in one stave, you will want both staves to be visible. Of course, adding hidden notes to the invisible staff will make the stave visible, but this is a rather ugly kludge.

A more elegant solution is to use the property keepAliveInterfaces. This determines which items of musical output are interesting enough to keep a bar visible when remove-empty is set. By default, it looks like this:

keepAliveInterfaces = #'( rhythmic-grob-interface lyric-interface stanza-number-interface percent-repeat-interface)

If you insert multi-measure-rest-interface into this list, multi-bar rests count as interesting items. You can then create macros to switch this behaviour on and off as required:

showMultiRests = { \set Staff.keepAliveInterfaces = #'( rhythmic-grob-interface multi-measure-rest-interface lyric-interface stanza-number-interface percent-repeat-interface) }

hideMultiRests = \unset Staff.keepAliveInterfaces

For this to work successfully, you must place these macros carefully, otherwise they tend to interfere with the visibility of other hidden staves.

Forcing visibility of systems with multi-bar rests when using \RemoveEmptyStaffContext

Putting parentheses around a single note

Objects may be parenthesized by prefixing \parenthesize to the music event: in other words, the note has to be put after the \parenthesize command.

This only functions inside chords; to parenthesize a single note it must be enclosed with as if it is a chord.

Putting parentheses around a single note

Adding parentheses around an expressive mark or chordal note

The \parenthesize function is a special tweak that encloses objects in parentheses. The associated grob is ParenthesesItem.

Adding parentheses around an expressive mark or chordal note

Showing barlines (SpanBars) only between systems

Span bars are drawn only between staff bar lines. By setting bar lines to transparent, they are shown only between systems.

Showing barlines (SpanBars) only between systems

Volta text markup using repeatCommands

Though volte are best specified using \repeat volta, the context property repeatCommands must be used in cases where the volta text needs more advanced formatting with \markup.

Since repeatCommands takes a list, the simplest method of including markup is to use an identifier for the text and embed it in the command list using the Scheme syntax #(list (list 'volta textIdentifier)). Start- and end-repeat commands can be added as separate list elements:

Volta text markup using repeatCommands

Shorthand for triplets

If you have lots of triplets and want to save some typing, you can define your own \triplet command. This is a simple illustration of how to define your own Scheme function with embedded LilyPond code. The example shows two possible implementations, one (\triplet) where you have to enclose the triplet notes withing curly braces and one (\trip) that takes the following three music expressions and combines them into a triplet. The latter alternative saves even more typing, since you don't need the curly braces. On the other hand, it makes the input file slightly harder to read and if you have a triplet with more than three notes (see the example) you need to add some curly braces to get exactly three arguments to the function.

Shorthand for triplets

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