]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/advanced-notation.itely
Small fixes (bugs and commonprop)
[lilypond.git] / Documentation / user / advanced-notation.itely
1 @c -*- coding: utf-8; mode: texinfo; -*-
2 @c This file is part of lilypond.tely
3
4 @c A menu is needed before every deeper *section nesting of @node's; run 
5 @c     M-x texinfo-all-menus-update
6 @c to automatically fill in these menus before saving changes
7
8
9 @node Advanced notation
10 @chapter Advanced notation
11
12 This chapter deals with rarely-used and advanced notation.
13
14 @menu
15 * Text::                        
16 * Preparing parts::             
17 * Orchestral music::            
18 * Contemporary notation::       
19 * Educational use::             
20 * Automatic notation::          
21 @end menu
22
23
24
25 @node Text
26 @section Text
27
28 This section explains how to include text (with various formatting) in
29 your scores.
30
31 @menu
32 * Text scripts::                
33 * Text spanners::               
34 * Text marks::                  
35 * Text markup::                 
36 * Text encoding::               
37 * Nested scores::               
38 * Overview of text markup commands::  
39 * Font selection::              
40 * New dynamic marks::           
41 @end menu
42
43
44 @node Text scripts
45 @subsection Text scripts
46
47 @cindex Text scripts
48 @cindex text items, non-empty
49 @cindex non-empty texts
50
51 It is possible to place arbitrary strings of text or @ref{Text markup}
52 above or below notes by using a string @code{c^"text"}.  By default,
53 these indications do not influence the note spacing, but by using the
54 command @code{\fatText}, the widths will be taken into account
55
56 @lilypond[quote,fragment,raggedright,verbatim,relative=1]
57 c4^"longtext" \fatText c4_"longlongtext" c4
58 @end lilypond
59
60 More complex formatting may also be added to a note by using the
61 markup command,
62 @lilypond[fragment,raggedright,verbatim,quote]
63 c'4^\markup { bla \bold bla }
64 @end lilypond
65
66 The @code{\markup} is described in more detail in
67 @ref{Text markup}.
68
69
70 @refcommands
71
72 @cindex @code{\fatText}
73 @code{\fatText},
74 @cindex @code{\emptyText}
75 @code{\emptyText}.
76
77
78 @commonprop
79
80 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
81
82 @example
83 \override Score.PaperColumn #'keep-inside-line = ##t
84 @end example
85
86
87 @seealso
88
89 In this manual: @ref{Text markup}.
90
91 Program reference: @internalsref{TextScript}.
92
93
94 @node Text spanners
95 @subsection Text spanners
96
97 @cindex Text spanners
98
99 Some performance indications, e.g., @i{rallentando} or @i{accelerando},
100 are written as text and are extended over many measures with dotted
101 lines.  Such texts are created using text spanners; attach
102 @code{\startTextSpan} and @code{\stopTextSpan} to the first and last
103 notes of the spanner.
104
105 The string to be printed, as well as the style, is set through object
106 properties
107
108 @lilypond[quote,raggedright,fragment,relative=1,verbatim]
109 c1
110 \textSpannerDown
111 \override TextSpanner #'edge-text = #'("rall " . "")
112 c2\startTextSpan b c\stopTextSpan a
113 \break
114 \textSpannerUp
115 \override TextSpanner #'edge-text = #(cons (markup #:italic "rit" ) "")
116 c2\startTextSpan b c\stopTextSpan a
117 @end lilypond
118
119 @refcommands
120
121 @cindex textSpannerUp
122 @code{textSpannerUp},
123 @cindex textSpannerDown 
124 @code{textSpannerDown},
125 @cindex textSpannerNeutral
126 @code{textSpannerNeutral}.
127
128
129 @seealso
130
131 Program reference: @internalsref{TextSpanner}.
132
133 Examples: @inputfileref{input/@/regression,text@/-spanner@/.ly}.
134
135
136 @node Text marks
137 @subsection Text marks
138
139 @cindex coda on bar line
140 @cindex segno on bar line
141 @cindex fermata on bar line
142 @cindex bar lines, symbols on
143 @cindex @code{\mark}
144
145 The @code{\mark} command is primarily used for
146 @ref{Rehearsal marks},
147 but it can also be used to put signs like coda,
148 segno, and fermata on a bar line.  Use @code{\markup} to
149 access the appropriate symbol
150
151 @lilypond[fragment,quote,raggedright,verbatim,relative=2]
152 c1 \mark \markup { \musicglyph #"scripts.ufermata" }
153 c1
154 @end lilypond
155
156 @noindent
157 @code{\mark} is only typeset above the top stave of the score.  If
158 you specify the @code{\mark} command at a bar line, the resulting
159 mark is placed above the bar line.  If you specify it in the middle
160 of a bar, the resulting mark is positioned between notes.  If it is
161 specified before the beginning of a score line, it is placed
162 before the first note of the line.  Finally, if the mark occurs at
163 a line break, the mark will be printed at the
164 beginning of the next line.
165 @c  IMO this is a bug; hopefully it'll be fixed soon, so I can
166 @c  delete this sentence.   -gp
167 If there is no next line, then the mark will not be printed at all.
168
169
170 @commonprop
171
172 To print the mark at the end of the current line, use
173
174 @example
175 \override Score.RehearsalMark
176   #'break-visibility = #begin-of-line-invisible
177 @end example
178
179 @code{\mark} is often useful for adding text to the end of bar.  In
180 such cases, changing the @code{#'self-alignment} is very useful
181
182 @lilypond[fragment,quote,raggedright,verbatim,relative=2]
183 \override Score.RehearsalMark
184   #'break-visibility = #begin-of-line-invisible
185 c1 c c c4 c c c
186 \once \override Score.RehearsalMark #'self-alignment-X = #right
187 \mark "D.S. al Fine "
188 @end lilypond
189
190
191 @seealso
192
193 Program reference: @internalsref{RehearsalMark}.
194
195
196 @node Text markup
197 @subsection Text markup
198
199 @cindex markup
200 @cindex text markup
201 @cindex markup text
202 @cindex typeset text
203
204 Use @code{\markup} to typeset text.  Commands are entered with the
205 backslash @code{\}.
206
207 @lilypond[quote,verbatim,fragment,relative=1]
208 c1^\markup { hello }
209 c1_\markup { hi there }
210 c1^\markup { hi \bold there, is \italic anyone home? }
211 @end lilypond
212
213 @noindent
214 See @ref{Overview of text markup commands} for a list of all
215 commands.
216
217 @code{\markup} is primarily used for @internalsref{TextScript}s,
218 but it can also be used anywhere text is called in lilypond
219
220 @lilypond[quote,verbatim]
221 \header{ title = \markup{ \bold { foo \italic { bar! } } } }
222 \score{
223   \relative c'' {
224     \override Score.RehearsalMark
225       #'break-visibility = #begin-of-line-invisible
226     \override Score.RehearsalMark #'self-alignment-X = #right
227
228     \set Staff.instrument = \markup{ \column{ Alto solo } }
229     c2^\markup{ don't be \flat }
230     \override TextSpanner #'edge-text = #(cons (markup #:italic "rit" ) "")
231     b2\startTextSpan
232     a2\mark \markup{ \large \bold Fine }
233     r2\stopTextSpan
234     \bar "||"
235   }
236   \addlyrics { bar, foo \markup{ \italic bar! } }
237 }
238 @end lilypond
239
240 Text can also be placed on its own, away from any @code{\score}
241 block.  This is primarily used in a @code{\book} (see
242 @ref{Multiple movements}).
243
244 @lilypond[quote,raggedright,verbatim]
245 \markup{ Here is some text. }
246 @end lilypond
247
248 @cindex font switching
249
250 The markup in the example demonstrates font switching commands.  The
251 command @code{\bold} and @code{\italic} apply to the first following 
252 word only; to apply a command to more than one word, enclose the
253 words with braces,
254
255 @example
256 \markup @{ \bold @{ hi there @} @}
257 @end example
258
259 @noindent
260 For clarity, you can also do this for single arguments, e.g.,
261
262 @example
263 \markup @{ is \italic @{ anyone @} home @}
264 @end example
265
266 In markup mode you can compose expressions, similar to mathematical
267 expressions, XML documents, and music expressions.  You can stack
268 expressions grouped vertically with the command @code{\column}.
269 Similarly, @code{\center-align} aligns texts by their center lines:
270
271 @lilypond[quote,verbatim,fragment,relative=1]
272 c1^\markup { \column { a bbbb \line { c d } } }
273 c1^\markup { \center-align { a bbbb c } }
274 c1^\markup { \line { a b c } }
275 @end lilypond
276
277 Lists with no previous command are not kept distinct.  The expression
278
279 @example
280 \center-align @{ @{ a b @} @{ c d @} @} 
281 @end example
282
283 @noindent
284
285 is equivalent to
286
287 @example
288 \center-align @{ a b c d @}
289 @end example
290
291 @noindent
292
293 To keep lists of words distinct, please use quotes @code{"} or
294 the @code{\line} command
295
296 @lilypond[quote,verbatim,fragment,relative=1]
297 \fatText
298 c4^\markup{ \center-align { on three lines } }
299 c4^\markup{ \center-align { "all one line" } }
300 c4^\markup{ \center-align { { on three lines } } }
301 c4^\markup{ \center-align { \line { on one line } } }
302 @end lilypond
303
304 Markups can be stored in variables and these variables
305 may be attached to notes, like
306 @example
307 allegro = \markup @{ \bold \large @{ Allegro @} @}
308  @{ a^\allegro b c d @}
309 @end example
310
311 Some objects have alignment procedures of their own, which cancel out
312 any effects of alignments applied to their markup arguments as a
313 whole.  For example, the @internalsref{RehearsalMark} is horizontally
314 centered, so using @code{\mark \markup @{ \left-align .. @}} has no
315 effect.
316
317 In addition, vertical placement is performed after creating the
318 text markup object.  If you wish to move an entire piece of markup,
319 you need to use the #'padding property or create an "anchor" point
320 inside the markup (generally with @code{\hspace #0}).
321
322 @lilypond[quote,verbatim,fragment,relative=1]
323 \fatText
324 c'4^\markup{ \raise #5 "not raised" }
325 \once \override TextScript #'padding = #3
326 c'4^\markup{ raised }
327 c'4^\markup{ \hspace #0 \raise #1.5 raised }
328 @end lilypond
329
330
331 @seealso
332
333 This manual: @ref{Overview of text markup commands}.
334
335 Program reference: @internalsref{TextScript}.
336
337 Init files: @file{scm/@/new@/-markup@/.scm}.
338
339
340 @refbugs
341
342 Kerning or generation of ligatures is only done when the @TeX{}
343 backend is used.  In this case, LilyPond does not account for them so
344 texts will be spaced slightly too wide.
345
346 Syntax errors for markup mode are confusing.
347
348
349 @node Text encoding
350 @subsection Text encoding
351
352 LilyPond uses the Pango library to format multi-lingual texts, and
353 does not perform any input-encoding conversions.  This means that any
354 text, be it title, lyric text, or musical instruction containing
355 non-ASCII characters, must be utf-8.  Easiest to enter such texts is
356 by using a Unicode-aware editor, and save using utf-8 encoding.  Most
357 popular modern editors have utf-8 support, for example, vim, Emacs,
358 jEdit, and GEdit do.
359
360 Depending on the fonts installed, the following fragment shows Hebrew
361 and Cyrillic lyrics,
362
363 @cindex Cyrillic
364 @cindex Hebrew
365 @cindex ASCII, non
366
367 @lilypondfile[fontload]{utf-8.ly}
368
369 The @TeX{} backend does not handle encoding specially at all.  Strings
370 in the input are put in the output as-is.  Extents of text items in the
371 @TeX{} backend, are determined by reading a file created via the
372 @file{texstr} backend,
373
374 @example
375 lilypond -b texstr input/les-nereides.ly
376 latex les-nereides.texstr
377 @end example
378
379 The last command produces @file{les-nereides.textmetrics}, which is
380 read when you execute
381
382 @example
383 lilypond -b tex input/les-nereides.ly
384 @end example
385
386 Both @file{les-nereides.texstr} and @file{les-nereides.tex} need
387 suitable LaTeX wrappers to load appropriate La@TeX{} packages for
388 interpreting non-ASCII strings.
389
390 To use a Unicode escape sequence, use
391
392 @example
393 #(ly:export (ly:wide-char->utf-8 #x2014))
394 @end example
395
396
397 @seealso
398
399 @inputfileref{input/regression,utf-8.ly}
400
401
402 @node Nested scores
403 @subsection Nested scores
404
405 It is possible to nest music inside markups, by adding a @code{\score}
406 block to a markup expression.  Such a score must contain a @code{\layout}
407 block.
408
409 @lilypond[quote,verbatim,raggedright]
410 \relative {
411   c4 d^\markup {
412     \score {
413       \relative { c4 d e f }
414       \layout { }
415     }
416   }
417   e f
418 }
419 @end lilypond
420
421
422 @node Overview of text markup commands
423 @subsection Overview of text markup commands
424
425 The following commands can all be used inside @code{\markup @{ @}}.
426
427 @include markup-commands.tely
428
429
430 @node Font selection
431 @subsection Font selection
432
433 @cindex font selection
434 @cindex font magnification
435 @cindex @code{font-interface}
436
437 By setting the object properties described below, you can select a
438 font from the preconfigured font families.  LilyPond has default
439 support for the feta music fonts. Text fonts are selected through
440 Pango/FontConfig. The serif font defaults to New Century Schoolbook,
441 the sans and typewriter to whatever the Pango installation defaults
442 to.
443
444
445 @itemize @bullet
446 @item @code{font-encoding}
447 is a symbol that sets layout of the glyphs.  This should only be set to
448 select different types of non-text fonts, eg.
449
450 @code{fetaBraces} for piano staff braces, @code{fetaMusic} the
451 standard music font, including ancient glyphs, @code{fetaDynamic} for
452 dynamic signs and @code{fetaNumber} for the number font.
453
454 @item @code{font-family}
455 is a symbol indicating the general class of the typeface.  Supported are
456 @code{roman} (Computer Modern), @code{sans}, and @code{typewriter}.
457   
458 @item @code{font-shape}
459 is a symbol indicating the shape of the font.  There are typically
460 several font shapes available for each font family.  Choices are
461 @code{italic}, @code{caps}, and @code{upright}.
462
463 @item @code{font-series}
464 is a symbol indicating the series of the font.  There are typically
465 several font series for each font family and shape.  Choices are
466 @code{medium} and @code{bold}. 
467
468 @end itemize
469
470 Fonts selected in the way sketched above come from a predefined style
471 sheet. If you want to use a font from outside the style sheet, 
472 then set the 
473 @code{font-name} property, 
474
475 @lilypond[fragment,verbatim]
476 {
477   \override Staff.TimeSignature #'font-name = #"Charter"
478   \override Staff.TimeSignature #'font-size = #2
479   \time 3/4
480   c'1_\markup {
481     \override #'(font-name . "Vera Bold")
482       { This text is in Vera Bold }
483   }
484 }
485 @end lilypond
486
487 @noindent
488 Any font can be used, as long as it is available to Pango/FontConfig.
489
490 The size of the font may be set with the @code{font-size}
491 property. The resulting size is taken relative to the
492 @code{text-font-size} as defined in the @code{\paper} block.
493
494 @cindex font size
495 @cindex font magnification
496
497
498 It is also possible to change the default font family for the entire
499 document. This is done by calling the @code{make-pango-font-tree} from
500 within the @code{\paper} block. The function takes names for the font
501 families to use for roman, sans serif and monospaced text. For
502 example,
503
504 @cindex font families, setting
505 @cindex Pango
506
507
508 @lilypond[verbatim]
509 \paper  {
510   myStaffSize = #20
511   
512   #(define fonts
513     (make-pango-font-tree "Times New Roman"
514                           "Nimbus Sans"
515                           "Luxi Mono"
516                            (/ myStaffSize 20)))
517 }
518
519 {
520   c'^\markup { roman: foo \sans bla \typewriter bar }
521 }
522 @end lilypond
523
524 @c we don't do Helvetica / Courier, since GS incorrectly loads
525 @c Apple TTF fonts  
526
527
528
529 @seealso
530
531 Examples: @file{ly/@/font@/-family@/-override.ly}
532
533
534 @node New dynamic marks
535 @subsection New dynamic marks
536
537 It is possible to print new dynamic marks or text that should be aligned
538 with dynamics.  Use @code{make-dynamic-script} to create these marks.
539
540 @cindex make-dynamic-script
541
542 @lilypond[quote,verbatim,raggedright]
543 sfzp = #(make-dynamic-script "sfzp")
544 \relative c' {
545   c4 c c\sfzp c
546 }
547 @end lilypond
548
549 @cindex Dynamics, editorial
550 @cindex Dynamics, parenthesis
551
552 It is also possible to print dynamics in round parenthesis or square
553 brackets.  These are often used for adding editorial dynamics.
554
555 @lilypond[quote,verbatim,raggedright]
556 rndf = \markup{ \center-align {\line { \bold{\italic (}
557   \dynamic f \bold{\italic )} }} }
558 boxf = \markup{ \bracket { \dynamic f } }
559 { c'1_\rndf c'1_\boxf }
560 @end lilypond
561
562
563
564 @node Preparing parts
565 @section Preparing parts
566
567 This section describes various notation that are useful for preparing
568 individual parts.
569
570 @menu
571 * Multi measure rests::         
572 * Metronome marks::             
573 * Rehearsal marks::             
574 * Bar numbers::                 
575 * Instrument names::            
576 * Instrument transpositions::   
577 * Ottava brackets::             
578 * Different editions from one source::  
579 @end menu
580
581
582 @node Multi measure rests
583 @subsection Multi measure rests
584
585 @cindex multi measure rests
586 @cindex full measure rests
587 @cindex Rests, multi measure
588 @cindex Rests, full measure
589 @cindex whole rests for a full measure
590 @cindex @code{R}
591
592 Rests for one full measure (or many bars) are entered using `@code{R}'.  It
593 is specifically meant for full bar rests and for entering parts: the rest
594 can expand to fill a score with rests, or it can be printed as a single
595 multi-measure rest.  This expansion is controlled by the property
596 @code{Score.skipBars}.  If this is set to true, empty measures will not
597 be expanded, and the appropriate number is added automatically
598
599 @lilypond[quote,raggedright,fragment,verbatim]
600 \time 4/4 r1 | R1 | R1*2
601 \set Score.skipBars = ##t R1*17 R1*4
602 @end lilypond
603
604 The @code{1} in @code{R1} is similar to the duration notation used for
605 notes.  Hence, for time signatures other than 4/4, you must enter other
606 durations.  This can be done with augmentation dots or fractions
607
608 @lilypond[quote,raggedright,fragment,verbatim]
609 \set Score.skipBars = ##t
610 \time 3/4
611 R2. | R2.*2
612 \time 13/8
613 R1*13/8
614 R1*13/8*12 |
615 \time 10/8 R4*5*4 |
616 @end lilypond
617
618 An @code{R} spanning a single measure is printed as either a whole rest
619 or a breve, centered in the measure regardless of the time signature.
620
621 If there are only a few measures of rest, LilyPond prints ``church rests''
622 (a series of rectangles) in the staff.  To replace that with a simple
623 rest, use @code{MultiMeasureRest.expand-limit}.
624
625 @lilypond[quote,raggedright,fragment,verbatim]
626 \set Score.skipBars = ##t
627 R1*2 | R1*5 | R1*9
628 \override MultiMeasureRest #'expand-limit = 1
629 R1*2 | R1*5 | R1*9
630 @end lilypond
631
632 @cindex text on multi-measure rest
633 @cindex script on multi-measure rest
634 @cindex fermata on multi-measure rest
635
636 Texts can be added to multi-measure rests by using the
637 @var{note}-@code{markup} syntax @ref{Text markup}.
638 A variable (@code{\fermataMarkup}) is provided for
639 adding fermatas
640
641 @lilypond[quote,raggedright,verbatim,fragment]
642 \set Score.skipBars = ##t
643 \time 3/4
644 R2.*10^\markup { \italic "ad lib." }
645 R2.^\fermataMarkup
646 @end lilypond
647
648 Warning!  This text is created by @code{MultiMeasureRestText}, not
649 @code{TextScript}.
650
651 @lilypond[quote,raggedright,verbatim,fragment]
652 \override TextScript #'padding = #5
653 R1^"low"
654 \override MultiMeasureRestText #'padding = #5
655 R1^"high"
656 @end lilypond
657
658 If you want to have text on the left end of a multi-measure rest,
659 attach the text to a zero-length skip note, i.e.,
660
661 @example
662 s1*0^"Allegro"
663 R1*4
664 @end example
665
666
667 @seealso
668
669 Program reference: @internalsref{MultiMeasureRestMusicGroup},
670 @internalsref{MultiMeasureRest}.
671
672 The layout object @internalsref{MultiMeasureRestNumber} is for the
673 default number, and @internalsref{MultiMeasureRestText} for user
674 specified texts.
675
676
677 @refbugs
678
679 It is not possible to use fingerings (e.g., @code{R1-4}) to put numbers
680 over multi-measure rests.  And the pitch of multi-measure rests (or
681 staff-centered rests) can not be influenced.
682
683 @cindex condensing rests
684
685 There is no way to automatically condense multiple rests into a single
686 multi-measure rest.  Multi-measure rests do not take part in rest
687 collisions.
688
689 Be careful when entering multi-measure rests followed by whole
690 notes.  The following will enter two notes lasting four measures each
691 @example
692 R1*4 cis cis
693 @end example
694 When @code{skipBars} is set, the result will look OK, but the bar
695 numbering will be off.
696
697
698 @node Metronome marks
699 @subsection Metronome marks
700
701 @cindex Tempo
702 @cindex beats per minute
703 @cindex metronome marking
704
705 Metronome settings can be entered as follows
706 @example
707 \tempo @var{duration} = @var{per-minute}
708 @end example
709
710 In the MIDI output, they are interpreted as a tempo change.  In the
711 layout output, a metronome marking is printed
712 @cindex @code{\tempo}
713 @lilypond[quote,raggedright,verbatim,fragment]
714 \tempo 8.=120 c''1
715 @end lilypond
716
717
718 @commonprop
719
720 To change the tempo in the MIDI output without printing anything, make
721 the metronome marking invisible
722 @example
723 \once \override Score.MetronomeMark #'transparent = ##t
724 @end example
725
726 To print other metronome markings, use these markup commands
727 @lilypond[quote,raggedright,verbatim,relative,fragment]
728 c4^\markup {
729   (
730   \smaller \general-align #Y #DOWN \note #"16." #1
731   =
732   \smaller \general-align #Y #DOWN \note #"8" #1
733   ) }
734 @end lilypond
735
736 @noindent
737 See @ref{Text markup} for more details.
738
739
740 @seealso
741
742 Program reference: @internalsref{MetronomeMark}.
743
744
745 @refbugs
746
747 Collisions are not checked.  If you have notes above the top line of
748 the staff (or notes with articulations, slurs, text, etc), then the
749 metronome marking may be printed on top of musical symbols.  If this
750 occurs, increase the padding of the metronome mark to place it 
751 further away from the staff.
752
753 @example
754 \override Score.MetronomeMark #'padding = #2.5
755 @end example
756
757
758 @node Rehearsal marks
759 @subsection Rehearsal marks
760
761 @cindex Rehearsal marks
762 @cindex @code{\mark}
763
764 To print a rehearsal mark, use the @code{\mark} command
765
766 @lilypond[quote,raggedright,fragment,verbatim,relative=2]
767 c1 \mark \default
768 c1 \mark \default
769 c1 \mark #8
770 c1 \mark \default
771 c1 \mark \default
772 @end lilypond
773
774 @noindent
775 The letter@tie{}`I' is skipped in accordance with engraving traditions.
776 If you wish to include the letter `I', then use
777
778 @example
779 \set Score.markFormatter = #format-mark-alphabet
780 @end example
781
782 The mark is incremented automatically if you use @code{\mark
783 \default}, but you can also use an integer argument to set the mark
784 manually.  The value to use is stored in the property
785 @code{rehearsalMark}.
786
787 The style is defined by the property @code{markFormatter}.  It is a
788 function taking the current mark (an integer) and the current context
789 as argument.  It should return a markup object.  In the following
790 example, @code{markFormatter} is set to a canned procedure.  After a
791 few measures, it is set to function that produces a boxed number.
792
793 @lilypond[fragment,quote,raggedright,verbatim,relative=2]
794 \set Score.markFormatter = #format-mark-numbers
795 c1 \mark \default
796 c1 \mark \default
797 \set Score.markFormatter = #format-mark-box-numbers
798 c1 \mark \default
799 c1 \mark \default
800 c1
801 @end lilypond
802
803 The file @file{scm/@/translation@/-functions@/.scm} contains the definitions
804 of @code{format-mark-numbers} (the default format), @code{format-mark-box-numbers},
805 @code{format-mark-letters} and @code{format-mark-box-letters}.
806 These can be used as inspiration for other formatting functions.
807
808
809 @seealso
810
811 Program reference: @internalsref{RehearsalMark}.
812
813 Init files: @file{scm/@/translation@/-functions@/.scm} contains the
814 definition of @code{format-mark-numbers} and
815 @code{format-mark-letters}.  They can be used as inspiration for other
816 formatting functions.
817
818 Examples: @inputfileref{input/@/regression,rehearsal@/-mark@/-letter@/.ly},
819
820 @inputfileref{input/@/regression,rehearsal@/-mark@/-number@/.ly}.
821
822
823 @node Bar numbers
824 @subsection Bar numbers
825
826 @cindex Bar numbers
827 @cindex measure numbers
828 @cindex @code{currentBarNumber}
829
830 Bar numbers are printed by default at the start of the line.  The
831 number itself is stored in the @code{currentBarNumber} property, which
832 is normally updated automatically for every measure.
833
834 Bar numbers can be typeset at regular intervals instead of at the
835 beginning of each line.  This is illustrated in the following example,
836 whose source is available as
837 @inputfileref{input/@/test,bar@/-number@/-regular@/-interval@/.ly}
838
839 @lilypondfile[raggedright,quote]{bar-number-regular-interval.ly}
840
841 Bar numbers can be typeset manually by tweaking the
842 @code{markFormatter} property
843
844 @lilypond[verbatim,raggedright,quote]
845 \relative c' {
846   \set Score.markFormatter
847     = #(lambda (mark context)
848       (make-bold-markup
849         (make-box-markup
850           (number->string (ly:context-property context
851                                                'currentBarNumber)))))
852
853   c1 \bar "||" \mark \default c1 c1 \mark \default c1 \bar "|."
854 }
855 @end lilypond
856
857 Bar numbers can be manually changed by setting the
858 @code{Staff.currentBarNumber} property
859
860 @lilypond[verbatim,raggedright,quote]
861 \relative c' {
862   \repeat unfold 4 {c4 c c c} \break
863   \set Score.currentBarNumber = #50
864   \repeat unfold 4 {c4 c c c}
865 }
866 @end lilypond
867
868
869 @seealso
870
871 Program reference: @internalsref{BarNumber}.
872
873 Examples:
874 @inputfileref{input/@/test,bar@/-number@/-every@/-five@/-reset@/.ly},
875 and @inputfileref{input/@/test,bar@/-number@/-regular@/-interval@/.ly}.
876
877
878 @refbugs
879
880 Bar numbers can collide with the @internalsref{StaffGroup} bracket, if
881 there is one at the top.  To solve this, the
882 @code{padding} property of @internalsref{BarNumber} can be
883 used to position the number correctly.
884
885
886 @node Instrument names
887 @subsection Instrument names
888
889 In an orchestral score, instrument names are printed at the left side
890 of the staves.
891
892 This can be achieved by setting @internalsref{Staff}.@code{instrument}
893 and @internalsref{Staff}.@code{instr}.  This will print a string before
894 the start of the staff.  For the first staff, @code{instrument} is
895 used, for the following ones, @code{instr} is used.
896
897 @lilypond[quote,verbatim,raggedright,relative=1,fragment]
898 \set Staff.instrument = "Ploink "
899 \set Staff.instr = "Plk "
900 c1
901 \break
902 c''
903 @end lilypond
904
905 You can also use markup texts to construct more complicated instrument
906 names, for example
907
908 @lilypond[quote,fragment,verbatim,raggedright]
909 \set Staff.instrument = \markup {
910   \column { "Clarinetti"
911             \line { "in B" \smaller \flat } } }
912 c''1
913 @end lilypond
914
915 If you wish to center the instrument names, you must center all of them
916
917 @lilypond[quote,verbatim,raggedright]
918 { <<
919 \new Staff {
920   \set Staff.instrument = \markup {
921     \center-align { "Clarinetti"
922       \line { "in B" \smaller \flat } } }
923   c''1
924 }
925 \new Staff {
926   \set Staff.instrument = \markup{ \center-align { Vibraphone }}
927   c''1
928 }
929 >>
930 }
931 @end lilypond
932
933 For longer instrument names, it may be useful to increase the
934 @code{indent} setting in the @code{\layout} block.
935
936 @seealso
937
938 Program reference: @internalsref{InstrumentName}.
939
940 @refbugs
941
942 When you put a name on a grand staff or piano staff, the width of the
943 brace is not taken into account. The following property setting can be
944 used to move the instrument names to the left, in such situations.
945
946 @example
947 \override Score.InstrumentName #'space-alist = #'((left-edge extra-space . 2.0))
948 @end example
949
950
951 @node Instrument transpositions
952 @subsection Instrument transpositions
953
954 @cindex transposition, MIDI
955 @cindex transposition, instrument
956
957 The key of a transposing instrument can also be specified.  This
958 applies to many wind instruments, for example, clarinets (B-flat, A, and
959 E-flat), horn (F) and trumpet (B-flat, C, D, and E-flat).
960
961 The transposition is entered after the keyword @code{\transposition}
962
963 @example
964 \transposition bes   %% B-flat clarinet
965 @end example
966
967 @noindent
968 This command sets the property @code{instrumentTransposition}.  The value of
969 this property is used for MIDI output and quotations.  It does not
970 affect how notes are printed in the current staff.  To change the printed
971 output, see @ref{Transpose}.
972
973 The pitch to use for @code{\transposition} should correspond to the
974 real sound heard when a @code{c'} written on the staff is played by the
975 transposing instrument.  For example, when entering a score in
976 concert pitch, typically all voices are entered in C, so
977 they should be entered as
978
979 @example
980 clarinet = @{
981   \transposition c'
982   ...
983 @}
984 saxophone = @{
985   \transposition c'
986   ...
987 @}
988 @end example
989
990 The command @code{\transposition} should be used when the music is
991 entered from a (transposed) orchestral part.  For example, in
992 classical horn parts, the tuning of the instrument is often changed
993 during a piece.  When copying the notes from the part, use
994 @code{\transposition}, e.g.,
995
996 @example
997 \transposition d'
998 c'4^"in D"
999 ...
1000 \transposition g'
1001 c'4^"in G"
1002 ...
1003 @end example
1004
1005
1006 @node Ottava brackets
1007 @subsection Ottava brackets
1008
1009 `Ottava' brackets introduce an extra transposition of an octave for
1010 the staff.  They are created by invoking the function
1011 @code{set-octavation}
1012
1013 @cindex ottava
1014 @cindex 15ma
1015 @cindex octavation
1016
1017 @lilypond[quote,raggedright,verbatim,fragment]
1018 \relative c''' {
1019   a2 b
1020   #(set-octavation 1)
1021   a b
1022   #(set-octavation 0)
1023   a b
1024 }
1025 @end lilypond
1026
1027 The @code{set-octavation} function also takes -1 (for 8va bassa) and 2
1028 (for 15ma) as arguments.  Internally the function sets the properties
1029 @code{ottavation} (e.g., to @code{"8va"}) and
1030 @code{centralCPosition}.  For overriding the text of the bracket, set
1031 @code{ottavation} after invoking @code{set-octavation}, i.e.,
1032
1033 @lilypond[quote,raggedright,verbatim]
1034 {
1035   #(set-octavation 1)
1036   \set Staff.ottavation = #"8"
1037   c'''
1038 }
1039 @end lilypond
1040
1041
1042 @seealso
1043
1044 Program reference: @internalsref{OttavaBracket}.
1045
1046 Examples: @inputfileref{input/@/regression,ottava@/.ly},
1047 @inputfileref{input/@/regression,ottava@/-broken@/.ly}.
1048
1049
1050 @refbugs
1051
1052 @code{set-octavation} will get confused when clef changes happen
1053 during an octavation bracket.
1054
1055
1056 @node Different editions from one source
1057 @subsection Different editions from one source
1058
1059 @cindex @code{\tag}
1060 @cindex tag
1061
1062 The @code{\tag} command marks music expressions with a name.  These
1063 tagged expressions can be filtered out later.  With this mechanism it
1064 is possible to make different versions of the same music source.
1065
1066 In the following example, we see two versions of a piece of music, one
1067 for the full score, and one with cue notes for the instrumental part
1068
1069 @example
1070 c1
1071 <<
1072   \tag #'part <<
1073     R1 \\
1074     @{
1075       \set fontSize = #-1
1076       c4_"cue" f2 g4 @}
1077   >>
1078   \tag #'score R1
1079 >>
1080 c1
1081 @end example
1082
1083 The same can be applied to articulations, texts, etc.: they are
1084 made by prepending
1085 @example
1086 -\tag #@var{your-tag}
1087 @end example
1088 to an articulation, for example,
1089 @example
1090 c1-\tag #'part ^4
1091 @end example
1092
1093 This defines a note with a conditional fingering indication.
1094
1095 @cindex keepWithTag
1096 @cindex removeWithTag
1097 By applying the @code{\keepWithTag} and @code{\removeWithTag}
1098 commands, tagged expressions can be filtered.  For example,
1099 @example
1100 <<
1101   @var{the music}
1102   \keepWithTag #'score @var{the music}
1103   \keepWithTag #'part @var{the music}
1104 >>
1105 @end example
1106 would yield
1107
1108 @lilypondfile[raggedright,quote]{tag-filter.ly}
1109
1110 The argument of the @code{\tag} command should be a symbol. It's 
1111 possible to put multiple tags on a piece of music, with multiple
1112 @code{\tag} entries, 
1113 @example
1114   \tag #'original-part \tag #'transposed-part @dots{}
1115 @end example
1116
1117
1118 @seealso
1119
1120 Examples: @inputfileref{input/@/regression,tag@/-filter@/.ly}.
1121
1122
1123 @refbugs
1124
1125 Multiple rests are not merged if you create the score with both tagged
1126 sections.
1127  
1128
1129
1130 @node Orchestral music
1131 @section Orchestral music
1132
1133 Orchestral music involves some special notation, both in the full
1134 score and the individual parts.  This section explains how to tackle
1135 some common problems in orchestral music.
1136
1137 @menu
1138 * Automatic part combining::    
1139 * Hiding staves::               
1140 * Quoting other voices::        
1141 * Formatting cue notes::        
1142 * Aligning to cadenzas::        
1143 @end menu
1144
1145
1146 @node Automatic part combining
1147 @subsection Automatic part combining
1148 @cindex automatic part combining
1149 @cindex part combiner
1150
1151 Automatic part combining is used to merge two parts of music onto a
1152 staff.  It is aimed at typesetting orchestral scores.  When the two
1153 parts are identical for a period of time, only one is shown.  In
1154 places where the two parts differ, they are typeset as separate
1155 voices, and stem directions are set automatically.  Also, solo and
1156 @emph{a due} parts are identified and can be marked.
1157
1158 The syntax for part combining is
1159
1160 @example
1161 \partcombine @var{musicexpr1} @var{musicexpr2}
1162 @end example
1163
1164
1165 The following example demonstrates the basic functionality of the part
1166 combiner: putting parts on one staff, and setting stem directions and
1167 polyphony
1168
1169 @lilypond[quote,verbatim,raggedright,fragment]
1170 \new Staff \partcombine
1171   \relative g' { g g a( b) c c r r }
1172   \relative g' { g g r4 r e e g g }
1173 @end lilypond
1174
1175 The first @code{g} appears only once, although it was
1176 specified twice (once in each part).  Stem, slur, and tie directions are
1177 set automatically, depending whether there is a solo or unisono.  The
1178 first part (with context called @code{one}) always gets up stems, and
1179 `Solo', while the second (called @code{two}) always gets down stems and
1180 `Solo II'.
1181
1182 If you just want the merging parts, and not the textual markings, you
1183 may set the property @code{printPartCombineTexts} to false
1184
1185 @lilypond[quote,verbatim,raggedright,fragment,relative=2]
1186 \new Staff <<
1187   \set Staff.printPartCombineTexts = ##f
1188   \partcombine
1189     \relative g' { g a( b) r }
1190     \relative g' { g r4 r f }
1191 >>
1192 @end lilypond
1193
1194 To change the text that is printed for solos or merging, you may
1195 set the @code{soloText}, @code{soloIIText}, and @code{aDueText}
1196 properties.
1197
1198 @lilypond[quote,verbatim,raggedright,fragment,relative=2]
1199 \new Staff <<
1200   \set Score.soloText = #"ichi"
1201   \set Score.soloIIText = #"ni"
1202   \set Score.aDueText = #"tachi"
1203   \partcombine
1204     \relative g' { g4 g a( b) r }
1205     \relative g' { g4 g r r f }
1206 >>
1207 @end lilypond
1208
1209 Both arguments to @code{\partcombine} will be interpreted as
1210 @internalsref{Voice} contexts.  If using relative octaves,
1211 @code{\relative} should be specified for both music expressions, i.e.,
1212
1213 @example
1214 \partcombine
1215   \relative @dots{} @var{musicexpr1}
1216   \relative @dots{} @var{musicexpr2}
1217 @end example
1218
1219 @noindent
1220 A @code{\relative} section that is outside of @code{\partcombine} has
1221 no effect on the pitches of @var{musicexpr1} and @var{musicexpr2}.
1222
1223 @seealso
1224
1225 Program reference: @internalsref{PartCombineMusic}.
1226
1227 @refbugs
1228
1229 When @code{printPartCombineTexts} is set, when the two voices play the
1230 same notes on and off, the part combiner may typeset @code{a2} more
1231 than once in a measure.
1232
1233 @code{\partcombine} cannot be inside @code{\times}.
1234
1235 @code{\partcombine} cannot be inside @code{\relative}.
1236
1237 Internally, the @code{\partcombine} interprets both arguments as
1238 @code{Voice}s named @code{one} and @code{two}, and then decides when
1239 the parts can be combined.  Consequently, if the arguments switch to
1240 differently named @internalsref{Voice} contexts, the events in those
1241 will be ignored.
1242
1243
1244 @node Hiding staves
1245 @subsection Hiding staves
1246
1247 @cindex Frenched scores
1248 @cindex Hiding staves
1249
1250 In orchestral scores, staff lines that only have rests are usually
1251 removed; this saves some space.  This style is called `French Score'.
1252 For @internalsref{Lyrics},
1253 @internalsref{ChordNames} and @internalsref{FiguredBass}, this is
1254 switched on by default.  When the lines of these contexts turn out
1255 empty after the line-breaking process, they are removed.
1256
1257 For normal staves, a specialized @internalsref{Staff} context is
1258 available, which does the same: staves containing nothing (or only
1259 multi-measure rests) are removed.  The context definition is stored in
1260 @code{\RemoveEmptyStaffContext} variable.  Observe how the second staff
1261 in this example disappears in the second line
1262
1263 @lilypond[quote,raggedright,verbatim]
1264 \layout {
1265   \context { \RemoveEmptyStaffContext }
1266 }
1267
1268 {
1269   \relative c' <<
1270     \new Staff { e4 f g a \break c1 }
1271     \new Staff { c4 d e f \break R1 }
1272   >>
1273 }
1274 @end lilypond
1275
1276 The first system shows all staves in full.  If empty staves should be
1277 removed from the first system too, set @code{remove-first} to true in
1278 @internalsref{VerticalAxisGroup}.
1279
1280 @example
1281 \override Score.VerticalAxisGroup #'remove-first = ##t
1282 @end example
1283
1284 To remove other types of contexts, use @code{\AncientRemoveEmptyStaffContext}
1285 or @code{\RemoveEmptyRhythmicStaffContext}.
1286
1287 Another application is making ossia sections, i.e., alternative
1288 melodies on a separate piece of staff, with help of a Frenched
1289 staff.  See @inputfileref{input/@/test,ossia@/.ly} for an example.
1290
1291
1292 @node Quoting other voices
1293 @subsection Quoting other voices
1294
1295 With quotations, fragments of other parts can be inserted into a part
1296 directly.  Before a part can be quoted, it must be marked especially as
1297 quotable.  This is done with the @code{\addquote} command.
1298
1299 @example
1300 \addquote @var{name} @var{music}
1301 @end example
1302
1303
1304 @noindent
1305 Here, @var{name} is an identifying string.  The @var{music} is any kind
1306 of music.  Here is an example of @code{\addquote}
1307
1308 @example
1309 \addquote clarinet \relative c' @{
1310   f4 fis g gis
1311 @}
1312 @end example
1313
1314 This command must be entered at toplevel, i.e., outside any music
1315 blocks.
1316
1317 After calling @code{\addquote}, the quotation may then be done with
1318 @code{\quoteDuring} or @code{\cueDuring},
1319
1320 @example
1321 \quoteDuring #@var{name} @var{music}
1322 @end example
1323
1324 During a part, a piece of music can be quoted with the @code{\quoteDuring}
1325 command.
1326
1327 @example
1328 \quoteDuring #"clarinet" @{ s2. @}
1329 @end example
1330
1331 This would cite three quarter notes (the duration of @code{s2.})  of
1332 the previously added @code{clarinet} voice.
1333
1334
1335 More precisely, it takes the current time-step of the part being
1336 printed, and extracts the notes at the corresponding point of the
1337 @code{\addquote}d voice.  Therefore, the argument to @code{\addquote}
1338 should be the entire part of the voice to be quoted, including any
1339 rests at the beginning.
1340
1341 Quotations take into account the transposition of both source and target
1342 instruments, if they are specified using the @code{\transposition} command.
1343
1344 @lilypond[quote,raggedright,verbatim]
1345 \addquote clarinet \relative c' {
1346   \transposition bes
1347   f4 fis g gis
1348 }
1349
1350 {
1351   e'8 f'8 \quoteDuring #"clarinet" { s2 }
1352 }
1353 @end lilypond
1354
1355 The type of events that are present in cue notes can be trimmed with
1356 the @code{quotedEventTypes} property.  The default value is
1357 @code{(note-event rest-event)}, which means that only notes and
1358 rests of the cued voice end up in the @code{\quoteDuring}.
1359 Setting
1360
1361 @example
1362 \set Staff.quotedEventTypes =
1363        #'(note-event articulation-event dynamic-event)
1364 @end example
1365
1366 @noindent
1367 will quote notes (but no rests), together with scripts and dynamics.
1368
1369 @refbugs
1370
1371 Only the contents of the first @internalsref{Voice} occurring in an
1372 @code{\addquote} command will be considered for quotation, so
1373 @var{music} can not contain @code{\new} and @code{\context Voice}
1374 statements that would switch to a different Voice.
1375
1376 Quoting grace notes is broken and can even cause LilyPond to crash.
1377
1378 @seealso
1379
1380 In this manual: @ref{Instrument transpositions}.
1381
1382 Examples: @inputfileref{input/@/regression,quote@/.ly}
1383 @inputfileref{input/@/regression,quote@/-transposition@/.ly}
1384
1385 Program reference: @internalsref{QuoteMusic}.
1386
1387
1388 @node Formatting cue notes
1389 @subsection Formatting cue notes
1390
1391 The previous section deals with inserting notes from another voice.
1392 There is a more advanced music function called @code{\cueDuring},
1393 which makes formatting cue notes easier.
1394
1395 The syntax is
1396
1397 @example
1398   \cueDuring #@var{name} #@var{updown} @var{music}
1399 @end example
1400
1401 This will insert notes from the part @var{name} into a
1402 @internalsref{Voice} called @code{cue}.  This happens simultaneously
1403 with @var{music}, which usually is a rest.  When the cue notes start,
1404 the staff in effect becomes polyphonic for a moment.  The argument
1405 @var{updown} determines whether the cue notes should be notated as a
1406 first or second voice.
1407
1408
1409 @lilypond[verbatim,raggedright]
1410 smaller = {
1411   \set fontSize = #-2
1412   \override Stem #'length-fraction = #0.8
1413   \override Beam #'thickness = #0.384
1414   \override Beam #'length-fraction = #0.8
1415 }
1416
1417 \addquote clarinet \relative {
1418   R1*20
1419   r2 r8 c f f
1420
1421
1422 \new Staff \relative  <<
1423
1424   % setup a context for  cue  notes.
1425   \context Voice = cue { \smaller \skip 1*21 }
1426   
1427   \set Score.skipBars = ##t
1428   
1429   \new Voice {
1430     R1*20
1431     \cueDuring #"clarinet" #1 {
1432       R1
1433     }
1434     g4 g2. 
1435   }
1436 >>
1437 @end lilypond 
1438
1439
1440 Here are a couple of hints for successful cue notes
1441
1442 @itemize @bullet
1443 @item
1444 Cue notes have smaller font sizes.
1445 @item
1446  the cued part is marked with the instrument playing the cue.
1447 @item
1448  when the original part takes over again, this should be marked with
1449  the name of the original instrument.
1450
1451 @c really?  Are you sure about that last point?  I'll check after 3.0 -gp
1452
1453 @c Yes, this is good practice.  Otherwise, the start of the original
1454 @c part can only be seen from the font size.  This is not good enough
1455 @c for sight-reading.  It is possilbe to use other
1456 @c markers (eg. a big close-bracket over the staff) to indicate the cue notes are
1457 @c finished.
1458 @c -hwn
1459
1460
1461 Any other changes introduced by the cued part should also be
1462 undone.  For example, if the cued instrument plays in a different clef,
1463 the original clef should be stated once again.
1464
1465 @end itemize
1466
1467
1468 @node Aligning to cadenzas
1469 @subsection Aligning to cadenzas
1470
1471 In an orchestral context, cadenzas present a special problem:
1472 when constructing a score that includes a cadenza, all other
1473 instruments should skip just as many notes as the length of the
1474 cadenza, otherwise they will start too soon or too late.
1475
1476 A solution to this problem are the functions @code{mmrest-of-length}
1477 and @code{skip-of-length}.  These Scheme functions take a piece of music
1478 as argument, and generate a @code{\skip} or multi-rest, exactly as
1479 long as the piece.  The use of @code{mmrest-of-length} is demonstrated
1480 in the following example.
1481
1482 @lilypond[verbatim,raggedright,quote]
1483 cadenza = \relative c' {
1484   c4 d8 << { e f g } \\ { d4. } >>
1485   g4 f2 g4 g
1486 }
1487
1488 \new GrandStaff <<
1489   \new Staff { \cadenza c'4 }
1490   \new Staff {
1491     #(ly:export (mmrest-of-length cadenza))
1492     c'4
1493   }
1494 >>
1495 @end lilypond
1496
1497
1498
1499
1500 @node Contemporary notation
1501 @section Contemporary notation
1502
1503 In the 20th century, composers have greatly expanded the musical
1504 vocabulary.  With this expansion, many innovations in musical notation
1505 have been tried.  The book ``Music Notation in the 20th century'' by
1506 Kurt Stone gives a comprehensive overview (see @ref{Literature
1507 list}).  In general, the use of new, innovative notation makes a piece
1508 harder to understand and perform and its use should therefore be
1509 avoided.  For this reason, support for contemporary notation in
1510 LilyPond is limited.
1511
1512
1513 @menu
1514 * Polymetric notation::         
1515 * Time administration::         
1516 * Clusters::                    
1517 * Special fermatas::            
1518 * Special noteheads::           
1519 * Pitched trills::              
1520 * Feathered beams::             
1521 * Improvisation::               
1522 @end menu
1523
1524
1525 @node Polymetric notation
1526 @subsection Polymetric notation
1527
1528 Double time signatures are not supported explicitly, but they can be
1529 faked.  In the next example, the markup for the time signature is
1530 created with a markup text.  This markup text is inserted in the
1531 @internalsref{TimeSignature} grob.
1532
1533 @lilypond[verbatim,raggedright]
1534 % create 2/4 + 5/8
1535 tsMarkup =\markup {
1536   \number {
1537     \column { "2" "4" }
1538     \musicglyph #"scripts.stopped"
1539     \bracket \column { "5" "8" }
1540   }
1541 }
1542
1543 {
1544   \override Staff.TimeSignature #'stencil = #Text_interface::print
1545   \override Staff.TimeSignature #'text = #tsMarkup
1546   \time 3/2
1547   c'2 \bar ":" c'4 c'4.
1548 }
1549 @end lilypond
1550
1551 Each staff can also have its own time signature.  This is done by
1552 moving the @internalsref{Timing_translator} to the @internalsref{Staff}
1553 context.
1554
1555 @example
1556 \layout @{
1557   \context @{ \Score
1558      \remove "Timing_translator"
1559      \remove "Default_bar_line_engraver"
1560   @}
1561   \context @{
1562     \Staff
1563     \consists "Timing_translator"
1564     \consists "Default_bar_line_engraver"
1565   @}
1566     
1567 @}
1568 @end example
1569
1570
1571 Now, each staff has its own time signature.
1572 @example
1573 <<
1574   \new Staff @{
1575     \time 3/4
1576     c4 c c | c c c |
1577   @}
1578   \new Staff @{
1579     \time 2/4
1580     c4 c | c c | c c
1581   @}
1582   \new Staff @{
1583     \time 3/8
1584     c4. c8 c c c4. c8 c c
1585   @}
1586 >>
1587 @end example
1588
1589 @lilypond[quote,raggedright]
1590 \layout{
1591   \context{
1592      \Score
1593      \remove "Timing_translator"
1594      \remove "Default_bar_line_engraver"
1595     }
1596   \context{ \Staff
1597     \consists "Timing_translator"
1598     \consists "Default_bar_line_engraver"
1599   }
1600 }
1601
1602 \relative c' <<
1603   \new Staff {
1604     \time 3/4
1605     c4 c c | c c c |
1606   }
1607   \new Staff {
1608     \time 2/4
1609     c4 c | c c | c c
1610   }
1611   \new Staff {
1612     \time 3/8
1613     c4. c8 c c c4. c8 c c
1614   }
1615 >>
1616 @end lilypond
1617
1618
1619 A different form of polymetric notation is where note lengths have
1620 different values across staves.
1621
1622 This notation can be created by setting a common time signature for
1623 each staff but replacing it manually using
1624 @code{timeSignatureFraction} to the desired fraction.  Then the printed
1625 durations in each staff are scaled to the common time signature.
1626 The latter is done with @code{\compressMusic}, which is used similar
1627 to @code{\times}, but does not create a tuplet bracket. The syntax is
1628 @example
1629 \compressMusic #'(@var{numerator} . @var{denominator}) @var{musicexpr}
1630 @end example
1631
1632
1633
1634 In this example, music with the time signatures of 3/4, 9/8, and 10/8 are
1635 used in parallel.  In the second staff, shown durations are multiplied by
1636 2/3, so that 2/3 * 9/8 = 3/4, and in the third staff, shown durations are
1637 multiplied by 3/5, so that 3/5 * 10/8 = 3/4.
1638
1639 @lilypond[quote,raggedright,verbatim,fragment]
1640 \relative c' { <<
1641   \new Staff {
1642     \time 3/4
1643     c4 c c | c c c |
1644   }
1645   \new Staff {
1646     \time 3/4
1647     \set Staff.timeSignatureFraction = #'(9 . 8)
1648     \compressMusic #'(2 . 3)
1649       \repeat unfold 6 { c8[ c c] }
1650   }
1651   \new Staff {
1652     \time 3/4
1653     \set Staff.timeSignatureFraction = #'(10 . 8)
1654     \compressMusic #'(3 . 5) {
1655       \repeat unfold 2 { c8[ c c] }
1656       \repeat unfold 2 { c8[ c] }
1657       | c4. c4. \times 2/3 { c8 c c } c4
1658     }
1659   }
1660 >> }
1661 @end lilypond
1662
1663
1664
1665
1666 @refbugs
1667
1668 When using different time signatures in parallel, the spacing is
1669 aligned vertically, but bar lines distort the regular spacing.
1670
1671
1672 @node Time administration
1673 @subsection Time administration
1674
1675 @cindex Time administration
1676
1677 Time is administered by the @internalsref{Time_signature_engraver},
1678 which usually lives in the @internalsref{Score} context.  The
1679 bookkeeping deals with the following variables
1680
1681 @table @code
1682 @item currentBarNumber
1683 The measure number.
1684
1685 @item measureLength
1686 The length of the measures in the current time signature.  For a 4/4
1687 time this is@tie{}1, and for 6/8 it is 3/4.
1688
1689 @item measurePosition
1690 The point within the measure where we currently are.  This quantity
1691 is reset to@tie{}0 whenever it exceeds @code{measureLength}.  When that
1692 happens, @code{currentBarNumber} is incremented.
1693
1694 @item timing
1695 If set to true, the above variables are updated for every time
1696 step.  When set to false, the engraver stays in the current measure
1697 indefinitely.
1698 @end table
1699
1700 Timing can be changed by setting any of these variables explicitly.
1701 In the next example, the 4/4 time signature is printed, but
1702 @code{measureLength} is set to 5/4.  After a while, the measure is
1703 shortened by 1/8, by setting @code{measurePosition} to 7/8 at 2/4
1704 in the measure, so the next bar line will fall at 2/4 + 3/8.  The
1705 3/8 arises because 5/4 normally has 10/8, but we have manually
1706 set the measure position to be 7/8 and 10/8 - 7/8 = 3/8.
1707
1708 @lilypond[quote,raggedright,verbatim,relative,fragment]
1709 \set Score.measureLength = #(ly:make-moment 5 4)
1710 c1 c4
1711 c1 c4
1712 c4 c4
1713 \set Score.measurePosition = #(ly:make-moment 7 8)
1714 b8 b b
1715 c4 c1
1716 @end lilypond
1717
1718
1719
1720 @node Clusters
1721 @subsection Clusters
1722
1723 @cindex cluster
1724
1725 A cluster indicates a continuous range of pitches to be played.  They
1726 can be denoted as the envelope of a set of notes.  They are entered by
1727 applying the function @code{makeClusters} to a sequence of
1728 chords, e.g.,
1729 @lilypond[quote,raggedright,relative=2,fragment,verbatim]
1730 \makeClusters { <c e > <b f'> }
1731 @end lilypond
1732
1733 The following example (from
1734 @inputfileref{input/@/regression,cluster@/.ly}) shows what the result
1735 looks like
1736
1737 @lilypondfile[raggedright,quote]{cluster.ly}
1738
1739 Ordinary notes and clusters can be put together in the same staff,
1740 even simultaneously.  In such a case no attempt is made to
1741 automatically avoid collisions between ordinary notes and clusters.
1742
1743 @seealso
1744
1745 Program reference: @internalsref{ClusterSpanner},
1746 @internalsref{ClusterSpannerBeacon},
1747 @internalsref{Cluster_spanner_engraver}.
1748
1749 Examples: @inputfileref{input/@/regression,cluster@/.ly}.
1750
1751 @refbugs
1752
1753 Music expressions like @code{<< @{ g8 e8 @} a4 >>} are not printed
1754 accurately.  Use @code{<g a>8 <e a>8} instead.
1755
1756
1757
1758 @node Special fermatas
1759 @subsection Special fermatas
1760
1761 @cindex fermatas, special
1762
1763 In contemporary music notation, special fermata symbols denote breaks
1764 of differing lengths.  The following fermatas are supported
1765
1766 @lilypond[quote,raggedright]
1767 <<
1768   \oldaddlyrics {
1769     b'2
1770     ^\shortfermata
1771     _\shortfermata
1772     r
1773
1774     b'
1775     ^\fermata
1776     _\fermata
1777     r
1778
1779     b'
1780     ^\longfermata
1781     _\longfermata
1782     r
1783
1784     b'
1785     ^\verylongfermata
1786     _\verylongfermata
1787     r
1788   }
1789   \context Lyrics \lyricmode {
1790     \override LyricText #'font-family = #'typewriter
1791     "shortfermata" "fermata" "longfermata" "verylongfermata"
1792   }
1793 >>
1794 @end lilypond
1795
1796 See @ref{Articulations} for general instructions how to apply scripts
1797 such as fermatas to notes.
1798
1799
1800 @node Special noteheads
1801 @subsection Special noteheads
1802
1803 Different noteheads are used by various instruments for various
1804 meanings -- crosses are used for ``parlato'' with vocalists, stopped
1805 notes on guitar; diamonds are used for harmonics on string instruments,
1806 etc.  There is a shorthand (@code{\harmonic}) for diamond shapes; the
1807 other notehead styles are produced by tweaking the property
1808
1809 @lilypond[raggedright,relative=1,fragment,verbatim,quote]
1810 c4 d
1811 \override NoteHead #'style = #'cross
1812 e f
1813 \revert NoteHead #'style
1814 e d <c f\harmonic> <d a'\harmonic>
1815 @end lilypond
1816
1817 @noindent
1818 To see all notehead styles, please see
1819 @inputfileref{input/@/regression,note@/-head@/-style@/.ly}.
1820
1821
1822 @seealso
1823
1824 Program reference: @internalsref{NoteHead}.
1825
1826 @node Pitched trills
1827 @subsection Pitched trills
1828
1829 Trills that should be executed on an explicitly specified pitch can be
1830 typeset with the command @code{pitchedTrill}, 
1831
1832 @lilypond[raggedright,verbatim,fragment]
1833   \pitchedTrill c'4\startTrillSpan fis
1834   f'\stopTrillSpan
1835 @end lilypond
1836
1837 The first argument is the main note. The absolute pitch of the second
1838 is printed as a stemless note head in parentheses.
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[raggedright,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,raggedright,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,raggedright,relative=2]
1921 \context 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   \context Staff \emptymusic
1966   \context 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,raggedright,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,raggedright,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,raggedright,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,raggedright,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,raggedright,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,raggedright,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,raggedright,relative=1,fragment,verbatim]
2230 \context 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,raggedright,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,raggedright,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,raggedright,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,raggedright,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,raggedright,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,raggedright,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,raggedright,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,raggedright,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