]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/rhythms.itely
Merge branch 'master' of ssh://jomand@git.sv.gnu.org/srv/git/lilypond into lilypond...
[lilypond.git] / Documentation / user / rhythms.itely
1 @c -*- coding: utf-8; mode: texinfo; -*-
2 @ignore
3     Translation of GIT committish: FILL-IN-HEAD-COMMITTISH
4
5     When revising a translation, copy the HEAD committish of the
6     version that you are working on.  See TRANSLATION for details.
7 @end ignore
8
9 @node Rhythms
10 @section Rhythms
11
12 @lilypondfile[quote]{rhythms-headword.ly}
13
14 This section discusses rhythms, rests, durations, beaming and bars.
15
16 @menu
17 * Writing rhythms::             
18 * Writing rests::               
19 * Displaying rhythms::          
20 * Beams::                       
21 * Bars::                        
22 * Special rhythmic concerns::   
23 @end menu
24
25
26 @node Writing rhythms
27 @subsection Writing rhythms
28
29 @menu
30 * Durations::                   
31 * Tuplets::                     
32 * Scaling durations::           
33 * Ties::                        
34 @end menu
35
36 @node Durations
37 @subsubsection Durations
38
39 @cindex durations, of notes
40 @cindex note durations
41
42 @funindex \longa
43 @funindex \breve
44 @funindex \maxima
45
46 Durations are designated by numbers and dots.
47 Durations are entered as their reciprocal values.  For example, a
48 quarter note is entered using a @code{4} (since it is a 1/4 note),
49 and a half note is entered using a @code{2} (since it is a 1/2
50 note).  For notes longer than a whole you must use the
51 @code{\longa} (a double breve) and @code{\breve} commands.  
52 Durations as short as 64th notes may be specified.  Shorter values
53 are possible, but only as beamed notes.
54
55 @c Two 64th notes are needed to obtain beams
56 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
57 \time 8/1
58 c\longa c\breve c1 c2
59 c4 c8 c16 c32 c64 c64
60 @end lilypond
61
62 @noindent
63 Here are the same durations with automatic beaming turned off.
64
65 @c not strictly "writing rhythms"; more of a "displaying" thing,
66 @c but it's ok here.  -gp
67 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
68 \time 8/1
69 \autoBeamOff
70 c\longa c\breve c1 c2
71 c4 c8 c16 c32 c64 c64
72 @end lilypond
73
74 A note with the duration of a quadruple breve may be entered with
75 @code{\maxima}, but this is supported only within ancient music
76 notation.  For details, see @ref{Ancient notation}.
77
78 If the duration is omitted, it is set to the previously
79 entered duration.  The default for the first note is a quarter
80 note.
81
82 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
83 a a a2 a a4 a a1 a
84 @end lilypond
85
86 @cindex notes, dotted
87 @cindex dotted notes
88
89 @funindex .
90
91 To obtain dotted note lengths, place a dot (@code{.}) after the
92 duration.  Double-dotted notes are specified by appending two
93 dots, and so on.
94
95 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
96 a4 b c4. b8 a4. b4.. c8.
97 @end lilypond
98
99 Some durations cannot be represented with just binary durations
100 and dots; they can be represented only by tying two or more
101 notes together.  For details, see @ref{Ties}.
102
103 For ways of specifying durations for the syllables of lyrics and
104 ways of aligning lyrics to notes, see @ref{Vocal music}.
105
106 Optionally, notes can be spaced strictly proportionately to their
107 duration.  For details of this and other settings which control
108 proportional notation, see @ref{Proportional notation}.
109
110 Dots are normally moved up to avoid staff lines, except in
111 polyphonic situations.  To force a particular direction manually, 
112 see @ref{Controlling direction and placement}.
113
114 @predefined
115
116 @funindex \dotsUp
117 @code{\dotsUp},
118 @funindex \dotsDown
119 @code{\dotsDown},
120 @funindex \dotsNeutral
121 @code{\dotsNeutral}.
122
123
124 @seealso
125
126 Music Glossary: 
127 @rglos{breve}, 
128 @rglos{longa}, 
129 @rglos{note value},
130 @rglos{Duration names notes and rests}.
131
132 Notation Reference: 
133 @ref{Automatic beams}, 
134 @ref{Ties},
135 @ref{Writing rhythms}, 
136 @ref{Writing rests}, 
137 @ref{Vocal music},
138 @ref{Ancient notation}, 
139 @ref{Proportional notation}.
140
141 Snippets: @lsrdir{Rhythms,Rhythms}
142
143 Internals Reference: 
144 @internalsref{Dots},
145 @internalsref{DotColumn}.
146
147
148 @knownissues
149
150 @c Deliberately duplicated in Durations and Rests.  -gp
151 There is no fundamental limit to rest durations (both in terms of
152 longest and shortest), but the number of glyphs is limited:
153 rests from 128th to maxima (8 x whole) may be printed.
154
155
156 @node Tuplets
157 @subsubsection Tuplets
158
159 @cindex tuplets
160 @cindex triplets
161 @funindex \times
162
163 Tuplets are made from a music expression by multiplying all the
164 durations with a fraction:
165
166 @example
167 \times @var{fraction} @var{musicexpr}
168 @end example
169
170 @noindent
171 The duration of @var{musicexpr} will be multiplied by the 
172 fraction.  The fraction's denominator will be printed over or 
173 under the notes, optionally with a bracket.  The most common 
174 tuplet is the triplet in which 3 notes have the duration of 2, so
175 the notes are 2/3 of their written length.
176
177 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
178 a2 \times 2/3 {b4 b b}
179 c4 c \times 2/3 {b4 a g}
180
181 @end lilypond
182
183 The automatic placement of the tuplet bracket above or below the 
184 notes may be overridden manually, for details see 
185 @ref{Controlling direction and placement}.
186
187 Tuplets may be nested:
188
189 @lilypond[quote,fragment,ragged-right,verbatim,relative=2]
190 \autoBeamOff
191 c4 \times 4/5 { f8 e f \times 2/3 {e[ f g] } } f4 |
192 @end lilypond
193
194 Modifying nested tuplets which begin at the same musical moment
195 must be done with @code{\tweak}.
196
197 To modify the duration of notes without printing a tuplet bracket,
198 see @ref{Scaling durations}.
199
200 @predefined
201
202 @funindex \tupletUp
203 @code{\tupletUp},
204 @funindex \tupletDown
205 @code{\tupletDown},
206 @funindex \tupletNeutral
207 @code{\tupletNeutral}.
208
209
210 @snippets
211
212 @cindex tuplet formatting
213 @cindex triplet formatting
214
215 @funindex tupletNumberFormatFunction
216 @funindex tupletSpannerDuration
217
218 @lilypondfile [verbatim,lilyquote,ragged-right,texidoc]
219 {entering-several-tuplets-using-only-one--times-command.ly}
220
221 @funindex TupletNumber
222
223 @c Sent to VV on 12 Feb - replace with @lilypondfile when available
224 @c TODO and delete from here ...
225 By default, only the numerator of the tuplet number
226 is printed over the tuplet bracket, i.e. the denominator
227 of the argument to the @code{\times} command.  Alternatively,
228 @var{num}:@var{den} of the tuplet number may be printed, or
229 the tuplet number may be suppressed altogether.
230
231
232 @lilypond[quote,fragment,relative=2,ragged-right,verbatim]
233 \times 2/3 { c8 c c } \times 2/3 { c8 c c }
234 \override TupletNumber #'text = #tuplet-number::calc-fraction-text
235 \times 2/3 { c8 c c }
236 \override TupletNumber #'transparent = ##t
237 \times 2/3 { c8 c c }
238 @end lilypond
239
240 @c ... to here
241
242
243 @c Sent to VV on 12 Feb - replace with @lilypondfile when available
244 @c TODO and delete from here ...
245 This artificial example shows how both manual and automatic line
246 breaks may be permitted within a beamed tuplet. Note that such
247 off-beat tuplets have to be beamed manually.
248
249 @lilypond[quote,ragged-right,verbatim]
250 \relative c'' {
251   a8
252   \repeat unfold 8 {\times 2/3 { c[ b a]}}
253   % Insert a manual line break within a tuplet
254   \times 2/3 { c[ b \bar "" \break a]}
255   \repeat unfold 2 {\times 2/3 { c[ b a]}}
256   c8
257 }
258 \layout {
259   \context {
260     \Voice
261     % Permit line breaks within tuplets
262     \remove "Forbid_line_break_engraver"
263     % Allow beams to be broken at line breaks
264     \override Beam #'breakable = ##t
265   }
266 }
267 @end lilypond
268
269 @c .. to here
270
271 @seealso
272
273 Music Glossary: 
274 @rglos{triplet}, 
275 @rglos{tuplet},
276 @rglos{polymetric}.
277
278 Notation Reference:
279 @ref{Time administration},
280 @ref{Scaling durations},
281 @ref{Objects connected to the input},
282 @ref{Polymetric notation}.
283
284 Snippets: @lsrdir{Rhythms,Rhythms}.
285
286 Internals Reference: 
287 @internalsref{TupletBracket},
288 @internalsref{TupletNumber}, 
289 @internalsref{TimeScaledMusic}.
290
291
292 @node Scaling durations
293 @subsubsection Scaling durations
294
295 @cindex scaling durations
296 @cindex durations, scaling
297
298 You can alter the duration of single notes, rests or chords by a
299 fraction @code{N/M} by appending @code{*N/M} (or @code{*N} if
300 @code{M} is 1) to the duration.
301 This will not affect the appearance of the notes or rests
302 produced, but the altered duration will be used in calculating the
303 position within the measure and setting the duration in the MIDI
304 output.  Multiplying factors may be combined such as @code{*L*M/N}.
305
306 In the following example, the first three notes take up exactly
307 two beats, but no triplet bracket is printed.
308
309 @lilypond[quote,ragged-right,fragment,relative=2,verbatim]
310 \time 2/4
311 % Alter durations to triplets
312 a4*2/3 gis4*2/3 a4*2/3
313 % Normal durations
314 a4 a4
315 % Double the duration of chord
316 <a d>4*2
317 % Duration of quarter, appears like sixteeth
318 b16*4 c4
319 @end lilypond
320
321 The duration of skip or spacing notes may also be modified by
322 a multiplier.  This is useful for skipping many measures, e.g.,
323 @code{s1*23}.
324
325 @cindex compressing music
326 @funindex \compressMusic
327
328 Longer stretches of music may be compressed by a fraction in 
329 the same way, as if every note, chord or rest had the fraction 
330 as a multiplier.  The general syntax of the command to do this
331 is:
332
333 @example
334 \compressMusic #'(@emph{num} . @emph{den}) @{ @emph{music} @}
335 @end example
336
337 @noindent
338 This will leave the appearance of @emph{music} unchanged but
339 the internal duration of the notes will be multiplied by the
340 fraction @emph{num}/@emph{den}.  The spaces around the dot
341 are required.  Here is an example showing how music can be
342 compressed and expanded:
343
344 @lilypond[quote,fragment,relative=2,ragged-right,verbatim]
345 \time 2/4
346 % Normal durations
347 <c a>4 c8 a
348 % Scale music by *2/3
349 \compressMusic #'(2 . 3) {
350   <c a f>4. c8 a f
351 }
352 % Scale music by *2
353 \compressMusic #'(2 . 1) {
354   <c' a>4 c8 b
355 }
356 @end lilypond
357
358 @noindent
359 One application of this command is in polymetric
360 notation, see @ref{Polymetric notation}.
361
362
363 @seealso
364
365 Notation Reference:
366 @ref{Tuplets},
367 @ref{Skips},
368 @ref{Polymetric notation}.
369
370 Snippets: @lsrdir{Rhythms,Rhythms}
371
372 @node Ties
373 @subsubsection Ties
374
375 @cindex tie
376 @funindex ~
377
378 A tie connects two adjacent note heads of the same pitch.  The tie
379 in effect extends the duration of a note.
380
381 @warning{Ties should not be confused with @emph{slurs}, which
382 indicate articulation, or @emph{phrasing slurs}, which indicate
383 musical phrasing. A tie is just a way of extending a note
384 duration, similar to the augmentation dot.}
385
386 A tie is entered using the tilde symbol @code{~}
387
388 @lilypond[quote,ragged-right,fragment,verbatim]
389 e' ~ e'
390 @end lilypond
391
392
393 @noindent
394 Ties are used either when the note crosses a bar line, or when
395 dots cannot be used to denote the rhythm.  Ties should also be
396 used when note values cross larger subdivisions of the measure:
397
398 @lilypond[fragment,quote,ragged-right]
399 \relative {
400   r8 c8 ~ c2 r4 | r8^"not" c2 ~ c8 r4
401 }
402 @end lilypond
403
404 If you need to tie a lot of notes across bar lines, it may be
405 easier to use automatic note splitting, see @ref{Automatic note
406 splitting}.  This mechanism automatically splits long notes, and
407 ties them across bar lines.
408
409 @cindex ties and chords
410 @cindex chords and ties
411
412 When a tie is applied to a chord, all note heads whose pitches
413 match are connected.  When no note heads match, no ties will be
414 created.  Chords may be partially tied by placing the tie inside
415 the chord.
416
417 @lilypond[quote,ragged-right,fragment,verbatim,relative=1]
418  <c e g> ~ <c e g>
419 <c~ e g~ b> <c e g b>
420 @end lilypond
421
422 @funindex \repeatTie
423 @cindex repeating ties
424 @cindex ties, repeating
425 @cindex volta brackets and ties
426 @cindex ties and volta brackets
427
428 When a second alternative of a repeat starts with a tied note, you
429 have to specify the repeated tie as follows:
430
431 @lilypond[fragment,quote,ragged-right,relative=2,verbatim]
432 \repeat volta 2 { c g <c e>2 ~ }
433 \alternative {
434   % Following note is tied normally in first alternative
435   { <c e>2. r4 }
436   % Following note has a repeated tie in second alternative
437   {<c e>2\repeatTie d4 c }}
438 @end lilypond
439
440 @cindex laissez vibrer
441 @cindex ties, laissez vibrer
442 @funindex \laissezVibrer
443
444 @notation{L.v.} ties (@notation{laissez vibrer}) indicate that
445 notes must not be damped at the end.  It is used in notation for
446 piano, harp and other string and percussion instruments.  They can
447 be entered as follows:
448
449 @lilypond[fragment,ragged-right,verbatim,relative=1]
450 <c f g>\laissezVibrer
451 @end lilypond
452
453 @cindex ties, placement
454 @funindex \tieUp
455 @funindex \tieDown
456 @funindex \tieNeutral
457
458 The vertical placement of ties may be controlled, see the
459 predefined commands.  For details, see
460 @ref{Controlling direction and placement}.
461
462 @cindex ties, appearance
463 @funindex \tieDotted
464 @funindex \tieDashed
465 @funindex \tieSolid
466
467 Solid, dotted or dashed ties may be specified, see predefined
468 commands.
469
470
471 @predefined
472
473 @funindex \tieUp
474 @code{\tieUp},
475 @funindex \tieDown
476 @code{\tieDown},
477 @funindex \tieNeutral
478 @code{\tieNeutral},
479 @funindex \tieDotted
480 @code{\tieDotted},
481 @funindex \tieDashed
482 @code{\tieDashed},
483 @funindex \tieSolid
484 @code{\tieSolid}.
485
486
487 @snippets
488
489 @c TODO Remove when snippet available - sent 15 Mar 08
490 Ties are sometimes used to write out arpeggios.  In this case, two
491 tied notes need not be consecutive.  This can be achieved by
492 setting the @code{tieWaitForNote} property to true.  The same
493 feature is also useful, for example, to tie a tremolo to a chord,
494 but in principle, it can also be used for ordinary, consecutive
495 notes:
496
497 @lilypond[fragment,verbatim,relative=1,ragged-right,quote]
498 \set tieWaitForNote = ##t
499 \grace { c16[~ e~ g]~ } <c, e g>2
500 \repeat tremolo 8 { c32~ c'~ } <c c,>1
501 e8~ c~ a~ f~ <e' c a f>2
502 \tieUp c8~ a \tieDown \tieDotted g~ c g2
503 @end lilypond
504
505 @c end of section to be removed
506
507 @c TODO Remove when snippet available - sent 15 Mar 08
508 Ties may be engraved manually by changing the
509 @code{tie-configuration} property of the @code{TieColumn} object.
510 The first number indicates the distance from the center of the
511 staff in staff-spaces, and the second number indicates the
512 direction (1=up, -1=down).
513
514 @lilypond[fragment,verbatim,relative=1,ragged-right,quote]
515 <c e g>2~ <c e g> |
516 \override TieColumn #'tie-configuration =
517   #'((0.0 . 1) (-2.0 . 1) (-4.0 . 1))
518 <c e g>~ <c e g> |
519 @end lilypond
520
521 @c end of section to be removed
522
523
524 @seealso
525
526 Music Glossary:
527 @rglos{tie},
528 @rglos{laissez vibrer}.
529
530 Notation Reference: @ref{Automatic note splitting}.
531
532 Snippets: @lsrdir{Rhythms,Rhythms}
533
534 Internals Reference:
535 @internalsref{LaissezVibrerTie}
536 @internalsref{LaissezVibrerTieColumn}
537 @internalsref{TieColumn}
538 @internalsref{Tie}.
539
540
541 @knownissues
542
543 Switching staves when a tie is active will not produce a slanted
544 tie.
545
546 Changing clefs or octavations during a tie is not really
547 well-defined.  In these cases, a slur may be preferable.
548
549
550
551
552
553 @node Writing rests
554 @subsection Writing rests
555
556 @menu
557 * Rests::
558 * Skips::
559 * Full measure rests::
560 @end menu
561
562 @node Rests
563 @subsubsection Rests
564 @cindex rest
565 @cindex maxima
566 @cindex longa
567 @cindex breve
568
569 @funindex \rest
570 @funindex r
571 @funindex \maxima
572 @funindex \longa
573 @funindex \breve
574
575 Rests are entered like notes with the note name @code{r}:
576
577 @c \time 16/1 is used to avoid spurious bar lines
578 @c and long tracts of empty measures
579 @lilypond[fragment,quote,ragged-right,verbatim]
580 \new Staff {
581   \time 16/1
582   \override Staff.TimeSignature #'stencil = ##f
583   r\maxima
584   r\longa r\breve r1 r2
585   r4 r8 r16 r32 r64
586 }
587 @end lilypond
588
589 Whole measure rests, centered in middle of the measure, must be entered as
590 multi-measure rests.  They can be used for a single measure as well as
591 many measures and are discussed in @ref{Full measure rests}.
592
593 To explicitly specify a rest's vertical position, write a note
594 followed by @code{\rest}.  A rest will be placed in the position
595 where the note would appear.  This allows for precise manual
596 formatting of polyphonic music, since the automatic rest collision
597 formatter will leave these rests alone.
598
599 @lilypond[fragment,quote,ragged-right,verbatim,relative=2]
600 a4\rest d4\rest
601 @end lilypond
602
603
604 @seealso
605
606 Notation Reference: @ref{Full measure rests}.
607
608 Snippets: @lsrdir{Rhythms,Rhythms}.
609
610 Internals Reference: @internalsref{Rest}.
611
612
613 @knownissues
614
615 @c Deliberately duplicated in Durations and Rests.  -gp
616 There is no fundamental limit to rest durations (both in terms of
617 longest and shortest), but the number of glyphs is limited: there
618 are rests from 128th to maxima (8 x whole).
619
620 @node Skips
621 @subsubsection Skips
622
623 @cindex skip
624 @cindex invisible rest
625 @cindex space note
626 @funindex \skip
627 @funindex s
628
629 An invisible rest (also called a @q{skip}) can be entered like a
630 note with note name @code{s} or with @code{\skip @var{duration}}
631
632 @lilypond[fragment,quote,ragged-right,verbatim,relative=2]
633 a4 a4 s4 a4 \skip 1 a4
634 @end lilypond
635
636 @cindex lyrics, skip
637
638 The @code{s} syntax is only available in note mode and chord mode.
639 In other situations, for example, when entering lyrics, one must
640 use the @code{\skip} command:
641
642 @lilypond[quote,ragged-right,verbatim,relative=2]
643 <<
644   { a2 a2 }
645   \new Lyrics \lyricmode { \skip 2 bla2 }
646 >>
647 @end lilypond
648
649 The skip command is merely an empty musical placeholder.  It does
650 not produce any output, not even transparent output.
651
652 The @code{s} skip command does create @internalsref{Staff} and
653 @internalsref{Voice} when necessary, similar to note and rest
654 commands.  For example, the following results in an empty staff.
655
656 @lilypond[quote,verbatim]
657 { s4 }
658 @end lilypond
659 @c with ragged-right, the staff lines are cut BEFORE the time
660 @c signature, which makes for a VERY empty staff
661
662 @c The fragment @code{@{ \skip 4 @} } would produce an empty page.
663 @c Misleading -- it doesn't produce anything, not even an empty page.
664 @c Ppl who want to make empty sheets will see this and wonder what's
665 @c happening.  -eo
666
667 @seealso
668
669 Snippets: @lsrdir{Rhythms,Rhythms}
670
671 Internals Reference: @internalsref{SkipMusic}.
672
673
674 @node Full measure rests
675 @subsubsection Full measure rests
676
677 @cindex multi measure rests
678 @cindex full measure rests
679 @cindex rest, multi measure
680 @cindex rest, full measure
681 @cindex whole rest for a full measure
682 @funindex R
683
684 Rests for one or more full measures are entered using @code{R}
685 followed by a duration (see @ref{Durations}).  The duration should
686 correspond to an integral number of measures, otherwise a barcheck
687 warning is printed.  A @rglos{multi-measure rest} is used 
688 principally to indicate that a part in a multi-part score should 
689 be silent:
690
691 @lilypond[quote,fragment,verbatim,relative=2]
692 \set Score.skipBars = ##t
693 R1*4
694 R1*24
695 R1*4
696 b2^"Tutti" b4 a4
697 @end lilypond
698
699 A multi-measure rest can be expanded in the printed score
700 to show all the rest measures explicitly, or, as above, it can be 
701 condensed to a single measure
702 containing a multi-measure rest symbol, with the number of
703 measures of rest printed above the measure.  This expansion
704 is controlled by the property @code{Score.skipBars}.  If this is
705 set to true, empty measures will be condensed to a single measure.
706
707 @lilypond[quote,ragged-right,fragment,verbatim]
708 \time 4/4 r1 | R1 | R1*2 | 
709 \time 2/4 R2 | 
710 \time 4/4
711 \set Score.skipBars = ##t 
712 R1*17 | R1*4 |
713 @end lilypond
714
715 The @code{1} in @code{R1} is similar to the duration notation 
716 used for notes and is the length of a measure in 2/2 or 4/4 time.
717 The duration in a multi-measure rest must always be an integral
718 number of measure-lengths, so in other time signatures augmentation
719 dots or fractions must be used:
720
721 @lilypond[quote,ragged-right,fragment,verbatim]
722 \set Score.skipBars = ##t
723 \time 3/4
724 R2. | R2.*2
725 \time 13/8
726 R1*13/8 | R1*13/8*12 |
727 \time 10/8 
728 R4*5*4 |
729 @end lilypond
730
731 An @code{R} spanning a single measure is printed as either a whole
732 or breve rest, centered in the measure, regardless of the time
733 signature.
734
735 @cindex church rest
736 @cindex rest, church
737 @cindex kirchenpausen 
738
739 If there are 10 or fewer measures of rest, LilyPond prints
740 a series of longa and breve rests (called in German 
741 Kirchenpausen - @q{church rests}) within the staff and
742 prints a simple line otherwise.  This default number of 10
743 may be changed by overriding 
744 @code{MultiMeasureRest.expand-limit}.
745
746 @lilypond[quote,ragged-right,fragment,verbatim]
747 \set Score.skipBars = ##t
748 R1*2 | R1*5 | R1*9
749 \override MultiMeasureRest #'expand-limit = 3
750 R1*2 | R1*5 | R1*9
751 @end lilypond
752
753 Note that unlike ordinary rests, the vertical position on the
754 staff of the multi-measure rest symbol of either form cannot be
755 changed.
756
757 @cindex text on multi-measure rest
758 @cindex script on multi-measure rest
759 @cindex fermata on multi-measure rest
760
761 Text can be added to multi-measure rests by using the
762 @var{note}-@code{markup} syntax described in @ref{Text markup}.
763 The variable @code{\fermataMarkup} is provided for adding
764 fermatas.
765
766 @lilypond[quote,ragged-right,verbatim,fragment]
767 \set Score.skipBars = ##t
768 \time 3/4
769 R2.*10^\markup { \italic "ad lib." }
770 R2.^\fermataMarkup
771 @end lilypond
772
773 @warning{Text attached to a multi-measure rest is created 
774 by @code{MultiMeasureRestText}, not
775 @code{TextScript}.  Overrides must be directed to the correct
776 object, or they will be ignored.  See the following example.}
777
778 @lilypond[quote,ragged-right,verbatim,fragment]
779 \override TextScript #'padding = #5
780 R1^"low"
781 \override MultiMeasureRestText #'padding = #5
782 R1^"high"
783 @end lilypond
784
785 Text attached to a multi-measure rest will be centered above or
786 below it.  Long text attached in this way does not cause the
787 measure to expand, and may collide with text in adjacent measures.
788 Long text is better attached to a zero-length skip note preceding
789 the rest, preceded by @code{\textLengthOn} (turn off again with
790 @code{\textLengthOff}), since this will cause the measure to expand to
791 accommodate the length of the text:
792
793 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
794 \set Score.skipBars = ##t
795 \textLengthOn
796 s1*0^\markup {[MAJOR GENERAL]}
797 R1*19
798 s1*0^\markup {[MABEL] }
799 s1*0_\markup {\italic {Cue: ... it is yours}}
800 R1*30
801 \textLengthOff
802 c4^\markup {CHORUS} d f c
803 @end lilypond
804
805 @noindent
806 Text attached to a skip note in this way is left-aligned to the
807 position where the note would be placed in the bar, and placed
808 above the bar count numeral, but because the bar length is
809 determined by the length of the text, the text will appear to be
810 centered.  If two (or more) texts are
811 attached to skip notes in a bar the bar length is determined by
812 the longer text, and the shorter text is then clearly
813 left-aligned, as shown in the second bar above.  If the shorter
814 text of two marks is short enough to fit it will be placed
815 alongside and to the left of the bar count numeral.
816
817 @seealso
818
819 Notation Reference: @ref{Durations}, @ref{Text},
820 @ref{Text markup}, @ref{Text scripts}.
821
822 Snippets: @lsrdir{Rhythms,Rhythms}
823
824 Internals Reference: @internalsref{MultiMeasureRest}.
825
826 The layout object @internalsref{MultiMeasureRestNumber} is for the
827 default number, and @internalsref{MultiMeasureRestText} for user
828 specified texts.
829
830
831 @knownissues
832
833 If an attempt is made to use fingerings (e.g., 
834 @code{R1*10-4}) to put numbers over multi-measure rests, the
835 fingering numeral (4) may collide with the bar counter 
836 numeral (10).  
837
838 @cindex condensing rests
839
840 There is no way to automatically condense multiple rests into a
841 single multi-measure rest.  Multi-measure rests do not take part
842 in rest collisions.
843
844 Be careful when entering multi-measure rests followed by whole
845 notes.  The following will enter two notes lasting four measures
846 each:
847
848 @example
849 R1*4 cis cis
850 @end example
851
852
853 @node Displaying rhythms
854 @subsection Displaying rhythms
855
856 @menu
857 * Time signature::              
858 * Upbeats::                     
859 * Unmetered music::             
860 * Polymetric notation::         
861 * Automatic note splitting::    
862 @end menu
863
864 @node Time signature
865 @subsubsection Time signature
866
867 @cindex time signature
868 @cindex meter
869 @funindex \time
870
871 The time signature is set with the @code{\time} command:
872
873 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
874 \time 2/4 c2 \time 3/4 c2.
875 @end lilypond
876
877 @snippets
878
879 The symbol that is printed can be customized with the @code{style}
880 property.  Setting it to @code{#'()} uses fraction style for 4/4
881 and 2/2 time,
882
883 @lilypond[fragment,quote,ragged-right,verbatim,relative=2]
884 \time 4/4 c1
885 \time 2/2 c1
886 \override Staff.TimeSignature #'style = #'()
887 \time 4/4 c1
888 \time 2/2 c1
889 @end lilypond
890
891 A time signature symbol is normally printed whenever the time
892 signature changes.  If this takes place at the end of a line a
893 warning time signature sign is printed at the end of the line and
894 again at the start of a new line.  This default behaviour can be
895 modified by setting the value of the @code{break-visibility}
896 property.  This takes three values which may be set to @code{#t}
897 or @code{#f} to specify whether the corresponding time signature
898 is visible or not.  The order of the three values is @code{end of
899 line visible}, @code{middle of line visible}, @code{beginning of
900 line visible}.
901
902 @lilypond[fragment,quote,ragged-right,verbatim,relative=2]
903 % Do not print any time signatures at end of line
904 \override Staff.TimeSignature #'break-visibility = ##(#f #t #t)
905 \time 4/4 c1
906 \time 3/4 c2.
907 % Do not print the following 9/8 time signature
908 \once \override Staff.TimeSignature #'break-visibility = ##(#t #f #t)
909 \time 9/8 c4. c c
910 \time 2/2 c1
911 \break
912 \time 9/8 c4. c c
913 \time 12/8 c2. c2.
914 @end lilypond
915
916 There are many more options for its layout.  See @ref{Ancient time
917 signatures}, for more examples.
918
919 @code{\time} sets the properties @code{timeSignatureFraction},
920 @code{beatLength}, and @code{measureLength} in the @code{Timing}
921 context, which is normally aliased to @internalsref{Score}.  The
922 property @code{measureLength} determines where bar lines should be
923 inserted, and how automatic beams should be generated.  Changing
924 the value of @code{timeSignatureFraction} also causes the symbol
925 to be printed.
926
927 @cindex measure groupings
928  
929 More options are available through the Scheme function
930 @code{set-time-signature}, which takes three arguments: the number
931 of beats, the beat length, and the internal grouping of beats in
932 the measure.  If the @internalsref{Measure_grouping_engraver} is
933 included, the function will also create
934 @internalsref{MeasureGrouping} signs.  Such signs ease reading
935 rhythmically complex modern music.  In the following example, the
936 9/8 measure is subdivided in 2, 2, 2 and 3.  This is passed to
937 @code{set-time-signature} as the third argument @code{(2 2 2 3)}:
938
939 @lilypond[quote,ragged-right,verbatim]
940 \score {
941   \relative c'' {
942     #(set-time-signature 9 8 '(2 2 2 3))
943     g8[ g] d[ d] g[ g] a8[( bes g]) |
944     #(set-time-signature 5 8 '(3 2))
945     a4. g4
946   }
947   \layout {
948     \context {
949       \Staff
950       \consists "Measure_grouping_engraver"
951     }
952   }
953 }
954 @end lilypond
955
956
957 @seealso
958
959 Snippets: @lsrdir{Rhythms,Rhythms}
960
961 Internals Reference: @internalsref{TimeSignature}, and
962 @internalsref{Timing_translator}.
963
964 Examples: @c @lsr{contemporary,compound-time-signature.ly}.
965
966
967 @knownissues
968
969 Automatic beaming does not use the measure grouping specified with
970 @code{set-time-signature}.
971
972
973 @node Upbeats
974 @subsubsection Upbeats
975
976 @cindex anacrusis
977 @cindex upbeat
978 @cindex partial measure
979 @cindex measure, partial
980 @cindex pickup measure
981 @cindex shorten measures
982 @funindex \partial
983
984 Partial or pickup measures, such as an anacrusis or upbeat, are
985 entered using the @code{\partial} command, with the syntax
986
987 @example
988 \partial @var{duration}
989 @end example
990
991 where @code{duration} is the rhythmic length to be added before
992 the next measure:
993
994 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
995 \partial 16*5 c16 cis d dis e | a2. c,4 | b2
996 @end lilypond
997
998 Internally, this is translated into
999
1000 @example
1001 \set Timing.measurePosition = -@var{length of duration}
1002 @end example
1003
1004 The property @code{measurePosition} contains a rational number
1005 indicating how much of the measure has passed at this point.  Note
1006 that this is a negative number; @code{\partial 4} is internally
1007 translated to mean @qq{there is a quarter note left in the bar.}
1008
1009
1010 @knownissues
1011
1012 This command does not take into account grace notes at the start
1013 of the music.  When a piece starts with grace notes in the
1014 pickup, then the @code{\partial} should follow the grace notes:
1015
1016 @lilypond[verbatim,quote,ragged-right,relative,fragment]
1017 \grace f16
1018 \partial 4
1019 g4
1020 a2 g2
1021 @end lilypond
1022
1023 @code{\partial} is only intended to be used at the beginning of a
1024 piece.  If you use it after the beginning, some odd warnings may
1025 occur.
1026
1027 @seealso
1028
1029 Snippets: @lsrdir{Rhythms,Rhythms}
1030
1031 @node Unmetered music
1032 @subsubsection Unmetered music
1033
1034 @cindex cadenza
1035 @funindex \cadenzaOn
1036 @funindex \cadenzaOff
1037
1038 Bar lines and bar numbers are calculated automatically.  For
1039 unmetered music (cadenzas, for example), this is not desirable.
1040 To turn off automatic bar lines and bar numbers, use the commands
1041 @code{\cadenzaOn} and @code{\cadenzaOff}.
1042
1043 @lilypond[verbatim,quote,ragged-right,relative=2,fragment]
1044 c4 d e d
1045 \cadenzaOn
1046 c4 c d8 d d f4 g4.
1047 \cadenzaOff
1048 \bar "|"
1049 d4 e d c
1050 @end lilypond
1051
1052 Bar numbering is resumed at the end of the cadenza as if the
1053 cadenza were not there:
1054
1055 @lilypond[verbatim,quote,ragged-right,relative=2,fragment]
1056 \override Score.BarNumber #'break-visibility = ##( #t #t #t )
1057 c4 d e d
1058 \cadenzaOn
1059 c4 c d8 d d f4 g4.
1060 \cadenzaOff
1061 \bar "|"
1062 d4 e d c
1063 @end lilypond
1064
1065 @knownissues
1066
1067 LilyPond will only insert line breaks and page breaks at a
1068 bar line.  Unless the unmetered music ends before the end of the
1069 staff line, you will need to insert invisible bar lines with
1070
1071 @example
1072 \bar ""
1073 @end example
1074
1075 @noindent
1076 to indicate where breaks can occur.
1077
1078 @seealso
1079
1080 Snippets: @lsrdir{Rhythms,Rhythms}
1081
1082
1083 @node Polymetric notation
1084 @subsubsection Polymetric notation
1085
1086 @c TODO Work this example into the main text
1087 @c @lilypondfile [verbatim,lilyquote,ragged-right,texidoc]
1088 @c {printing-music-with-different-time-signatures.ly}
1089
1090 @cindex double time signatures
1091 @cindex signatures, polymetric
1092 @cindex polymetric signatures
1093 @cindex meter, polymetric
1094
1095 Music Glossary:
1096 @rglos{polymetric}
1097 @rglos{polymetric time signature}
1098 @rglos{meter}
1099
1100 Double time signatures are not supported explicitly, but they can
1101 be faked.  In the next example, the markup for the time signature
1102 is created with a markup text.  This markup text is inserted in
1103 the @internalsref{TimeSignature} grob.  See also
1104 @c @lsr{contemporary,compound-time-signature}.
1105
1106 @lilypond[verbatim,ragged-right]
1107 % create 2/4 + 5/8
1108 tsMarkup = \markup {
1109   \override #'(baseline-skip . 2) \number {
1110     \column { "2" "4" }
1111     \vcenter "+"
1112     \bracket \column { "5" "8" }
1113   }
1114 }
1115
1116 {
1117   \override Staff.TimeSignature #'stencil =
1118     #ly:text-interface::print
1119   \override Staff.TimeSignature #'text = #tsMarkup
1120   \time 3/2
1121   c'2 \bar ":" c'4 c'4.
1122 }
1123 @end lilypond
1124
1125 Each staff can also have its own time signature.  This is done by
1126 moving the @internalsref{Timing_translator} to the
1127 @internalsref{Staff} context.
1128
1129 @lilypond[quote,verbatim,ragged-right]
1130 \layout {
1131   \context {
1132     \Score
1133     \remove "Timing_translator"
1134     \remove "Default_bar_line_engraver"
1135   }
1136   \context {
1137     \Staff
1138     \consists "Timing_translator"
1139     \consists "Default_bar_line_engraver"
1140   }
1141 }
1142 %Now, each staff has its own time signature.
1143
1144 \relative c' <<
1145   \new Staff {
1146     \time 3/4
1147     c4 c c | c c c |
1148   }
1149   \new Staff {
1150     \time 2/4
1151     c4 c | c c | c c
1152   }
1153   \new Staff {
1154     \time 3/8
1155     c4. c8 c c c4. c8 c c
1156   }
1157 >>
1158 @end lilypond
1159
1160
1161 A different form of polymetric notation is where note lengths have
1162 different values across staves, but the measures are all the same 
1163 length.
1164
1165 This notation can be created by setting a common time signature
1166 for each staff but replacing it manually using
1167 @code{timeSignatureFraction} to the desired fraction.  Then the
1168 printed durations in each staff are scaled to the common time
1169 signature.  The latter is done with @code{\compressMusic}, which
1170 is used in a similar way to @code{\times}, but does not create 
1171 a tuplet bracket.  The syntax is 
1172
1173 @funindex \compressMusic
1174
1175 @example 
1176 \compressMusic 
1177 #'(@var{numerator} . @var{denominator}) @var{musicexpr} 
1178 @end example
1179
1180
1181
1182 In this example, music with the time signatures of 3/4, 9/8, and
1183 10/8 are used in parallel.  In the second staff, shown durations
1184 are multiplied by 2/3, so that 2/3 * 9/8 = 3/4, and in the third
1185 staff, shown durations are multiplied by 3/5, so that 3/5 * 10/8 =
1186 3/4.
1187
1188 @lilypond[quote,ragged-right,verbatim,fragment]
1189 \relative c' { <<
1190   \new Staff {
1191     \time 3/4
1192     c4 c c | c c c |
1193   }
1194   \new Staff {
1195     \time 3/4
1196     \set Staff.timeSignatureFraction = #'(9 . 8)
1197     \compressMusic #'(2 . 3)
1198       \repeat unfold 6 { c8[ c c] }
1199   }
1200   \new Staff {
1201     \time 3/4
1202     \set Staff.timeSignatureFraction = #'(10 . 8)
1203     \compressMusic #'(3 . 5) {
1204       \repeat unfold 2 { c8[ c c] }
1205       \repeat unfold 2 { c8[ c] }
1206       | c4. c4. \times 2/3 { c8 c c } c4
1207     }
1208   }
1209 >> }
1210 @end lilypond
1211
1212
1213 @knownissues
1214
1215 When using different time signatures in parallel, the spacing is
1216 aligned vertically, but bar lines distort the regular spacing.
1217
1218 @seealso
1219
1220 Snippets: @lsrdir{Rhythms,Rhythms}, @c @lsr{contemporary,compound-time-signature}.
1221
1222 Internals Reference: @internalsref{TimeSignature}, @internalsref{Timing-translator}, @internalsref{Staff}.
1223
1224
1225 @node Automatic note splitting
1226 @subsubsection Automatic note splitting
1227
1228 Long notes which overrun bar lines can be converted automatically
1229 to tied notes.  This is done by replacing the
1230 @internalsref{Note_heads_engraver} by the
1231 @internalsref{Completion_heads_engraver}.  In the following
1232 examples, notes crossing the bar line are split and tied.
1233
1234 @lilypond[quote,fragment,verbatim,relative=1,line-width=12\cm]
1235 \new Voice \with {
1236   \remove "Note_heads_engraver"
1237   \consists "Completion_heads_engraver"
1238 } {
1239   c2. c8 d4 e f g a b c8 c2 b4 a g16 f4 e d c8. c2
1240 }
1241 @end lilypond
1242
1243 This engraver splits all running notes at the bar line, and
1244 inserts ties.  One of its uses is to debug complex scores: if the
1245 measures are not entirely filled, then the ties exactly show how
1246 much each measure is off.
1247
1248 If you want to allow line breaking on the bar lines where
1249 @internalsref{Completion_heads_engraver} splits notes, you must
1250 also remove @internalsref{Forbid_line_break_engraver}.
1251
1252
1253 @knownissues
1254
1255 Not all durations (especially those containing tuplets) can be
1256 represented exactly with normal notes and dots, but the engraver
1257 will not insert tuplets.
1258
1259 @code{Completion_heads_engraver} only affects notes; it does not
1260 split rests.
1261
1262
1263 @seealso
1264
1265 Snippets: @lsrdir{Rhythms,Rhythms}
1266
1267 Internals Reference: @internalsref{Note_heads_engraver},
1268 @internalsref{Completion_heads_engraver},
1269 @internalsref{Forbid_line_break_engraver}.
1270
1271
1272
1273
1274
1275 @node Beams
1276 @subsection Beams
1277
1278 @menu
1279 * Automatic beams::             
1280 * Setting automatic beam behavior::  
1281 * Manual beams::                
1282 * Feathered beams::             
1283 @end menu
1284
1285 @node Automatic beams
1286 @subsubsection Automatic beams
1287
1288 By default, beams are inserted automatically:
1289
1290 @cindex beams, manual
1291 @cindex manual beams
1292
1293 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
1294 \time 2/4 c8 c c c
1295 \time 6/8 c c c c8. c16 c8
1296 @end lilypond
1297
1298 If these automatic decisions are not satisfactory, beaming can be
1299 entered explicitly; see @ref{Manual beams}.  It is also possible
1300 to define beaming patterns that differ from the defaults; see
1301 @ref{Setting automatic beam behavior}.  The default beaming rules
1302 are defined in @file{scm/@/auto@/-beam@/.scm}.
1303
1304 @cindex autoBeamOn
1305 @cindex autoBeamOff
1306
1307 @noindent
1308 Automatic beaming may be turned off and on with
1309 @code{\autoBeamOff} and @code{\autoBeamOn} commands:
1310
1311 @lilypond[quote,ragged-right,fragment,relative=1,verbatim]
1312 c4 c8 c8. c16 c8. c16 c8
1313 \autoBeamOff
1314 c4 c8 c8. c16 c8.
1315 \autoBeamOn
1316 c16 c8
1317 @end lilypond
1318
1319
1320 @snippets
1321
1322 Beaming patterns may be altered with the @code{beatGrouping} property,
1323
1324 @lilypond[quote,verbatim,relative=2,fragment,ragged-right]
1325 \time 5/16
1326 \set beatGrouping = #'(2 3)
1327 c8[^"(2+3)" c16 c8]
1328 \set beatGrouping = #'(3 2)
1329 c8[^"(3+2)" c16 c8]
1330 @end lilypond
1331
1332 The beams of consecutive 16th (or shorter) notes are, by default,
1333 not sub-divided.  That is, the three (or more) beams stretch
1334 unbroken over entire groups of notes.  This behaviour can
1335 be modified to sub-divide the beams into sub-groups by setting 
1336 the property @code{subdivideBeams}.  When set, multiple beams 
1337 will be sub-divided at intervals defined by the current value of
1338 @code{beatLength} by reducing the multiple beams to just one beam
1339 between the sub-groups. Note that @code{beatLength} lives in the
1340 @code{Score} context and defaults to a quarter note.  It must be
1341 set to a fraction giving the duration of the beam sub-group
1342 using the @code{make-moment} function, as shown here:
1343
1344 @lilypond[fragment,ragged-right,quote,relative=2,verbatim]
1345 c32[ c c c c c c c]
1346 \set subdivideBeams = ##t
1347 c32[ c c c c c c c]
1348 % Set beam sub-group length to an eighth note
1349 \set Score.beatLength = #(ly:make-moment 1 8)
1350 c32[ c c c c c c c]
1351 % Set beam sub-group length to a sixteenth note
1352 \set Score.beatLength = #(ly:make-moment 1 16)
1353 c32[ c c c c c c c]
1354 @end lilypond
1355 @funindex subdivideBeams
1356
1357 @noindent
1358 For more information about @code{make-moment}, see
1359 @ref{Time administration}.
1360
1361 @funindex breakable
1362 @cindex break, line
1363 @cindex line breaks
1364
1365 Line breaks are normally forbidden when beams cross bar lines.
1366 This behavior can be changed by setting the @code{breakable} 
1367 property: @code{\override Beam #'breakable = ##t}.
1368
1369 @lilypond[ragged-right,relative=2,fragment,verbatim,quote]
1370 \override Beam #'breakable = ##t
1371 c8 \repeat unfold 15 {c[ c] } c
1372 @end lilypond
1373
1374 @cindex beams and line breaks
1375 @cindex beams, kneed
1376 @cindex kneed beams
1377 @cindex auto-knee-gap
1378
1379 Kneed beams are inserted automatically when a large gap is
1380 detected between the note heads.  This behavior can be tuned
1381 through the @code{auto-knee-gap} property.  A kneed beam is
1382 drawn if the gap is larger than the value of 
1383 @code{auto-knee-gap} plus the width of the beam object (which
1384 depends on the duration of the notes and the slope of the beam).
1385 By default @code{auto-knee-gap} is set to 5.5 staff spaces.
1386
1387 @lilypond[fragment,ragged-right,quote,verbatim]
1388 f8 f''8 f8 f''8
1389 \override Beam #'auto-knee-gap = #6
1390 f8 f''8 f8 f''8
1391 @end lilypond
1392
1393
1394 @seealso
1395
1396 Notation Reference: @ref{Manual beams}, @ref{Setting automatic beam behavior}.
1397
1398 Snippets: @lsrdir{Rhythms,Rhythms}
1399
1400 Internals Reference: @internalsref{Beam}.
1401
1402
1403 @knownissues
1404
1405 Automatically kneed cross-staff beams cannot be used together with
1406 hidden staves.  See @ref{Hiding staves}.
1407
1408 Beams can collide with note heads and accidentals in other voices
1409
1410
1411 @node Setting automatic beam behavior
1412 @subsubsection Setting automatic beam behavior
1413
1414 @funindex autoBeamSettings
1415 @funindex (end * * * *)
1416 @funindex (begin * * * *)
1417 @cindex automatic beams, tuning
1418 @cindex tuning automatic beaming
1419
1420 @c [TODO: use \applyContext]
1421
1422 In normal time signatures, automatic beams can start on any note
1423 but can end in only a few positions within the measure: beams can
1424 end on a beat, or at durations specified by the properties in
1425 @code{autoBeamSettings}.  The properties in
1426 @code{autoBeamSettings} consist of a list of rules for where beams
1427 can begin and end.  The default @code{autoBeamSettings} rules are
1428 defined in @file{scm/@/auto@/-beam@/.scm}.
1429
1430 In order to add a rule to the list, use
1431 @example
1432 #(override-auto-beam-setting '(be p q n m) a b [context])
1433 @end example
1434
1435 @itemize
1436
1437 @item @code{be} is either @code{begin} or @code{end}.
1438
1439 @item @code{p/q} is the duration of the note for which you want
1440 to add a rule.  A beam is considered to have the duration of its
1441 shortest note.  Set @code{p} and @code{q} to @code{'*'} to
1442 have this apply to any beam.
1443
1444 @item @code{n/m} is the time signature to which
1445 this rule should apply.  Set @code{n} and @code{m} to @code{'*'}
1446 to have this apply in any time signature.
1447
1448 @item @code{a/b} is the position in the bar at which the beam should
1449 begin/end.
1450
1451 @item @code{context} is optional, and it specifies the context at which
1452 the change should be made.  The default is @code{'Voice}.
1453
1454 @code{#(score-override-auto-beam-setting '(A B C D) E F)} is equivalent to
1455 @code{#(override-auto-beam-setting '(A B C D) E F 'Score)}.
1456
1457 @end itemize
1458
1459 For example, if automatic beams should always end on the first quarter
1460 note, use
1461
1462 @example
1463 #(override-auto-beam-setting '(end * * * *) 1 4)
1464 @end example
1465
1466 You can force the beam settings to only take effect on beams whose shortest
1467 note is a certain duration
1468
1469 @lilypond[quote,fragment,ragged-right,verbatim,relative=2]
1470 \time 2/4
1471 #(override-auto-beam-setting '(end 1 16 * *) 1 16)
1472 a16 a a a a a a a |
1473 a32 a a a a16 a a a a a |
1474 #(override-auto-beam-setting '(end 1 32 * *) 1 16)
1475 a32 a a a a16 a a a a a |
1476 @end lilypond
1477
1478 You can force the beam settings to only take effect in certain time
1479 signatures
1480
1481 @lilypond[quote,fragment,ragged-right,verbatim,relative=2]
1482 \time 5/8
1483 #(override-auto-beam-setting '(end * * 5 8) 2 8)
1484 c8 c d d d
1485 \time 4/4
1486 e8 e f f e e d d
1487 \time 5/8
1488 c8 c d d d
1489 @end lilypond
1490
1491 You can also remove a previously set beam-ending rule by using
1492
1493 @example
1494 #(revert-auto-beam-setting '(be p q n m) a b [context])
1495 @end example
1496
1497 @noindent
1498 be, p, q, n, m, a, b and context are the same as above.  Note that the
1499 default rules are specified in @file{scm/@/auto@/-beam@/.scm},
1500 so you can revert rules that you did not explicitly create.
1501
1502 @lilypond[quote,fragment,ragged-right,verbatim,relative=2]
1503 \time 4/4
1504 a16 a a a a a a a a a a a a a a a
1505 #(revert-auto-beam-setting '(end 1 16 4 4) 1 4)
1506 a16 a a a a a a a a a a a a a a a
1507 @end lilypond
1508
1509 The rule in a revert-auto-beam-setting statement must exactly match the
1510 original rule.  That is, no wildcard expansion is taken into account.
1511
1512 @lilypond[quote,fragment,ragged-right,verbatim,relative=2]
1513 \time 1/4
1514 #(override-auto-beam-setting '(end 1 16 1 4) 1 8)
1515 a16 a a a
1516 #(revert-auto-beam-setting '(end 1 16 * *) 1 8) % this won't revert it!
1517 a a a a
1518 #(revert-auto-beam-setting '(end 1 16 1 4) 1 8) % this will
1519 a a a a
1520 @end lilypond
1521
1522
1523
1524 @c TODO:  old material -- not covered by above stuff, I think.
1525 If automatic beams should end on every quarter in 5/4 time, specify
1526 all endings
1527 @example
1528 #(override-auto-beam-setting '(end * * * *) 1 4 'Staff)
1529 #(override-auto-beam-setting '(end * * * *) 1 2 'Staff)
1530 #(override-auto-beam-setting '(end * * * *) 3 4 'Staff)
1531 #(override-auto-beam-setting '(end * * * *) 5 4 'Staff)
1532 @dots{}
1533 @end example
1534
1535 The same syntax can be used to specify beam starting points.  In this
1536 example, automatic beams can only end on a dotted quarter note
1537 @example
1538 #(override-auto-beam-setting '(end * * * *) 3 8)
1539 #(override-auto-beam-setting '(end * * * *) 1 2)
1540 #(override-auto-beam-setting '(end * * * *) 7 8)
1541 @end example
1542 In 4/4 time signature, this means that automatic beams could end only on
1543 3/8 and on the fourth beat of the measure (after 3/4, that is 2 times
1544 3/8, has passed within the measure).
1545
1546 If any unexpected beam behaviour occurs, check the default automatic beam
1547 settings in @file{scm/@/auto@/-beam@/.scm}
1548 for possible interference, because the beam
1549 endings defined there will still apply on top of your own overrides.  Any
1550 unwanted endings in the default vales must be reverted for your time
1551 signature(s).
1552
1553 For example, to typeset @code{(3 4 3 2)}-beam endings in 12/8, begin
1554 with
1555
1556 @example
1557 %%% revert default values in scm/auto-beam.scm regarding 12/8 time
1558 #(revert-auto-beam-setting '(end * * 12 8) 3 8)
1559 #(revert-auto-beam-setting '(end * * 12 8) 3 4)
1560 #(revert-auto-beam-setting '(end * * 12 8) 9 8)
1561
1562 %%% your new values
1563 #(override-auto-beam-setting '(end 1 8 12 8) 3 8)
1564 #(override-auto-beam-setting '(end 1 8 12 8) 7 8)
1565 #(override-auto-beam-setting '(end 1 8 12 8) 10 8)
1566 @end example
1567
1568 @cindex automatic beam generation
1569 @cindex autobeam
1570 @funindex autoBeaming
1571 @cindex lyrics
1572
1573 If beams are used to indicate melismata in songs, then automatic
1574 beaming should be switched off with @code{\autoBeamOff}.
1575
1576
1577 @predefined
1578
1579 @funindex \autoBeamOff
1580 @code{\autoBeamOff},
1581 @funindex \autoBeamOn
1582 @code{\autoBeamOn}.
1583
1584
1585 @knownissues
1586
1587 If a score ends while an automatic beam has not been ended and is
1588 still accepting notes, this last beam will not be typeset at all.
1589 The same holds for polyphonic voices, entered with @code{<<
1590 @dots{} \\ @dots{} >>}.  If a polyphonic voice ends while an
1591 automatic beam is still accepting notes, it is not typeset.
1592
1593 @seealso
1594
1595 Snippets: @lsrdir{Rhythms,Rhythms}
1596
1597
1598 @node Manual beams
1599 @subsubsection Manual beams
1600
1601 @cindex beams, manual
1602
1603 In some cases it may be necessary to override the automatic
1604 beaming algorithm.  For example, the autobeamer will not put beams
1605 over rests or bar lines, and in choral scores the beaming is
1606 often set to follow the meter of the lyrics rather than the
1607 notes. Such beams can be specified manually by
1608 marking the begin and end point with @code{[} and @code{]}
1609
1610 @lilypond[quote,ragged-right,fragment,relative=1,verbatim]
1611 {
1612   r4 r8[ g' a r8] r8 g[ | a] r8
1613 }
1614 @end lilypond
1615
1616
1617 Individual notes may be marked with @code{\noBeam} to prevent them
1618 from being beamed:
1619
1620 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
1621 \time 2/4 c8 c\noBeam c c
1622 @end lilypond
1623
1624 @funindex ]
1625 @funindex [
1626
1627 @funindex stemLeftBeamCount
1628 @funindex stemRightBeamCount
1629
1630 Even more strict manual control with the beams can be achieved by
1631 setting the properties @code{stemLeftBeamCount} and
1632 @code{stemRightBeamCount}.  They specify the number of beams to
1633 draw on the left and right side, respectively, of the next note.
1634 If either property is set, its value will be used only once, and
1635 then it is erased.  In this example, the last @code{f} is printed
1636 with only one beam on the left side, i.e. the eigth-note beam of
1637 the group as a whole.
1638
1639 @lilypond[quote,ragged-right,fragment,relative=1,verbatim]
1640 {
1641   f8[ r16 f g a]
1642   f8[ r16
1643   \set stemLeftBeamCount = #1
1644   f g a]
1645 }
1646 @end lilypond
1647
1648
1649 @snippets
1650
1651 @node Feathered beams
1652 @subsubsection Feathered beams
1653
1654 @cindex beams, feathered
1655 @funindex \featherDurations 
1656
1657 Feathered beams are used to indicate that a small group of notes
1658 should be played at an increasing (or decreasing) tempo, without
1659 changing the overall tempo of the piece.  The extent of the 
1660 feathered beam must be indicated manually using @code{[} and
1661 @code{]}, and the beam feathering is turned on by specifying a 
1662 direction to the Beam property @code{grow-direction}.
1663
1664 If the placement of the notes and the sound in the MIDI output
1665 is to reflect the ritardando or accelerando indicated by the
1666 feathered beam the notes must be grouped as a
1667 music expression delimited by braces and preceded by a
1668 @code{featheredDurations} command which specifies the ratio
1669 between the durations of the first and last notes in the group.
1670
1671 The square brackets
1672 show the extent of the beam and the braces show
1673 which notes are to have their durations modified.  Normally 
1674 these would delimit the same group of notes, but this is not
1675 required: the two commands are independent. 
1676
1677 In the following example the eight 16th notes occupy exactly the
1678 same time as a half note, but the first note is one half as long
1679 as the last one, with the intermediate notes gradually
1680 lengthening.  The first four 32nd notes gradually speed up, while
1681 the last four 32nd notes are at a constant tempo.
1682
1683 @lilypond[ragged-right,relative=1,fragment,verbatim,quote]
1684 \override Beam #'grow-direction = #LEFT
1685 \featherDurations #(ly:make-moment 2 1)
1686 { c16[ c c c c c c c] }
1687 \override Beam #'grow-direction = #RIGHT
1688 \featherDurations #(ly:make-moment 2 3)
1689 { c32[ d e f] }
1690 % revert to non-feathered beams
1691 \override Beam #'grow-direction = #'()
1692 { g32[ a b c] }
1693 @end lilypond
1694
1695 @noindent
1696 The spacing in the printed output represents the 
1697 note durations only approximately, but the midi output is exact.
1698
1699 @knownissues
1700
1701 The @code{\featherDurations} command only works with very short
1702 music snippets, and when numbers in the fraction are small.
1703
1704 @seealso
1705
1706 Snippets: @lsrdir{Rhythms,Rhythms}
1707
1708
1709
1710 @node Bars
1711 @subsection Bars
1712
1713
1714 @menu
1715 * Bar lines::                   
1716 * Bar numbers::                 
1717 * Bar and bar number checks::   
1718 * Rehearsal marks::             
1719 @end menu
1720
1721 @node Bar lines
1722 @subsubsection Bar lines
1723
1724 @cindex bar lines
1725 @funindex \bar
1726 @cindex measure lines
1727 @cindex repeat bars
1728
1729 Bar lines delimit measures, and are also used to indicate
1730 repeats.  Normally, simple bar lines are automatically inserted
1731 into the printed output at places based on the current time 
1732 signature.  
1733
1734 The simple bar lines inserted automatically can be changed to 
1735 other types with the @code{\bar} command.  For example, a closing
1736 double bar line is usually placed at the end of a piece:
1737
1738 @lilypond[quote,ragged-right,relative=1,fragment,verbatim]
1739 e4 d c2 \bar "|."
1740 @end lilypond
1741
1742 @warning{An incorrect duration can lead to poorly formatted
1743 music.}
1744  
1745 It is not invalid if the final note in a bar does not 
1746 end on the automatically entered bar line: the note is assumed 
1747 to carry over into the next bar.  But if a long sequence
1748 of such carry-over bars appears the music can appear compressed
1749 or even flowing off the page.  This is because automatic line
1750 breaks happen only at the end of complete bars, i.e. where 
1751 the end of a note coincides with the end of a bar.
1752
1753 @cindex line breaks
1754 @cindex bar lines, invisible
1755 @cindex measure lines, invisible
1756
1757 Line breaks are also permitted at manually inserted bar lines
1758 even within incomplete bars.  To allow a line break without 
1759 printing a bar line, use
1760
1761 @example
1762 \bar ""
1763 @end example
1764
1765 @noindent
1766 This will insert an invisible bar line and allow (but not
1767 force) a line break to occur at this point.  The bar number 
1768 counter is not increased.  To force a line break see 
1769 @ref{Line breaking}.
1770
1771 This and other special bar lines may be inserted manually at any
1772 point.  When they coincide with the end of a bar they replace
1773 the simple bar line which would have been inserted there 
1774 automatically.  When they do not coincide
1775 with the end of a bar the specified bar line is inserted at that
1776 point in the printed output.  Such insertions do not affect
1777 the calculation and placement of subsequent automatic bar lines.  
1778
1779 The simple bar line and four types of double bar line are available
1780 for manual insertion:
1781
1782 @lilypond[quote,ragged-right,fragment,relative=1,verbatim]
1783 f1 \bar "|" g \bar "||" a \bar ".|" b \bar ".|." c \bar "|." d
1784 @end lilypond
1785
1786 @noindent
1787 together with dotted and dashed bar lines:
1788
1789 @lilypond[quote,ragged-right,fragment,relative=1,verbatim]
1790 f1 \bar ":" g \bar "dashed" a
1791 @end lilypond
1792
1793 @noindent
1794 and three types of repeat bar line:
1795
1796 @lilypond[quote,ragged-right,fragment,relative=1,verbatim]
1797 f1 \bar "|:" g \bar ":|:" a \bar ":|" b
1798 @end lilypond
1799
1800 @cindex repeats
1801
1802 Although the bar line types signifying repeats may be inserted
1803 manually they do not in themselves cause LilyPond to recognise
1804 a repeated section.  Such repeated sections are better entered
1805 using the various repeat commands (see @ref{Repeats}), which
1806 automatically print the appropriate bar lines.
1807
1808 In addition, you can specify @code{"||:"}, which is equivalent to
1809 @code{"|:"} except at line breaks, where it gives a double bar
1810 line at the end of the line and a start repeat at the beginning of
1811 the next line. 
1812
1813 @lilypond[quote,ragged-right,relative=2,fragment,verbatim]
1814 \override Score.RehearsalMark #'padding = #3
1815 c c c c
1816 \bar "||:" 
1817 c c c c \break
1818 \bar "||:" 
1819 c c c c
1820 @end lilypond
1821
1822 In scores with many staves, a @code{\bar} command in one staff is
1823 automatically applied to all staves.  The resulting bar lines are
1824 connected between different staves of a @code{StaffGroup},
1825 @code{PianoStaff}, or @code{GrandStaff}.
1826
1827 @lilypond[quote,ragged-right,fragment,verbatim]
1828 <<
1829   \new StaffGroup <<
1830     \new Staff {
1831       e'4 d'
1832       \bar "||"
1833       f' e'
1834     }
1835     \new Staff { \clef bass c4 g e g }
1836   >>
1837   \new Staff { \clef bass c2 c2 }
1838 >>
1839 @end lilypond
1840
1841
1842 @snippets
1843
1844 @funindex whichBar
1845 @funindex defaultBarType
1846
1847 The command @code{\bar }@var{bartype} is a shortcut for
1848 @code{\set Timing.whichBar = }@var{bartype}.  A bar line is 
1849 created whenever the @code{whichBar} property is
1850 set.  
1851
1852 The default bar type used for automatically inserted bar lines is
1853 @code{"|"}.  This may be changed at any time
1854 with @code{\set Timing.defaultBarType = }@var{bartype}.  
1855
1856 @seealso
1857
1858 Notation Reference: @ref{Line breaking}, @ref{Repeats},
1859 @c FIXME: node name changed, but is subject to further changes.
1860 @c @ref{System start delimiters}.
1861
1862 Snippets: @lsrdir{Rhythms,Rhythms}
1863
1864 Internals Reference: @internalsref{BarLine} (created at
1865 @internalsref{Staff} level), @internalsref{SpanBar} (across
1866 staves), @internalsref{Timing_translator} (for Timing 
1867 properties).
1868
1869
1870 @node Bar numbers
1871 @subsubsection Bar numbers
1872
1873 @cindex bar numbers
1874 @cindex measure numbers
1875 @funindex currentBarNumber
1876
1877 Bar numbers are typeset by default at the start of every line except
1878 the first line.  The number itself is stored in the
1879 @code{currentBarNumber} property, which is normally updated
1880 automatically for every measure.  It may also be set manually:
1881
1882 @lilypond[verbatim,ragged-right,quote,fragment,relative]
1883 c1 c c c
1884 \break
1885 \set Score.currentBarNumber = #50
1886 c1 c c c
1887 @end lilypond
1888
1889
1890 @snippets
1891
1892 @funindex barNumberVisibility
1893 @cindex bar numbers, regular spacing
1894
1895 Bar numbers can be typeset at regular intervals instead of just at
1896 the beginning of every line.  To do this the default behaviour
1897 must be overridden to permit bar numbers to be printed at places
1898 other than the start of a line.  This is controlled by the
1899 @code{break-visibility} property of @code{BarNumber}.  This takes
1900 three values which may be set to @code{#t} or @code{#f} to specify
1901 whether the corresponding bar number is visible or not.  The order
1902 of the three values is @code{end of line visible}, @code{middle of
1903 line visible}, @code{beginning of line visible}.  In the following
1904 example bar numbers are printed at all possible places:
1905
1906 @lilypond[verbatim,ragged-right,quote,fragment,relative]
1907 \override Score.BarNumber #'break-visibility = ##(#t #t #t)
1908 \set Score.currentBarNumber = #11
1909 \bar ""  % Permit first bar number to be printed
1910 c1 c c c
1911 \break
1912 c c c c
1913 @end lilypond
1914
1915 @c  All the rest of these examples will be added to LSR
1916 @c  and moved into the Snippets.  -gp
1917
1918 @noindent
1919 and here the bar numbers are printed every two bars
1920 except at the end of the line:
1921
1922 @lilypond[verbatim,ragged-right,quote,fragment,relative]
1923 \override Score.BarNumber #'break-visibility = ##(#f #t #t)
1924 \set Score.currentBarNumber = #11
1925 \bar ""  % Permit first bar number to be printed
1926 % Print a bar number every 2nd bar
1927 \set Score.barNumberVisibility = #(every-nth-bar-number-visible 2)
1928 c1 c c c c
1929 \break
1930 c c c c c
1931 @end lilypond
1932
1933 @cindex measure number, format
1934 @cindex bar number, format
1935
1936 The size of the bar number may be changed.  This is illustrated
1937 in the following example, which also shows how to enclose bar 
1938 numbers in boxes and circles, and shows an alternative way
1939 of specifying @code{#(#f #t #t)} for @code{break-visibility}.
1940
1941 @lilypond[verbatim,ragged-right,quote,fragment,relative]
1942 % Prevent bar numbers at the end of a line and permit them elsewhere
1943 \override Score.BarNumber #'break-visibility
1944   = #end-of-line-invisible
1945
1946 % Increase the size of the bar number by 2 
1947 \override Score.BarNumber #'font-size = #2
1948 \repeat unfold 3 { c1 } \bar "|"
1949
1950 % Draw a box round the following bar number(s)
1951 \override Score.BarNumber  #'stencil
1952   = #(make-stencil-boxer 0.1 0.25 ly:text-interface::print)
1953 \repeat unfold 3 { c1 } \bar "|"
1954
1955 % Draw a circle round the following bar number(s)
1956 \override Score.BarNumber  #'stencil
1957   = #(make-stencil-circler 0.1 0.25 ly:text-interface::print)
1958 \repeat unfold 4 { c1 } \bar "|."
1959 @end lilypond
1960
1961 @cindex bar number alignment
1962
1963 Bar numbers by default are left-aligned to their parent object.
1964 This is usually the left edge of a line or, if numbers are printed
1965 within a line, the left bar line of the bar.  The numbers may also
1966 be positioned directly on the bar line or right-aligned to the 
1967 bar line:
1968
1969 @lilypond[verbatim,ragged-right,quote,fragment,relative]
1970 \set Score.currentBarNumber = #111
1971 \override Score.BarNumber #'break-visibility = ##(#t #t #t)
1972 % Increase the size of the bar number by 2
1973 \override Score.BarNumber #'font-size = #2
1974 % Print a bar number every 2nd bar
1975 \set Score.barNumberVisibility = #(every-nth-bar-number-visible 2)
1976 c1 c1
1977 % Centre-align bar numbers
1978 \override Score.BarNumber #'self-alignment-X = #0
1979 c1 c1
1980 % Right-align bar numbers
1981 \override Score.BarNumber #'self-alignment-X = #-1
1982 c1 c1
1983 @end lilypond
1984
1985 Bar numbers can be removed entirely by removing the Bar number
1986 engraver from the score context.
1987
1988 @lilypond[verbatim,ragged-right,quote]
1989 \layout {
1990   \context {
1991     \Score
1992     \remove "Bar_number_engraver"
1993   }
1994 }
1995 \relative c''{
1996   c4 c c c \break
1997   c4 c c c
1998 }
1999 @end lilypond
2000
2001
2002 @seealso
2003
2004 Snippets: @lsrdir{Rhythms,Rhythms}
2005
2006 Internals Reference: @internalsref{BarNumber}.
2007
2008
2009 @knownissues
2010
2011 Bar numbers may collide with the top of the
2012 @internalsref{StaffGroup} bracket, if there is one.  To solve
2013 this, the @code{padding} property of @internalsref{BarNumber} can
2014 be used to position the number correctly.
2015
2016 Bar numbers may only be printed at bar lines; to print a bar
2017 number at the beginning of a piece, an empty bar line must be
2018 inserted there, and a value other than @code{1} must be placed
2019 in @code{currentBarNumber}:
2020
2021 @lilypond[verbatim,ragged-right,quote,fragment,relative]
2022 \set Score.currentBarNumber = #50
2023 \bar ""
2024 c1 c c c
2025 c1 c c c
2026 \break
2027 @end lilypond
2028
2029
2030
2031 @node Bar and bar number checks
2032 @subsubsection Bar and bar number checks
2033
2034 @cindex bar check
2035 @funindex barCheckSynchronize
2036 @funindex |
2037
2038 Bar checks help detect errors in the entered durations.
2039 A bar check may be entered using the bar symbol, @code{|}, 
2040 at any place where a bar line is expected to fall.  
2041 If bar check lines are encountered at other places, 
2042 a list of warnings is printed in the log file,
2043 showing the line numbers and lines  
2044 in which the bar checks failed.  In the next
2045 example, the second bar check will signal an error.
2046
2047 @example
2048 \time 3/4 c2 e4 | g2 |
2049 @end example
2050
2051 Bar checks can also be used in lyrics, for example
2052
2053 @example
2054 \lyricmode @{
2055   \time 2/4
2056   Twin -- kle | Twin -- kle |
2057 @}
2058 @end example
2059
2060 An incorrect duration can result in a completely garbled score,
2061 especially if the score is polyphonic, so a good place to start
2062 correcting input is by scanning for failed bar checks and
2063 incorrect durations.
2064
2065 @funindex |
2066 @funindex pipeSymbol
2067
2068 It is also possible to redefine the action taken when a bar check 
2069 or pipe symbol, @code{|}, is encountered in the input, so that 
2070 it does something other than a bar check.  This is done by 
2071 assigning a music expression to @code{pipeSymbol}.  
2072 In the following example @code{|} is set to insert a double bar 
2073 line wherever it appears in the input, rather than checking 
2074 for end of bar.
2075
2076 @lilypond[quote,ragged-right,verbatim]
2077 pipeSymbol = \bar "||"
2078
2079   c'2 c'2 |
2080   c'2 c'2
2081   c'2 | c'2
2082   c'2 c'2
2083 }
2084 @end lilypond
2085
2086 When copying large pieces of music, it can be helpful to check
2087 that the LilyPond bar number corresponds to the original that you
2088 are entering from.  This can be checked with
2089 @code{\barNumberCheck}, for example,
2090
2091 @verbatim
2092 \barNumberCheck #123
2093 @end verbatim
2094
2095 @noindent
2096 will print a warning if the @code{currentBarNumber} is not 123
2097 when it is processed.
2098
2099 @seealso
2100
2101 Snippets: @lsrdir{Rhythms,Rhythms}
2102
2103
2104 @node Rehearsal marks
2105 @subsubsection Rehearsal marks
2106
2107 @cindex rehearsal marks
2108 @cindex mark, rehearsal
2109 @funindex \mark
2110
2111 To print a rehearsal mark, use the @code{\mark} command
2112
2113 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
2114 c1 \mark \default
2115 c1 \mark \default
2116 c1 \mark #8
2117 c1 \mark \default
2118 c1 \mark \default
2119 @end lilypond
2120
2121 @noindent
2122 The letter@tie{}@q{I} is skipped in accordance with engraving
2123 traditions.  If you wish to include the letter @q{I}, then use
2124
2125 @example
2126 \set Score.markFormatter = #format-mark-alphabet
2127 @end example
2128
2129 The mark is incremented automatically if you use @code{\mark
2130 \default}, but you can also use an integer argument to set the
2131 mark manually.  The value to use is stored in the property
2132 @code{rehearsalMark}.
2133
2134 @cindex rehearsal mark format
2135 @cindex rehearsal mark style
2136 @cindex style, rehearsal mark
2137 @cindex format, rehearsal mark
2138 @cindex mark, rehearsal, style
2139 @cindex mark, rehearsal, format
2140
2141 The style is defined by the property @code{markFormatter}.  It is
2142 a function taking the current mark (an integer) and the current
2143 context as argument.  It should return a markup object.  In the
2144 following example, @code{markFormatter} is set to a pre-defined
2145 procedure.  After a few measures, it is set to a procedure that
2146 produces a boxed number.
2147
2148 @lilypond[fragment,quote,ragged-right,verbatim,relative=2]
2149 \set Score.markFormatter = #format-mark-numbers
2150 c1 \mark \default
2151 c1 \mark \default
2152 \set Score.markFormatter = #format-mark-box-numbers
2153 c1 \mark \default
2154 c1 \mark \default
2155 c1
2156 @end lilypond
2157
2158 The file @file{scm/@/translation@/-functions@/.scm} contains the
2159 definitions of @code{format-mark-numbers} (the default format),
2160 @code{format-mark-box-numbers}, @code{format-mark-letters} and
2161 @code{format-mark-box-letters}.  These can be used as inspiration
2162 for other formatting functions.
2163
2164 You may use @code{format-mark-barnumbers},
2165 @code{format-mark-box-barnumbers}, and
2166 @code{format-mark-circle-barnumbers} to get bar numbers instead of
2167 incremented numbers or letters.
2168
2169 Other styles of rehearsal mark can be specified manually
2170
2171 @example
2172 \mark "A1"
2173 @end example
2174
2175 @noindent
2176 @code{Score.markFormatter} does not affect marks specified in this
2177 manner.  However, it is possible to apply a @code{\markup} to the
2178 string.
2179
2180 @example
2181 \mark \markup@{ \box A1 @}
2182 @end example
2183
2184 @cindex segno
2185 @cindex coda
2186 @cindex D.S al Fine
2187
2188 Music glyphs (such as the segno sign) may be printed inside a
2189 @code{\mark}
2190
2191 @lilypond[fragment,quote,ragged-right,verbatim,relative]
2192 c1 \mark \markup { \musicglyph #"scripts.segno" }
2193 c1 \mark \markup { \musicglyph #"scripts.coda" }
2194 c1 \mark \markup { \musicglyph #"scripts.ufermata" }
2195 c1
2196 @end lilypond
2197
2198 @noindent
2199 See @ref{The Feta font}, for a list of symbols which may be
2200 printed with @code{\musicglyph}.
2201
2202 For common tweaks to the positioning of rehearsal marks, see
2203 @ref{Text marks}.
2204
2205 @seealso
2206
2207 Snippets: @lsrdir{Rhythms,Rhythms}
2208
2209 This manual: @ref{The Feta font}, @ref{Text marks}.
2210
2211 Internals Reference: @internalsref{RehearsalMark}.
2212
2213 Init files: @file{scm/@/translation@/-functions@/.scm} contains
2214 the definition of @code{format-mark-numbers} and
2215 @code{format-mark-letters}.  They can be used as inspiration for
2216 other formatting functions.
2217
2218 Examples: @c @lsr{parts,rehearsal-mark-numbers.ly}
2219
2220
2221 @node Special rhythmic concerns
2222 @subsection Special rhythmic concerns
2223
2224
2225 @menu
2226 * Grace notes::                 
2227 * Aligning to cadenzas::        
2228 * Time administration::         
2229 @end menu
2230
2231 @node Grace notes
2232 @subsubsection Grace notes
2233
2234 @funindex \grace
2235 @cindex ornaments
2236 @cindex grace notes
2237 @cindex appoggiatura
2238 @cindex acciaccatura
2239
2240 Grace notes are ornaments that are written out. They are made with
2241 the @code{\grace} command.  By prefixing this keyword to a music
2242 expression, a new one is formed, which will be printed in a
2243 smaller font and takes up no logical time in a measure.
2244
2245 @lilypond[quote,ragged-right,relative=2,verbatim,fragment]
2246 c4 \grace c16 c4
2247 \grace { c16[ d16] } c2 c4
2248 @end lilypond
2249
2250 Two special forms of the @code{\grace} command exist.
2251 An @emph{acciaccatura}, which should be played as very short,
2252 is denoted by a slurred small note with a slashed stem.  The
2253 @emph{appoggiatura}, a grace note that takes a fixed fraction of the
2254 main note, is denoted as a slurred note in small print without
2255 a slash.  They are entered with the commands @code{\acciaccatura}
2256 and @code{\appoggiatura}, as demonstrated in the following
2257 example:
2258
2259 @lilypond[quote,ragged-right,relative=2,verbatim,fragment]
2260 b4 \acciaccatura d8 c4 
2261 \appoggiatura e8 d4
2262 \acciaccatura { g16[ f] } e4
2263 @end lilypond
2264
2265 @noindent
2266 @code{\acciaccatura} and @code{\appoggiatura} start a slur, 
2267 @code{\grace} does not.
2268
2269 The placement of grace notes is synchronized between different
2270 staves.  In the following example, there are two sixteenth grace
2271 notes for every eighth grace note
2272
2273 @lilypond[quote,ragged-right,relative=2,verbatim,fragment]
2274 << \new Staff { e4 \grace { c16[ d e f] } e4 }
2275    \new Staff { c4 \grace { g8[ b] } c4 } >>
2276 @end lilypond
2277
2278 @funindex \afterGrace
2279
2280 @cindex grace notes, following
2281
2282 If you want to end a note with a grace, use the @code{\afterGrace}
2283 command.  It takes two arguments: the main note, and the grace
2284 notes following the main note.
2285
2286 @lilypond[ragged-right, verbatim,relative=2,fragment]
2287 c1 \afterGrace d1 { c16[ d] } c4
2288 @end lilypond
2289
2290 This will put the grace notes after a @q{space} lasting 3/4 of the
2291 length of the main note.  The fraction 3/4 can be changed by
2292 setting @code{afterGraceFraction}, ie.
2293
2294 @example
2295 #(define afterGraceFraction (cons 7 8))
2296 @end example
2297
2298 @noindent
2299 will put the grace note at 7/8 of the main note.
2300
2301 The same effect can be achieved manually by doing
2302
2303 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
2304 \new Voice {
2305   << { d1^\trill_( }
2306      { s2 \grace { c16[ d] } } >>
2307   c4)
2308 }
2309 @end lilypond
2310
2311 @noindent
2312 By adjusting the duration of the skip note (here it is a
2313 half-note), the space between the main-note and the grace
2314 may be adjusted.
2315
2316 A @code{\grace} music expression will introduce special
2317 typesetting settings, for example, to produce smaller type, and
2318 set directions.  Hence, when introducing layout tweaks, they
2319 should be inside the grace expression, for example,
2320
2321 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
2322 \new Voice {
2323   \acciaccatura {
2324     \stemDown
2325     f16->
2326     \stemNeutral
2327   }
2328   g4
2329 }
2330 @end lilypond
2331
2332 @noindent
2333 The overrides should also be reverted inside the grace expression.
2334
2335 The layout of grace expressions can be changed throughout the
2336 music using the function @code{add-grace-property}.  The following
2337 example undefines the @code{Stem} direction for this grace, so
2338 that stems do not always point up.
2339
2340 @example
2341 \new Staff @{
2342   #(add-grace-property 'Voice 'Stem 'direction '())
2343   @dots{}
2344 @}
2345 @end example
2346
2347 @noindent
2348 Another option is to change the variables @code{startGraceMusic},
2349 @code{stopGraceMusic}, @code{startAcciaccaturaMusic},
2350 @code{stopAcciaccaturaMusic}, @code{startAppoggiaturaMusic},
2351 @code{stopAppoggiaturaMusic}.  The default values of these can be
2352 seen in the file @file{ly/@/grace@/-init@/.ly}.  By redefining
2353 them other effects may be obtained.
2354
2355 @cindex stem, with slash
2356
2357 @noindent
2358 The slash through the stem in @emph{acciaccatura}s can be obtained in
2359 other situations by @code{\override Stem  #'stroke-style =
2360 #"grace"}.
2361
2362
2363 @snippets
2364
2365 Grace notes may be forced to use align with regular notes
2366 in other staves by setting @code{strict-grace-spacing} to
2367 ##t:
2368
2369 @lilypond[relative=2,ragged-right]
2370 <<
2371   \override Score.SpacingSpanner #'strict-grace-spacing = ##t
2372   \new Staff {
2373      c'4
2374      \afterGrace
2375      c'4
2376      { c'16[ c'8 c'16] }
2377      c'4
2378   }  
2379   \new Staff {
2380      c'16[ c'16 c'16 c'16]
2381      c'16[ c'16 c'16 c'16]
2382      c'4
2383   }
2384 >>
2385 @end lilypond
2386
2387
2388 @seealso
2389
2390 Music Glossary:
2391 @rglos{grace notes},
2392 @rglos{acciaccatura},
2393 @rglos{appoggiatura}
2394
2395 Snippets: @lsrdir{Rhythms,Rhythms}
2396
2397 Internals Reference: @internalsref{GraceMusic}.
2398
2399
2400 @knownissues
2401
2402 A multi-note beamed @emph{acciaccatura} is printed without a slash, 
2403 and looks exactly the same as a multi-note beamed
2404 @emph{appoggiatura}.
2405 @c TODO Add link to LSR snippet to add slash when available
2406
2407 Grace note synchronization can also lead to surprises.  Staff
2408 notation, such as key signatures, bar lines, etc., are also
2409 synchronized.  Take care when you mix staves with grace notes and
2410 staves without, for example,
2411
2412 @lilypond[quote,ragged-right,relative=2,verbatim,fragment]
2413 << \new Staff { e4 \bar "|:" \grace c16 d4 }
2414    \new Staff { c4 \bar "|:" d4 } >>
2415 @end lilypond
2416
2417 @noindent
2418 This can be remedied by inserting grace skips of the corresponding
2419 durations in the other staves.  For the above example
2420
2421 @lilypond[quote,ragged-right,relative=2,verbatim,fragment]
2422 << \new Staff { e4 \bar "|:" \grace c16 d4 }
2423    \new Staff { c4 \bar "|:" \grace s16 d4 } >>
2424 @end lilypond
2425
2426 Grace sections should only be used within sequential music
2427 expressions.  Nesting or juxtaposing grace sections is not
2428 supported, and might produce crashes or other errors.
2429
2430 @node Aligning to cadenzas
2431 @subsubsection Aligning to cadenzas
2432
2433 @cindex cadenza
2434 @cindex cadenza, aligning to
2435 @cindex aligning to cadenza
2436
2437 In an orchestral context, cadenzas present a special problem: when
2438 constructing a score that includes a cadenza, all other
2439 instruments should skip just as many notes as the length of the
2440 cadenza, otherwise they will start too soon or too late.
2441
2442 A solution to this problem is to use the functions
2443 @code{mmrest-of-length} and @code{skip-of-length}.  These Scheme
2444 functions take a piece of music as argument, and generate a multi-rest
2445 or @code{\skip}, exactly as long as the piece.  The use of
2446 @code{mmrest-of-length} is demonstrated in the following example.
2447
2448 @lilypond[verbatim,ragged-right,quote]
2449 cadenza = \relative c' {
2450   c4 d8 << { e f g } \\ { d4. } >>
2451   g4 f2 g4 g
2452 }
2453
2454 \new GrandStaff <<
2455   \new Staff { \cadenza c'4 }
2456   \new Staff {
2457     #(ly:export (mmrest-of-length cadenza))
2458     c'4
2459   }
2460 >>
2461 @end lilypond
2462
2463 @seealso
2464
2465 Snippets: @lsrdir{Rhythms,Rhythms}
2466
2467
2468 @node Time administration
2469 @subsubsection Time administration
2470
2471 @cindex time administration
2472 @cindex timing (within the score)
2473 @cindex music, unmetered
2474 @cindex unmetered music
2475
2476 @funindex currentBarNumber
2477 @funindex measurePosition
2478 @funindex measureLength
2479
2480 Time is administered by the @code{Timing_translator}, which by
2481 default is to be found in the @code{Score} context.  An alias,
2482 @code{Timing}, is added to the context in which the
2483 @code{Timing_translator} is placed.
2484
2485 The following properties of @code{Timing} are used
2486 to keep track of timing within the score.
2487  
2488 @cindex bar number
2489 @cindex measure number
2490
2491 @table @code
2492 @item currentBarNumber
2493 The current measure number.  For an example showing the
2494 use of this property see @ref{Bar numbers}.
2495
2496 @item measureLength
2497 The length of the measures in the current time signature.  For a
2498 4/4 time this is@tie{}1, and for 6/8 it is 3/4.  Its value
2499 determines when bar lines are inserted and how automatic beams
2500 should be generated.
2501
2502 @item measurePosition
2503 The point within the measure where we currently are.  This
2504 quantity is reset by subtracting @code{measureLength} whenever
2505 @code{measureLength} is reached or exceeded.  When that happens, 
2506 @code{currentBarNumber} is incremented.
2507
2508 @item timing
2509 If set to true, the above variables are updated for every time
2510 step.  When set to false, the engraver stays in the current
2511 measure indefinitely.
2512
2513 @end table
2514
2515 Timing can be changed by setting any of these variables
2516 explicitly.  In the next example, the default 4/4 time 
2517 signature is printed, but @code{measureLength} is set to 5/4.
2518 At 4/8 through the third measure, the @code{measurePosition} is
2519 advanced by 1/8 to 5/8, shortening that bar by 1/8.
2520 The next bar line then falls at 9/8 rather than 5/4.
2521
2522 @lilypond[quote,ragged-right,verbatim,relative,fragment]
2523 \set Score.measureLength = #(ly:make-moment 5 4)
2524 c1 c4
2525 c1 c4
2526 c4 c4
2527 \set Score.measurePosition = #(ly:make-moment 5 8)
2528 b4 b4 b8
2529 c4 c1
2530 @end lilypond
2531
2532 @noindent
2533 As the example illustrates, @code{ly:make-moment n m} constructs a
2534 duration of n/m of a whole note.  For example,
2535 @code{ly:make-moment 1 8} is an eighth note duration and
2536 @code{ly:make-moment 7 16} is the duration of seven sixteenths
2537 notes.
2538
2539
2540 @seealso
2541
2542 This manual: @ref{Bar numbers}, @ref{Unmetered music}
2543
2544 Snippets: @lsrdir{Rhythms,Rhythms}
2545
2546 Internals Reference: @internalsref{Timing_translator},
2547 @internalsref{Score}
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561