]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/pitches.itely
Update from Trevor.
[lilypond.git] / Documentation / user / 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.  See TRANSLATION for details.
7 @end ignore
8
9
10 @node Pitches
11 @section Pitches
12
13 @lilypondfile[quote,ragged-right,line-width=16\cm,staffsize=16]
14 {pitches-headword.ly}
15
16 This section discusses how to specify the pitch of notes.  There
17 are three steps to this process: input, modifying, and output.
18
19 @menu
20 * Writing pitches::
21 * Changing multiple pitches::
22 * Displaying pitches::
23 * Note heads::
24 @end menu
25
26
27 @node Writing pitches
28 @subsection Writing pitches
29
30 This section discusses how to input pitches.
31
32 @menu
33 * Absolute octave entry::
34 * Relative octave entry::
35 * Accidentals::
36 * Note names in other languages::
37 @end menu
38
39
40 @node Absolute octave entry
41 @unnumberedsubsubsec Absolute octave entry
42
43 @cindex pitch names
44 @cindex pitches
45
46 @c don't use @samp here because that might get confused with
47 @c octave marks
48 A pitch name is specified using lowercase letters@tie{}@code{a}
49 through@tie{}@code{g}.  An ascending C-major scale is engraved
50 with
51
52 @lilypond[verbatim,quote,ragged-right,fragment]
53 \clef bass
54 c d e f g a b c'
55 @end lilypond
56
57 There are two different ways to enter these note names with regard
58 to octave placement: absolute and relative.  The relative mode
59 will in most cases be the most convenient, but the absolute mode
60 is more fundamental and will be presented first.
61
62 @cindex absolute
63 @cindex absolute octave specification
64
65 In absolute mode, every note is placed explicitly in a specific
66 octave.  The note names @code{c} to @code{b} are engraved in the
67 octave below middle C, as in the previous example.
68
69 @lilypond[verbatim,quote,ragged-right,fragment]
70 \clef treble
71 c1
72 \clef bass
73 c1
74 @end lilypond
75
76 @funindex '
77 @funindex ,
78
79 If a note should be in another octave than this, an octave
80 specification must be given.  It takes the form of a series of
81 single quote@tie{}(@code{'}) or comma@tie{}(@code{,}) characters.
82 Each@tie{}@code{'} raises the pitch by one octave;
83 each@tie{}@code{,} lowers the pitch by an octave.
84
85 @lilypond[verbatim,quote,ragged-right,fragment]
86 \clef treble
87 c' c'' e' g d'' d' d c
88 \clef bass
89 c, c,, e, g d,, d, d c
90 @end lilypond
91
92 @seealso
93
94 Snippets: @lsrdir{pitches}.
95
96 Internals reference: @internalsref{LedgerLineSpanner},
97 @internalsref{NoteHead}.
98
99
100 @node Relative octave entry
101 @unnumberedsubsubsec Relative octave entry
102
103 @cindex relative
104 @cindex relative octave specification
105 @funindex \relative
106
107 The absolute mode requires a lot of octave specifications, which
108 not only becomes tedious but also easily leads to errors.
109 Therefore, it is usually more convenient to let notes be entered
110 relative to the previous note.  This is done with the relative
111 mode.
112
113 @example
114 \relative @var{startpitch} @var{musicexpr}
115 @end example
116
117 In relative mode, each note is assumed to be as close to the
118 previous note as possible.  This means that the octave of notes
119 that appear in @var{musicexpr} are calculated as follows:
120
121 @itemize
122 @item
123 The pitch of the first note is relative to @code{\relative
124 @var{startpitch} }.
125
126 @item
127 If no octave changing marks are used, the basic interval between a
128 note and the one that precedes it is always taken to be a fourth
129 or less.
130
131 @item
132 This distance is determined without regarding alterations or the
133 actual sounding pitches; a @code{fisis} following a @code{ceses}
134 will be put above the @code{ceses}.  In other words, a
135 doubly-augmented fourth is considered a smaller interval than a
136 diminished fifth, even though the doubly-augmented fourth spans
137 seven semitones while the diminished fifth only spans six
138 semitones.
139
140 @item
141 The octave changing marks@tie{}@code{'} and@tie{}@code{,} can be
142 added to raise or lower the pitch by an extra octave from the
143 basic interval.
144
145 @item
146 Multiple octave changing marks can be used.  @code{''}@tie{}will
147 raise the pitch by two octaves.
148
149 @end itemize
150
151 Here is the relative mode shown in action:
152
153 @lilypond[verbatim,quote,ragged-right,fragment]
154 \relative c'' {
155   b c d c b c bes a
156 }
157 @end lilypond
158
159 Octave changing marks are used for intervals greater than a
160 fourth:
161
162 @lilypond[verbatim,quote,ragged-right,fragment]
163 \relative c'' {
164   c g c f, c' a, e''
165 }
166 @end lilypond
167
168 A note sequence without a single octave mark can nevertheless span
169 large intervals:
170
171 @lilypond[verbatim,quote,ragged-right,fragment]
172 \relative c {
173   c f b e a d g
174 }
175 @end lilypond
176
177 If the preceding item is a chord, the first note of the chord is
178 used as the reference point for the octave placement of a
179 following note or chord:
180
181 @lilypond[verbatim,quote,ragged-right,fragment]
182 \relative c' {
183   c <c e g>
184   <c' e, g'>
185   <c, e' g> c
186 }
187 @end lilypond
188
189 The @var{startpitch} (after @code{\relative}) is a note name in
190 absolute mode.  In principle it can be any note name, but common
191 practice is to use@tie{}@code{c} in various octave positions.
192
193 When octaves are specified as above by adding@tie{}@code{'}
194 and@tie{}@code{,} to pitch names, it is easy to accidentally put a
195 pitch in the wrong octave.  The relative octave mode prevents
196 these errors since most of the time it is not necessary to
197 indicate any octaves at all.  Furthermore, in absolute mode, a
198 single mistake may be difficult to spot; in relative mode, a
199 single error puts the rest of the piece off by one octave.
200
201 LilyPond examines pitches based on the note names -- in other
202 words, an augmented fourth is @emph{not} treated the same as a
203 diminished fifth.  If we begin at a C, then an F-sharp will be
204 placed higher than the C, while a G-flat will be placed lower than
205 the C.
206
207 @lilypond[verbatim,quote,ragged-right,fragment,relative=2]
208 c2 fis
209 c2 ges
210 @end lilypond
211
212 @seealso
213
214 Snippets: @lsrdir{pitches}.
215
216
217 @refbugs
218
219 The relative conversion will not affect @code{\transpose},
220 @code{\chordmode} or @code{\relative} sections in its argument.
221 To use relative within transposed music, an additional
222 @code{\relative} must be placed inside @code{\transpose}.
223
224 @c DEPRECATED
225 If no @var{startpitch} is specified for @code{\relative},
226 then@tie{}@code{c'} is assumed.  However, this is a deprecated
227 option and may disappear in future versions, so its use is
228 discouraged.
229
230
231
232 @node Accidentals
233 @unnumberedsubsubsec Accidentals
234
235 @warning{New users are sometimes confused about accidentals and
236 key signatures.  In LilyPond, note names are the raw input; key
237 signatures and clefs determine how this raw input is displayed.
238 An unaltered note like@tie{}@code{c} means @q{C natural},
239 regardless of the key signature or clef.  For more information,
240 see @rlearning{Accidentals and key signatures}.}
241
242 @cindex note names, Dutch
243 @cindex note names, default
244
245 A @notation{sharp} pitch is made by adding @code{is} to the name,
246 and a @notation{flat} pitch by adding @code{es}.  As you might
247 expect, a @notation{double sharp} or @notation{double flat} is
248 made by adding @code{isis} or @code{eses}.  This syntax derived
249 from note naming conventions in Nordic and Germanic languages,
250 like German and Dutch.  To use other names for accidentals, see
251 @ref{Note names in other languages}.
252
253 @lilypond[verbatim,quote,ragged-right,fragment,relative=2]
254 a2 ais a aes
255 a2 aisis a aeses
256 @end lilypond
257
258 @noindent
259 These are the Dutch note names.  In Dutch, @code{aes} is
260 contracted to @code{as}, but both forms are accepted.  Similarly,
261 both @code{es} and @code{ees} are accepted:
262
263 @lilypond[verbatim,quote,ragged-right,fragment,relative=2]
264 a2 as e es
265 @end lilypond
266
267 A natural will cancel the effect of an accidental or key
268 signature.  However, naturals are not encoded into the note name
269 syntax with a suffix; a natural pitch is shown as a simple note
270 name:
271
272 @lilypond[verbatim,quote,ragged-right,fragment,relative=2]
273 a4 aes a2
274 @end lilypond
275
276
277 @cindex accidental, reminder
278 @cindex accidental, cautionary
279 @cindex accidental, parenthesized
280 @cindex reminder accidental
281 @funindex ?
282 @cindex cautionary accidental
283 @cindex parenthesized accidental
284 @funindex !
285
286 Normally accidentals are printed automatically, but you may also
287 print them manually.  A reminder accidental can be forced by
288 adding an exclamation mark@tie{}@code{!} after the pitch.  A
289 cautionary accidental (i.e., an accidental within parentheses) can
290 be obtained by adding the question mark@tie{}@code{?} after the
291 pitch.  These extra accidentals can be used to produce natural
292 signs, too.
293
294 @lilypond[verbatim,quote,ragged-right,fragment,relative=1]
295 cis cis cis! cis? c c? c! c
296 @end lilypond
297
298
299 @cindex quarter tones
300 @cindex semi-flats, semi-sharps
301
302 Half-flats and half-sharps are formed by adding @code{eh} and
303 @code{ih}; the following is a series of Cs with increasing
304 pitches
305
306 @lilypond[verbatim,quote,ragged-right,fragment,relative=2]
307 \set Staff.extraNatural = ##f
308 ceseh ceh cih cisih
309 @end lilypond
310
311 Micro tones are also exported to the MIDI file.
312
313
314 @commonprop
315
316 Snippets: @lsrdir{pitches},
317 @lsr{pitches,preventing-extra-naturals-from-being-automatically-added.ly}.
318
319 @seealso
320
321 Music Glossary: @rglos{sharp}, @rglos{flat}, @rglos{double sharp},
322 @rglos{double flat}.
323
324 Learning Manual: @rlearning{Accidentals and key signatures}.
325
326 Notation Reference: @ref{Automatic accidentals},
327 @ref{Musica ficta accidentals},
328 @ref{Note names in other languages}.
329
330
331
332 @refbugs
333
334 There are no generally accepted standards for denoting
335 three-quarter flats, so LilyPond's symbol does not conform to any
336 standard.
337
338
339
340 @node Note names in other languages
341 @unnumberedsubsubsec Note names in other languages
342
343 There are predefined sets of note names for various other
344 languages.  To use them, include the language specific init file.
345 For example, add @code{\include "english.ly"} to the top of the
346 input file.  The available language files and the note names they
347 define are:
348
349 @cindex note names, other languages
350
351 @example
352 @multitable @columnfractions .2 .6 .05 .05 .05 .05
353 @headitem Language
354   @tab Note names
355   @tab sharp @tab flat @tab double sharp @tab double flat
356 @item nederlands.ly
357   @tab c d e f g a bes b
358   @tab -is @tab -es @tab -isis @tab -eses
359 @item english.ly
360   @tab c d e f g a bf b
361   @tab -s/-sharp @tab -f/-flat @tab -ss/-x/-sharpsharp
362     @tab -ff/-flatflat
363 @item deutsch.ly
364   @tab c d e f g a b h
365   @tab -is @tab -es @tab -isis @tab -eses
366 @item norsk.ly
367   @tab c d e f g a b h
368   @tab -iss/-is @tab -ess/-es @tab -ississ/-isis
369     @tab -essess/-eses
370 @item svenska.ly
371   @tab c d e f g a b h
372   @tab -iss @tab -ess @tab -ississ @tab -essess
373 @item suomi.ly
374   @tab c d e f g a b h
375   @tab -is @tab -es @tab -isis @tab -eses
376 @item italiano.ly
377   @tab do re mi fa sol la sib si
378   @tab -d @tab -b @tab -dd @tab -bb
379 @item catalan.ly
380   @tab do re mi fa sol la sib si
381   @tab -d/-s @tab -b @tab -dd/-ss @tab -bb
382 @item espanol.ly
383   @tab do re mi fa sol la sib si
384   @tab -s @tab -b @tab -ss @tab -bb
385 @item portugues.ly
386   @tab do re mi fa sol la sib si
387   @tab -s @tab -b @tab -ss @tab -bb
388 @item vlaams.ly
389   @tab do re mi fa sol la sib si
390   @tab -k @tab -b @tab -kk @tab -bb
391 @end multitable
392 @end example
393
394 @noindent
395 Note that in Dutch, German, Norwegian, and Swedish, the flat
396 alterations of@tie{}@code{a} like for example @code{aes} and
397 @code{aeses} are usually contracted to @code{as} and @code{ases}
398 (or more commonly @code{asas}).  Sometimes only these contracted
399 names are defined in the corresponding language files (this also
400 applies to the suffixes for quartertones below).
401
402 @noindent
403 Some music uses microtones whose alterations are fractions of a
404 @q{normal} sharp or flat.  The note names for quartertones defined
405 in the various language files are listed in the following table.
406 Here the prefixes @q{semi-} and @q{sesqui-} mean @q{half} and
407 @q{one and a half}, respectively.  For the other languages no
408 special names have been defined yet.
409
410
411 @c What about Turkish Maquam music and similar microtonal systems?
412 @c
413 @c Note that the term "three-quarter-sharp/-flat" used in
414 @c lilypond's source code is actually misleading since the
415 @c alteration is in fact one and a half of a regular sharp/flat.
416 @c Whence the naming "sesqui-sharp/-flat" used below.
417
418 @example
419 @multitable @columnfractions .2 .6 .05 .05 .05 .05
420 @headitem Language
421   @tab Note names
422   @tab semi- @tab semi- @tab sesqui- @tab sesqui-
423
424 @item nederlands.ly
425   @tab c d e f g a bes b
426   @tab -ih @tab -eh @tab -isih @tab -eseh
427 @item english.ly
428   @tab c d e f g a bf b
429   @tab -qs @tab -qf @tab -tqs @tab -tqf
430 @item deutsch.ly
431   @tab c d e f g a b h
432   @tab -ih @tab -eh @tab -isih @tab -eseh
433 @c @item norsk.ly
434 @c   @tab c d e f g a b h
435 @c @item svenska.ly
436 @c   @tab c d e f g a b h
437 @item italiano.ly
438   @tab do re mi fa sol la sib si
439   @tab -sd @tab -sb @tab -dsd @tab -bsb
440 @c @item catalan.ly
441 @c   @tab do re mi fa sol la sib si
442 @c @item  espanol.ly
443 @c   @tab do re mi fa sol la sib si
444 @item portugues.ly
445   @tab do re mi fa sol la sib si
446   @tab -sqt @tab -bqt @tab -stqt @tab -btqt
447 @end multitable
448 @end example
449
450 @seealso
451
452 Snippets: @lsrdir{pitches}.
453
454
455 @node Changing multiple pitches
456 @subsection Changing multiple pitches
457
458 This section discusses how to modify pitches.
459
460 @menu
461 * Octave check::
462 * Transpose::
463 @end menu
464
465 @node Octave check
466 @unnumberedsubsubsec Octave check
467
468 @cindex octave check
469
470 In relative mode, it is easy to forget an octave changing mark.
471 Octave checks make such errors easier to correct.  A note may be
472 followed by @code{=}@var{quotes} to indicate what its absolute
473 octave should be.  In the following example,
474
475 @example
476 \relative c'' @{ c g d='' @}
477 @end example
478
479 @noindent
480 the@tie{}@code{d} will generate a warning, because
481 a@tie{}@code{d''} is expected, as indicated by the octave check
482 @code{=''}, but a @code{d'} is found, since both @code{c}-@code{g}
483 and @code{g}-@code{d} without octavation marks are descending
484 fourths.  In the output, the octave is corrected to be
485 a@tie{}@code{d''} and the next note is calculated relative
486 to@tie{}@code{d''} instead of@tie{}@code{d'}.
487
488 There is also an octave check that produces no visible output.
489 The syntax is:
490
491 @example
492 @var{pitch} \octave @var{controlpitch}
493 @end example
494
495 @noindent
496 where @var{pitch} is a regular note within a music expression in
497 relative mode and @var{controlpitch} is a pitch in absolute mode.
498 This checks that @var{pitch} lies within the octave surrounding
499 @var{controlpitch}, i.e. not more than a fourth above or below it.
500 If this is not the case, a warning is printed and the octave is
501 corrected.  The @var{controlpitch} is not printed as a note.
502
503 In the example below, the first check passes without incident,
504 since the@tie{}@code{e} (in @code{relative} mode) is within the
505 octave range of@tie{}@code{a'}.  However, the second check
506 produces a warning, since the@tie{}@code{e} is not within the
507 octave range of@tie{}@code{b'}.  The warning message is printed,
508 and the octave is adjusted so that the following notes are in the
509 correct octave once again.
510
511 @example
512 \relative c' @{
513   e
514   \octave a'
515   \octave b'
516 @}
517 @end example
518
519
520 The octave of a note following an @code{\octave} check is
521 determined with respect to the note preceding it, as modified by
522 the outcome of the octave check.  In the next fragment, the first
523 note, an@tie{}@code{e'}, lies within the octave of@tie{}@code{b},
524 and the @code{\octave} check passes successfully.  The second note
525 is then calculated relative to (absolute)@tie{}@code{e'}, which
526 yields an@tie{}@code{a'}, above middle@tie{}C.  In this case, the
527 check had no influence on the output of the piece.
528
529 The second @code{\octave} check fails: @code{a'}@tie{}is not
530 within the range of@tie{}@code{b}.  A warning is issued, and the
531 last note is calculated relative to@tie{}@code{a}, not
532 to@tie{}@code{a'}, and we get a@tie{}@code{d'}.  Without the last
533 @code{\octave} check, the last note would have been
534 a@tie{}@code{d''}.
535
536 @lilypond[verbatim,quote,ragged-right,fragment]
537 \relative c' {
538   e
539   \octave b
540   a
541   \octave b
542   d
543 }
544 @end lilypond
545
546 @seealso
547
548 Snippets: @lsrdir{pitches}.
549
550
551 @node Transpose
552 @unnumberedsubsubsec Transpose
553
554 @cindex transpose
555 @cindex transposition of pitches
556 @funindex \transpose
557
558 A music expression can be transposed with @code{\transpose}.  The
559 syntax is
560
561 @example
562 \transpose @var{from} @var{to} @var{musicexpr}
563 @end example
564
565 This means that @var{musicexpr} is transposed by the interval
566 between the pitches @var{from} and @var{to}: any note with pitch
567 @var{from} is changed to @var{to} and any other note is transposed
568 by the same interval.
569
570 Consider a piece written in the key of D-major.  If this piece is
571 a little too low for its performer, it can be transposed up to
572 E-major with
573
574 @example
575 \transpose d e @dots{}
576 @end example
577
578 Consider a part written for violin (a C instrument).  If this part
579 is to be played on the A clarinet (for which an A is notated as a
580 C, and thus sounds a minor third lower than notated), the
581 following transposition will produce the appropriate part:
582
583 @example
584 \transpose a c @dots{}
585 @end example
586
587 @code{\transpose} will also transpose key signatures:
588
589 @lilypond[verbatim,quote,ragged-right]
590 mus = { \key d \major cis d fis g }
591 \new Staff {
592   \clef "F" \mus
593   \clef "G"
594   \transpose c g' \mus
595   \transpose c f' \mus
596 }
597 @end lilypond
598
599 @code{\transpose} distinguishes between enharmonic pitches: both
600 @code{\transpose c cis} or @code{\transpose c des} will transpose
601 up half a tone.  The first version will print sharps and the notes
602 will remain on the same scale step, the second version will print
603 flats on the scale step above.
604
605 @lilypond[verbatim,quote,ragged-right]
606 mus = { c d e f }
607 \new Staff {
608   \transpose c cis { \relative c' \mus }
609   \transpose c des { \relative c' \mus }
610 }
611 @end lilypond
612
613 @code{\transpose} may also be used to input written notes for a
614 transposing instrument.  The previous examples show how to enter
615 pitches in C (or @notation{concert pitch}) and typeset them for a
616 transposing instrument, but the opposite is also possible if you
617 for example have a set of instrumental parts and want to print a
618 conductor's score.  For example, when entering music for a B-flat
619 trumpet which begins on a notated E (concert D), one would write:
620
621 @example
622 musicInBflat = @{ e4 @dots{} @}
623 \transpose c bes \musicInBflat
624 @end example
625
626 To print this music in F (e.g., rearranging to a french horn) you
627 would wrap the existing music with another @code{\transpose}
628
629 @example
630 musicInBflat = @{ e4 @dots{} @}
631 \transpose f c @{ \transpose c bes \musicInBflat @}
632 @end example
633
634 @seealso
635
636 Snippets: @lsrdir{pitches}, @lsr{scheme,
637 transpose-pitches-with-minimum-accidentals.ly}.
638
639 Internals reference: @internalsref{TransposedMusic}.
640
641 @refbugs
642
643 If you want to use both @code{\transpose} and @code{\relative},
644 you must put @code{\transpose} outside of @code{\relative}, since
645 @code{\relative} will have no effect on music that appears inside
646 a @code{\transpose}.  See the previous example.
647
648
649 @node Displaying pitches
650 @subsection Displaying pitches
651
652 This section discusses how to alter the output of pitches.
653
654 @menu
655 * Clef::
656 * Key signature::
657 * Ottava brackets::
658 * Instrument transpositions::
659 * Automatic accidentals::
660 * Ambitus::
661 @end menu
662
663 @node Clef
664 @unnumberedsubsubsec Clef
665
666 @funindex \clef
667
668 @cindex G clef
669 @cindex C clef
670 @cindex F clef
671 @cindex treble clef
672 @cindex violin clef
673 @cindex alto clef
674 @cindex tenor clef
675 @cindex bass clef
676 @cindex french clef
677 @cindex soprano clef
678 @cindex mezzosoprano clef
679 @cindex baritone clef
680 @cindex varbaritone clef
681 @cindex subbass clef
682
683 The clef is set with the @code{\clef} @var{clefname}
684 command:
685
686 @lilypond[verbatim,quote,ragged-right,fragment]
687 <<
688   \new Staff {
689     % treble clef by default
690     c'1^"middle C"
691   }
692   \new Staff {
693     \clef alto
694     c'1^"middle C"
695   }
696   \new Staff {
697     \clef bass
698     c'1^"middle C"
699   }
700 >>
701 @end lilypond
702
703 The clef can also be changed inside the staff:
704
705 @lilypond[verbatim,quote,ragged-right,fragment]
706 \new PianoStaff <<
707   \new Staff {
708     \time 2/4
709     \clef treble
710     r16
711     \clef bass
712     e g c' e' e g c'
713   }
714   \new Staff {
715     \clef bass
716     c,8 r
717     \clef treble
718     g''4
719   }
720 >>
721 @end lilypond
722
723 These same clef symbols are used in different positions on the
724 staff to change the range of notes shown by that staff.  The
725 treble (alto, bass) clef is always positioned to show the line on
726 which a@tie{}@code{g'} (@code{c'}, @code{f}) note is printed.
727
728 Supported clefs include
729
730 @multitable @columnfractions .4 .6
731 @headitem Clef @tab Position
732 @item @code{treble, violin, G, G2} @tab
733 G clef (g') on 2nd line
734 @item @code{alto, C} @tab
735 C clef (c') on 3rd line
736 @item @code{tenor} @tab
737 C clef (c') on 4th line
738 @item @code{bass, F} @tab
739 F clef (f) on 4th line
740 @item @code{french} @tab
741 G clef (g') on 1st line, so-called French violin clef
742 @item @code{soprano} @tab
743 C clef (c') on 1st line
744 @item @code{mezzosoprano} @tab
745 C clef (c') on 2nd line
746 @item @code{baritone} @tab
747 C clef (c') on 5th line
748 @item @code{varbaritone} @tab
749 F clef (f) on 3rd line
750 @item @code{subbass} @tab
751 F clef (f) on 5th line
752 @item @code{percussion} @tab
753 percussion clef
754 @item @code{tab} @tab
755 tablature clef
756 @end multitable
757
758 Further supported clefs are described under @ref{Ancient clefs}.
759
760 By adding @code{_8} or @code{^8} to the clef name, the clef is
761 transposed one octave down or up, respectively, and @code{_15} and
762 @code{^15} transposes by two octaves.  The argument @var{clefname}
763 must be enclosed in quotes when it contains underscores or digits.
764 For example,
765
766 @cindex choral tenor clef
767
768 @lilypond[verbatim,quote,ragged-right,fragment,relative=1]
769 \clef "G_8" c4
770 @end lilypond
771
772 @commonprop
773
774 When a clef change takes place at a line break the new clef symbol
775 is printed at both the end of the previous line and the beginning
776 of the new line by default.  If the warning clef at the end of the
777 previous line in not required it can be suppressed by setting the
778 @code{explicitClefVisibility} Staff property to the value
779 @var{end-of-line-invisible}:  @code{\set
780 Staff.explicitClefVisibility = #end-of-line-invisible} The default
781 behaviour can be recovered with @code{\unset
782 Staff.explicitClefVisibility}
783
784 The command @code{\clef "treble_8"} is equivalent to setting
785 @code{clefGlyph}, @code{clefPosition} (which controls the Y
786 position of the clef), @code{middleCPosition} and
787 @code{clefOctavation}.  A clef is printed when either the
788 @code{clefGlyph}, @code{clefPosition} or @code{clefOctavation}
789 properties are changed.  Note that changing the glyph, the
790 position of the clef, or the octavation, does not in itself change
791 the position of subsequent notes on the staff: the position of
792 middle C must also be specified to do this.  The positional
793 parameters are relative to the staff centre line, positive numbers
794 displacing upwards, counting 1 for each line and space.  The
795 clefOctavation value would normally be set to 7, -7, 15 or -15,
796 but other values are not invalid.
797
798 The following examples show the possibilities when setting these
799 properties manually.  First some manual changes which preserve the
800 standard relative positioning of clefs and notes:
801
802 @lilypond[verbatim,quote,ragged-right]
803 {
804   % The default treble clef
805   c'4
806   % The standard bass clef
807   \set Staff.clefGlyph = #"clefs.F"
808   \set Staff.clefPosition = #2
809   \set Staff.middleCPosition = #6
810   c'4
811   % The baritone clef
812   \set Staff.clefGlyph = #"clefs.C"
813   \set Staff.clefPosition = #4
814   \set Staff.middleCPosition = #4
815   c'4
816   % The standard choral tenor clef
817   \set Staff.clefGlyph = #"clefs.G"
818   \set Staff.clefPosition = #-2
819   \set Staff.clefOctavation = #-7
820   \set Staff.middleCPosition = #1
821   c'4
822   % A non-standard clef
823   \set Staff.clefPosition = #0
824   \set Staff.clefOctavation = #0
825   \set Staff.middleCPosition = #-4
826   c'4
827 }
828 @end lilypond
829
830 and some which do not:
831
832 @lilypond[verbatim,quote,ragged-right]
833 {
834   \set Staff.clefGlyph = #"clefs.F"
835   \set Staff.clefPosition = #2
836   c'4
837   \set Staff.clefGlyph = #"clefs.G"
838   c'4
839   \set Staff.clefGlyph = #"clefs.C"
840   c'4
841   \set Staff.clefOctavation = #7
842   c'4
843   \set Staff.clefOctavation = #0
844   \set Staff.clefPosition = #0
845   c'4
846   \set Staff.middleCPosition = #4
847   c'4
848 }
849 @end lilypond
850
851 @seealso
852
853 Notation Reference: @ref{Ancient clefs}.
854
855 Snippets: @lsrdir{pitches}.
856
857 Internals reference: @internalsref{Clef}.
858
859
860 @node Key signature
861 @unnumberedsubsubsec Key signature
862
863 @cindex key signature
864 @funindex \key
865
866 @warning{New users are sometimes confused about accidentals and
867 key signatures.  In LilyPond, note names are the raw input; key
868 signatures and clefs determine how this raw input is displayed.
869 An unaltered note like@tie{}@code{c} means @q{C natural},
870 regardless of the key signature or clef.  For more information,
871 see @rlearning{Accidentals and key signatures}.}
872
873 The key signature indicates the tonality in which a piece is
874 played.  It is denoted by a set of alterations (flats or sharps)
875 at the start of the staff.
876
877 Setting or changing the key signature is done with the @code{\key}
878 command:
879
880 @example
881 \key @var{pitch} @var{type}
882 @end example
883
884 @funindex \minor
885 @funindex \major
886 @funindex \minor
887 @funindex \ionian
888 @funindex \locrian
889 @funindex \aeolian
890 @funindex \mixolydian
891 @funindex \lydian
892 @funindex \phrygian
893 @funindex \dorian
894 @cindex church modes
895
896 Here, @var{type} should be @code{\major} or @code{\minor} to get
897 @var{pitch}-major or @var{pitch}-minor, respectively.  You may
898 also use the standard mode names (also called @q{church modes}):
899 @code{\ionian}, @code{\locrian}, @code{\aeolian},
900 @code{\mixolydian}, @code{\lydian}, @code{\phrygian}, and
901 @code{\dorian}.
902
903 @lilypond[verbatim,quote,ragged-right,fragment,relative=2]
904 \key g \major
905 f1
906 fis
907 @end lilypond
908
909
910 @commonprop
911
912 Snippets: @lsrdir{pitches}, @lsr{pitches,
913 preventing-natural-signs-from-being-printed-when-the-key-signature-changes.ly},
914 @lsr{pitches, non-traditional-key-signatures.ly}
915
916 @seealso
917
918 Music Glossary: @rglos{church mode}, @rglos{scordatura}.
919
920 Learning Manual: @rlearning{Accidentals and key signatures}.
921
922 Internals reference: @internalsref{KeyCancellation},
923 @internalsref{KeySignature}, @internalsref{Key_engraver}.
924
925
926 @node Ottava brackets
927 @unnumberedsubsubsec Ottava brackets
928
929 @cindex ottava
930 @cindex 15ma
931 @cindex 8va
932 @cindex 8ve
933 @cindex octavation
934
935 @notation{Ottava brackets} introduce an extra transposition of an
936 octave for the staff:
937
938 @lilypond[verbatim,quote,ragged-right,fragment]
939 \relative c''' {
940   a2 b
941   #(set-octavation 1)
942   a b
943   #(set-octavation 0)
944   a b
945 }
946 @end lilypond
947
948 The @code{set-octavation} function also takes -1 (for 8va bassa),
949 2@tie{}(for 15ma), and -2 (for 15ma bassa) as arguments.
950 Internally the function sets the properties @code{ottavation}
951 (e.g., to @code{"8va"} or @code{"8vb"}) and
952 @code{middleCPosition}.  To override the text of the bracket, set
953 @code{ottavation} after invoking @code{set-octavation}, i.e.,
954
955 @lilypond[verbatim,quote,ragged-right]
956 {
957   #(set-octavation 1)
958   \set Staff.ottavation = #"8"
959   c'''
960 }
961 @end lilypond
962
963
964 @seealso
965
966 Music Glossary: @c FIXME add link once it's in the glossary @c @rgloss{ottava}.
967
968 Snippets: @lsrdir{pitches}.
969
970 Internals reference: @internalsref{OttavaBracket}.
971
972
973 @refbugs
974
975 @code{set-octavation} will get confused when clef changes happen
976 during an octavation bracket.
977
978
979 @node Instrument transpositions
980 @unnumberedsubsubsec Instrument transpositions
981
982 @cindex transposition, MIDI
983 @cindex transposition, instrument
984
985 The key of a @notation{transposing instrument} can be specified.
986 This applies to many wind instruments, for example, clarinets
987 (B-flat, A, and E-flat), horn (F) and trumpet (B-flat, C, D, and
988 E-flat).
989
990 The transposition is entered with the command
991
992 @example
993 \transposition @var{pitch}
994 @end example
995
996 @noindent
997 where @var{pitch} specifies the key in which the instrument plays.
998 For example, a part for B-flat clarinet would include
999
1000 @example
1001 \transposition bes
1002 @end example
1003
1004 This command sets the property @code{instrumentTransposition}.
1005 The value of this property is used for MIDI output and quotations.
1006 MIDI output is transposed to play at concert pitch, and cue notes
1007 and quotations are automatically transposed to the key of the
1008 instrument in which they are quoted.  For more information about
1009 quotations, see @ref{Quoting other voices}.
1010
1011 The pitch to use for @code{\transposition} should correspond to
1012 the real sound heard when a@tie{}@code{c'} written on the staff is
1013 played by the transposing instrument.  @code{\transposition}
1014 should be used when the music is entered from an orchestral part
1015 written for the instrument.  For example, in classical horn parts,
1016 the tuning of the instrument is often changed during a piece.
1017 Here are a few notes for a violin and a B-flat clarinet where the
1018 parts have been entered using the notes and key as they appear in
1019 each part or the conductor's score:
1020
1021 @lilypond[verbatim,quote,ragged-right]
1022 \new GrandStaff <<
1023   \new Staff = "Violin I" {
1024     \set Staff.instrumentName = "Vln"
1025     \set Staff.midiInstrument="violin"
1026     \key c \major
1027     \transposition c
1028     g'4( c''8) r c'' r c''4
1029   }
1030   \new Staff = "Clarinet" {
1031     \set Staff.instrumentName = "Cl"
1032     \set Staff.midiInstrument="clarinet"
1033     \key d \major
1034     \transposition bes
1035     a'4( d''8) r d'' r d''4
1036   }
1037 >>
1038 @end lilypond
1039
1040 Without the @code{\transposition} command the MIDI output of this
1041 music would play the notes a tone apart; with it the notes are
1042 played correctly in unison.
1043
1044 However, when entering the notes of a score in concert pitch, when
1045 all voices are entered in C, they may be prefaced by (the default)
1046 @code{\transposition c'}:
1047
1048 @example
1049 clarinet = @{
1050   \transposition c'
1051   ...
1052 @}
1053 saxophone = @{
1054   \transposition c'
1055   ...
1056 @}
1057 @end example
1058
1059 @noindent
1060 to serve as a reminder that these parts are written in C.
1061
1062
1063 @seealso
1064
1065 Music Glossary: @c FIXME add link once it's in the glossary @c @rgloss{instrument transposition}.
1066
1067 Notation Reference: @ref{Quoting other voices}, @ref{Transpose}.
1068
1069 Snippets: @lsrdir{pitches}.
1070
1071
1072 @node Automatic accidentals
1073 @unnumberedsubsubsec Automatic accidentals
1074 @cindex automatic accidentals
1075
1076 Common rules for typesetting accidentals have been placed in a
1077 function.  This function is called as follows
1078
1079 @funindex set-accidental-style
1080
1081 @example
1082 \new Staff <<
1083   #(set-accidental-style 'voice)
1084   @{ @dots{} @}
1085 >>
1086 @end example
1087
1088 @c TODO: check the context stuff below
1089 @c -does it *really* work?
1090 @c -the default contexts as specified in
1091 @c  scm/music-function.scm seem to be different -vv
1092
1093 If no context name is supplied, the accidental style applies to
1094 the @code{Staff} by default.  Optionally, the function can take
1095 the context for which the style should be changed as a second
1096 argument:
1097
1098 @example
1099 #(set-accidental-style 'STYLE #('CONTEXT))
1100 @end example
1101
1102 The following accidental styles are supported.  To demonstrate
1103 each style, we use the following example:
1104
1105 @lilypond[verbatim,quote,ragged-right]
1106 musicA = {
1107   <<
1108     \relative c' {
1109       cis'8 fis, d'4 <a cis>8 f bis4 |
1110       cis2. <c, g'>4 |
1111     }
1112     \\
1113     \relative c' {
1114       ais'2 cis, |
1115       fis8 b a4 cis2 |
1116     }
1117   >>
1118 }
1119
1120 musicB = {
1121   \clef bass
1122   \new Voice {
1123     \voiceTwo \relative c' {
1124       <fis, a cis>4
1125       \change Staff = up
1126       cis'
1127       \change Staff = down
1128       <fis, a>
1129       \change Staff = up
1130       dis' |
1131       \change Staff = down
1132       <fis, a cis>4 gis <f a d>2 |
1133     }
1134   }
1135 }
1136
1137 \new PianoStaff {
1138   <<
1139     \context Staff = "up" {
1140       %%% change the next line as desired:
1141       %#(set-accidental-style 'default)
1142       \musicA
1143     }
1144     \context Staff = "down" {
1145       %%% change the next line as desired:
1146       %#(set-accidental-style 'default)
1147       \musicB
1148     }
1149   >>
1150 }
1151 @end lilypond
1152
1153 @c don't use verbatim in this table.
1154 @table @code
1155 @item default
1156 This is the default typesetting behavior.  It corresponds to
1157 eighteenth-century common practice: Accidentals are remembered to
1158 the end of the measure in which they occur and only on their own
1159 octave.  Thus, in the example below, no natural signs are printed
1160 before the@tie{}@code{b} in the second measure or the
1161 last@tie{}@code{c}:
1162
1163 @lilypond[quote,ragged-right]
1164 musicA = {
1165   <<
1166     \relative c' {
1167       cis'8 fis, d'4 <a cis>8 f bis4 |
1168       cis2. <c, g'>4 |
1169     }
1170     \\
1171     \relative c' {
1172       ais'2 cis, |
1173       fis8 b a4 cis2 |
1174     }
1175   >>
1176 }
1177
1178 musicB = {
1179   \clef bass
1180   \new Voice {
1181     \voiceTwo \relative c' {
1182       <fis, a cis>4
1183       \change Staff = up
1184       cis'
1185       \change Staff = down
1186       <fis, a>
1187       \change Staff = up
1188       dis' |
1189       \change Staff = down
1190       <fis, a cis>4 gis <f a d>2 |
1191     }
1192   }
1193 }
1194
1195 \new PianoStaff {
1196   <<
1197     \context Staff = "up" {
1198       %#(set-accidental-style 'default)
1199       \musicA
1200     }
1201     \context Staff = "down" {
1202       %#(set-accidental-style 'default)
1203       \musicB
1204     }
1205   >>
1206 }
1207 @end lilypond
1208
1209 @item voice
1210 The normal behavior is to remember the accidentals on
1211 Staff-level.  This variable, however, typesets accidentals
1212 individually for each voice.  Apart from that, the rule is similar
1213 to @code{default}.
1214
1215 As a result, accidentals from one voice do not get canceled in
1216 other voices, which is often an unwanted result: in the following
1217 example, it is hard to determine whether the second@tie{}@code{a}
1218 should be played natural or sharp.  The @code{voice} option should
1219 therefore be used only if the voices are to be read solely by
1220 individual musicians.  If the staff is to be used by one musician
1221 (e.g., a conductor or in a piano score) then @code{modern} or
1222 @code{modern-cautionary} should be used instead.
1223
1224
1225 @lilypond[quote,ragged-right]
1226 musicA = {
1227   <<
1228     \relative c' {
1229       cis'8 fis, d'4 <a cis>8 f bis4 |
1230       cis2. <c, g'>4 |
1231     }
1232     \\
1233     \relative c' {
1234       ais'2 cis, |
1235       fis8 b a4 cis2 |
1236     }
1237   >>
1238 }
1239
1240 musicB = {
1241   \clef bass
1242   \new Voice {
1243     \voiceTwo \relative c' {
1244       <fis, a cis>4
1245       \change Staff = up
1246       cis'
1247       \change Staff = down
1248       <fis, a>
1249       \change Staff = up
1250       dis' |
1251       \change Staff = down
1252       <fis, a cis>4 gis <f a d>2 |
1253     }
1254   }
1255 }
1256
1257 \new PianoStaff {
1258   <<
1259     \context Staff = "up" {
1260       #(set-accidental-style 'voice)
1261       \musicA
1262     }
1263     \context Staff = "down" {
1264       #(set-accidental-style 'voice)
1265       \musicB
1266     }
1267   >>
1268 }
1269 @end lilypond
1270
1271 @item modern
1272 @funindex modern style accidentals
1273
1274 This rule corresponds to the common practice in the twentieth
1275 century.  It prints the same accidentals as @code{default}, with
1276 two exceptions which serve to avoid ambiguity: after temporary
1277 accidentals, cancellation marks are printed also in the following
1278 measure (for notes in the same octave) and, in the same measure,
1279 for notes in other octaves.  Hence the naturals before
1280 the@tie{}@code{b} and the@tie{}@code{c} in the second measure of
1281 the upper staff:
1282
1283 @lilypond[quote,ragged-right]
1284 musicA = {
1285   <<
1286     \relative c' {
1287       cis'8 fis, d'4 <a cis>8 f bis4 |
1288       cis2. <c, g'>4 |
1289     }
1290     \\
1291     \relative c' {
1292       ais'2 cis, |
1293       fis8 b a4 cis2 |
1294     }
1295   >>
1296 }
1297
1298 musicB = {
1299   \clef bass
1300   \new Voice {
1301     \voiceTwo \relative c' {
1302       <fis, a cis>4
1303       \change Staff = up
1304       cis'
1305       \change Staff = down
1306       <fis, a>
1307       \change Staff = up
1308       dis' |
1309       \change Staff = down
1310       <fis, a cis>4 gis <f a d>2 |
1311     }
1312   }
1313 }
1314
1315 \new PianoStaff {
1316   <<
1317     \context Staff = "up" {
1318       #(set-accidental-style 'modern)
1319       \musicA
1320     }
1321     \context Staff = "down" {
1322       #(set-accidental-style 'modern)
1323       \musicB
1324     }
1325   >>
1326 }
1327 @end lilypond
1328
1329 @item modern-cautionary
1330 @funindex modern-cautionary
1331
1332 This rule is similar to @code{modern}, but the @q{extra}
1333 accidentals (the ones not typeset by @code{default}) are typeset
1334 as cautionary accidentals.  They are by default printed with
1335 parentheses, but they can also be printed in reduced size by
1336 defining the @code{cautionary-style} property of
1337 @code{AccidentalSuggestion}.
1338
1339
1340 @lilypond[quote,ragged-right]
1341 musicA = {
1342   <<
1343     \relative c' {
1344       cis'8 fis, d'4 <a cis>8 f bis4 |
1345       cis2. <c, g'>4 |
1346     }
1347     \\
1348     \relative c' {
1349       ais'2 cis, |
1350       fis8 b a4 cis2 |
1351     }
1352   >>
1353 }
1354
1355 musicB = {
1356   \clef bass
1357   \new Voice {
1358     \voiceTwo \relative c' {
1359       <fis, a cis>4
1360       \change Staff = up
1361       cis'
1362       \change Staff = down
1363       <fis, a>
1364       \change Staff = up
1365       dis' |
1366       \change Staff = down
1367       <fis, a cis>4 gis <f a d>2 |
1368     }
1369   }
1370 }
1371
1372 \new PianoStaff {
1373   <<
1374     \context Staff = "up" {
1375       #(set-accidental-style 'modern-cautionary)
1376       \musicA
1377     }
1378     \context Staff = "down" {
1379       #(set-accidental-style 'modern-cautionary)
1380       \musicB
1381     }
1382   >>
1383 }
1384 @end lilypond
1385
1386 @item modern-voice
1387 @funindex modern-voice
1388
1389 This rule is used for multivoice accidentals to be read both by
1390 musicians playing one voice and musicians playing all voices.
1391 Accidentals are typeset for each voice, but they @emph{are}
1392 canceled across voices in the same @internalsref{Staff}.  Hence,
1393 the@tie{}@code{a} in the last measure is canceled because the
1394 previous cancellation was in a different voice, and
1395 the@tie{}@code{d} in the lower staff is canceled because of the
1396 accidental in a different voice in the previous measure:
1397
1398
1399 @lilypond[quote,ragged-right]
1400 musicA = {
1401   <<
1402     \relative c' {
1403       cis'8 fis, d'4 <a cis>8 f bis4 |
1404       cis2. <c, g'>4 |
1405     }
1406     \\
1407     \relative c' {
1408       ais'2 cis, |
1409       fis8 b a4 cis2 |
1410     }
1411   >>
1412 }
1413
1414 musicB = {
1415   \clef bass
1416   \new Voice {
1417     \voiceTwo \relative c' {
1418       <fis, a cis>4
1419       \change Staff = up
1420       cis'
1421       \change Staff = down
1422       <fis, a>
1423       \change Staff = up
1424       dis' |
1425       \change Staff = down
1426       <fis, a cis>4 gis <f a d>2 |
1427     }
1428   }
1429 }
1430
1431 \new PianoStaff {
1432   <<
1433     \context Staff = "up" {
1434       #(set-accidental-style 'modern-voice)
1435       \musicA
1436     }
1437     \context Staff = "down" {
1438       #(set-accidental-style 'modern-voice)
1439       \musicB
1440     }
1441   >>
1442 }
1443 @end lilypond
1444
1445 @funindex modern-voice-cautionary
1446 @item modern-voice-cautionary
1447
1448 This rule is the same as @code{modern-voice}, but with the extra
1449 accidentals (the ones not typeset by @code{voice}) typeset
1450 as cautionaries.  Even though all accidentals typeset by
1451 @code{default} @emph{are} typeset by this variable,
1452 some of them are typeset as cautionaries.
1453
1454 @lilypond[quote,ragged-right]
1455 musicA = {
1456   <<
1457     \relative c' {
1458       cis'8 fis, d'4 <a cis>8 f bis4 |
1459       cis2. <c, g'>4 |
1460     }
1461     \\
1462     \relative c' {
1463       ais'2 cis, |
1464       fis8 b a4 cis2 |
1465     }
1466   >>
1467 }
1468
1469 musicB = {
1470   \clef bass
1471   \new Voice {
1472     \voiceTwo \relative c' {
1473       <fis, a cis>4
1474       \change Staff = up
1475       cis'
1476       \change Staff = down
1477       <fis, a>
1478       \change Staff = up
1479       dis' |
1480       \change Staff = down
1481       <fis, a cis>4 gis <f a d>2 |
1482     }
1483   }
1484 }
1485
1486 \new PianoStaff {
1487   <<
1488     \context Staff = "up" {
1489       #(set-accidental-style 'modern-voice-cautionary)
1490       \musicA
1491     }
1492     \context Staff = "down" {
1493       #(set-accidental-style 'modern-voice-cautionary)
1494       \musicB
1495     }
1496   >>
1497 }
1498 @end lilypond
1499
1500 @item piano
1501 @funindex piano accidentals
1502
1503 This rule reflects twentieth-century practice for piano notation.
1504 Its behavior is very similar to @code{modern} style, but here
1505 accidentals also get canceled across the staves in the same
1506 GrandStaff or PianoStaff, hence all the cancellations of the final
1507 notes.
1508
1509 This accidental style takes place in a GrandStaff context.
1510 However, you have to explicitly set it for @emph{each} individual
1511 Staff of the GrandStaff:
1512
1513
1514 @example
1515 \new GrandStaff @{ <<
1516   \new Staff = "up" @{ <<
1517     #(set-accidental-style 'piano)
1518     @{ @dots{} @}
1519   >> @}
1520   \new Staff = "down" @{ <<
1521     #(set-accidental-style 'piano)
1522     @{ @dots{} @}
1523   >> @}
1524 >> @}
1525 @end example
1526
1527 @lilypond[quote,ragged-right]
1528 musicA = {
1529   <<
1530     \relative c' {
1531       cis'8 fis, d'4 <a cis>8 f bis4 |
1532       cis2. <c, g'>4 |
1533     }
1534     \\
1535     \relative c' {
1536       ais'2 cis, |
1537       fis8 b a4 cis2 |
1538     }
1539   >>
1540 }
1541
1542 musicB = {
1543   \clef bass
1544   \new Voice {
1545     \voiceTwo \relative c' {
1546       <fis, a cis>4
1547       \change Staff = up
1548       cis'
1549       \change Staff = down
1550       <fis, a>
1551       \change Staff = up
1552       dis' |
1553       \change Staff = down
1554       <fis, a cis>4 gis <f a d>2 |
1555     }
1556   }
1557 }
1558
1559 \new PianoStaff {
1560   <<
1561     \context Staff = "up" {
1562       #(set-accidental-style 'piano)
1563       \musicA
1564     }
1565     \context Staff = "down" {
1566       #(set-accidental-style 'piano)
1567       \musicB
1568     }
1569   >>
1570 }
1571 @end lilypond
1572
1573 @item piano-cautionary
1574 @funindex #(set-accidental-style 'piano-cautionary)
1575
1576 Same as @code{#(set-accidental-style 'piano)} but with the extra
1577 accidentals typeset as cautionaries.
1578
1579 @lilypond[quote,ragged-right]
1580 musicA = {
1581   <<
1582     \relative c' {
1583       cis'8 fis, d'4 <a cis>8 f bis4 |
1584       cis2. <c, g'>4 |
1585     }
1586     \\
1587     \relative c' {
1588       ais'2 cis, |
1589       fis8 b a4 cis2 |
1590     }
1591   >>
1592 }
1593
1594 musicB = {
1595   \clef bass
1596   \new Voice {
1597     \voiceTwo \relative c' {
1598       <fis, a cis>4
1599       \change Staff = up
1600       cis'
1601       \change Staff = down
1602       <fis, a>
1603       \change Staff = up
1604       dis' |
1605       \change Staff = down
1606       <fis, a cis>4 gis <f a d>2 |
1607     }
1608   }
1609 }
1610
1611 \new PianoStaff {
1612   <<
1613     \context Staff = "up" {
1614       #(set-accidental-style 'piano-cautionary)
1615       \musicA
1616     }
1617     \context Staff = "down" {
1618       #(set-accidental-style 'piano-cautionary)
1619       \musicB
1620     }
1621   >>
1622 }
1623 @end lilypond
1624
1625 @item no-reset
1626 @funindex no-reset accidental style
1627
1628 This is the same as @code{default} but with accidentals lasting
1629 @q{forever} and not only within the same measure:
1630
1631 @lilypond[quote,ragged-right]
1632 musicA = {
1633   <<
1634     \relative c' {
1635       cis'8 fis, d'4 <a cis>8 f bis4 |
1636       cis2. <c, g'>4 |
1637     }
1638     \\
1639     \relative c' {
1640       ais'2 cis, |
1641       fis8 b a4 cis2 |
1642     }
1643   >>
1644 }
1645
1646 musicB = {
1647   \clef bass
1648   \new Voice {
1649     \voiceTwo \relative c' {
1650       <fis, a cis>4
1651       \change Staff = up
1652       cis'
1653       \change Staff = down
1654       <fis, a>
1655       \change Staff = up
1656       dis' |
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       #(set-accidental-style 'no-reset)
1667       \musicA
1668     }
1669     \context Staff = "down" {
1670       #(set-accidental-style 'no-reset)
1671       \musicB
1672     }
1673   >>
1674 }
1675 @end lilypond
1676
1677 @item forget
1678 @funindex forget accidental style
1679
1680 This is the opposite of @code{no-reset}: Accidentals are not
1681 remembered at all -- and hence all accidentals are typeset
1682 relative to the key signature, regardless of what was before in
1683 the music:
1684
1685 @lilypond[quote,ragged-right]
1686 musicA = {
1687   <<
1688     \relative c' {
1689       cis'8 fis, d'4 <a cis>8 f bis4 |
1690       cis2. <c, g'>4 |
1691     }
1692     \\
1693     \relative c' {
1694       ais'2 cis, |
1695       fis8 b a4 cis2 |
1696     }
1697   >>
1698 }
1699
1700 musicB = {
1701   \clef bass
1702   \new Voice {
1703     \voiceTwo \relative c' {
1704       <fis, a cis>4
1705       \change Staff = up
1706       cis'
1707       \change Staff = down
1708       <fis, a>
1709       \change Staff = up
1710       dis' |
1711       \change Staff = down
1712       <fis, a cis>4 gis <f a d>2 |
1713     }
1714   }
1715 }
1716
1717 \new PianoStaff {
1718   <<
1719     \context Staff = "up" {
1720       #(set-accidental-style 'forget)
1721       \musicA
1722     }
1723     \context Staff = "down" {
1724       #(set-accidental-style 'forget)
1725       \musicB
1726     }
1727   >>
1728 }
1729 @end lilypond
1730 @end table
1731
1732
1733 @seealso
1734
1735 Snippets: @lsrdir{pitches}.
1736
1737 Internals reference: @internalsref{Accidental_engraver},
1738 @internalsref{Accidental}, @internalsref{AccidentalSuggestion},
1739 @internalsref{AccidentalPlacement}, @internalsref{GrandStaff} and
1740 @internalsref{PianoStaff}, @internalsref{Staff}.
1741
1742
1743 @refbugs
1744
1745 Simultaneous notes are considered to be entered in sequential
1746 mode.  This means that in a chord the accidentals are typeset as
1747 if the notes in the chord happen one at a time, in the order in
1748 which they appear in the input file.  This is a problem when
1749 accidentals in a chord depend on each other, which does not happen
1750 for the default accidental style.  The problem can be solved by
1751 manually inserting@tie{}@code{!} and@tie{}@code{?}  for the
1752 problematic notes.
1753
1754
1755 @node Ambitus
1756 @unnumberedsubsubsec Ambitus
1757 @cindex ambitus
1758
1759 The term @notation{ambitus} or @notation{ambit} denotes a range of
1760 pitches for a given voice in a part of music.  It may also denote
1761 the pitch range that a musical instrument is capable of playing.
1762 Ambits are printed on vocal parts, so performers can easily
1763 determine if it matches their capabilities.
1764
1765 Ambits are denoted at the beginning of a piece near the initial
1766 clef.  The range is graphically specified by two note heads that
1767 represent the minimum and maximum pitch.  To print such ambits,
1768 add the @code{Ambitus_engraver} to the @code{Voice} context, for
1769 example:
1770
1771 @lilypond[verbatim,quote,ragged-right]
1772 \layout {
1773   \context {
1774     \Staff
1775     \consists Ambitus_engraver
1776   }
1777 }
1778
1779 \relative \new Staff {
1780   as'' c e2 cis,2
1781 }
1782 @end lilypond
1783
1784 If you have multiple voices in a single staff and you want a
1785 single ambitus per staff rather than per voice, add the
1786 @code{Ambitus_engraver} to the @code{Staff} context rather than to
1787 the @code{Voice} context:
1788
1789 @lilypond[verbatim,quote,ragged-right]
1790 \new Staff \with {
1791   \consists "Ambitus_engraver"
1792 }
1793 <<
1794   \new Voice \with {
1795     \remove "Ambitus_engraver"
1796   } \relative c'' {
1797     \override Ambitus #'X-offset = #-1.0
1798     \voiceOne
1799     c4 a d e f2
1800   }
1801   \new Voice \with {
1802     \remove "Ambitus_engraver"
1803   } \relative c' {
1804     \voiceTwo
1805     es4 f g as b2
1806   }
1807 >>
1808 @end lilypond
1809
1810 @noindent
1811 This example uses one advanced feature,
1812
1813 @example
1814 \override Ambitus #'X-offset = #-1.0
1815 @end example
1816
1817 @noindent
1818 This code moves the ambitus to the left.  The same effect could
1819 have been achieved with @code{extra-offset}, but then the
1820 formatting system would not reserve space for the moved object.
1821
1822 @seealso
1823
1824 Snippets: @lsrdir{pitches}.
1825 @c FIXME: lsr stuff.
1826 @c @lsr{vocal,ambitus@/.ly}.
1827
1828 Internals reference: @internalsref{Ambitus},
1829 @internalsref{AmbitusLine}, @internalsref{AmbitusNoteHead},
1830 @internalsref{AmbitusAccidental}, @internalsref{Ambitus_engraver},
1831 @internalsref{Staff} and @internalsref{Voice}.
1832
1833
1834 @refbugs
1835
1836 There is no collision handling in the case of multiple per-voice
1837 ambitus.
1838
1839
1840 @node Note heads
1841 @subsection Note heads
1842
1843 @menu
1844 * Easy notation note heads::
1845 * Shape note heads::
1846 * Improvisation::
1847 * Special noteheads::
1848 @end menu
1849
1850 @node Easy notation note heads
1851 @unnumberedsubsubsec Easy notation note heads
1852
1853 @cindex note heads, practice
1854 @cindex note heads, easy notation
1855 @cindex easy notation
1856 @cindex Hal Leonard
1857
1858 The @q{easy play} note head includes a note name inside the head.
1859 It is used in music for beginners
1860
1861 @lilypond[verbatim,quote,ragged-right,fragment,staffsize=26]
1862 \setEasyHeads
1863 c'2 e'4 f' |
1864 g'1
1865 @end lilypond
1866
1867 The command @code{\setEasyHeads} overrides settings for the
1868 @code{NoteHead} object.  To make the letters readable, it
1869 has to be printed in a large font size.  To print with a larger
1870 font, see @ref{Setting the staff size}.
1871
1872 @refcommands
1873
1874 @funindex \setEasyHeads
1875 @code{\setEasyHeads}
1876
1877 @seealso
1878
1879 Notation Reference: @ref{Setting the staff size}.
1880
1881 Snippets: @lsrdir{pitches},
1882
1883 Internals reference: @internalsref{NoteHead}.
1884
1885
1886 @node Shape note heads
1887 @unnumberedsubsubsec Shape note heads
1888
1889 @cindex note heads, shape
1890
1891 In shape note head notation, the shape of the note head
1892 corresponds to the harmonic function of a note in the scale.  This
1893 notation was popular in nineteenth-century American song books.
1894
1895 Shape note heads can be produced by setting @code{\aikenHeads} or
1896 @code{\sacredHarpHeads}, depending on the style desired.
1897
1898 @lilypond[verbatim,fragment,relative=1]
1899 \aikenHeads
1900 c8 d4 e8 a2 g1
1901 \sacredHarpHeads
1902 c,8 d4. e8 a2 g1
1903 @end lilypond
1904
1905 Shapes are typeset according to the step in the scale, where
1906 the base of the scale is determined by the @code{\key} command.
1907
1908 @funindex \key
1909 @funindex shapeNoteStyles
1910 @funindex \aikenHeads
1911 @funindex \sacredHarpHeads
1912
1913 Shape note heads are implemented through the
1914 @code{shapeNoteStyles} property.  Its value is a vector of
1915 symbols.  The k-th element indicates the style to use for the k-th
1916 step of the scale.  Arbitrary combinations are possible, e.g.:
1917
1918 @lilypond[verbatim,fragment,relative=1]
1919 \set shapeNoteStyles =
1920   ##(cross triangle fa #f mensural xcircle diamond)
1921 c8 d4. e8 a2 g1
1922 @end lilypond
1923
1924 @seealso
1925
1926 Snippets: @lsrdir{pitches}.
1927
1928
1929 @node Improvisation
1930 @unnumberedsubsubsec Improvisation
1931
1932 Improvisation is sometimes denoted with slashed note heads.  Such
1933 note heads can be created by adding a @code{Pitch_squash_engraver}
1934 to the @code{Voice} context.  Then, the following command
1935
1936 @example
1937 \set squashedPosition = #0
1938 \override NoteHead #'style = #'slash
1939 @end example
1940
1941 @noindent
1942 switches on the slashes.
1943
1944 There are shortcuts @code{\improvisationOn} (and an accompanying
1945 @code{\improvisationOff}) for this command sequence.  They are
1946 used in the following example:
1947
1948 @lilypond[verbatim,quote,ragged-right]
1949 \new Voice \with {
1950   \consists Pitch_squash_engraver
1951 } \transpose c c' {
1952   e8 e g a a16(bes)(a8) g
1953   \improvisationOn
1954   e8
1955   ~e2~e8 f4 fis8
1956   ~fis2
1957   \improvisationOff
1958   a16(bes) a8 g e
1959 }
1960 @end lilypond
1961
1962 @seealso
1963
1964 Snippets: @lsrdir{pitches}.
1965
1966 Internals reference: @internalsref{Pitch_squash_engraver} and
1967 @internalsref{Voice}.
1968
1969 @node Special noteheads
1970 @unnumberedsubsubsec Special noteheads
1971
1972 @cindex note heads, special
1973
1974 Different noteheads are used by various instruments for various
1975 meanings -- crosses are used for @q{parlato} with vocalists,
1976 stopped notes on guitar; diamonds are used for harmonics on string
1977 instruments, etc.  There is a shorthand (@code{\harmonic}) for
1978 diamond shapes; the other notehead styles are produced by tweaking
1979 the property:
1980
1981 @lilypond[verbatim,quote,ragged-right,fragment,relative=1]
1982 c4 d
1983 \override NoteHead #'style = #'cross
1984 e f
1985 \revert NoteHead #'style
1986 e d <c f\harmonic> <d a'\harmonic>
1987 @end lilypond
1988
1989 @noindent
1990 To see all notehead styles, please see @ref{Note head styles}.
1991
1992
1993 @seealso
1994
1995 Snippets: @lsrdir{pitches}.
1996
1997 Notation Reference: @ref{Note head styles}.
1998
1999 Internals reference: @internalsref{NoteHead}.