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