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