+.ly

0.1 Introduction

This document shows all kinds of tips and tricks, from simple to advanced. You may also find dirty tricks, or the very very latest features that have not been documented or fully implemented yet. This document is for LilyPond version 2.2.6.

[image of music]

add-staccato.ly

Using make-music, you can add various stuff to notes. In this example staccato dots are added to the notes. For this simple case, it is not necessary to use scm constructs (see separate-staccato.ly).

[image of music]

add-text-script.ly

You can add various stuff to notes using make-music. In this example, an extra fingering is attached to a note.

In general, first do a display of the music you want to create, then write a function that will structure the music for you.

[image of music]

ambitus-mixed.ly

The showing of ambituses can be switched off or they can be shifted horizontally by using applyoutput.

If you want to mix per-voice and per-staff ambituses, then you have to define new context type derived from the Voice or Staff context. The derived context must contain the Ambitus_engraver and it must be accepted by a proper parent context, which are respectively the Staff context or Score context in the example below. The original context and the derived context can then be used in parallel in the same score (not demonstrated in this file).

[image of music]

ancient-accidentals.ly

Accidentals are available in different ancient styles, which all are collected here.

[image of music]

ancient-font.ly

Here are shown many (all?) of the symbols that are included in LilyPond's support of ancient notation.

[image of music]

ancient-time.ly

Time signatures may also be engraved in an old style.

[image of music]

bagpipe.ly

Here's an example of bagpipe music.

[image of music]

bar-always.ly

By setting barAlways and defaultBarType, barlines may be inserted automatically everywhere.

[image of music]

bar-lines-lyric-only.ly

You can move Bar_engraver and Span_bar_engraver to a different engraving context, if you want, for example, bar lines on lyrics.

[image of music]

bar-lines.ly

There a many types of bar lines available.

[image of music]

bar-number-every-five-reset.ly

If you would like the bar numbers to appear at regular intervals, but not starting from measure zero, you can use a context function, set-bar-number-visibility, to set automatically barNumberVisibility, so that the bar numbers appear at regular intervals, starting from the measure in which set-bar-number-visibility is set using \applycontext.

[image of music]

bar-number-regular-interval.ly

Bar numbers can also be printed inside boxes.

[image of music]

bar-number-show-all.ly

By default, bar numbers are printed only in the first measure. This setting can be overridden, so that bar numbers on start of every measure.

[image of music]

beam-alternate.ly

The eighth notes may be seemingly attached to different beams, and the corresponding notes connected by ties (see also tie-cross-voice.ly). Such a situation may occur, for example, in the cello suites.

[image of music]

beam-auto-4-8.ly

You can override the automatic beaming settings.

[image of music]

beam-auto-override.ly

The auto-beamer, which can be overridden, will only engrave beams that end before encountering of

The autoBeaming can also be turned off.

[image of music]

beam-auto.ly

There are presets for the auto-beam engraver in the case of common time signatures.

[image of music] [image of music]

beam-control.ly

Beam positions may be controlled manually, by overriding the positions setting of the Beam grob.

[image of music]

beam-count.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.

[image of music]

beam-dir-functions.ly

The direction of a beam may be calculated in several ways. As shown in the example, the beam are be below the notes if:

majority
of (individual) notes would have down stems,
mean
of note pitches is on the center line or below it, or
median
of note pithes (i.e. the centermost element of ordered pitches) is on the center line or below it.

If your favourite algorithm is not one of these, you can hook up your own one. (These beam direction functions are defined in scm/beam.scm.)

[image of music]

beam-isknee.ly

Beams can be placed across a PianoStaff.

[image of music]

beam-neutral-direction.ly

When a beam falls in the middle of the staff, the beams point normally down. However, this behaviour can be altered, if desired.

[image of music]

beam-rest.ly

Beams may be forced to be over rests.

[image of music]

blank-notes.ly

