]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/advanced-notation.itely
0c0844a530e5795b1ccff9c67cce44ab06e909c8
[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 true in
934 @internalsref{RemoveEmptyVerticalGroup}.
935
936 @example
937 \override Score.RemoveEmptyVerticalGroup #'remove-first = ##t
938 @end example
939
940 To remove other types of contexts, use @code{\AncientRemoveEmptyStaffContext}
941 or @code{\RemoveEmptyRhythmicStaffContext}.
942
943 Another application is making ossia sections, i.e., alternative
944 melodies on a separate piece of staff, with help of a Frenched
945 staff.  See @inputfileref{input/@/test,ossia@/.ly} for an example.
946
947
948 @node Quoting other voices
949 @subsection Quoting other voices
950
951 With quotations, fragments of other parts can be inserted into a part
952 directly.  Before a part can be quoted, it must be marked especially as
953 quotable.  This is done with the @code{\addquote} command.
954
955 @example
956 \addquote @var{name} @var{music}
957 @end example
958
959
960 @noindent
961 Here, @var{name} is an identifying string.  The @var{music} is any kind
962 of music.  Here is an example of @code{\addquote}
963
964 @example
965 \addquote clarinet \relative c' @{
966   f4 fis g gis
967 @}
968 @end example
969
970 This command must be entered at toplevel, i.e., outside any music
971 blocks.
972
973 After calling @code{\addquote}, the quotation may then be done with
974 @code{\quoteDuring} or @code{\cueDuring},
975
976 @example
977 \quoteDuring #@var{name} @var{music}
978 @end example
979
980 During a part, a piece of music can be quoted with the @code{\quoteDuring}
981 command.
982
983 @example
984 \quoteDuring #"clarinet" @{ s2. @}
985 @end example
986
987 This would cite three quarter notes (the duration of @code{s2.})  of
988 the previously added @code{clarinet} voice.
989
990
991 More precisely, it takes the current time-step of the part being
992 printed, and extracts the notes at the corresponding point of the
993 @code{\addquote}d voice.  Therefore, the argument to @code{\addquote}
994 should be the entire part of the voice to be quoted, including any
995 rests at the beginning.
996
997 Quotations take into account the transposition of both source and target
998 instruments, if they are specified using the @code{\transposition} command.
999
1000 @lilypond[quote,raggedright,verbatim]
1001 \addquote clarinet \relative c' {
1002   \transposition bes
1003   f4 fis g gis
1004 }
1005
1006 {
1007   e'8 f'8 \quoteDuring #"clarinet" { s2 }
1008 }
1009 @end lilypond
1010
1011 The type of events that are present in cue notes can be trimmed with
1012 the @code{quotedEventTypes} property.  The default value is
1013 @code{(note-event rest-event)}, which means that only notes and
1014 rests of the cued voice end up in the @code{\quoteDuring}.
1015 Setting
1016
1017 @example
1018 \set Staff.quotedEventTypes =
1019        #'(note-event articulation-event dynamic-event)
1020 @end example
1021
1022 @noindent
1023 will quote notes (but no rests), together with scripts and dynamics.
1024
1025 @refbugs
1026
1027 Only the contents of the first @internalsref{Voice} occurring in an
1028 @code{\addquote} command will be considered for quotation, so
1029 @var{music} can not contain @code{\new} and @code{\context Voice}
1030 statements that would switch to a different Voice.
1031
1032 Quoting grace notes is broken and can even cause LilyPond to crash.
1033
1034 @seealso
1035
1036 In this manual: @ref{Instrument transpositions}.
1037
1038 Examples: @inputfileref{input/@/regression,quote@/.ly}
1039 @inputfileref{input/@/regression,quote@/-transposition@/.ly}
1040
1041 Program reference: @internalsref{QuoteMusic}.
1042
1043
1044 @node Formatting cue notes
1045 @subsection Formatting cue notes
1046
1047 The previous section deals with inserting notes from another voice.
1048 There is a more advanced music function called @code{\cueDuring},
1049 which makes formatting cue notes easier.
1050
1051 The syntax is
1052
1053 @example
1054   \cueDuring #@var{name} #@var{updown} @var{music}
1055 @end example
1056
1057 This will insert notes from the part @var{name} into a
1058 @internalsref{Voice} called @code{cue}.  This happens simultaneously
1059 with @var{music}, which usually is a rest.  When the cue notes start,
1060 the staff in effect becomes polyphonic for a moment.  The argument
1061 @var{updown} determines whether the cue notes should be notated as a
1062 first or second voice.
1063
1064
1065 @lilypond[verbatim,raggedright]
1066 smaller = {
1067   \set fontSize = #-2
1068   \override Stem #'length = #5.5
1069   \override Beam #'thickness = #0.384
1070   \override Beam #'space-function =
1071     #(lambda (beam mult) (* 0.8 (Beam::space_function beam mult)))
1072 }
1073
1074 \addquote clarinet \relative {
1075   R1*20
1076   r2 r8 c f f
1077
1078
1079 \new Staff \relative  <<
1080
1081   % setup a context for  cue  notes.
1082   \context Voice = cue { \smaller \skip 1*21 }
1083   
1084   \set Score.skipBars = ##t
1085   
1086   \new Voice {
1087     R1*20
1088     \cueDuring #"clarinet" #1 {
1089       R1
1090     }
1091     g4 g2. 
1092   }
1093 >>
1094 @end lilypond 
1095
1096
1097 Here are a couple of hints for successful cue notes
1098
1099 @itemize @bullet
1100 @item
1101 Cue notes have smaller font sizes.
1102 @item
1103  the cued part is marked with the instrument playing the cue.
1104 @item
1105  when the original part takes over again, this should be marked with
1106  the name of the original instrument.
1107
1108  @c really?  Are you sure about that last point?  I'll check after 3.0 -gp
1109
1110 @c Yes, this is good practice.  Otherwise, the start of the original
1111 @c part can only be seen from the font size.  This is not good enough
1112 @c for sight-reading.  It is possilbe to use other
1113 @c markers (eg. a big close-bracket over the staff) to indicate the cue notes are
1114 @c finished.
1115 @c -hwn
1116
1117
1118  any other changes introduced by the cued part should also be
1119 undone.  For example, if the cued instrument plays in a different clef,
1120 the original clef should be stated once again.
1121
1122 @end itemize
1123
1124
1125 @node Aligning to cadenzas
1126 @subsection Aligning to cadenzas
1127
1128 In an orchestral context, cadenzas present a special problem:
1129 when constructing a score that includes a cadenza, all other
1130 instruments should skip just as many notes as the length of the
1131 cadenza, otherwise they will start too soon or too late.
1132
1133 A solution to this problem are the functions @code{mmrest-of-length}
1134 and @code{skip-of-length}.  These Scheme functions take a piece of music
1135 as argument, and generate a @code{\skip} or multi-rest, exactly as
1136 long as the piece.  The use of @code{mmrest-of-length} is demonstrated
1137 in the following example.
1138
1139 @lilypond[verbatim,raggedright,quote]
1140 cadenza = \relative c' {
1141   c4 d8 << { e f g } \\ { d4. } >>
1142   g4 f2 g4 g
1143 }
1144
1145 \new GrandStaff <<
1146   \new Staff { \cadenza c'4 }
1147   \new Staff {
1148     #(ly:export (mmrest-of-length cadenza))
1149     c'4
1150   }
1151 >>
1152 @end lilypond
1153
1154
1155
1156
1157 @node Contemporary notation
1158 @section Contemporary notation
1159
1160 In the 20th century, composers have greatly expanded the musical
1161 vocabulary.  With this expansion, many innovations in musical notation
1162 have been tried.  The book ``Music Notation in the 20th century'' by
1163 Kurt Stone gives a comprehensive overview (see @ref{Literature
1164 list}).  In general, the use of new, innovative notation makes a piece
1165 harder to understand and perform and its use should therefore be
1166 avoided.  For this reason, support for contemporary notation in
1167 LilyPond is limited.
1168
1169
1170 @menu
1171 * Polymetric notation::         
1172 * Clusters::                    
1173 * Special fermatas::            
1174 * Feathered beams::             
1175 * Improvisation::               
1176 @end menu
1177
1178 @node Polymetric notation
1179 @subsection Polymetric notation
1180
1181 Double time signatures are not supported explicitly, but they can be
1182 faked.  In the next example, the markup for the time signature is
1183 created with a markup text.  This markup text is inserted in the
1184 @internalsref{TimeSignature} grob.
1185
1186 @lilypond[verbatim,raggedright]
1187 % create 2/4 + 5/8
1188 tsMarkup =\markup {
1189   \number {
1190     \column { "2" "4" }
1191     \musicglyph #"scripts.stopped"
1192     \bracket \column { "5" "8" }
1193   }
1194 }
1195
1196 {
1197   \override Staff.TimeSignature #'print-function = #Text_interface::print
1198   \override Staff.TimeSignature #'text = #tsMarkup
1199   \time 3/2
1200   c'2 \bar ":" c'4 c'4.
1201 }
1202 @end lilypond
1203
1204 Each staff can also have its own time signature.  This is done by
1205 moving the @internalsref{Timing_engraver} to the @internalsref{Staff}
1206 context.
1207
1208 @example
1209 \layout @{
1210   \context @{ \Score \remove "Timing_engraver" @}
1211   \context @{ \Staff \consists "Timing_engraver" @}
1212 @}
1213 @end example
1214
1215
1216 Now, each staff has its own time signature.
1217 @example
1218 <<
1219   \new Staff @{
1220     \time 3/4
1221     c4 c c | c c c |
1222   @}
1223   \new Staff @{
1224     \time 2/4
1225     c4 c | c c | c c
1226   @}
1227   \new Staff @{
1228     \time 3/8
1229     c4. c8 c c c4. c8 c c
1230   @}
1231 >>
1232 @end example
1233
1234 @lilypond[quote,raggedright]
1235 \layout{
1236   \context{ \Score \remove "Timing_engraver" }
1237   \context{ \Staff \consists "Timing_engraver" }
1238 }
1239
1240 \relative c' <<
1241   \new Staff {
1242     \time 3/4
1243     c4 c c | c c c |
1244   }
1245   \new Staff {
1246     \time 2/4
1247     c4 c | c c | c c
1248   }
1249   \new Staff {
1250     \time 3/8
1251     c4. c8 c c c4. c8 c c
1252   }
1253 >>
1254 @end lilypond
1255
1256
1257 A different form of polymetric notation is where note lengths have
1258 different values across staves.
1259
1260 This notation can be created by setting a common time signature for
1261 each staff but replacing it manually using
1262 @code{timeSignatureFraction} to the desired fraction.  Then the printed
1263 durations in each staff are scaled to the common time signature.
1264 The latter is done with @code{\compressmusic}, which is similar to
1265 @code{\times}, but does not create a tuplet bracket.
1266
1267
1268 In this example, music with the time signatures of 3/4, 9/8, and 10/8 are
1269 used in parallel.  In the second staff, shown durations are multiplied by
1270 2/3, so that 2/3 * 9/8 = 3/4, and in the third staff, shown durations are
1271 multiplied by 3/5, so that 3/5 * 10/8 = 3/4.
1272
1273 @lilypond[quote,raggedright,verbatim,fragment]
1274 \relative c' { <<
1275   \new Staff {
1276     \time 3/4
1277     c4 c c | c c c |
1278   }
1279   \new Staff {
1280     \time 3/4
1281     \set Staff.timeSignatureFraction = #'(9 . 8)
1282     \compressmusic #'(2 . 3)
1283       \repeat unfold 6 { c8[ c c] }
1284   }
1285   \new Staff {
1286     \time 3/4
1287     \set Staff.timeSignatureFraction = #'(10 . 8)
1288     \compressmusic #'(3 . 5) {
1289       \repeat unfold 2 { c8[ c c] }
1290       \repeat unfold 2 { c8[ c] }
1291       | c4. c4. \times 2/3 { c8 c c } c4
1292     }
1293   }
1294 >> }
1295 @end lilypond
1296
1297
1298
1299
1300 @refbugs
1301
1302 When using different time signatures in parallel, the spacing is
1303 aligned vertically, but bar lines distort the regular spacing.
1304
1305
1306
1307 @node Clusters
1308 @subsection Clusters
1309
1310 @cindex cluster
1311
1312 A cluster indicates a continuous range of pitches to be played.  They
1313 can be denoted as the envelope of a set of notes.  They are entered by
1314 applying the function @code{makeClusters} to a sequence of
1315 chords, e.g.,
1316 @lilypond[quote,raggedright,relative=2,fragment,verbatim]
1317 \makeClusters { <c e > <b f'> }
1318 @end lilypond
1319
1320 The following example (from
1321 @inputfileref{input/@/regression,cluster@/.ly}) shows what the result
1322 looks like
1323
1324 @lilypondfile[raggedright,quote]{cluster.ly}
1325
1326 Ordinary notes and clusters can be put together in the same staff,
1327 even simultaneously.  In such a case no attempt is made to
1328 automatically avoid collisions between ordinary notes and clusters.
1329
1330 @seealso
1331
1332 Program reference: @internalsref{ClusterSpanner},
1333 @internalsref{ClusterSpannerBeacon},
1334 @internalsref{Cluster_spanner_engraver}, and
1335 @internalsref{ClusterNoteEvent}.
1336
1337 Examples: @inputfileref{input/@/regression,cluster@/.ly}.
1338
1339 @refbugs
1340
1341 Music expressions like @code{<< @{ g8 e8 @} a4 >>} are not printed
1342 accurately.  Use @code{<g a>8 <e a>8} instead.
1343
1344
1345
1346 @node Special fermatas
1347 @subsection Special fermatas
1348
1349 @cindex fermatas, special
1350
1351 In contemporary music notation, special fermata symbols denote breaks
1352 of differing lengths.  The following fermatas are supported
1353
1354 @lilypond[quote,raggedright]
1355 <<
1356   \oldaddlyrics {
1357     b'2
1358     ^\shortfermata
1359     _\shortfermata
1360     r
1361
1362     b'
1363     ^\fermata
1364     _\fermata
1365     r
1366
1367     b'
1368     ^\longfermata
1369     _\longfermata
1370     r
1371
1372     b'
1373     ^\verylongfermata
1374     _\verylongfermata
1375     r
1376   }
1377   \context Lyrics \lyricmode {
1378     \override LyricText #'font-family = #'typewriter
1379     "shortfermata" "fermata" "longfermata" "verylongfermata"
1380   }
1381 >>
1382 @end lilypond
1383
1384 See @ref{Articulations} for general instructions how to apply scripts
1385 such as fermatas to notes.
1386
1387 @node Feathered beams
1388 @subsection Feathered beams
1389
1390 Feathered beams are not supported natively, but they can be faked by
1391 forcing two beams to overlap.  Here is an example,
1392
1393 @c don't change relative setting witout changing positions!
1394 @lilypond[raggedright,relative=1,fragment,verbatim]
1395 \new Staff <<
1396   \new Voice
1397   {
1398     \stemUp
1399     \once \override Voice.Beam #'positions = #'(0 . 0.5)
1400     c8[ c c c c ]
1401   }
1402   \new Voice {
1403     \stemUp
1404     \once \override Voice.Beam #'positions = #'(0 . -0.5)
1405     c[ c c c c]
1406   }
1407 >>
1408 @end lilypond
1409
1410
1411 @node Improvisation
1412 @subsection Improvisation
1413
1414 Improvisation is sometimes denoted with slashed note heads.  Such note
1415 heads can be created by adding a @internalsref{Pitch_squash_engraver}
1416 to the @internalsref{Staff} or @internalsref{Voice} context.  Then, the
1417 following command
1418
1419 @example
1420 \set squashedPosition = #0
1421 \override NoteHead #'style = #'slash
1422 @end example
1423
1424 @noindent
1425 switches on the slashes.
1426
1427 There are shortcuts @code{\improvisationOn} (and an accompanying
1428 @code{\improvisationOff}) for this command sequence.  They are used in
1429 the following example
1430
1431 @lilypond[verbatim,raggedright,quote]
1432 \new Staff \with {
1433   \consists Pitch_squash_engraver
1434 } \transpose c c' {
1435   e8 e g a a16(bes)(a8) g \improvisationOn
1436   e8
1437   ~e2~e8 f4 fis8
1438   ~fis2 \improvisationOff a16(bes) a8 g e
1439 }
1440 @end lilypond
1441
1442
1443 @node Educational use
1444 @section Educational use
1445
1446 With the amount of control that LilyPond offers, one can make great
1447 teaching tools in addition to great musical scores.
1448
1449 @menu
1450 * Balloon help::                
1451 * Blank music sheet::           
1452 * Hidden notes::                
1453 * Shaped note heads ::          
1454 * Easy Notation note heads::    
1455 * Analysis brackets::           
1456 * Coloring objects::            
1457 @end menu
1458
1459 @node Balloon help
1460 @subsection Balloon help
1461
1462 Elements of notation can be marked and named with the help of a square
1463 balloon.  The primary purpose of this feature is to explain notation.
1464
1465 The following example demonstrates its use.
1466
1467 @lilypond[quote,verbatim,fragment,raggedright,relative=2]
1468 \context Voice {
1469   \applyoutput
1470     #(add-balloon-text 'NoteHead "heads, or tails?"
1471     '(1 . -3))
1472   c8
1473 }
1474 @end lilypond
1475
1476 @noindent
1477 The function @code{add-balloon-text} takes the name of a grob, the
1478 label to print, and the position where to put the label relative to
1479 the object.  In the above example, the text ``heads or tails?'' ends
1480 3 spaces below and 1 space to the right of the marked head.
1481
1482 @cindex balloon
1483 @cindex notation, explaining
1484
1485 @seealso
1486
1487 Program reference: @internalsref{text-balloon-interface}.
1488
1489 Examples: @inputfileref{input/@/regression,balloon@/.ly}.
1490
1491
1492
1493
1494 @node Blank music sheet
1495 @subsection Blank music sheet
1496
1497 A blank music sheet can be produced also by using invisible notes, and
1498 removing @code{Bar_number_engraver}.
1499
1500
1501 @lilypond[quote,verbatim]
1502 emptymusic = {
1503   \repeat unfold 2 % Change this for more lines.
1504   { s1\break }
1505   \bar "|."
1506 }
1507 \new Score \with {
1508   \override TimeSignature #'transparent = ##t
1509   defaultBarType = #""
1510   \remove Bar_number_engraver
1511 } <<
1512   \context Staff \emptymusic
1513   \context TabStaff \emptymusic
1514 >>
1515 @end lilypond
1516
1517
1518 @node Hidden notes
1519 @subsection Hidden notes
1520
1521 @cindex Hidden notes
1522 @cindex Invisible notes
1523 @cindex Transparent notes
1524
1525 @cindex @code{\hideNotes}
1526 @cindex @code{\unHideNotes}
1527 Hidden (or invisible or transparent) notes can be useful in preparing theory
1528 or composition exercises.
1529
1530 @lilypond[quote,raggedright,verbatim,relative=2,fragment]
1531 c4 d4
1532 \hideNotes
1533 e4 f4
1534 \unHideNotes
1535 g4 a
1536 @end lilypond
1537
1538 Hidden notes are also great for performing weird tricks.  For example,
1539 slurs cannot be attached to rests or spacer rests, but you may wish
1540 to include that in your score -- string instruments use this notation
1541 when doing pizzicato to indicate that the note should ring for as long
1542 as possible.
1543
1544 @lilypond[quote,raggedright,verbatim,relative=0,fragment]
1545 \clef bass
1546 << {
1547   c4^"pizz"( \hideNotes c)
1548   \unHideNotes c( \hideNotes c)
1549 } {
1550   s4 r s r
1551 } >>
1552 @end lilypond
1553
1554
1555 @node Shaped note heads 
1556 @subsection Shaped note heads 
1557
1558 In shaped note head notation, the shape of the note head corresponds
1559 to the harmonic function of a note in the scale.  This notation was
1560 popular in the 19th century American song books.
1561
1562 Shaped note heads can be produced by setting @code{\aikenHeads} or
1563 @code{\sacredHarpHeads}, depending on the style desired.
1564
1565 @lilypond[verbatim,relative=1,fragment]
1566   \aikenHeads
1567   c8 d4 e8 a2 g1
1568   \sacredHarpHeads
1569   c8 d4. e8 a2 g1
1570 @end lilypond
1571
1572 Shapes are determined on the step in the scale, where the base of the
1573 scale is determined by  the @code{\key} command
1574
1575 @findex \key
1576 @findex shapeNoteStyles
1577 @findex \aikenHeads
1578 @findex \sacredHarpHeads
1579
1580 Shaped note heads are implemented through the @code{shapeNoteStyles}
1581 property.  Its value is a vector of symbols.  The k-th element indicates
1582 the style to use for the k-th step of the scale.  Arbitrary
1583 combinations are possible, eg.,
1584
1585
1586 @lilypond[verbatim,relative=1,fragment]
1587   \set shapeNoteStyles  = ##(cross triangle fa #f mensural xcircle diamond)
1588   c8 d4. e8 a2 g1
1589 @end lilypond
1590
1591
1592 @node Easy Notation note heads
1593 @subsection Easy Notation note heads
1594
1595 @cindex easy notation
1596 @cindex Hal Leonard
1597
1598 The `easy play' note head includes a note name inside the head.  It is
1599 used in music for beginners
1600
1601 @lilypond[quote,raggedright,verbatim,fragment,staffsize=26]
1602   \setEasyHeads
1603   c'2 e'4 f' | g'1
1604 @end lilypond
1605
1606 The command @code{\setEasyHeads} overrides settings for the
1607 @internalsref{NoteHead} object.  To make the letters readable, it has
1608 to be printed in a large font size.  To print with a larger font, see
1609 @ref{Setting global staff size}.
1610
1611 @refcommands
1612
1613 @cindex @code{\setEasyHeads}
1614 @code{\setEasyHeads}
1615
1616
1617 @node Analysis brackets
1618 @subsection Analysis brackets
1619 @cindex brackets
1620 @cindex phrasing brackets
1621 @cindex musicological analysis
1622 @cindex note grouping bracket
1623
1624 Brackets are used in musical analysis to indicate structure in musical
1625 pieces.  LilyPond supports a simple form of nested horizontal
1626 brackets.  To use this, add the @internalsref{Horizontal_bracket_engraver}
1627 to @internalsref{Staff} context.  A bracket is started with
1628 @code{\startGroup} and closed with @code{\stopGroup}
1629
1630 @lilypond[quote,raggedright,verbatim]
1631 \score {
1632   \relative c'' {
1633     c4\startGroup\startGroup
1634     c4\stopGroup
1635     c4\startGroup
1636     c4\stopGroup\stopGroup
1637   }
1638   \layout {
1639     \context {
1640       \Staff \consists "Horizontal_bracket_engraver"
1641 }}}
1642 @end lilypond
1643
1644 @seealso
1645
1646 Program reference: @internalsref{HorizontalBracket},
1647 @internalsref{NoteGroupingEvent}.
1648
1649 Examples: @inputfileref{input/@/regression,note@/-group@/-bracket@/.ly}.
1650
1651
1652
1653 @ignore
1654
1655 I don't think we need this info.
1656
1657 @n ode Stems
1658 @s ubsection Stems
1659
1660 Whenever a note is found, a @internalsref{Stem} object is created
1661 automatically.  For whole notes and rests, they are also created but
1662 made invisible.
1663
1664 @refcommands
1665
1666 @cindex @code{\stemUp}
1667 @code{\stemUp},
1668 @cindex @code{\stemDown}
1669 @code{\stemDown},
1670 @cindex @code{\stemNeutral}
1671 @code{\stemNeutral}.
1672
1673 @end ignore
1674
1675
1676
1677
1678 @ignore
1679
1680 FIXME:  We don't need this section.  It will be moved into LSR as soon
1681 as the safe mode stuff is worked out.
1682
1683 @n ode Controlling formatting of prefatory matter
1684 @s ubsection Controlling formatting of prefatory matter
1685
1686 @c  This section will be moved to somewhere else soon. -gp
1687 This example demonstrates how to place prefatory matter
1688 (such as the clef and key signature) at the end of a line.
1689
1690 @lilypond[quote,verbatim]
1691 \transpose c c' {
1692   \override Staff.Clef
1693     #'break-visibility = #end-of-line-visible
1694   \override Staff.KeySignature
1695     #'break-visibility = #end-of-line-visible
1696   \set Staff.explicitClefVisibility = #end-of-line-visible
1697   \set Staff.explicitKeySignatureVisibility = #end-of-line-visible
1698
1699   % We want the time sig to take space, otherwise there is not
1700   % enough white at the start of the line.
1701
1702   \override Staff.TimeSignature #'transparent = ##t
1703   \set Score.defaultBarType = #"empty"
1704
1705   c1 d e f g a b c
1706   \key d \major
1707   \break
1708
1709   % see above.
1710   \time 4/4
1711
1712   d e fis g a b cis d
1713   \key g \major
1714   \break
1715   \time 4/4
1716 }
1717 @end lilypond
1718
1719 @end ignore
1720
1721
1722 @node Coloring objects
1723 @subsection Coloring objects
1724
1725 @c FIXME: need link to missing list of colors
1726 Individual objects may be assigned colors.  You may use color names
1727 listed HERE
1728
1729 @lilypond[quote,raggedright,verbatim,fragment]
1730 \override NoteHead #'color = #red
1731 c4 c
1732 \override NoteHead #'color = #(x11-color 'LimeGreen)
1733 d
1734 \override Stem #'color = #blue
1735 e
1736 @end lilypond
1737
1738 The full range of colors defined for X11 can be accessed by using the
1739 scheme function x11-color.  The function takes one argument that can be a
1740 symbol
1741
1742 @example
1743 \override Beam #'color = #(x11-color 'MediumTurquoise)
1744 @end example
1745
1746 or a string
1747
1748 @example
1749 \override Beam #'color = #(x11-color "MediumTurquoise")
1750 @end example
1751
1752 The first form is quicker to write and is more efficient.  However, using
1753 the second form it is possible to access X11 colors by the multi-word
1754 form of its name
1755
1756 @example
1757 \override Beam #'color = #(x11-color "medium turquoise")
1758 @end example
1759
1760 If x11-color cannot make sense of the parameter then the color returned
1761 defaults to black.  It should be obvious from the final score that
1762 something is wrong.
1763
1764 This example, illustrates the use of x11-color.  Notice that the stem
1765 color remains black after being set to (x11-color 'Boggle), which is
1766 deliberate nonsense.
1767
1768 @lilypond[quote,raggedright,verbatim]
1769 {
1770   \override Staff.StaffSymbol #'color = #(x11-color 'SlateBlue2)
1771   \set Staff.instrument = \markup {
1772     \with-color #(x11-color 'navy) "Clarinet"
1773   }
1774   \time 2/4
1775   gis''8 a''
1776   \override Beam #'color = #(x11-color "medium turquoise")
1777   gis'' a''
1778   \override NoteHead #'color = #(x11-color "LimeGreen")
1779   gis'' a''
1780   \override Stem #'color = #(x11-color 'Boggle)
1781   gis'' a''
1782 }
1783 @end lilypond
1784
1785
1786 @refbugs
1787 Not all x11 colors are distinguishable in a web browser.  For web use
1788 normal colors are recommended. 
1789
1790 An x11 color is not necessarily exactly the same shade as a similarly
1791 named normal color. 
1792
1793
1794 @seealso
1795
1796 COLORLIST
1797
1798
1799 @node Automatic notation
1800 @section Automatic notation
1801
1802 This section describes how to change the way that accidentals and
1803 beams are automatically displayed.
1804
1805 FIXME: this might get moved into Changing Defaults.  Please send
1806 opinions to lilypond-devel.  Thanks!  :)
1807
1808 @menu
1809 * Automatic accidentals::       
1810 * Setting automatic beam behavior::  
1811 * Beam formatting::             
1812 @end menu
1813
1814 @node Automatic accidentals
1815 @subsection Automatic accidentals
1816 @cindex Automatic accidentals
1817
1818 Common rules for typesetting accidentals have been placed in a
1819 function.  This function is called as follows
1820
1821 @cindex @code{set-accidental-style}
1822 @example
1823 #(set-accidental-style 'STYLE #('CONTEXT#))
1824 @end example
1825
1826 The function can take two arguments: the name of the accidental style,
1827 and an optional argument that denotes the context that should be
1828 changed.  If no context name is supplied, @code{Staff} is the default,
1829 but you may wish to apply the accidental style to a single @code{Voice}
1830 instead.
1831
1832 The following accidental styles are supported
1833 @table @code
1834 @item default
1835 This is the default typesetting behavior.  It corresponds
1836 to 18th century common practice: Accidentals are
1837 remembered to the end of the measure in which they occur and
1838 only on their own octave.
1839
1840 @item voice
1841 The normal behavior is to remember the accidentals on
1842 Staff-level.  This variable, however, typesets accidentals
1843 individually for each voice.  Apart from that, the rule is similar to
1844 @code{default}.
1845
1846 As a result, accidentals from one voice do not get canceled in other
1847 voices, which is often an unwanted result
1848
1849 @lilypond[quote,raggedright,relative=1,fragment,verbatim]
1850 \context Staff <<
1851   #(set-accidental-style 'voice)
1852   <<
1853     { es g } \\
1854     { c, e }
1855 >> >>
1856 @end lilypond
1857
1858 The @code{voice} option should be used if the voices
1859 are to be read solely by individual musicians.  If the staff is to be
1860 used by one musician (e.g., a conductor) then
1861 @code{modern} or @code{modern-cautionary}
1862 should be used instead.
1863
1864 @item modern
1865 @cindex @code{modern} style accidentals
1866 This rule corresponds to the common practice in the 20th century.  This rule
1867 prints the same accidentals as @code{default}, but temporary
1868 accidentals also are canceled in other octaves.  Furthermore,
1869 in the same octave, they also get canceled in the following
1870 measure
1871
1872 @lilypond[quote,raggedright,fragment,verbatim]
1873 #(set-accidental-style 'modern)
1874 cis' c'' cis'2 | c'' c'
1875 @end lilypond
1876
1877 @item @code{modern-cautionary}
1878 @cindex @code{modern-cautionary}
1879 This rule is similar to @code{modern}, but the ``extra'' accidentals
1880 (the ones not typeset by @code{default}) are typeset as cautionary
1881 accidentals.  They are printed in reduced size or with parentheses
1882 @lilypond[quote,raggedright,fragment,verbatim]
1883 #(set-accidental-style 'modern-cautionary)
1884 cis' c'' cis'2 | c'' c'
1885 @end lilypond
1886
1887 @cindex @code{modern-voice}
1888 @item modern-voice
1889 This rule is used for multivoice accidentals to be read both by musicians
1890 playing one voice and musicians playing all voices.  Accidentals are
1891 typeset for each voice, but they @emph{are} canceled across voices in
1892 the same @internalsref{Staff}.
1893
1894 @cindex @code{modern-voice-cautionary}
1895 @item modern-voice-cautionary
1896 This rule is the same as @code{modern-voice}, but with the extra
1897 accidentals (the ones not typeset by @code{voice}) typeset
1898 as cautionaries.  Even though all accidentals typeset by
1899 @code{default} @emph{are} typeset by this variable,
1900 some of them are typeset as cautionaries.
1901
1902 @item piano
1903 @cindex @code{piano} accidentals
1904 This rule reflects 20th century practice for piano notation.  Very similar to
1905 @code{modern} but accidentals also get canceled
1906 across the staves in the same @internalsref{GrandStaff} or
1907 @internalsref{PianoStaff}.
1908
1909 @item piano-cautionary
1910 @cindex @code{#(set-accidental-style 'piano-cautionary)}
1911 Same as @code{#(set-accidental-style 'piano)} but with the extra
1912 accidentals typeset as cautionaries.
1913
1914 @item no-reset
1915 @cindex @code{no-reset} accidental style
1916 This is the same as @code{default} but with accidentals lasting
1917 ``forever'' and not only until the next measure
1918 @lilypond[quote,raggedright,fragment,verbatim,relative=1]
1919 #(set-accidental-style 'no-reset)
1920 c1 cis cis c
1921 @end lilypond
1922
1923 @item forget
1924 This is sort of the opposite of @code{no-reset}: Accidentals
1925 are not remembered at all---and hence all accidentals are
1926 typeset relative to the key signature, regardless of what was
1927 before in the music
1928
1929 @lilypond[quote,raggedright,fragment,verbatim,relative=1]
1930 #(set-accidental-style 'forget)
1931 \key d\major c4 c cis cis d d dis dis
1932 @end lilypond
1933 @end table
1934
1935
1936 @seealso
1937
1938 Program reference: @internalsref{Accidental_engraver},
1939 @internalsref{Accidental}, and @internalsref{AccidentalPlacement}.
1940
1941
1942 @refbugs
1943
1944 Simultaneous notes are considered to be entered in sequential
1945 mode.  This means that in a chord the accidentals are typeset as if the
1946 notes in the chord happened once at a time - in the order in which
1947 they appear in the input file.
1948
1949 This is a problem when accidentals in a chord depend on each other,
1950 which does not happen for the default accidental style.  The problem
1951 can be solved by manually inserting @code{!} and @code{?} for the
1952 problematic notes.
1953
1954
1955 @node Setting automatic beam behavior
1956 @subsection Setting automatic beam behavior
1957
1958 @cindex @code{autoBeamSettings}
1959 @cindex @code{(end * * * *)}
1960 @cindex @code{(begin * * * *)}
1961 @cindex automatic beams, tuning
1962 @cindex tuning automatic beaming
1963
1964 @c [TODO: use \applycontext]
1965
1966 In normal time signatures, automatic beams can start on any note but can
1967 only end in a few positions within the measure: beams can end on a beat,
1968 or at durations specified by the properties in
1969 @code{autoBeamSettings}.  The defaults for @code{autoBeamSettings}
1970 are defined in @file{scm/@/auto@/-beam@/.scm}.
1971
1972 The value of @code{autoBeamSettings} is changed with three functions,
1973 @example
1974 #(override-auto-beam-setting
1975    '(@var{be} @var{p} @var{q} @var{n} @var{m}) @var{a} @var{b}
1976    [@var{context}])
1977 #(score-override-auto-beam-setting
1978    '(@var{be} @var{p} @var{q} @var{n} @var{m}) @var{a} @var{b})
1979 #(revert-auto-beam-setting '(@var{be} @var{p} @var{q} @var{n} @var{m})
1980    [@var{context}])
1981 @end example
1982 Here, @var{be} is the symbol @code{begin} or @code{end}, and
1983 @var{context} is an optional context (default: @code{'Voice}).  It
1984 determines whether the rule applies to begin or end-points.  The
1985 quantity @var{p}/@var{q} refers to the length of the beamed notes (and
1986 `@code{* *}' designates notes of any length), @var{n}/@var{M} refers
1987 to a time signature (wildcards `@code{* *}' may be entered to
1988 designate all time signatures), @var{a}/@var{b} is a duration.  By
1989 default, this command changes settings for the current voice.  It is
1990 also possible to adjust settings at higher contexts, by adding a
1991 @var{context} argument.  @code{score-override-auto-beam-setting} is
1992 equal to @code{override-auto-beam-setting} with the argument
1993 @var{context} set to @code{'Score}.
1994
1995 For example, if automatic beams should end on the first quarter note, use
1996 the following
1997 @example
1998 #(override-auto-beam-setting '(end * * * *) 1 4 'Staff)
1999 @end example
2000 Since the duration of a quarter note is 1/4 of a whole note, it is
2001 entered as @code{(ly:make-moment 1 4)}.
2002
2003 If automatic beams should end on every quarter in 5/4 time, specify
2004 all endings
2005 @example
2006 #(override-auto-beam-setting '(end * * * *) 1 4 'Staff)
2007 #(override-auto-beam-setting '(end * * * *) 1 2 'Staff)
2008 #(override-auto-beam-setting '(end * * * *) 3 4 'Staff)
2009 #(override-auto-beam-setting '(end * * * *) 5 4 'Staff)
2010 @dots{}
2011 @end example
2012
2013 The same syntax can be used to specify beam starting points.  In this
2014 example, automatic beams can only end on a dotted quarter note
2015 @example
2016 #(override-auto-beam-setting '(end * * * *) 3 8)
2017 #(override-auto-beam-setting '(end * * * *) 1 2)
2018 #(override-auto-beam-setting '(end * * * *) 7 8)
2019 @end example
2020 In 4/4 time signature, this means that automatic beams could end only on
2021 3/8 and on the fourth beat of the measure (after 3/4, that is 2 times
2022 3/8, has passed within the measure).
2023
2024 Rules can also be restricted to specific time signatures.  A rule that
2025 should only be applied in @var{N}/@var{M} time signature is formed by
2026 replacing the second asterisks by @var{N} and @var{M}.  For example, a
2027 rule for 6/8 time exclusively looks like
2028 @example
2029 #(override-auto-beam-setting '(begin * * 6 8) @dots{})
2030 @end example
2031
2032 If a rule should be to applied only to certain types of beams, use the
2033 first pair of asterisks.  Beams are classified according to the
2034 shortest note they contain.  For a beam ending rule that only applies
2035 to beams with 32nd notes (and no shorter notes), use @code{(end 1 32 *
2036 *)}.
2037
2038 @cindex automatic beam generation
2039 @cindex autobeam
2040 @cindex @code{autoBeaming}
2041 @cindex lyrics
2042
2043 If beams are used to indicate melismata in songs, then automatic
2044 beaming should be switched off.  This is done by setting
2045 @code{autoBeaming} to @code{#f}.
2046
2047 @refcommands
2048
2049 @cindex @code{\autoBeamOff}
2050 @code{\autoBeamOff},
2051 @cindex @code{\autoBeamOn}
2052 @code{\autoBeamOn}.
2053
2054
2055 @refbugs
2056
2057 If a score ends while an automatic beam has not been ended and is
2058 still accepting notes, this last beam will not be typeset at all.  The
2059 same holds polyphonic voices, entered with @code{<< @dots{} \\ @dots{}
2060 >>}.  If a polyphonic voice ends while an automatic beam is still
2061 accepting notes, it is not typeset.
2062
2063 @node Beam formatting
2064 @subsection Beam formatting
2065
2066 When a beam falls in the middle of the staff, the beams point normally
2067 down.  However, this behaviour can be altered with the
2068 @code{neutral-direction} property.
2069
2070 @lilypond[quote,raggedright,relative=2,fragment,verbatim]
2071 {
2072   b8[ b]
2073   \override Beam #'neutral-direction = #-1
2074   b[ b]
2075   \override Beam #'neutral-direction = #1
2076   b[ b]
2077 }
2078 @end lilypond
2079
2080