]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/advanced-notation.itely
Whole bunch of minor fixes from mailist.
[lilypond.git] / Documentation / user / advanced-notation.itely
1 @c -*- coding: utf-8; mode: texinfo; -*-
2 @c This file is part of lilypond.tely
3
4 @c A menu is needed before every deeper *section nesting of @node's; run 
5 @c     M-x texinfo-all-menus-update
6 @c to automatically fill in these menus before saving changes
7
8
9 @node Advanced notation
10 @chapter Advanced notation
11
12 This chapter deals with rarely-used and advanced notation.
13
14 @menu
15 * Text::                        
16 * Preparing parts::             
17 * Orchestral music::            
18 * Contemporary notation::       
19 * Educational use::             
20 * Automatic notation::          
21 @end menu
22
23
24
25 @node Text
26 @section Text
27
28 This section explains how to include text (with various formatting) in
29 your scores.
30
31 @cindex Text, other languages
32 To write non-ascii text (such as characters from other languages), simply
33 insert the characters directly into the lilypond file.  The file must be
34 saved as UTF-8.  For more information, see @ref{Text encoding}.
35
36 @menu
37 * Text scripts::                
38 * Text spanners::               
39 * Text marks::                  
40 * Text markup::                 
41 * Nested scores::               
42 * Overview of text markup commands::  
43 * Font selection::              
44 * New dynamic marks::           
45 @end menu
46
47
48 @node Text scripts
49 @subsection Text scripts
50
51 @cindex Text scripts
52 @cindex text items, non-empty
53 @cindex non-empty texts
54
55 It is possible to place arbitrary strings of text or @ref{Text markup}
56 above or below notes by using a string @code{c^"text"}.  By default,
57 these indications do not influence the note spacing, but by using the
58 command @code{\fatText}, the widths will be taken into account
59
60 @lilypond[quote,fragment,ragged-right,verbatim,relative=1]
61 c4^"longtext" \fatText c4_"longlongtext" c4
62 @end lilypond
63
64 @noindent
65 To prevent text from influencing spacing, use @code{\emptyText}.
66
67 More complex formatting may also be added to a note by using the
68 markup command,
69 @lilypond[fragment,ragged-right,verbatim,quote]
70 c'4^\markup { bla \bold bla }
71 @end lilypond
72
73 The @code{\markup} is described in more detail in
74 @ref{Text markup}.
75
76
77 @refcommands
78
79 @cindex @code{\fatText}
80 @code{\fatText},
81 @cindex @code{\emptyText}
82 @code{\emptyText}.
83
84
85 @commonprop
86
87 Checking to make sure that text scripts and lyrics are within the margins is a relatively large computational task.  To speed up processing, lilypond does not perform such calculations by default; to enable it, use
88
89 @example
90 \override Score.PaperColumn #'keep-inside-line = ##t
91 @end example
92
93
94 @seealso
95
96 In this manual: @ref{Text markup}.
97
98 Program reference: @internalsref{TextScript}.
99
100
101 @node Text spanners
102 @subsection Text spanners
103
104 @cindex Text spanners
105
106 Some performance indications, e.g., @i{rallentando} or @i{accelerando},
107 are written as text and are extended over many measures with dotted
108 lines.  Such texts are created using text spanners; attach
109 @code{\startTextSpan} and @code{\stopTextSpan} to the first and last
110 notes of the spanner.
111
112 The string to be printed, as well as the style, is set through object
113 properties
114
115 @lilypond[quote,ragged-right,fragment,relative=1,verbatim]
116 c1
117 \textSpannerDown
118 \override TextSpanner #'edge-text = #'("rall " . "")
119 c2\startTextSpan b c\stopTextSpan a
120 \break
121 \textSpannerUp
122 \override TextSpanner #'edge-text = #(cons (markup #:italic "rit" ) "")
123 c2\startTextSpan b c\stopTextSpan a
124 @end lilypond
125
126 @refcommands
127
128 @cindex textSpannerUp
129 @code{textSpannerUp},
130 @cindex textSpannerDown 
131 @code{textSpannerDown},
132 @cindex textSpannerNeutral
133 @code{textSpannerNeutral}.
134
135
136 @commonprop
137
138 To print a solid line, use
139
140 @example
141 \override TextSpanner #'dash-fraction = #'() 
142 @end example
143
144
145 @seealso
146
147 Program reference: @internalsref{TextSpanner}.
148
149 Examples: @inputfileref{input/@/regression,text@/-spanner@/.ly}.
150
151
152 @node Text marks
153 @subsection Text marks
154
155 @cindex coda on bar line
156 @cindex segno on bar line
157 @cindex fermata on bar line
158 @cindex bar lines, symbols on
159 @cindex @code{\mark}
160
161 The @code{\mark} command is primarily used for
162 @ref{Rehearsal marks},
163 but it can also be used to put signs like coda,
164 segno, and fermata on a bar line.  Use @code{\markup} to
165 access the appropriate symbol
166
167 @lilypond[fragment,quote,ragged-right,verbatim,relative=2]
168 c1 \mark \markup { \musicglyph #"scripts.ufermata" }
169 c1
170 @end lilypond
171
172 @noindent
173 @code{\mark} is only typeset above the top stave of the score.  If
174 you specify the @code{\mark} command at a bar line, the resulting
175 mark is placed above the bar line.  If you specify it in the middle
176 of a bar, the resulting mark is positioned between notes.  If it is
177 specified before the beginning of a score line, it is placed
178 before the first note of the line.  Finally, if the mark occurs at
179 a line break, the mark will be printed at the
180 beginning of the next line.
181 @c  IMO this is a bug; hopefully it'll be fixed soon, so I can
182 @c  delete this sentence.   -gp
183 If there is no next line, then the mark will not be printed at all.
184
185
186 @commonprop
187
188 To print the mark at the end of the current line, use
189
190 @example
191 \override Score.RehearsalMark
192   #'break-visibility = #begin-of-line-invisible
193 @end example
194
195 @code{\mark} is often useful for adding text to the end of bar.  In
196 such cases, changing the @code{#'self-alignment} is very useful
197
198 @lilypond[fragment,quote,ragged-right,verbatim,relative=2]
199 \override Score.RehearsalMark
200   #'break-visibility = #begin-of-line-invisible
201 c1 c c c4 c c c
202 \once \override Score.RehearsalMark #'self-alignment-X = #right
203 \mark "D.S. al Fine "
204 @end lilypond
205
206 Text marks may be aligned with notation objects other than
207 bar lines,
208
209 @lilypond[fragment,quote,ragged-right,verbatim,relative=2]
210 \relative {
211   c1
212   \key cis \major
213   \clef alto
214   \override Score.RehearsalMark #'break-align-symbol = #'key-signature
215   \mark "on key"
216   cis
217   \key ces \major
218   \override Score.RehearsalMark #'break-align-symbol = #'clef
219   \clef treble
220   \mark "on clef"
221   ces
222   \override Score.RehearsalMark #'break-align-symbol = #'time-signature
223   \key d \minor
224   \clef tenor
225   \time 3/4
226   \mark "on time"
227   c
228 }
229 @end lilypond
230
231 Although text marks are normally only printed above the topmost
232 staff, you may alter this to print them on every staff,
233
234 @lilypond[quote,ragged-right,verbatim,relative=2]
235 {
236   \new Score \with {
237     \remove "Mark_engraver"
238   }
239   <<
240     \new Staff \with {
241       \consists "Mark_engraver"
242     }
243     { c''1 \mark "foo" c'' }
244     \new Staff \with {
245       \consists "Mark_engraver"
246     }
247     { c'1 \mark "foo" c' }
248   >>
249 }
250 @end lilypond
251
252
253 @seealso
254
255 Program reference: @internalsref{RehearsalMark}.
256
257
258 @node Text markup
259 @subsection Text markup
260
261 @cindex markup
262 @cindex text markup
263 @cindex markup text
264 @cindex typeset text
265
266 Use @code{\markup} to typeset text.  Commands are entered with the
267 backslash @code{\}.  To enter @code{\} and @code{#}, use double
268 quotation marks.
269
270 @lilypond[quote,verbatim,fragment,relative=1]
271 c1^\markup { hello }
272 c1_\markup { hi there }
273 c1^\markup { hi \bold there, is \italic anyone home? }
274 c1_\markup { "\special #characters" }
275 @end lilypond
276
277 @noindent
278 See @ref{Overview of text markup commands} for a list of all
279 commands.
280
281 @code{\markup} is primarily used for @internalsref{TextScript}s,
282 but it can also be used anywhere text is called in lilypond
283
284 @lilypond[quote,verbatim]
285 \header{ title = \markup{ \bold { foo \italic { bar! } } } }
286 \score{
287   \relative c'' {
288     \override Score.RehearsalMark
289       #'break-visibility = #begin-of-line-invisible
290     \override Score.RehearsalMark #'self-alignment-X = #right
291
292     \set Staff.instrument = \markup{ \column{ Alto solo } }
293     c2^\markup{ don't be \flat }
294     \override TextSpanner #'edge-text = #(cons (markup #:italic "rit" ) "")
295     b2\startTextSpan
296     a2\mark \markup{ \large \bold Fine }
297     r2\stopTextSpan
298     \bar "||"
299   }
300   \addlyrics { bar, foo \markup{ \italic bar! } }
301 }
302 @end lilypond
303
304 Text can also be placed on its own, away from any @code{\score}
305 block.  This is primarily used in a @code{\book} (see
306 @ref{Multiple movements}).
307
308 @lilypond[quote,ragged-right,verbatim]
309 \markup{ Here is some text. }
310 @end lilypond
311
312 @cindex font switching
313
314 The markup in the example demonstrates font switching commands.  The
315 command @code{\bold} and @code{\italic} apply to the first following 
316 word only; to apply a command to more than one word, enclose the
317 words with braces,
318
319 @example
320 \markup @{ \bold @{ hi there @} @}
321 @end example
322
323 @noindent
324 For clarity, you can also do this for single arguments, e.g.,
325
326 @example
327 \markup @{ is \italic @{ anyone @} home @}
328 @end example
329
330 In markup mode you can compose expressions, similar to mathematical
331 expressions, XML documents, and music expressions.  You can stack
332 expressions grouped vertically with the command @code{\column}.
333 Similarly, @code{\center-align} aligns texts by their center lines:
334
335 @lilypond[quote,verbatim,fragment,relative=1]
336 c1^\markup { \column { a bbbb \line { c d } } }
337 c1^\markup { \center-align { a bbbb c } }
338 c1^\markup { \line { a b c } }
339 @end lilypond
340
341 Lists with no previous command are not kept distinct.  The expression
342
343 @example
344 \center-align @{ @{ a b @} @{ c d @} @} 
345 @end example
346
347 @noindent
348
349 is equivalent to
350
351 @example
352 \center-align @{ a b c d @}
353 @end example
354
355 @noindent
356
357 To keep lists of words distinct, please use quotes @code{"} or
358 the @code{\line} command
359
360 @lilypond[quote,verbatim,fragment,relative=1]
361 \fatText
362 c4^\markup{ \center-align { on three lines } }
363 c4^\markup{ \center-align { "all one line" } }
364 c4^\markup{ \center-align { { on three lines } } }
365 c4^\markup{ \center-align { \line { on one line } } }
366 @end lilypond
367
368 Markups can be stored in variables and these variables
369 may be attached to notes, like
370 @example
371 allegro = \markup @{ \bold \large @{ Allegro @} @}
372  @{ a^\allegro b c d @}
373 @end example
374
375 Some objects have alignment procedures of their own, which cancel out
376 any effects of alignments applied to their markup arguments as a
377 whole.  For example, the @internalsref{RehearsalMark} is horizontally
378 centered, so using @code{\mark \markup @{ \left-align .. @}} has no
379 effect.
380
381 In addition, vertical placement is performed after creating the
382 text markup object.  If you wish to move an entire piece of markup,
383 you need to use the #'padding property or create an "anchor" point
384 inside the markup (generally with @code{\hspace #0}).
385
386 @lilypond[quote,verbatim,fragment,relative=1]
387 \fatText
388 c'4^\markup{ \raise #5 "not raised" }
389 \once \override TextScript #'padding = #3
390 c'4^\markup{ raised }
391 c'4^\markup{ \hspace #0 \raise #1.5 raised }
392 @end lilypond
393
394 Some situations (such as dynamic marks) have preset font-related
395 properties.  If you are creating text in such situations, it
396 is advisable to cancel those properties with
397 @code{normal-text}.  See @ref{Overview of text markup commands}
398 for more details.
399
400
401 @seealso
402
403 This manual: @ref{Overview of text markup commands}.
404
405 Program reference: @internalsref{TextScript}.
406
407 Init files: @file{scm/@/new@/-markup@/.scm}.
408
409
410 @refbugs
411
412 Kerning or generation of ligatures is only done when the @TeX{}
413 backend is used.  In this case, LilyPond does not account for them so
414 texts will be spaced slightly too wide.
415
416 Syntax errors for markup mode are confusing.
417
418
419 @node Nested scores
420 @subsection Nested scores
421
422 It is possible to nest music inside markups, by adding a @code{\score}
423 block to a markup expression.  Such a score must contain a @code{\layout}
424 block.
425
426 @lilypond[quote,verbatim,ragged-right]
427 \relative {
428   c4 d^\markup {
429     \score {
430       \relative { c4 d e f }
431       \layout { }
432     }
433   }
434   e f
435 }
436 @end lilypond
437
438
439 @node Overview of text markup commands
440 @subsection Overview of text markup commands
441
442 The following commands can all be used inside @code{\markup @{ @}}.
443
444 @include markup-commands.tely
445
446
447 @node Font selection
448 @subsection Font selection
449
450 @cindex font selection
451 @cindex font magnification
452 @cindex @code{font-interface}
453
454 By setting the object properties described below, you can select a
455 font from the preconfigured font families.  LilyPond has default
456 support for the feta music fonts. Text fonts are selected through
457 Pango/FontConfig. The serif font defaults to New Century Schoolbook,
458 the sans and typewriter to whatever the Pango installation defaults
459 to.
460
461
462 @itemize @bullet
463 @item @code{font-encoding}
464 is a symbol that sets layout of the glyphs.  This should only be set to
465 select different types of non-text fonts, e.g.
466
467 @code{fetaBraces} for piano staff braces, @code{fetaMusic} the
468 standard music font, including ancient glyphs, @code{fetaDynamic} for
469 dynamic signs and @code{fetaNumber} for the number font.
470
471 @item @code{font-family}
472 is a symbol indicating the general class of the typeface.  Supported are
473 @code{roman} (Computer Modern), @code{sans}, and @code{typewriter}.
474   
475 @item @code{font-shape}
476 is a symbol indicating the shape of the font.  There are typically
477 several font shapes available for each font family.  Choices are
478 @code{italic}, @code{caps}, and @code{upright}.
479
480 @item @code{font-series}
481 is a symbol indicating the series of the font.  There are typically
482 several font series for each font family and shape.  Choices are
483 @code{medium} and @code{bold}. 
484
485 @end itemize
486
487 Fonts selected in the way sketched above come from a predefined style
488 sheet. If you want to use a font from outside the style sheet, 
489 then set the 
490 @code{font-name} property, 
491
492 @lilypond[fragment,verbatim]
493 {
494   \override Staff.TimeSignature #'font-name = #"Charter"
495   \override Staff.TimeSignature #'font-size = #2
496   \time 3/4
497   c'1_\markup {
498     \override #'(font-name . "Vera Bold")
499       { This text is in Vera Bold }
500   }
501 }
502 @end lilypond
503
504 @noindent
505 Any font can be used, as long as it is available to Pango/FontConfig.
506
507 The size of the font may be set with the @code{font-size}
508 property. The resulting size is taken relative to the
509 @code{text-font-size} as defined in the @code{\paper} block.
510
511 @cindex font size
512 @cindex font magnification
513
514
515 It is also possible to change the default font family for the entire
516 document. This is done by calling the @code{make-pango-font-tree} from
517 within the @code{\paper} block. The function takes names for the font
518 families to use for roman, sans serif and monospaced text. For
519 example,
520
521 @cindex font families, setting
522 @cindex Pango
523
524
525 @lilypond[verbatim]
526 \paper  {
527   myStaffSize = #20
528   
529   #(define fonts
530     (make-pango-font-tree "Times New Roman"
531                           "Nimbus Sans"
532                           "Luxi Mono"
533                            (/ myStaffSize 20)))
534 }
535
536 {
537   c'^\markup { roman: foo \sans bla \typewriter bar }
538 }
539 @end lilypond
540
541 @c we don't do Helvetica / Courier, since GS incorrectly loads
542 @c Apple TTF fonts  
543
544
545
546 @seealso
547
548 Examples: @inputfileref{input/@/regression,font@/-family@/-override.ly}.
549
550
551 @node New dynamic marks
552 @subsection New dynamic marks
553
554 It is possible to print new dynamic marks or text that should be aligned
555 with dynamics.  Use @code{make-dynamic-script} to create these
556 marks.  Note that the dynamic font only contains the characters
557 @code{f,m,p,r,s} and @code{z}.
558
559 Some situations (such as dynamic marks) have preset font-related
560 properties.  If you are creating text in such situations, it
561 is advisable to cancel those properties with
562 @code{normal-text}.  See @ref{Overview of text markup commands}
563 for more details.
564
565 @cindex make-dynamic-script
566
567 @lilypond[quote,verbatim,ragged-right]
568 sfzp = #(make-dynamic-script "sfzp")
569 \relative c' {
570   c4 c c\sfzp c
571 }
572 @end lilypond
573
574 @cindex Dynamics, editorial
575 @cindex Dynamics, parenthesis
576
577 It is also possible to print dynamics in round parenthesis or square
578 brackets.  These are often used for adding editorial dynamics.
579
580 @lilypond[quote,verbatim,ragged-right]
581 rndf = \markup{ \center-align {\line { \bold{\italic (}
582   \dynamic f \bold{\italic )} }} }
583 boxf = \markup{ \bracket { \dynamic f } }
584 { c'1_\rndf c'1_\boxf }
585 @end lilypond
586
587
588
589 @node Preparing parts
590 @section Preparing parts
591
592 This section describes various notation that are useful for preparing
593 individual parts.
594
595 @menu
596 * Multi measure rests::         
597 * Metronome marks::             
598 * Rehearsal marks::             
599 * Bar numbers::                 
600 * Instrument names::            
601 * Instrument transpositions::   
602 * Ottava brackets::             
603 * Different editions from one source::  
604 @end menu
605
606
607 @node Multi measure rests
608 @subsection Multi measure rests
609
610 @cindex multi measure rests
611 @cindex full measure rests
612 @cindex Rests, multi measure
613 @cindex Rests, full measure
614 @cindex whole rests for a full measure
615 @cindex @code{R}
616
617 Rests for one full measure (or many bars) are entered using `@code{R}'.  It
618 is specifically meant for full bar rests and for entering parts: the rest
619 can expand to fill a score with rests, or it can be printed as a single
620 multi-measure rest.  This expansion is controlled by the property
621 @code{Score.skipBars}.  If this is set to true, empty measures will not
622 be expanded, and the appropriate number is added automatically
623
624 @lilypond[quote,ragged-right,fragment,verbatim]
625 \time 4/4 r1 | R1 | R1*2 \time 3/4 R2. \time 2/4 R2 \time 4/4
626 \set Score.skipBars = ##t R1*17 R1*4
627 @end lilypond
628
629 The @code{1} in @code{R1} is similar to the duration notation used for
630 notes.  Hence, for time signatures other than 4/4, you must enter other
631 durations.  This can be done with augmentation dots or fractions
632
633 @lilypond[quote,ragged-right,fragment,verbatim]
634 \set Score.skipBars = ##t
635 \time 3/4
636 R2. | R2.*2
637 \time 13/8
638 R1*13/8
639 R1*13/8*12 |
640 \time 10/8 R4*5*4 |
641 @end lilypond
642
643 An @code{R} spanning a single measure is printed as either a whole rest
644 or a breve, centered in the measure regardless of the time signature.
645
646 If there are only a few measures of rest, LilyPond prints ``church rests''
647 (a series of rectangles) in the staff.  To replace that with a simple
648 rest, use @code{MultiMeasureRest.expand-limit}.
649
650 @lilypond[quote,ragged-right,fragment,verbatim]
651 \set Score.skipBars = ##t
652 R1*2 | R1*5 | R1*9
653 \override MultiMeasureRest #'expand-limit = 1
654 R1*2 | R1*5 | R1*9
655 @end lilypond
656
657 @cindex text on multi-measure rest
658 @cindex script on multi-measure rest
659 @cindex fermata on multi-measure rest
660
661 Texts can be added to multi-measure rests by using the
662 @var{note}-@code{markup} syntax @ref{Text markup}.
663 A variable (@code{\fermataMarkup}) is provided for
664 adding fermatas
665
666 @lilypond[quote,ragged-right,verbatim,fragment]
667 \set Score.skipBars = ##t
668 \time 3/4
669 R2.*10^\markup { \italic "ad lib." }
670 R2.^\fermataMarkup
671 @end lilypond
672
673 Warning!  This text is created by @code{MultiMeasureRestText}, not
674 @code{TextScript}.
675
676 @lilypond[quote,ragged-right,verbatim,fragment]
677 \override TextScript #'padding = #5
678 R1^"low"
679 \override MultiMeasureRestText #'padding = #5
680 R1^"high"
681 @end lilypond
682
683 If you want to have text on the left end of a multi-measure rest,
684 attach the text to a zero-length skip note, i.e.,
685
686 @example
687 s1*0^"Allegro"
688 R1*4
689 @end example
690
691
692 @seealso
693
694 Program reference: @internalsref{MultiMeasureRestMusicGroup},
695 @internalsref{MultiMeasureRest}.
696
697 The layout object @internalsref{MultiMeasureRestNumber} is for the
698 default number, and @internalsref{MultiMeasureRestText} for user
699 specified texts.
700
701
702 @refbugs
703
704 It is not possible to use fingerings (e.g., @code{R1-4}) to put numbers
705 over multi-measure rests.  And the pitch of multi-measure rests (or
706 staff-centered rests) can not be influenced.
707
708 @cindex condensing rests
709
710 There is no way to automatically condense multiple rests into a single
711 multi-measure rest.  Multi-measure rests do not take part in rest
712 collisions.
713
714 Be careful when entering multi-measure rests followed by whole
715 notes.  The following will enter two notes lasting four measures each
716 @example
717 R1*4 cis cis
718 @end example
719 When @code{skipBars} is set, the result will look OK, but the bar
720 numbering will be off.
721
722
723 @node Metronome marks
724 @subsection Metronome marks
725
726 @cindex Tempo
727 @cindex beats per minute
728 @cindex metronome marking
729
730 Metronome settings can be entered as follows
731 @example
732 \tempo @var{duration} = @var{per-minute}
733 @end example
734
735 In the MIDI output, they are interpreted as a tempo change.  In the
736 layout output, a metronome marking is printed
737 @cindex @code{\tempo}
738 @lilypond[quote,ragged-right,verbatim,fragment]
739 \tempo 8.=120 c''1
740 @end lilypond
741
742
743 @commonprop
744
745 To change the tempo in the MIDI output without printing anything, make
746 the metronome marking invisible
747 @example
748 \once \override Score.MetronomeMark #'transparent = ##t
749 @end example
750
751 To print other metronome markings, use these markup commands
752 @lilypond[quote,ragged-right,verbatim,relative,fragment]
753 c4^\markup {
754   (
755   \smaller \general-align #Y #DOWN \note #"16." #1
756   =
757   \smaller \general-align #Y #DOWN \note #"8" #1
758   ) }
759 @end lilypond
760
761 @noindent
762 See @ref{Text markup} for more details.
763
764
765 @seealso
766
767 Program reference: @internalsref{MetronomeMark}.
768
769
770 @refbugs
771
772 Collisions are not checked.  If you have notes above the top line of
773 the staff (or notes with articulations, slurs, text, etc), then the
774 metronome marking may be printed on top of musical symbols.  If this
775 occurs, increase the padding of the metronome mark to place it 
776 further away from the staff.
777
778 @example
779 \override Score.MetronomeMark #'padding = #2.5
780 @end example
781
782
783 @node Rehearsal marks
784 @subsection Rehearsal marks
785
786 @cindex Rehearsal marks
787 @cindex @code{\mark}
788
789 To print a rehearsal mark, use the @code{\mark} command
790
791 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
792 c1 \mark \default
793 c1 \mark \default
794 c1 \mark #8
795 c1 \mark \default
796 c1 \mark \default
797 @end lilypond
798
799 @noindent
800 The letter@tie{}`I' is skipped in accordance with engraving traditions.
801 If you wish to include the letter `I', then use
802
803 @example
804 \set Score.markFormatter = #format-mark-alphabet
805 @end example
806
807 The mark is incremented automatically if you use @code{\mark
808 \default}, but you can also use an integer argument to set the mark
809 manually.  The value to use is stored in the property
810 @code{rehearsalMark}.
811
812 The style is defined by the property @code{markFormatter}.  It is a
813 function taking the current mark (an integer) and the current context
814 as argument.  It should return a markup object.  In the following
815 example, @code{markFormatter} is set to a canned procedure.  After a
816 few measures, it is set to function that produces a boxed number.
817
818 @lilypond[fragment,quote,ragged-right,verbatim,relative=2]
819 \set Score.markFormatter = #format-mark-numbers
820 c1 \mark \default
821 c1 \mark \default
822 \set Score.markFormatter = #format-mark-box-numbers
823 c1 \mark \default
824 c1 \mark \default
825 c1
826 @end lilypond
827
828 The file @file{scm/@/translation@/-functions@/.scm} contains the definitions
829 of @code{format-mark-numbers} (the default format), @code{format-mark-box-numbers},
830 @code{format-mark-letters} and @code{format-mark-box-letters}.
831 These can be used as inspiration for other formatting functions.
832
833 You may use @code{format-mark-barnumbers}, @code{format-mark-box-barnumbers},
834 and @code{format-mark-circle-barnumbers} to get bar numbers instead of
835 incremented numbers or letters.
836
837
838 @seealso
839
840 Program reference: @internalsref{RehearsalMark}.
841
842 Init files: @file{scm/@/translation@/-functions@/.scm} contains the
843 definition of @code{format-mark-numbers} and
844 @code{format-mark-letters}.  They can be used as inspiration for other
845 formatting functions.
846
847 Examples: @inputfileref{input/@/regression,rehearsal@/-mark@/-letter@/.ly},
848
849 @inputfileref{input/@/regression,rehearsal@/-mark@/-number@/.ly}.
850
851
852 @node Bar numbers
853 @subsection Bar numbers
854
855 @cindex Bar numbers
856 @cindex measure numbers
857 @cindex @code{currentBarNumber}
858
859 Bar numbers are printed by default at the start of the line.  The
860 number itself is stored in the @code{currentBarNumber} property, which
861 is normally updated automatically for every measure.
862
863 Bar numbers can be typeset at regular intervals instead of at the
864 beginning of each line.  This is illustrated in the following example,
865 whose source is available as
866 @inputfileref{input/@/test,bar@/-number@/-regular@/-interval@/.ly}
867
868 @lilypondfile[ragged-right,quote]{bar-number-regular-interval.ly}
869
870 Bar numbers can be typeset manually by tweaking the
871 @code{markFormatter} property
872
873 @lilypond[verbatim,ragged-right,quote]
874 \relative c' {
875   \set Score.markFormatter
876     = #(lambda (mark context)
877       (make-bold-markup
878         (make-box-markup
879           (number->string (ly:context-property context
880                                                'currentBarNumber)))))
881
882   c1 \bar "||" \mark \default c1 c1 \mark \default c1 \bar "|."
883 }
884 @end lilypond
885
886 Bar numbers can be manually changed by setting the
887 @code{Staff.currentBarNumber} property
888
889 @lilypond[verbatim,ragged-right,quote]
890 \relative c' {
891   \repeat unfold 4 {c4 c c c} \break
892   \set Score.currentBarNumber = #50
893   \repeat unfold 4 {c4 c c c}
894 }
895 @end lilypond
896
897 Bar numbers can be removed entirely by removing the Bar number
898 engraver from the score.
899
900 @lilypond[verbatim,ragged-right,quote,relative=2]
901 \layout {
902   \context {
903     \Score
904     \remove "Bar_number_engraver"
905   }
906 }
907 {
908 c4 c c c \break
909 c4 c c c
910 }
911 @end lilypond
912
913
914 @seealso
915
916 Program reference: @internalsref{BarNumber}.
917
918 Examples:
919 @inputfileref{input/@/test,bar@/-number@/-every@/-five@/-reset@/.ly},
920 and @inputfileref{input/@/test,bar@/-number@/-regular@/-interval@/.ly}.
921
922
923 @refbugs
924
925 Bar numbers can collide with the @internalsref{StaffGroup} bracket, if
926 there is one at the top.  To solve this, the
927 @code{padding} property of @internalsref{BarNumber} can be
928 used to position the number correctly.
929
930
931 @node Instrument names
932 @subsection Instrument names
933
934 In an orchestral score, instrument names are printed at the left side
935 of the staves.
936
937 This can be achieved by setting @internalsref{Staff}.@code{instrument}
938 and @internalsref{Staff}.@code{instr}.  This will print a string before
939 the start of the staff.  For the first staff, @code{instrument} is
940 used, for the following ones, @code{instr} is used.
941
942 @lilypond[quote,verbatim,ragged-right,relative=1,fragment]
943 \set Staff.instrument = "Ploink "
944 \set Staff.instr = "Plk "
945 c1
946 \break
947 c''
948 @end lilypond
949
950 You can also use markup texts to construct more complicated instrument
951 names, for example
952
953 @lilypond[quote,fragment,verbatim,ragged-right]
954 \set Staff.instrument = \markup {
955   \column { "Clarinetti"
956             \line { "in B" \smaller \flat } } }
957 c''1
958 @end lilypond
959
960 If you wish to center the instrument names, you must center all of them
961
962 @lilypond[quote,verbatim,ragged-right]
963 { <<
964 \new Staff {
965   \set Staff.instrument = \markup {
966     \center-align { "Clarinetti"
967       \line { "in B" \smaller \flat } } }
968   c''1
969 }
970 \new Staff {
971   \set Staff.instrument = \markup{ \center-align { Vibraphone }}
972   c''1
973 }
974 >>
975 }
976 @end lilypond
977
978 For longer instrument names, it may be useful to increase the
979 @code{indent} setting in the @code{\layout} block.
980
981 To center instrument names while leaving extra space to the right,
982
983 @lilypond[quote,verbatim,ragged-right]
984 \new StaffGroup \relative
985 <<
986   \new Staff {
987     \set Staff.instrument
988     = \markup { \hcenter-in #10 "blabla" }
989     c1 c1
990   }
991   \new Staff {
992     \set Staff.instrument
993     = \markup { \hcenter-in #10 "blo" }
994     c1 c1
995   }
996 >>
997 @end lilypond
998
999
1000 @seealso
1001
1002 Program reference: @internalsref{InstrumentName}.
1003
1004 @refbugs
1005
1006 When you put a name on a grand staff or piano staff, the width of the
1007 brace is not taken into account. The following property setting can be
1008 used to move the instrument names to the left, in such situations.
1009
1010 @example
1011 \override Score.InstrumentName #'space-alist = #'((left-edge extra-space . 2.0))
1012 @end example
1013
1014
1015 @node Instrument transpositions
1016 @subsection Instrument transpositions
1017
1018 @cindex transposition, MIDI
1019 @cindex transposition, instrument
1020
1021 The key of a transposing instrument can also be specified.  This
1022 applies to many wind instruments, for example, clarinets (B-flat, A, and
1023 E-flat), horn (F) and trumpet (B-flat, C, D, and E-flat).
1024
1025 The transposition is entered after the keyword @code{\transposition}
1026
1027 @example
1028 \transposition bes   %% B-flat clarinet
1029 @end example
1030
1031 @noindent
1032 This command sets the property @code{instrumentTransposition}.  The value of
1033 this property is used for MIDI output and quotations.  It does not
1034 affect how notes are printed in the current staff.  To change the printed
1035 output, see @ref{Transpose}.
1036
1037 The pitch to use for @code{\transposition} should correspond to the
1038 real sound heard when a @code{c'} written on the staff is played by the
1039 transposing instrument.  For example, when entering a score in
1040 concert pitch, typically all voices are entered in C, so
1041 they should be entered as
1042
1043 @example
1044 clarinet = @{
1045   \transposition c'
1046   ...
1047 @}
1048 saxophone = @{
1049   \transposition c'
1050   ...
1051 @}
1052 @end example
1053
1054 The command @code{\transposition} should be used when the music is
1055 entered from a (transposed) orchestral part.  For example, in
1056 classical horn parts, the tuning of the instrument is often changed
1057 during a piece.  When copying the notes from the part, use
1058 @code{\transposition}, e.g.,
1059
1060 @example
1061 \transposition d'
1062 c'4^"in D"
1063 ...
1064 \transposition g'
1065 c'4^"in G"
1066 ...
1067 @end example
1068
1069
1070 @node Ottava brackets
1071 @subsection Ottava brackets
1072
1073 `Ottava' brackets introduce an extra transposition of an octave for
1074 the staff.  They are created by invoking the function
1075 @code{set-octavation}
1076
1077 @cindex ottava
1078 @cindex 15ma
1079 @cindex octavation
1080
1081 @lilypond[quote,ragged-right,verbatim,fragment]
1082 \relative c''' {
1083   a2 b
1084   #(set-octavation 1)
1085   a b
1086   #(set-octavation 0)
1087   a b
1088 }
1089 @end lilypond
1090
1091 The @code{set-octavation} function also takes -1 (for 8va bassa) and 2
1092 (for 15ma) as arguments.  Internally the function sets the properties
1093 @code{ottavation} (e.g., to @code{"8va"}) and
1094 @code{centralCPosition}.  For overriding the text of the bracket, set
1095 @code{ottavation} after invoking @code{set-octavation}, i.e.,
1096
1097 @lilypond[quote,ragged-right,verbatim]
1098 {
1099   #(set-octavation 1)
1100   \set Staff.ottavation = #"8"
1101   c'''
1102 }
1103 @end lilypond
1104
1105
1106 @seealso
1107
1108 Program reference: @internalsref{OttavaBracket}.
1109
1110 Examples: @inputfileref{input/@/regression,ottava@/.ly},
1111 @inputfileref{input/@/regression,ottava@/-broken@/.ly}.
1112
1113
1114 @refbugs
1115
1116 @code{set-octavation} will get confused when clef changes happen
1117 during an octavation bracket.
1118
1119
1120 @node Different editions from one source
1121 @subsection Different editions from one source
1122
1123 @cindex @code{\tag}
1124 @cindex tag
1125
1126 The @code{\tag} command marks music expressions with a name.  These
1127 tagged expressions can be filtered out later.  With this mechanism it
1128 is possible to make different versions of the same music source.
1129
1130 In the following example, we see two versions of a piece of music, one
1131 for the full score, and one with cue notes for the instrumental part
1132
1133 @example
1134 c1
1135 <<
1136   \tag #'part <<
1137     R1 \\
1138     @{
1139       \set fontSize = #-1
1140       c4_"cue" f2 g4 @}
1141   >>
1142   \tag #'score R1
1143 >>
1144 c1
1145 @end example
1146
1147 The same can be applied to articulations, texts, etc.: they are
1148 made by prepending
1149 @example
1150 -\tag #@var{your-tag}
1151 @end example
1152 to an articulation, for example,
1153 @example
1154 c1-\tag #'part ^4
1155 @end example
1156
1157 This defines a note with a conditional fingering indication.
1158
1159 @cindex keepWithTag
1160 @cindex removeWithTag
1161 By applying the @code{\keepWithTag} and @code{\removeWithTag}
1162 commands, tagged expressions can be filtered.  For example,
1163 @example
1164 <<
1165   @var{the music}
1166   \keepWithTag #'score @var{the music}
1167   \keepWithTag #'part @var{the music}
1168 >>
1169 @end example
1170 would yield
1171
1172 @lilypondfile[ragged-right,quote]{tag-filter.ly}
1173
1174 The arguments of the @code{\tag} command should be a symbol
1175 (such as @code{#'score} or @code{#'part}), followed by a
1176 music expression.  It is possible to put multiple tags on
1177 a piece of music with multiple @code{\tag} entries,
1178
1179 @example
1180   \tag #'original-part \tag #'transposed-part @dots{}
1181 @end example
1182
1183
1184 @seealso
1185
1186 Examples: @inputfileref{input/@/regression,tag@/-filter@/.ly}.
1187
1188
1189 @refbugs
1190
1191 Multiple rests are not merged if you create the score with both tagged
1192 sections.
1193  
1194
1195
1196 @node Orchestral music
1197 @section Orchestral music
1198
1199 Orchestral music involves some special notation, both in the full
1200 score and the individual parts.  This section explains how to tackle
1201 some common problems in orchestral music.
1202
1203 @menu
1204 * Automatic part combining::    
1205 * Hiding staves::               
1206 * Quoting other voices::        
1207 * Formatting cue notes::        
1208 * Aligning to cadenzas::        
1209 @end menu
1210
1211
1212 @node Automatic part combining
1213 @subsection Automatic part combining
1214 @cindex automatic part combining
1215 @cindex part combiner
1216
1217 Automatic part combining is used to merge two parts of music onto a
1218 staff.  It is aimed at typesetting orchestral scores.  When the two
1219 parts are identical for a period of time, only one is shown.  In
1220 places where the two parts differ, they are typeset as separate
1221 voices, and stem directions are set automatically.  Also, solo and
1222 @emph{a due} parts are identified and can be marked.
1223
1224 The syntax for part combining is
1225
1226 @example
1227 \partcombine @var{musicexpr1} @var{musicexpr2}
1228 @end example
1229
1230
1231 The following example demonstrates the basic functionality of the part
1232 combiner: putting parts on one staff, and setting stem directions and
1233 polyphony
1234
1235 @lilypond[quote,verbatim,ragged-right,fragment]
1236 \new Staff \partcombine
1237   \relative g' { g g a( b) c c r r }
1238   \relative g' { g g r4 r e e g g }
1239 @end lilypond
1240
1241 The first @code{g} appears only once, although it was
1242 specified twice (once in each part).  Stem, slur, and tie directions are
1243 set automatically, depending whether there is a solo or unisono.  The
1244 first part (with context called @code{one}) always gets up stems, and
1245 `Solo', while the second (called @code{two}) always gets down stems and
1246 `Solo II'.
1247
1248 If you just want the merging parts, and not the textual markings, you
1249 may set the property @code{printPartCombineTexts} to false
1250
1251 @lilypond[quote,verbatim,ragged-right,fragment,relative=2]
1252 \new Staff <<
1253   \set Staff.printPartCombineTexts = ##f
1254   \partcombine
1255     \relative g' { g a( b) r }
1256     \relative g' { g r4 r f }
1257 >>
1258 @end lilypond
1259
1260 To change the text that is printed for solos or merging, you may
1261 set the @code{soloText}, @code{soloIIText}, and @code{aDueText}
1262 properties.
1263
1264 @lilypond[quote,verbatim,ragged-right,fragment,relative=2]
1265 \new Staff <<
1266   \set Score.soloText = #"ichi"
1267   \set Score.soloIIText = #"ni"
1268   \set Score.aDueText = #"tachi"
1269   \partcombine
1270     \relative g' { g4 g a( b) r }
1271     \relative g' { g4 g r r f }
1272 >>
1273 @end lilypond
1274
1275 Both arguments to @code{\partcombine} will be interpreted as
1276 @internalsref{Voice} contexts.  If using relative octaves,
1277 @code{\relative} should be specified for both music expressions, i.e.,
1278
1279 @example
1280 \partcombine
1281   \relative @dots{} @var{musicexpr1}
1282   \relative @dots{} @var{musicexpr2}
1283 @end example
1284
1285 @noindent
1286 A @code{\relative} section that is outside of @code{\partcombine} has
1287 no effect on the pitches of @var{musicexpr1} and @var{musicexpr2}.
1288
1289 @seealso
1290
1291 Program reference: @internalsref{PartCombineMusic}.
1292
1293 @refbugs
1294
1295 When @code{printPartCombineTexts} is set, when the two voices play the
1296 same notes on and off, the part combiner may typeset @code{a2} more
1297 than once in a measure.
1298
1299 @code{\partcombine} cannot be inside @code{\times}.
1300
1301 @code{\partcombine} cannot be inside @code{\relative}.
1302
1303 Internally, the @code{\partcombine} interprets both arguments as
1304 @code{Voice}s named @code{one} and @code{two}, and then decides when
1305 the parts can be combined.  Consequently, if the arguments switch to
1306 differently named @internalsref{Voice} contexts, the events in those
1307 will be ignored.
1308
1309
1310 @node Hiding staves
1311 @subsection Hiding staves
1312
1313 @cindex Frenched scores
1314 @cindex Hiding staves
1315
1316 In orchestral scores, staff lines that only have rests are usually
1317 removed; this saves some space.  This style is called `French Score'.
1318 For @internalsref{Lyrics},
1319 @internalsref{ChordNames} and @internalsref{FiguredBass}, this is
1320 switched on by default.  When the lines of these contexts turn out
1321 empty after the line-breaking process, they are removed.
1322
1323 For normal staves, a specialized @internalsref{Staff} context is
1324 available, which does the same: staves containing nothing (or only
1325 multi-measure rests) are removed.  The context definition is stored in
1326 @code{\RemoveEmptyStaffContext} variable.  Observe how the second staff
1327 in this example disappears in the second line
1328
1329 @lilypond[quote,ragged-right,verbatim]
1330 \layout {
1331   \context { \RemoveEmptyStaffContext }
1332 }
1333
1334 {
1335   \relative c' <<
1336     \new Staff { e4 f g a \break c1 }
1337     \new Staff { c4 d e f \break R1 }
1338   >>
1339 }
1340 @end lilypond
1341
1342 The first system shows all staves in full.  If empty staves should be
1343 removed from the first system too, set @code{remove-first} to true in
1344 @internalsref{VerticalAxisGroup}.
1345
1346 @example
1347 \override Score.VerticalAxisGroup #'remove-first = ##t
1348 @end example
1349
1350 To remove other types of contexts, use @code{\AncientRemoveEmptyStaffContext}
1351 or @code{\RemoveEmptyRhythmicStaffContext}.
1352
1353 Another application is making ossia sections, i.e., alternative
1354 melodies on a separate piece of staff, with help of a Frenched
1355 staff.  See @inputfileref{input/@/test,ossia@/.ly} for an example.
1356
1357
1358 @node Quoting other voices
1359 @subsection Quoting other voices
1360
1361 With quotations, fragments of other parts can be inserted into a part
1362 directly.  Before a part can be quoted, it must be marked especially as
1363 quotable.  This is done with the @code{\addquote} command.
1364
1365 @example
1366 \addquote @var{name} @var{music}
1367 @end example
1368
1369
1370 @noindent
1371 Here, @var{name} is an identifying string.  The @var{music} is any kind
1372 of music.  Here is an example of @code{\addquote}
1373
1374 @example
1375 \addquote clarinet \relative c' @{
1376   f4 fis g gis
1377 @}
1378 @end example
1379
1380 This command must be entered at toplevel, i.e., outside any music
1381 blocks.
1382
1383 After calling @code{\addquote}, the quotation may then be done with
1384 @code{\quoteDuring} or @code{\cueDuring},
1385
1386 @example
1387 \quoteDuring #@var{name} @var{music}
1388 @end example
1389
1390 During a part, a piece of music can be quoted with the @code{\quoteDuring}
1391 command.
1392
1393 @example
1394 \quoteDuring #"clarinet" @{ s2. @}
1395 @end example
1396
1397 This would cite three quarter notes (the duration of @code{s2.})  of
1398 the previously added @code{clarinet} voice.
1399
1400
1401 More precisely, it takes the current time-step of the part being
1402 printed, and extracts the notes at the corresponding point of the
1403 @code{\addquote}d voice.  Therefore, the argument to @code{\addquote}
1404 should be the entire part of the voice to be quoted, including any
1405 rests at the beginning.
1406
1407 Quotations take into account the transposition of both source and target
1408 instruments, if they are specified using the @code{\transposition} command.
1409
1410 @lilypond[quote,ragged-right,verbatim]
1411 \addquote clarinet \relative c' {
1412   \transposition bes
1413   f4 fis g gis
1414 }
1415
1416 {
1417   e'8 f'8 \quoteDuring #"clarinet" { s2 }
1418 }
1419 @end lilypond
1420
1421 The type of events that are present in cue notes can be trimmed with
1422 the @code{quotedEventTypes} property.  The default value is
1423 @code{(note-event rest-event)}, which means that only notes and
1424 rests of the cued voice end up in the @code{\quoteDuring}.
1425 Setting
1426
1427 @example
1428 \set Staff.quotedEventTypes =
1429        #'(note-event articulation-event dynamic-event)
1430 @end example
1431
1432 @noindent
1433 will quote notes (but no rests), together with scripts and dynamics.
1434
1435 @refbugs
1436
1437 Only the contents of the first @internalsref{Voice} occurring in an
1438 @code{\addquote} command will be considered for quotation, so
1439 @var{music} can not contain @code{\new} and @code{\context Voice}
1440 statements that would switch to a different Voice.
1441
1442 Quoting grace notes is broken and can even cause LilyPond to crash.
1443
1444 @seealso
1445
1446 In this manual: @ref{Instrument transpositions}.
1447
1448 Examples: @inputfileref{input/@/regression,quote@/.ly}
1449 @inputfileref{input/@/regression,quote@/-transposition@/.ly}
1450
1451 Program reference: @internalsref{QuoteMusic}.
1452
1453
1454 @node Formatting cue notes
1455 @subsection Formatting cue notes
1456
1457 The previous section deals with inserting notes from another voice.
1458 There is a more advanced music function called @code{\cueDuring},
1459 which makes formatting cue notes easier.
1460
1461 The syntax is
1462
1463 @example
1464   \cueDuring #@var{name} #@var{updown} @var{music}
1465 @end example
1466
1467 This will insert notes from the part @var{name} into a
1468 @internalsref{Voice} called @code{cue}.  This happens simultaneously
1469 with @var{music}, which usually is a rest.  When the cue notes start,
1470 the staff in effect becomes polyphonic for a moment.  The argument
1471 @var{updown} determines whether the cue notes should be notated as a
1472 first or second voice.
1473
1474
1475 @lilypond[verbatim,ragged-right]
1476 smaller = {
1477   \set fontSize = #-2
1478   \override Stem #'length-fraction = #0.8
1479   \override Beam #'thickness = #0.384
1480   \override Beam #'length-fraction = #0.8
1481 }
1482
1483 \addquote clarinet \relative {
1484   R1*20
1485   r2 r8 c f f
1486
1487
1488 \new Staff \relative  <<
1489
1490   % setup a context for  cue  notes.
1491   \new Voice = "cue" { \smaller \skip 1*21 }
1492   
1493   \set Score.skipBars = ##t
1494   
1495   \new Voice {
1496     R1*20
1497     \cueDuring #"clarinet" #1 {
1498       R1
1499     }
1500     g4 g2. 
1501   }
1502 >>
1503 @end lilypond 
1504
1505
1506 Here are a couple of hints for successful cue notes
1507
1508 @itemize @bullet
1509 @item
1510 Cue notes have smaller font sizes.
1511 @item
1512  the cued part is marked with the instrument playing the cue.
1513 @item
1514  when the original part takes over again, this should be marked with
1515  the name of the original instrument.
1516
1517 @c really?  Are you sure about that last point?  I'll check after 3.0 -gp
1518
1519 @c Yes, this is good practice.  Otherwise, the start of the original
1520 @c part can only be seen from the font size.  This is not good enough
1521 @c for sight-reading.  It is possilbe to use other
1522 @c markers (e.g. a big close-bracket over the staff) to indicate the cue notes are
1523 @c finished.
1524 @c -hwn
1525
1526
1527 Any other changes introduced by the cued part should also be
1528 undone.  For example, if the cued instrument plays in a different clef,
1529 the original clef should be stated once again.
1530
1531 @end itemize
1532
1533
1534 @node Aligning to cadenzas
1535 @subsection Aligning to cadenzas
1536
1537 In an orchestral context, cadenzas present a special problem:
1538 when constructing a score that includes a cadenza, all other
1539 instruments should skip just as many notes as the length of the
1540 cadenza, otherwise they will start too soon or too late.
1541
1542 A solution to this problem are the functions @code{mmrest-of-length}
1543 and @code{skip-of-length}.  These Scheme functions take a piece of music
1544 as argument, and generate a @code{\skip} or multi-rest, exactly as
1545 long as the piece.  The use of @code{mmrest-of-length} is demonstrated
1546 in the following example.
1547
1548 @lilypond[verbatim,ragged-right,quote]
1549 cadenza = \relative c' {
1550   c4 d8 << { e f g } \\ { d4. } >>
1551   g4 f2 g4 g
1552 }
1553
1554 \new GrandStaff <<
1555   \new Staff { \cadenza c'4 }
1556   \new Staff {
1557     #(ly:export (mmrest-of-length cadenza))
1558     c'4
1559   }
1560 >>
1561 @end lilypond
1562
1563
1564
1565
1566 @node Contemporary notation
1567 @section Contemporary notation
1568
1569 In the 20th century, composers have greatly expanded the musical
1570 vocabulary.  With this expansion, many innovations in musical notation
1571 have been tried.  The book ``Music Notation in the 20th century'' by
1572 Kurt Stone gives a comprehensive overview (see @ref{Literature
1573 list}).
1574
1575 This section describes notation that does
1576 not fit into traditional notation categories, such as pitches,
1577 tuplet beams, and articulation.  For contemporary notation
1578 that fits into traditional notation categories, such as
1579 microtones, nested tuplet beams, and unusual fermatas, please
1580 see those sections of the documentation.
1581
1582
1583 @c I don't think we should discourage modern composers who might
1584 @c want to sponsor new features.  :)
1585 @c  In general, the use of new, innovative notation makes a piece
1586 @c harder to understand and perform and its use should therefore be
1587 @c avoided.  For this reason, support for contemporary notation in
1588 @c LilyPond is limited.
1589
1590
1591 @menu
1592 * Polymetric notation::         
1593 * Time administration::         
1594 * Proportional notation::       
1595 * Clusters::                    
1596 * Special noteheads::           
1597 * Feathered beams::             
1598 * Improvisation::               
1599 @end menu
1600
1601
1602 @node Polymetric notation
1603 @subsection Polymetric notation
1604
1605 Double time signatures are not supported explicitly, but they can be
1606 faked.  In the next example, the markup for the time signature is
1607 created with a markup text.  This markup text is inserted in the
1608 @internalsref{TimeSignature} grob. See also 
1609 @inputfileref{input/@/test,compound@/-time@/.ly}).
1610
1611 @lilypond[verbatim,ragged-right]
1612 % create 2/4 + 5/8
1613 tsMarkup =\markup {
1614   \override #'(baseline-skip . 2) \number {
1615     \column { "2" "4" }
1616     \lower #1 "+"
1617     \bracket \column { "5" "8" }
1618   }
1619 }
1620
1621 {
1622   \override Staff.TimeSignature #'stencil = #ly:text-interface::print
1623   \override Staff.TimeSignature #'text = #tsMarkup
1624   \time 3/2
1625   c'2 \bar ":" c'4 c'4.
1626 }
1627 @end lilypond
1628
1629 Each staff can also have its own time signature.  This is done by
1630 moving the @internalsref{Timing_translator} to the @internalsref{Staff}
1631 context.
1632
1633 @example
1634 \layout @{
1635   \context @{ \Score
1636      \remove "Timing_translator"
1637      \remove "Default_bar_line_engraver"
1638   @}
1639   \context @{
1640     \Staff
1641     \consists "Timing_translator"
1642     \consists "Default_bar_line_engraver"
1643   @}
1644     
1645 @}
1646 @end example
1647
1648
1649 Now, each staff has its own time signature.
1650 @example
1651 <<
1652   \new Staff @{
1653     \time 3/4
1654     c4 c c | c c c |
1655   @}
1656   \new Staff @{
1657     \time 2/4
1658     c4 c | c c | c c
1659   @}
1660   \new Staff @{
1661     \time 3/8
1662     c4. c8 c c c4. c8 c c
1663   @}
1664 >>
1665 @end example
1666
1667 @lilypond[quote,ragged-right]
1668 \layout{
1669   \context{
1670      \Score
1671      \remove "Timing_translator"
1672      \remove "Default_bar_line_engraver"
1673     }
1674   \context{ \Staff
1675     \consists "Timing_translator"
1676     \consists "Default_bar_line_engraver"
1677   }
1678 }
1679
1680 \relative c' <<
1681   \new Staff {
1682     \time 3/4
1683     c4 c c | c c c |
1684   }
1685   \new Staff {
1686     \time 2/4
1687     c4 c | c c | c c
1688   }
1689   \new Staff {
1690     \time 3/8
1691     c4. c8 c c c4. c8 c c
1692   }
1693 >>
1694 @end lilypond
1695
1696
1697 A different form of polymetric notation is where note lengths have
1698 different values across staves.
1699
1700 This notation can be created by setting a common time signature for
1701 each staff but replacing it manually using
1702 @code{timeSignatureFraction} to the desired fraction.  Then the printed
1703 durations in each staff are scaled to the common time signature.
1704 The latter is done with @code{\compressMusic}, which is used similar
1705 to @code{\times}, but does not create a tuplet bracket. The syntax is
1706 @example
1707 \compressMusic #'(@var{numerator} . @var{denominator}) @var{musicexpr}
1708 @end example
1709
1710
1711
1712 In this example, music with the time signatures of 3/4, 9/8, and 10/8 are
1713 used in parallel.  In the second staff, shown durations are multiplied by
1714 2/3, so that 2/3 * 9/8 = 3/4, and in the third staff, shown durations are
1715 multiplied by 3/5, so that 3/5 * 10/8 = 3/4.
1716
1717 @lilypond[quote,ragged-right,verbatim,fragment]
1718 \relative c' { <<
1719   \new Staff {
1720     \time 3/4
1721     c4 c c | c c c |
1722   }
1723   \new Staff {
1724     \time 3/4
1725     \set Staff.timeSignatureFraction = #'(9 . 8)
1726     \compressMusic #'(2 . 3)
1727       \repeat unfold 6 { c8[ c c] }
1728   }
1729   \new Staff {
1730     \time 3/4
1731     \set Staff.timeSignatureFraction = #'(10 . 8)
1732     \compressMusic #'(3 . 5) {
1733       \repeat unfold 2 { c8[ c c] }
1734       \repeat unfold 2 { c8[ c] }
1735       | c4. c4. \times 2/3 { c8 c c } c4
1736     }
1737   }
1738 >> }
1739 @end lilypond
1740
1741
1742
1743
1744 @refbugs
1745
1746 When using different time signatures in parallel, the spacing is
1747 aligned vertically, but bar lines distort the regular spacing.
1748
1749
1750 @node Time administration
1751 @subsection Time administration
1752
1753 @cindex Time administration
1754
1755 Time is administered by the @internalsref{Time_signature_engraver},
1756 which usually lives in the @internalsref{Score} context.  The
1757 bookkeeping deals with the following variables
1758
1759 @table @code
1760 @item currentBarNumber
1761 The measure number.
1762
1763 @item measureLength
1764 The length of the measures in the current time signature.  For a 4/4
1765 time this is@tie{}1, and for 6/8 it is 3/4.
1766
1767 @item measurePosition
1768 The point within the measure where we currently are.  This quantity
1769 is reset to@tie{}0 whenever it exceeds @code{measureLength}.  When that
1770 happens, @code{currentBarNumber} is incremented.
1771
1772 @item timing
1773 If set to true, the above variables are updated for every time
1774 step.  When set to false, the engraver stays in the current measure
1775 indefinitely.
1776 @end table
1777
1778 Timing can be changed by setting any of these variables explicitly.
1779 In the next example, the 4/4 time signature is printed, but
1780 @code{measureLength} is set to 5/4.  After a while, the measure is
1781 shortened by 1/8, by setting @code{measurePosition} to 7/8 at 2/4
1782 in the measure, so the next bar line will fall at 2/4 + 3/8.  The
1783 3/8 arises because 5/4 normally has 10/8, but we have manually
1784 set the measure position to be 7/8 and 10/8 - 7/8 = 3/8.
1785
1786 @lilypond[quote,ragged-right,verbatim,relative,fragment]
1787 \set Score.measureLength = #(ly:make-moment 5 4)
1788 c1 c4
1789 c1 c4
1790 c4 c4
1791 \set Score.measurePosition = #(ly:make-moment 7 8)
1792 b8 b b
1793 c4 c1
1794 @end lilypond
1795
1796 @noindent
1797 As the example illustrates, @code{ly:make-moment n m} constructs a
1798 duration of n/m of a whole note.  For example, @code{ly:make-moment 1 8} is an eighth
1799 note duration and @code{ly:make-moment 7 16} is the duration of
1800 seven sixteenths notes.
1801
1802
1803 @node Proportional notation
1804 @subsection Proportional notation
1805 @cindex Proportional notation
1806
1807 Notes can be spaced proportional to their time-difference by
1808 assigning a duration to @code{proportionalNotationDuration}
1809
1810 @lilypond[quote,ragged-right,verbatim,relative=2,fragment]
1811 <<
1812   \set Score.proportionalNotationDuration = #(ly:make-moment 1 16)
1813   \new Staff { c8[ c c c c c]  c4 c2 r2 }
1814   \new Staff { c2  \times 2/3 { c8 c c } c4 c1 }
1815 >>
1816 @end lilypond
1817
1818
1819 @node Clusters
1820 @subsection Clusters
1821
1822 @cindex cluster
1823
1824 A cluster indicates a continuous range of pitches to be played.  They
1825 can be denoted as the envelope of a set of notes.  They are entered by
1826 applying the function @code{makeClusters} to a sequence of
1827 chords, e.g.,
1828 @lilypond[quote,ragged-right,relative=2,fragment,verbatim]
1829 \makeClusters { <c e > <b f'> }
1830 @end lilypond
1831
1832 The following example (from
1833 @inputfileref{input/@/regression,cluster@/.ly}) shows what the result
1834 looks like
1835
1836 @lilypondfile[ragged-right,quote]{cluster.ly}
1837
1838 Ordinary notes and clusters can be put together in the same staff,
1839 even simultaneously.  In such a case no attempt is made to
1840 automatically avoid collisions between ordinary notes and clusters.
1841
1842 @seealso
1843
1844 Program reference: @internalsref{ClusterSpanner},
1845 @internalsref{ClusterSpannerBeacon},
1846 @internalsref{Cluster_spanner_engraver}.
1847
1848 Examples: @inputfileref{input/@/regression,cluster@/.ly}.
1849
1850 @refbugs
1851
1852 Music expressions like @code{<< @{ g8 e8 @} a4 >>} are not printed
1853 accurately.  Use @code{<g a>8 <e a>8} instead.
1854
1855
1856 @node Special noteheads
1857 @subsection Special noteheads
1858
1859 Different noteheads are used by various instruments for various
1860 meanings -- crosses are used for ``parlato'' with vocalists, stopped
1861 notes on guitar; diamonds are used for harmonics on string instruments,
1862 etc.  There is a shorthand (@code{\harmonic}) for diamond shapes; the
1863 other notehead styles are produced by tweaking the property
1864
1865 @lilypond[ragged-right,relative=1,fragment,verbatim,quote]
1866 c4 d
1867 \override NoteHead #'style = #'cross
1868 e f
1869 \revert NoteHead #'style
1870 e d <c f\harmonic> <d a'\harmonic>
1871 @end lilypond
1872
1873 @noindent
1874 To see all notehead styles, please see
1875 @inputfileref{input/@/regression,note@/-head@/-style@/.ly}.
1876
1877
1878 @seealso
1879
1880 Program reference: @internalsref{NoteHead}.
1881
1882
1883 @node Feathered beams
1884 @subsection Feathered beams
1885
1886 Feathered beams are not supported natively, but they can be faked by
1887 forcing two beams to overlap.  Here is an example,
1888
1889 @c don't change relative setting witout changing positions!
1890 @lilypond[ragged-right,relative=1,fragment,verbatim,quote]
1891 \new Staff <<
1892   \new Voice
1893   {
1894     \stemUp
1895     \once \override Voice.Beam #'positions = #'(0 . 0.5)
1896     c8[ c c c c ]
1897   }
1898   \new Voice {
1899     \stemUp
1900     \once \override Voice.Beam #'positions = #'(0 . -0.5)
1901     c[ c c c c]
1902   }
1903 >>
1904 @end lilypond
1905
1906
1907 @node Improvisation
1908 @subsection Improvisation
1909
1910 Improvisation is sometimes denoted with slashed note heads.  Such note
1911 heads can be created by adding a @internalsref{Pitch_squash_engraver}
1912 to the @internalsref{Staff} or @internalsref{Voice} context.  Then, the
1913 following command
1914
1915 @example
1916 \set squashedPosition = #0
1917 \override NoteHead #'style = #'slash
1918 @end example
1919
1920 @noindent
1921 switches on the slashes.
1922
1923 There are shortcuts @code{\improvisationOn} (and an accompanying
1924 @code{\improvisationOff}) for this command sequence.  They are used in
1925 the following example
1926
1927 @lilypond[verbatim,ragged-right,quote]
1928 \new Staff \with {
1929   \consists Pitch_squash_engraver
1930 } \transpose c c' {
1931   e8 e g a a16(bes)(a8) g \improvisationOn
1932   e8
1933   ~e2~e8 f4 fis8
1934   ~fis2 \improvisationOff a16(bes) a8 g e
1935 }
1936 @end lilypond
1937
1938
1939 @node Educational use
1940 @section Educational use
1941
1942 With the amount of control that LilyPond offers, one can make great
1943 teaching tools in addition to great musical scores.
1944
1945 @menu
1946 * Balloon help::                
1947 * Blank music sheet::           
1948 * Hidden notes::                
1949 * Shape note heads ::           
1950 * Easy Notation note heads::    
1951 * Analysis brackets::           
1952 * Coloring objects::            
1953 @end menu
1954
1955 @node Balloon help
1956 @subsection Balloon help
1957
1958 Elements of notation can be marked and named with the help of a square
1959 balloon.  The primary purpose of this feature is to explain notation.
1960
1961 The following example demonstrates its use.
1962
1963 @lilypond[quote,verbatim,fragment,ragged-right,relative=2]
1964 \new Voice {
1965   \applyOutput
1966     #(add-balloon-text 'NoteHead "heads, or tails?"
1967     '(1 . -3))
1968   c8
1969 }
1970 @end lilypond
1971
1972 @noindent
1973 The function @code{add-balloon-text} takes the name of a grob, the
1974 label to print, and the position where to put the label relative to
1975 the object.  In the above example, the text ``heads or tails?'' ends
1976 3 spaces below and 1 space to the right of the marked head.
1977
1978 @cindex balloon
1979 @cindex notation, explaining
1980
1981 @seealso
1982
1983 Program reference: @internalsref{text-balloon-interface}.
1984
1985 Examples: @inputfileref{input/@/regression,balloon@/.ly}.
1986
1987
1988
1989
1990 @node Blank music sheet
1991 @subsection Blank music sheet
1992
1993 @cindex Sheet music, empty
1994 @cindex Staves, blank sheet
1995
1996 A blank music sheet can be produced also by using invisible notes, and
1997 removing @code{Bar_number_engraver}.
1998
1999
2000 @lilypond[quote,verbatim]
2001 emptymusic = {
2002   \repeat unfold 2 % Change this for more lines.
2003   { s1\break }
2004   \bar "|."
2005 }
2006 \new Score \with {
2007   \override TimeSignature #'transparent = ##t
2008   defaultBarType = #""
2009   \remove Bar_number_engraver
2010 } <<
2011   \new Staff \emptymusic
2012   \new TabStaff \emptymusic
2013 >>
2014 @end lilypond
2015
2016
2017 @node Hidden notes
2018 @subsection Hidden notes
2019
2020 @cindex Hidden notes
2021 @cindex Invisible notes
2022 @cindex Transparent notes
2023
2024 @cindex @code{\hideNotes}
2025 @cindex @code{\unHideNotes}
2026 Hidden (or invisible or transparent) notes can be useful in preparing theory
2027 or composition exercises.
2028
2029 @lilypond[quote,ragged-right,verbatim,relative=2,fragment]
2030 c4 d4
2031 \hideNotes
2032 e4 f4
2033 \unHideNotes
2034 g4 a
2035 @end lilypond
2036
2037
2038 @node Shape note heads 
2039 @subsection Shape note heads 
2040
2041 In shape note head notation, the shape of the note head corresponds
2042 to the harmonic function of a note in the scale.  This notation was
2043 popular in the 19th century American song books.
2044
2045 Shape note heads can be produced by setting @code{\aikenHeads} or
2046 @code{\sacredHarpHeads}, depending on the style desired.
2047
2048 @lilypond[verbatim,relative=1,fragment]
2049   \aikenHeads
2050   c8 d4 e8 a2 g1
2051   \sacredHarpHeads
2052   c8 d4. e8 a2 g1
2053 @end lilypond
2054
2055 Shapes are determined on the step in the scale, where the base of the
2056 scale is determined by  the @code{\key} command
2057
2058 @findex \key
2059 @findex shapeNoteStyles
2060 @findex \aikenHeads
2061 @findex \sacredHarpHeads
2062
2063 Shape note heads are implemented through the @code{shapeNoteStyles}
2064 property.  Its value is a vector of symbols.  The k-th element indicates
2065 the style to use for the k-th step of the scale.  Arbitrary
2066 combinations are possible, e.g.
2067
2068 @lilypond[verbatim,relative=1,fragment]
2069   \set shapeNoteStyles  = ##(cross triangle fa #f mensural xcircle diamond)
2070   c8 d4. e8 a2 g1
2071 @end lilypond
2072
2073
2074 @node Easy Notation note heads
2075 @subsection Easy Notation note heads
2076
2077 @cindex easy notation
2078 @cindex Hal Leonard
2079
2080 The `easy play' note head includes a note name inside the head.  It is
2081 used in music for beginners
2082
2083 @lilypond[quote,ragged-right,verbatim,fragment,staffsize=26]
2084   \setEasyHeads
2085   c'2 e'4 f' | g'1
2086 @end lilypond
2087
2088 The command @code{\setEasyHeads} overrides settings for the
2089 @internalsref{NoteHead} object.  To make the letters readable, it has
2090 to be printed in a large font size.  To print with a larger font, see
2091 @ref{Setting global staff size}.
2092
2093 @refcommands
2094
2095 @cindex @code{\setEasyHeads}
2096 @code{\setEasyHeads}
2097
2098
2099 @node Analysis brackets
2100 @subsection Analysis brackets
2101 @cindex brackets
2102 @cindex phrasing brackets
2103 @cindex musicological analysis
2104 @cindex note grouping bracket
2105
2106 Brackets are used in musical analysis to indicate structure in musical
2107 pieces.  LilyPond supports a simple form of nested horizontal
2108 brackets.  To use this, add the @internalsref{Horizontal_bracket_engraver}
2109 to @internalsref{Staff} context.  A bracket is started with
2110 @code{\startGroup} and closed with @code{\stopGroup}
2111
2112 @lilypond[quote,ragged-right,verbatim]
2113 \score {
2114   \relative c'' {
2115     c4\startGroup\startGroup
2116     c4\stopGroup
2117     c4\startGroup
2118     c4\stopGroup\stopGroup
2119   }
2120   \layout {
2121     \context {
2122       \Staff \consists "Horizontal_bracket_engraver"
2123 }}}
2124 @end lilypond
2125
2126 @seealso
2127
2128 Program reference: @internalsref{HorizontalBracket}.
2129
2130 Examples: @inputfileref{input/@/regression,note@/-group@/-bracket@/.ly}.
2131
2132
2133 @node Coloring objects
2134 @subsection Coloring objects
2135
2136 Individual objects may be assigned colors.  You may use the
2137 color names listed in the @ref{List of colors}.
2138
2139 @lilypond[quote,ragged-right,verbatim,fragment,relative=1]
2140 \override NoteHead #'color = #red
2141 c4 c
2142 \override NoteHead #'color = #(x11-color 'LimeGreen)
2143 d
2144 \override Stem #'color = #blue
2145 e
2146 @end lilypond
2147
2148 The full range of colors defined for X11 can be accessed by using the
2149 scheme function x11-color.  The function takes one argument that can be a
2150 symbol
2151
2152 @example
2153 \override Beam #'color = #(x11-color 'MediumTurquoise)
2154 @end example
2155
2156 or a string
2157
2158 @example
2159 \override Beam #'color = #(x11-color "MediumTurquoise")
2160 @end example
2161
2162 The first form is quicker to write and is more efficient.  However, using
2163 the second form it is possible to access X11 colors by the multi-word
2164 form of its name
2165
2166 @example
2167 \override Beam #'color = #(x11-color "medium turquoise")
2168 @end example
2169
2170 If x11-color cannot make sense of the parameter then the color returned
2171 defaults to black.  It should be obvious from the final score that
2172 something is wrong.
2173
2174 This example, illustrates the use of x11-color.  Notice that the stem
2175 color remains black after being set to (x11-color 'Boggle), which is
2176 deliberate nonsense.
2177
2178 @lilypond[quote,ragged-right,verbatim]
2179 {
2180   \override Staff.StaffSymbol #'color = #(x11-color 'SlateBlue2)
2181   \set Staff.instrument = \markup {
2182     \with-color #(x11-color 'navy) "Clarinet"
2183   }
2184   \time 2/4
2185   gis''8 a''
2186   \override Beam #'color = #(x11-color "medium turquoise")
2187   gis'' a''
2188   \override NoteHead #'color = #(x11-color "LimeGreen")
2189   gis'' a''
2190   \override Stem #'color = #(x11-color 'Boggle)
2191   gis'' a''
2192 }
2193 @end lilypond
2194
2195
2196 @seealso
2197
2198 Appendix: @ref{List of colors}.
2199
2200
2201 @refbugs
2202 Not all x11 colors are distinguishable in a web browser.  For web use
2203 normal colors are recommended. 
2204
2205 An x11 color is not necessarily exactly the same shade as a similarly
2206 named normal color. 
2207
2208
2209 @node Automatic notation
2210 @section Automatic notation
2211
2212 This section describes how to change the way that accidentals and
2213 beams are automatically displayed.
2214
2215 FIXME: this might get moved into Changing Defaults.  Please send
2216 opinions to lilypond-devel.  Thanks!  :)
2217
2218 @menu
2219 * Automatic accidentals::       
2220 * Setting automatic beam behavior::  
2221 @end menu
2222
2223 @node Automatic accidentals
2224 @subsection Automatic accidentals
2225 @cindex Automatic accidentals
2226
2227 Common rules for typesetting accidentals have been placed in a
2228 function.  This function is called as follows
2229
2230 @cindex @code{set-accidental-style}
2231 @example
2232 #(set-accidental-style 'STYLE #('CONTEXT#))
2233 @end example
2234
2235 The function can take two arguments: the name of the accidental style,
2236 and an optional argument that denotes the context that should be
2237 changed.  If no context name is supplied, @code{Staff} is the default,
2238 but you may wish to apply the accidental style to a single @code{Voice}
2239 instead.
2240
2241 The following accidental styles are supported
2242 @table @code
2243 @item default
2244 This is the default typesetting behavior.  It corresponds
2245 to 18th century common practice: Accidentals are
2246 remembered to the end of the measure in which they occur and
2247 only on their own octave.
2248
2249 @item voice
2250 The normal behavior is to remember the accidentals on
2251 Staff-level.  This variable, however, typesets accidentals
2252 individually for each voice.  Apart from that, the rule is similar to
2253 @code{default}.
2254
2255 As a result, accidentals from one voice do not get canceled in other
2256 voices, which is often an unwanted result
2257
2258 @lilypond[quote,ragged-right,relative=1,fragment,verbatim]
2259 \new Staff <<
2260   #(set-accidental-style 'voice)
2261   <<
2262     { es g } \\
2263     { c, e }
2264 >> >>
2265 @end lilypond
2266
2267 The @code{voice} option should be used if the voices
2268 are to be read solely by individual musicians.  If the staff is to be
2269 used by one musician (e.g., a conductor) then
2270 @code{modern} or @code{modern-cautionary}
2271 should be used instead.
2272
2273 @item modern
2274 @cindex @code{modern} style accidentals
2275 This rule corresponds to the common practice in the 20th century.  This rule
2276 prints the same accidentals as @code{default}, but temporary
2277 accidentals also are canceled in other octaves.  Furthermore,
2278 in the same octave, they also get canceled in the following
2279 measure
2280
2281 @lilypond[quote,ragged-right,fragment,verbatim]
2282 #(set-accidental-style 'modern)
2283 cis' c'' cis'2 | c'' c'
2284 @end lilypond
2285
2286 @item @code{modern-cautionary}
2287 @cindex @code{modern-cautionary}
2288 This rule is similar to @code{modern}, but the ``extra'' accidentals
2289 (the ones not typeset by @code{default}) are typeset as cautionary
2290 accidentals.  They are printed in reduced size or with parentheses
2291 @lilypond[quote,ragged-right,fragment,verbatim]
2292 #(set-accidental-style 'modern-cautionary)
2293 cis' c'' cis'2 | c'' c'
2294 @end lilypond
2295
2296 @cindex @code{modern-voice}
2297 @item modern-voice
2298 This rule is used for multivoice accidentals to be read both by musicians
2299 playing one voice and musicians playing all voices.  Accidentals are
2300 typeset for each voice, but they @emph{are} canceled across voices in
2301 the same @internalsref{Staff}.
2302
2303 @cindex @code{modern-voice-cautionary}
2304 @item modern-voice-cautionary
2305 This rule is the same as @code{modern-voice}, but with the extra
2306 accidentals (the ones not typeset by @code{voice}) typeset
2307 as cautionaries.  Even though all accidentals typeset by
2308 @code{default} @emph{are} typeset by this variable,
2309 some of them are typeset as cautionaries.
2310
2311 @item piano
2312 @cindex @code{piano} accidentals
2313 This rule reflects 20th century practice for piano notation.  Very similar to
2314 @code{modern} but accidentals also get canceled
2315 across the staves in the same @internalsref{GrandStaff} or
2316 @internalsref{PianoStaff}.
2317
2318 @item piano-cautionary
2319 @cindex @code{#(set-accidental-style 'piano-cautionary)}
2320 Same as @code{#(set-accidental-style 'piano)} but with the extra
2321 accidentals typeset as cautionaries.
2322
2323 @item no-reset
2324 @cindex @code{no-reset} accidental style
2325 This is the same as @code{default} but with accidentals lasting
2326 ``forever'' and not only until the next measure
2327 @lilypond[quote,ragged-right,fragment,verbatim,relative=1]
2328 #(set-accidental-style 'no-reset)
2329 c1 cis cis c
2330 @end lilypond
2331
2332 @item forget
2333 This is sort of the opposite of @code{no-reset}: Accidentals
2334 are not remembered at all---and hence all accidentals are
2335 typeset relative to the key signature, regardless of what was
2336 before in the music
2337
2338 @lilypond[quote,ragged-right,fragment,verbatim,relative=1]
2339 #(set-accidental-style 'forget)
2340 \key d\major c4 c cis cis d d dis dis
2341 @end lilypond
2342 @end table
2343
2344
2345 @seealso
2346
2347 Program reference: @internalsref{Accidental_engraver},
2348 @internalsref{Accidental}, and @internalsref{AccidentalPlacement}.
2349
2350
2351 @refbugs
2352
2353 Simultaneous notes are considered to be entered in sequential
2354 mode.  This means that in a chord the accidentals are typeset as if the
2355 notes in the chord happened once at a time - in the order in which
2356 they appear in the input file.
2357
2358 This is a problem when accidentals in a chord depend on each other,
2359 which does not happen for the default accidental style.  The problem
2360 can be solved by manually inserting @code{!} and @code{?} for the
2361 problematic notes.
2362
2363
2364 @node Setting automatic beam behavior
2365 @subsection Setting automatic beam behavior
2366
2367 @cindex @code{autoBeamSettings}
2368 @cindex @code{(end * * * *)}
2369 @cindex @code{(begin * * * *)}
2370 @cindex automatic beams, tuning
2371 @cindex tuning automatic beaming
2372
2373 @c [TODO: use \applyContext]
2374
2375 In normal time signatures, automatic beams can start on any note but can
2376 only end in a few positions within the measure: beams can end on a beat,
2377 or at durations specified by the properties in
2378 @code{autoBeamSettings}.  The properties in @code{autoBeamSettings}
2379 consist of a list of rules for where beams can begin and end.  The
2380 default @code{autoBeamSettings} rules are defined in
2381 @file{scm/@/auto@/-beam@/.scm}.
2382
2383 In order to add a rule to the list, use
2384 @example
2385 #(override-auto-beam-setting '(be p q n m) a b [context])
2386 @end example
2387
2388 @itemize @bullet
2389
2390 @item @code{be} is either "begin" or "end".
2391
2392 @item @code{p/q} is the duration of the note for which you want
2393 to add a rule.  A beam is considered to have the duration of its
2394 shortest note.  Set @code{p} and @code{q} to @code{'*'} to
2395 have this apply to any beam.
2396
2397 @item @code{n/m} is the time signature to which
2398 this rule should apply.  Set @code{n} and @code{m} to @code{'*'}
2399 to have this apply in any time signature.
2400
2401 @item @code{a/b} is the position in the bar at which the beam should begin/end.
2402
2403 @item @code{context} is optional, and it specifies the context at which
2404 the change should be made.  The default is @code{'Voice}.
2405 @code{#(score-override-auto-beam-setting '(A B C D) E F)} is equivalent to
2406 @code{#(override-auto-beam-setting '(A B C D) E F 'Score)}.
2407
2408 @end itemize
2409
2410 For example, if automatic beams should always end on the first quarter
2411 note, use
2412
2413 @example
2414 #(override-auto-beam-setting '(end * * * *) 1 4)
2415 @end example
2416
2417 You can force the beam settings to only take effect on beams whose shortest
2418 note is a certain duration
2419
2420 @lilypond[quote,fragment,ragged-right,verbatim,relative=2]
2421 \time 2/4
2422 #(override-auto-beam-setting '(end 1 16 * *) 1 16)
2423 a16 a a a a a a a |
2424 a32 a a a a16 a a a a a |
2425 #(override-auto-beam-setting '(end 1 32 * *) 1 16)
2426 a32 a a a a16 a a a a a |
2427 @end lilypond
2428
2429 You can force the beam settings to only take effect in certain time
2430 signatures
2431
2432 @lilypond[quote,fragment,ragged-right,verbatim,relative=2]
2433 \time 5/8
2434 #(override-auto-beam-setting '(end * * 5 8) 2 8)
2435 c8 c d d d
2436 \time 4/4
2437 e8 e f f e e d d
2438 \time 5/8
2439 c8 c d d d
2440 @end lilypond
2441
2442 You can also remove a previously set beam-ending rule by using
2443
2444 @example
2445 #(revert-auto-beam-setting '(be p q n m) a b [context])
2446 @end example
2447
2448 @noindent
2449 be, p, q, n, m, a, b and context are the same as above.  Note that the
2450 default rules are specified in @file{scm/@/auto@/-beam@/.scm},
2451 so you can revert rules that you did not explicitly create.
2452
2453 @lilypond[quote,fragment,ragged-right,verbatim,relative=2]
2454 \time 4/4
2455 a16 a a a a a a a a a a a a a a a
2456 #(revert-auto-beam-setting '(end 1 16 4 4) 1 4)
2457 a16 a a a a a a a a a a a a a a a
2458 @end lilypond
2459
2460 The rule in a revert-auto-beam-setting statement must exactly match the
2461 original rule.  That is, no wildcard expansion is taken into account.
2462
2463 @lilypond[quote,fragment,ragged-right,verbatim,relative=2]
2464 \time 1/4
2465 #(override-auto-beam-setting '(end 1 16 1 4) 1 8)
2466 a16 a a a
2467 #(revert-auto-beam-setting '(end 1 16 * *) 1 8) % this won't revert it!
2468 a a a a
2469 #(revert-auto-beam-setting '(end 1 16 1 4) 1 8) % this will
2470 a a a a
2471 @end lilypond
2472
2473
2474
2475 @c TODO:  old material -- not covered by above stuff, I think.
2476 If automatic beams should end on every quarter in 5/4 time, specify
2477 all endings
2478 @example
2479 #(override-auto-beam-setting '(end * * * *) 1 4 'Staff)
2480 #(override-auto-beam-setting '(end * * * *) 1 2 'Staff)
2481 #(override-auto-beam-setting '(end * * * *) 3 4 'Staff)
2482 #(override-auto-beam-setting '(end * * * *) 5 4 'Staff)
2483 @dots{}
2484 @end example
2485
2486 The same syntax can be used to specify beam starting points.  In this
2487 example, automatic beams can only end on a dotted quarter note
2488 @example
2489 #(override-auto-beam-setting '(end * * * *) 3 8)
2490 #(override-auto-beam-setting '(end * * * *) 1 2)
2491 #(override-auto-beam-setting '(end * * * *) 7 8)
2492 @end example
2493 In 4/4 time signature, this means that automatic beams could end only on
2494 3/8 and on the fourth beat of the measure (after 3/4, that is 2 times
2495 3/8, has passed within the measure).
2496
2497 @cindex automatic beam generation
2498 @cindex autobeam
2499 @cindex @code{autoBeaming}
2500 @cindex lyrics
2501
2502 If beams are used to indicate melismata in songs, then automatic
2503 beaming should be switched off with @code{\autoBeamOff}.
2504
2505
2506 @refcommands
2507
2508 @cindex @code{\autoBeamOff}
2509 @code{\autoBeamOff},
2510 @cindex @code{\autoBeamOn}
2511 @code{\autoBeamOn}.
2512
2513
2514 @refbugs
2515
2516 If a score ends while an automatic beam has not been ended and is
2517 still accepting notes, this last beam will not be typeset at all.  The
2518 same holds polyphonic voices, entered with @code{<< @dots{} \\ @dots{}
2519 >>}.  If a polyphonic voice ends while an automatic beam is still
2520 accepting notes, it is not typeset.
2521
2522
2523