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