]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/notation/pitches.itely
ffa4e33b0b30276c932f0a1c000678ea9975b45d
[lilypond.git] / Documentation / notation / pitches.itely
1 @c -*- coding: utf-8; mode: texinfo; -*-
2 @ignore
3    Translation of GIT committish: FILL-IN-HEAD-COMMITTISH
4
5     When revising a translation, copy the HEAD committish of the
6     version that you are working on.  For details, see the Contributors'
7     Guide, node Updating translation committishes..
8 @end ignore
9
10 @c \version "2.19.22"
11
12
13 @node Pitches
14 @section Pitches
15
16 @lilypondfile[quote]{pitches-headword.ly}
17
18 This section discusses how to specify the pitch of notes.  There
19 are three steps to this process: input, modification, and output.
20
21 @menu
22 * Writing pitches::
23 * Changing multiple pitches::
24 * Displaying pitches::
25 * Note heads::
26 @end menu
27
28
29 @node Writing pitches
30 @subsection Writing pitches
31
32 This section discusses how to input pitches.  There are two
33 different ways to place notes in octaves: absolute and relative
34 mode.  In most cases, relative mode will be more convenient.
35
36 @menu
37 * Absolute octave entry::
38 * Relative octave entry::
39 * Accidentals::
40 * Note names in other languages::
41 @end menu
42
43
44 @node Absolute octave entry
45 @unnumberedsubsubsec Absolute octave entry
46
47 @cindex pitch names
48 @cindex pitches
49 @cindex absolute
50 @cindex absolute octave specification
51 @cindex octave specification, absolute
52 @cindex absolute octave entry
53 @cindex octave entry, absolute
54
55 A pitch name is specified using lowercase letters@tie{}@code{a}
56 through@tie{}@code{g}.  The note names @code{c} to @code{b} are
57 engraved in the octave below middle C.
58
59 @c don't use c' here.
60 @lilypond[verbatim,quote]
61 {
62   \clef bass
63   c4 d e f
64   g4 a b c
65   d4 e f g
66 }
67 @end lilypond
68
69 @cindex octave changing mark
70
71 @funindex '
72 @funindex ,
73
74 Other octaves may be specified with a single quote@tie{}(@code{'})
75 or comma@tie{}(@code{,}) character.  Each@tie{}@code{'} raises the
76 pitch by one octave; each@tie{}@code{,} lowers the pitch by an
77 octave.
78
79 @lilypond[verbatim,quote]
80 {
81   \clef treble
82   c'4 e' g' c''
83   c'4 g b c'
84   \clef bass
85   c,4 e, g, c
86   c,4 g,, b,, c,
87 }
88 @end lilypond
89
90 @funindex fixed
91 @funindex \fixed
92 Common octave marks can be entered just once on a reference pitch
93 after @code{\fixed} placed before the music.  Pitches inside
94 @code{\fixed} only need @code{'} or@tie{}@code{,} marks
95 when they are above or below the octave of the reference pitch.
96
97 @lilypond[verbatim,quote]
98 {
99   \fixed c' {
100     \clef treble
101     c4 e g c'
102     c4 g, b, c
103   }
104   \clef bass
105   \fixed c, {
106     c4 e g c'
107     c4 g, b, c
108   }
109 }
110 @end lilypond
111
112 Pitches in the music expression following @code{\fixed} are
113 unaffected by any enclosing @code{\relative}, discussed next.
114
115 @seealso
116 Music Glossary:
117 @rglos{Pitch names}.
118
119 Snippets:
120 @rlsr{Pitches}.
121
122
123 @node Relative octave entry
124 @unnumberedsubsubsec Relative octave entry
125
126 @cindex relative
127 @cindex relative octave entry
128 @cindex octave entry, relative
129 @cindex relative octave specification
130 @cindex octave specification, relative
131
132 @funindex relative
133 @funindex \relative
134
135 Absolute octave entry requires specifying the octave for every
136 single note.  Relative octave entry, in contrast, specifies each
137 octave in relation to the last note: changing one note's octave
138 will affect all of the following notes.
139
140 Relative note mode has to be entered explicitly using the
141 @code{\relative} command:
142
143 @example
144 \relative @var{startpitch} @var{musicexpr}
145 @end example
146
147 In relative mode, each note is assumed to be as close to the
148 previous note as possible.  This means that the octave of each
149 pitch inside @code{@var{musicexpr}} is calculated as follows:
150
151 @itemize
152 @item
153 If no octave changing mark is used on a pitch, its octave is
154 calculated so that the interval with the previous note is less
155 than a fifth.  This interval is determined without considering
156 accidentals.
157
158 @item
159 An octave changing mark@tie{}@code{'} or@tie{}@code{,} can be
160 added to respectively raise or lower a pitch by an extra octave,
161 relative to the pitch calculated without an octave mark.
162
163 @item
164 Multiple octave changing marks can be used.  For example,
165 @code{''}@tie{}and@tie{}@code{,,} will alter the pitch by two
166 octaves.
167
168 @item
169 The pitch of the first note is relative to
170 @code{@var{startpitch}}.  @code{@var{startpitch}} is specified in
171 absolute octave mode.  Which choices are meaningful?
172
173 @table @asis
174 @item an octave of @code{c}
175 Identifying middle C with @code{c'} is quite basic, so finding
176 octaves of @code{c} tends to be straightforward.  If your music
177 starts with @code{gis} above @code{c'''}, you'd write something
178 like @code{\relative c''' @{ gis' @dots{} @}}
179
180 @item an octave of the first note inside
181 Writing @code{\relative gis''' @{ gis @dots{} @}} makes it easy to
182 determine the absolute pitch of the first note inside.
183
184 @item no explicit starting pitch
185 The form @code{\relative @{ gis''' @dots{} @}}) serves
186 as a compact version of the previous option: the first note
187 inside is written in absolute pitch itself.  (This happens to be
188 equivalent to choosing @code{f} as the reference pitch.)
189 @end table
190
191 The documentation will usually employ the last option.
192 @end itemize
193
194 Here is the relative mode shown in action:
195
196 @lilypond[verbatim,quote]
197 \relative {
198   \clef bass
199   c d e f
200   g a b c
201   d e f g
202 }
203 @end lilypond
204
205 Octave changing marks are used for intervals greater than a
206 fourth:
207
208 @lilypond[verbatim,quote]
209 \relative {
210   c'' g c f,
211   c' a, e'' c
212 }
213 @end lilypond
214
215 A note sequence without a single octave mark can nevertheless span
216 large intervals:
217
218 @lilypond[verbatim,quote]
219 \relative {
220   c f b e
221   a d g c
222 }
223 @end lilypond
224
225 When @code{\relative} blocks are nested, the innermost
226 @code{\relative} block starts with its own reference pitch
227 independently of the outer @code{\relative}.
228
229 @lilypond[verbatim,quote]
230 \relative {
231   c' d e f
232   \relative {
233     c'' d e f
234   }
235 }
236 @end lilypond
237
238 @code{\relative} has no effect on @code{\chordmode} blocks.
239
240 @lilypond[verbatim,quote]
241 \new Staff {
242   \relative c''' {
243     \chordmode { c1 }
244   }
245   \chordmode { c1 }
246 }
247 @end lilypond
248
249 @code{\relative} is not allowed inside of @code{\chordmode} blocks.
250
251 Music inside a @code{\transpose} block is absolute unless a
252 @code{\relative} is included.
253
254 @lilypond[verbatim,quote]
255 \relative {
256   d' e
257   \transpose f g {
258     d e
259     \relative {
260       d' e
261     }
262   }
263 }
264 @end lilypond
265
266
267 @cindex chords and relative octave entry
268 @cindex relative octave entry and chords
269
270 If the preceding item is a chord, the first note of the chord is
271 used as the reference point for the octave placement of a
272 following note or chord.  Inside chords, the next note is always
273 relative to the preceding one.  Examine the next example
274 carefully, paying attention to the @code{c} notes.
275
276 @lilypond[verbatim,quote]
277 \relative {
278   c'
279   <c e g>
280   <c' e g'>
281   <c, e, g''>
282 }
283 @end lilypond
284
285 As explained above, the octave of pitches is calculated only with
286 the note names, regardless of any alterations.  Therefore, an
287 E-double-sharp following a B will be placed higher, while an
288 F-double-flat will be placed lower.  In other words, a
289 double-augmented fourth is considered a smaller interval than a
290 double-diminished fifth, regardless of the number of semitones
291 that each interval contains.
292
293 @lilypond[verbatim,quote]
294 \relative {
295   c''2 fis
296   c2 ges
297   b2 eisis
298   b2 feses
299 }
300 @end lilypond
301
302
303 @seealso
304 Music Glossary:
305 @rglos{fifth},
306 @rglos{interval},
307 @rglos{Pitch names}.
308
309 Notation Reference:
310 @ref{Octave checks}.
311
312 Snippets:
313 @rlsr{Pitches}.
314
315 Internals Reference:
316 @rinternals{RelativeOctaveMusic}.
317
318 @cindex relative octave entry and transposition
319 @cindex transposition and relative octave entry
320
321 @funindex \transpose
322 @funindex transpose
323 @funindex \chordmode
324 @funindex chordmode
325 @funindex \relative
326 @funindex relative
327
328
329 @node Accidentals
330 @unnumberedsubsubsec Accidentals
331
332 @cindex accidental
333 @cindex key signature
334 @cindex clef
335
336 @c duplicated in Key signature and Accidentals
337 @warning{New users are sometimes confused about accidentals and
338 key signatures.  In LilyPond, note names specify pitches; key
339 signatures and clefs determine how these pitches are displayed.
340 An unaltered note like@tie{}@code{c} means @q{C natural},
341 regardless of the key signature or clef.  For more information,
342 see @rlearning{Pitches and key signatures}.}
343
344 @cindex note names, Dutch
345 @cindex note names, default
346 @cindex default note names
347 @cindex sharp
348 @cindex flat
349 @cindex double sharp
350 @cindex sharp, double
351 @cindex double flat
352 @cindex flat, double
353 @cindex natural sign
354 @cindex natural pitch
355
356 A @notation{sharp} pitch is made by adding @code{is} to the note
357 name, and a @notation{flat} pitch by adding @code{es}.  As you
358 might expect, a @notation{double sharp} or @notation{double flat}
359 is made by adding @code{isis} or @code{eses}.  This syntax is
360 derived from Dutch note naming conventions.  To use other names
361 for accidentals, see @ref{Note names in other languages}.
362
363 @lilypond[verbatim,quote,relative=2]
364 ais1 aes aisis aeses
365 @end lilypond
366
367 A natural pitch is entered as a simple note name; no suffix is
368 required.  A natural sign will be printed when needed to cancel
369 the effect of an earlier accidental or key signature.
370
371 @lilypond[verbatim,quote,relative=2]
372 a4 aes a2
373 @end lilypond
374
375 @cindex quarter tones
376 @cindex semi-flats
377 @cindex semi-sharps
378
379 Quarter tones may be added; the following is a series of Cs with
380 increasing pitches:
381
382 @lilypond[verbatim,quote,relative=2]
383 ceseh1 ces ceh c cih cis cisih
384 @end lilypond
385
386
387
388 @cindex accidental, reminder
389 @cindex accidental, cautionary
390 @cindex accidental, parenthesized
391 @cindex reminder accidental
392 @cindex cautionary accidental
393 @cindex parenthesized accidental
394
395 @funindex ?
396 @funindex !
397
398
399 Normally accidentals are printed automatically, but you may also
400 print them manually.  A reminder accidental can be forced by
401 adding an exclamation mark@tie{}@code{!} after the pitch.  A
402 cautionary accidental (i.e., an accidental within parentheses) can
403 be obtained by adding the question mark@tie{}@code{?} after the
404 pitch.
405
406 @lilypond[verbatim,quote,relative=2]
407 cis cis cis! cis? c c c! c?
408 @end lilypond
409
410 @cindex accidental on tied note
411 @cindex tied note, accidental
412
413 Accidentals on tied notes are only printed at the beginning of a
414 new system:
415
416 @lilypond[verbatim,quote,relative=2,ragged-right]
417 cis1~ 1~
418 \break
419 cis
420 @end lilypond
421
422
423 @snippets
424
425 @lilypondfile[verbatim,quote,texidoc,doctitle,ragged-right]
426 {hiding-accidentals-on-tied-notes-at-the-start-of-a-new-system.ly}
427
428 @lilypondfile[verbatim,quote,texidoc,doctitle]
429 {preventing-extra-naturals-from-being-automatically-added.ly}
430
431 @seealso
432 Music Glossary:
433 @rglos{sharp},
434 @rglos{flat},
435 @rglos{double sharp},
436 @rglos{double flat},
437 @rglos{Pitch names},
438 @rglos{quarter tone}.
439
440 Learning Manual:
441 @rlearning{Pitches and key signatures}.
442
443 Notation Reference:
444 @ref{Automatic accidentals},
445 @ref{Annotational accidentals (musica ficta)},
446 @ref{Note names in other languages}.
447
448 Snippets:
449 @rlsr{Pitches}.
450
451 Internals Reference:
452 @rinternals{Accidental_engraver},
453 @rinternals{Accidental},
454 @rinternals{AccidentalCautionary},
455 @rinternals{accidental-interface}.
456
457 @cindex accidental, quarter-tone
458 @cindex quarter-tone accidental
459
460 @knownissues
461 There are no generally accepted standards for denoting
462 quarter-tone accidentals, so LilyPond's symbol does not conform to
463 any standard.
464
465
466 @node Note names in other languages
467 @unnumberedsubsubsec Note names in other languages
468
469 @cindex note names, other languages
470 @cindex pitch names, other languages
471 @cindex language, note names in other
472 @cindex language, pitch names in other
473
474 There are predefined sets of note and accidental names for various
475 other languages.  Selecting the note name language is usually done
476 at the beginning of the file; the following example is written
477 using Italian note names:
478
479 @lilypond[quote,verbatim]
480 \language "italiano"
481
482 \relative {
483   do' re mi sib
484 }
485 @end lilypond
486
487 The available languages and the note names they define are:
488
489 @quotation
490 @multitable {@code{nederlands}} {do re mi fa sol la sib si}
491 @headitem Language
492   @tab Note Names
493 @item @code{nederlands}
494   @tab c d e f g a bes b
495 @item @code{catalan}
496   @tab do re mi fa sol la sib si
497 @item @code{deutsch}
498   @tab c d e f g a b h
499 @item @code{english}
500   @tab c d e f g a bf b
501 @item @code{espanol} or @code{español}
502   @tab do re mi fa sol la sib si
503 @item @code{italiano} or @code{français}
504   @tab do re mi fa sol la sib si
505 @item @code{norsk}
506   @tab c d e f g a b h
507 @item @code{portugues}
508   @tab do re mi fa sol la sib si
509 @item @code{suomi}
510   @tab c d e f g a b h
511 @item @code{svenska}
512   @tab c d e f g a b h
513 @item @code{vlaams}
514   @tab do re mi fa sol la sib si
515 @end multitable
516 @end quotation
517
518 In addition to note names, accidental suffixes may
519 also vary depending on the language:
520
521 @quotation
522 @multitable {@code{nederlands}} {-@code{s}/-@code{-sharp}} {-@code{ess}/-@code{es}} {-@code{ss}/-@code{x}/-@code{-sharpsharp}} {-@code{essess}/-@code{eses}}
523 @headitem Language
524   @tab sharp @tab flat @tab double sharp @tab double flat
525 @item @code{nederlands}
526   @tab -@code{is} @tab -@code{es} @tab -@code{isis} @tab -@code{eses}
527 @item @code{catalan}
528   @tab -@code{d}/-@code{s} @tab -@code{b} @tab -@code{dd}/-@code{ss} @tab -@code{bb}
529 @item @code{deutsch}
530   @tab -@code{is} @tab -@code{es} @tab -@code{isis} @tab -@code{eses}
531 @item @code{english}
532   @tab -@code{s}/-@code{-sharp} @tab -@code{f}/-@code{-flat} @tab -@code{ss}/-@code{x}/-@code{-sharpsharp}
533     @tab -@code{ff}/-@code{-flatflat}
534 @item @code{espanol} or @code{español}
535   @tab -@code{s} @tab -@code{b} @tab -@code{ss}/-@code{x} @tab -@code{bb}
536 @item @code{italiano} or @code{français}
537   @tab -@code{d} @tab -@code{b} @tab -@code{dd} @tab -@code{bb}
538 @item @code{norsk}
539   @tab -@code{iss}/-@code{is} @tab -@code{ess}/-@code{es} @tab -@code{ississ}/-@code{isis}
540     @tab -@code{essess}/-@code{eses}
541 @item @code{portugues}
542   @tab -@code{s} @tab -@code{b} @tab -@code{ss} @tab -@code{bb}
543 @item @code{suomi}
544   @tab -@code{is} @tab -@code{es} @tab -@code{isis} @tab -@code{eses}
545 @item @code{svenska}
546   @tab -@code{iss} @tab -@code{ess} @tab -@code{ississ} @tab -@code{essess}
547 @item @code{vlaams}
548   @tab -@code{k} @tab -@code{b} @tab -@code{kk} @tab -@code{bb}
549 @end multitable
550 @end quotation
551
552 In Dutch, @code{aes} is contracted to @code{as}, but both forms
553 are accepted in LilyPond.  Similarly, both @code{es} and
554 @code{ees} are accepted.  This also applies to
555 @code{aeses}@tie{}/@tie{}@code{ases} and
556 @code{eeses}@tie{}/@tie{}@code{eses}.  Sometimes only these
557 contracted names are defined in the corresponding language files.
558
559 @lilypond[verbatim,quote,relative=2]
560 a2 as e es a ases e eses
561 @end lilypond
562
563
564 @cindex microtones
565 @cindex semi-sharp
566 @cindex semi-flat
567 @cindex sesqui-sharp
568 @cindex sesqui-flat
569
570 Some music uses microtones whose alterations are fractions of a
571 @q{normal} sharp or flat.  The following table lists note names
572 for quarter-tone accidentals in various languages; here the prefixes
573 @notation{semi-} and @notation{sesqui-} respectively
574 mean @q{half} and @q{one and a half}.  Languages that do not
575 appear in this table do not provide special note names yet.
576
577 @quotation
578 @multitable {@code{nederlands}} {@b{semi-sharp}} {@b{semi-flat}} {@b{sesqui-sharp}} {@b{sesqui-flat}}
579 @headitem Language
580   @tab semi-sharp @tab semi-flat @tab sesqui-sharp @tab sesqui-flat
581
582 @item @code{nederlands}
583   @tab -ih @tab -eh @tab -isih @tab -eseh
584 @item @code{deutsch}
585   @tab -ih @tab -eh @tab -isih @tab -eseh
586 @item @code{english}
587   @tab -qs @tab -qf @tab -tqs @tab -tqf
588 @item @code{espanol} or @code{español}
589   @tab -cs @tab -cb @tab -tcs @tab -tcb
590 @item @code{italiano} or @code{français}
591   @tab -sd @tab -sb @tab -dsd @tab -bsb
592 @item @code{portugues}
593   @tab -sqt @tab -bqt @tab -stqt @tab -btqt
594 @end multitable
595 @end quotation
596
597 Most languages presented here are commonly associated with
598 Western classical music, also referred to as
599 @notation{Common Practice Period}.  However, alternate
600 pitches and tuning systems are also supported: see
601 @ref{Common notation for non-Western music}.
602
603 @seealso
604 Music Glossary:
605 @rglos{Pitch names},
606 @rglos{Common Practice Period}.
607
608 Notation Reference:
609 @ref{Common notation for non-Western music}.
610
611 Installed Files:
612 @file{scm/define-note-names.scm}.
613
614 Snippets:
615 @rlsr{Pitches}.
616
617
618 @node Changing multiple pitches
619 @subsection Changing multiple pitches
620
621 This section discusses how to modify pitches.
622
623 @menu
624 * Octave checks::
625 * Transpose::
626 * Inversion::
627 * Retrograde::
628 * Modal transformations::
629 @end menu
630
631 @node Octave checks
632 @unnumberedsubsubsec Octave checks
633
634 @cindex octave correction
635 @cindex octave check
636 @cindex control pitch
637
638 @funindex =
639 @funindex \octaveCheck
640 @funindex octaveCheck
641 @funindex controlpitch
642
643 In relative mode, it is easy to forget an octave changing mark.
644 Octave checks make such errors easier to find by displaying a
645 warning and correcting the octave if a note is found in an
646 unexpected octave.
647
648 To check the octave of a note, specify the absolute octave after
649 the @code{=}@tie{}symbol.  This example will generate a warning
650 (and change the pitch) because the second note is the absolute
651 octave @code{d''} instead of @code{d'} as indicated by the octave
652 correction.
653
654 @lilypond[verbatim,quote]
655 \relative {
656   c''2 d='4 d
657   e2 f
658 }
659 @end lilypond
660
661 The octave of notes may also be checked with the
662 @code{\octaveCheck@tie{}@var{controlpitch}} command.
663 @code{@var{controlpitch}} is specified in absolute mode.  This
664 checks that the interval between the previous note and the
665 @code{@var{controlpitch}} is within a fourth (i.e., the normal
666 calculation of relative mode).  If this check fails, a warning is
667 printed, but the previous note is not changed.  Future notes are
668 relative to the @code{@var{controlpitch}}.
669
670 @lilypond[verbatim,quote]
671 \relative {
672   c''2 d
673   \octaveCheck c'
674   e2 f
675 }
676 @end lilypond
677
678 Compare the two bars below.  The first and third @code{\octaveCheck}
679 checks fail, but the second one does not fail.
680
681 @lilypond[verbatim,quote]
682 \relative {
683   c''4 f g f
684
685   c4
686   \octaveCheck c'
687   f
688   \octaveCheck c'
689   g
690   \octaveCheck c'
691   f
692 }
693 @end lilypond
694
695 @seealso
696 Snippets:
697 @rlsr{Pitches}.
698
699 Internals Reference:
700 @rinternals{RelativeOctaveCheck}.
701
702
703 @node Transpose
704 @unnumberedsubsubsec Transpose
705
706 @cindex transpose
707 @cindex transposing
708 @cindex transposition
709 @cindex transposition of pitches
710 @cindex transposition of notes
711 @cindex pitches, transposition of
712 @cindex notes, transposition of
713
714 @funindex \transpose
715 @funindex transpose
716
717 A music expression can be transposed with @code{\transpose}.  The
718 syntax is
719
720 @example
721 \transpose @var{frompitch} @var{topitch} @var{musicexpr}
722 @end example
723
724 @noindent
725 This means that @code{@var{musicexpr}} is transposed by the
726 interval between the pitches @code{@var{frompitch}} and
727 @code{@var{topitch}}: any note with pitch @code{@var{frompitch}}
728 is changed to @code{@var{topitch}} and any other note is
729 transposed by the same interval.  Both pitches are entered in
730 absolute mode.
731
732 @warning{Music inside a @code{@bs{}transpose} block is absolute
733 unless a @code{@bs{}relative} is included in the block.}
734
735 Consider a piece written in the key of D-major.  It can be
736 transposed up to E-major; note that the key signature is
737 automatically transposed as well.
738
739 @lilypond[verbatim,quote]
740 \transpose d e {
741   \relative {
742     \key d \major
743     d'4 fis a d
744   }
745 }
746 @end lilypond
747
748 @cindex transposing instruments
749 @cindex instruments, transposing
750
751 If a part written in C (normal @notation{concert pitch}) is to be
752 played on the A clarinet (for which an A is notated as a C and
753 thus sounds a minor third lower than notated), the appropriate
754 part will be produced with:
755
756 @lilypond[verbatim,quote]
757 \transpose a c' {
758   \relative {
759     \key c \major
760     c'4 d e g
761   }
762 }
763 @end lilypond
764
765 @noindent
766 Note that we specify @w{@code{\key c \major}} explicitly.  If we
767 do not specify a key signature, the notes will be transposed but
768 no key signature will be printed.
769
770 @code{\transpose} distinguishes between enharmonic pitches: both
771 @w{@code{\transpose c cis}} or @w{@code{\transpose c des}} will
772 transpose up a semitone.  The first version will print sharps and
773 the notes will remain on the same scale step, the second version
774 will print flats on the scale step above.
775
776 @lilypond[verbatim,quote]
777 music = \relative { c' d e f }
778 \new Staff {
779   \transpose c cis { \music }
780   \transpose c des { \music }
781 }
782 @end lilypond
783
784
785 @code{\transpose} may also be used in a different way, to input
786 written notes for a transposing instrument.  The previous examples
787 show how to enter pitches in C (or @notation{concert pitch}) and
788 typeset them for a transposing instrument, but the opposite is
789 also possible if you for example have a set of instrumental parts
790 and want to print a conductor's score.  For example, when entering
791 music for a B-flat trumpet that begins on a notated E (concert D),
792 one would write:
793
794 @example
795 musicInBflat = @{ e4 @dots{} @}
796 \transpose c bes, \musicInBflat
797 @end example
798
799 @noindent
800 To print this music in F (e.g., rearranging to a French horn) you
801 could wrap the existing music with another @code{\transpose}:
802
803 @example
804 musicInBflat = @{ e4 @dots{} @}
805 \transpose f c' @{ \transpose c bes, \musicInBflat @}
806 @end example
807
808 @noindent
809 For more information about transposing instruments,
810 see @ref{Instrument transpositions}.
811
812
813 @snippets
814
815 @lilypondfile[verbatim,quote,texidoc,doctitle]
816 {transposing-pitches-with-minimum-accidentals-smart-transpose.ly}
817
818 @seealso
819 Notation Reference:
820 @ref{Instrument transpositions},
821 @ref{Inversion},
822 @ref{Modal transformations},
823 @ref{Relative octave entry},
824 @ref{Retrograde}.
825
826 Snippets:
827 @rlsr{Pitches}.
828
829 Internals Reference:
830 @rinternals{TransposedMusic}.
831
832 @funindex \transpose
833 @funindex transpose
834 @funindex \chordmode
835 @funindex chordmode
836 @funindex \relative
837 @funindex relative
838
839 @knownissues
840 The relative conversion will not affect @code{\transpose},
841 @code{\chordmode} or @code{\relative} sections in its argument.  To use
842 relative mode within transposed music, an additional @code{\relative}
843 must be placed inside @code{\transpose}.
844
845 Triple accidentals will not be printed if using @code{\transpose}. An
846 @q{enharmonically equivalent} pitch will be used instead (e.g. d-flat
847 rather than e-triple-flat).
848
849
850 @node Inversion
851 @unnumberedsubsubsec Inversion
852
853 @cindex inversion
854 @cindex operation, inversion
855 @funindex \inversion
856
857 A music expression can be inverted and transposed in a single
858 operation with:
859
860 @example
861 \inversion @var{around-pitch} @var{to-pitch} @var{musicexpr}
862 @end example
863
864 The @code{@var{musicexpr}} is inverted interval-by-interval around
865 @code{@var{around-pitch}}, and then transposed so that
866 @code{@var{around-pitch}} is mapped to @code{@var{to-pitch}}.
867
868 @lilypond[verbatim,quote]
869 music = \relative { c' d e f }
870 \new Staff {
871   \music
872   \inversion d' d' \music
873   \inversion d' ees' \music
874 }
875 @end lilypond
876
877 @warning{Motifs to be inverted should be expressed in absolute form
878 or be first converted to absolute form by enclosing them in a
879 @code{\relative} block.}
880
881 @seealso
882 Notation Reference:
883 @ref{Modal transformations},
884 @ref{Retrograde},
885 @ref{Transpose}.
886
887
888 @node Retrograde
889 @unnumberedsubsubsec Retrograde
890
891 @cindex retrograde transformation
892 @cindex transformation, retrograde
893 @cindex operation, retrograde
894 @funindex \retrograde
895 @funindex retrograde
896
897 A music expression can be reversed to produce its retrograde:
898
899 @lilypond[verbatim,quote]
900 music = \relative { c'8. ees16( fis8. a16 b8.) gis16 f8. d16 }
901
902 \new Staff {
903   \music
904   \retrograde \music
905 }
906 @end lilypond
907
908 @knownissues
909 Manual ties inside @code{\retrograde} will be broken and
910 generate warnings.  Some ties can be generated automatically
911 by enabling @ref{Automatic note splitting}.
912
913 @seealso
914 Notation Reference:
915 @ref{Inversion},
916 @ref{Modal transformations},
917 @ref{Transpose}.
918
919
920 @node Modal transformations
921 @unnumberedsubsubsec Modal transformations
922
923 @cindex modal transformations
924 @cindex transformations, modal
925 @cindex operations, modal
926
927 In a musical composition that is based on a scale, a motif is
928 frequently transformed in various ways.  It may be
929 @notation{transposed} to start at different places in the scale or
930 it may be @notation{inverted} around a pivot point in the scale.
931 It may also be reversed to produce its @notation{retrograde}, see
932 @ref{Retrograde}.
933
934 @warning{Any note that does not lie within the given scale will be
935 left untransformed.}
936
937 @subsubsubheading Modal transposition
938
939 @cindex modal transposition
940 @cindex transposition, modal
941 @cindex operation, transposition
942 @funindex \modalTranspose
943 @funindex modalTranspose
944
945 A motif can be transposed within a given scale with:
946
947 @example
948 \modalTranspose @var{from-pitch} @var{to-pitch} @var{scale} @var{motif}
949 @end example
950
951 The notes of @var{motif} are shifted within the @var{scale} by the
952 number of scale degrees given by the interval between @var{to-pitch}
953 and @var{from-pitch}:
954
955 @lilypond[verbatim,quote]
956 diatonicScale = \relative { c' d e f g a b }
957 motif = \relative { c'8 d e f g a b c }
958
959 \new Staff {
960   \motif
961   \modalTranspose c f \diatonicScale \motif
962   \modalTranspose c b, \diatonicScale \motif
963 }
964 @end lilypond
965
966 An ascending scale of any length and with any intervals may be
967 specified:
968
969 @lilypond[verbatim,quote]
970 pentatonicScale = \relative { ges aes bes des ees }
971 motif = \relative { ees'8 des ges,4 <ges' bes,> <ges bes,> }
972
973 \new Staff {
974   \motif
975   \modalTranspose ges ees' \pentatonicScale \motif
976 }
977 @end lilypond
978
979 When used with a chromatic scale @code{\modalTranspose} has a
980 similar effect to @code{\transpose}, but with the ability to
981 specify the names of the notes to be used:
982
983 @lilypond[verbatim,quote]
984 chromaticScale = \relative { c' cis d dis e f fis g gis a ais b }
985 motif = \relative { c'8 d e f g a b c }
986
987 \new Staff {
988   \motif
989   \transpose c f \motif
990   \modalTranspose c f \chromaticScale \motif
991 }
992 @end lilypond
993
994 @subsubsubheading Modal inversion
995
996 @cindex modal inversion
997 @cindex inversion, modal
998 @cindex operation, modal inversion
999 @funindex \modalInversion
1000 @funindex modalInversion
1001
1002 A motif can be inverted within a given scale around a given pivot
1003 note and transposed in a single operation with:
1004
1005 @example
1006 \modalInversion @var{around-pitch} @var{to-pitch} @var{scale} @var{motif}
1007 @end example
1008
1009 The notes of @var{motif} are placed the same number of scale degrees
1010 from the @var{around-pitch} note within the @var{scale}, but in the
1011 opposite direction, and the result is then shifted within the
1012 @var{scale} by the number of scale degrees given by the interval between
1013 @var{to-pitch} and @var{around-pitch}.
1014
1015 So to simply invert around a note in the scale use the same value for
1016 @var{around-pitch} and @var{to-pitch}:
1017
1018 @lilypond[verbatim,quote]
1019 octatonicScale = \relative { ees' f fis gis a b c d }
1020 motif = \relative { c'8. ees16 fis8. a16 b8. gis16 f8. d16 }
1021
1022 \new Staff {
1023   \motif
1024   \modalInversion fis' fis' \octatonicScale \motif
1025 }
1026 @end lilypond
1027
1028 To invert around a pivot between two notes in the scale, invert around
1029 one of the notes and then transpose by one scale degree.  The two notes
1030 specified can be interpreted as bracketing the pivot point:
1031
1032 @lilypond[verbatim,quote]
1033 scale = \relative { c' g' }
1034 motive = \relative { c' c g' c, }
1035
1036 \new Staff {
1037   \motive
1038   \modalInversion c' g' \scale \motive
1039 }
1040 @end lilypond
1041
1042 The combined operation of inversion and retrograde produce the
1043 retrograde-inversion:
1044
1045 @lilypond[verbatim,quote]
1046 octatonicScale = \relative { ees' f fis gis a b c d }
1047 motif = \relative { c'8. ees16 fis8. a16 b8. gis16 f8. d16 }
1048
1049 \new Staff {
1050   \motif
1051   \retrograde \modalInversion c' c' \octatonicScale \motif
1052 }
1053 @end lilypond
1054
1055 @seealso
1056 Notation Reference:
1057 @ref{Inversion},
1058 @ref{Retrograde},
1059 @ref{Transpose}.
1060
1061
1062 @node Displaying pitches
1063 @subsection Displaying pitches
1064
1065 This section discusses how to alter the output of pitches.
1066
1067 @menu
1068 * Clef::
1069 * Key signature::
1070 * Ottava brackets::
1071 * Instrument transpositions::
1072 * Automatic accidentals::
1073 * Ambitus::
1074 @end menu
1075
1076
1077 @node Clef
1078 @unnumberedsubsubsec Clef
1079
1080 @cindex G clef
1081 @cindex C clef
1082 @cindex F clef
1083 @cindex treble clef
1084 @cindex violin clef
1085 @cindex alto clef
1086 @cindex tenor clef
1087 @cindex bass clef
1088 @cindex french clef
1089 @cindex soprano clef
1090 @cindex mezzosoprano clef
1091 @cindex baritone clef
1092 @cindex varbaritone clef
1093 @cindex subbass clef
1094 @cindex clef
1095 @cindex ancient clef
1096 @cindex clef, ancient
1097 @cindex clef, G
1098 @cindex clef, C
1099 @cindex clef, F
1100 @cindex clef, treble
1101 @cindex clef, violin
1102 @cindex clef, alto
1103 @cindex clef, tenor
1104 @cindex clef, bass
1105 @cindex clef, french
1106 @cindex clef, soprano
1107 @cindex clef, mezzosoprano
1108 @cindex clef, baritone
1109 @cindex clef, varbaritone
1110 @cindex clef, subbass
1111
1112
1113 @funindex \clef
1114 @funindex clef
1115
1116 Without any explicit command, the default clef for LilyPond is the
1117 treble (or @emph{G}) clef.
1118
1119 @lilypond[verbatim,quote,relative=1,ragged-right]
1120 c2 c
1121 @end lilypond
1122
1123 However, the clef can be changed by using the @code{\clef} command and
1124 an appropriate clef name.  @emph{Middle C} is shown in each of the
1125 following examples.
1126
1127 @lilypond[verbatim,quote,relative=1]
1128 \clef treble
1129 c2 c
1130 \clef alto
1131 c2 c
1132 \clef tenor
1133 c2 c
1134 \clef bass
1135 c2 c
1136 @end lilypond
1137
1138 For the full range of possible clef names see @ref{Clef styles}.
1139
1140 Specialized clefs, such as those used in @emph{Ancient} music, are
1141 described in @ref{Mensural clefs} and @ref{Gregorian clefs}.  Music that
1142 requires tablature clefs is discussed in @ref{Default tablatures} and
1143 @ref{Custom tablatures}.
1144
1145 @cindex Cue clefs
1146 @cindex Clefs with cue notes
1147 For mixing clefs when using cue notes, see the @code{\cueClef} and
1148 @code{\cueDuringWithClef} commands in @ref{Formatting cue notes}.
1149
1150 @cindex transposing clef
1151 @cindex clef, transposing
1152 @cindex octave transposition
1153 @cindex optional octave transposition
1154 @cindex octave transposition, optional
1155 @cindex choral tenor clef
1156 @cindex tenor clef, choral
1157
1158 By adding@tie{}@code{_8} or@tie{}@code{^8} to the clef name, the
1159 clef is transposed one octave down or up respectively,
1160 and@tie{}@code{_15} and@tie{}@code{^15} transpose by two octaves.
1161 Other integers can be used if required.  Clef names containing
1162 non-alphabetic characters must be enclosed in quotes
1163
1164 @lilypond[verbatim,quote,relative=1]
1165 \clef treble
1166 c2 c
1167 \clef "treble_8"
1168 c2 c
1169 \clef "bass^15"
1170 c2 c
1171 \clef "alto_2"
1172 c2 c
1173 \clef "G_8"
1174 c2 c
1175 \clef "F^5"
1176 c2 c
1177 @end lilypond
1178
1179 Optional octavation can be obtained by enclosing the numeric
1180 argument in parentheses or brackets:
1181
1182 @lilypond[verbatim,quote,relative=1]
1183 \clef "treble_(8)"
1184 c2 c
1185 \clef "bass^[15]"
1186 c2 c
1187 @end lilypond
1188
1189 The pitches are displayed as if the numeric argument were
1190 given without parentheses/brackets.
1191
1192 By default, a clef change taking place at a line break will cause
1193 the new clef symbol to be printed at the end of the previous line,
1194 as a @emph{warning} clef, as well as the beginning of the next.
1195 This @emph{warning} clef can be suppressed.
1196
1197 @lilypond[verbatim,quote,relative=1]
1198 \clef treble { c2 c } \break
1199 \clef bass { c2 c } \break
1200 \clef alto
1201   \set Staff.explicitClefVisibility = #end-of-line-invisible
1202   { c2 c } \break
1203   \unset Staff.explicitClefVisibility
1204 \clef bass { c2 c } \break
1205 @end lilypond
1206
1207 By default, a clef that has previously been printed will not be
1208 re-printed if the same @code{\clef} command is issued again and
1209 will be ignored.  The the command
1210 @code{\set Staff.forceClef = ##t} changes this behaviour.
1211
1212 @lilypond[verbatim,quote,relative=1]
1213   \clef treble
1214   c1
1215   \clef treble
1216   c1
1217   \set Staff.forceClef = ##t
1218   c1
1219   \clef treble
1220   c1
1221 @end lilypond
1222
1223 When there is a manual clef change, the glyph of the changed clef
1224 will be smaller than normal.  This behaviour can be overridden.
1225
1226 @lilypond[verbatim,quote,relative=1]
1227   \clef "treble"
1228   c1
1229   \clef "bass"
1230   c1
1231   \clef "treble"
1232   c1
1233   \override Staff.Clef.full-size-change = ##t
1234   \clef "bass"
1235   c1
1236   \clef "treble"
1237   c1
1238   \revert Staff.Clef.full-size-change
1239   \clef "bass"
1240   c1
1241   \clef "treble"
1242   c1
1243 @end lilypond
1244
1245 @snippets
1246 @lilypondfile[verbatim,quote,texidoc,doctitle]
1247 {tweaking-clef-properties.ly}
1248
1249 @seealso
1250 Notation Reference:
1251 @ref{Mensural clefs},
1252 @ref{Gregorian clefs},
1253 @ref{Default tablatures},
1254 @ref{Custom tablatures},
1255 @ref{Formatting cue notes}.
1256
1257 Installed Files:
1258 @file{scm/parser-clef.scm}.
1259
1260 Snippets:
1261 @rlsr{Pitches}.
1262
1263 Internals Reference:
1264 @rinternals{Clef_engraver},
1265 @rinternals{Clef},
1266 @rinternals{ClefModifier},
1267 @rinternals{clef-interface}.
1268
1269 @knownissues
1270 Ottavation numbers attached to clefs are treated as separate
1271 grobs.  So any @code{\override} done to the @var{Clef} will also
1272 need to be applied, as a separate @code{\override}, to the
1273 @var{ClefModifier} grob.
1274
1275 @lilypond[fragment,quote,verbatim,relative=1]
1276 \new Staff \with {
1277   \override Clef.color = #blue
1278   \override ClefModifier.color = #red
1279 }
1280
1281 \clef "treble_8" c4
1282 @end lilypond
1283
1284
1285 @node Key signature
1286 @unnumberedsubsubsec Key signature
1287
1288 @cindex key signature
1289
1290 @funindex \key
1291 @funindex key
1292
1293 @c duplicated in Key signature and Accidentals
1294 @warning{New users are sometimes confused about accidentals and
1295 key signatures.  In LilyPond, note names are the raw input; key
1296 signatures and clefs determine how this raw input is displayed.
1297 An unaltered note like@tie{}@code{c} means @q{C natural},
1298 regardless of the key signature or clef.  For more information,
1299 see @rlearning{Pitches and key signatures}.}
1300
1301 The key signature indicates the tonality in which a piece is
1302 played.  It is denoted by a set of alterations (flats or sharps)
1303 at the start of the staff.  The key signature may be altered:
1304
1305 @example
1306 \key @var{pitch} @var{mode}
1307 @end example
1308
1309 @funindex \major
1310 @funindex major
1311 @funindex \minor
1312 @funindex minor
1313 @funindex \ionian
1314 @funindex ionian
1315 @funindex \locrian
1316 @funindex locrian
1317 @funindex \aeolian
1318 @funindex aeolian
1319 @funindex \mixolydian
1320 @funindex mixolydian
1321 @funindex \lydian
1322 @funindex lydian
1323 @funindex \phrygian
1324 @funindex phrygian
1325 @funindex \dorian
1326 @funindex dorian
1327
1328 @cindex church modes
1329 @cindex modes
1330 @cindex major
1331 @cindex minor
1332 @cindex ionian
1333 @cindex locrian
1334 @cindex aeolian
1335 @cindex mixolydian
1336 @cindex lydian
1337 @cindex phrygian
1338 @cindex dorian
1339
1340 @noindent
1341 Here, @code{@var{mode}} should be @code{\major} or @code{\minor}
1342 to get a key signature of @code{@var{pitch}}-major or
1343 @code{@var{pitch}}-minor, respectively.  You may also use the
1344 standard mode names, also called @notation{church modes}:
1345 @code{\ionian}, @code{\dorian}, @code{\phrygian}, @code{\lydian},
1346 @code{\mixolydian}, @code{\aeolian}, and @code{\locrian}.
1347
1348 @lilypond[verbatim,quote,relative=2]
1349 \key g \major
1350 fis1
1351 f
1352 fis
1353 @end lilypond
1354
1355 Additional modes can be defined, by listing the alterations
1356 for each scale step when the mode starts on C.
1357
1358 @lilypond[verbatim,quote]
1359 freygish = #`((0 . ,NATURAL) (1 . ,FLAT) (2 . ,NATURAL)
1360     (3 . ,NATURAL) (4 . ,NATURAL) (5 . ,FLAT) (6 . ,FLAT))
1361
1362 \relative {
1363   \key c \freygish c'4 des e f
1364   \bar "||" \key d \freygish d es fis g
1365 }
1366 @end lilypond
1367
1368 Accidentals in the key signature may be printed in octaves other
1369 than their traditional positions, or in multiple octaves, by
1370 using the @code{flat-positions} and @code{sharp-positions}
1371 properties of @code{KeySignature}.  Entries in these properties
1372 specify the range of staff-positions where accidentals will be
1373 printed.  If a single position is specified in an entry, the
1374 accidentals are placed within the octave ending at that staff
1375 position.
1376
1377 @lilypond[verbatim, quote,relative=0]
1378 \override Staff.KeySignature.flat-positions = #'((-5 . 5))
1379 \override Staff.KeyCancellation.flat-positions = #'((-5 . 5))
1380 \clef bass \key es \major es g bes d
1381 \clef treble \bar "||" \key es \major es g bes d
1382
1383 \override Staff.KeySignature.sharp-positions = #'(2)
1384 \bar "||" \key b \major b fis b2
1385 @end lilypond
1386
1387 @snippets
1388
1389 @lilypondfile[verbatim,quote,texidoc,doctitle]
1390 {preventing-natural-signs-from-being-printed-when-the-key-signature-changes.ly}
1391
1392 @lilypondfile[verbatim,quote,texidoc,doctitle]
1393 {non-traditional-key-signatures.ly}
1394
1395
1396 @seealso
1397 Music Glossary:
1398 @rglos{church mode},
1399 @rglos{scordatura}.
1400
1401 Learning Manual:
1402 @rlearning{Pitches and key signatures}.
1403
1404 Snippets:
1405 @rlsr{Pitches}.
1406
1407 Internals Reference:
1408 @rinternals{KeyChangeEvent},
1409 @rinternals{Key_engraver},
1410 @rinternals{Key_performer},
1411 @rinternals{KeyCancellation},
1412 @rinternals{KeySignature},
1413 @rinternals{key-signature-interface}.
1414
1415
1416 @node Ottava brackets
1417 @unnumberedsubsubsec Ottava brackets
1418
1419 @cindex ottava
1420 @cindex 15ma
1421 @cindex 8va
1422 @cindex 8ve
1423 @cindex octavation
1424
1425 @funindex set-octavation
1426 @funindex \ottava
1427 @funindex ottava
1428
1429 @notation{Ottava brackets} introduce an extra transposition of an
1430 octave for the staff:
1431
1432 @lilypond[verbatim,quote,relative=2]
1433 a2 b
1434 \ottava #-2
1435 a2 b
1436 \ottava #-1
1437 a2 b
1438 \ottava #0
1439 a2 b
1440 \ottava #1
1441 a2 b
1442 \ottava #2
1443 a2 b
1444 @end lilypond
1445
1446 @snippets
1447
1448 @lilypondfile[verbatim,quote,texidoc,doctitle]
1449 {ottava-text.ly}
1450
1451 @lilypondfile[verbatim,quote,texidoc,doctitle]
1452 {adding-an-ottava-marking-to-a-single-voice.ly}
1453
1454 @lilypondfile[verbatim,quote,texidoc,doctitle]
1455 {modifying-the-ottava-spanner-slope.ly}
1456
1457 @seealso
1458 Music Glossary:
1459 @rglos{octavation}.
1460
1461 Snippets:
1462 @rlsr{Pitches}.
1463
1464 Internals Reference:
1465 @rinternals{Ottava_spanner_engraver},
1466 @rinternals{OttavaBracket},
1467 @rinternals{ottava-bracket-interface}.
1468
1469
1470 @node Instrument transpositions
1471 @unnumberedsubsubsec Instrument transpositions
1472
1473 @cindex transposition, MIDI
1474 @cindex transposition, instrument
1475 @cindex transposing instrument
1476 @cindex MIDI
1477 @cindex MIDI transposition
1478
1479 @funindex \transposition
1480 @funindex transposition
1481
1482 When typesetting scores that involve transposing instruments, some
1483 parts can be typeset in a different pitch than the
1484 @notation{concert pitch}.  In these cases, the key of the
1485 @notation{transposing instrument} should be specified; otherwise
1486 the MIDI output and cues in other parts will produce incorrect
1487 pitches.  For more information about quotations, see
1488 @ref{Quoting other voices}.
1489
1490 @example
1491 \transposition @var{pitch}
1492 @end example
1493
1494 The pitch to use for @code{\transposition} should correspond to
1495 the real sound heard when a@tie{}@code{c'} written on the staff is
1496 played by the transposing instrument.  This pitch is entered in
1497 absolute mode, so an instrument that produces a real sound which
1498 is one tone higher than the printed music should use
1499 @w{@code{\transposition d'}}.  @code{\transposition} should
1500 @emph{only} be used if the pitches are @emph{not} being entered in
1501 concert pitch.
1502
1503 Here are a few notes for violin and B-flat clarinet where the
1504 parts have been entered using the notes and key as they appear in
1505 each part of the conductor's score.  The two instruments are
1506 playing in unison.
1507
1508 @lilypond[verbatim,quote]
1509 \new GrandStaff <<
1510   \new Staff = "violin" {
1511     \relative c'' {
1512       \set Staff.instrumentName = #"Vln"
1513       \set Staff.midiInstrument = #"violin"
1514       % not strictly necessary, but a good reminder
1515       \transposition c'
1516
1517       \key c \major
1518       g4( c8) r c r c4
1519     }
1520   }
1521   \new Staff = "clarinet" {
1522     \relative c'' {
1523       \set Staff.instrumentName = \markup { Cl (B\flat) }
1524       \set Staff.midiInstrument = #"clarinet"
1525       \transposition bes
1526
1527       \key d \major
1528       a4( d8) r d r d4
1529     }
1530   }
1531 >>
1532 @end lilypond
1533
1534 The @code{\transposition} may be changed during a piece.  For
1535 example, a clarinetist may be required to switch from an A clarinet
1536 to a B-flat clarinet.
1537
1538 @lilypond[verbatim,quote]
1539 flute = \relative c'' {
1540   \key f \major
1541   \cueDuring #"clarinet" #DOWN {
1542     R1 _\markup\tiny "clarinet"
1543     c4 f e d
1544     R1 _\markup\tiny "clarinet"
1545   }
1546 }
1547 clarinet = \relative c'' {
1548   \key aes \major
1549   \transposition a
1550   aes4 bes c des
1551   R1^\markup { muta in B\flat }
1552   \key g \major
1553   \transposition bes
1554   d2 g,
1555 }
1556 \addQuote "clarinet" \clarinet
1557 <<
1558   \new Staff \with { instrumentName = #"Flute" }
1559     \flute
1560   \new Staff \with { instrumentName = #"Cl (A)" }
1561     \clarinet
1562 >>
1563 @end lilypond
1564
1565 @seealso
1566 Music Glossary:
1567 @rglos{concert pitch},
1568 @rglos{transposing instrument}.
1569
1570 Notation Reference:
1571 @ref{Quoting other voices},
1572 @ref{Transpose}.
1573
1574 Snippets:
1575 @rlsr{Pitches}.
1576
1577
1578 @node Automatic accidentals
1579 @unnumberedsubsubsec Automatic accidentals
1580
1581 @cindex accidental style
1582 @cindex accidental style, default
1583 @cindex accidentals
1584 @cindex accidentals, automatic
1585 @cindex automatic accidentals
1586 @cindex default accidental style
1587
1588 @funindex \accidentalStyle
1589 @funindex voice
1590 @funindex default
1591
1592 There are many different conventions on how to typeset
1593 accidentals.  LilyPond provides a function to specify which
1594 accidental style to use.  This function is called as follows:
1595
1596 @example
1597 \new Staff <<
1598   \accidentalStyle voice
1599   @{ @dots{} @}
1600 >>
1601 @end example
1602
1603 The accidental style applies to the current @code{Staff} by
1604 default (with the exception of the styles @code{piano} and
1605 @code{piano-cautionary}, which are explained below).  Optionally,
1606 the function can take a second argument that determines in which
1607 scope the style should be changed.  For example, to use the same
1608 style in all staves of the current @code{StaffGroup}, use:
1609
1610 @example
1611 \accidentalStyle StaffGroup.voice
1612 @end example
1613
1614 The following accidental styles are supported.  To demonstrate
1615 each style, we use the following example:
1616
1617
1618 @lilypond[verbatim,quote]
1619 musicA = {
1620   <<
1621     \relative {
1622       cis''8 fis, bes4 <a cis>8 f bis4 |
1623       cis2. <c, g'>4 |
1624     }
1625     \\
1626     \relative {
1627       ais'2 cis, |
1628       fis8 b a4 cis2 |
1629     }
1630   >>
1631 }
1632
1633 musicB = {
1634   \clef bass
1635   \new Voice {
1636     \voiceTwo \relative {
1637       <fis a cis>8[ <fis a cis>
1638       \change Staff = up
1639       cis' cis
1640       \change Staff = down
1641       <fis, a> <fis a>]
1642       \showStaffSwitch
1643       \change Staff = up
1644       dis'4 |
1645       \change Staff = down
1646       <fis, a cis>4 gis <f a d>2 |
1647     }
1648   }
1649 }
1650
1651 \new PianoStaff {
1652   <<
1653     \context Staff = "up" {
1654       \accidentalStyle default
1655       \musicA
1656     }
1657     \context Staff = "down" {
1658       \accidentalStyle default
1659       \musicB
1660     }
1661   >>
1662 }
1663 @end lilypond
1664
1665 Note that the last lines of this example can be replaced by the
1666 following, as long as the same accidental style should be used in
1667 both staves.
1668
1669 @example
1670 \new PianoStaff @{
1671   <<
1672     \context Staff = "up" @{
1673       %%% change the next line as desired:
1674       \accidentalStyle Score.default
1675       \musicA
1676     @}
1677     \context Staff = "down" @{
1678       \musicB
1679     @}
1680   >>
1681 @}
1682 @end example
1683
1684
1685 @c don't use verbatim in this table.
1686 @table @code
1687 @item default
1688
1689 @cindex default accidental style
1690 @cindex accidental style, default
1691
1692 @funindex default
1693
1694 This is the default typesetting behavior.  It corresponds to
1695 eighteenth-century common practice: accidentals are remembered to
1696 the end of the measure in which they occur and only in their own
1697 octave.  Thus, in the example below, no natural signs are printed
1698 before the@tie{}@code{b} in the second measure or the
1699 last@tie{}@code{c}:
1700
1701 @lilypond[quote]
1702 musicA = {
1703   <<
1704     \relative {
1705       cis''8 fis, bes4 <a cis>8 f bis4 |
1706       cis2. <c, g'>4 |
1707     }
1708     \\
1709     \relative {
1710       ais'2 cis, |
1711       fis8 b a4 cis2 |
1712     }
1713   >>
1714 }
1715
1716 musicB = {
1717   \clef bass
1718   \new Voice {
1719     \voiceTwo \relative {
1720       <fis a cis>8[ <fis a cis>
1721       \change Staff = up
1722       cis' cis
1723       \change Staff = down
1724       <fis, a> <fis a>]
1725       \showStaffSwitch
1726       \change Staff = up
1727       dis'4 |
1728       \change Staff = down
1729       <fis, a cis>4 gis <f a d>2 |
1730     }
1731   }
1732 }
1733
1734 \new PianoStaff {
1735   <<
1736     \context Staff = "up" {
1737       \accidentalStyle default
1738       \musicA
1739     }
1740     \context Staff = "down" {
1741       \accidentalStyle default
1742       \musicB
1743     }
1744   >>
1745 }
1746 @end lilypond
1747
1748 @item voice
1749
1750 @cindex accidental style, voice
1751 @cindex voice accidental style
1752 @cindex accidental style, modern
1753 @cindex modern accidental style
1754 @cindex accidental style, modern-cautionary
1755 @cindex modern-cautionary accidental style
1756
1757 @funindex voice
1758
1759 The normal behavior is to remember the accidentals at
1760 @code{Staff}-level.  In this style, however, accidentals are
1761 typeset individually for each voice.  Apart from that, the rule is
1762 similar to @code{default}.
1763
1764 As a result, accidentals from one voice do not get canceled in
1765 other voices, which is often an unwanted result: in the following
1766 example, it is hard to determine whether the second@tie{}@code{a}
1767 should be played natural or sharp.  The @code{voice} option should
1768 therefore be used only if the voices are to be read solely by
1769 individual musicians.  If the staff is to be used by one musician
1770 (e.g., a conductor or in a piano score) then @code{modern} or
1771 @code{modern-cautionary} should be used instead.
1772
1773
1774 @lilypond[quote]
1775 musicA = {
1776   <<
1777     \relative {
1778       cis''8 fis, bes4 <a cis>8 f bis4 |
1779       cis2. <c, g'>4 |
1780     }
1781     \\
1782     \relative {
1783       ais'2 cis, |
1784       fis8 b a4 cis2 |
1785     }
1786   >>
1787 }
1788
1789 musicB = {
1790   \clef bass
1791   \new Voice {
1792     \voiceTwo \relative {
1793       <fis a cis>8[ <fis a cis>
1794       \change Staff = up
1795       cis' cis
1796       \change Staff = down
1797       <fis, a> <fis a>]
1798       \showStaffSwitch
1799       \change Staff = up
1800       dis'4 |
1801       \change Staff = down
1802       <fis, a cis>4 gis <f a d>2 |
1803     }
1804   }
1805 }
1806
1807 \new PianoStaff {
1808   <<
1809     \context Staff = "up" {
1810       \accidentalStyle voice
1811       \musicA
1812     }
1813     \context Staff = "down" {
1814       \accidentalStyle voice
1815       \musicB
1816     }
1817   >>
1818 }
1819 @end lilypond
1820
1821 @item modern
1822
1823 @cindex accidentals, modern style
1824 @cindex modern style accidentals
1825
1826 @funindex modern
1827
1828 This rule corresponds to the common practice in the twentieth
1829 century.  It omits some extra natural signs, which were
1830 traditionally prefixed to a sharp following a double sharp,
1831 or a flat following a double flat.  The @code{modern} rule
1832 prints the same accidentals as @code{default}, with
1833 two additions that serve to avoid ambiguity: after temporary
1834 accidentals, cancellation marks are printed also in the following
1835 measure (for notes in the same octave) and, in the same measure,
1836 for notes in other octaves.  Hence the naturals before
1837 the@tie{}@code{b} and the@tie{}@code{c} in the second measure of
1838 the upper staff:
1839
1840 @lilypond[quote]
1841 musicA = {
1842   <<
1843     \relative {
1844       cis''8 fis, bes4 <a cis>8 f bis4 |
1845       cis2. <c, g'>4 |
1846     }
1847     \\
1848     \relative {
1849       ais'2 cis, |
1850       fis8 b a4 cis2 |
1851     }
1852   >>
1853 }
1854
1855 musicB = {
1856   \clef bass
1857   \new Voice {
1858     \voiceTwo \relative {
1859       <fis a cis>8[ <fis a cis>
1860       \change Staff = up
1861       cis' cis
1862       \change Staff = down
1863       <fis, a> <fis a>]
1864       \showStaffSwitch
1865       \change Staff = up
1866       dis'4 |
1867       \change Staff = down
1868       <fis, a cis>4 gis <f a d>2 |
1869     }
1870   }
1871 }
1872
1873 \new PianoStaff {
1874   <<
1875     \context Staff = "up" {
1876       \accidentalStyle modern
1877       \musicA
1878     }
1879     \context Staff = "down" {
1880       \accidentalStyle modern
1881       \musicB
1882     }
1883   >>
1884 }
1885 @end lilypond
1886
1887 @item modern-cautionary
1888
1889 @cindex accidentals, modern cautionary style
1890 @cindex modern accidental style
1891 @cindex modern cautionary accidental style
1892 @cindex modern style accidentals
1893 @cindex modern style cautionary accidentals
1894
1895 @funindex modern-cautionary
1896
1897 This rule is similar to @code{modern}, but the @q{extra}
1898 accidentals (the ones not typeset by @code{default}) are typeset
1899 as cautionary accidentals.  They are by default printed with
1900 parentheses, but they can also be printed in reduced size by
1901 defining the @code{cautionary-style} property of
1902 @code{AccidentalSuggestion}.
1903
1904 @lilypond[quote]
1905 musicA = {
1906   <<
1907     \relative {
1908       cis''8 fis, bes4 <a cis>8 f bis4 |
1909       cis2. <c, g'>4 |
1910     }
1911     \\
1912     \relative {
1913       ais'2 cis, |
1914       fis8 b a4 cis2 |
1915     }
1916   >>
1917 }
1918
1919 musicB = {
1920   \clef bass
1921   \new Voice {
1922     \voiceTwo \relative {
1923       <fis a cis>8[ <fis a cis>
1924       \change Staff = up
1925       cis' cis
1926       \change Staff = down
1927       <fis, a> <fis a>]
1928       \showStaffSwitch
1929       \change Staff = up
1930       dis'4 |
1931       \change Staff = down
1932       <fis, a cis>4 gis <f a d>2 |
1933     }
1934   }
1935 }
1936
1937 \new PianoStaff {
1938   <<
1939     \context Staff = "up" {
1940       \accidentalStyle modern-cautionary
1941       \musicA
1942     }
1943     \context Staff = "down" {
1944       \accidentalStyle modern-cautionary
1945       \musicB
1946     }
1947   >>
1948 }
1949 @end lilypond
1950
1951 @item modern-voice
1952
1953 @cindex accidental style, modern
1954 @cindex accidentals, modern
1955 @cindex accidentals, multivoice
1956 @cindex modern accidental style
1957 @cindex modern accidentals
1958 @cindex multivoice accidentals
1959
1960 @funindex modern-voice
1961
1962 This rule is used for multivoice accidentals to be read both by
1963 musicians playing one voice and musicians playing all voices.
1964 Accidentals are typeset for each voice, but they @emph{are}
1965 canceled across voices in the same @code{Staff}.  Hence,
1966 the@tie{}@code{a} in the last measure is canceled because the
1967 previous cancellation was in a different voice, and
1968 the@tie{}@code{d} in the lower staff is canceled because of the
1969 accidental in a different voice in the previous measure:
1970
1971 @lilypond[quote]
1972 musicA = {
1973   <<
1974     \relative {
1975       cis''8 fis, bes4 <a cis>8 f bis4 |
1976       cis2. <c, g'>4 |
1977     }
1978     \\
1979     \relative {
1980       ais'2 cis, |
1981       fis8 b a4 cis2 |
1982     }
1983   >>
1984 }
1985
1986 musicB = {
1987   \clef bass
1988   \new Voice {
1989     \voiceTwo \relative {
1990       <fis a cis>8[ <fis a cis>
1991       \change Staff = up
1992       cis' cis
1993       \change Staff = down
1994       <fis, a> <fis a>]
1995       \showStaffSwitch
1996       \change Staff = up
1997       dis'4 |
1998       \change Staff = down
1999       <fis, a cis>4 gis <f a d>2 |
2000     }
2001   }
2002 }
2003
2004 \new PianoStaff {
2005   <<
2006     \context Staff = "up" {
2007       \accidentalStyle modern-voice
2008       \musicA
2009     }
2010     \context Staff = "down" {
2011       \accidentalStyle modern-voice
2012       \musicB
2013     }
2014   >>
2015 }
2016 @end lilypond
2017
2018 @cindex accidental style, cautionary, modern voice
2019 @cindex accidental style, modern voice cautionary
2020 @cindex accidental style, voice, modern cautionary
2021
2022 @funindex modern-voice-cautionary
2023
2024 @item modern-voice-cautionary
2025
2026 This rule is the same as @code{modern-voice}, but with the extra
2027 accidentals (the ones not typeset by @code{voice}) typeset as
2028 cautionaries.  Even though all accidentals typeset by
2029 @code{default} @emph{are} typeset with this rule, some of them are
2030 typeset as cautionaries.
2031
2032 @lilypond[quote]
2033 musicA = {
2034   <<
2035     \relative {
2036       cis''8 fis, bes4 <a cis>8 f bis4 |
2037       cis2. <c, g'>4 |
2038     }
2039     \\
2040     \relative {
2041       ais'2 cis, |
2042       fis8 b a4 cis2 |
2043     }
2044   >>
2045 }
2046
2047 musicB = {
2048   \clef bass
2049   \new Voice {
2050     \voiceTwo \relative {
2051       <fis a cis>8[ <fis a cis>
2052       \change Staff = up
2053       cis' cis
2054       \change Staff = down
2055       <fis, a> <fis a>]
2056       \showStaffSwitch
2057       \change Staff = up
2058       dis'4 |
2059       \change Staff = down
2060       <fis, a cis>4 gis <f a d>2 |
2061     }
2062   }
2063 }
2064
2065 \new PianoStaff {
2066   <<
2067     \context Staff = "up" {
2068       \accidentalStyle modern-voice-cautionary
2069       \musicA
2070     }
2071     \context Staff = "down" {
2072       \accidentalStyle modern-voice-cautionary
2073       \musicB
2074     }
2075   >>
2076 }
2077 @end lilypond
2078
2079 @item piano
2080
2081 @cindex accidental style, piano
2082 @cindex accidentals, piano
2083 @cindex piano accidental style
2084 @cindex piano accidentals
2085
2086 @funindex piano
2087
2088 This rule reflects twentieth-century practice for piano notation.
2089 Its behavior is very similar to @code{modern} style, but here
2090 accidentals also get canceled across the staves in the same
2091 @code{GrandStaff} or @code{PianoStaff}, hence all the
2092 cancellations of the final notes.
2093
2094 This accidental style applies to the current @code{GrandStaff} or
2095 @code{PianoStaff} by default.
2096
2097 @lilypond[quote]
2098 musicA = {
2099   <<
2100     \relative {
2101       cis''8 fis, bes4 <a cis>8 f bis4 |
2102       cis2. <c, g'>4 |
2103     }
2104     \\
2105     \relative {
2106       ais'2 cis, |
2107       fis8 b a4 cis2 |
2108     }
2109   >>
2110 }
2111
2112 musicB = {
2113   \clef bass
2114   \new Voice {
2115     \voiceTwo \relative {
2116       <fis a cis>8[ <fis a cis>
2117       \change Staff = up
2118       cis' cis
2119       \change Staff = down
2120       <fis, a> <fis a>]
2121       \showStaffSwitch
2122       \change Staff = up
2123       dis'4 |
2124       \change Staff = down
2125       <fis, a cis>4 gis <f a d>2 |
2126     }
2127   }
2128 }
2129
2130 \new PianoStaff {
2131   <<
2132     \context Staff = "up" {
2133       \accidentalStyle piano
2134       \musicA
2135     }
2136     \context Staff = "down" {
2137       \musicB
2138     }
2139   >>
2140 }
2141 @end lilypond
2142
2143 @item piano-cautionary
2144
2145 @cindex accidentals, piano cautionary
2146 @cindex cautionary accidentals, piano
2147 @cindex piano cautionary accidentals
2148 @cindex accidental style, piano cautionary
2149 @cindex cautionary accidental style, piano
2150 @cindex piano cautionary accidental style
2151
2152 @funindex piano-cautionary
2153
2154 This is the same as @code{piano} but with the extra accidentals
2155 typeset as cautionaries.
2156
2157 @lilypond[quote]
2158 musicA = {
2159   <<
2160     \relative {
2161       cis''8 fis, bes4 <a cis>8 f bis4 |
2162       cis2. <c, g'>4 |
2163     }
2164     \\
2165     \relative {
2166       ais'2 cis, |
2167       fis8 b a4 cis2 |
2168     }
2169   >>
2170 }
2171
2172 musicB = {
2173   \clef bass
2174   \new Voice {
2175     \voiceTwo \relative {
2176       <fis a cis>8[ <fis a cis>
2177       \change Staff = up
2178       cis' cis
2179       \change Staff = down
2180       <fis, a> <fis a>]
2181       \showStaffSwitch
2182       \change Staff = up
2183       dis'4 |
2184       \change Staff = down
2185       <fis, a cis>4 gis <f a d>2 |
2186     }
2187   }
2188 }
2189
2190 \new PianoStaff {
2191   <<
2192     \context Staff = "up" {
2193       \accidentalStyle piano-cautionary
2194       \musicA
2195     }
2196     \context Staff = "down" {
2197       \musicB
2198     }
2199   >>
2200 }
2201 @end lilypond
2202
2203
2204 @item neo-modern
2205
2206 @cindex neo-modern accidental style
2207 @cindex accidental style, neo-modern
2208
2209 @funindex neo-modern
2210
2211 This rule reproduces a common practice in contemporary music:
2212 accidentals are printed like with @code{modern}, but they are printed
2213 again if the same note appears later in the same measure -- except
2214 if the note is immediately repeated.
2215
2216 @lilypond[quote]
2217 musicA = {
2218   <<
2219     \relative {
2220       cis''8 fis, bes4 <a cis>8 f bis4 |
2221       cis2. <c, g'>4 |
2222     }
2223     \\
2224     \relative {
2225       ais'2 cis, |
2226       fis8 b a4 cis2 |
2227     }
2228   >>
2229 }
2230
2231 musicB = {
2232   \clef bass
2233   \new Voice {
2234     \voiceTwo \relative {
2235       <fis a cis>8[ <fis a cis>
2236       \change Staff = up
2237       cis' cis
2238       \change Staff = down
2239       <fis, a> <fis a>]
2240       \showStaffSwitch
2241       \change Staff = up
2242       dis'4 |
2243       \change Staff = down
2244       <fis, a cis>4 gis <f a d>2 |
2245     }
2246   }
2247 }
2248
2249 \new PianoStaff {
2250   <<
2251     \context Staff = "up" {
2252       \accidentalStyle neo-modern
2253       \musicA
2254     }
2255     \context Staff = "down" {
2256       \accidentalStyle neo-modern
2257       \musicB
2258     }
2259   >>
2260 }
2261 @end lilypond
2262
2263 @item neo-modern-cautionary
2264
2265 @cindex neo-modern-cautionary accidental style
2266 @cindex accidental style, neo-modern-cautionary
2267
2268 @funindex neo-modern-cautionary
2269
2270 This rule is similar to @code{neo-modern}, but the extra
2271 accidentals are printed as cautionary accidentals.
2272
2273 @lilypond[quote]
2274 musicA = {
2275   <<
2276     \relative {
2277       cis''8 fis, bes4 <a cis>8 f bis4 |
2278       cis2. <c, g'>4 |
2279     }
2280     \\
2281     \relative {
2282       ais'2 cis, |
2283       fis8 b a4 cis2 |
2284     }
2285   >>
2286 }
2287
2288 musicB = {
2289   \clef bass
2290   \new Voice {
2291     \voiceTwo \relative {
2292       <fis a cis>8[ <fis a cis>
2293       \change Staff = up
2294       cis' cis
2295       \change Staff = down
2296       <fis, a> <fis a>]
2297       \showStaffSwitch
2298       \change Staff = up
2299       dis'4 |
2300       \change Staff = down
2301       <fis, a cis>4 gis <f a d>2 |
2302     }
2303   }
2304 }
2305
2306 \new PianoStaff {
2307   <<
2308     \context Staff = "up" {
2309       \accidentalStyle neo-modern-cautionary
2310       \musicA
2311     }
2312     \context Staff = "down" {
2313       \accidentalStyle neo-modern-cautionary
2314       \musicB
2315     }
2316   >>
2317 }
2318 @end lilypond
2319
2320
2321 @item neo-modern-voice
2322
2323 @cindex neo-modern-voice accidental style
2324 @cindex accidental style, neo-modern-voice
2325
2326 @funindex neo-modern-voice
2327
2328 This rule is used for multivoice accidentals to be read both by
2329 musicians playing one voice and musicians playing all voices.
2330 Accidentals are typeset for each voice as with @code{neo-modern},
2331 but they are canceled across voices in the same @code{Staff}.
2332
2333 @lilypond[quote]
2334 musicA = {
2335   <<
2336     \relative {
2337       cis''8 fis, bes4 <a cis>8 f bis4 |
2338       cis2. <c, g'>4 |
2339     }
2340     \\
2341     \relative {
2342       ais'2 cis, |
2343       fis8 b a4 cis2 |
2344     }
2345   >>
2346 }
2347
2348 musicB = {
2349   \clef bass
2350   \new Voice {
2351     \voiceTwo \relative {
2352       <fis a cis>8[ <fis a cis>
2353       \change Staff = up
2354       cis' cis
2355       \change Staff = down
2356       <fis, a> <fis a>]
2357       \showStaffSwitch
2358       \change Staff = up
2359       dis'4 |
2360       \change Staff = down
2361       <fis, a cis>4 gis <f a d>2 |
2362     }
2363   }
2364 }
2365
2366 \new PianoStaff {
2367   <<
2368     \context Staff = "up" {
2369       \accidentalStyle neo-modern-voice
2370       \musicA
2371     }
2372     \context Staff = "down" {
2373       \accidentalStyle neo-modern-voice
2374       \musicB
2375     }
2376   >>
2377 }
2378 @end lilypond
2379
2380 @item neo-modern-voice-cautionary
2381
2382 @cindex neo-modern-voice-cautionary accidental style
2383 @cindex accidental style, neo-modern-voice-cautionary
2384
2385 @funindex neo-modern-voice-cautionary
2386
2387 This rule is similar to @code{neo-modern-voice}, but the extra
2388 accidentals are printed as cautionary accidentals.
2389
2390 @lilypond[quote]
2391 musicA = {
2392   <<
2393     \relative {
2394       cis''8 fis, bes4 <a cis>8 f bis4 |
2395       cis2. <c, g'>4 |
2396     }
2397     \\
2398     \relative {
2399       ais'2 cis, |
2400       fis8 b a4 cis2 |
2401     }
2402   >>
2403 }
2404
2405 musicB = {
2406   \clef bass
2407   \new Voice {
2408     \voiceTwo \relative {
2409       <fis a cis>8[ <fis a cis>
2410       \change Staff = up
2411       cis' cis
2412       \change Staff = down
2413       <fis, a> <fis a>]
2414       \showStaffSwitch
2415       \change Staff = up
2416       dis'4 |
2417       \change Staff = down
2418       <fis, a cis>4 gis <f a d>2 |
2419     }
2420   }
2421 }
2422
2423 \new PianoStaff {
2424   <<
2425     \context Staff = "up" {
2426       \accidentalStyle neo-modern-voice-cautionary
2427       \musicA
2428     }
2429     \context Staff = "down" {
2430       \accidentalStyle neo-modern-voice-cautionary
2431       \musicB
2432     }
2433   >>
2434 }
2435 @end lilypond
2436
2437 @item dodecaphonic
2438
2439 @cindex dodecaphonic accidental style
2440 @cindex dodecaphonic style, neo-modern
2441
2442 @funindex dodecaphonic
2443
2444 This rule reflects a practice introduced by composers at
2445 the beginning of the 20th century, in an attempt to
2446 abolish the hierarchy between natural and non-natural notes.
2447 With this style, @emph{every} note gets an accidental sign,
2448 including natural signs.
2449
2450 @lilypond[quote]
2451 musicA = {
2452   <<
2453     \relative {
2454       cis''8 fis, bes4 <a cis>8 f bis4 |
2455       cis2. <c, g'>4 |
2456     }
2457     \\
2458     \relative {
2459       ais'2 cis, |
2460       fis8 b a4 cis2 |
2461     }
2462   >>
2463 }
2464
2465 musicB = {
2466   \clef bass
2467   \new Voice {
2468     \voiceTwo \relative {
2469       <fis a cis>8[ <fis a cis>
2470       \change Staff = up
2471       cis' cis
2472       \change Staff = down
2473       <fis, a> <fis a>]
2474       \showStaffSwitch
2475       \change Staff = up
2476       dis'4 |
2477       \change Staff = down
2478       <fis, a cis>4 gis <f a d>2 |
2479     }
2480   }
2481 }
2482
2483 \new PianoStaff {
2484   <<
2485     \context Staff = "up" {
2486       \accidentalStyle dodecaphonic
2487       \musicA
2488     }
2489     \context Staff = "down" {
2490       \accidentalStyle dodecaphonic
2491       \musicB
2492     }
2493   >>
2494 }
2495 @end lilypond
2496
2497 @item dodecaphonic-no-repeat
2498
2499 @cindex dodecaphonic accidental style
2500 @cindex dodecaphonic style, neo-modern
2501
2502 @funindex dodecaphonic-no-repeat
2503
2504 Like with the dodecaphonic accidental style @emph{every} note
2505 gets an accidental sign by default, but accidentals are
2506 suppressed for pitches immediately repeated within the same staff.
2507
2508 @lilypond[quote]
2509 musicA = {
2510   <<
2511     \relative {
2512       cis''8 fis, bes4 <a cis>8 f bis4 |
2513       cis2. <c, g'>4 |
2514     }
2515     \\
2516     \relative {
2517       ais'2 cis, |
2518       fis8 b a4 cis2 |
2519     }
2520   >>
2521 }
2522
2523 musicB = {
2524   \clef bass
2525   \new Voice {
2526     \voiceTwo \relative {
2527       <fis a cis>8[ <fis a cis>
2528       \change Staff = up
2529       cis' cis
2530       \change Staff = down
2531       <fis, a> <fis a>]
2532       \showStaffSwitch
2533       \change Staff = up
2534       dis'4 |
2535       \change Staff = down
2536       <fis, a cis>4 gis <f a d>2 |
2537     }
2538   }
2539 }
2540
2541 \new PianoStaff {
2542   <<
2543     \context Staff = "up" {
2544       \accidentalStyle dodecaphonic-no-repeat
2545       \musicA
2546     }
2547     \context Staff = "down" {
2548       \accidentalStyle dodecaphonic-no-repeat
2549       \musicB
2550     }
2551   >>
2552 }
2553 @end lilypond
2554
2555
2556 @item dodecaphonic-first
2557
2558 @cindex dodecaphonic accidental style
2559 @cindex dodecaphonic style, neo-modern
2560
2561 @funindex dodecaphonic-first
2562
2563 Similar to the dodecaphonic accidental style @emph{every} pitch
2564 gets an accidental sign, but only the first time it is encountered
2565 in a measure.  Accidentals are only remembered for the actual octave
2566 but throughout voices.
2567
2568 @lilypond[quote]
2569 musicA = {
2570   <<
2571     \relative {
2572       cis''8 fis, bes4 <a cis>8 f bis4 |
2573       cis2. <c, g'>4 |
2574     }
2575     \\
2576     \relative {
2577       ais'2 cis, |
2578       fis8 b a4 cis2 |
2579     }
2580   >>
2581 }
2582
2583 musicB = {
2584   \clef bass
2585   \new Voice {
2586     \voiceTwo \relative {
2587       <fis a cis>8[ <fis a cis>
2588       \change Staff = up
2589       cis' cis
2590       \change Staff = down
2591       <fis, a> <fis a>]
2592       \showStaffSwitch
2593       \change Staff = up
2594       dis'4 |
2595       \change Staff = down
2596       <fis, a cis>4 gis <f a d>2 |
2597     }
2598   }
2599 }
2600
2601 \new PianoStaff {
2602   <<
2603     \context Staff = "up" {
2604       \accidentalStyle dodecaphonic-first
2605       \musicA
2606     }
2607     \context Staff = "down" {
2608       \accidentalStyle dodecaphonic-first
2609       \musicB
2610     }
2611   >>
2612 }
2613 @end lilypond
2614
2615
2616 @item teaching
2617
2618 @cindex teaching accidental style
2619 @cindex accidental style, teaching
2620
2621 @funindex teaching
2622
2623 This rule is intended for students, and makes it easy to create
2624 scale sheets with automatically created cautionary accidentals.
2625 Accidentals are printed like with @code{modern}, but cautionary
2626 accidentals are added for all sharp or flat tones specified by the
2627 key signature, except if the note is immediately repeated.
2628
2629 @lilypond[quote,staffsize=18]
2630 musicA = {
2631   <<
2632     \relative {
2633       cis''8 fis, bes4 <a cis>8 f bis4 |
2634       cis2. <c, g'>4 |
2635     }
2636     \\
2637     \relative {
2638       ais'2 cis, |
2639       fis8 b a4 cis2 |
2640     }
2641   >>
2642 }
2643
2644 musicB = {
2645   \clef bass
2646   \new Voice {
2647     \voiceTwo \relative {
2648       <fis a cis>8[ <fis a cis>
2649       \change Staff = up
2650       cis' cis
2651       \change Staff = down
2652       <fis, a> <fis a>]
2653       \showStaffSwitch
2654       \change Staff = up
2655       dis'4 |
2656       \change Staff = down
2657       <fis, a cis>4 gis <f a d>2 |
2658     }
2659   }
2660 }
2661
2662 \new PianoStaff {
2663   <<
2664     \context Staff = "up" {
2665       \key fis \minor
2666       \accidentalStyle teaching
2667       \musicA
2668     }
2669     \context Staff = "down" {
2670       \key fis \minor
2671       \accidentalStyle teaching
2672       \musicB
2673     }
2674   >>
2675 }
2676 @end lilypond
2677
2678
2679
2680 @item no-reset
2681
2682 @cindex accidental style, no reset
2683 @cindex no reset accidental style
2684
2685 @funindex no-reset
2686
2687 This is the same as @code{default} but with accidentals lasting
2688 @q{forever} and not only within the same measure:
2689
2690 @lilypond[quote]
2691 musicA = {
2692   <<
2693     \relative {
2694       cis''8 fis, bes4 <a cis>8 f bis4 |
2695       cis2. <c, g'>4 |
2696     }
2697     \\
2698     \relative {
2699       ais'2 cis, |
2700       fis8 b a4 cis2 |
2701     }
2702   >>
2703 }
2704
2705 musicB = {
2706   \clef bass
2707   \new Voice {
2708     \voiceTwo \relative {
2709       <fis a cis>8[ <fis a cis>
2710       \change Staff = up
2711       cis' cis
2712       \change Staff = down
2713       <fis, a> <fis a>]
2714       \showStaffSwitch
2715       \change Staff = up
2716       dis'4 |
2717       \change Staff = down
2718       <fis, a cis>4 gis <f a d>2 |
2719     }
2720   }
2721 }
2722
2723 \new PianoStaff {
2724   <<
2725     \context Staff = "up" {
2726       \accidentalStyle no-reset
2727       \musicA
2728     }
2729     \context Staff = "down" {
2730       \accidentalStyle no-reset
2731       \musicB
2732     }
2733   >>
2734 }
2735 @end lilypond
2736
2737 @item forget
2738
2739 @cindex forget accidental style
2740 @cindex accidental style, forget
2741
2742 @funindex forget
2743
2744 This is the opposite of @code{no-reset}: Accidentals are not
2745 remembered at all -- and hence all accidentals are typeset
2746 relative to the key signature, regardless of what came before in
2747 the music.
2748
2749 @lilypond[quote]
2750 musicA = {
2751   <<
2752     \relative {
2753       cis''8 fis, bes4 <a cis>8 f bis4 |
2754       cis2. <c, g'>4 |
2755     }
2756     \\
2757     \relative {
2758       ais'2 cis, |
2759       fis8 b a4 cis2 |
2760     }
2761   >>
2762 }
2763
2764 musicB = {
2765   \clef bass
2766   \new Voice {
2767     \voiceTwo \relative {
2768       <fis a cis>8[ <fis a cis>
2769       \change Staff = up
2770       cis' cis
2771       \change Staff = down
2772       <fis, a> <fis a>]
2773       \showStaffSwitch
2774       \change Staff = up
2775       dis'4 |
2776       \change Staff = down
2777       <fis, a cis>4 gis <f a d>2 |
2778     }
2779   }
2780 }
2781
2782 \new PianoStaff {
2783   <<
2784     \context Staff = "up" {
2785       \accidentalStyle forget
2786       \musicA
2787     }
2788     \context Staff = "down" {
2789       \accidentalStyle forget
2790       \musicB
2791     }
2792   >>
2793 }
2794 @end lilypond
2795 @end table
2796
2797 @seealso
2798 Snippets:
2799 @rlsr{Pitches}.
2800
2801 Internals Reference:
2802 @rinternals{Accidental},
2803 @rinternals{Accidental_engraver},
2804 @rinternals{GrandStaff},
2805 @rinternals{PianoStaff},
2806 @rinternals{Staff},
2807 @rinternals{AccidentalSuggestion},
2808 @rinternals{AccidentalPlacement},
2809 @rinternals{accidental-suggestion-interface}.
2810
2811 @cindex accidentals and simultaneous notes
2812 @cindex simultaneous notes and accidentals
2813 @cindex accidentals in chords
2814 @cindex chords, accidentals in
2815
2816 @knownissues
2817 Simultaneous notes are not considered in the automatic
2818 determination of accidentals; only previous notes and the key
2819 signature are considered.  Forcing accidentals with@tie{}@code{!}
2820 or@tie{}@code{?} may be required when the same note name occurs
2821 simultaneously with different alterations, as in @samp{<f! fis!>}.
2822
2823 Cautionary cancellation of accidentals is done by looking at previous measure.
2824 However, in the @code{\alternative} block following a @code{\repeat volta N}
2825 section, one would expect the cancellation being calculated using the previous
2826 @emph{played} measure, not previous @emph{printed} measure.
2827 In the following example, the natural @code{c} in the second alternative does
2828 not need a natural sign:
2829
2830 @lilypond[quote]
2831 {
2832   \accidentalStyle modern
2833   \time 2/4
2834   \repeat volta 2 {
2835     c'2
2836   }
2837   \alternative {
2838      cis'
2839      c'
2840   }
2841 }
2842 @end lilypond
2843
2844 The following work-around can be used: define a function that locally changes
2845 the accidental style to @code{forget}:
2846
2847 @lilypond[verbatim,quote]
2848 forget = #(define-music-function (music) (ly:music?) #{
2849   \accidentalStyle forget
2850   #music
2851   \accidentalStyle modern
2852 #})
2853 {
2854   \accidentalStyle modern
2855   \time 2/4
2856   \repeat volta 2 {
2857     c'2
2858   }
2859   \alternative {
2860      cis'
2861      \forget c'
2862   }
2863 }
2864 @end lilypond
2865
2866
2867 @node Ambitus
2868 @unnumberedsubsubsec Ambitus
2869
2870 @cindex ambitus
2871 @cindex range of pitches
2872 @cindex pitch range
2873
2874 The term @notation{ambitus} (pl. ambitus) denotes a range of
2875 pitches for a given voice in a part of music.  It may also denote
2876 the pitch range that a musical instrument is capable of playing.
2877 Ambitus are printed on vocal parts so that performers can easily
2878 determine if it matches their capabilities.
2879
2880 Ambitus are denoted at the beginning of a piece near the initial
2881 clef.  The range is graphically specified by two note heads that
2882 represent the lowest and highest pitches.  Accidentals are only
2883 printed if they are not part of the key signature.
2884
2885 @lilypond[verbatim,quote]
2886 \layout {
2887   \context {
2888     \Voice
2889     \consists "Ambitus_engraver"
2890   }
2891 }
2892
2893 \relative {
2894   aes' c e2
2895   cis,1
2896 }
2897 @end lilypond
2898
2899
2900 @snippets
2901
2902 @lilypondfile[verbatim,quote,texidoc,doctitle]
2903 {adding-ambitus-per-voice.ly}
2904
2905 @lilypondfile[verbatim,quote,texidoc,doctitle]
2906 {ambitus-with-multiple-voices.ly}
2907
2908 @lilypondfile[verbatim,quote,texidoc,doctitle]
2909 {changing-the-ambitus-gap.ly}
2910
2911 @seealso
2912 Music Glossary:
2913 @rglos{ambitus}.
2914
2915 Snippets:
2916 @rlsr{Pitches}.
2917
2918 Internals Reference:
2919 @rinternals{Ambitus_engraver},
2920 @rinternals{Voice},
2921 @rinternals{Staff},
2922 @rinternals{Ambitus},
2923 @rinternals{AmbitusAccidental},
2924 @rinternals{AmbitusLine},
2925 @rinternals{AmbitusNoteHead},
2926 @rinternals{ambitus-interface}.
2927
2928 @knownissues
2929 There is no collision handling in the case of multiple per-voice
2930 ambitus.
2931
2932
2933 @node Note heads
2934 @subsection Note heads
2935
2936 This section suggests ways of altering note heads.
2937
2938 @menu
2939 * Special note heads::
2940 * Easy notation note heads::
2941 * Shape note heads::
2942 * Improvisation::
2943 @end menu
2944
2945 @node Special note heads
2946 @unnumberedsubsubsec Special note heads
2947
2948 @cindex note heads, special
2949 @cindex note heads, cross
2950 @cindex note heads, diamond
2951 @cindex note heads, parlato
2952 @cindex note heads, harmonic
2953 @cindex note heads, guitar
2954 @cindex special note heads
2955 @cindex cross note heads
2956 @cindex diamond note heads
2957 @cindex parlato note heads
2958 @cindex harmonic note heads
2959 @cindex guitar note heads
2960 @cindex note head styles
2961 @cindex styles, note heads
2962
2963 @funindex cross
2964
2965 The appearance of note heads may be altered:
2966
2967 @lilypond[verbatim,quote,relative=2]
2968 c4 b
2969 \override NoteHead.style = #'cross
2970 c4 b
2971 \revert NoteHead.style
2972 a b
2973 \override NoteHead.style = #'harmonic
2974 a b
2975 \revert NoteHead.style
2976 c4 d e f
2977 @end lilypond
2978
2979 To see all note head styles, see @ref{Note head styles}.
2980
2981 The @code{cross} style is used to represent a variety of musical
2982 intentions.  The following generic predefined commands modify the
2983 note head in both staff and tablature contexts and can be used to
2984 represent any musical meaning:
2985
2986 @lilypond[verbatim,quote,relative=2]
2987 c4 b
2988 \xNotesOn
2989  a b c4 b
2990 \xNotesOff
2991 c4 d
2992 @end lilypond
2993
2994 The music function form of this predefined command may be used
2995 inside and outside chords to generate crossed note heads in both
2996 staff and tablature contexts:
2997
2998 @lilypond[verbatim,quote,relative=2]
2999 c4 b
3000 \xNote { e f }
3001 c b < g \xNote c f > b
3002 @end lilypond
3003
3004 As synonyms for @code{\xNote}, @code{\xNotesOn} and @code{\xNotesOff},
3005 @code{\deadNote}, @code{\deadNotesOn} and @code{\deadNotesOff} can
3006 be used.  The term @notation{dead note} is commonly used by guitarists.
3007
3008 There is also a similar shorthand for diamond shapes:
3009
3010 @lilypond[verbatim,quote,relative=2]
3011 <c f\harmonic>2 <d a'\harmonic>4 <c g'\harmonic> f\harmonic
3012 @end lilypond
3013
3014 @predefined
3015 @code{\harmonic},
3016 @code{\xNotesOn},
3017 @code{\xNotesOff},
3018 @code{\xNote}.
3019 @endpredefined
3020
3021 @seealso
3022 Snippets:
3023 @rlsr{Pitches}.
3024
3025 Notation Reference:
3026 @ref{Note head styles},
3027 @ref{Chorded notes},
3028 @ref{Indicating harmonics and dampened notes}.
3029
3030 Internals Reference:
3031 @rinternals{note-event},
3032 @rinternals{Note_heads_engraver},
3033 @rinternals{Ledger_line_engraver},
3034 @rinternals{NoteHead},
3035 @rinternals{LedgerLineSpanner},
3036 @rinternals{note-head-interface},
3037 @rinternals{ledger-line-spanner-interface}.
3038
3039
3040 @node Easy notation note heads
3041 @unnumberedsubsubsec Easy notation note heads
3042
3043 @cindex note heads, practice
3044 @cindex practice note heads
3045 @cindex note heads, easy notation
3046 @cindex easy notation
3047 @cindex beginners' music
3048 @cindex music, beginners'
3049 @cindex easy play note heads
3050 @cindex note heads, easy play
3051
3052 @funindex \easyHeadsOn
3053 @funindex easyHeadsOn
3054 @funindex \easyHeadsOff
3055 @funindex easyHeadsOff
3056
3057 The @q{easy play} note head includes a note name inside the head.
3058 It is used in music for beginners.  To make the letters readable,
3059 it should be printed in a large font size.  To print with a larger
3060 font, see @ref{Setting the staff size}.
3061
3062 @lilypond[verbatim,quote]
3063 #(set-global-staff-size 26)
3064 \relative c' {
3065   \easyHeadsOn
3066   c2 e4 f
3067   g1
3068   \easyHeadsOff
3069   c,1
3070 }
3071 @end lilypond
3072
3073
3074 @predefined
3075 @code{\easyHeadsOn},
3076 @code{\easyHeadsOff}.
3077 @endpredefined
3078
3079
3080 @snippets
3081
3082 @lilypondfile[verbatim,quote,texidoc,doctitle]
3083 {numbers-as-easy-note-heads.ly}
3084
3085 @seealso
3086 Notation Reference:
3087 @ref{Setting the staff size}.
3088
3089 Snippets:
3090 @rlsr{Pitches}.
3091
3092 Internals Reference:
3093 @rinternals{note-event},
3094 @rinternals{Note_heads_engraver},
3095 @rinternals{NoteHead},
3096 @rinternals{note-head-interface}.
3097
3098
3099 @node Shape note heads
3100 @unnumberedsubsubsec Shape note heads
3101
3102 @cindex note heads, shape
3103 @cindex note heads, Aiken
3104 @cindex note heads, sacred harp
3105 @cindex shape notes
3106 @cindex Aiken shape note heads
3107 @cindex sacred harp note heads
3108 @cindex note heads, Southern Harmony
3109 @cindex Southern Harmony note heads
3110 @cindex Funk shape note heads
3111 @cindex note heads, Funk
3112 @cindex note heads, Harmonica Sacra
3113 @cindex Harmonica Sacra note heads
3114 @cindex Christian Harmony note heads
3115 @cindex note heads, Christian Harmony
3116 @cindex Walker shape note heads
3117 @cindex note heads, Walker
3118
3119 @funindex \aikenHeads
3120 @funindex aikenHeads
3121 @funindex \sacredHarpHeads
3122 @funindex sacredHarpHeads
3123 @funindex \southernHarmonyHeads
3124 @funindex southernHarmonyHeads
3125 @funindex \funkHeads
3126 @funindex funkHeads
3127 @funindex \walkerHeads
3128 @funindex walkerHeads
3129
3130 In shape note head notation, the shape of the note head
3131 corresponds to the harmonic function of a note in the scale.  This
3132 notation was popular in nineteenth-century American song books.
3133 Shape note heads can be produced in Sacred Harp, Southern Harmony,
3134 Funk (Harmonica Sacra), Walker, and Aiken (Christian Harmony) styles:
3135
3136 @lilypond[verbatim,quote,relative=2]
3137 \aikenHeads
3138 c, d e f g2 a b1 c \break
3139 \sacredHarpHeads
3140 c,4 d e f g2 a b1 c \break
3141 \southernHarmonyHeads
3142 c,4 d e f g2 a b1 c \break
3143 \funkHeads
3144 c,4 d e f g2 a b1 c \break
3145 \walkerHeads
3146 c,4 d e f g2 a b1 c \break
3147 @end lilypond
3148
3149 @funindex \key
3150 @funindex key
3151 @funindex \aikenHeadsMinor
3152 @funindex aikenHeadsMinor
3153 @funindex \sacredHarpHeadsMinor
3154 @funindex sacredHarpHeadsMinor
3155 @funindex \southernHarmonyHeadsMinor
3156 @funindex southernHarmonyHeadsMinor
3157 @funindex \funkHeadsMinor
3158 @funindex funkHeadsMinor
3159 @funindex \walkerHeadsMinor
3160 @funindex walkerHeadsMinor
3161
3162 Shapes are typeset according to the step in the scale, where the base
3163 of the scale is determined by the @code{\key} command.  When writing
3164 in a minor key, the scale step can be determined from the relative
3165 major:
3166
3167 @lilypond[verbatim,quote,relative=2]
3168 \key a \minor
3169 \aikenHeads
3170 a b c d e2 f g1 a \break
3171 \aikenHeadsMinor
3172 a,4 b c d e2 f g1 a \break
3173 \sacredHarpHeadsMinor
3174 a,2 b c d \break
3175 \southernHarmonyHeadsMinor
3176 a2 b c d \break
3177 \funkHeadsMinor
3178 a2 b c d \break
3179 \walkerHeadsMinor
3180 a2 b c d \break
3181
3182 @end lilypond
3183
3184
3185 @predefined
3186 @code{\aikenHeads},
3187 @code{\aikenHeadsMinor},
3188 @code{\funkHeads},
3189 @code{\funkHeadsMinor},
3190 @code{\sacredHarpHeads},
3191 @code{\sacredHarpHeadsMinor},
3192 @code{\southernHarmonyHeads},
3193 @code{\southernHarmonyHeadsMinor},
3194 @code{\walkerHeads},
3195 @code{\walkerHeadsMinor}.
3196 @endpredefined
3197
3198
3199 @snippets
3200
3201 @lilypondfile[verbatim,quote,texidoc,doctitle]
3202 {applying-note-head-styles-depending-on-the-step-of-the-scale.ly}
3203
3204 To see all note head styles, see @ref{Note head styles}.
3205
3206 @seealso
3207 Snippets:
3208 @rlsr{Pitches}.
3209
3210 Notation Reference:
3211 @ref{Note head styles}.
3212
3213 Internals Reference:
3214 @rinternals{note-event},
3215 @rinternals{Note_heads_engraver},
3216 @rinternals{NoteHead},
3217 @rinternals{note-head-interface}.
3218
3219
3220 @node Improvisation
3221 @unnumberedsubsubsec Improvisation
3222
3223 @cindex improvisation
3224 @cindex slashed note heads
3225 @cindex note heads, improvisation
3226 @cindex note heads, slashed
3227
3228 @funindex \improvisationOn
3229 @funindex improvisationOn
3230 @funindex \improvisationOff
3231 @funindex improvisationOff
3232
3233 Improvisation is sometimes denoted with slashed note heads, where
3234 the performer may choose any pitch but should play the specified
3235 rhythm.  Such note heads can be created:
3236
3237 @lilypond[verbatim,quote,relative=2]
3238 \new Voice \with {
3239   \consists "Pitch_squash_engraver"
3240 } {
3241   e8 e g a a16( bes) a8 g
3242   \improvisationOn
3243   e8 ~
3244   2 ~ 8 f4 f8 ~
3245   2
3246   \improvisationOff
3247   a16( bes) a8 g e
3248 }
3249 @end lilypond
3250
3251 @predefined
3252 @code{\improvisationOn},
3253 @code{\improvisationOff}.
3254 @endpredefined
3255
3256 @seealso
3257 Snippets:
3258 @rlsr{Pitches}.
3259
3260 Internals Reference:
3261 @rinternals{Pitch_squash_engraver},
3262 @rinternals{Voice},
3263 @rinternals{RhythmicStaff}.