Examples¶
The LilyPond documentation used in example can be downloaded here:
/_scores/minuet-in-g.ly.
Original paper size¶

.. lilyinclude:: /_scores/minuet-in-g.ly
:nocrop:
Disable Audio¶

.. lilyinclude:: /_scores/minuet-in-g.ly
:noaudio:
Transposing¶

.. lilyinclude:: /_scores/minuet-in-g.ly
:transpose: g c
Multiple Pages¶

.. lilyinclude:: /_scores/alice.ly
Loop¶

.. lilyinclude:: /_scores/minuet-in-g.ly
:loop:
Added in version 1.2.
Control Bar at the Top¶

.. lilyinclude:: /_scores/minuet-in-g.ly
:controls: top
Added in version 1.3.
Jianpu (Numbered Musical Notation)¶

.. jianpu::
title=C Major Scale
1=C
4=60
2/4
1 2 3 4 5 6 7 1'
See also
Added in version 1.5.
Jianpu (Change Chords into Roman Numerals)¶
![\version "2.20.0"
#(set-global-staff-size 20)
% un-comment the next line to remove Lilypond tagline:
% \header { tagline="" }
% comment out the next line if you're debugging jianpu-ly
% (but best leave it un-commented in production, since
% the point-and-click locations won't go to the user input)
\pointAndClickOff
\paper {
print-all-headers = ##t %% allow per-score headers
% un-comment the next line for A5:
% #(set-default-paper-size "a5" )
% un-comment the next line for no page numbers:
% print-page-number = ##f
% un-comment the next 3 lines for a binding edge:
% two-sided = ##t
% inner-margin = 20\mm
% outer-margin = 10\mm
% un-comment the next line for a more space-saving header layout:
% scoreTitleMarkup = \markup { \center-column { \fill-line { \magnify #1.5 { \bold { \fromproperty #'header:dedication } } \magnify #1.5 { \bold { \fromproperty #'header:title } } \fromproperty #'header:composer } \fill-line { \fromproperty #'header:instrument \fromproperty #'header:subtitle \smaller{\fromproperty #'header:subsubtitle } } } }
}
%% 2-dot and 3-dot articulations
#(append! default-script-alist
(list
`(two-dots
. (
(stencil . ,ly:text-interface::print)
(text . ,#{ \markup \override #'(font-encoding . latin1) \center-align \bold ":" #})
(padding . 0.20)
(avoid-slur . inside)
(direction . ,UP)))))
#(append! default-script-alist
(list
`(three-dots
. (
(stencil . ,ly:text-interface::print)
(text . ,#{ \markup \override #'(font-encoding . latin1) \center-align \bold "⋮" #})
(padding . 0.30)
(avoid-slur . inside)
(direction . ,UP)))))
"two-dots" =
#(make-articulation 'two-dots)
"three-dots" =
#(make-articulation 'three-dots)
\layout {
\context {
\Score
scriptDefinitions = #default-script-alist
}
}
note-mod =
#(define-music-function
(text note)
(markup? ly:music?)
#{
\tweak NoteHead.stencil #ly:text-interface::print
\tweak NoteHead.text
\markup \lower #0.5 \sans \bold #text
\tweak Rest.stencil #ly:text-interface::print
\tweak Rest.text
\markup \lower #0.5 \sans \bold #text
#note
#})
#(define (flip-beams grob)
(ly:grob-set-property!
grob 'stencil
(ly:stencil-translate
(let* ((stl (ly:grob-property grob 'stencil))
(centered-stl (ly:stencil-aligned-to stl Y DOWN)))
(ly:stencil-translate-axis
(ly:stencil-scale centered-stl 1 -1)
(* (- (car (ly:stencil-extent stl Y)) (car (ly:stencil-extent centered-stl Y))) 0) Y))
(cons 0 -0.8))))
%=======================================================
#(define-event-class 'jianpu-grace-curve-event 'span-event)
#(define (add-grob-definition grob-name grob-entry)
(set! all-grob-descriptions
(cons ((@@ (lily) completize-grob-entry)
(cons grob-name grob-entry))
all-grob-descriptions)))
#(define (jianpu-grace-curve-stencil grob)
(let* ((elts (ly:grob-object grob 'elements))
(refp-X (ly:grob-common-refpoint-of-array grob elts X))
(X-ext (ly:relative-group-extent elts refp-X X))
(refp-Y (ly:grob-common-refpoint-of-array grob elts Y))
(Y-ext (ly:relative-group-extent elts refp-Y Y))
(direction (ly:grob-property grob 'direction RIGHT))
(x-start (* 0.5 (+ (car X-ext) (cdr X-ext))))
(y-start (+ (car Y-ext) 0.32))
(x-start2 (if (eq? direction RIGHT)(+ x-start 0.5)(- x-start 0.5)))
(x-end (if (eq? direction RIGHT)(+ (cdr X-ext) 0.2)(- (car X-ext) 0.2)))
(y-end (- y-start 0.5))
(stil (ly:make-stencil `(path 0.1
(moveto ,x-start ,y-start
curveto ,x-start ,y-end ,x-start ,y-end ,x-start2 ,y-end
lineto ,x-end ,y-end))
X-ext
Y-ext))
(offset (ly:grob-relative-coordinate grob refp-X X)))
(ly:stencil-translate-axis stil (- offset) X)))
#(add-grob-definition
'JianpuGraceCurve
`(
(stencil . ,jianpu-grace-curve-stencil)
(meta . ((class . Spanner)
(interfaces . ())))))
#(define jianpu-grace-curve-types
'(
(JianpuGraceCurveEvent
. ((description . "Used to signal where curve encompassing music start and stop.")
(types . (general-music jianpu-grace-curve-event span-event event))
))
))
#(set!
jianpu-grace-curve-types
(map (lambda (x)
(set-object-property! (car x)
'music-description
(cdr (assq 'description (cdr x))))
(let ((lst (cdr x)))
(set! lst (assoc-set! lst 'name (car x)))
(set! lst (assq-remove! lst 'description))
(hashq-set! music-name-to-property-table (car x) lst)
(cons (car x) lst)))
jianpu-grace-curve-types))
#(set! music-descriptions
(append jianpu-grace-curve-types music-descriptions))
#(set! music-descriptions
(sort music-descriptions alist<?))
#(define (add-bound-item spanner item)
(if (null? (ly:spanner-bound spanner LEFT))
(ly:spanner-set-bound! spanner LEFT item)
(ly:spanner-set-bound! spanner RIGHT item)))
jianpuGraceCurveEngraver =
#(lambda (context)
(let ((span '())
(finished '())
(current-event '())
(event-start '())
(event-stop '()))
`(
(listeners
(jianpu-grace-curve-event .
,(lambda (engraver event)
(if (= START (ly:event-property event 'span-direction))
(set! event-start event)
(set! event-stop event)))))
(acknowledgers
(note-column-interface .
,(lambda (engraver grob source-engraver)
(if (ly:spanner? span)
(begin
(ly:pointer-group-interface::add-grob span 'elements grob)
(add-bound-item span grob)))
(if (ly:spanner? finished)
(begin
(ly:pointer-group-interface::add-grob finished 'elements grob)
(add-bound-item finished grob)))))
(inline-accidental-interface .
,(lambda (engraver grob source-engraver)
(if (ly:spanner? span)
(begin
(ly:pointer-group-interface::add-grob span 'elements grob)))
(if (ly:spanner? finished)
(ly:pointer-group-interface::add-grob finished 'elements grob))))
(script-interface .
,(lambda (engraver grob source-engraver)
(if (ly:spanner? span)
(begin
(ly:pointer-group-interface::add-grob span 'elements grob)))
(if (ly:spanner? finished)
(ly:pointer-group-interface::add-grob finished 'elements grob)))))
(process-music .
,(lambda (trans)
(if (ly:stream-event? event-stop)
(if (null? span)
(ly:warning "No start to this curve.")
(begin
(set! finished span)
(ly:engraver-announce-end-grob trans finished event-start)
(set! span '())
(set! event-stop '()))))
(if (ly:stream-event? event-start)
(begin
(set! span (ly:engraver-make-grob trans 'JianpuGraceCurve event-start))
(set! event-start '())))))
(stop-translation-timestep .
,(lambda (trans)
(if (and (ly:spanner? span)
(null? (ly:spanner-bound span LEFT)))
(ly:spanner-set-bound! span LEFT
(ly:context-property context 'currentMusicalColumn)))
(if (ly:spanner? finished)
(begin
(if (null? (ly:spanner-bound finished RIGHT))
(ly:spanner-set-bound! finished RIGHT
(ly:context-property context 'currentMusicalColumn)))
(set! finished '())
(set! event-start '())
(set! event-stop '())))))
(finalize
(lambda (trans)
(if (ly:spanner? finished)
(begin
(if (null? (ly:spanner-bound finished RIGHT))
(set! (ly:spanner-bound finished RIGHT)
(ly:context-property context 'currentMusicalColumn)))
(set! finished '())))))
)))
jianpuGraceCurveStart =
#(make-span-event 'JianpuGraceCurveEvent START)
jianpuGraceCurveEnd =
#(make-span-event 'JianpuGraceCurveEvent STOP)
%===========================================================
%{ The jianpu-ly input was:
NoBarNums % break heigth of chore names
ChordsRoman
title=送别
4=80
1=A
4/4
chords= a1 d2 a2 a1 e:7 a1 d2 a2 a1 e:7 d1 e:7 a2 d2 a2 e:7 a1 d2 a2 e:7 a1
5 q3 q5 1' -
6 q1' q6 5 -
5 q1 q2 3 q2 q1
2 - - 0
\break
5 q3 q5 1'. q7
6 1' 5 -
5 q2 q3 4. q7,
1 - . 0
\break
6 ^"低八度" 1' 1' 0
7 q6 q7 1' ^"I" 0
q6 q7 q1' q6 q6 q5 q3 q1
2 - . 0
\break
5 q3 q5 1'. q7
6 1' 5 -
5 q2 q3 4. q7,
1 - . 0
%}
\score {
<< \override Score.BarNumber.break-visibility = #center-visible
\override Score.BarNumber.Y-offset = -1
\set Score.barNumberVisibility = #(every-nth-bar-number-visible 5)
\new ChordNames { \set chordChanges = ##t
\set chordNameLowercaseMinor = ##t
\chordmode { a1 d2 a2 a1 e:7 a1 d2 a2 a1 e:7 d1 e:7 a2 d2 a2 e:7 a1 d2 a2 e:7 a1 } }
%% === BEGIN JIANPU STAFF ===
\new RhythmicStaff \with {
\consists "Accidental_engraver"
\consists \jianpuGraceCurveEngraver
% Get rid of the stave but not the barlines:
\override StaffSymbol.line-count = #0 % tested in 2.15.40, 2.16.2, 2.18.0, 2.18.2, 2.20.0 and 2.22.2
\override BarLine.bar-extent = #'(-2 . 2) % LilyPond 2.18: please make barlines as high as the time signature even though we're on a RhythmicStaff (2.16 and 2.15 don't need this although its presence doesn't hurt; Issue 3685 seems to indicate they'll fix it post-2.18)
$(add-grace-property 'Voice 'Stem 'direction DOWN)
$(add-grace-property 'Voice 'Slur 'direction UP)
$(add-grace-property 'Voice 'Stem 'length-fraction 0.5)
$(add-grace-property 'Voice 'Beam 'beam-thickness 0.1)
$(add-grace-property 'Voice 'Beam 'length-fraction 0.3)
$(add-grace-property 'Voice 'Beam 'after-line-breaking flip-beams)
$(add-grace-property 'Voice 'Beam 'Y-offset 2.5)
$(add-grace-property 'Voice 'NoteHead 'Y-offset 2.5)
}
{ \new Voice="W" {
\override Beam.transparent = ##f
\override Stem.direction = #DOWN
\override Tie.staff-position = #2.5
\tupletUp
\tieUp
\override Stem.length-fraction = #0
\override Beam.beam-thickness = #0.1
\override Beam.length-fraction = #0.5
\override Beam.after-line-breaking = #flip-beams
\override Voice.Rest.style = #'neomensural % this size tends to line up better (we'll override the appearance anyway)
\override Accidental.font-size = #-4
\override TupletBracket.bracket-visibility = ##t
\override Staff.TimeSignature.style = #'numbered
\override Staff.Stem.transparent = ##t
\tempo 4=80 \mark \markup{1=A} \time 4/4 \note-mod "5" g4 \set stemLeftBeamCount = #0
\set stemRightBeamCount = #1
\note-mod "3" e8[
\set stemLeftBeamCount = #1
\set stemRightBeamCount = #1
\note-mod "5" g8]
\once \override Tie.transparent = ##t \once \override Tie.staff-position = #0 \note-mod "1" c4^.
~ \note-mod "–" c4 | %{ bar 2: %}
\note-mod "6" a4
\set stemLeftBeamCount = #0
\set stemRightBeamCount = #1
\note-mod "1" c8^.[
\set stemLeftBeamCount = #1
\set stemRightBeamCount = #1
\note-mod "6" a8]
\once \override Tie.transparent = ##t \once \override Tie.staff-position = #0 \note-mod "5" g4
~ \note-mod "–" g4 | %{ bar 3: %}
\note-mod "5" g4
\set stemLeftBeamCount = #0
\set stemRightBeamCount = #1
\note-mod "1" c8[
\set stemLeftBeamCount = #1
\set stemRightBeamCount = #1
\note-mod "2" d8]
\note-mod "3" e4 \set stemLeftBeamCount = #0
\set stemRightBeamCount = #1
\note-mod "2" d8[
\set stemLeftBeamCount = #1
\set stemRightBeamCount = #1
\note-mod "1" c8]
\once \override Tie.transparent = ##t \once \override Tie.staff-position = #0 | %{ bar 4: %}
\note-mod "2" d4
~ \once \override Tie.transparent = ##t \once \override Tie.staff-position = #0 \note-mod "–" d4
~ \note-mod "–" d4 \note-mod "0" r4 \break | %{ bar 5: %}
\note-mod "5" g4
\set stemLeftBeamCount = #0
\set stemRightBeamCount = #1
\note-mod "3" e8[
\set stemLeftBeamCount = #1
\set stemRightBeamCount = #1
\note-mod "5" g8]
\note-mod "1" c4.^. \set stemLeftBeamCount = #0
\set stemRightBeamCount = #1
\note-mod "7" b8[]
| %{ bar 6: %}
\note-mod "6" a4
\note-mod "1" c4^. \once \override Tie.transparent = ##t \once \override Tie.staff-position = #0 \note-mod "5" g4
~ \note-mod "–" g4 | %{ bar 7: %}
\note-mod "5" g4
\set stemLeftBeamCount = #0
\set stemRightBeamCount = #1
\note-mod "2" d8[
\set stemLeftBeamCount = #1
\set stemRightBeamCount = #1
\note-mod "3" e8]
\note-mod "4" f4. \set stemLeftBeamCount = #0
\set stemRightBeamCount = #1
\note-mod "7" b8-\tweak #'X-offset #0.6 _. []
\once \override Tie.transparent = ##t \once \override Tie.staff-position = #0 | %{ bar 8: %}
\note-mod "1" c4
~ \once \override Tie.transparent = ##t \once \override Tie.staff-position = #0 \note-mod "–" c4
~ \note-mod "–" c4 \note-mod "0" r4 \break | %{ bar 9: %}
\note-mod "6" a4
^"低八度" \note-mod "1" c4^. \note-mod "1" c4^. \note-mod "0" r4 | %{ bar 10: %}
\note-mod "7" b4
\set stemLeftBeamCount = #0
\set stemRightBeamCount = #1
\note-mod "6" a8[
\set stemLeftBeamCount = #1
\set stemRightBeamCount = #1
\note-mod "7" b8]
\note-mod "1" c4^. ^"I" \note-mod "0" r4 | %{ bar 11: %} \set stemLeftBeamCount = #0
\set stemRightBeamCount = #1
\note-mod "6" a8[
\set stemLeftBeamCount = #1
\set stemRightBeamCount = #1
\note-mod "7" b8]
\set stemLeftBeamCount = #0
\set stemRightBeamCount = #1
\note-mod "1" c8^.[
\set stemLeftBeamCount = #1
\set stemRightBeamCount = #1
\note-mod "6" a8]
\set stemLeftBeamCount = #0
\set stemRightBeamCount = #1
\note-mod "6" a8[
\set stemLeftBeamCount = #1
\set stemRightBeamCount = #1
\note-mod "5" g8]
\set stemLeftBeamCount = #0
\set stemRightBeamCount = #1
\note-mod "3" e8[
\set stemLeftBeamCount = #1
\set stemRightBeamCount = #1
\note-mod "1" c8]
\once \override Tie.transparent = ##t \once \override Tie.staff-position = #0 | %{ bar 12: %}
\note-mod "2" d4
~ \once \override Tie.transparent = ##t \once \override Tie.staff-position = #0 \note-mod "–" d4
~ \note-mod "–" d4 \note-mod "0" r4 \break | %{ bar 13: %}
\note-mod "5" g4
\set stemLeftBeamCount = #0
\set stemRightBeamCount = #1
\note-mod "3" e8[
\set stemLeftBeamCount = #1
\set stemRightBeamCount = #1
\note-mod "5" g8]
\note-mod "1" c4.^. \set stemLeftBeamCount = #0
\set stemRightBeamCount = #1
\note-mod "7" b8[]
| %{ bar 14: %}
\note-mod "6" a4
\note-mod "1" c4^. \once \override Tie.transparent = ##t \once \override Tie.staff-position = #0 \note-mod "5" g4
~ \note-mod "–" g4 | %{ bar 15: %}
\note-mod "5" g4
\set stemLeftBeamCount = #0
\set stemRightBeamCount = #1
\note-mod "2" d8[
\set stemLeftBeamCount = #1
\set stemRightBeamCount = #1
\note-mod "3" e8]
\note-mod "4" f4. \set stemLeftBeamCount = #0
\set stemRightBeamCount = #1
\note-mod "7" b8-\tweak #'X-offset #0.6 _. []
\once \override Tie.transparent = ##t \once \override Tie.staff-position = #0 | %{ bar 16: %}
\note-mod "1" c4
~ \once \override Tie.transparent = ##t \once \override Tie.staff-position = #0 \note-mod "–" c4
~ \note-mod "–" c4 \note-mod "0" r4 \bar "|." } }
% === END JIANPU STAFF ===
>>
\header{
title="送别"
}
\layout{ \context { \Score \remove "Bar_number_engraver" } \context { \ChordNames \consists #(lambda (cx) (let ((tonic #{ c #})) (make-engraver ((initialize engraver) (set! (ly:context-property cx 'chordRootNamer) (lambda (pitch capitalized) (let ((degree (1+ (ly:pitch-notename (ly:pitch-diff pitch tonic)))) (style (if capitalized 'roman-lower 'roman-upper))) (number-format style degree))))) (listeners ((key-change-event engraver event) (set! tonic (ly:event-property event 'tonic))))))) }
\context {
\Global
\grobdescriptions #all-grob-descriptions
}
} }
\score {
\unfoldRepeats
<<
\new ChordNames { \set chordChanges = ##t
\set chordNameLowercaseMinor = ##t
\chordmode { a1 d2 a2 a1 e:7 a1 d2 a2 a1 e:7 d1 e:7 a2 d2 a2 e:7 a1 d2 a2 e:7 a1 } }
% === BEGIN MIDI STAFF ===
\new Staff { \new Voice="X" { \tempo 4=80 \transpose c a, { \key c \major \time 4/4 g'4 e'8 g'8 c''2 | %{ bar 2: %} a'4 c''8 a'8 g'2 | %{ bar 3: %} g'4 c'8 d'8 e'4 d'8 c'8 | %{ bar 4: %} d'2. r4 \break | %{ bar 5: %} g'4 e'8 g'8 c''4. b'8 | %{ bar 6: %} a'4 c''4 g'2 | %{ bar 7: %} g'4 d'8 e'8 f'4. b8 | %{ bar 8: %} c'2. r4 \break | %{ bar 9: %} a'4 ^"低八度" c''4 c''4 r4 | %{ bar 10: %} b'4 a'8 b'8 c''4 ^"I" r4 | %{ bar 11: %} a'8 b'8 c''8 a'8 a'8 g'8 e'8 c'8 | %{ bar 12: %} d'2. r4 \break | %{ bar 13: %} g'4 e'8 g'8 c''4. b'8 | %{ bar 14: %} a'4 c''4 g'2 | %{ bar 15: %} g'4 d'8 e'8 f'4. b8 | %{ bar 16: %} c'2. r4 } } }
% === END MIDI STAFF ===
>>
\header{
title="送别"
}
\midi { \context { \Score tempoWholesPerMinute = #(ly:make-moment 84 4)}} }](./_lilypond/a64ac71f36b991666a8e665c933d938a0a0ce61a/music.cropped.png)
.. jianpu::
NoBarNums % break heigth of chore names
ChordsRoman
title=送别
4=80
1=A
4/4
chords= a1 d2 a2 a1 e:7 a1 d2 a2 a1 e:7 d1 e:7 a2 d2 a2 e:7 a1 d2 a2 e:7 a1
5 q3 q5 1' -
6 q1' q6 5 -
5 q1 q2 3 q2 q1
2 - - 0
\break
5 q3 q5 1'. q7
6 1' 5 -
5 q2 q3 4. q7,
1 - . 0
\break
6 ^"低八度" 1' 1' 0
7 q6 q7 1' ^"I" 0
q6 q7 q1' q6 q6 q5 q3 q1
2 - . 0
\break
5 q3 q5 1'. q7
6 1' 5 -
5 q2 q3 4. q7,
1 - . 0
Added in version 2.3: and require jianpu-ly >=v1.856
Multiple MIDI Outputs¶

.. lily::
\version "2.22.0"
melody = \relative {
\key c \major
\time 4/4
c'4 c g' g a a g2
f4 f e e d d c2
}
harmony = \chordmode {
c1: f2: c:
f2: c: g2: c:
}
\book {
\header {
title = "Twinkle Twinkle Little Star"
piece = \markup { \vspace #1 }
}
\score {
<<
\new ChordNames { \harmony }
\new Staff { \melody }
\addlyrics {
Twin -- kle, twin -- kle, lit -- tle star,
how I won -- der what you are!
}
>>
\layout {}
\midi {}
}
}
\book {
\header { title = "Twinkle Twinkle Little Star (Melody)" }
\score {
\new Staff { \melody }
\midi {}
}
}
\book {
\header { title = "Twinkle Twinkle Little Star (Harmony)" }
\score {
\new ChordNames { \harmony }
\midi {}
}
}
Added in version 2.4.