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.3.
When using automatic staff changes for the one voice, the
other voice must be given a name explicitely.
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.
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.
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
Accidentals are available in different ancient styles. This
file lists all of them.
Here is a display of many (all?) symbols that are
included in LilyPond's support of ancient notation.
Here's an example of bagpipe music.
By setting
You can move around
Different types of bar lines demonstrated.
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,
bar-number-regular-interval.ly
Bar numbers can also be printed at regular intervals.
Second line has bar numbers on start of every measure.
You can override LilyPond's automatic beaming.
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.
The auto-beam engraver has presets for common time signatures.
Beam positions may be controlled manually, by setting
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.
There are several ways to calculate the direction of a beam:
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.
LilyPond can beam across a Piano Staff.
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.
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).
Blank music paper, another example: empty staffs and a
tablature staff.
Blank music paper with clefs. Change the repeat count to get more staves.
You can override the molecule callback to draw a box around
arbitrary grobs.
You can set the font to use small caps.
LilyPond can display cautionary accidentals in different ways.
By setting Setting
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.
Chord names don't attempt to find inversions and
bass notes.
Jazz chords can also be used without notes.
Appending
Scales, but with clef and key signature at the end of the line.
You can use the clef engraver by using
Demonstration of how to set up an orchestral score (Beethoven's Coriolan overture).
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.
LilyPond can print crescendi in a number of different ways.
Cue notes should be set in smaller type.
Divisiones are gregorian variants of breathing signs.
Choices are
Slurs can be forced to always attach to note heads.
You can attach slurs and ties to noteheads.
Absolute dynamics have effect in MIDI files.
Additional tricks for dynamics. Pi`u forte dynamic script.
By inserting the TeX command \embeddedps, you can
insert postscript directly into the output.
You can embed scm functions in your scores.
You can embed Tex commands in your score.
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.
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.
You can add an extra staff after the beginning of a piece.
An alternate method to make bass figures is to use
markup texts.
Theads can be traced automagically when they switch staves by setting
property
Force hshift to override collisions.
This is taken from Gourlay's paper on
breaking lines.
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.
For stringed instruments, artificial harmonics are notated with
two different notehead styles on the same stem.
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.
You can manually shift notes horizontally.
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.
Noteheads for improvisation have a different shape.
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.
You can name the whole grandstaff in addition to individual staffs.
This file tests ly2dvi titling. It should be processed with ly2dvi.
Control the number of rests in a collision with maximum-rest-count.
LilyPond can print mensural ligatures.
MIDI and midi2ly test file. Diff between this and midi2ly.py should be minimal.
Positions of accidentals may be manually set. This
involves some scheme code.
You can move objects around with scheme. This example shows how to
move text around.
This example shows prelude in C major of WTK1, but coded
using Scheme functions to avoid typing work.
You can create music expressions from Scheme. The
mechanism for this is rather clumsy to use, so avoid it if possible.
LilyPond can print nested groups of staffs.
You can stop LilyPond from printing bar lines by removing the engraver.
You can stop LilyPond from printing the staff by removing the engraver.
Octave doubling parts of music.
Ossias present alternatives for a piece. They are not
really supported, but can be somewhat faked in lily.
When you combine two voices with the same notes, you should
only have one stem.
You can combine parts on two staffs, as well as two voices.
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.
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.
Piano pedal symbols merge stop and start. The strings are configurable.
Text style, bracket style, and a mixture of both are supported.
Make PhrasingSlur higher, to avoid colission from other slurs.
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.
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
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.
You can manually control repeat signs and numbers to produce
unusual output.
By setting
You can use alternate lyrics as well as alternate notes for repeats.
Simple customised music apply.
This example shows a way to generate rhythm exercises with
LilyPond (e.g. no staff but retaining the barlines).
With In this example, the E-s and D-s are generated using scheme functions,
and woven together with manually entered C-s.
Some scripts may be entered using an abbreviation.
A chart showing all feta scripts.
Relative placements of different script types can be controlled
by overriding script-priority.
You can stack text and articulations.
You can enter notes and articulations separately, and merge
them into one thread. Here is an example to add repeated staccato dots.
In some cases you may want to set slur attachments by hand.
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
You can print different kinds of slurs (dotted, dashed, etc).
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.
You can set the minimum length of a slur.
Slurs become flatter as they grow longer.
You can get ugly slurs, if you want.
1. Upon stretching every note should stretch according to duration.
2. 8th notes should be spaced equidistantly.
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.
Here's an example of staff brackets.
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.
Staff symbol property set workaround.
Setting staff sizes is a little clumsy. There are two options: using
Setting staff space on a staff.
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.
You can stop LilyPond from extending stems to the center line.
You can alter the length of stems.
You can fake a hammer in tablature with slurs.
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.
You can make LilyPond print text spanners.
Test font selection and scm text markup.
Cross voice ties can be faked by blanking noteheads.
Setting sparseTies causes only one tie to be
generated per chord pair.
0.1 Introduction
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).
barAlways and defaultBarType, you can automatically insert barlines everywhere.
Bar_engraver and
Span_bar_engraver if you want bar lines on lyrics.
set-bar-number-visibility, to automatically set
barNumberVisibility so that the bar numbers appear at regular
intervals, starting from the \applycontext.
positions in the Beam grob.
majoritymeanmedianChordNames.chordRootNamer, the root
of the chord may be named with a different function.
\germanChords gives true german chord-names,
\semiGermanChords gives semi-german chord-names - - with Bb and
keeping the english names.
_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").
\property directly.
\clef is merely a front-end to this. All the notes in this
example are central C.
divisioMinima, divisioMaior
divisioMaxima and finalis, virgula and
caesura.
followVoice.
Timing to make ime
command work correctly. Barlines distort the regular spacing, though.
voltaSpannerDuration the length of a volta bracket
can be shortened.
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.
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.
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.
StaffContainer and override/revert, or
\applyoutput. Both methods are shown in this example.