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