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