Invisible (or transparent) can be useful, when wierd tricks are needed; especially, a slur cannot be attach to a rest or spacer rest.

[image of music]

blank-paper-tab.ly

A blank music paper can be produced by using spacer rests, and removing Bar_number_engraver. Here is an empty staff with a tablature staff.

[image of music]

blank-paper.ly

A blank music paper can be produced also by using invisible notes, and removing Bar_number_engraver.

[image of music]

boxed-molecule.ly

The print-function can be overridden to draw a box around an arbitrary grob.

[image of music]

cadenza-skip.ly

A second staff can be aligned to a fragment (say, a cadenza) from the first staff, using a Scheme function: the function creates a skip of the same length as the cadenza.

[image of music]

caps.ly

The font can be changed to small caps.

[image of music]

cautionaries.ly

Cautinary accidentals are displayed in slurs by default. They can be shown also with accidentals of smaller size.

[image of music]

chord-names-german.ly

The english naming of chords (default) can be changed to german (\germanChords replaces B and Bes to H and B) or semi-german (\semiGermanChords replaces B and Bes to H and Bb).

[image of music]

chord-names-jazz.ly

Chord names are generated from a list pitches. The functions which construct these names can be customised. Here are shown Jazz chords, following Ignatzek (pp. 17-18, 1995) and an alternative Jazz chord notation.

Chords following Banter (1987) can also be printed from this file, but are turned off for brevity.

[image of music] [image of music] [image of music]

chord-names-no-inversions.ly

Since there are several interpretations for recognizing chord names, the lowest note is the bass note of a chord and the inversion of the chord is found accordingly.

[image of music]

chords-without-melody.ly

Jazz chord names can also be printed without notes.

[image of music]

clef-8-syntax.ly

Appending _8 or ^8 to a clef name will add an octavation sign to the clef; then the clef name is given in quotes (such as "treble^8").

[image of music]

clef-end-of-line.ly

In these scales, the clef and key signature are shown at the end of the line.

[image of music]

clef-manual-control.ly

The positioning of glyph and note can be separated. \clef is a front-end, which keeps them together. All the notes in this example are central C.

[image of music]

coriolan-margin.ly

