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