]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/notation/pitches.itely
c706a3a95125475a47f41aff58bcdac580154601
[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.21"
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 @{ gis''' @dots{} @}}
179
180 @item an octave of the first note inside
181 Writing @code{\relative @{ gis''' @dots{} @}} makes it easy to
182 determine the absolute pitch of the first note inside.
183
184 @item no explicit starting pitch
185 This (namely writing @code{\relative @{ gis''' @dots{} @}}) can be
186 viewed 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 first 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 applies.
227
228 @lilypond[verbatim,quote]
229 \relative {
230   c' d e f
231   \relative {
232     c'' d e f
233   }
234 }
235 @end lilypond
236
237 @code{\relative} has no effect on @code{\chordmode} blocks.
238
239 @lilypond[verbatim,quote]
240 \new Staff {
241   \relative c''' {
242     \chordmode { c1 }
243   }
244   \chordmode { c1 }
245 }
246 @end lilypond
247
248 @code{\relative} is not allowed inside of @code{\chordmode} blocks.
249
250 Music inside a @code{\transpose} block is absolute unless a
251 @code{\relative} is included.
252
253 @lilypond[verbatim,quote]
254 \relative {
255   d' e
256   \transpose f g {
257     d e
258     \relative {
259       d' e
260     }
261   }
262 }
263 @end lilypond
264
265
266 @cindex chords and relative octave entry
267 @cindex relative octave entry and chords
268
269 If the preceding item is a chord, the first note of the chord is
270 used as the reference point for the octave placement of a
271 following note or chord.  Inside chords, the next note is always
272 relative to the preceding one.  Examine the next example
273 carefully, paying attention to the @code{c} notes.
274
275 @lilypond[verbatim,quote]
276 \relative {
277   c'
278   <c e g>
279   <c' e g'>
280   <c, e, g''>
281 }
282 @end lilypond
283
284 As explained above, the octave of pitches is calculated only with
285 the note names, regardless of any alterations.  Therefore, an
286 E-double-sharp following a B will be placed higher, while an
287 F-double-flat will be placed lower.  In other words, a
288 double-augmented fourth is considered a smaller interval than a
289 double-diminished fifth, regardless of the number of semitones
290 that each interval contains.
291
292 @lilypond[verbatim,quote]
293 \relative {
294   c''2 fis
295   c2 ges
296   b2 eisis
297   b2 feses
298 }
299 @end lilypond
300
301 One consequence of these rules is that the first note inside
302 @code{@w{\relative f}} music is interpreted just the same as
303 if it was written in absolute pitch mode.
304
305 @seealso
306 Music Glossary:
307 @rglos{fifth},
308 @rglos{interval},
309 @rglos{Pitch names}.
310
311 Notation Reference:
312 @ref{Octave checks}.
313
314 Snippets:
315 @rlsr{Pitches}.
316
317 Internals Reference:
318 @rinternals{RelativeOctaveMusic}.
319
320 @cindex relative octave entry and transposition
321 @cindex transposition and relative octave entry
322
323 @funindex \transpose
324 @funindex transpose
325 @funindex \chordmode
326 @funindex chordmode
327 @funindex \relative
328 @funindex relative
329
330
331 @node Accidentals
332 @unnumberedsubsubsec Accidentals
333
334 @cindex accidental
335 @cindex key signature
336 @cindex clef
337
338 @c duplicated in Key signature and Accidentals
339 @warning{New users are sometimes confused about accidentals and
340 key signatures.  In LilyPond, note names specify pitches; key
341 signatures and clefs determine how these pitches are displayed.
342 An unaltered note like@tie{}@code{c} means @q{C natural},
343 regardless of the key signature or clef.  For more information,
344 see @rlearning{Pitches and key signatures}.}
345
346 @cindex note names, Dutch
347 @cindex note names, default
348 @cindex default note names
349 @cindex sharp
350 @cindex flat
351 @cindex double sharp
352 @cindex sharp, double
353 @cindex double flat
354 @cindex flat, double
355 @cindex natural sign
356 @cindex natural pitch
357
358 A @notation{sharp} pitch is made by adding @code{is} to the note
359 name, and a @notation{flat} pitch by adding @code{es}.  As you
360 might expect, a @notation{double sharp} or @notation{double flat}
361 is made by adding @code{isis} or @code{eses}.  This syntax is
362 derived from Dutch note naming conventions.  To use other names
363 for accidentals, see @ref{Note names in other languages}.
364
365 @lilypond[verbatim,quote,relative=2]
366 ais1 aes aisis aeses
367 @end lilypond
368
369 A natural pitch is entered as a simple note name; no suffix is
370 required.  A natural sign will be printed when needed to cancel
371 the effect of an earlier accidental or key signature.
372
373 @lilypond[verbatim,quote,relative=2]
374 a4 aes a2
375 @end lilypond
376
377 @cindex quarter tones
378 @cindex semi-flats
379 @cindex semi-sharps
380
381 Quarter tones may be added; the following is a series of Cs with
382 increasing pitches:
383
384 @lilypond[verbatim,quote,relative=2]
385 ceseh1 ces ceh c cih cis cisih
386 @end lilypond
387
388
389
390 @cindex accidental, reminder
391 @cindex accidental, cautionary
392 @cindex accidental, parenthesized
393 @cindex reminder accidental
394 @cindex cautionary accidental
395 @cindex parenthesized accidental
396
397 @funindex ?
398 @funindex !
399
400
401 Normally accidentals are printed automatically, but you may also
402 print them manually.  A reminder accidental can be forced by
403 adding an exclamation mark@tie{}@code{!} after the pitch.  A
404 cautionary accidental (i.e., an accidental within parentheses) can
405 be obtained by adding the question mark@tie{}@code{?} after the
406 pitch.
407
408 @lilypond[verbatim,quote,relative=2]
409 cis cis cis! cis? c c c! c?
410 @end lilypond
411
412 @cindex accidental on tied note
413 @cindex tied note, accidental
414
415 Accidentals on tied notes are only printed at the beginning of a
416 new system:
417
418 @lilypond[verbatim,quote,relative=2,ragged-right]
419 cis1~ 1~
420 \break
421 cis
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,relative=2]
562 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, but the previous note is not changed.  Future notes are
670 relative to the @code{@var{controlpitch}}.
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,relative=1,ragged-right]
1122 c2 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,relative=1]
1130 \clef treble
1131 c2 c
1132 \clef alto
1133 c2 c
1134 \clef tenor
1135 c2 c
1136 \clef bass
1137 c2 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,relative=1]
1167 \clef treble
1168 c2 c
1169 \clef "treble_8"
1170 c2 c
1171 \clef "bass^15"
1172 c2 c
1173 \clef "alto_2"
1174 c2 c
1175 \clef "G_8"
1176 c2 c
1177 \clef "F^5"
1178 c2 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,relative=1]
1185 \clef "treble_(8)"
1186 c2 c
1187 \clef "bass^[15]"
1188 c2 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,relative=1]
1200 \clef treble { c2 c } \break
1201 \clef bass { c2 c } \break
1202 \clef alto
1203   \set Staff.explicitClefVisibility = #end-of-line-invisible
1204   { c2 c } \break
1205   \unset Staff.explicitClefVisibility
1206 \clef bass { c2 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,relative=1]
1215   \clef treble
1216   c1
1217   \clef treble
1218   c1
1219   \set Staff.forceClef = ##t
1220   c1
1221   \clef treble
1222   c1
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,relative=1]
1229   \clef "treble"
1230   c1
1231   \clef "bass"
1232   c1
1233   \clef "treble"
1234   c1
1235   \override Staff.Clef.full-size-change = ##t
1236   \clef "bass"
1237   c1
1238   \clef "treble"
1239   c1
1240   \revert Staff.Clef.full-size-change
1241   \clef "bass"
1242   c1
1243   \clef "treble"
1244   c1
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,relative=1]
1278 \new Staff \with {
1279   \override Clef.color = #blue
1280   \override ClefModifier.color = #red
1281 }
1282
1283 \clef "treble_8" c4
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,relative=2]
1351 \key g \major
1352 fis1
1353 f
1354 fis
1355 @end lilypond
1356
1357 Additional modes can be defined, by listing the alterations
1358 for each scale step when the mode starts on C.
1359
1360 @lilypond[verbatim,quote]
1361 freygish = #`((0 . ,NATURAL) (1 . ,FLAT) (2 . ,NATURAL)
1362     (3 . ,NATURAL) (4 . ,NATURAL) (5 . ,FLAT) (6 . ,FLAT))
1363
1364 \relative {
1365   \key c \freygish c'4 des e f
1366   \bar "||" \key d \freygish d es fis g
1367 }
1368 @end lilypond
1369
1370 Accidentals in the key signature may be printed in octaves other
1371 than their traditional positions, or in multiple octaves, by
1372 using the @code{flat-positions} and @code{sharp-positions}
1373 properties of @code{KeySignature}.  Entries in these properties
1374 specify the range of staff-positions where accidentals will be
1375 printed.  If a single position is specified in an entry, the
1376 accidentals are placed within the octave ending at that staff
1377 position.
1378
1379 @lilypond[verbatim, quote,relative=0]
1380 \override Staff.KeySignature.flat-positions = #'((-5 . 5))
1381 \override Staff.KeyCancellation.flat-positions = #'((-5 . 5))
1382 \clef bass \key es \major es g bes d
1383 \clef treble \bar "||" \key es \major es g bes d
1384
1385 \override Staff.KeySignature.sharp-positions = #'(2)
1386 \bar "||" \key b \major b fis b2
1387 @end lilypond
1388
1389 @snippets
1390
1391 @lilypondfile[verbatim,quote,texidoc,doctitle]
1392 {preventing-natural-signs-from-being-printed-when-the-key-signature-changes.ly}
1393
1394 @lilypondfile[verbatim,quote,texidoc,doctitle]
1395 {non-traditional-key-signatures.ly}
1396
1397
1398 @seealso
1399 Music Glossary:
1400 @rglos{church mode},
1401 @rglos{scordatura}.
1402
1403 Learning Manual:
1404 @rlearning{Pitches and key signatures}.
1405
1406 Snippets:
1407 @rlsr{Pitches}.
1408
1409 Internals Reference:
1410 @rinternals{KeyChangeEvent},
1411 @rinternals{Key_engraver},
1412 @rinternals{Key_performer},
1413 @rinternals{KeyCancellation},
1414 @rinternals{KeySignature},
1415 @rinternals{key-signature-interface}.
1416
1417
1418 @node Ottava brackets
1419 @unnumberedsubsubsec Ottava brackets
1420
1421 @cindex ottava
1422 @cindex 15ma
1423 @cindex 8va
1424 @cindex 8ve
1425 @cindex octavation
1426
1427 @funindex set-octavation
1428 @funindex \ottava
1429 @funindex ottava
1430
1431 @notation{Ottava brackets} introduce an extra transposition of an
1432 octave for the staff:
1433
1434 @lilypond[verbatim,quote,relative=2]
1435 a2 b
1436 \ottava #-2
1437 a2 b
1438 \ottava #-1
1439 a2 b
1440 \ottava #0
1441 a2 b
1442 \ottava #1
1443 a2 b
1444 \ottava #2
1445 a2 b
1446 @end lilypond
1447
1448 @snippets
1449
1450 @lilypondfile[verbatim,quote,texidoc,doctitle]
1451 {ottava-text.ly}
1452
1453 @lilypondfile[verbatim,quote,texidoc,doctitle]
1454 {adding-an-ottava-marking-to-a-single-voice.ly}
1455
1456 @lilypondfile[verbatim,quote,texidoc,doctitle]
1457 {modifying-the-ottava-spanner-slope.ly}
1458
1459 @seealso
1460 Music Glossary:
1461 @rglos{octavation}.
1462
1463 Snippets:
1464 @rlsr{Pitches}.
1465
1466 Internals Reference:
1467 @rinternals{Ottava_spanner_engraver},
1468 @rinternals{OttavaBracket},
1469 @rinternals{ottava-bracket-interface}.
1470
1471
1472 @node Instrument transpositions
1473 @unnumberedsubsubsec Instrument transpositions
1474
1475 @cindex transposition, MIDI
1476 @cindex transposition, instrument
1477 @cindex transposing instrument
1478 @cindex MIDI
1479 @cindex MIDI transposition
1480
1481 @funindex \transposition
1482 @funindex transposition
1483
1484 When typesetting scores that involve transposing instruments, some
1485 parts can be typeset in a different pitch than the
1486 @notation{concert pitch}.  In these cases, the key of the
1487 @notation{transposing instrument} should be specified; otherwise
1488 the MIDI output and cues in other parts will produce incorrect
1489 pitches.  For more information about quotations, see
1490 @ref{Quoting other voices}.
1491
1492 @example
1493 \transposition @var{pitch}
1494 @end example
1495
1496 The pitch to use for @code{\transposition} should correspond to
1497 the real sound heard when a@tie{}@code{c'} written on the staff is
1498 played by the transposing instrument.  This pitch is entered in
1499 absolute mode, so an instrument that produces a real sound which
1500 is one tone higher than the printed music should use
1501 @w{@code{\transposition d'}}.  @code{\transposition} should
1502 @emph{only} be used if the pitches are @emph{not} being entered in
1503 concert pitch.
1504
1505 Here are a few notes for violin and B-flat clarinet where the
1506 parts have been entered using the notes and key as they appear in
1507 each part of the conductor's score.  The two instruments are
1508 playing in unison.
1509
1510 @lilypond[verbatim,quote]
1511 \new GrandStaff <<
1512   \new Staff = "violin" {
1513     \relative c'' {
1514       \set Staff.instrumentName = #"Vln"
1515       \set Staff.midiInstrument = #"violin"
1516       % not strictly necessary, but a good reminder
1517       \transposition c'
1518
1519       \key c \major
1520       g4( c8) r c r c4
1521     }
1522   }
1523   \new Staff = "clarinet" {
1524     \relative c'' {
1525       \set Staff.instrumentName = \markup { Cl (B\flat) }
1526       \set Staff.midiInstrument = #"clarinet"
1527       \transposition bes
1528
1529       \key d \major
1530       a4( d8) r d r d4
1531     }
1532   }
1533 >>
1534 @end lilypond
1535
1536 The @code{\transposition} may be changed during a piece.  For
1537 example, a clarinetist may be required to switch from an A clarinet
1538 to a B-flat clarinet.
1539
1540 @lilypond[verbatim,quote]
1541 flute = \relative c'' {
1542   \key f \major
1543   \cueDuring #"clarinet" #DOWN {
1544     R1 _\markup\tiny "clarinet"
1545     c4 f e d
1546     R1 _\markup\tiny "clarinet"
1547   }
1548 }
1549 clarinet = \relative c'' {
1550   \key aes \major
1551   \transposition a
1552   aes4 bes c des
1553   R1^\markup { muta in B\flat }
1554   \key g \major
1555   \transposition bes
1556   d2 g,
1557 }
1558 \addQuote "clarinet" \clarinet
1559 <<
1560   \new Staff \with { instrumentName = #"Flute" }
1561     \flute
1562   \new Staff \with { instrumentName = #"Cl (A)" }
1563     \clarinet
1564 >>
1565 @end lilypond
1566
1567 @seealso
1568 Music Glossary:
1569 @rglos{concert pitch},
1570 @rglos{transposing instrument}.
1571
1572 Notation Reference:
1573 @ref{Quoting other voices},
1574 @ref{Transpose}.
1575
1576 Snippets:
1577 @rlsr{Pitches}.
1578
1579
1580 @node Automatic accidentals
1581 @unnumberedsubsubsec Automatic accidentals
1582
1583 @cindex accidental style
1584 @cindex accidental style, default
1585 @cindex accidentals
1586 @cindex accidentals, automatic
1587 @cindex automatic accidentals
1588 @cindex default accidental style
1589
1590 @funindex \accidentalStyle
1591 @funindex voice
1592 @funindex default
1593
1594 There are many different conventions on how to typeset
1595 accidentals.  LilyPond provides a function to specify which
1596 accidental style to use.  This function is called as follows:
1597
1598 @example
1599 \new Staff <<
1600   \accidentalStyle voice
1601   @{ @dots{} @}
1602 >>
1603 @end example
1604
1605 The accidental style applies to the current @code{Staff} by
1606 default (with the exception of the styles @code{piano} and
1607 @code{piano-cautionary}, which are explained below).  Optionally,
1608 the function can take a second argument that determines in which
1609 scope the style should be changed.  For example, to use the same
1610 style in all staves of the current @code{StaffGroup}, use:
1611
1612 @example
1613 \accidentalStyle StaffGroup.voice
1614 @end example
1615
1616 The following accidental styles are supported.  To demonstrate
1617 each style, we use the following example:
1618
1619
1620 @lilypond[verbatim,quote]
1621 musicA = {
1622   <<
1623     \relative {
1624       cis''8 fis, bes4 <a cis>8 f bis4 |
1625       cis2. <c, g'>4 |
1626     }
1627     \\
1628     \relative {
1629       ais'2 cis, |
1630       fis8 b a4 cis2 |
1631     }
1632   >>
1633 }
1634
1635 musicB = {
1636   \clef bass
1637   \new Voice {
1638     \voiceTwo \relative {
1639       <fis a cis>8[ <fis a cis>
1640       \change Staff = up
1641       cis' cis
1642       \change Staff = down
1643       <fis, a> <fis a>]
1644       \showStaffSwitch
1645       \change Staff = up
1646       dis'4 |
1647       \change Staff = down
1648       <fis, a cis>4 gis <f a d>2 |
1649     }
1650   }
1651 }
1652
1653 \new PianoStaff {
1654   <<
1655     \context Staff = "up" {
1656       \accidentalStyle default
1657       \musicA
1658     }
1659     \context Staff = "down" {
1660       \accidentalStyle default
1661       \musicB
1662     }
1663   >>
1664 }
1665 @end lilypond
1666
1667 Note that the last lines of this example can be replaced by the
1668 following, as long as the same accidental style should be used in
1669 both staves.
1670
1671 @example
1672 \new PianoStaff @{
1673   <<
1674     \context Staff = "up" @{
1675       %%% change the next line as desired:
1676       \accidentalStyle Score.default
1677       \musicA
1678     @}
1679     \context Staff = "down" @{
1680       \musicB
1681     @}
1682   >>
1683 @}
1684 @end example
1685
1686
1687 @c don't use verbatim in this table.
1688 @table @code
1689 @item default
1690
1691 @cindex default accidental style
1692 @cindex accidental style, default
1693
1694 @funindex default
1695
1696 This is the default typesetting behavior.  It corresponds to
1697 eighteenth-century common practice: accidentals are remembered to
1698 the end of the measure in which they occur and only in their own
1699 octave.  Thus, in the example below, no natural signs are printed
1700 before the@tie{}@code{b} in the second measure or the
1701 last@tie{}@code{c}:
1702
1703 @lilypond[quote]
1704 musicA = {
1705   <<
1706     \relative {
1707       cis''8 fis, bes4 <a cis>8 f bis4 |
1708       cis2. <c, g'>4 |
1709     }
1710     \\
1711     \relative {
1712       ais'2 cis, |
1713       fis8 b a4 cis2 |
1714     }
1715   >>
1716 }
1717
1718 musicB = {
1719   \clef bass
1720   \new Voice {
1721     \voiceTwo \relative {
1722       <fis a cis>8[ <fis a cis>
1723       \change Staff = up
1724       cis' cis
1725       \change Staff = down
1726       <fis, a> <fis a>]
1727       \showStaffSwitch
1728       \change Staff = up
1729       dis'4 |
1730       \change Staff = down
1731       <fis, a cis>4 gis <f a d>2 |
1732     }
1733   }
1734 }
1735
1736 \new PianoStaff {
1737   <<
1738     \context Staff = "up" {
1739       \accidentalStyle default
1740       \musicA
1741     }
1742     \context Staff = "down" {
1743       \accidentalStyle default
1744       \musicB
1745     }
1746   >>
1747 }
1748 @end lilypond
1749
1750 @item voice
1751
1752 @cindex accidental style, voice
1753 @cindex voice accidental style
1754 @cindex accidental style, modern
1755 @cindex modern accidental style
1756 @cindex accidental style, modern-cautionary
1757 @cindex modern-cautionary accidental style
1758
1759 @funindex voice
1760
1761 The normal behavior is to remember the accidentals at
1762 @code{Staff}-level.  In this style, however, accidentals are
1763 typeset individually for each voice.  Apart from that, the rule is
1764 similar to @code{default}.
1765
1766 As a result, accidentals from one voice do not get canceled in
1767 other voices, which is often an unwanted result: in the following
1768 example, it is hard to determine whether the second@tie{}@code{a}
1769 should be played natural or sharp.  The @code{voice} option should
1770 therefore be used only if the voices are to be read solely by
1771 individual musicians.  If the staff is to be used by one musician
1772 (e.g., a conductor or in a piano score) then @code{modern} or
1773 @code{modern-cautionary} should be used instead.
1774
1775
1776 @lilypond[quote]
1777 musicA = {
1778   <<
1779     \relative {
1780       cis''8 fis, bes4 <a cis>8 f bis4 |
1781       cis2. <c, g'>4 |
1782     }
1783     \\
1784     \relative {
1785       ais'2 cis, |
1786       fis8 b a4 cis2 |
1787     }
1788   >>
1789 }
1790
1791 musicB = {
1792   \clef bass
1793   \new Voice {
1794     \voiceTwo \relative {
1795       <fis a cis>8[ <fis a cis>
1796       \change Staff = up
1797       cis' cis
1798       \change Staff = down
1799       <fis, a> <fis a>]
1800       \showStaffSwitch
1801       \change Staff = up
1802       dis'4 |
1803       \change Staff = down
1804       <fis, a cis>4 gis <f a d>2 |
1805     }
1806   }
1807 }
1808
1809 \new PianoStaff {
1810   <<
1811     \context Staff = "up" {
1812       \accidentalStyle voice
1813       \musicA
1814     }
1815     \context Staff = "down" {
1816       \accidentalStyle voice
1817       \musicB
1818     }
1819   >>
1820 }
1821 @end lilypond
1822
1823 @item modern
1824
1825 @cindex accidentals, modern style
1826 @cindex modern style accidentals
1827
1828 @funindex modern
1829
1830 This rule corresponds to the common practice in the twentieth
1831 century.  It omits some extra natural signs, which were
1832 traditionally prefixed to a sharp following a double sharp,
1833 or a flat following a double flat.  The @code{modern} rule
1834 prints the same accidentals as @code{default}, with
1835 two additions that serve to avoid ambiguity: after temporary
1836 accidentals, cancellation marks are printed also in the following
1837 measure (for notes in the same octave) and, in the same measure,
1838 for notes in other octaves.  Hence the naturals before
1839 the@tie{}@code{b} and the@tie{}@code{c} in the second measure of
1840 the upper staff:
1841
1842 @lilypond[quote]
1843 musicA = {
1844   <<
1845     \relative {
1846       cis''8 fis, bes4 <a cis>8 f bis4 |
1847       cis2. <c, g'>4 |
1848     }
1849     \\
1850     \relative {
1851       ais'2 cis, |
1852       fis8 b a4 cis2 |
1853     }
1854   >>
1855 }
1856
1857 musicB = {
1858   \clef bass
1859   \new Voice {
1860     \voiceTwo \relative {
1861       <fis a cis>8[ <fis a cis>
1862       \change Staff = up
1863       cis' cis
1864       \change Staff = down
1865       <fis, a> <fis a>]
1866       \showStaffSwitch
1867       \change Staff = up
1868       dis'4 |
1869       \change Staff = down
1870       <fis, a cis>4 gis <f a d>2 |
1871     }
1872   }
1873 }
1874
1875 \new PianoStaff {
1876   <<
1877     \context Staff = "up" {
1878       \accidentalStyle modern
1879       \musicA
1880     }
1881     \context Staff = "down" {
1882       \accidentalStyle modern
1883       \musicB
1884     }
1885   >>
1886 }
1887 @end lilypond
1888
1889 @item modern-cautionary
1890
1891 @cindex accidentals, modern cautionary style
1892 @cindex modern accidental style
1893 @cindex modern cautionary accidental style
1894 @cindex modern style accidentals
1895 @cindex modern style cautionary accidentals
1896
1897 @funindex modern-cautionary
1898
1899 This rule is similar to @code{modern}, but the @q{extra}
1900 accidentals (the ones not typeset by @code{default}) are typeset
1901 as cautionary accidentals.  They are by default printed with
1902 parentheses, but they can also be printed in reduced size by
1903 defining the @code{cautionary-style} property of
1904 @code{AccidentalSuggestion}.
1905
1906 @lilypond[quote]
1907 musicA = {
1908   <<
1909     \relative {
1910       cis''8 fis, bes4 <a cis>8 f bis4 |
1911       cis2. <c, g'>4 |
1912     }
1913     \\
1914     \relative {
1915       ais'2 cis, |
1916       fis8 b a4 cis2 |
1917     }
1918   >>
1919 }
1920
1921 musicB = {
1922   \clef bass
1923   \new Voice {
1924     \voiceTwo \relative {
1925       <fis a cis>8[ <fis a cis>
1926       \change Staff = up
1927       cis' cis
1928       \change Staff = down
1929       <fis, a> <fis a>]
1930       \showStaffSwitch
1931       \change Staff = up
1932       dis'4 |
1933       \change Staff = down
1934       <fis, a cis>4 gis <f a d>2 |
1935     }
1936   }
1937 }
1938
1939 \new PianoStaff {
1940   <<
1941     \context Staff = "up" {
1942       \accidentalStyle modern-cautionary
1943       \musicA
1944     }
1945     \context Staff = "down" {
1946       \accidentalStyle modern-cautionary
1947       \musicB
1948     }
1949   >>
1950 }
1951 @end lilypond
1952
1953 @item modern-voice
1954
1955 @cindex accidental style, modern
1956 @cindex accidentals, modern
1957 @cindex accidentals, multivoice
1958 @cindex modern accidental style
1959 @cindex modern accidentals
1960 @cindex multivoice accidentals
1961
1962 @funindex modern-voice
1963
1964 This rule is used for multivoice accidentals to be read both by
1965 musicians playing one voice and musicians playing all voices.
1966 Accidentals are typeset for each voice, but they @emph{are}
1967 canceled across voices in the same @code{Staff}.  Hence,
1968 the@tie{}@code{a} in the last measure is canceled because the
1969 previous cancellation was in a different voice, and
1970 the@tie{}@code{d} in the lower staff is canceled because of the
1971 accidental in a different voice in the previous measure:
1972
1973 @lilypond[quote]
1974 musicA = {
1975   <<
1976     \relative {
1977       cis''8 fis, bes4 <a cis>8 f bis4 |
1978       cis2. <c, g'>4 |
1979     }
1980     \\
1981     \relative {
1982       ais'2 cis, |
1983       fis8 b a4 cis2 |
1984     }
1985   >>
1986 }
1987
1988 musicB = {
1989   \clef bass
1990   \new Voice {
1991     \voiceTwo \relative {
1992       <fis a cis>8[ <fis a cis>
1993       \change Staff = up
1994       cis' cis
1995       \change Staff = down
1996       <fis, a> <fis a>]
1997       \showStaffSwitch
1998       \change Staff = up
1999       dis'4 |
2000       \change Staff = down
2001       <fis, a cis>4 gis <f a d>2 |
2002     }
2003   }
2004 }
2005
2006 \new PianoStaff {
2007   <<
2008     \context Staff = "up" {
2009       \accidentalStyle modern-voice
2010       \musicA
2011     }
2012     \context Staff = "down" {
2013       \accidentalStyle modern-voice
2014       \musicB
2015     }
2016   >>
2017 }
2018 @end lilypond
2019
2020 @cindex accidental style, cautionary, modern voice
2021 @cindex accidental style, modern voice cautionary
2022 @cindex accidental style, voice, modern cautionary
2023
2024 @funindex modern-voice-cautionary
2025
2026 @item modern-voice-cautionary
2027
2028 This rule is the same as @code{modern-voice}, but with the extra
2029 accidentals (the ones not typeset by @code{voice}) typeset as
2030 cautionaries.  Even though all accidentals typeset by
2031 @code{default} @emph{are} typeset with this rule, some of them are
2032 typeset as cautionaries.
2033
2034 @lilypond[quote]
2035 musicA = {
2036   <<
2037     \relative {
2038       cis''8 fis, bes4 <a cis>8 f bis4 |
2039       cis2. <c, g'>4 |
2040     }
2041     \\
2042     \relative {
2043       ais'2 cis, |
2044       fis8 b a4 cis2 |
2045     }
2046   >>
2047 }
2048
2049 musicB = {
2050   \clef bass
2051   \new Voice {
2052     \voiceTwo \relative {
2053       <fis a cis>8[ <fis a cis>
2054       \change Staff = up
2055       cis' cis
2056       \change Staff = down
2057       <fis, a> <fis a>]
2058       \showStaffSwitch
2059       \change Staff = up
2060       dis'4 |
2061       \change Staff = down
2062       <fis, a cis>4 gis <f a d>2 |
2063     }
2064   }
2065 }
2066
2067 \new PianoStaff {
2068   <<
2069     \context Staff = "up" {
2070       \accidentalStyle modern-voice-cautionary
2071       \musicA
2072     }
2073     \context Staff = "down" {
2074       \accidentalStyle modern-voice-cautionary
2075       \musicB
2076     }
2077   >>
2078 }
2079 @end lilypond
2080
2081 @item piano
2082
2083 @cindex accidental style, piano
2084 @cindex accidentals, piano
2085 @cindex piano accidental style
2086 @cindex piano accidentals
2087
2088 @funindex piano
2089
2090 This rule reflects twentieth-century practice for piano notation.
2091 Its behavior is very similar to @code{modern} style, but here
2092 accidentals also get canceled across the staves in the same
2093 @code{GrandStaff} or @code{PianoStaff}, hence all the
2094 cancellations of the final notes.
2095
2096 This accidental style applies to the current @code{GrandStaff} or
2097 @code{PianoStaff} by default.
2098
2099 @lilypond[quote]
2100 musicA = {
2101   <<
2102     \relative {
2103       cis''8 fis, bes4 <a cis>8 f bis4 |
2104       cis2. <c, g'>4 |
2105     }
2106     \\
2107     \relative {
2108       ais'2 cis, |
2109       fis8 b a4 cis2 |
2110     }
2111   >>
2112 }
2113
2114 musicB = {
2115   \clef bass
2116   \new Voice {
2117     \voiceTwo \relative {
2118       <fis a cis>8[ <fis a cis>
2119       \change Staff = up
2120       cis' cis
2121       \change Staff = down
2122       <fis, a> <fis a>]
2123       \showStaffSwitch
2124       \change Staff = up
2125       dis'4 |
2126       \change Staff = down
2127       <fis, a cis>4 gis <f a d>2 |
2128     }
2129   }
2130 }
2131
2132 \new PianoStaff {
2133   <<
2134     \context Staff = "up" {
2135       \accidentalStyle piano
2136       \musicA
2137     }
2138     \context Staff = "down" {
2139       \musicB
2140     }
2141   >>
2142 }
2143 @end lilypond
2144
2145 @item piano-cautionary
2146
2147 @cindex accidentals, piano cautionary
2148 @cindex cautionary accidentals, piano
2149 @cindex piano cautionary accidentals
2150 @cindex accidental style, piano cautionary
2151 @cindex cautionary accidental style, piano
2152 @cindex piano cautionary accidental style
2153
2154 @funindex piano-cautionary
2155
2156 This is the same as @code{piano} but with the extra accidentals
2157 typeset as cautionaries.
2158
2159 @lilypond[quote]
2160 musicA = {
2161   <<
2162     \relative {
2163       cis''8 fis, bes4 <a cis>8 f bis4 |
2164       cis2. <c, g'>4 |
2165     }
2166     \\
2167     \relative {
2168       ais'2 cis, |
2169       fis8 b a4 cis2 |
2170     }
2171   >>
2172 }
2173
2174 musicB = {
2175   \clef bass
2176   \new Voice {
2177     \voiceTwo \relative {
2178       <fis a cis>8[ <fis a cis>
2179       \change Staff = up
2180       cis' cis
2181       \change Staff = down
2182       <fis, a> <fis a>]
2183       \showStaffSwitch
2184       \change Staff = up
2185       dis'4 |
2186       \change Staff = down
2187       <fis, a cis>4 gis <f a d>2 |
2188     }
2189   }
2190 }
2191
2192 \new PianoStaff {
2193   <<
2194     \context Staff = "up" {
2195       \accidentalStyle piano-cautionary
2196       \musicA
2197     }
2198     \context Staff = "down" {
2199       \musicB
2200     }
2201   >>
2202 }
2203 @end lilypond
2204
2205
2206 @item neo-modern
2207
2208 @cindex neo-modern accidental style
2209 @cindex accidental style, neo-modern
2210
2211 @funindex neo-modern
2212
2213 This rule reproduces a common practice in contemporary music:
2214 accidentals are printed like with @code{modern}, but they are printed
2215 again if the same note appears later in the same measure -- except
2216 if the note is immediately repeated.
2217
2218 @lilypond[quote]
2219 musicA = {
2220   <<
2221     \relative {
2222       cis''8 fis, bes4 <a cis>8 f bis4 |
2223       cis2. <c, g'>4 |
2224     }
2225     \\
2226     \relative {
2227       ais'2 cis, |
2228       fis8 b a4 cis2 |
2229     }
2230   >>
2231 }
2232
2233 musicB = {
2234   \clef bass
2235   \new Voice {
2236     \voiceTwo \relative {
2237       <fis a cis>8[ <fis a cis>
2238       \change Staff = up
2239       cis' cis
2240       \change Staff = down
2241       <fis, a> <fis a>]
2242       \showStaffSwitch
2243       \change Staff = up
2244       dis'4 |
2245       \change Staff = down
2246       <fis, a cis>4 gis <f a d>2 |
2247     }
2248   }
2249 }
2250
2251 \new PianoStaff {
2252   <<
2253     \context Staff = "up" {
2254       \accidentalStyle neo-modern
2255       \musicA
2256     }
2257     \context Staff = "down" {
2258       \accidentalStyle neo-modern
2259       \musicB
2260     }
2261   >>
2262 }
2263 @end lilypond
2264
2265 @item neo-modern-cautionary
2266
2267 @cindex neo-modern-cautionary accidental style
2268 @cindex accidental style, neo-modern-cautionary
2269
2270 @funindex neo-modern-cautionary
2271
2272 This rule is similar to @code{neo-modern}, but the extra
2273 accidentals are printed as cautionary accidentals.
2274
2275 @lilypond[quote]
2276 musicA = {
2277   <<
2278     \relative {
2279       cis''8 fis, bes4 <a cis>8 f bis4 |
2280       cis2. <c, g'>4 |
2281     }
2282     \\
2283     \relative {
2284       ais'2 cis, |
2285       fis8 b a4 cis2 |
2286     }
2287   >>
2288 }
2289
2290 musicB = {
2291   \clef bass
2292   \new Voice {
2293     \voiceTwo \relative {
2294       <fis a cis>8[ <fis a cis>
2295       \change Staff = up
2296       cis' cis
2297       \change Staff = down
2298       <fis, a> <fis a>]
2299       \showStaffSwitch
2300       \change Staff = up
2301       dis'4 |
2302       \change Staff = down
2303       <fis, a cis>4 gis <f a d>2 |
2304     }
2305   }
2306 }
2307
2308 \new PianoStaff {
2309   <<
2310     \context Staff = "up" {
2311       \accidentalStyle neo-modern-cautionary
2312       \musicA
2313     }
2314     \context Staff = "down" {
2315       \accidentalStyle neo-modern-cautionary
2316       \musicB
2317     }
2318   >>
2319 }
2320 @end lilypond
2321
2322
2323 @item neo-modern-voice
2324
2325 @cindex neo-modern-voice accidental style
2326 @cindex accidental style, neo-modern-voice
2327
2328 @funindex neo-modern-voice
2329
2330 This rule is used for multivoice accidentals to be read both by
2331 musicians playing one voice and musicians playing all voices.
2332 Accidentals are typeset for each voice as with @code{neo-modern},
2333 but they are canceled across voices in the same @code{Staff}.
2334
2335 @lilypond[quote]
2336 musicA = {
2337   <<
2338     \relative {
2339       cis''8 fis, bes4 <a cis>8 f bis4 |
2340       cis2. <c, g'>4 |
2341     }
2342     \\
2343     \relative {
2344       ais'2 cis, |
2345       fis8 b a4 cis2 |
2346     }
2347   >>
2348 }
2349
2350 musicB = {
2351   \clef bass
2352   \new Voice {
2353     \voiceTwo \relative {
2354       <fis a cis>8[ <fis a cis>
2355       \change Staff = up
2356       cis' cis
2357       \change Staff = down
2358       <fis, a> <fis a>]
2359       \showStaffSwitch
2360       \change Staff = up
2361       dis'4 |
2362       \change Staff = down
2363       <fis, a cis>4 gis <f a d>2 |
2364     }
2365   }
2366 }
2367
2368 \new PianoStaff {
2369   <<
2370     \context Staff = "up" {
2371       \accidentalStyle neo-modern-voice
2372       \musicA
2373     }
2374     \context Staff = "down" {
2375       \accidentalStyle neo-modern-voice
2376       \musicB
2377     }
2378   >>
2379 }
2380 @end lilypond
2381
2382 @item neo-modern-voice-cautionary
2383
2384 @cindex neo-modern-voice-cautionary accidental style
2385 @cindex accidental style, neo-modern-voice-cautionary
2386
2387 @funindex neo-modern-voice-cautionary
2388
2389 This rule is similar to @code{neo-modern-voice}, but the extra
2390 accidentals are printed as cautionary accidentals.
2391
2392 @lilypond[quote]
2393 musicA = {
2394   <<
2395     \relative {
2396       cis''8 fis, bes4 <a cis>8 f bis4 |
2397       cis2. <c, g'>4 |
2398     }
2399     \\
2400     \relative {
2401       ais'2 cis, |
2402       fis8 b a4 cis2 |
2403     }
2404   >>
2405 }
2406
2407 musicB = {
2408   \clef bass
2409   \new Voice {
2410     \voiceTwo \relative {
2411       <fis a cis>8[ <fis a cis>
2412       \change Staff = up
2413       cis' cis
2414       \change Staff = down
2415       <fis, a> <fis a>]
2416       \showStaffSwitch
2417       \change Staff = up
2418       dis'4 |
2419       \change Staff = down
2420       <fis, a cis>4 gis <f a d>2 |
2421     }
2422   }
2423 }
2424
2425 \new PianoStaff {
2426   <<
2427     \context Staff = "up" {
2428       \accidentalStyle neo-modern-voice-cautionary
2429       \musicA
2430     }
2431     \context Staff = "down" {
2432       \accidentalStyle neo-modern-voice-cautionary
2433       \musicB
2434     }
2435   >>
2436 }
2437 @end lilypond
2438
2439 @item dodecaphonic
2440
2441 @cindex dodecaphonic accidental style
2442 @cindex dodecaphonic style, neo-modern
2443
2444 @funindex dodecaphonic
2445
2446 This rule reflects a practice introduced by composers at
2447 the beginning of the 20th century, in an attempt to
2448 abolish the hierarchy between natural and non-natural notes.
2449 With this style, @emph{every} note gets an accidental sign,
2450 including natural signs.
2451
2452 @lilypond[quote]
2453 musicA = {
2454   <<
2455     \relative {
2456       cis''8 fis, bes4 <a cis>8 f bis4 |
2457       cis2. <c, g'>4 |
2458     }
2459     \\
2460     \relative {
2461       ais'2 cis, |
2462       fis8 b a4 cis2 |
2463     }
2464   >>
2465 }
2466
2467 musicB = {
2468   \clef bass
2469   \new Voice {
2470     \voiceTwo \relative {
2471       <fis a cis>8[ <fis a cis>
2472       \change Staff = up
2473       cis' cis
2474       \change Staff = down
2475       <fis, a> <fis a>]
2476       \showStaffSwitch
2477       \change Staff = up
2478       dis'4 |
2479       \change Staff = down
2480       <fis, a cis>4 gis <f a d>2 |
2481     }
2482   }
2483 }
2484
2485 \new PianoStaff {
2486   <<
2487     \context Staff = "up" {
2488       \accidentalStyle dodecaphonic
2489       \musicA
2490     }
2491     \context Staff = "down" {
2492       \accidentalStyle dodecaphonic
2493       \musicB
2494     }
2495   >>
2496 }
2497 @end lilypond
2498
2499 @item dodecaphonic-no-repeat
2500
2501 @cindex dodecaphonic accidental style
2502 @cindex dodecaphonic style, neo-modern
2503
2504 @funindex dodecaphonic-no-repeat
2505
2506 Like with the dodecaphonic accidental style @emph{every} note
2507 gets an accidental sign by default, but accidentals are
2508 suppressed for pitches immediately repeated within the same staff.
2509
2510 @lilypond[quote]
2511 musicA = {
2512   <<
2513     \relative {
2514       cis''8 fis, bes4 <a cis>8 f bis4 |
2515       cis2. <c, g'>4 |
2516     }
2517     \\
2518     \relative {
2519       ais'2 cis, |
2520       fis8 b a4 cis2 |
2521     }
2522   >>
2523 }
2524
2525 musicB = {
2526   \clef bass
2527   \new Voice {
2528     \voiceTwo \relative {
2529       <fis a cis>8[ <fis a cis>
2530       \change Staff = up
2531       cis' cis
2532       \change Staff = down
2533       <fis, a> <fis a>]
2534       \showStaffSwitch
2535       \change Staff = up
2536       dis'4 |
2537       \change Staff = down
2538       <fis, a cis>4 gis <f a d>2 |
2539     }
2540   }
2541 }
2542
2543 \new PianoStaff {
2544   <<
2545     \context Staff = "up" {
2546       \accidentalStyle dodecaphonic-no-repeat
2547       \musicA
2548     }
2549     \context Staff = "down" {
2550       \accidentalStyle dodecaphonic-no-repeat
2551       \musicB
2552     }
2553   >>
2554 }
2555 @end lilypond
2556
2557
2558 @item dodecaphonic-first
2559
2560 @cindex dodecaphonic accidental style
2561 @cindex dodecaphonic style, neo-modern
2562
2563 @funindex dodecaphonic-first
2564
2565 Similar to the dodecaphonic accidental style @emph{every} pitch
2566 gets an accidental sign, but only the first time it is encountered
2567 in a measure.  Accidentals are only remembered for the actual octave
2568 but throughout voices.
2569
2570 @lilypond[quote]
2571 musicA = {
2572   <<
2573     \relative {
2574       cis''8 fis, bes4 <a cis>8 f bis4 |
2575       cis2. <c, g'>4 |
2576     }
2577     \\
2578     \relative {
2579       ais'2 cis, |
2580       fis8 b a4 cis2 |
2581     }
2582   >>
2583 }
2584
2585 musicB = {
2586   \clef bass
2587   \new Voice {
2588     \voiceTwo \relative {
2589       <fis a cis>8[ <fis a cis>
2590       \change Staff = up
2591       cis' cis
2592       \change Staff = down
2593       <fis, a> <fis a>]
2594       \showStaffSwitch
2595       \change Staff = up
2596       dis'4 |
2597       \change Staff = down
2598       <fis, a cis>4 gis <f a d>2 |
2599     }
2600   }
2601 }
2602
2603 \new PianoStaff {
2604   <<
2605     \context Staff = "up" {
2606       \accidentalStyle dodecaphonic-first
2607       \musicA
2608     }
2609     \context Staff = "down" {
2610       \accidentalStyle dodecaphonic-first
2611       \musicB
2612     }
2613   >>
2614 }
2615 @end lilypond
2616
2617
2618 @item teaching
2619
2620 @cindex teaching accidental style
2621 @cindex accidental style, teaching
2622
2623 @funindex teaching
2624
2625 This rule is intended for students, and makes it easy to create
2626 scale sheets with automatically created cautionary accidentals.
2627 Accidentals are printed like with @code{modern}, but cautionary
2628 accidentals are added for all sharp or flat tones specified by the
2629 key signature, except if the note is immediately repeated.
2630
2631 @lilypond[quote,staffsize=18]
2632 musicA = {
2633   <<
2634     \relative {
2635       cis''8 fis, bes4 <a cis>8 f bis4 |
2636       cis2. <c, g'>4 |
2637     }
2638     \\
2639     \relative {
2640       ais'2 cis, |
2641       fis8 b a4 cis2 |
2642     }
2643   >>
2644 }
2645
2646 musicB = {
2647   \clef bass
2648   \new Voice {
2649     \voiceTwo \relative {
2650       <fis a cis>8[ <fis a cis>
2651       \change Staff = up
2652       cis' cis
2653       \change Staff = down
2654       <fis, a> <fis a>]
2655       \showStaffSwitch
2656       \change Staff = up
2657       dis'4 |
2658       \change Staff = down
2659       <fis, a cis>4 gis <f a d>2 |
2660     }
2661   }
2662 }
2663
2664 \new PianoStaff {
2665   <<
2666     \context Staff = "up" {
2667       \key fis \minor
2668       \accidentalStyle teaching
2669       \musicA
2670     }
2671     \context Staff = "down" {
2672       \key fis \minor
2673       \accidentalStyle teaching
2674       \musicB
2675     }
2676   >>
2677 }
2678 @end lilypond
2679
2680
2681
2682 @item no-reset
2683
2684 @cindex accidental style, no reset
2685 @cindex no reset accidental style
2686
2687 @funindex no-reset
2688
2689 This is the same as @code{default} but with accidentals lasting
2690 @q{forever} and not only within the same measure:
2691
2692 @lilypond[quote]
2693 musicA = {
2694   <<
2695     \relative {
2696       cis''8 fis, bes4 <a cis>8 f bis4 |
2697       cis2. <c, g'>4 |
2698     }
2699     \\
2700     \relative {
2701       ais'2 cis, |
2702       fis8 b a4 cis2 |
2703     }
2704   >>
2705 }
2706
2707 musicB = {
2708   \clef bass
2709   \new Voice {
2710     \voiceTwo \relative {
2711       <fis a cis>8[ <fis a cis>
2712       \change Staff = up
2713       cis' cis
2714       \change Staff = down
2715       <fis, a> <fis a>]
2716       \showStaffSwitch
2717       \change Staff = up
2718       dis'4 |
2719       \change Staff = down
2720       <fis, a cis>4 gis <f a d>2 |
2721     }
2722   }
2723 }
2724
2725 \new PianoStaff {
2726   <<
2727     \context Staff = "up" {
2728       \accidentalStyle no-reset
2729       \musicA
2730     }
2731     \context Staff = "down" {
2732       \accidentalStyle no-reset
2733       \musicB
2734     }
2735   >>
2736 }
2737 @end lilypond
2738
2739 @item forget
2740
2741 @cindex forget accidental style
2742 @cindex accidental style, forget
2743
2744 @funindex forget
2745
2746 This is the opposite of @code{no-reset}: Accidentals are not
2747 remembered at all -- and hence all accidentals are typeset
2748 relative to the key signature, regardless of what came before in
2749 the music.
2750
2751 @lilypond[quote]
2752 musicA = {
2753   <<
2754     \relative {
2755       cis''8 fis, bes4 <a cis>8 f bis4 |
2756       cis2. <c, g'>4 |
2757     }
2758     \\
2759     \relative {
2760       ais'2 cis, |
2761       fis8 b a4 cis2 |
2762     }
2763   >>
2764 }
2765
2766 musicB = {
2767   \clef bass
2768   \new Voice {
2769     \voiceTwo \relative {
2770       <fis a cis>8[ <fis a cis>
2771       \change Staff = up
2772       cis' cis
2773       \change Staff = down
2774       <fis, a> <fis a>]
2775       \showStaffSwitch
2776       \change Staff = up
2777       dis'4 |
2778       \change Staff = down
2779       <fis, a cis>4 gis <f a d>2 |
2780     }
2781   }
2782 }
2783
2784 \new PianoStaff {
2785   <<
2786     \context Staff = "up" {
2787       \accidentalStyle forget
2788       \musicA
2789     }
2790     \context Staff = "down" {
2791       \accidentalStyle forget
2792       \musicB
2793     }
2794   >>
2795 }
2796 @end lilypond
2797 @end table
2798
2799 @seealso
2800 Snippets:
2801 @rlsr{Pitches}.
2802
2803 Internals Reference:
2804 @rinternals{Accidental},
2805 @rinternals{Accidental_engraver},
2806 @rinternals{GrandStaff},
2807 @rinternals{PianoStaff},
2808 @rinternals{Staff},
2809 @rinternals{AccidentalSuggestion},
2810 @rinternals{AccidentalPlacement},
2811 @rinternals{accidental-suggestion-interface}.
2812
2813 @cindex accidentals and simultaneous notes
2814 @cindex simultaneous notes and accidentals
2815 @cindex accidentals in chords
2816 @cindex chords, accidentals in
2817
2818 @knownissues
2819 Simultaneous notes are not considered in the automatic
2820 determination of accidentals; only previous notes and the key
2821 signature are considered.  Forcing accidentals with@tie{}@code{!}
2822 or@tie{}@code{?} may be required when the same note name occurs
2823 simultaneously with different alterations, as in @samp{<f! fis!>}.
2824
2825 Cautionary cancellation of accidentals is done by looking at previous measure.
2826 However, in the @code{\alternative} block following a @code{\repeat volta N}
2827 section, one would expect the cancellation being calculated using the previous
2828 @emph{played} measure, not previous @emph{printed} measure.
2829 In the following example, the natural @code{c} in the second alternative does
2830 not need a natural sign:
2831
2832 @lilypond[quote]
2833 {
2834   \accidentalStyle modern
2835   \time 2/4
2836   \repeat volta 2 {
2837     c'2
2838   }
2839   \alternative {
2840      cis'
2841      c'
2842   }
2843 }
2844 @end lilypond
2845
2846 The following work-around can be used: define a function that locally changes
2847 the accidental style to @code{forget}:
2848
2849 @lilypond[verbatim,quote]
2850 forget = #(define-music-function (parser location music) (ly:music?) #{
2851   \accidentalStyle forget
2852   #music
2853   \accidentalStyle modern
2854 #})
2855 {
2856   \accidentalStyle modern
2857   \time 2/4
2858   \repeat volta 2 {
2859     c'2
2860   }
2861   \alternative {
2862      cis'
2863      \forget c'
2864   }
2865 }
2866 @end lilypond
2867
2868
2869 @node Ambitus
2870 @unnumberedsubsubsec Ambitus
2871
2872 @cindex ambitus
2873 @cindex range of pitches
2874 @cindex pitch range
2875
2876 The term @notation{ambitus} (pl. ambitus) denotes a range of
2877 pitches for a given voice in a part of music.  It may also denote
2878 the pitch range that a musical instrument is capable of playing.
2879 Ambitus are printed on vocal parts so that performers can easily
2880 determine if it matches their capabilities.
2881
2882 Ambitus are denoted at the beginning of a piece near the initial
2883 clef.  The range is graphically specified by two note heads that
2884 represent the lowest and highest pitches.  Accidentals are only
2885 printed if they are not part of the key signature.
2886
2887 @lilypond[verbatim,quote]
2888 \layout {
2889   \context {
2890     \Voice
2891     \consists "Ambitus_engraver"
2892   }
2893 }
2894
2895 \relative {
2896   aes' c e2
2897   cis,1
2898 }
2899 @end lilypond
2900
2901
2902 @snippets
2903
2904 @lilypondfile[verbatim,quote,texidoc,doctitle]
2905 {adding-ambitus-per-voice.ly}
2906
2907 @lilypondfile[verbatim,quote,texidoc,doctitle]
2908 {ambitus-with-multiple-voices.ly}
2909
2910 @lilypondfile[verbatim,quote,texidoc,doctitle]
2911 {changing-the-ambitus-gap.ly}
2912
2913 @seealso
2914 Music Glossary:
2915 @rglos{ambitus}.
2916
2917 Snippets:
2918 @rlsr{Pitches}.
2919
2920 Internals Reference:
2921 @rinternals{Ambitus_engraver},
2922 @rinternals{Voice},
2923 @rinternals{Staff},
2924 @rinternals{Ambitus},
2925 @rinternals{AmbitusAccidental},
2926 @rinternals{AmbitusLine},
2927 @rinternals{AmbitusNoteHead},
2928 @rinternals{ambitus-interface}.
2929
2930 @knownissues
2931 There is no collision handling in the case of multiple per-voice
2932 ambitus.
2933
2934
2935 @node Note heads
2936 @subsection Note heads
2937
2938 This section suggests ways of altering note heads.
2939
2940 @menu
2941 * Special note heads::
2942 * Easy notation note heads::
2943 * Shape note heads::
2944 * Improvisation::
2945 @end menu
2946
2947 @node Special note heads
2948 @unnumberedsubsubsec Special note heads
2949
2950 @cindex note heads, special
2951 @cindex note heads, cross
2952 @cindex note heads, diamond
2953 @cindex note heads, parlato
2954 @cindex note heads, harmonic
2955 @cindex note heads, guitar
2956 @cindex special note heads
2957 @cindex cross note heads
2958 @cindex diamond note heads
2959 @cindex parlato note heads
2960 @cindex harmonic note heads
2961 @cindex guitar note heads
2962 @cindex note head styles
2963 @cindex styles, note heads
2964
2965 @funindex cross
2966
2967 The appearance of note heads may be altered:
2968
2969 @lilypond[verbatim,quote,relative=2]
2970 c4 b
2971 \override NoteHead.style = #'cross
2972 c4 b
2973 \revert NoteHead.style
2974 a b
2975 \override NoteHead.style = #'harmonic
2976 a b
2977 \revert NoteHead.style
2978 c4 d e f
2979 @end lilypond
2980
2981 To see all note head styles, see @ref{Note head styles}.
2982
2983 The @code{cross} style is used to represent a variety of musical
2984 intentions.  The following generic predefined commands modify the
2985 note head in both staff and tablature contexts and can be used to
2986 represent any musical meaning:
2987
2988 @lilypond[verbatim,quote,relative=2]
2989 c4 b
2990 \xNotesOn
2991  a b c4 b
2992 \xNotesOff
2993 c4 d
2994 @end lilypond
2995
2996 The music function form of this predefined command may be used
2997 inside and outside chords to generate crossed note heads in both
2998 staff and tablature contexts:
2999
3000 @lilypond[verbatim,quote,relative=2]
3001 c4 b
3002 \xNote { e f }
3003 c b < g \xNote c f > b
3004 @end lilypond
3005
3006 As synonyms for @code{\xNote}, @code{\xNotesOn} and @code{\xNotesOff},
3007 @code{\deadNote}, @code{\deadNotesOn} and @code{\deadNotesOff} can
3008 be used.  The term @notation{dead note} is commonly used by guitarists.
3009
3010 There is also a similar shorthand for diamond shapes:
3011
3012 @lilypond[verbatim,quote,relative=2]
3013 <c f\harmonic>2 <d a'\harmonic>4 <c g'\harmonic> f\harmonic
3014 @end lilypond
3015
3016 @predefined
3017 @code{\harmonic},
3018 @code{\xNotesOn},
3019 @code{\xNotesOff},
3020 @code{\xNote}.
3021 @endpredefined
3022
3023 @seealso
3024 Snippets:
3025 @rlsr{Pitches}.
3026
3027 Notation Reference:
3028 @ref{Note head styles},
3029 @ref{Chorded notes},
3030 @ref{Indicating harmonics and dampened notes}.
3031
3032 Internals Reference:
3033 @rinternals{note-event},
3034 @rinternals{Note_heads_engraver},
3035 @rinternals{Ledger_line_engraver},
3036 @rinternals{NoteHead},
3037 @rinternals{LedgerLineSpanner},
3038 @rinternals{note-head-interface},
3039 @rinternals{ledger-line-spanner-interface}.
3040
3041
3042 @node Easy notation note heads
3043 @unnumberedsubsubsec Easy notation note heads
3044
3045 @cindex note heads, practice
3046 @cindex practice note heads
3047 @cindex note heads, easy notation
3048 @cindex easy notation
3049 @cindex beginners' music
3050 @cindex music, beginners'
3051 @cindex easy play note heads
3052 @cindex note heads, easy play
3053
3054 @funindex \easyHeadsOn
3055 @funindex easyHeadsOn
3056 @funindex \easyHeadsOff
3057 @funindex easyHeadsOff
3058
3059 The @q{easy play} note head includes a note name inside the head.
3060 It is used in music for beginners.  To make the letters readable,
3061 it should be printed in a large font size.  To print with a larger
3062 font, see @ref{Setting the staff size}.
3063
3064 @lilypond[verbatim,quote]
3065 #(set-global-staff-size 26)
3066 \relative c' {
3067   \easyHeadsOn
3068   c2 e4 f
3069   g1
3070   \easyHeadsOff
3071   c,1
3072 }
3073 @end lilypond
3074
3075
3076 @predefined
3077 @code{\easyHeadsOn},
3078 @code{\easyHeadsOff}.
3079 @endpredefined
3080
3081
3082 @snippets
3083
3084 @lilypondfile[verbatim,quote,texidoc,doctitle]
3085 {numbers-as-easy-note-heads.ly}
3086
3087 @seealso
3088 Notation Reference:
3089 @ref{Setting the staff size}.
3090
3091 Snippets:
3092 @rlsr{Pitches}.
3093
3094 Internals Reference:
3095 @rinternals{note-event},
3096 @rinternals{Note_heads_engraver},
3097 @rinternals{NoteHead},
3098 @rinternals{note-head-interface}.
3099
3100
3101 @node Shape note heads
3102 @unnumberedsubsubsec Shape note heads
3103
3104 @cindex note heads, shape
3105 @cindex note heads, Aiken
3106 @cindex note heads, sacred harp
3107 @cindex shape notes
3108 @cindex Aiken shape note heads
3109 @cindex sacred harp note heads
3110 @cindex note heads, Southern Harmony
3111 @cindex Southern Harmony note heads
3112 @cindex Funk shape note heads
3113 @cindex note heads, Funk
3114 @cindex note heads, Harmonica Sacra
3115 @cindex Harmonica Sacra note heads
3116 @cindex Christian Harmony note heads
3117 @cindex note heads, Christian Harmony
3118 @cindex Walker shape note heads
3119 @cindex note heads, Walker
3120
3121 @funindex \aikenHeads
3122 @funindex aikenHeads
3123 @funindex \sacredHarpHeads
3124 @funindex sacredHarpHeads
3125 @funindex \southernHarmonyHeads
3126 @funindex southernHarmonyHeads
3127 @funindex \funkHeads
3128 @funindex funkHeads
3129 @funindex \walkerHeads
3130 @funindex walkerHeads
3131
3132 In shape note head notation, the shape of the note head
3133 corresponds to the harmonic function of a note in the scale.  This
3134 notation was popular in nineteenth-century American song books.
3135 Shape note heads can be produced in Sacred Harp, Southern Harmony,
3136 Funk (Harmonica Sacra), Walker, and Aiken (Christian Harmony) styles:
3137
3138 @lilypond[verbatim,quote,relative=2]
3139 \aikenHeads
3140 c, d e f g2 a b1 c \break
3141 \sacredHarpHeads
3142 c,4 d e f g2 a b1 c \break
3143 \southernHarmonyHeads
3144 c,4 d e f g2 a b1 c \break
3145 \funkHeads
3146 c,4 d e f g2 a b1 c \break
3147 \walkerHeads
3148 c,4 d e f g2 a b1 c \break
3149 @end lilypond
3150
3151 @funindex \key
3152 @funindex key
3153 @funindex \aikenHeadsMinor
3154 @funindex aikenHeadsMinor
3155 @funindex \sacredHarpHeadsMinor
3156 @funindex sacredHarpHeadsMinor
3157 @funindex \southernHarmonyHeadsMinor
3158 @funindex southernHarmonyHeadsMinor
3159 @funindex \funkHeadsMinor
3160 @funindex funkHeadsMinor
3161 @funindex \walkerHeadsMinor
3162 @funindex walkerHeadsMinor
3163
3164 Shapes are typeset according to the step in the scale, where the base
3165 of the scale is determined by the @code{\key} command.  When writing
3166 in a minor key, the scale step can be determined from the relative
3167 major:
3168
3169 @lilypond[verbatim,quote,relative=2]
3170 \key a \minor
3171 \aikenHeads
3172 a b c d e2 f g1 a \break
3173 \aikenHeadsMinor
3174 a,4 b c d e2 f g1 a \break
3175 \sacredHarpHeadsMinor
3176 a,2 b c d \break
3177 \southernHarmonyHeadsMinor
3178 a2 b c d \break
3179 \funkHeadsMinor
3180 a2 b c d \break
3181 \walkerHeadsMinor
3182 a2 b c d \break
3183
3184 @end lilypond
3185
3186
3187 @predefined
3188 @code{\aikenHeads},
3189 @code{\aikenHeadsMinor},
3190 @code{\funkHeads},
3191 @code{\funkHeadsMinor},
3192 @code{\sacredHarpHeads},
3193 @code{\sacredHarpHeadsMinor},
3194 @code{\southernHarmonyHeads},
3195 @code{\southernHarmonyHeadsMinor},
3196 @code{\walkerHeads},
3197 @code{\walkerHeadsMinor}.
3198 @endpredefined
3199
3200
3201 @snippets
3202
3203 @lilypondfile[verbatim,quote,texidoc,doctitle]
3204 {applying-note-head-styles-depending-on-the-step-of-the-scale.ly}
3205
3206 To see all note head styles, see @ref{Note head styles}.
3207
3208 @seealso
3209 Snippets:
3210 @rlsr{Pitches}.
3211
3212 Notation Reference:
3213 @ref{Note head styles}.
3214
3215 Internals Reference:
3216 @rinternals{note-event},
3217 @rinternals{Note_heads_engraver},
3218 @rinternals{NoteHead},
3219 @rinternals{note-head-interface}.
3220
3221
3222 @node Improvisation
3223 @unnumberedsubsubsec Improvisation
3224
3225 @cindex improvisation
3226 @cindex slashed note heads
3227 @cindex note heads, improvisation
3228 @cindex note heads, slashed
3229
3230 @funindex \improvisationOn
3231 @funindex improvisationOn
3232 @funindex \improvisationOff
3233 @funindex improvisationOff
3234
3235 Improvisation is sometimes denoted with slashed note heads, where
3236 the performer may choose any pitch but should play the specified
3237 rhythm.  Such note heads can be created:
3238
3239 @lilypond[verbatim,quote,relative=2]
3240 \new Voice \with {
3241   \consists "Pitch_squash_engraver"
3242 } {
3243   e8 e g a a16( bes) a8 g
3244   \improvisationOn
3245   e8 ~
3246   2 ~ 8 f4 f8 ~
3247   2
3248   \improvisationOff
3249   a16( bes) a8 g e
3250 }
3251 @end lilypond
3252
3253 @predefined
3254 @code{\improvisationOn},
3255 @code{\improvisationOff}.
3256 @endpredefined
3257
3258 @seealso
3259 Snippets:
3260 @rlsr{Pitches}.
3261
3262 Internals Reference:
3263 @rinternals{Pitch_squash_engraver},
3264 @rinternals{Voice},
3265 @rinternals{RhythmicStaff}.