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