+.ly

Introduction

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

[picture of music]

ac-extra-voice.ly

When using automatic staff changes for the one voice, the other voice must be given a name explicitely.

[picture of music]

add-staccato.ly

Using make-music, you can add various stuff to notes. Here is an example how to add staccato dots. Note: for this simple case one would not use scm constructs. See separate-staccato.ly first.

[picture of music]

add-text-script.ly

You can add various stuff to notes using make-music. Here is an example of how to add an extra fingering.

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

[picture of music]

ambitus-mixed.ly

Ambituses can be switched off or translated by using applyoutput.

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

[picture of music]

ancient-accidentals.ly

Accidentals are available in different ancient styles. This file lists all of them.

[picture of music]

ancient-font.ly

Here is a display of many (all?) symbols that are included in LilyPond's support of ancient notation.

[picture of music]

ancient-time.ly

Should use old style.

[picture of music]

bagpipe.ly

Here's an example of bagpipe music.

[picture of music]

bar-always.ly

By setting barAlways and defaultBarType, you can automatically insert barlines everywhere.

[picture of music]

bar-lines-lyric-only.ly

You can move around Bar_engraver and Span_bar_engraver if you want bar lines on lyrics.

[picture of music]

bar-lines.ly

Different types of bar lines demonstrated.

[picture 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 the context function, set-bar-number-visibility, to automatically set barNumberVisibility so that the bar numbers appear at regular intervals, starting from the \applycontext.

[picture of music]

bar-number-regular-interval.ly

Bar numbers can also be printed at regular intervals.

[picture of music]

bar-number-show-all.ly

Second line has bar numbers on start of every measure.

[picture of music]

beam-auto-4-8.ly

You can override LilyPond's automatic beaming.

[picture of music]

beam-auto-override.ly

This shows how auto-beaming settings can be overridden.

The auto-beamer will only engrave beams that end when:

The beam will be ended also when now % beamAutoEnd = 0.

[picture of music]

beam-auto.ly

The auto-beam engraver has presets for common time signatures.

[picture of music]

beam-control.ly

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

[picture of music]

beam-count.ly

You can alter the number of stems in a beam. Here we see two sets of four 32nds joined as if they were 8th notes.

[picture of music]

beam-dir-functions.ly

There are several ways to calculate the direction of a beam:

majority
number count of up or down notes
mean
mean center distance of all notes
median
mean centre distance weighted per note

You can spot the differences of these settings from these simple examples:

These beam direction functions are defined in scm/beam.scm. If your favourite algorithm isn't one of these, you can hook up your own.

[picture of music]

beam-isknee.ly

LilyPond can beam across a Piano Staff.

[picture of music]

beam-neutral-direction.ly

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

[picture of music]

beam-rest.ly

Beams over rests.

[picture of music]

blank-notes.ly

You can suppress printing of LilyPond output. This example shows you how to print invisible (or blank) notes. This can be very useful when you want to do wierd tricks with LilyPond (especially with slurs, since you can't attach a slur to a rest or spacer rest).

[picture of music]

blank-paper-tab.ly

Blank music paper, another example: empty staffs and a tablature staff.

[picture of music]

blank-paper.ly

Blank music paper with clefs. Change the repeat count to get more staves.

[picture of music]

boxed-molecule.ly

You can override the molecule callback to draw a box around arbitrary grobs.

[picture of music]

caps.ly

You can set the font to use small caps.

[picture of music]

cautionaries.ly

LilyPond can display cautionary accidentals in different ways.

[picture of music]

chord-names-german.ly

By setting ChordNames.chordRootNamer, the root of the chord may be named with a different function.

Setting \germanChords gives true german chord-names, \semiGermanChords gives semi-german chord-names - - with Bb and keeping the english names.

[picture of music]

chord-names-jazz.ly

Chord names are generated from a list pitches. The functions constructing the names are customisable. This file shows Jazz chords, following Ignatzek (1995), page 17 and 18, Banter chords, and an alternative Jazz chord notation.

[picture of music][picture of music]

chord-names-no-inversions.ly

Chord names don't attempt to find inversions and bass notes.

[picture of music]

chords-without-melody.ly

Jazz chords can also be used without notes.

[picture of music]

clef-8-syntax.ly

Appending _8 or ^8 to a clef name will add an octavation sign to the clef, although the clef name needs to be in quotes (such as "treble^8").

[picture of music]

clef-end-of-line.ly

Scales, but with clef and key signature at the end of the line.

[picture of music]

clef-manual-control.ly

You can use the clef engraver by using \property directly. \clef is merely a front-end to this. All the notes in this example are central C.

[picture of music]

coriolan-margin.ly

Demonstration of how to set up an orchestral score (Beethoven's Coriolan overture).

[picture of music][picture of music]

count-systems.ly

Display the number of systems, or the system number of a Grob. This can be most useful to assertain that a piece uses a specified number of lines.

[picture of music]

crescendi.ly

LilyPond can print crescendi in a number of different ways.

[picture of music]

cue-notes.ly

Cue notes should be set in smaller type.

[picture of music]

divisiones.ly

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

[picture of music]

drarn-slurs.ly

Slurs can be forced to always attach to note heads.

[picture of music]

drarn.ly

You can attach slurs and ties to noteheads.

[picture of music]

dynamic-absolute-volume.ly

Absolute dynamics have effect in MIDI files.

[picture of music]

dynamic-extra.ly

Additional tricks for dynamics. Pi`u forte dynamic script.

[picture of music]

embedded-postscript.ly

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

[picture of music]

embedded-scm.ly

You can embed scm functions in your scores.

[picture of music]

embedded-tex.ly

You can embed Tex commands in your score.

[picture 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.

[picture of music]

engraver-one-by-one.ly

The notation problem, what symbols to create, is handled by plugins. Each plugin is called Engraver. In this example, we switch on engravers 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 the Staff context.

[picture of music]

extra-staff.ly

You can add an extra staff after the beginning of a piece.

[picture of music]

figured-bass-alternate.ly

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

[picture of music]

fill-a4.ly

This should fill a4 paper.

[picture of music][picture of music]

follow-thread.ly

Theads can be traced automagically when they switch staves by setting property followVoice.

[picture of music]

force-hshift.ly

Force hshift to override collisions.

[picture of music]

gourlay.ly

This is taken from Gourlay's paper on breaking lines.

[picture of music]

gregorian-scripts.ly

Gregorian Scripts:

ictus, circulus, semicirculus, accentus, episem.

TODO: augmentum. Syntax: either as bracket (\augmentumInitium, \augmentumFinis), or as head prefix with subsequently collecting all dots and putting them behind the ligature in a vertical row. Counterexample to the second approach: Graduale Triplex, tempus per annum, hebdomada septima, alleluia (page 280).

FIXME: horizontal spacing (ragged right mode).

FIXME: padding/minimum-distance is fragile.

[picture of music]

harmonic.ly

For stringed instruments, artificial harmonics are notated with two different notehead styles on the same stem.

[picture 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. Since the tagline isn't used in creating the webpage, this example doesn't output anything unusual in the collated snippets.

[picture of music]

hshift.ly

You can manually shift notes horizontally.

[picture 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.

[picture of music]

improv.ly

Noteheads for improvisation have a different shape.

[picture of music]

incipit.ly

This shows how to make an "incipit" to indicate scordatora tuning of a violin part, using the clefStyle property. The two first bars of Biber's Rosary sonata III.

[picture of music]

instrument-name-grandstaff.ly

You can name the whole grandstaff in addition to individual staffs.

[picture of music]

ly2dvi-testpage.ly

This file tests ly2dvi titling. It should be processed with ly2dvi.

[picture of music]

maximum-rest-count.ly

Control the number of rests in a collision with maximum-rest-count.

[picture of music]

mensural-ligatures.ly

LilyPond can print mensural ligatures.

[picture of music]

midi-scales.ly

MIDI and midi2ly test file. Diff between this and midi2ly.py should be minimal.

[picture of music][picture of music]

move-accidentals.ly

Positions of accidentals may be manually set. This involves some scheme code.

[picture of music]

move-specific-text.ly

You can move objects around with scheme. This example shows how to move text around.

[picture of music]

music-box.ly

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

[picture of music]

music-creation.ly

You can create music expressions from Scheme. The mechanism for this is rather clumsy to use, so avoid it if possible.

[picture of music]

nested-groups.ly

LilyPond can print nested groups of staffs.

[picture of music]

no-bar-lines.ly

You can stop LilyPond from printing bar lines by removing the engraver.

[picture of music]

no-staff.ly

You can stop LilyPond from printing the staff by removing the engraver.

[picture of music]

octave-duplicate.ly

Octave doubling parts of music.

[picture of music]

ossia.ly

Ossias present alternatives for a piece. They are not really supported, but can be somewhat faked in lily.

[picture of music]

part-combine-moments.ly

When you combine two voices with the same notes, you should only have one stem.

[picture of music]

part-combine-staff.ly

You can combine parts on two staffs, as well as two voices.

[picture of music]

part-combine.ly

In orchestral scores and hymns, voices are traditionally combined onto one staff. LilyPond has a part combiner, that combines or separates two voices according to actual rhythm and pitch. User-defined texts such as "solo" and "à2" are typeset automagically, as appropriate.

[picture of music]

partial-blank.ly

When entering half music (i.e. for students to complete by hand) you need the spacing to correspond to the timing - all measures same length, etc. This thing implements it by adding invisible staff with lots of fast notes.

[picture of music]

pedal.ly

Piano pedal symbols merge stop and start. The strings are configurable. Text style, bracket style, and a mixture of both are supported.

[picture of music]

phrasing-slur-height.ly

Make PhrasingSlur higher, to avoid colission from other slurs.

[picture of music]

polymetric-differing-notes.ly

You can have multiple time signatures occuring at the same time, with different durations aligned. This is done by 1. compressing one of the lines, analogous to imes, but without the bracket, and 2. manually setting timeSignatureFraction to the desired fraction.

This example puts 3/4, 9/8 and 10/8 in parallel. The last staff shows what happens on the inside: a 3/4 time signature is combined with a 3/5 tuplet yielding the equivalent of a 10/8.

[picture 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 ime command work correctly. Barlines distort the regular spacing, though.

[picture of music]

preset-extent.ly

Grob extents may be hard coded using grob properties. This requires Grob::preset_extent () function.

The lyrics in this example have extent (-10,10) which is why they are spaced so widely.

[picture of music]

repeat-manual.ly

You can manually control repeat signs and numbers to produce unusual output.

[picture of music]

repeat-shorter-bracket.ly

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

[picture of music]

repeat.ly

You can use alternate lyrics as well as alternate notes for repeats.

[picture of music]

rest-dot-positions.ly

This file tests dotted rests.

[picture of music]

rests.ly

Rests in various styles.

[picture of music]

reverse-music.ly

Simple customised music apply.

[picture of music]

rhythm-excercise.ly

This example shows a way to generate rhythm exercises with LilyPond (e.g. no staff but retaining the barlines).

[picture of music]

scales-greek.ly

Show different scales.

[picture of music]

scheme-interactions.ly

With ly:export, you can pass of the result of Scheme expressions as lilypond input. Within a Scheme expression, you can use, define or change lilypond variables.

In this example, the E-s and D-s are generated using scheme functions, and woven together with manually entered C-s.

[picture of music]

script-abbreviations.ly

Some scripts may be entered using an abbreviation.

[picture of music]

script-chart.ly

A chart showing all feta scripts.

[picture of music]

script-priority.ly

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

[picture of music]

script-stack.ly

You can stack text and articulations.

[picture of music]

separate-staccato.ly

You can enter notes and articulations separately, and merge them into one thread. Here is an example to add repeated staccato dots.

[picture of music]

slur-attachment-override.ly

In some cases you may want to set slur attachments by hand.

[picture of music]

slur-beautiful.ly

Similarly, the curvature of a slur is adjusted to stay clear of note heads and stems. When that would increase the curvature too much, the slur is reverted to its default shape. The threshold for this decision is in Slur's object property beautiful. It is loosely related to the enclosed area between the slur and the notes. Usually, the default setting works well, but in some cases you may prefer a curved slur when LilyPond decides for a vertically moved one. You can indicate this preference by increasing the beautiful value.

[picture of music]

slur-dash.ly

You can print different kinds of slurs (dotted, dashed, etc).

[picture of music]

slur-manual.ly

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

[picture of music]

slur-minimum-length.ly

You can set the minimum length of a slur.

[picture of music]

slur-shape.ly

Slurs become flatter as they grow longer.

[picture of music]

slur-ugly.ly

You can get ugly slurs, if you want.

[picture of music]

smart-transpose.ly

     	Here's a copy of my feature request :
     
Your task, if you accept it is to implement a \smarttranspose command>> that would translate such oddities into more natural notations. Double accidentals should be removed, as well as E-sharp (-> F), bC (-> B), bF (-> E), B-sharp (-> C).
You mean like this. (Sorry 'bout the nuked indentation.) Modified to use the standard transpose mechanism. The question is how useful these enharmonic modifications are. Mats B.

[picture of music]

spacing-2.ly

1. Upon stretching every note should stretch according to duration.

2. 8th notes should be spaced equidistantly.

[picture of music]

spanner-after-break-tweak.ly

To selectively tweak spanners after the linebreaking process, Scheme code must be used. In this simple example, the tie after the line break is moved around.

[picture of music]

staff-bracket.ly

Here's an example of staff brackets.

[picture of music]

staff-container.ly

Container By splitting the grouping (Axis_group_engraver) and creation functionality into separate contexts, you can override interesting things.

Notation like this is used in modern scores. Note that LilyPond is not especially prepared for it: the clefs and time-signatures don't do what you would expect.

[picture of music]

staff-lines.ly

Staff symbol property set workaround.

[picture of music]

staff-size.ly

Setting staff sizes is a little clumsy. There are two options: using StaffContainer and override/revert, or \applyoutput. Both methods are shown in this example.

[picture of music]

staff-space.ly

Setting staff space on a staff.

[picture of music]

stem-centered.ly

Mensural note heads.

[picture of music]

stem-cross-staff.ly

There is no support for putting chords across staves. You can get this result by increasing the length of the stem in the lower stave so it reaches the stem in the upper stave, or vice versa.

[picture of music]

stem-extend.ly

You can stop LilyPond from extending stems to the center line.

[picture of music]

stem-length.ly

You can alter the length of stems.

[picture of music]

tablature-hammer.ly

You can fake a hammer in tablature with slurs.

[picture of music]

tablature.ly

A sample tablature, with both normal staff and tab.

Tablature is done by overriding the note-head formatting function, and putting it on a 6-line staff. A special engraver takes care of going from string-number + pitch to number.

[picture of music]

text-spanner.ly

You can make LilyPond print text spanners.

[picture of music]

textscript.ly

Test font selection and scm text markup.

[picture of music]

tie-cross-voice.ly

Cross voice ties can be faked by blanking noteheads.

[picture of music]

tie-sparse.ly

Setting sparseTies causes only one tie to be generated per chord pair.

[picture of music]

time-signature-double.ly

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

[picture of music]

time.ly

Old time signatures. For further information, consult the file.

[picture of music]

timing.ly

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

[picture of music]

title.ly

This test ly2dvi titling. process with ly2dvi, not lilypond-book.

[picture of music][picture of music]

to-xml.ly

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

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

[picture of music]

transposition.ly

Transposition test file.

[picture of music]

trill.ly

Show trill line type.

[picture of music]

trills.ly

Document trills, pralls and turns.

[picture of music]

unfold-all-repeats.ly

The standard function unfold-repeats will recursively unfold all repeats for correct MIDI output. Thanks to Rune Zedeler.

[picture of music]

vaticana.ly

Ancient Vaticana Vaticana ligature test.

[picture of music]

version-output.ly

By putting the output of lilypond-version into a lyric, we can print the version number in a score, or a lilypond-book document.

[picture of music]

vertical-extent.ly

Vertical extents may be overriden by minimumVerticalExtent, extraVerticalExtent, and verticalExtent. These are normal property values, and are written into the grob when the associated context finishes, so using it in \property works.

[picture of music]


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

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