Ambits can be added per voice. In that case, the ambitus must be moved manually to prevent collisions.
\new Staff << \new Voice \with { \consists "Ambitus_engraver" } \relative c'' { \override Ambitus #'X-offset = # 2.0 \voiceOne c4 a d e f1 } \new Voice \with { \consists "Ambitus_engraver" } \relative c' { \voiceTwo es4 f g as b1 } >>
If you have multiple voices in a single staff and you want a single
ambitus per staff rather than per voice, add the
Ambitus_engraver
to the Staff
context rather than to the
Voice
context.
\new Staff \with { \consists "Ambitus_engraver" } << \new Voice \relative c'' { \voiceOne c4 a d e f1 } \new Voice \relative c' { \voiceTwo es4 f g as b1 } >>
applying-noteheads-styles-depending-on-the-step-of-the-scale.ly
The shapeNoteStyles property gives you the ability to define various note heads styles for each step of the scale (as defined by the key signature or the "tonic" property).
This property requires a set of symbols, which can be purely arbitrary (geometrical expressions such as triangle, cross, xcircle etc. are allowed) or based on old American engraving tradition (you can use some latin note names as well).
That said, if you're trying to imitate old American song books, you may also want to try LilyPond's predefined note heads styles, through shortcut commands such as \aikenHeads or \sacredHarpHeads.
This example shows different ways to obtain shape note heads, and demonstrates the ability to transpose a melody without losing the correspondance between harmonic functions and note heads styles.
fragment = { \key c \major c1 d e f g a b c \break } \score { \new Staff { \transpose c d \relative { \set shapeNoteStyles = ##(do re mi fa #f la ti) \fragment \break } \relative { \set shapeNoteStyles = ##(cross triangle fa #f mensural xcircle diamond) \fragment } } }
clefs-commonly-tweaked-properties.ly
The command \clef "treble_8"
is equivalent to setting
clefGlyph
, clefPosition
(which controls the Y position of
the clef), middleCPosition
and clefOctavation
. A clef is
printed when any of these properties are changed.
Note that changing the glyph, the position of the clef, or the octavation, does not in itself change the position of subsequent notes on the staff: the position of middle C must also be specified to do this. The positional parameters are relative to the staff centre line, positive numbers displacing upwards, counting 1 for each line and space. The clefOctavation value would normally be set to 7, -7, 15 or -15, but other values are not invalid.
When a clef change takes place at a line break the new clef symbol is
printed at both the end of the previous line and the beginning of the
new line by default. If the warning clef at the end of the previous
line is not required it can be suppressed by setting the
explicitClefVisibility Staff property to the value
end-of-line-invisible
. The default behaviour can be recovered
with \unset Staff.explicitClefVisibility
.
The following examples show the possibilities when setting these properties manually. On the first line, the manual changes preserve the standard relative positioning of clefs and notes, whereas on the second line, they do not.
{ % The default treble clef c'1 % The standard bass clef \set Staff.clefGlyph = #"clefs.F" \set Staff.clefPosition = #2 \set Staff.middleCPosition = #6 c' % The baritone clef \set Staff.clefGlyph = #"clefs.C" \set Staff.clefPosition = #4 \set Staff.middleCPosition = #4 c' % The standard choral tenor clef \set Staff.clefGlyph = #"clefs.G" \set Staff.clefPosition = #-2 \set Staff.clefOctavation = #-7 \set Staff.middleCPosition = #1 c' % A non-standard clef \set Staff.clefPosition = #0 \set Staff.clefOctavation = #0 \set Staff.middleCPosition = #-4 c' \break % The following clef changes do not preserve % the normal relationship between notes and clefs: \set Staff.clefGlyph = #"clefs.F" \set Staff.clefPosition = #2 c' \set Staff.clefGlyph = #"clefs.G" c' \set Staff.clefGlyph = #"clefs.C" c' \set Staff.clefOctavation = #7 c' \set Staff.clefOctavation = #0 \set Staff.clefPosition = #0 c' % Here we go back to the normal clef: \set Staff.middleCPosition = #4 c' }
creating-a-sequence-of-notes-on-various-pitches.ly
In music that contains many occurrences of the same sequence of notes at different pitches, you can use the following music function. It takes a note, of which the pitch is used. The supporting Scheme functions were borrowed from the Tips and Tricks document in the manual.
This example creates the rhythm used throughout Mars, from The Planets, by Gustav Holst.
#(define (make-note-req p d) (make-music 'NoteEvent 'duration d 'pitch p)) #(define (make-note p d) (make-music 'EventChord 'elements (list (make-note-req p d)))) #(define (seq-music-list elts) (make-music 'SequentialMusic 'elements elts)) #(define (make-triplet elt) (make-music 'TimeScaledMusic 'denominator 3 'numerator 2 'element elt)) rhythm = #(define-music-function (parser location note) (ly:music?) "Make the rhythm in Mars (the Planets) at the given note's pitch" (let* ((p (ly:music-property (car (ly:music-property note 'elements)) 'pitch))) (seq-music-list (list (make-triplet (seq-music-list (list (make-note p (ly:make-duration 3 0 2 3)) (make-note p (ly:make-duration 3 0 2 3)) (make-note p (ly:make-duration 3 0 2 3)) ))) (make-note p (ly:make-duration 2 0)) (make-note p (ly:make-duration 2 0)) (make-note p (ly:make-duration 3 0)) (make-note p (ly:make-duration 3 0)) (make-note p (ly:make-duration 2 0)) )))) \score { \new Staff { \time 5/4 \rhythm c' \rhythm c'' \rhythm g } }
dodecaphonic-style-accidentals-for-each-note-including-naturals.ly
In early XXth century works, starting with Schönberg, Berg and Webern (the "second" Viennese school), every pitch in the twelve-tone scale has to be regarded as equal, without any hierarchy such as the classical (tonal) degrees. Therefore, these composers print one accidental for each note, even at natural pitches, to emphasize their new approach to music theory and language. This snippet shows how to achieve such notation rules with LilyPond.
webernAccidentals = { % the 5s are just "a value different from any accidental" \set Staff.keySignature = #'((0 . 5) (1 . 5) (2 . 5) (3 . 5) (4 . 5) (5 . 5) (6 . 5)) \set Staff.extraNatural = ##f #(set-accidental-style 'forget) } \layout { \context { \Staff \remove Key_engraver } } \score { { \webernAccidentals c' dis' cis' cis' c' dis' cis' cis' c' c' dis' des' } }
This Scheme-based snippet allows you to generate 24 random notes (or as many as you want), based on the current time (or any randomish number you might wish to specify instead, so you can obtain the same random notes each time): i.e. to get different random notes patterns, just change this number.
\score { { #(let ((random-state (seed->random-state (current-time)))) (ly:export (make-music 'SequentialMusic 'elements (map (lambda x (let ((idx (random 12 random-state))) (make-music 'EventChord 'elements (list (make-music 'NoteEvent 'duration (ly:make-duration 2 0 1 1) 'pitch (ly:make-pitch (quotient idx 7) (remainder idx 7) 0)))))) (make-list 24))))) } }
Makam is Turkish type of melody that uses 1/9 tone microtonal alterations.
% Define 1/9 alterations. #(define-public KOMA 1/9) #(define-public BAKIYE 4/9) #(define-public KUCUK 5/9) #(define-public BUYUKMUCENNEB 8/9) % Define pitch names makamPitchNames = #`( (c . ,(ly:make-pitch -1 0 NATURAL)) (d . ,(ly:make-pitch -1 1 NATURAL)) (e . ,(ly:make-pitch -1 2 NATURAL)) (f . ,(ly:make-pitch -1 3 NATURAL)) (g . ,(ly:make-pitch -1 4 NATURAL)) (a . ,(ly:make-pitch -1 5 NATURAL)) (b . ,(ly:make-pitch -1 6 NATURAL)) (cc . ,(ly:make-pitch -1 0 KOMA)) (dc . ,(ly:make-pitch -1 1 KOMA)) (ec . ,(ly:make-pitch -1 2 KOMA)) (fc . ,(ly:make-pitch -1 3 KOMA)) (gc . ,(ly:make-pitch -1 4 KOMA)) (ac . ,(ly:make-pitch -1 5 KOMA)) (bc . ,(ly:make-pitch -1 6 KOMA)) (cb . ,(ly:make-pitch -1 0 BAKIYE)) (db . ,(ly:make-pitch -1 1 BAKIYE)) (eb . ,(ly:make-pitch -1 2 BAKIYE)) (fb . ,(ly:make-pitch -1 3 BAKIYE)) (gb . ,(ly:make-pitch -1 4 BAKIYE)) (ab . ,(ly:make-pitch -1 5 BAKIYE)) (bb . ,(ly:make-pitch -1 6 BAKIYE)) (ck . ,(ly:make-pitch -1 0 KUCUK)) (dk . ,(ly:make-pitch -1 1 KUCUK)) (ek . ,(ly:make-pitch -1 2 KUCUK)) (fk . ,(ly:make-pitch -1 3 KUCUK)) (gk . ,(ly:make-pitch -1 4 KUCUK)) (ak . ,(ly:make-pitch -1 5 KUCUK)) (bk . ,(ly:make-pitch -1 6 KUCUK)) (cbm . ,(ly:make-pitch -1 0 BUYUKMUCENNEB)) (dbm . ,(ly:make-pitch -1 1 BUYUKMUCENNEB)) (ebm . ,(ly:make-pitch -1 2 BUYUKMUCENNEB)) (fbm . ,(ly:make-pitch -1 3 BUYUKMUCENNEB)) (gbm . ,(ly:make-pitch -1 4 BUYUKMUCENNEB)) (abm . ,(ly:make-pitch -1 5 BUYUKMUCENNEB)) (bbm . ,(ly:make-pitch -1 6 BUYUKMUCENNEB)) ;; f for flat. (cfc . ,(ly:make-pitch -1 0 (- KOMA))) (dfc . ,(ly:make-pitch -1 1 (- KOMA))) (efc . ,(ly:make-pitch -1 2 (- KOMA))) (ffc . ,(ly:make-pitch -1 3 (- KOMA))) (gfc . ,(ly:make-pitch -1 4 (- KOMA))) (afc . ,(ly:make-pitch -1 5 (- KOMA))) (bfc . ,(ly:make-pitch -1 6 (- KOMA))) (cfb . ,(ly:make-pitch -1 0 (- BAKIYE))) (dfb . ,(ly:make-pitch -1 1 (- BAKIYE))) (efb . ,(ly:make-pitch -1 2 (- BAKIYE))) (ffb . ,(ly:make-pitch -1 3 (- BAKIYE))) (gfb . ,(ly:make-pitch -1 4 (- BAKIYE))) (afb . ,(ly:make-pitch -1 5 (- BAKIYE))) (bfb . ,(ly:make-pitch -1 6 (- BAKIYE))) (cfk . ,(ly:make-pitch -1 0 (- KUCUK))) (dfk . ,(ly:make-pitch -1 1 (- KUCUK))) (efk . ,(ly:make-pitch -1 2 (- KUCUK))) (ffk . ,(ly:make-pitch -1 3 (- KUCUK))) (gfk . ,(ly:make-pitch -1 4 (- KUCUK))) (afk . ,(ly:make-pitch -1 5 (- KUCUK))) (bfk . ,(ly:make-pitch -1 6 (- KUCUK))) (cfbm . ,(ly:make-pitch -1 0 (- BUYUKMUCENNEB))) (dfbm . ,(ly:make-pitch -1 1 (- BUYUKMUCENNEB))) (efbm . ,(ly:make-pitch -1 2 (- BUYUKMUCENNEB))) (ffbm . ,(ly:make-pitch -1 3 (- BUYUKMUCENNEB))) (gfbm . ,(ly:make-pitch -1 4 (- BUYUKMUCENNEB))) (afbm . ,(ly:make-pitch -1 5 (- BUYUKMUCENNEB))) (bfbm . ,(ly:make-pitch -1 6 (- BUYUKMUCENNEB))) ) %% set pitch names. pitchnames = \makamPitchNames #(ly:parser-set-note-names parser makamPitchNames) makamGlyphs = #'((1 . "accidentals.doublesharp") (8/9 . "accidentals.sharp.slashslashslash.stemstem") (5/9 . "accidentals.sharp.slashslashslash.stem") (4/9 . "accidentals.sharp") (1/9 . "accidentals.sharp.slashslash.stem") (0 . "accidentals.natural") (-1/9 . "accidentals.mirroredflat") (-4/9 . "accidentals.flat.slash") (-5/9 . "accidentals.flat") (-8/9 . "accidentals.flat.slashslash") (-1 . "accidentals.flatflat") ) \relative { %{ define alteration <-> symbol mapping. The following glyphs are available. accidentals.sharp accidentals.sharp.slashslash.stem accidentals.sharp.slashslashslash.stemstem accidentals.sharp.slashslashslash.stem accidentals.sharp.slashslash.stemstemstem accidentals.natural accidentals.flat accidentals.flat.slash accidentals.flat.slashslash accidentals.mirroredflat.flat accidentals.mirroredflat accidentals.flatflat accidentals.flatflat.slash accidentals.doublesharp %} \override Accidental #'glyph-name-alist = \makamGlyphs \override Staff.KeySignature #'glyph-name-alist = \makamGlyphs \set Staff.keySignature = #'( (3 . 4/9) (6 . -1/9)) c cc db fk gbm gfc gfb efk dfbm }
non-traditional-key-signatures.ly
The commonly used \key
command sets the keySignature
property, in the Staff
context. However, non-standard key
signatures can be specified by setting this property directly. The
format of this command is a list: \set Staff.keySignature =
#'(((octave . step) . alter) ((octave . step) . alter) ...)
where,
for each element in the list, octave specifies the octave (0 being the
octave from middle C to the B above), step specifies the note within
the octave (0 means C and 6 means B), and alter is ,SHARP ,FLAT
,DOUBLE-SHARP etc. (Note the leading comma.)
However, for each item in the list, you can also use the alternative format (step . alter), which specifies that the same alteration should hold in all octaves.
Here is an example of a possible key signature for generating a whole-tone scale:
\relative c' { \set Staff.keySignature = #`(((0 . 3) . ,SHARP) ((0 . 5) . ,FLAT) ((0 . 6) . ,FLAT)) c d e fis aes bes c2 }
Internally, the set-octavation function sets the properties
ottavation
(e.g., to "8va"
or "8vb"
) and
middleCPosition
. To override the text of the bracket, set
ottavation
after invoking set-octavation
, like in the
following example.
{ #(set-octavation 1) \set Staff.ottavation = #"8" c''1 #(set-octavation 0) c'1 #(set-octavation 1) \set Staff.ottavation = #"Text" c''1 }
preventing-extra-naturals-from-being-automatically-added.ly
In accordance with standard typesetting rules, a natural sign is printed before a sharp or flat if a previous accidental on the same note needs to be canceled. To change this behavior, set the extraNatural property to "false" in the Staff context.
\relative { aeses'4 aes ais a \set Staff.extraNatural = ##f aeses4 aes ais a }
preventing-natural-signs-from-being-printed-when-the-key-signature-changes.ly
When the key signature changes, natural signs are automatically printed to cancel any accidentals from previous key signatures. This may be altered by setting to "false" the printKeyCancellation property in the Staff context.
\relative { \key d \major a b cis d \key g \minor a bes c d \set Staff.printKeyCancellation = ##f \key d \major a b cis d \key g \minor a bes c d }
quoting-another-voice-with-transposition.ly
Quotations take into account the transposition of both
source and target. In this example, all instruments play sounding
central C, the target is a instrument in F. The target part may be
\transpose
d. In this case, all the pitches (including the
quoted ones) will transposed as well.
\addQuote clarinet { \transposition bes d'16 d'16 d'8 d'16 d'16 d'8 d'16 d'16 d'8 d'16 d'16 d'8 } \addQuote sax { \transposition es' a8 a a a a a a a } quoteTest = { \transposition f % french horn g'4 << \quoteDuring #"clarinet" { \skip 4 } s4^"clar" >> << \quoteDuring #"sax" { \skip 4 } s4^"sax" >> } << \quoteTest \new Staff << \transpose c' d' \quoteTest s4_"up 1 tone" >> >>
transposing-pitches-with-minimum-accidentals-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 this manner, the most natural enharmonic notes are chosen in this example.
#(define (naturalise-pitch p) (let* ((o (ly:pitch-octave p)) (a (* 4 (ly:pitch-alteration p))) ; alteration, a, in quarter tone steps, for historical reasons (n (ly:pitch-notename p))) (cond ((and (> a 1) (or (eq? n 6) (eq? n 2))) (set! a (- a 2)) (set! n (+ n 1))) ((and (< a -1) (or (eq? n 0) (eq? n 3))) (set! a (+ a 2)) (set! n (- n 1)))) (cond ((> a 2) (set! a (- a 4)) (set! n (+ n 1))) ((< a -2) (set! a (+ a 4)) (set! n (- n 1)))) (if (< n 0) (begin (set! o (- o 1)) (set! n (+ n 7)))) (if (> n 6) (begin (set! o (+ o 1)) (set! n (- n 7)))) (ly:make-pitch o n (/ a 4)))) #(define (naturalise music) (let* ((es (ly:music-property music 'elements)) (e (ly:music-property music 'element)) (p (ly:music-property music 'pitch))) (if (pair? es) (ly:music-set-property! music 'elements (map (lambda (x) (naturalise x)) es))) (if (ly:music? e) (ly:music-set-property! music 'element (naturalise e))) (if (ly:pitch? p) (begin (set! p (naturalise-pitch p)) (ly:music-set-property! music 'pitch p))) music)) music = \relative c' { c4 d e f g a b c } naturaliseMusic = #(define-music-function (parser location m) (ly:music?) (naturalise m)) \score { \new Staff { \transpose c ais \music \naturaliseMusic \transpose c ais \music \break \transpose c deses \music \naturaliseMusic \transpose c deses \music } \layout { ragged-right = ##t} }
This page is for LilyPond-2.11.40 (development-branch).
Report errors to http://post.gmane.org/post.php?group=gmane.comp.gnu.lilypond.bugs.
Your suggestions for the documentation are welcome.