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