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