Pitches
Pitches
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
}
>>
|
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
}
>>
}
|
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
}
|
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
}
>>
|
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'
}
}
>>
|
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
}
}
|
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
}
|
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''
}
|
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
}
>>
}
|
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
}
|
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
}
}
|
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,
}
|
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
}
|
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))))
}
}
|
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
}
|
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
}
|
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
}
|
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
}
|
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.
Alternatively, using the more concise format for each item in the list,
(step . alter)
specifies the same alteration holds in all
octaves. For microtonal scales where a “sharp” is not 100 cents,
alter
refers to the proportion of a 200-cent whole tone.
| \include "arabic.ly"
\relative do' {
\set Staff.keyAlterations = #`((0 . ,SEMI-FLAT)
(1 . ,SEMI-FLAT)
(2 . ,FLAT)
(5 . ,FLAT)
(6 . ,SEMI-FLAT))
%\set Staff.extraNatural = ##f
re reb \dwn reb resd
dod dob dosd \dwn dob |
dobsb dodsd do do |
}
|
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
}
|
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.
| #(set-global-staff-size 17)
\paper {
indent = 3.0\cm % add space for instrumentName
short-indent = 1.5\cm % add less space for shortInstrumentName
}
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 { }
}
|
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
}
|
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
}
|
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 clarinet {
\transposition bes
\repeat unfold 8 { d'16 d' d'8 }
}
\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
}
|
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
}
|
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
}
>>
}
|