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