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