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