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