]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/advanced-notation.itely
Minor changes and docs for color.
[lilypond.git] / Documentation / user / advanced-notation.itely
1 @c -*- coding: latin-1; 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 * Even more than notes::        
16 * Preparing parts::             
17 * Orchestral music::            
18 * Contemporary notation::       
19 * Educational use::             
20 * Automatic notation::          
21 @end menu
22
23
24 @c  really bad section name.  :(
25 @node Even more than notes
26 @section Even more than notes
27
28 @menu
29 * Text scripts::                
30 * Text spanners::               
31 * Transpose::                   
32 * Ottava brackets::             
33 * Multi measure rests::         
34 * Time administration::         
35 @end menu
36
37
38 @node Text scripts
39 @subsection Text scripts
40 @cindex Text scripts
41
42 @cindex text items, non-empty
43 @cindex non-empty texts
44
45 It is possible to place arbitrary strings of text or markup text (see
46 @ref{Text markup}) above or below notes by using a string
47 @code{c^"text"}.  By default, these indications do not influence the
48 note spacing, but by using the command @code{\fatText}, the widths
49 will be taken into account
50
51 @lilypond[quote,fragment,raggedright,verbatim,relative=1]
52 c4^"longtext" \fatText c4_"longlongtext" c4
53 @end lilypond
54
55 More complex formatting may also be added to a note by using the
56 markup command,
57 @lilypond[fragment,raggedright,verbatim,quote]
58 c'4^\markup { bla \bold bla }
59 @end lilypond
60
61 The @code{\markup} is described in more detail in
62 @ref{Text markup}.
63
64
65 @refcommands
66
67 @cindex @code{\fatText}
68 @code{\fatText},
69 @cindex @code{\emptyText}
70 @code{\emptyText}.
71
72 @seealso
73
74 In this manual: @ref{Text markup}.
75
76 Program reference: @internalsref{TextScriptEvent}, @internalsref{TextScript}.
77
78
79 @node Text spanners
80 @subsection Text spanners
81 @cindex Text spanners
82
83 Some performance indications, e.g., @i{rallentando} or @i{accelerando},
84 are written as text and are extended over many measures with dotted
85 lines.  Such texts are created using text spanners; attach
86 @code{\startTextSpan} and @code{\stopTextSpan} to the first and last
87 notes of the spanner.
88
89 The string to be printed, as well as the style, is set through object
90 properties
91
92 @lilypond[quote,raggedright,fragment,relative=1,verbatim]
93 c1
94 \override TextSpanner #'direction = #-1
95 \override TextSpanner #'edge-text = #'("rall " . "")
96 c2\startTextSpan b c\stopTextSpan a
97 @end lilypond
98
99
100 @seealso
101
102 Internals @internalsref{TextSpanEvent},
103 @internalsref{TextSpanner}.
104
105 Examples: @inputfileref{input/@/regression,text@/-spanner@/.ly}.
106
107
108 @node Transpose
109 @subsection Transpose
110 @cindex Transpose
111 @cindex transposition of pitches
112 @cindex @code{\transpose}
113
114 A music expression can be transposed with @code{\transpose}.  The
115 syntax is
116 @example
117 \transpose @var{from} @var{to} @var{musicexpr}
118 @end example
119
120 This means that @var{musicexpr} is transposed by the interval between
121 the pitches @var{from} and @var{to}: any note with pitch @code{from}
122 is changed to @code{to}.
123
124
125 For example, consider a piece written in the key of D-major.  If
126 this piece is a little too low for its performer, it can be
127 transposed up to E-major with
128 @example
129 \transpose d e @dots{}
130 @end example
131
132 Consider a part written for violin (a C instrument).  If
133 this part is to be played on the A clarinet, the following
134 transposition will produce the appropriate part
135
136 @example
137 \transpose a c @dots{}
138 @end example
139
140 @code{\transpose} distinguishes between enharmonic pitches: both
141 @code{\transpose c cis} or @code{\transpose c des} will transpose up
142 half a tone.  The first version will print sharps and the second
143 version will print flats
144
145 @lilypond[quote,raggedright,verbatim]
146 mus = { \key d \major cis d fis g }
147 \context Staff {
148   \clef "F" \mus
149   \clef "G"
150   \transpose c g' \mus
151   \transpose c f' \mus
152 }
153 @end lilypond
154
155 @code{\transpose} may also be used to input written notes for a
156 transposing instrument.  Pitches are normally entered into LilyPond
157 in C (or ``concert pitch''), but they may be entered in another
158 key.  For example, when entering music for a B-flat trumpet which
159 begins on concert D, one would write
160
161 @example
162 \transpose c bes @{ e4 @dots{} @}
163 @end example
164
165 To print this music in B-flat again (ie producing a trumpet part,
166 instead of a concert pitch conductor's score) you would wrap the
167 existing music with another @code{transpose}
168
169 @example
170 \transpose bes c @{ \transpose c bes @{ e4 @dots{} @} @}
171 @end example
172
173
174
175 @seealso
176
177 Program reference: @internalsref{TransposedMusic}, and
178 @internalsref{UntransposableMusic}.
179
180 @refbugs
181
182 If you want to use both @code{\transpose} and @code{\relative},
183 you must put @code{\transpose} outside of @code{\relative}, since
184 @code{\relative} will have no effect music that appears inside a
185 @code{\transpose}.
186
187
188 @node Ottava brackets
189 @subsection Ottava brackets
190
191 `Ottava' brackets introduce an extra transposition of an octave for
192 the staff.  They are created by invoking the function
193 @code{set-octavation}
194
195 @cindex ottava
196 @cindex 15ma
197 @cindex octavation
198
199 @lilypond[quote,raggedright,verbatim,fragment]
200 \relative c''' {
201   a2 b
202   #(set-octavation 1)
203   a b
204   #(set-octavation 0)
205   a b
206 }
207 @end lilypond
208
209 The @code{set-octavation} function also takes -1 (for 8va bassa) and 2
210 (for 15ma) as arguments.  Internally the function sets the properties
211 @code{ottavation} (e.g., to @code{"8va"}) and
212 @code{centralCPosition}.  For overriding the text of the bracket, set
213 @code{ottavation} after invoking @code{set-octavation}, i.e.,
214
215 @lilypond[quote,raggedright,verbatim]
216 {
217   #(set-octavation 1)
218   \set Staff.ottavation = #"8"
219   c'''
220 }
221 @end lilypond
222
223 @seealso
224
225 Program reference: @internalsref{OttavaBracket}.
226
227 Examples: @inputfileref{input/@/regression,ottava@/.ly},
228 @inputfileref{input/@/regression,ottava@/-broken@/.ly}.
229
230 @refbugs
231
232 @code{set-octavation} will get confused when clef changes happen
233 during an octavation bracket.
234
235
236 @node Multi measure rests
237 @subsection Multi measure rests
238 @cindex multi measure rests
239 @cindex Rests, multi measure
240
241 @cindex @code{R}
242
243 Multi-measure rests are entered using `@code{R}'.  It is specifically
244 meant for full bar rests and for entering parts: the rest can expand
245 to fill a score with rests, or it can be printed as a single
246 multi-measure rest.  This expansion is controlled by the property
247 @code{Score.skipBars}.  If this is set to true, empty measures will not
248 be expanded, and the appropriate number is added automatically
249
250 @lilypond[quote,raggedright,fragment,verbatim]
251 \time 4/4 r1 | R1 | R1*2
252 \set Score.skipBars = ##t R1*17 R1*4
253 @end lilypond
254
255 The @code{1} in @code{R1} is similar to the duration notation used for
256 notes.  Hence, for time signatures other than 4/4, you must enter other
257 durations.  This can be done with augmentation dots or fractions
258
259 @lilypond[quote,raggedright,fragment,verbatim]
260 \set Score.skipBars = ##t
261 \time 3/4
262 R2. | R2.*2
263 \time 13/8
264 R1*13/8
265 R1*13/8*12 |
266 \time 10/8 R4*5*4 |
267 @end lilypond
268
269 An @code{R} spanning a single measure is printed as either a whole rest
270 or a breve, centered in the measure regardless of the time signature.
271
272 If there are only a few measures of rest, LilyPond prints ``church rests''
273 (a series of rectangles) in the staff.  To replace that with a simple
274 rest, use @code{MultiMeasureRest.expand-limit}.
275
276 @lilypond[quote,raggedright,fragment,verbatim]
277 \set Score.skipBars = ##t
278 R1*2 | R1*5 | R1*9
279 \override MultiMeasureRest #'expand-limit = 1
280 R1*2 | R1*5 | R1*9
281 @end lilypond
282
283
284 @cindex text on multi-measure rest
285 @cindex script on multi-measure rest
286 @cindex fermata on multi-measure rest
287
288 Texts can be added to multi-measure rests by using the
289 @var{note}-@code{markup} syntax (see @ref{Text markup}).
290 A variable (@code{\fermataMarkup}) is provided for
291 adding fermatas
292
293 @lilypond[quote,raggedright,verbatim,fragment]
294 \set Score.skipBars = ##t
295 \time 3/4
296 R2.*10^\markup { \italic "ad lib." }
297 R2.^\fermataMarkup
298 @end lilypond
299
300 If you want to have text on the left end of a multi-measure rest,
301 attach the text to a zero-length skip note, i.e.,
302
303 @example
304 s1*0^"Allegro"
305 R1*4
306 @end example
307
308
309 @cindex whole rests for a full measure
310
311 @seealso
312
313 Program reference: @internalsref{MultiMeasureRestEvent},
314 @internalsref{MultiMeasureTextEvent},
315 @internalsref{MultiMeasureRestMusicGroup}, and
316 @internalsref{MultiMeasureRest}.
317
318 The layout object @internalsref{MultiMeasureRestNumber} is for the
319 default number, and @internalsref{MultiMeasureRestText} for user
320 specified texts.
321
322 @refbugs
323
324 It is not possible to use fingerings (e.g., @code{R1-4}) to put numbers
325 over multi-measure rests.  And the pitch of multi-measure rests (or
326 staff-centered rests) can not be influenced.
327
328 @cindex condensing rests
329
330 There is no way to automatically condense multiple rests into a single
331 multi-measure rest.  Multi-measure rests do not take part in rest
332 collisions.
333
334 Be careful when entering multi-measure rests followed by whole
335 notes.  The following will enter two notes lasting four measures each
336 @example
337 R1*4 cis cis
338 @end example
339 When @code{skipBars} is set, the result will look OK, but the bar
340 numbering will be off.
341
342
343 @node Time administration
344 @subsection Time administration
345
346 Time is administered by the @internalsref{Time_signature_engraver},
347 which usually lives in the @internalsref{Score} context.
348 The bookkeeping deals with the following variables
349
350 @table @code
351 @item currentBarNumber
352 The measure number.
353
354 @item measureLength
355 The length of the measures in the current time signature.  For a 4/4
356 time this is@tie{}1, and for 6/8 it is 3/4.
357
358 @item measurePosition
359 The point within the measure where we currently are.  This quantity
360 is reset to@tie{}0 whenever it exceeds @code{measureLength}.  When that
361 happens, @code{currentBarNumber} is incremented.
362
363 @item timing
364 If set to true, the above variables are updated for every time
365 step.  When set to false, the engraver stays in the current measure
366 indefinitely.
367 @end table
368
369 Timing can be changed by setting any of these variables explicitly.
370 In the next example, the 4/4 time signature is printed, but
371 @code{measureLength} is set to 5/4.  After a while, the measure is
372 shortened by 1/8, by setting @code{measurePosition} to 7/8 at 2/4
373 in the measure, so the next bar line will fall at 2/4 + 3/8.  The
374 3/8 arises because 5/4 normally has 10/8, but we have manually
375 set the measure position to be 7/8 and 10/8 - 7/8 = 3/8.
376
377 @lilypond[quote,raggedright,verbatim,relative,fragment]
378 \set Score.measureLength = #(ly:make-moment 5 4)
379 c1 c4
380 c1 c4
381 c4 c4
382 \set Score.measurePosition = #(ly:make-moment 7 8)
383 b8 b b
384 c4 c1
385 @end lilypond
386
387
388
389 @node Preparing parts
390 @section Preparing parts
391
392 This section describes various notation that are useful for preparing
393 individual parts.
394
395 @menu
396 * Metronome marks::             
397 * Rehearsal marks::             
398 * Bar numbers::                 
399 * Instrument names::            
400 * Instrument transpositions::   
401 * Different editions from one source::  
402 @end menu
403
404
405 @node Metronome marks
406 @subsection Metronome marks
407
408 @cindex Tempo
409 @cindex beats per minute
410 @cindex metronome marking
411
412 Metronome settings can be entered as follows
413 @example
414 \tempo @var{duration} = @var{per-minute}
415 @end example
416
417 In the MIDI output, they are interpreted as a tempo change.  In the
418 layout output, a metronome marking is printed
419 @cindex @code{\tempo}
420 @lilypond[quote,raggedright,verbatim,fragment]
421 \tempo 8.=120 c''1
422 @end lilypond
423
424 To change the tempo in the MIDI output without printing anything, make
425 the metronome marking invisible
426 @example
427 \once \override Score.MetronomeMark #'transparent = ##t
428 @end example
429
430 To print other metronome markings, use these markup commands
431 @lilypond[quote,raggedright,verbatim,relative,fragment]
432 c4^\markup {
433   "("
434   \smaller \general-align #Y #DOWN \note #"16." #1
435   "="
436   \smaller \general-align #Y #DOWN \note #"8" #1"
437   ")" }
438 @end lilypond
439
440 @noindent
441 See @ref{Text markup} for more details.
442
443
444 @seealso
445
446 Program reference: @internalsref{MetronomeChangeEvent}.
447
448 @refbugs
449
450 Collisions are not checked.  If you have notes above the top line of
451 the staff (or notes with articulations, slurs, text, etc), then the
452 metronome marking may be printed on top of musical symbols.  If this
453 occurs, increase the padding of the metronome mark to place it 
454 further away from the staff.
455
456 @example
457 \override Score.MetronomeMark #'padding = #2.5
458 @end example
459
460
461 @node Rehearsal marks
462 @subsection Rehearsal marks
463 @cindex Rehearsal marks
464 @cindex mark
465 @cindex @code{\mark}
466
467 To print a rehearsal mark, use the @code{\mark} command
468
469 @lilypond[quote,raggedright,fragment,verbatim,relative=2]
470 c1 \mark \default
471 c1 \mark \default
472 c1 \mark #8
473 c1 \mark \default
474 c1 \mark \default
475 @end lilypond
476
477 @noindent
478 (The letter@tie{}`I' is skipped in accordance with engraving traditions.)
479 @c umm, is the manual the right place for feature requests?  :)  -gp
480 @c FIXME - should make that tunable.
481
482 The mark is incremented automatically if you use @code{\mark
483 \default}, but you can also use an integer argument to set the mark
484 manually.  The value to use is stored in the property
485 @code{rehearsalMark}.
486
487 The style is defined by the property @code{markFormatter}.  It is a
488 function taking the current mark (an integer) and the current context
489 as argument.  It should return a markup object.  In the following
490 example, @code{markFormatter} is set to a canned procedure.  After a
491 few measures, it is set to function that produces a boxed number.
492
493 @lilypond[fragment,quote,raggedright,verbatim,relative=2]
494 \set Score.markFormatter = #format-mark-numbers
495 c1 \mark \default
496 c1 \mark \default
497 \set Score.markFormatter = #format-mark-box-numbers
498 c1 \mark \default
499 c1 \mark \default
500 c1
501 @end lilypond
502
503 The file @file{scm/@/translation@/-functions@/.scm} contains the definitions
504 of @code{format-mark-numbers} (the default format), @code{format-mark-box-numbers},
505 @code{format-mark-letters} and @code{format-mark-box-letters}.
506 These can be used as inspiration for other formatting functions.
507
508
509 @cindex coda on bar line
510 @cindex segno on bar line
511 @cindex fermata on bar line
512 @cindex bar lines, symbols on
513
514 The @code{\mark} command can also be used to put signs like coda,
515 segno, and fermata on a bar line.  Use @code{\markup} to
516 access the appropriate symbol
517
518 @lilypond[fragment,quote,raggedright,verbatim,relative=2]
519 c1 \mark \markup { \musicglyph #"scripts.ufermata" }
520 c1
521 @end lilypond
522
523 If the mark occurs at a line break, the mark will be printed at the
524 beginning of the next line.
525 @c  IMO this is a bug; hopefully it'll be fixed soon, so I can
526 @c  delete this sentence.   -gp
527 If there is no next line, then the mark will not be printed at all.
528 To print the mark at the end of the current line, use
529
530 @example
531 \override Score.RehearsalMark
532   #'break-visibility = #begin-of-line-invisible
533 @end example
534
535 @cindex fermatas
536 @cindex coda
537 @cindex segno
538 @cindex bar lines, putting symbols on
539
540 @seealso
541
542 Program reference: @internalsref{MarkEvent}, @internalsref{RehearsalMark}.
543
544 Init files: @file{scm/@/translation@/-functions@/.scm} contains the
545 definition of @code{format-mark-numbers} and
546 @code{format-mark-letters}.  They can be used as inspiration for other
547 formatting functions.
548
549 Examples: @inputfileref{input/@/regression,rehearsal@/-mark@/-letter@/.ly},
550
551 @inputfileref{input/@/regression,rehearsal@/-mark@/-number@/.ly}.
552
553
554 @node Bar numbers
555 @subsection Bar numbers
556
557
558 @cindex Bar numbers
559 @cindex measure numbers
560 @cindex @code{currentBarNumber}
561
562 Bar numbers are printed by default at the start of the line.  The
563 number itself is stored in the @code{currentBarNumber} property, which
564 is normally updated automatically for every measure.
565
566 Bar numbers can be typeset at regular intervals instead of at the
567 beginning of each line.  This is illustrated in the following example,
568 whose source is available as
569 @inputfileref{input/@/test,bar@/-number@/-regular@/-interval@/.ly}
570
571 @lilypondfile[raggedright,quote]{bar-number-regular-interval.ly}
572
573 Bar numbers can be typeset manually by tweaking the
574 @code{markFormatter} property
575
576 @lilypond[verbatim,raggedright,quote]
577 \relative c' {
578   \set Score.markFormatter
579     = #(lambda (mark context)
580       (make-bold-markup
581         (make-box-markup
582           (number->string (ly:context-property context
583                                                'currentBarNumber)))))
584
585   c1 \bar "||" \mark \default c1 c1 \mark \default c1 \bar "|."
586 }
587 @end lilypond
588
589 Bar numbers can be manually changed by setting the
590 @code{Staff.currentBarNumber} property
591
592 @lilypond[verbatim,raggedright,quote]
593 \relative c' {
594   \repeat unfold 4 {c4 c c c} \break
595   \set Score.currentBarNumber = #50
596   \repeat unfold 4 {c4 c c c}
597 }
598 @end lilypond
599
600 @seealso
601
602 Program reference: @internalsref{BarNumber}.
603
604 Examples:
605 @inputfileref{input/@/test,bar@/-number@/-every@/-five@/-reset@/.ly},
606 and @inputfileref{input/@/test,bar@/-number@/-regular@/-interval@/.ly}.
607
608 @refbugs
609
610 Bar numbers can collide with the @internalsref{StaffGroup} bracket, if
611 there is one at the top.  To solve this, the
612 @code{padding} property of @internalsref{BarNumber} can be
613 used to position the number correctly.
614
615
616 @node Instrument names
617 @subsection Instrument names
618
619 In an orchestral score, instrument names are printed at the left side
620 of the staves.
621
622 This can be achieved by setting @internalsref{Staff}.@code{instrument}
623 and @internalsref{Staff}.@code{instr}.  This will print a string before
624 the start of the staff.  For the first staff, @code{instrument} is
625 used, for the following ones, @code{instr} is used.
626
627 @lilypond[quote,verbatim,raggedright,relative=1,fragment]
628 \set Staff.instrument = "Ploink "
629 \set Staff.instr = "Plk "
630 c1
631 \break
632 c''
633 @end lilypond
634
635 You can also use markup texts to construct more complicated instrument
636 names, for example
637
638 @lilypond[quote,fragment,verbatim,raggedright]
639 \set Staff.instrument = \markup {
640   \column { "Clarinetti"
641             \line { "in B" \smaller \flat } } }
642 c''1
643 @end lilypond
644
645 For longer instrument names, it may be useful to increase the
646 @code{indent} setting in the @code{\layout} block.
647
648 @seealso
649
650 Program reference: @internalsref{InstrumentName}.
651
652 @refbugs
653
654 When you put a name on a grand staff or piano staff, the width of the
655 brace is not taken into account.  You must add extra spaces to the end of
656 the name to avoid a collision.
657
658
659 @node Instrument transpositions
660 @subsection Instrument transpositions
661 @cindex transposition, MIDI
662 @cindex transposition, instrument
663
664 The key of a transposing instrument can also be specified.  This
665 applies to many wind instruments, for example, clarinets (B-flat, A, and
666 E-flat), horn (F) and trumpet (B-flat, C, D, and E-flat).
667
668 The transposition is entered after the keyword @code{\transposition}
669
670 @example
671 \transposition bes   %% B-flat clarinet
672 @end example
673
674 @noindent
675 This command sets the property @code{instrumentTransposition}.  The value of
676 this property is used for MIDI output and quotations.  It does not
677 affect how notes are printed in the current staff.  To change the printed
678 output, see @ref{Transpose}.
679
680 The pitch to use for @code{\transposition} should correspond to the
681 transposition of the notes.  For example, when entering a score in
682 concert pitch, typically all voices are entered in C, so
683 they should be entered as
684
685 @example
686 clarinet = @{
687   \transposition c'
688   ...
689 @}
690 saxophone = @{
691   \transposition c'
692   ...
693 @}
694 @end example
695
696 The command @code{\transposition} should be used when the music is
697 entered from a (transposed) orchestral part.  For example, in
698 classical horn parts, the tuning of the instrument is often changed
699 during a piece.  When copying the notes from the part, use
700 @code{\transposition}, e.g.,
701
702 @example
703 \transposition d'
704 c'4^"in D"
705 ...
706 \transposition g'
707 c'4^"in G"
708 ...
709 @end example
710
711
712 @node Different editions from one source
713 @subsection Different editions from one source
714
715 @cindex tag
716 The @code{\tag} command marks music expressions with a name.  These
717 tagged expressions can be filtered out later.  With this mechanism it
718 is possible to make different versions of the same music source.
719
720 In the following example, we see two versions of a piece of music, one
721 for the full score, and one with cue notes for the instrumental part
722
723 @example
724 c1
725 <<
726   \tag #'part <<
727     R1 \\
728     @{
729       \set fontSize = #-1
730       c4_"cue" f2 g4 @}
731   >>
732   \tag #'score R1
733 >>
734 c1
735 @end example
736
737 The same can be applied to articulations, texts, etc.: they are
738 made by prepending
739 @example
740 -\tag #@var{your-tag}
741 @end example
742 to an articulation, for example,
743 @example
744 c1-\tag #'part ^4
745 @end example
746
747 This defines a note with a conditional fingering indication.
748
749 @cindex keepWithTag
750 @cindex removeWithTag
751 By applying the @code{\keepWithTag} and @code{\removeWithTag}
752 commands, tagged expressions can be filtered.  For example,
753 @example
754 <<
755   @var{the music}
756   \keepWithTag #'score @var{the music}
757   \keepWithTag #'part @var{the music}
758 >>
759 @end example
760 would yield
761
762 @lilypondfile[raggedright,quote]{tag-filter.ly}
763
764
765 The argument of the @code{\tag} command should be a symbol, or a list
766 of symbols, for example,
767 @example
768 \tag #'(original-part transposed-part) @dots{}
769 @end example
770
771
772
773 @seealso
774
775 Examples: @inputfileref{input/@/regression,tag@/-filter@/.ly}.
776
777 @refbugs
778
779 Multiple rests are not merged if you create the score with both tagged
780 sections.
781  
782
783 @node Orchestral music
784 @section Orchestral music
785
786 Orchestral music involves some special notation, both in the full
787 score and the individual parts.  This section explains how to tackle
788 some common problems in orchestral music.
789
790 @menu
791 * Automatic part combining::    
792 * Hiding staves::               
793 * Quoting other voices::        
794 * Formatting cue notes::        
795 * Aligning to cadenzas::        
796 @end menu
797
798
799 @node Automatic part combining
800 @subsection Automatic part combining
801 @cindex automatic part combining
802 @cindex part combiner
803
804 Automatic part combining is used to merge two parts of music onto a
805 staff.  It is aimed at typesetting orchestral scores.  When the two
806 parts are identical for a period of time, only one is shown.  In
807 places where the two parts differ, they are typeset as separate
808 voices, and stem directions are set automatically.  Also, solo and
809 @emph{a due} parts are identified and can be marked.
810
811 The syntax for part combining is
812
813 @example
814 \partcombine @var{musicexpr1} @var{musicexpr2}
815 @end example
816
817
818 The following example demonstrates the basic functionality of the part
819 combiner: putting parts on one staff, and setting stem directions and
820 polyphony
821
822 @lilypond[quote,verbatim,raggedright,fragment]
823 \new Staff \partcombine
824   \relative g' { g g a( b) c c r r }
825   \relative g' { g g r4 r e e g g }
826 @end lilypond
827
828 The first @code{g} appears only once, although it was
829 specified twice (once in each part).  Stem, slur, and tie directions are
830 set automatically, depending whether there is a solo or unisono.  The
831 first part (with context called @code{one}) always gets up stems, and
832 `Solo', while the second (called @code{two}) always gets down stems and
833 `Solo II'.
834
835 If you just want the merging parts, and not the textual markings, you
836 may set the property @code{printPartCombineTexts} to false
837
838 @lilypond[quote,verbatim,raggedright,fragment,relative=2]
839 \new Staff <<
840   \set Staff.printPartCombineTexts = ##f
841   \partcombine
842     \relative g' { g a( b) r }
843     \relative g' { g r4 r f }
844 >>
845 @end lilypond
846
847 To change the text that is printed for solos or merging, you may
848 set the @code{soloText}, @code{soloIIText}, and @code{aDueText}
849 properties.
850
851 @lilypond[quote,verbatim,raggedright,fragment,relative=2]
852 \new Staff <<
853   \set Score.soloText = #"ichi"
854   \set Score.soloIIText = #"ni"
855   \set Score.aDueText = #"tachi"
856   \partcombine
857     \relative g' { g4 g a( b) r }
858     \relative g' { g4 g r r f }
859 >>
860 @end lilypond
861
862 Both arguments to @code{\partcombine} will be interpreted as
863 @internalsref{Voice} contexts.  If using relative octaves,
864 @code{\relative} should be specified for both music expressions, i.e.,
865
866 @example
867 \partcombine
868   \relative @dots{} @var{musicexpr1}
869   \relative @dots{} @var{musicexpr2}
870 @end example
871
872 @noindent
873 A @code{\relative} section that is outside of @code{\partcombine} has
874 no effect on the pitches of @var{musicexpr1} and @var{musicexpr2}.
875
876 @seealso
877
878 Program reference: @internalsref{PartCombineMusic},
879 @internalsref{SoloOneEvent}, and
880 @internalsref{SoloTwoEvent}, and
881 @internalsref{UnisonoEvent}.
882
883 @refbugs
884
885 When @code{printPartCombineTexts} is set, when the two voices play the
886 same notes on and off, the part combiner may typeset @code{a2} more
887 than once in a measure.
888
889 @code{\partcombine} cannot be inside @code{\times}.
890
891 @code{\partcombine} cannot be inside @code{\relative}.
892
893 Internally, the @code{\partcombine} interprets both arguments as
894 @code{Voice}s named @code{one} and @code{two}, and then decides when
895 the parts can be combined.  Consequently, if the arguments switch to
896 differently named @internalsref{Voice} contexts, the events in those
897 will be ignored.
898
899
900 @node Hiding staves
901 @subsection Hiding staves
902
903 @cindex Frenched scores
904 @cindex Hiding staves
905
906 In orchestral scores, staff lines that only have rests are usually
907 removed; this saves some space.  This style is called `French Score'.
908 For @internalsref{Lyrics},
909 @internalsref{ChordNames} and @internalsref{FiguredBass}, this is
910 switched on by default.  When the lines of these contexts turn out
911 empty after the line-breaking process, they are removed.
912
913 For normal staves, a specialized @internalsref{Staff} context is
914 available, which does the same: staves containing nothing (or only
915 multi-measure rests) are removed.  The context definition is stored in
916 @code{\RemoveEmptyStaffContext} variable.  Observe how the second staff
917 in this example disappears in the second line
918
919 @lilypond[quote,raggedright,verbatim]
920 \layout {
921   \context { \RemoveEmptyStaffContext }
922 }
923
924 {
925   \relative c' <<
926     \new Staff { e4 f g a \break c1 }
927     \new Staff { c4 d e f \break R1 }
928   >>
929 }
930 @end lilypond
931
932 The first system shows all staves in full.  If empty staves should be
933 removed from the first system too, set @code{remove-first} to false in
934 @internalsref{RemoveEmptyVerticalGroup}.
935
936 To remove other types of contexts, use @code{\AncientRemoveEmptyStaffContext}
937 or @code{\RemoveEmptyRhythmicStaffContext}.
938
939 Another application is making ossia sections, i.e., alternative
940 melodies on a separate piece of staff, with help of a Frenched
941 staff.  See @inputfileref{input/@/test,ossia@/.ly} for an example.
942
943
944 @node Quoting other voices
945 @subsection Quoting other voices
946
947 With quotations, fragments of other parts can be inserted into a part
948 directly.  Before a part can be quoted, it must be marked especially as
949 quotable.  This is done with the @code{\addquote} command.
950
951 @example
952 \addquote @var{name} @var{music}
953 @end example
954
955
956 @noindent
957 Here, @var{name} is an identifying string.  The @var{music} is any kind
958 of music.  Here is an example of @code{\addquote}
959
960 @example
961 \addquote clarinet \relative c' @{
962   f4 fis g gis
963 @}
964 @end example
965
966 This command must be entered at toplevel, i.e., outside any music
967 blocks.
968
969 After calling @code{\addquote}, the quotation may then be done with
970 @code{\quoteDuring} or @code{\cueDuring},
971
972 @example
973 \quoteDuring #@var{name} @var{music}
974 @end example
975
976 During a part, a piece of music can be quoted with the @code{\quoteDuring}
977 command.
978
979 @example
980 \quoteDuring #"clarinet" @{ s2. @}
981 @end example
982
983 This would cite three quarter notes (the duration of @code{s2.})  of
984 the previously added @code{clarinet} voice.
985
986
987 More precisely, it takes the current time-step of the part being
988 printed, and extracts the notes at the corresponding point of the
989 @code{\addquote}d voice.  Therefore, the argument to @code{\addquote}
990 should be the entire part of the voice to be quoted, including any
991 rests at the beginning.
992
993 Quotations take into account the transposition of both source and target
994 instruments, if they are specified using the @code{\transposition} command.
995
996 @lilypond[quote,raggedright,verbatim]
997 \addquote clarinet \relative c' {
998   \transposition bes
999   f4 fis g gis
1000 }
1001
1002 {
1003   e'8 f'8 \quoteDuring #"clarinet" { s2 }
1004 }
1005 @end lilypond
1006
1007 The type of events that are present in cue notes can be trimmed with
1008 the @code{quotedEventTypes} property.  The default value is
1009 @code{(note-event rest-event)}, which means that only notes and
1010 rests of the cued voice end up in the @code{\quoteDuring}.
1011 Setting
1012
1013 @example
1014 \set Staff.quotedEventTypes =
1015        #'(note-event articulation-event dynamic-event)
1016 @end example
1017
1018 @noindent
1019 will quote notes (but no rests), together with scripts and dynamics.
1020
1021 @refbugs
1022
1023 Only the contents of the first @internalsref{Voice} occurring in an
1024 @code{\addquote} command will be considered for quotation, so
1025 @var{music} can not contain @code{\new} and @code{\context Voice}
1026 statements that would switch to a different Voice.
1027
1028 Quoting grace notes is broken and can even cause LilyPond to crash.
1029
1030 @seealso
1031
1032 In this manual: @ref{Instrument transpositions}.
1033
1034 Examples: @inputfileref{input/@/regression,quote@/.ly}
1035 @inputfileref{input/@/regression,quote@/-transposition@/.ly}
1036
1037 Program reference: @internalsref{QuoteMusic}.
1038
1039
1040 @node Formatting cue notes
1041 @subsection Formatting cue notes
1042
1043 The previous section deals with inserting notes from another voice.
1044 There is a more advanced music function called @code{\cueDuring},
1045 which makes formatting cue notes easier.
1046
1047 The syntax is
1048
1049 @example
1050   \cueDuring #@var{name} #@var{updown} @var{music}
1051 @end example
1052
1053 This will insert notes from the part @var{name} into a
1054 @internalsref{Voice} called @code{cue}.  This happens simultaneously
1055 with @var{music}, which usually is a rest.  When the cue notes start,
1056 the staff in effect becomes polyphonic for a moment.  The argument
1057 @var{updown} determines whether the cue notes should be notated as a
1058 first or second voice.
1059
1060
1061 @lilypond[verbatim,raggedright]
1062 smaller = {
1063   \set fontSize = #-2
1064   \override Stem #'length = #5.5
1065   \override Beam #'thickness = #0.384
1066   \override Beam #'space-function =
1067     #(lambda (beam mult) (* 0.8 (Beam::space_function beam mult)))
1068 }
1069
1070 \addquote clarinet \relative {
1071   R1*20
1072   r2 r8 c f f
1073
1074
1075 \new Staff \relative  <<
1076
1077   % setup a context for  cue  notes.
1078   \context Voice = cue { \smaller \skip 1*21 }
1079   
1080   \set Score.skipBars = ##t
1081   
1082   \new Voice {
1083     R1*20
1084     \cueDuring #"clarinet" #1 {
1085       R1
1086     }
1087     g4 g2. 
1088   }
1089 >>
1090 @end lilypond 
1091
1092
1093 Here are a couple of hints for successful cue notes
1094
1095 @itemize @bullet
1096 @item
1097 Cue notes have smaller font sizes.
1098 @item
1099  the cued part is marked with the instrument playing the cue.
1100 @item
1101  when the original part takes over again, this should be marked with
1102  the name of the original instrument.
1103
1104  @c really?  Are you sure about that last point?  I'll check after 3.0 -gp
1105
1106 @c Yes, this is good practice.  Otherwise, the start of the original
1107 @c part can only be seen from the font size.  This is not good enough
1108 @c for sight-reading.  It is possilbe to use other
1109 @c markers (eg. a big close-bracket over the staff) to indicate the cue notes are
1110 @c finished.
1111 @c -hwn
1112
1113
1114  any other changes introduced by the cued part should also be
1115 undone.  For example, if the cued instrument plays in a different clef,
1116 the original clef should be stated once again.
1117
1118 @end itemize
1119
1120
1121 @node Aligning to cadenzas
1122 @subsection Aligning to cadenzas
1123
1124 In an orchestral context, cadenzas present a special problem:
1125 when constructing a score that includes a cadenza, all other
1126 instruments should skip just as many notes as the length of the
1127 cadenza, otherwise they will start too soon or too late.
1128
1129 A solution to this problem are the functions @code{mmrest-of-length}
1130 and @code{skip-of-length}.  These Scheme functions take a piece of music
1131 as argument, and generate a @code{\skip} or multi-rest, exactly as
1132 long as the piece.  The use of @code{mmrest-of-length} is demonstrated
1133 in the following example.
1134
1135 @lilypond[verbatim,raggedright,quote]
1136 cadenza = \relative c' {
1137   c4 d8 << { e f g } \\ { d4. } >>
1138   g4 f2 g4 g
1139 }
1140
1141 \new GrandStaff <<
1142   \new Staff { \cadenza c'4 }
1143   \new Staff {
1144     #(ly:export (mmrest-of-length cadenza))
1145     c'4
1146   }
1147 >>
1148 @end lilypond
1149
1150
1151
1152
1153 @node Contemporary notation
1154 @section Contemporary notation
1155
1156 In the 20th century, composers have greatly expanded the musical
1157 vocabulary.  With this expansion, many innovations in musical notation
1158 have been tried.  The book ``Music Notation in the 20th century'' by
1159 Kurt Stone gives a comprehensive overview (see @ref{Literature
1160 list}).  In general, the use of new, innovative notation makes a piece
1161 harder to understand and perform and its use should therefore be
1162 avoided.  For this reason, support for contemporary notation in
1163 LilyPond is limited.
1164
1165
1166 @menu
1167 * Polymetric notation::         
1168 * Clusters::                    
1169 * Special fermatas::            
1170 * Feathered beams::             
1171 * Improvisation::               
1172 @end menu
1173
1174 @node Polymetric notation
1175 @subsection Polymetric notation
1176
1177 Double time signatures are not supported explicitly, but they can be
1178 faked.  In the next example, the markup for the time signature is
1179 created with a markup text.  This markup text is inserted in the
1180 @internalsref{TimeSignature} grob.
1181
1182 @lilypond[verbatim,raggedright]
1183 % create 2/4 + 5/8
1184 tsMarkup =\markup {
1185   \number {
1186     \column { "2" "4" }
1187     \musicglyph #"scripts.stopped"
1188     \bracket \column { "5" "8" }
1189   }
1190 }
1191
1192 {
1193   \override Staff.TimeSignature #'print-function = #Text_interface::print
1194   \override Staff.TimeSignature #'text = #tsMarkup
1195   \time 3/2
1196   c'2 \bar ":" c'4 c'4.
1197 }
1198 @end lilypond
1199
1200 Each staff can also have its own time signature.  This is done by
1201 moving the @internalsref{Timing_engraver} to the @internalsref{Staff}
1202 context.
1203
1204 @example
1205 \layout @{
1206   \context @{ \Score \remove "Timing_engraver" @}
1207   \context @{ \Staff \consists "Timing_engraver" @}
1208 @}
1209 @end example
1210
1211
1212 Now, each staff has its own time signature.
1213 @example
1214 <<
1215   \new Staff @{
1216     \time 3/4
1217     c4 c c | c c c |
1218   @}
1219   \new Staff @{
1220     \time 2/4
1221     c4 c | c c | c c
1222   @}
1223   \new Staff @{
1224     \time 3/8
1225     c4. c8 c c c4. c8 c c
1226   @}
1227 >>
1228 @end example
1229
1230 @lilypond[quote,raggedright]
1231 \layout{
1232   \context{ \Score \remove "Timing_engraver" }
1233   \context{ \Staff \consists "Timing_engraver" }
1234 }
1235
1236 \relative c' <<
1237   \new Staff {
1238     \time 3/4
1239     c4 c c | c c c |
1240   }
1241   \new Staff {
1242     \time 2/4
1243     c4 c | c c | c c
1244   }
1245   \new Staff {
1246     \time 3/8
1247     c4. c8 c c c4. c8 c c
1248   }
1249 >>
1250 @end lilypond
1251
1252
1253 A different form of polymetric notation is where note lengths have
1254 different values across staves.
1255
1256 This notation can be created by setting a common time signature for
1257 each staff but replacing it manually using
1258 @code{timeSignatureFraction} to the desired fraction.  Then the printed
1259 durations in each staff are scaled to the common time signature.
1260 The latter is done with @code{\compressmusic}, which is similar to
1261 @code{\times}, but does not create a tuplet bracket.
1262
1263
1264 In this example, music with the time signatures of 3/4, 9/8, and 10/8 are
1265 used in parallel.  In the second staff, shown durations are multiplied by
1266 2/3, so that 2/3 * 9/8 = 3/4, and in the third staff, shown durations are
1267 multiplied by 3/5, so that 3/5 * 10/8 = 3/4.
1268
1269 @lilypond[quote,raggedright,verbatim,fragment]
1270 \relative c' { <<
1271   \new Staff {
1272     \time 3/4
1273     c4 c c | c c c |
1274   }
1275   \new Staff {
1276     \time 3/4
1277     \set Staff.timeSignatureFraction = #'(9 . 8)
1278     \compressmusic #'(2 . 3)
1279       \repeat unfold 6 { c8[ c c] }
1280   }
1281   \new Staff {
1282     \time 3/4
1283     \set Staff.timeSignatureFraction = #'(10 . 8)
1284     \compressmusic #'(3 . 5) {
1285       \repeat unfold 2 { c8[ c c] }
1286       \repeat unfold 2 { c8[ c] }
1287       | c4. c4. \times 2/3 { c8 c c } c4
1288     }
1289   }
1290 >> }
1291 @end lilypond
1292
1293
1294
1295
1296 @refbugs
1297
1298 When using different time signatures in parallel, the spacing is
1299 aligned vertically, but bar lines distort the regular spacing.
1300
1301
1302
1303 @node Clusters
1304 @subsection Clusters
1305
1306 @cindex cluster
1307
1308 A cluster indicates a continuous range of pitches to be played.  They
1309 can be denoted as the envelope of a set of notes.  They are entered by
1310 applying the function @code{makeClusters} to a sequence of
1311 chords, e.g.,
1312 @lilypond[quote,raggedright,relative=2,fragment,verbatim]
1313 \makeClusters { <c e > <b f'> }
1314 @end lilypond
1315
1316 The following example (from
1317 @inputfileref{input/@/regression,cluster@/.ly}) shows what the result
1318 looks like
1319
1320 @lilypondfile[raggedright,quote]{cluster.ly}
1321
1322 Ordinary notes and clusters can be put together in the same staff,
1323 even simultaneously.  In such a case no attempt is made to
1324 automatically avoid collisions between ordinary notes and clusters.
1325
1326 @seealso
1327
1328 Program reference: @internalsref{ClusterSpanner},
1329 @internalsref{ClusterSpannerBeacon},
1330 @internalsref{Cluster_spanner_engraver}, and
1331 @internalsref{ClusterNoteEvent}.
1332
1333 Examples: @inputfileref{input/@/regression,cluster@/.ly}.
1334
1335 @refbugs
1336
1337 Music expressions like @code{<< @{ g8 e8 @} a4 >>} are not printed
1338 accurately.  Use @code{<g a>8 <e a>8} instead.
1339
1340
1341
1342 @node Special fermatas
1343 @subsection Special fermatas
1344
1345 @cindex fermatas, special
1346
1347 In contemporary music notation, special fermata symbols denote breaks
1348 of differing lengths.  The following fermatas are supported
1349
1350 @lilypond[quote,raggedright]
1351 <<
1352   \oldaddlyrics {
1353     b'2
1354     ^\shortfermata
1355     _\shortfermata
1356     r
1357
1358     b'
1359     ^\fermata
1360     _\fermata
1361     r
1362
1363     b'
1364     ^\longfermata
1365     _\longfermata
1366     r
1367
1368     b'
1369     ^\verylongfermata
1370     _\verylongfermata
1371     r
1372   }
1373   \context Lyrics \lyricmode {
1374     \override LyricText #'font-family = #'typewriter
1375     "shortfermata" "fermata" "longfermata" "verylongfermata"
1376   }
1377 >>
1378 @end lilypond
1379
1380 See @ref{Articulations} for general instructions how to apply scripts
1381 such as fermatas to notes.
1382
1383 @node Feathered beams
1384 @subsection Feathered beams
1385
1386 Feathered beams are not supported natively, but they can be faked by
1387 forcing two beams to overlap.  Here is an example,
1388
1389 @c don't change relative setting witout changing positions!
1390 @lilypond[raggedright,relative=1,fragment,verbatim]
1391 \new Staff <<
1392   \new Voice
1393   {
1394     \stemUp
1395     \once \override Voice.Beam #'positions = #'(0 . 0.5)
1396     c8[ c c c c ]
1397   }
1398   \new Voice {
1399     \stemUp
1400     \once \override Voice.Beam #'positions = #'(0 . -0.5)
1401     c[ c c c c]
1402   }
1403 >>
1404 @end lilypond
1405
1406
1407 @node Improvisation
1408 @subsection Improvisation
1409
1410 Improvisation is sometimes denoted with slashed note heads.  Such note
1411 heads can be created by adding a @internalsref{Pitch_squash_engraver}
1412 to the @internalsref{Staff} or @internalsref{Voice} context.  Then, the
1413 following command
1414
1415 @example
1416 \set squashedPosition = #0
1417 \override NoteHead #'style = #'slash
1418 @end example
1419
1420 @noindent
1421 switches on the slashes.
1422
1423 There are shortcuts @code{\improvisationOn} (and an accompanying
1424 @code{\improvisationOff}) for this command sequence.  They are used in
1425 the following example
1426
1427 @lilypond[verbatim,raggedright,quote]
1428 \new Staff \with {
1429   \consists Pitch_squash_engraver
1430 } \transpose c c' {
1431   e8 e g a a16(bes)(a8) g \improvisationOn
1432   e8
1433   ~e2~e8 f4 fis8
1434   ~fis2 \improvisationOff a16(bes) a8 g e
1435 }
1436 @end lilypond
1437
1438
1439 @node Educational use
1440 @section Educational use
1441
1442 With the amount of control that LilyPond offers, one can make great
1443 teaching tools in addition to great musical scores.
1444
1445 @menu
1446 * Balloon help::                
1447 * Blank music sheet::           
1448 * Hidden notes::                
1449 * Shaped note heads ::          
1450 * Easy Notation note heads::    
1451 * Analysis brackets::           
1452 @end menu
1453
1454 @node Balloon help
1455 @subsection Balloon help
1456
1457 Elements of notation can be marked and named with the help of a square
1458 balloon.  The primary purpose of this feature is to explain notation.
1459
1460 The following example demonstrates its use.
1461
1462 @lilypond[quote,verbatim,fragment,raggedright,relative=2]
1463 \context Voice {
1464   \applyoutput
1465     #(add-balloon-text 'NoteHead "heads, or tails?"
1466     '(1 . -3))
1467   c8
1468 }
1469 @end lilypond
1470
1471 @noindent
1472 The function @code{add-balloon-text} takes the name of a grob, the
1473 label to print, and the position where to put the label relative to
1474 the object.  In the above example, the text ``heads or tails?'' ends
1475 3 spaces below and 1 space to the right of the marked head.
1476
1477 @cindex balloon
1478 @cindex notation, explaining
1479
1480 @seealso
1481
1482 Program reference: @internalsref{text-balloon-interface}.
1483
1484 Examples: @inputfileref{input/@/regression,balloon@/.ly}.
1485
1486
1487
1488
1489 @node Blank music sheet
1490 @subsection Blank music sheet
1491
1492 A blank music sheet can be produced also by using invisible notes, and
1493 removing @code{Bar_number_engraver}.
1494
1495
1496 @lilypond[quote,verbatim]
1497 emptymusic = {
1498   \repeat unfold 2 % Change this for more lines.
1499   { s1\break }
1500   \bar "|."
1501 }
1502 \new Score \with {
1503   \override TimeSignature #'transparent = ##t
1504   defaultBarType = #""
1505   \remove Bar_number_engraver
1506 } <<
1507   \context Staff \emptymusic
1508   \context TabStaff \emptymusic
1509 >>
1510 @end lilypond
1511
1512
1513 @node Hidden notes
1514 @subsection Hidden notes
1515
1516 @cindex Hidden notes
1517 @cindex Invisible notes
1518 @cindex Transparent notes
1519
1520 @cindex @code{\hideNotes}
1521 @cindex @code{\unHideNotes}
1522 Hidden (or invisible or transparent) notes can be useful in preparing theory
1523 or composition exercises.
1524
1525 @lilypond[quote,raggedright,verbatim,relative=2,fragment]
1526 c4 d4
1527 \hideNotes
1528 e4 f4
1529 \unHideNotes
1530 g4 a
1531 @end lilypond
1532
1533 Hidden notes are also great for performing weird tricks.  For example,
1534 slurs cannot be attached to rests or spacer rests, but you may wish
1535 to include that in your score -- string instruments use this notation
1536 when doing pizzicato to indicate that the note should ring for as long
1537 as possible.
1538
1539 @lilypond[quote,raggedright,verbatim,relative=0,fragment]
1540 \clef bass
1541 << {
1542   c4^"pizz"( \hideNotes c)
1543   \unHideNotes c( \hideNotes c)
1544 } {
1545   s4 r s r
1546 } >>
1547 @end lilypond
1548
1549
1550 @node Shaped note heads 
1551 @subsection Shaped note heads 
1552
1553 In shaped note head notation, the shape of the note head corresponds
1554 to the harmonic function of a note in the scale.  This notation was
1555 popular in the 19th century American song books.
1556
1557 Shaped note heads can be produced by setting @code{\aikenHeads} or
1558 @code{\sacredHarpHeads}, depending on the style desired.
1559
1560 @lilypond[verbatim,relative=1,fragment]
1561   \aikenHeads
1562   c8 d4 e8 a2 g1
1563   \sacredHarpHeads
1564   c8 d4. e8 a2 g1
1565 @end lilypond
1566
1567 Shapes are determined on the step in the scale, where the base of the
1568 scale is determined by  the @code{\key} command
1569
1570 @findex \key
1571 @findex shapeNoteStyles
1572 @findex \aikenHeads
1573 @findex \sacredHarpHeads
1574
1575 Shaped note heads are implemented through the @code{shapeNoteStyles}
1576 property.  Its value is a vector of symbols.  The k-th element indicates
1577 the style to use for the k-th step of the scale.  Arbitrary
1578 combinations are possible, eg.,
1579
1580
1581 @lilypond[verbatim,relative=1,fragment]
1582   \set shapeNoteStyles  = ##(cross triangle fa #f mensural xcircle diamond)
1583   c8 d4. e8 a2 g1
1584 @end lilypond
1585
1586
1587 @node Easy Notation note heads
1588 @subsection Easy Notation note heads
1589
1590 @cindex easy notation
1591 @cindex Hal Leonard
1592
1593 The `easy play' note head includes a note name inside the head.  It is
1594 used in music for beginners
1595
1596 @lilypond[quote,raggedright,verbatim,fragment,staffsize=26]
1597   \setEasyHeads
1598   c'2 e'4 f' | g'1
1599 @end lilypond
1600
1601 The command @code{\setEasyHeads} overrides settings for the
1602 @internalsref{NoteHead} object.  To make the letters readable, it has
1603 to be printed in a large font size.  To print with a larger font, see
1604 @ref{Setting global staff size}.
1605
1606 @refcommands
1607
1608 @cindex @code{\setEasyHeads}
1609 @code{\setEasyHeads}
1610
1611
1612 @node Analysis brackets
1613 @subsection Analysis brackets
1614 @cindex brackets
1615 @cindex phrasing brackets
1616 @cindex musicological analysis
1617 @cindex note grouping bracket
1618
1619 Brackets are used in musical analysis to indicate structure in musical
1620 pieces.  LilyPond supports a simple form of nested horizontal
1621 brackets.  To use this, add the @internalsref{Horizontal_bracket_engraver}
1622 to @internalsref{Staff} context.  A bracket is started with
1623 @code{\startGroup} and closed with @code{\stopGroup}
1624
1625 @lilypond[quote,raggedright,verbatim]
1626 \score {
1627   \relative c'' {
1628     c4\startGroup\startGroup
1629     c4\stopGroup
1630     c4\startGroup
1631     c4\stopGroup\stopGroup
1632   }
1633   \layout {
1634     \context {
1635       \Staff \consists "Horizontal_bracket_engraver"
1636 }}}
1637 @end lilypond
1638
1639 @seealso
1640
1641 Program reference: @internalsref{HorizontalBracket},
1642 @internalsref{NoteGroupingEvent}.
1643
1644 Examples: @inputfileref{input/@/regression,note@/-group@/-bracket@/.ly}.
1645
1646
1647
1648 @ignore
1649
1650 I don't think we need this info.
1651
1652 @n ode Stems
1653 @s ubsection Stems
1654
1655 Whenever a note is found, a @internalsref{Stem} object is created
1656 automatically.  For whole notes and rests, they are also created but
1657 made invisible.
1658
1659 @refcommands
1660
1661 @cindex @code{\stemUp}
1662 @code{\stemUp},
1663 @cindex @code{\stemDown}
1664 @code{\stemDown},
1665 @cindex @code{\stemNeutral}
1666 @code{\stemNeutral}.
1667
1668 @end ignore
1669
1670
1671
1672
1673 @ignore
1674
1675 FIXME:  We don't need this section.  It will be moved into LSR as soon
1676 as the safe mode stuff is worked out.
1677
1678 @n ode Controlling formatting of prefatory matter
1679 @s ubsection Controlling formatting of prefatory matter
1680
1681 @c  This section will be moved to somewhere else soon. -gp
1682 This example demonstrates how to place prefatory matter
1683 (such as the clef and key signature) at the end of a line.
1684
1685 @lilypond[quote,verbatim]
1686 \transpose c c' {
1687   \override Staff.Clef
1688     #'break-visibility = #end-of-line-visible
1689   \override Staff.KeySignature
1690     #'break-visibility = #end-of-line-visible
1691   \set Staff.explicitClefVisibility = #end-of-line-visible
1692   \set Staff.explicitKeySignatureVisibility = #end-of-line-visible
1693
1694   % We want the time sig to take space, otherwise there is not
1695   % enough white at the start of the line.
1696
1697   \override Staff.TimeSignature #'transparent = ##t
1698   \set Score.defaultBarType = #"empty"
1699
1700   c1 d e f g a b c
1701   \key d \major
1702   \break
1703
1704   % see above.
1705   \time 4/4
1706
1707   d e fis g a b cis d
1708   \key g \major
1709   \break
1710   \time 4/4
1711 }
1712 @end lilypond
1713
1714 @end ignore
1715
1716
1717 @node Coloring objects
1718 @section Coloring objects
1719
1720 @c FIXME: need link to missing list of colors
1721 Individual objects may be assigned colors.  You may use color names
1722 listed HERE or the x11 color names listed THERE.
1723
1724 @lilypond[quote,raggedright,verbatim,fragment]
1725 \override NoteHead #'color = #red
1726 c4 c
1727 \override NoteHead #'color = #(x11-color 'LimeGreen)
1728 d
1729 \override Stem #'color = #blue
1730 e
1731 @end lilypond
1732
1733 @seealso
1734
1735 COLORLIST
1736
1737
1738 @node Automatic notation
1739 @section Automatic notation
1740
1741 This section describes how to change the way that accidentals and
1742 beams are automatically displayed.
1743
1744 FIXME: this might get moved into Changing Defaults.  Please send
1745 opinions to lilypond-devel.  Thanks!  :)
1746
1747 @menu
1748 * Automatic accidentals::       
1749 * Setting automatic beam behavior::  
1750 * Beam formatting::             
1751 @end menu
1752
1753 @node Automatic accidentals
1754 @subsection Automatic accidentals
1755 @cindex Automatic accidentals
1756
1757 Common rules for typesetting accidentals have been placed in a
1758 function.  This function is called as follows
1759
1760 @cindex @code{set-accidental-style}
1761 @example
1762 #(set-accidental-style 'STYLE #('CONTEXT#))
1763 @end example
1764
1765 The function can take two arguments: the name of the accidental style,
1766 and an optional argument that denotes the context that should be
1767 changed.  If no context name is supplied, @code{Staff} is the default,
1768 but you may wish to apply the accidental style to a single @code{Voice}
1769 instead.
1770
1771 The following accidental styles are supported
1772 @table @code
1773 @item default
1774 This is the default typesetting behavior.  It corresponds
1775 to 18th century common practice: Accidentals are
1776 remembered to the end of the measure in which they occur and
1777 only on their own octave.
1778
1779 @item voice
1780 The normal behavior is to remember the accidentals on
1781 Staff-level.  This variable, however, typesets accidentals
1782 individually for each voice.  Apart from that, the rule is similar to
1783 @code{default}.
1784
1785 As a result, accidentals from one voice do not get canceled in other
1786 voices, which is often an unwanted result
1787
1788 @lilypond[quote,raggedright,relative=1,fragment,verbatim]
1789 \context Staff <<
1790   #(set-accidental-style 'voice)
1791   <<
1792     { es g } \\
1793     { c, e }
1794 >> >>
1795 @end lilypond
1796
1797 The @code{voice} option should be used if the voices
1798 are to be read solely by individual musicians.  If the staff is to be
1799 used by one musician (e.g., a conductor) then
1800 @code{modern} or @code{modern-cautionary}
1801 should be used instead.
1802
1803 @item modern
1804 @cindex @code{modern} style accidentals
1805 This rule corresponds to the common practice in the 20th century.  This rule
1806 prints the same accidentals as @code{default}, but temporary
1807 accidentals also are canceled in other octaves.  Furthermore,
1808 in the same octave, they also get canceled in the following
1809 measure
1810
1811 @lilypond[quote,raggedright,fragment,verbatim]
1812 #(set-accidental-style 'modern)
1813 cis' c'' cis'2 | c'' c'
1814 @end lilypond
1815
1816 @item @code{modern-cautionary}
1817 @cindex @code{modern-cautionary}
1818 This rule is similar to @code{modern}, but the ``extra'' accidentals
1819 (the ones not typeset by @code{default}) are typeset as cautionary
1820 accidentals.  They are printed in reduced size or with parentheses
1821 @lilypond[quote,raggedright,fragment,verbatim]
1822 #(set-accidental-style 'modern-cautionary)
1823 cis' c'' cis'2 | c'' c'
1824 @end lilypond
1825
1826 @cindex @code{modern-voice}
1827 @item modern-voice
1828 This rule is used for multivoice accidentals to be read both by musicians
1829 playing one voice and musicians playing all voices.  Accidentals are
1830 typeset for each voice, but they @emph{are} canceled across voices in
1831 the same @internalsref{Staff}.
1832
1833 @cindex @code{modern-voice-cautionary}
1834 @item modern-voice-cautionary
1835 This rule is the same as @code{modern-voice}, but with the extra
1836 accidentals (the ones not typeset by @code{voice}) typeset
1837 as cautionaries.  Even though all accidentals typeset by
1838 @code{default} @emph{are} typeset by this variable,
1839 some of them are typeset as cautionaries.
1840
1841 @item piano
1842 @cindex @code{piano} accidentals
1843 This rule reflects 20th century practice for piano notation.  Very similar to
1844 @code{modern} but accidentals also get canceled
1845 across the staves in the same @internalsref{GrandStaff} or
1846 @internalsref{PianoStaff}.
1847
1848 @item piano-cautionary
1849 @cindex @code{#(set-accidental-style 'piano-cautionary)}
1850 Same as @code{#(set-accidental-style 'piano)} but with the extra
1851 accidentals typeset as cautionaries.
1852
1853 @item no-reset
1854 @cindex @code{no-reset} accidental style
1855 This is the same as @code{default} but with accidentals lasting
1856 ``forever'' and not only until the next measure
1857 @lilypond[quote,raggedright,fragment,verbatim,relative=1]
1858 #(set-accidental-style 'no-reset)
1859 c1 cis cis c
1860 @end lilypond
1861
1862 @item forget
1863 This is sort of the opposite of @code{no-reset}: Accidentals
1864 are not remembered at all---and hence all accidentals are
1865 typeset relative to the key signature, regardless of what was
1866 before in the music
1867
1868 @lilypond[quote,raggedright,fragment,verbatim,relative=1]
1869 #(set-accidental-style 'forget)
1870 \key d\major c4 c cis cis d d dis dis
1871 @end lilypond
1872 @end table
1873
1874
1875 @seealso
1876
1877 Program reference: @internalsref{Accidental_engraver},
1878 @internalsref{Accidental}, and @internalsref{AccidentalPlacement}.
1879
1880
1881 @refbugs
1882
1883 Simultaneous notes are considered to be entered in sequential
1884 mode.  This means that in a chord the accidentals are typeset as if the
1885 notes in the chord happened once at a time - in the order in which
1886 they appear in the input file.
1887
1888 This is a problem when accidentals in a chord depend on each other,
1889 which does not happen for the default accidental style.  The problem
1890 can be solved by manually inserting @code{!} and @code{?} for the
1891 problematic notes.
1892
1893
1894 @node Setting automatic beam behavior
1895 @subsection Setting automatic beam behavior
1896
1897 @cindex @code{autoBeamSettings}
1898 @cindex @code{(end * * * *)}
1899 @cindex @code{(begin * * * *)}
1900 @cindex automatic beams, tuning
1901 @cindex tuning automatic beaming
1902
1903 @c [TODO: use \applycontext]
1904
1905 In normal time signatures, automatic beams can start on any note but can
1906 only end in a few positions within the measure: beams can end on a beat,
1907 or at durations specified by the properties in
1908 @code{autoBeamSettings}.  The defaults for @code{autoBeamSettings}
1909 are defined in @file{scm/@/auto@/-beam@/.scm}.
1910
1911 The value of @code{autoBeamSettings} is changed with three functions,
1912 @example
1913 #(override-auto-beam-setting
1914    '(@var{be} @var{p} @var{q} @var{n} @var{m}) @var{a} @var{b}
1915    [@var{context}])
1916 #(score-override-auto-beam-setting
1917    '(@var{be} @var{p} @var{q} @var{n} @var{m}) @var{a} @var{b})
1918 #(revert-auto-beam-setting '(@var{be} @var{p} @var{q} @var{n} @var{m})
1919    [@var{context}])
1920 @end example
1921 Here, @var{be} is the symbol @code{begin} or @code{end}, and
1922 @var{context} is an optional context (default: @code{'Voice}).  It
1923 determines whether the rule applies to begin or end-points.  The
1924 quantity @var{p}/@var{q} refers to the length of the beamed notes (and
1925 `@code{* *}' designates notes of any length), @var{n}/@var{M} refers
1926 to a time signature (wildcards `@code{* *}' may be entered to
1927 designate all time signatures), @var{a}/@var{b} is a duration.  By
1928 default, this command changes settings for the current voice.  It is
1929 also possible to adjust settings at higher contexts, by adding a
1930 @var{context} argument.  @code{score-override-auto-beam-setting} is
1931 equal to @code{override-auto-beam-setting} with the argument
1932 @var{context} set to @code{'Score}.
1933
1934 For example, if automatic beams should end on the first quarter note, use
1935 the following
1936 @example
1937 #(override-auto-beam-setting '(end * * * *) 1 4 'Staff)
1938 @end example
1939 Since the duration of a quarter note is 1/4 of a whole note, it is
1940 entered as @code{(ly:make-moment 1 4)}.
1941
1942 If automatic beams should end on every quarter in 5/4 time, specify
1943 all endings
1944 @example
1945 #(override-auto-beam-setting '(end * * * *) 1 4 'Staff)
1946 #(override-auto-beam-setting '(end * * * *) 1 2 'Staff)
1947 #(override-auto-beam-setting '(end * * * *) 3 4 'Staff)
1948 #(override-auto-beam-setting '(end * * * *) 5 4 'Staff)
1949 @dots{}
1950 @end example
1951
1952 The same syntax can be used to specify beam starting points.  In this
1953 example, automatic beams can only end on a dotted quarter note
1954 @example
1955 #(override-auto-beam-setting '(end * * * *) 3 8)
1956 #(override-auto-beam-setting '(end * * * *) 1 2)
1957 #(override-auto-beam-setting '(end * * * *) 7 8)
1958 @end example
1959 In 4/4 time signature, this means that automatic beams could end only on
1960 3/8 and on the fourth beat of the measure (after 3/4, that is 2 times
1961 3/8, has passed within the measure).
1962
1963 Rules can also be restricted to specific time signatures.  A rule that
1964 should only be applied in @var{N}/@var{M} time signature is formed by
1965 replacing the second asterisks by @var{N} and @var{M}.  For example, a
1966 rule for 6/8 time exclusively looks like
1967 @example
1968 #(override-auto-beam-setting '(begin * * 6 8) @dots{})
1969 @end example
1970
1971 If a rule should be to applied only to certain types of beams, use the
1972 first pair of asterisks.  Beams are classified according to the
1973 shortest note they contain.  For a beam ending rule that only applies
1974 to beams with 32nd notes (and no shorter notes), use @code{(end 1 32 *
1975 *)}.
1976
1977 @cindex automatic beam generation
1978 @cindex autobeam
1979 @cindex @code{autoBeaming}
1980 @cindex lyrics
1981
1982 If beams are used to indicate melismata in songs, then automatic
1983 beaming should be switched off.  This is done by setting
1984 @code{autoBeaming} to @code{#f}.
1985
1986 @refcommands
1987
1988 @cindex @code{\autoBeamOff}
1989 @code{\autoBeamOff},
1990 @cindex @code{\autoBeamOn}
1991 @code{\autoBeamOn}.
1992
1993
1994 @refbugs
1995
1996 If a score ends while an automatic beam has not been ended and is
1997 still accepting notes, this last beam will not be typeset at all.  The
1998 same holds polyphonic voices, entered with @code{<< @dots{} \\ @dots{}
1999 >>}.  If a polyphonic voice ends while an automatic beam is still
2000 accepting notes, it is not typeset.
2001
2002 @node Beam formatting
2003 @subsection Beam formatting
2004
2005 When a beam falls in the middle of the staff, the beams point normally
2006 down.  However, this behaviour can be altered with the
2007 @code{neutral-direction} property.
2008
2009 @lilypond[quote,raggedright,relative=2,fragment,verbatim]
2010 {
2011   b8[ b]
2012   \override Beam #'neutral-direction = #-1
2013   b[ b]
2014   \override Beam #'neutral-direction = #1
2015   b[ b]
2016 }
2017 @end lilypond
2018
2019