[ << Top ] | [Top][Contents][Index][ ? ] | [ Rhythms >> ] | ||
[ < Top ] | [ Up : Top ] | [ Pitches: Adding ambitus per voice > ] |
Pitches
[ << Pitches ] | [Top][Contents][Index][ ? ] | [ Rhythms >> ] | ||
[ < Pitches ] | [ Up : Pitches ] | [ Pitches: Adding an ottava marking to a single voice > ] |
Adding ambitus per voice
Ambitus can be added per voice. In this 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 } >>
[ << Pitches ] | [Top][Contents][Index][ ? ] | [ Rhythms >> ] | ||
[ < Pitches: Adding ambitus per voice ] | [ Up : Pitches ] | [ Pitches: Aiken head thin variant noteheads > ] |
Adding an ottava marking to a single voice
If you have more than one voice on the staff, setting octavation in one voice will transpose the position of notes in all voices for the duration of the ottava bracket. If the ottavation is only intended to apply to one voice, the middleCPosition and ottava bracket may be set explicitly. In this snippet, the bass clef usually has middleCPosition set to 6, six positions above the center line, so in the 8va portion middleCPosition is 7 positions (one octave) higher still.
{ \clef bass << { <g d'>1~ q2 <c' e'> } \\ { r2. \set Staff.ottavation = #"8vb" \once \override Staff.OttavaBracket.direction = #DOWN \set Voice.middleCPosition = #(+ 6 7) <b,,, b,,>4 ~ | q2 \unset Staff.ottavation \unset Voice.middleCPosition <c e>2 } >> }
[ << Pitches ] | [Top][Contents][Index][ ? ] | [ Rhythms >> ] | ||
[ < Pitches: Adding an ottava marking to a single voice ] | [ Up : Pitches ] | [ Pitches: Altering the length of beamed stems > ] |
Aiken head thin variant noteheads
Aiken head white notes get harder to read at smaller staff sizes, especially with ledger lines. Losing interior white space makes them appear as quarter notes.
} % END EXAMPLE
[ << Pitches ] | [Top][Contents][Index][ ? ] | [ Rhythms >> ] | ||
[ < Pitches: Aiken head thin variant noteheads ] | [ Up : Pitches ] | [ Pitches: Ambitus with multiple voices > ] |
Altering the length of beamed stems
Stem lengths on beamed notes can be varied by overriding the
beamed-lengths
property of the details
of the
Stem
. If a single value is used as an argument, the length
applies to all stems. When multiple arguments are used, the first
applies to eighth notes, the second to sixteenth notes and so on. The
final argument also applies to all notes shorter than the note length
of the final argument. Non-integer arguments may also be used.
\relative c'' { \override Stem.details.beamed-lengths = #'(2) a8[ a] a16[ a] a32[ a] \override Stem.details.beamed-lengths = #'(8 10 12) a8[ a] a16[ a] a32[ a] r8 \override Stem.details.beamed-lengths = #'(8) a8[ a] \override Stem.details.beamed-lengths = #'(8.5) a8[ a] \revert Stem.details a8[ a] a16[ a] a32[ a] r16 }
[ << Pitches ] | [Top][Contents][Index][ ? ] | [ Rhythms >> ] | ||
[ < Pitches: Altering the length of beamed stems ] | [ Up : Pitches ] | [ Pitches: Ambitus > ] |
Ambitus with multiple voices
Adding the Ambitus_engraver
to the Staff
context creates
a single ambitus per staff, even in the case of staves with multiple
voices.
\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 } >>
[ << Pitches ] | [Top][Contents][Index][ ? ] | [ Rhythms >> ] | ||
[ < Pitches: Ambitus with multiple voices ] | [ Up : Pitches ] | [ Pitches: Applying note head styles depending on the step of the scale > ] |
Ambitus
Ambitus indicate pitch ranges for voices.
Accidentals only show up if they are not part of the key signature.
AmbitusNoteHead
grobs also have ledger lines.
\layout { \context { \Voice \consists "Ambitus_engraver" } } << \new Staff { \relative c' { \time 2/4 c4 f' } } \new Staff { \relative c' { \time 2/4 \key d \major cis4 as' } } >>
[ << Pitches ] | [Top][Contents][Index][ ? ] | [ Rhythms >> ] | ||
[ < Pitches: Ambitus ] | [ Up : Pitches ] | [ Pitches: Automatically changing the stem direction of the middle note based on the melody > ] |
Applying note head styles depending on the step of the scale
The shapeNoteStyles
property can be used to define various note
head styles for each step of the scale (as set 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
, and xcircle
are allowed) or based
on old American engraving tradition (some latin note names are also
allowed).
That said, to imitate old American song books, there are several
predefined note head styles available 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 correspondence between harmonic functions and note head styles.
fragment = { \key c \major c2 d e2 f g2 a b2 c } \new Staff { \transpose c d \relative c' { \set shapeNoteStyles = ##(do re mi fa #f la ti) \fragment } \break \relative c' { \set shapeNoteStyles = ##(cross triangle fa #f mensural xcircle diamond) \fragment } }
[ << Pitches ] | [Top][Contents][Index][ ? ] | [ Rhythms >> ] | ||
[ < Pitches: Applying note head styles depending on the step of the scale ] | [ Up : Pitches ] | [ Pitches: Changing ottava text > ] |
Automatically changing the stem direction of the middle note based on the melody
LilyPond can alter the stem direction of the middle note on a staff so
that it follows the melody, by adding the Melody_engraver
to the
Voice context and overriding the neutral-direction
of Stem.
\relative c'' { \time 3/4 a8 b g f b g | c b d c b c | } \layout { \context { \Voice \consists "Melody_engraver" \autoBeamOff \override Stem.neutral-direction = #'() } }
Changing ottava text
Internally, \ottava
sets the properties ottavation
(for
example, to 8va
or 8vb
) and middleCPosition
. To
override the text of the bracket, set ottavation
after invoking
\ottava
.
Short text is especially useful when a brief ottava is used.
{ c'2 \ottava #1 \set Staff.ottavation = #"8" c''2 \ottava #0 c'1 \ottava #1 \set Staff.ottavation = #"Text" c''1 }
[ << Pitches ] | [Top][Contents][Index][ ? ] | [ Rhythms >> ] | ||
[ < Pitches: Changing ottava text ] | [ Up : Pitches ] | [ Pitches: Changing the interval of lines on the stave > ] |
Changing the ambitus gap
It is possible to change the default gap between the ambitus noteheads and the line joining them.
\layout { \context { \Voice \consists "Ambitus_engraver" } } \new Staff { \time 2/4 % Default setting c'4 g'' } \new Staff { \time 2/4 \override AmbitusLine.gap = #0 c'4 g'' } \new Staff { \time 2/4 \override AmbitusLine.gap = #1 c'4 g'' } \new Staff { \time 2/4 \override AmbitusLine.gap = #1.5 c'4 g'' }
[ << Pitches ] | [Top][Contents][Index][ ? ] | [ Rhythms >> ] | ||
[ < Pitches: Changing the ambitus gap ] | [ Up : Pitches ] | [ Pitches: Clefs can be transposed by arbitrary amounts > ] |
Changing the interval of lines on the stave
staffLineLayoutFunction
is used to change the position of notes.
This snippet shows setting its value to ly:pitch-semitones
in
order to produce a chromatic scale with the distance between each space
and line of the stave equal to one semitone.
scale = \relative c' { a4 ais b c cis4 d dis e f4 fis g gis a1 } \new Staff \with { \remove "Accidental_engraver" staffLineLayoutFunction = #ly:pitch-semitones } { << \scale \context NoteNames { \set printOctaveNames = ##f \scale } >> }
[ << Pitches ] | [Top][Contents][Index][ ? ] | [ Rhythms >> ] | ||
[ < Pitches: Changing the interval of lines on the stave ] | [ Up : Pitches ] | [ Pitches: Coloring notes depending on their pitch > ] |
Clefs can be transposed by arbitrary amounts
Clefs can be transposed by arbitrary amounts, not just by octaves.
\relative c' { \clef treble c4 c c c \clef "treble_8" c4 c c c \clef "treble_5" c4 c c c \clef "treble^3" c4 c c c }
[ << Pitches ] | [Top][Contents][Index][ ? ] | [ Rhythms >> ] | ||
[ < Pitches: Clefs can be transposed by arbitrary amounts ] | [ Up : Pitches ] | [ Pitches: Creating a sequence of notes on various pitches > ] |
Coloring notes depending on their pitch
It is possible to color note heads depending on their pitch and/or their names: the function used in this example even makes it possible to distinguish enharmonics.
%Association list of pitches to colors. #(define color-mapping (list (cons (ly:make-pitch 0 0 NATURAL) (x11-color 'red)) (cons (ly:make-pitch 0 0 SHARP) (x11-color 'green)) (cons (ly:make-pitch 0 1 FLAT) (x11-color 'green)) (cons (ly:make-pitch 0 2 NATURAL) (x11-color 'red)) (cons (ly:make-pitch 0 2 SHARP) (x11-color 'green)) (cons (ly:make-pitch 0 3 FLAT) (x11-color 'red)) (cons (ly:make-pitch 0 3 NATURAL) (x11-color 'green)) (cons (ly:make-pitch 0 4 SHARP) (x11-color 'red)) (cons (ly:make-pitch 0 5 NATURAL) (x11-color 'green)) (cons (ly:make-pitch 0 5 FLAT) (x11-color 'red)) (cons (ly:make-pitch 0 6 SHARP) (x11-color 'red)) (cons (ly:make-pitch 0 1 NATURAL) (x11-color 'blue)) (cons (ly:make-pitch 0 3 SHARP) (x11-color 'blue)) (cons (ly:make-pitch 0 4 FLAT) (x11-color 'blue)) (cons (ly:make-pitch 0 5 SHARP) (x11-color 'blue)) (cons (ly:make-pitch 0 6 FLAT) (x11-color 'blue)))) %Compare pitch and alteration (not octave). #(define (pitch-equals? p1 p2) (and (= (ly:pitch-alteration p1) (ly:pitch-alteration p2)) (= (ly:pitch-notename p1) (ly:pitch-notename p2)))) #(define (pitch-to-color pitch) (let ((color (assoc pitch color-mapping pitch-equals?))) (if color (cdr color)))) #(define (color-notehead grob) (pitch-to-color (ly:event-property (event-cause grob) 'pitch))) \score { \new Staff \relative c' { \override NoteHead.color = #color-notehead c8 b d dis ees f g aes } }
[ << Pitches ] | [Top][Contents][Index][ ? ] | [ Rhythms >> ] | ||
[ < Pitches: Coloring notes depending on their pitch ] | [ Up : Pitches ] | [ Pitches: Creating custom key signatures > ] |
Creating a sequence of notes on various pitches
In music that contains many occurrences of the same sequence of notes at different pitches, the following music function may prove useful. It takes a note, of which only the pitch is used. This example creates the rhythm used throughout Mars, from Gustav Holst’s The Planets.
rhythm = #(define-music-function (p) (ly:pitch?) "Make the rhythm in Mars (the Planets) at the given pitch" #{ \tuplet 3/2 { $p 8 8 8 } 4 4 8 8 4 #}) \new Staff { \time 5/4 \rhythm c' \rhythm c'' \rhythm g }
Creating custom key signatures
LilyPond supports custom key signatures. In this example, print for D minor with an extended range of printed flats.
\new Staff \with { \override StaffSymbol.line-count = #8 \override KeySignature.flat-positions = #'((-7 . 6)) \override KeyCancellation.flat-positions = #'((-7 . 6)) % presumably sharps are also printed in both octaves \override KeySignature.sharp-positions = #'((-6 . 7)) \override KeyCancellation.sharp-positions = #'((-6 . 7)) \override Clef.stencil = # (lambda (grob)(grob-interpret-markup grob #{ \markup\combine \musicglyph #"clefs.C" \translate #'(-3 . -2) \musicglyph #"clefs.F" #})) clefPosition = #3 middleCPosition = #3 middleCClefPosition = #3 } { \key d\minor f bes, f bes, }
[ << Pitches ] | [Top][Contents][Index][ ? ] | [ Rhythms >> ] | ||
[ < Pitches: Creating custom key signatures ] | [ Up : Pitches ] | [ Pitches: Forcing a clef symbol to be displayed > ] |
Customize drumPitchNames drumStyleTable and drumPitchTable in layout and midi
If you want to use customized drum-pitch-names for an own drum-style with proper output for layout and midi, follow the steps as demonstrated in the code below. In short:
* define the names * define the appearence * tell LilyPond to use it for layout * assign pitches to the names * tell LilyPond to use them for midi
%% This snippet tries to amend %% NR 2.5.1 Common notation for percussion - Custom percussion staves %% http://lilypond.org/doc/v2.18/Documentation/notation/common-notation-for-percussion#custom-percussion-staves %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% %% To use custom drum-pitch-names for your score and midi you need to follow %% this route: %% %%%%%%%%%%%% %% LAYOUT: %%%%%%%%%%%% %% %% (1) Define a name and put it in `drumPitchNames' %% This can be done at toplevel with %% drumPitchNames #'my-name = #'my-name %% or shorter: %% drumPitchNames.my-name = #'my-name %% It's possible to add an alias as well. %% (2) Define how it should be printed %% Therefore put them into a toplevel-list, where each entry should look: %% (my-name %% note-head-style-or-default %% articulation-string-or-#f %% staff-position) %% Example: %% #(define my-style %% '( %% (my-name default "tenuto" -1) %% ; ... %% )) %% (3) Tell LilyPond to use this custom-definitions, with %% drumStyleTable = #(alist->hash-table my-style) %% in a \layout or \with %% %% Now we're done for layout, here a short, but complete example: %% \new DrumStaff %% \with { drumStyleTable = #(alist->hash-table my-style) } %% \drummode { my-name } %% %%%%%%%%%%%% %% MIDI: %%%%%%%%%%%% %% %% (1) Again at toplvel, assign a pitch to your custom-note-name %% midiDrumPitches #'my-name = #(ly:make-pitch -1 4 FLAT) %% or shorter: %% midiDrumPitches.my-name = ges %% Note that you have to use the name, which is in drumPitchNames, no alias %% (2) Tell LilyPond to use this pitch(es), with %% drumPitchTable = #(alist->hash-table midiDrumPitches) %% %% Example: %% \score { %% \new DrumStaff %% \with { %% drumStyleTable = #(alist->hash-table my-style) %% drumPitchTable = #(alist->hash-table midiDrumPitches) %% } %% \drummode { my-name4 } %% \layout {} %% \midi {} %% } %% %%%%%%%%%%%% %% TESTING %%%%%%%%%%%% %% %% To test whether all is fine, run the following sequence in terminal: %% lilypond my-file.ly %% midi2ly my-file.midi %% gedit my-file-midi.ly %% %% Which will do: %% 1. create pdf and midi %% 2. transform the midi back to a .ly-file %% (note: midi2ly is not always good in correctly identifying enharmonic pitches) %% 3. open this file in gedit (or use another editor) %% Now watch what you've got. %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% FULL EXAMPLE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% drumPitchNames.dbass = #'dbass drumPitchNames.dba = #'dbass % 'db is in use already drumPitchNames.dbassmute = #'dbassmute drumPitchNames.dbm = #'dbassmute drumPitchNames.do = #'dopen drumPitchNames.dopenmute = #'dopenmute drumPitchNames.dom = #'dopenmute drumPitchNames.dslap = #'dslap drumPitchNames.ds = #'dslap drumPitchNames.dslapmute = #'dslapmute drumPitchNames.dsm = #'dslapmute #(define djembe '((dbass default #f -2) (dbassmute default "stopped" -2) (dopen default #f 0) (dopenmute default "stopped" 0) (dslap default #f 2) (dslapmute default "stopped" 2))) midiDrumPitches.dbass = g midiDrumPitches.dbassmute = fis midiDrumPitches.dopen = a midiDrumPitches.dopenmute = gis midiDrumPitches.dslap = b midiDrumPitches.dslapmute = ais one = \drummode { r4 dba4 do ds r dbm dom dsm } \score { \new DrumStaff \with { \override StaffSymbol.line-count = #3 instrumentName = #"Djembe " drumStyleTable = #(alist->hash-table djembe) drumPitchTable = #(alist->hash-table midiDrumPitches) } \one \layout {} \midi {} }
Forcing a clef symbol to be displayed
When a clef sign has already been displayed and it has not been changed
to a different clef, then repeating the \clef
command will be
ignored by LilyPond, since it is not a change of clef. It is possible
to force the clef to be redisplayed using the command \set
Staff.forceClef = ##t
.
\relative c' { \clef treble c1 \clef treble c1 \set Staff.forceClef = ##t c1 \clef treble c1 }
[ << Pitches ] | [Top][Contents][Index][ ? ] | [ Rhythms >> ] | ||
[ < Pitches: Forcing a clef symbol to be displayed ] | [ Up : Pitches ] | [ Pitches: Hiding accidentals on tied notes at the start of a new system > ] |
Generating random notes
This Scheme-based snippet generates 24 random notes (or as many as required), based on the current time (or any randomish number specified instead, in order to obtain the same random notes each time): i.e., to get different random note patterns, just change this number.
\score { { $(let ((random-state (seed->random-state (current-time)))) (make-sequential-music (map (lambda (x) (let ((idx (random 12 random-state))) (make-event-chord (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)))) } }
[ << Pitches ] | [Top][Contents][Index][ ? ] | [ Rhythms >> ] | ||
[ < Pitches: Generating random notes ] | [ Up : Pitches ] | [ Pitches: Keep change clefs full sized > ] |
Hiding accidentals on tied notes at the start of a new system
This shows how to hide accidentals on tied notes at the start of a new system.
\relative c'' { \override Accidental.hide-tied-accidental-after-break = ##t cis1~ cis~ \break cis }
[ << Pitches ] | [Top][Contents][Index][ ? ] | [ Rhythms >> ] | ||
[ < Pitches: Hiding accidentals on tied notes at the start of a new system ] | [ Up : Pitches ] | [ Pitches: Makam example > ] |
Keep change clefs full sized
When a clef is changed, the clef sign displayed is smaller than the
initial clef. This can be overridden with full-size-change
.
\relative c' { \clef "treble" c1 \clef "bass" c1 \clef "treble" c1 \override Staff.Clef.full-size-change = ##t \clef "bass" c1 \clef "treble" c1 \revert Staff.Clef.full-size-change \clef "bass" c1 \clef "treble" c1 }
[ << Pitches ] | [Top][Contents][Index][ ? ] | [ Rhythms >> ] | ||
[ < Pitches: Keep change clefs full sized ] | [ Up : Pitches ] | [ Pitches: Modifying the Ottava spanner slope > ] |
Makam example
Makam is a type of melody from Turkey using 1/9th-tone microtonal alterations. Consult the initialization file ‘ly/makam.ly’ for details of pitch names and alterations.
% Initialize makam settings \include "makam.ly" \relative c' { \set Staff.keyAlterations = #`((6 . ,(- KOMA)) (3 . ,BAKIYE)) c4 cc db fk gbm4 gfc gfb efk fk4 db cc c }
[ << Pitches ] | [Top][Contents][Index][ ? ] | [ Rhythms >> ] | ||
[ < Pitches: Makam example ] | [ Up : Pitches ] | [ Pitches: Non-traditional key signatures > ] |
Modifying the Ottava spanner slope
It is possible to change the slope of the Ottava spanner.
\relative c'' { \override Staff.OttavaBracket.stencil = #ly:line-spanner::print \override Staff.OttavaBracket.bound-details = #`((left . ((Y . 0) ; Change the integer here (attach-dir . ,LEFT) (padding . 0) (stencil-align-dir-y . ,CENTER))) (right . ((Y . 5) ; Change the integer here (padding . 0) (attach-dir . ,RIGHT) (text . ,(make-draw-dashed-line-markup (cons 0 -1.2)))))) \override Staff.OttavaBracket.left-bound-info = #ly:line-spanner::calc-left-bound-info-and-text \override Staff.OttavaBracket.right-bound-info = #ly:line-spanner::calc-right-bound-info \ottava #1 c1 c'''1 }
[ << Pitches ] | [Top][Contents][Index][ ? ] | [ Rhythms >> ] | ||
[ < Pitches: Modifying the Ottava spanner slope ] | [ Up : Pitches ] | [ Pitches: Numbers as easy note heads > ] |
Non-traditional key signatures
The commonly used \key
command sets the keyAlterations
property, in the Staff
context.
To create non-standard key signatures, set this property directly. The format of this command is a list:
\set Staff.keyAlterations = #`(((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.)
Alternatively, for each item in the list, using the more concise format
(step . alter)
specifies that the same alteration should hold in
all octaves.
For microtonal scales where a “sharp” is not 100 cents, alter
refers to the alteration as a proportion of a 200-cent whole tone.
Here is an example of a possible key signature for generating a whole-tone scale:
\relative { \set Staff.keyAlterations = #`((6 . ,FLAT) (5 . ,FLAT) (3 . ,SHARP)) c'4 d e fis aes4 bes c2 }
[ << Pitches ] | [Top][Contents][Index][ ? ] | [ Rhythms >> ] | ||
[ < Pitches: Non-traditional key signatures ] | [ Up : Pitches ] | [ Pitches: Orchestra choir and piano template > ] |
Numbers as easy note heads
Easy notation note heads use the note-names
property of the
NoteHead
object to determine what appears inside the note head.
By overriding this property, it is possible to print numbers
representing the scale-degree.
A simple engraver can be created to do this for every note head object it sees.
#(define Ez_numbers_engraver (make-engraver (acknowledgers ((note-head-interface engraver grob source-engraver) (let* ((context (ly:translator-context engraver)) (tonic-pitch (ly:context-property context 'tonic)) (tonic-name (ly:pitch-notename tonic-pitch)) (grob-pitch (ly:event-property (event-cause grob) 'pitch)) (grob-name (ly:pitch-notename grob-pitch)) (delta (modulo (- grob-name tonic-name) 7)) (note-names (make-vector 7 (number->string (1+ delta))))) (ly:grob-set-property! grob 'note-names note-names)))))) #(set-global-staff-size 26) \layout { ragged-right = ##t \context { \Voice \consists \Ez_numbers_engraver } } \relative c' { \easyHeadsOn c4 d e f g4 a b c \break \key a \major a,4 b cis d e4 fis gis a \break \key d \dorian d,4 e f g a4 b c d }
[ << Pitches ] | [Top][Contents][Index][ ? ] | [ Rhythms >> ] | ||
[ < Pitches: Numbers as easy note heads ] | [ Up : Pitches ] | [ Pitches: Ottava text > ] |
Orchestra choir and piano template
This template demonstrates the use of nested StaffGroup
and
GrandStaff
contexts to sub-group instruments of the same type
together, and a way to use \transpose
so that variables hold
music for transposing instruments at concert pitch.
fluteMusic = \relative c' { \key g \major g'1 b } % Pitches as written on a manuscript for Clarinet in A % are transposed to concert pitch. clarinetMusic = \transpose c' a \relative c'' { \key bes \major bes1 d } trumpetMusic = \relative c { \key g \major g''1 b } % Key signature is often omitted for horns hornMusic = \transpose c' f \relative c { d'1 fis } percussionMusic = \relative c { \key g \major g1 b } sopranoMusic = \relative c'' { \key g \major g'1 b } sopranoLyrics = \lyricmode { Lyr -- ics } altoIMusic = \relative c' { \key g \major g'1 b } altoIIMusic = \relative c' { \key g \major g'1 b } altoILyrics = \sopranoLyrics altoIILyrics = \lyricmode { Ah -- ah } tenorMusic = \relative c' { \clef "treble_8" \key g \major g1 b } tenorLyrics = \sopranoLyrics pianoRHMusic = \relative c { \key g \major g''1 b } pianoLHMusic = \relative c { \clef bass \key g \major g1 b } violinIMusic = \relative c' { \key g \major g'1 b } violinIIMusic = \relative c' { \key g \major g'1 b } violaMusic = \relative c { \clef alto \key g \major g'1 b } celloMusic = \relative c { \clef bass \key g \major g1 b } bassMusic = \relative c { \clef "bass_8" \key g \major g,1 b } \score { << \new StaffGroup = "StaffGroup_woodwinds" << \new Staff = "Staff_flute" \with { instrumentName = #"Flute" } \fluteMusic \new Staff = "Staff_clarinet" \with { instrumentName = \markup { \concat { "Clarinet in B" \flat } } } % Declare that written Middle C in the music % to follow sounds a concert B flat, for % output using sounded pitches such as MIDI. %\transposition bes % Print music for a B-flat clarinet \transpose bes c' \clarinetMusic >> \new StaffGroup = "StaffGroup_brass" << \new Staff = "Staff_hornI" \with { instrumentName = #"Horn in F" } % \transposition f \transpose f c' \hornMusic \new Staff = "Staff_trumpet" \with { instrumentName = #"Trumpet in C" } \trumpetMusic >> \new RhythmicStaff = "RhythmicStaff_percussion" \with { instrumentName = #"Percussion" } << \percussionMusic >> \new PianoStaff \with { instrumentName = #"Piano" } << \new Staff { \pianoRHMusic } \new Staff { \pianoLHMusic } >> \new ChoirStaff = "ChoirStaff_choir" << \new Staff = "Staff_soprano" \with { instrumentName = #"Soprano" } \new Voice = "soprano" \sopranoMusic \new Lyrics \lyricsto "soprano" { \sopranoLyrics } \new GrandStaff = "GrandStaff_altos" \with { \accepts Lyrics } << \new Staff = "Staff_altoI" \with { instrumentName = #"Alto I" } \new Voice = "altoI" \altoIMusic \new Lyrics \lyricsto "altoI" { \altoILyrics } \new Staff = "Staff_altoII" \with { instrumentName = #"Alto II" } \new Voice = "altoII" \altoIIMusic \new Lyrics \lyricsto "altoII" { \altoIILyrics } >> \new Staff = "Staff_tenor" \with { instrumentName = #"Tenor" } \new Voice = "tenor" \tenorMusic \new Lyrics \lyricsto "tenor" { \tenorLyrics } >> \new StaffGroup = "StaffGroup_strings" << \new GrandStaff = "GrandStaff_violins" << \new Staff = "Staff_violinI" \with { instrumentName = #"Violin I" } \violinIMusic \new Staff = "Staff_violinII" \with { instrumentName = #"Violin II" } \violinIIMusic >> \new Staff = "Staff_viola" \with { instrumentName = #"Viola" } \violaMusic \new Staff = "Staff_cello" \with { instrumentName = #"Cello" } \celloMusic \new Staff = "Staff_bass" \with { instrumentName = #"Double Bass" } \bassMusic >> >> \layout { } }
[ << Pitches ] | [Top][Contents][Index][ ? ] | [ Rhythms >> ] | ||
[ < Pitches: Orchestra choir and piano template ] | [ Up : Pitches ] | [ Pitches: Preventing extra naturals from being automatically added > ] |
Ottava text
Internally, \ottava
sets the properties ottavation
(for
example, to 8va
or 8vb
) and middleCPosition
. To
override the text of the bracket, set ottavation
after invoking
\ottava
.
{ \ottava #1 \set Staff.ottavation = #"8" c''1 \ottava #0 c'1 \ottava #1 \set Staff.ottavation = #"Text" c''1 }
[ << Pitches ] | [Top][Contents][Index][ ? ] | [ Rhythms >> ] | ||
[ < Pitches: Ottava text ] | [ Up : Pitches ] | [ Pitches: Preventing natural signs from being printed when the key signature changes > ] |
Preventing extra naturals from being automatically added
In accordance with traditional typesetting rules, a natural sign is
printed before a sharp or flat if a previous double sharp or flat on
the same note is canceled. To change this behavior to contemporary
practice, set the extraNatural
property to f
in the
Staff
context.
\relative c'' { aeses4 aes ais a \set Staff.extraNatural = ##f aeses4 aes ais a }
[ << Pitches ] | [Top][Contents][Index][ ? ] | [ Rhythms >> ] | ||
[ < Pitches: Preventing extra naturals from being automatically added ] | [ Up : Pitches ] | [ Pitches: Quoting another voice with transposition > ] |
Preventing natural signs from being printed when the key signature changes
When the key signature changes, natural signs are automatically printed
to cancel any accidentals from previous key signatures. This may be
prevented by setting to f
the printKeyCancellation
property in the Staff
context.
\relative c' { \key d \major a4 b cis d \key g \minor a4 bes c d \set Staff.printKeyCancellation = ##f \key d \major a4 b cis d \key g \minor a4 bes c d }
Quoting another voice with transposition
Quotations take into account the transposition of both source and
target. In this example, all instruments play sounding middle C; the
target is an instrument in F. The target part may be transposed using
\transpose
. In this case, all the pitches (including the
quoted ones) are transposed.
} \addQuote sax { \transposition es' \repeat unfold 16 { a8 } } quoteTest = { % french horn \transposition f g'4 << \quoteDuring #"clarinet" { \skip 4 } s4^"clar." >> << \quoteDuring #"sax" { \skip 4 } s4^"sax." >> g'4 } { \new Staff \with { instrumentName = \markup { \column { Horn "in F" } } } \quoteTest \transpose c' d' << \quoteTest s4_"up a tone" >> }
Separating key cancellations from key signature changes
By default, the accidentals used for key cancellations are placed
adjacent to those for key signature changes. This behavior can be
changed by overriding the 'break-align-orders
property of the
BreakAlignment
grob.
The value of 'break-align-orders
is a vector of length 3, with
quoted lists of breakable items as elements. This example only
modifies the second list, moving key-cancellation
before
staff-bar
; by modifying the second list, break alignment
behavior only changes in the middle of a system, not at the beginning
or the end.
\new Staff { \override Score.BreakAlignment.break-align-orders = ##((left-edge ambitus breathing-sign clef staff-bar key-cancellation key-signature time-signature custos) (left-edge ambitus breathing-sign clef key-cancellation staff-bar key-signature time-signature custos) (left-edge ambitus breathing-sign clef key-cancellation key-signature staff-bar time-signature custos)) \key des \major c'1 \bar "||" \key bes \major c'1 }
[ << Pitches ] | [Top][Contents][Index][ ? ] | [ Rhythms >> ] | ||
[ < Pitches: Separating key cancellations from key signature changes ] | [ Up : Pitches ] | [ Pitches: Tweaking clef properties > ] |
Transposing pitches with minimum accidentals ("Smart" transpose)
This example uses some Scheme code to enforce enharmonic modifications for notes in order to have the minimum number of accidentals. In this case, the following rules apply:
Double accidentals should be removed
B sharp -> C
E sharp -> F
C flat -> B
F flat -> E
In this manner, the most natural enharmonic notes are chosen.
#(define (naturalize-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 (eqv? n 6) (eqv? n 2))) (set! a (- a 2)) (set! n (+ n 1))) ((and (< a -1) (or (eqv? n 0) (eqv? 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 (naturalize 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 naturalize es))) (if (ly:music? e) (ly:music-set-property! music 'element (naturalize e))) (if (ly:pitch? p) (begin (set! p (naturalize-pitch p)) (ly:music-set-property! music 'pitch p))) music)) naturalizeMusic = #(define-music-function (m) (ly:music?) (naturalize m)) music = \relative c' { c4 d e g } \score { \new Staff { \transpose c ais { \music } \naturalizeMusic \transpose c ais { \music } \transpose c deses { \music } \naturalizeMusic \transpose c deses { \music } } \layout { } }
Tweaking clef properties
Changing the Clef glyph, its position, or the ottavation does not
change the position of subsequent notes on the staff. To get key
signatures on their correct staff lines middleCClefPosition
must
also be specified, with positive or negative values moving middle
C
up or down respectively, relative to the staff’s center line.
For example, \clef "treble_8"
is equivalent to setting the
clefGlyph
, clefPosition
(the vertical position of the
clef itself on the staff), middleCPosition
and
clefTransposition
. Note that when any of these properties
(except middleCPosition
) are changed a new clef symbol is
printed.
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 \key f \major c'1 % The standard bass clef \set Staff.clefGlyph = #"clefs.F" \set Staff.clefPosition = #2 \set Staff.middleCPosition = #6 \set Staff.middleCClefPosition = #6 \key g \major c'1 % The baritone clef \set Staff.clefGlyph = #"clefs.C" \set Staff.clefPosition = #4 \set Staff.middleCPosition = #4 \set Staff.middleCClefPosition = #4 \key f \major c'1 % The standard choral tenor clef \set Staff.clefGlyph = #"clefs.G" \set Staff.clefPosition = #-2 \set Staff.clefTransposition = #-7 \set Staff.middleCPosition = #1 \set Staff.middleCClefPosition = #1 \key f \major c'1 % A non-standard clef \set Staff.clefPosition = #0 \set Staff.clefTransposition = #0 \set Staff.middleCPosition = #-4 \set Staff.middleCClefPosition = #-4 \key g \major c'1 \break % The following clef changes do not preserve % the normal relationship between notes, key signatures % and clefs: \set Staff.clefGlyph = #"clefs.F" \set Staff.clefPosition = #2 c'1 \set Staff.clefGlyph = #"clefs.G" c'1 \set Staff.clefGlyph = #"clefs.C" c'1 \set Staff.clefTransposition = #7 c'1 \set Staff.clefTransposition = #0 \set Staff.clefPosition = #0 c'1 % Return to the normal clef: \set Staff.middleCPosition = #0 c'1 }
[ << Pitches ] | [Top][Contents][Index][ ? ] | [ Rhythms >> ] | ||
[ < Pitches: Tweaking clef properties ] | [ Up : Pitches ] | [ Rhythms > ] |
Using autochange with more than one voice
Using autochange
with more than one voice.
\score { \new PianoStaff << \new Staff = "up" { << \set Timing.beamExceptions = #'() \set Timing.beatStructure = #'(4) \new Voice { \voiceOne \autochange \relative c' { g8 a b c d e f g g,8 a b c d e f g } } \new Voice { \voiceTwo \autochange \relative c' { g8 a b c d e f g g,,8 a b c d e f g } } >> } \new Staff = "down" { \clef bass } >> }
[ << Pitches ] | [Top][Contents][Index][ ? ] | [ Rhythms >> ] | ||
[ < Pitches: Tweaking clef properties ] | [ Up : Pitches ] | [ Rhythms > ] |