In an orchestral score (Beethoven's Coriolan overture), there are different instrument groups, and some of the instruments may be transposed. Instruments are indicated either with a long or short name.

[image of music] [image of music]

count-systems.ly

After a line break, some function may called by overriding after-line-breaking-callback. This can be most useful to assertain that a piece uses a specified number of lines; typically the number of lines (or systems) is not engraved, but it can be printed to console when generating the output. The number of lines may be associated either to the number of systems or the system number of a grob.

[image of music]

crescendi.ly

Crescendi can be printed in a number of different ways.

[image of music]

cue-notes.ly

Cue notes are typeset in a smaller font.

[image of music]

divisiones.ly

Divisiones are gregorian variants of breathing signs. Choices are divisioMinima, divisioMaior, divisioMaxima and finalis, virgula and caesura.

[image of music]

drarn-slurs.ly

Slurs can be forced to always attach to note heads.

[image of music]

drarn.ly

You can attach slurs and ties to noteheads.

[image of music]

dynamic-absolute-volume.ly

Absolute dynamics have an effect on MIDI files.

[image of music]

dynamic-extra.ly

Pił forte dynamics is produced using \markup.

[image of music]

embedded-postscript.ly

By inserting the TeX command \embeddedps, you can insert postscript directly into the output.

[image of music]

embedded-scm.ly

You can embed scheme functions in your scores. While generating the output, “hello world” is printed to the console.

[image of music]

embedded-tex.ly

You can embed Tex commands in your score.

[image of music]

engraver-contexts.ly

In polyphonic notation, many voices can share a staff: In this situation, the accidentals and staff are shared, but the stems, slurs, beams, etc. are private to each voice. Hence, engravers should be grouped. The engravers for note head, stems, slurs, etc. go into a group called “Voice context”, while the engravers for key, accidental, bar, etc. go into a group called “Staff context”. In the case of polyphony, a single Staff context contains more than one Voice context. Similarly, more Staff contexts can be put into a single Score context.

[image of music]

engraver-one-by-one.ly

The notation problem, creating a certain symbol, is handled by plugins. Each plugin is called Engraver. In this example, engravers is switched on one by one, in the following order:

Engravers are grouped. For example, note heads, slurs, beams etc. form a Voice context. Engravers for key, accidental, bar, etc. form a Staff context.

[image of music]

extra-staff.ly

You can add (possibly temporarily) an extra staff after the beginning of a piece.

[image of music]

figured-bass-alternate.ly

An alternate method to make bass figures is to use markup texts.

[image of music]

fill-a4.ly

This should fill a4 paper.

[image of music] [image of music]

follow-voice.ly

Voices can be traced automatically when they switch staves by setting followVoice.

[image of music]

force-hshift.ly

Horizontal shift (hshift) can be forced in order to avoid collisions.

[image of music]

gourlay.ly

The breaking of line works also with polyphony. This is taken from Gourlay's paper on breaking lines.

[image of music]

gregorian-scripts.ly

Here is demonstrated a preliminary support of Gregorian Scripts:

ictus, circulus, semicirculus, accentus, episem.

[image of music]

harmonic.ly

Artificial harmonics are notated with a different notehead style, by marking the harmonic pitch with \harmonic.

[image of music]

header-ifelse.ly

High level functionality (eg. conditional defines), can be accomplished with GUILE.

This example puts the current version in the tagline via Scheme, however, the tagline is not printed to the collated webpage snippets.

[image of music]

hshift.ly

Notes may be manually horizontally shifted.

[image of music]

hymn.ly

You can combine two parts on the same staff using the part combiner. For vocal scores (hymns), there is no need to add solo/a2 texts, so they should be switched off.

[image of music]

improv.ly

In improvisation, noteheads do not have a pitch, and have different shapes. In this example, this is achieved by adding Pitch_squash_engraver and setting squashedPosition when the improvisation is active.

[image of music]

incipit.ly

This example shows how to make an “incipit” to indicate scordatora tuning of a violin part, by overriding the style of a TimeSignature. Here are the two first bars of Biber's Rosary sonata III.

[image of music]

instrument-name-grandstaff.ly

You can have a name for the whole GrandStaff in addition to individual Staffs.

[image of music]

ligature-vaticana.ly

Vaticana ligature uses four staff lines, special clef, an notes calligraphic notes.

[image of music]

lilypond-testpage.ly

In the generated output for printing, there are several titles which do not appear in the web pages.

[image of music]

lyric-hyphen-retain.ly

In tightly engraved music, hyphens are removed, except at the end of the line. Normally, lyrics are not typeset so tightly, but by tuning down padding of in SeparationItem, syllables are put closer together, and as a result hyphens may disappear.

In some languages (e.g. German and Hungarian), hyphens should not disappear, since spelling depends on hyphenation. For that purpose, hyphens can be forced to remain by overriding minimum-length of the LyricHyphen grob.

[image of music]

lyrics-skip-notes.ly

By inserting \skip statements into lyric lines, one can attach less lyric syllables to a melody.

[image of music]

mensural-ligatures.ly

In mensural ligatures, notes with ancient durations are printed in a tight manner.

[image of music]

mensural-note-heads.ly

Mensural notes may also have note heads.

[image of music]

midi-scales.ly

Converting LilyPond input to MIDI and then again back with midi2ly.py is a reversible procedure in some simple cases, which mean that the original .ly -file and the one converted back from the generated .midi -file do not differ. Here are produced some scales.

[image of music] [image of music]

move-accidentals.ly

The positions of accidentals may be manually set by incorporating some Scheme code.

[image of music]

move-specific-text.ly

Objects, like text, can be moved around by using some Scheme code.

[image of music]

music-box.ly

This example shows prelude in C major of WTK1, but coded using Scheme functions to avoid typing work.

[image of music]

music-creation.ly

You can engrave music using just Scheme expressions. Although those expressions reflect the inner mechanism of LilyPond, they are rather clumsy to use, so avoid them, if possible.

[image of music]

no-bar-lines.ly

Engravers can be removed one by one. Here, the time signature and bar lines have been removed.

[image of music]

no-key-at-end-of-line.ly

According to normal typesetting conventions, LilyPond typesets key changes at the end of the line, when the change appears at a line break. This example shows how to change this default to only print the new key signature at the beginning of the next line.

[image of music]

no-staff.ly

The printing of the staff lines may be suppressed by removing the corresponding engraver.

[image of music]

ossia.ly

A temporary ossia in an instrumental part may be printed using a separate, short staff. A simpler solution is also given: instantiate a full staff, and let RemoveEmptyStaffContext take out the unused parts.

[image of music]

page-breaks.ly

Stress optimal page breaking. This should look nice on 4 a6 pages.

[image of music] [image of music] [image of music]

part-combine.ly

In orchestral scores and hymns, voices are traditionally combined into one staff. LilyPond has a part combiner that combines, or separates, two voices according to the actual rhythm and pitch. Configurable texts, such as “solo” and “à2”, are typeset automatically in appropriate places.

[image of music]

partial-blank.ly

When entering partially typeset music (i.e. for students to be completed by hand), you may need the spacing that correspond to the timing of notes: all measures have same length, etc. It can be implemented by adding an invisible staff with a lot of fast notes.

[image of music]

phrasing-slur-height.ly

The PhrasingSlur can be made higher in order to avoid collision with other slurs.

[image of music]

piano-staff-distance.ly

It is possible to have different staff distances between the staffs of a piano system, but it requires some advanced Scheme code. Currently, this is for testing purposes.

[image of music]

polymetric-differing-notes.ly

It is possible to have multiple time signatures, each one in an own staffs, at the same time, and have even a proper vertical alignment of the different durations. This is done, firstly, by setting a common time signature for each staff but replacing it manually using timeSignatureFraction to the desired fraction, and secondly, by scaling the printed durations to the actual, polymetric durations.

In this example, music with the time signatures of 3/4, 9/8 and 10/8 are used in parallel. In the second staff, shown durations are multiplied by 2/3, so that 2/3 * 9/8 = 3/4, and in the third staff, shown durations are multiplied by 3/5, so that 3/5 * 10/8 = 3/4.

[image of music]

polymetric.ly

You can have multiple time signatures occuring at the same time.

This is done by moving the timing engraver to staff context. Also, Staff should be given the alias Timing to make \time command work correctly. The spacing is aligned vertically, although the bar lines seem to distort the regular spacing.

[image of music]

preset-extent.ly

The object may be extended to larger sized by overriding their properties. The lyrics in this example have an extent of (-10,10), which is why they are spaced so widely.

[image of music]

repeat-manual.ly

By controlling manually the signs and numbers in repeats, an unusual output can be produced.

[image of music]

repeat-shorter-bracket.ly

By setting voltaSpannerDuration, the horizontal length of a volta bracket can be shortened.

[image of music]

repeat.ly

Alternate lyrics can be used, as well as alternate notes for repeats.

[image of music]

rest-dot-positions.ly

Dots of rests should follow the rest positions.

[image of music]

rests.ly

Rests may be used in various styles.

[image of music]

reverse-music.ly

Symmetric, or palindromical music can be produced, first, by printing some music, and second, by printing the same music applying a Scheme function to reverse the syntax.

[image of music]

rhythm-excercise.ly

Rythmic exercises may be produced by removing the Clef engraver, putting all notes to the same pitch and using transparent staff lines.

[image of music]

scales-greek.ly

In addition to major and minor keys, the key can be given also in terms of greek, modal scales: ionian (= major), dorian, phrygian, lydian, mixolydian, aeolian (= minor), and locrian. All these scales are in the key of C.

[image of music]

scheme-interactions.ly

Using ly:export, the result of Scheme expressions can be passed as LilyPond input. Within a Scheme expression, you can use, define or change the corresponding variables. In this example, the D-s and E-s are generated using scheme functions, and between there are manually (without Scheme) entered C-s.

[image of music]

script-abbreviations.ly

Some articulations may be entered using an abbreviation.

[image of music]

script-chart.ly

This chart shows all articulations, or scripts, that feta font contains.

[image of music] [image of music]

script-priority.ly

Relative placements of different script types can be controlled by overriding script-priority.

In this example, accidentals are put either below or above other script symbols.

[image of music]

script-stack.ly

Text and articulations may be stacked on top of each other.

[image of music]

separate-staccato.ly

You can enter notes and articulations separately, and merge them into one thread. In this example, a repead series of staccato dots is attached to the notes.

[image of music]

slur-attachment-override.ly

In some cases, you may want to control the attachment points of a slur by hand.

[image of music]

slur-beautiful.ly

The curvature of a slur is adjusted to stay away from note heads and stems. When the curvature would increase much, the slur is reverted to its default shape. The Slur's property beautiful (which is loosely related to the enclosed area between the slur and the notes) controls the transition point, and by increasing that value you may keep slurs more curved.

[image of music]

slur-dash.ly

The appearance of slurs may be changed from solid to dotted or dashed.

[image of music]

slur-manual.ly

In extreme cases, you can resort to setting the control-points of a slur manually, althout it involves a lot of trial and error. Be sure to force line breaks at both sides, since different horizontal spacing will require rearrangement of the slur.

[image of music]

slur-minimum-length.ly

By setting the minimum length of a slur, notes are more separated.

[image of music]

slur-ugly.ly

Strange slurs can be produced by setting properties by hand.

[image of music]

smart-transpose.ly

There is a way to enforce enharmonic modifications for notes in order to have the minimum number of accidentals. In that case, “Double accidentals should be removed, as well as E-sharp (-> F), bC (-> B), bF (-> E), B-sharp (-> C).”, as proposed by a request for a new feature. In that manner, the most natural enharmonic notes are chosen in this example.

[image of music]

spacing-2.ly

When stretching notes, every note should stretch according to its duration. Eighth notes should be spaced equidistantly.

[image of music]

spanner-after-break-tweak.ly

In order to selectively change the properties of spanners after a line break, Scheme code must be used. In thas manner, the tie after the line break in this example is moved around.

[image of music]

staff-bracket.ly

Staffs can be nested in various combinations. Here, StaffGroup and ChoirStaff produce similar straight brackets, whereas GrandStaff produces curly brackets. In InnerStaffGroup and InnerChoirStaff, the brackets are shifted leftwards.

[image of music] [image of music]

staff-container.ly

In this preliminary test of a modern score, the staff lines are washed out temporarily. This is done by making a tuned StaffContainer, which \skips some notes without printing lines either and creates a ew Staff then in order to create the lines again. (Be careful if you use this; it has been done by splitting the grouping Axis_group_engraver and creating functionality into separate contexts, but the clefs and time signatures may not do what you would expect.)

[image of music]

staff-lines.ly

The number of lines in a staff may changed by overriding line-count in the properties of StaffSymbol.

[image of music]

staff-size.ly

In order to change staff sizes, both staff-space and fontSize must be scaled.

[image of music]

staff-space.ly

By just increasing staff-space on a staff, you may produce strange results.

[image of music]

stem-cross-staff.ly

The chords which exceptionally cross staves may be produced by increasing the length of the stem in the lower stave, so it reaches the stem in the upper stave, or vice versa.

[image of music]

stem-extend.ly

Extending stems to the center line may be prevented using no-stem-extend.

[image of music]

stem-length.ly

The length of stems can be altered.

[image of music]

tablature-hammer.ly

A hammer in tablature can be faked with slurs.

[image of music]

tablature.ly

Tablature is internally done by overriding the note-head formatting function and let it act on a 6-line staff. A special engraver takes then care of choosing the fret and converting the pitch to a number.

Thus, by providing the fret numbers, the same music can be generated both for a normal and tabulature staffs. By default, the fret is the smallest possible, according to minimumFret.

[image of music]

temporary-stave.ly

An additional stave can be typeset in the middle of a score line. A new context type is created for the temporary staff to avoid printing time and key signatures and clef at the beginning of the extra stave.

[image of music]

text-rotate.ly

Inline TeX (or PostScript) may be used, for example, to rotate text. To see the result, use the lilypond.py script to generate the output for printing of the source of this example (commenting one line).

[image of music]

text-spanner.ly

Text spanners can be used in the similar manner than markings for pedals or octavation.

[image of music]

textscript.ly

There are different fonts and glyphs to be used with \markup command.

[image of music]

tie-cross-voice.ly

Cross voice ties can be faked by using transparent noteheads.

[image of music]

time-signature-double.ly

Double time signatures are not supported explicitly, but they can be faked with markups and overriding formatting routines.

[image of music]

time.ly

The different styles for time signatures are shown in this file.

[image of music] [image of music]

timing.ly

You can alter the length of bars by setting explicitly measureLength or by resetting measurePosition.

[image of music]

title-markup.ly

Make titles using markup. Only in direct PostScript output.

[image of music]

title.ly

This example tests titling. By processing with lilypond (not lilypond-book), you will see all the titles.

[image of music] [image of music]

to-xml.ly

The input representation is very generic. Therefore, it should not be hard to convert it to XML or a similar format:

     <music
        type="score">
     <SequentialMusic>
     <SimultaneousMusic>
     <EventChord>
     <NoteEvent>
     <pitch
        octave="1"
        notename="0"
        alteration="0">
     </pitch>
     <duration
        log="2"
        dots="0"
        numer="1"
        denom="1">
     </duration>
     </NoteEvent>
     </EventChord>
     <VoiceSeparator>
     </VoiceSeparator>
     <EventChord>
     <NoteEvent>
     <pitch
        octave="0"
        notename="4"
        alteration="0">
     </pitch>
     <duration
        log="2"
        dots="0"
        numer="1"
        denom="1">
     </duration>
     </NoteEvent>
     </EventChord>
     </SimultaneousMusic>
     </SequentialMusic></music>

[image of music]

transposition.ly

Transposing has also an effect key signature, if it is given using \key. If keySignature is set explicitly instead, the key signature is not transposed.

[image of music]

trill.ly

The extended trill may be produced using TextSpanner with trill spanner style.

[image of music]

trills.ly

Trills, pralls and turns may also be written out in full. Here the D'Anglebert system (1689) is shown.

[image of music]

unfold-all-repeats.ly

Applying the standard function unfold-repeats unfolds recursively all repeats for a correct MIDI output.

[image of music]

version-output.ly

By putting the output of lilypond-version into a lyric, it is possible to print the version number of LilyPond in a score, or in a document generated with lilypond-book. Another possibility is to append the version number to the doc-string, in this manner: 2.2.6

[image of music]

vertical-extent.ly

Vertical extents may increased by setting minimumVerticalExtent, extraVerticalExtent, and verticalExtent. In this example, verticalExtent is increased.

[image of music]

volta-chord-names.ly

Volta brackets can be placed over chord names. This requires adding an engraver to ChordNames, and setting voltaOnThisStaff correctly.

[image of music]

Read comments on this page, or add one.

This page is for LilyPond-2.2.6 (stable-branch).

Report errors to <bug-lilypond@gnu.org>.