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