]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/notation/staff.itely
Rerun scripts/auxiliar/update-with-convert-ly.sh
[lilypond.git] / Documentation / notation / staff.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.  For details, see the Contributors'
7     Guide, node Updating translation committishes..
8 @end ignore
9
10 @c \version "2.17.6"
11
12 @node Staff notation
13 @section Staff notation
14
15 @c The line width is a bit of a hack to allow space for the
16 @c  instrument names.
17 @lilypondfile[quote,ragged-right,line-width=14.5\cm,staffsize=16]{staff-headword.ly}
18
19 This section explains how to influence the appearance of staves,
20 how to print scores with more than one staff, and how to add tempo
21 indications and cue notes to staves.
22
23 @menu
24 * Displaying staves::
25 * Modifying single staves::
26 * Writing parts::
27 @end menu
28
29
30 @node Displaying staves
31 @subsection Displaying staves
32
33 This section describes the different methods of creating and
34 grouping staves.
35
36 @menu
37 * Instantiating new staves::
38 * Grouping staves::
39 * Nested staff groups::
40 * Separating systems::
41 @end menu
42
43
44 @node Instantiating new staves
45 @unnumberedsubsubsec Instantiating new staves
46
47 @cindex new staff
48 @cindex staff initiation
49 @cindex staff instantiation
50 @cindex staff, new
51 @cindex staff, single
52 @cindex staff, drum
53 @cindex staff, percussion
54 @cindex drum staff
55 @cindex percussion staff
56 @cindex Gregorian transcription staff
57 @cindex rhythmic staff
58 @cindex tabstaff
59 @cindex tablature
60
61 @funindex \drummode
62 @funindex drummode
63 @funindex DrumStaff
64 @funindex RhythmicStaff
65 @funindex TabStaff
66 @funindex MensuralStaff
67 @funindex VaticanaStaff
68 @funindex GregorianTranscriptionStaff
69
70 @notation{Staves} (singular: @notation{staff}) are created with
71 the @code{\new} or @code{\context} commands.  For details, see
72 @ref{Creating contexts}.
73
74 The basic staff context is @code{Staff}:
75
76 @lilypond[verbatim,quote,relative=2]
77 \new Staff { c4 d e f }
78 @end lilypond
79
80 The @code{DrumStaff} context creates a five-line staff set up for
81 a typical drum set.  Each instrument is shown with a different
82 symbol.  The instruments are entered in drum mode following a
83 @code{\drummode} command, with each instrument specified by name.
84 For details, see @ref{Percussion staves}.
85
86 @lilypond[verbatim,quote]
87 \new DrumStaff {
88   \drummode { cymc hh ss tomh }
89 }
90 @end lilypond
91
92 @code{RhythmicStaff} creates a single-line staff that only
93 displays the rhythmic values of the input.  Real durations are
94 preserved.  For details, see @ref{Showing melody rhythms}.
95
96 @lilypond[verbatim,quote,relative=2]
97 \new RhythmicStaff { c4 d e f }
98 @end lilypond
99
100 @code{TabStaff} creates a tablature with six strings in standard
101 guitar tuning.  For details, see @ref{Default tablatures}.
102
103 @lilypond[verbatim,quote,relative=2]
104 \new TabStaff { c4 d e f }
105 @end lilypond
106
107 There are two staff contexts specific for the notation of ancient
108 music: @code{MensuralStaff} and @code{VaticanaStaff}.  They are
109 described in @ref{Pre-defined contexts}.
110
111 The @code{GregorianTranscriptionStaff} context creates a staff to
112 notate modern Gregorian chant.  It does not show bar lines.
113
114 @lilypond[verbatim,quote,relative=2]
115 \new GregorianTranscriptionStaff { c4 d e f e d }
116 @end lilypond
117
118 New single staff contexts may be defined.  For details, see
119 @ref{Defining new contexts}.
120
121 @seealso
122 Music Glossary:
123 @rglos{staff},
124 @rglos{staves}.
125
126 Notation Reference:
127 @ref{Creating contexts},
128 @ref{Percussion staves},
129 @ref{Showing melody rhythms},
130 @ref{Default tablatures},
131 @ref{Pre-defined contexts},
132 @ref{Staff symbol},
133 @ref{Gregorian chant contexts},
134 @ref{Mensural contexts},
135 @ref{Defining new contexts}.
136
137 Snippets:
138 @rlsr{Staff notation}.
139
140 Internals Reference:
141 @rinternals{Staff},
142 @rinternals{DrumStaff},
143 @rinternals{GregorianTranscriptionStaff},
144 @rinternals{RhythmicStaff},
145 @rinternals{TabStaff},
146 @rinternals{MensuralStaff},
147 @rinternals{VaticanaStaff},
148 @rinternals{StaffSymbol}.
149
150
151 @node Grouping staves
152 @unnumberedsubsubsec Grouping staves
153
154 @cindex start of system
155 @cindex staff, multiple
156 @cindex staves, multiple
157 @cindex system start delimiters
158 @cindex bracket, vertical
159 @cindex brace, vertical
160 @cindex choir staff
161 @cindex grand staff
162 @cindex piano staff
163 @cindex staff group
164 @cindex staff, choir
165 @cindex staff, piano
166 @cindex staff, grand
167 @cindex system
168
169 Various contexts exist to group single staves together in order to
170 form multi-stave systems.  Each grouping context sets the style of
171 the system start delimiter and the behavior of bar lines.
172
173 If no context is specified, the default properties will be used:
174 the group is started with a vertical line, and the bar lines are
175 not connected.
176
177 @lilypond[verbatim,quote,relative=2]
178 <<
179   \new Staff { c1 c }
180   \new Staff { c1 c }
181 >>
182 @end lilypond
183
184 In the @code{StaffGroup} context, the group is started with a
185 bracket and bar lines are drawn through all the staves.
186
187 @lilypond[verbatim,quote,relative=2]
188 \new StaffGroup <<
189   \new Staff { c1 c }
190   \new Staff { c1 c }
191 >>
192 @end lilypond
193
194 In a @code{ChoirStaff}, the group starts with a bracket, but bar
195 lines are not connected.
196
197 @lilypond[verbatim,quote,relative=2]
198 \new ChoirStaff <<
199   \new Staff { c1 c }
200   \new Staff { c1 c }
201 >>
202 @end lilypond
203
204 In a @code{GrandStaff}, the group begins with a brace, and bar
205 lines are connected between the staves.
206
207 @lilypond[verbatim,quote,relative=2]
208 \new GrandStaff <<
209   \new Staff { c1 c }
210   \new Staff { c1 c }
211 >>
212 @end lilypond
213
214 The @code{PianoStaff} is identical to a @code{GrandStaff}, except
215 that it supports printing the instrument name directly.  For
216 details, see @ref{Instrument names}.
217
218 @lilypond[verbatim,quote,relative=2]
219 \new PianoStaff <<
220   \set PianoStaff.instrumentName = #"Piano"
221   \new Staff { c1 c }
222   \new Staff { c1 c }
223 >>
224 @end lilypond
225
226 Each staff group context sets the property
227 @code{systemStartDelimiter} to one of the following values:
228 @code{SystemStartBar}, @code{SystemStartBrace}, or
229 @code{SystemStartBracket}.  A fourth delimiter,
230 @code{SystemStartSquare}, is also available, but it must be
231 explicitly specified.
232
233 New staff group contexts may be defined.  For details, see
234 @ref{Defining new contexts}.
235
236
237 @snippets
238
239 @lilypondfile[verbatim,quote,texidoc,doctitle]
240 {use-square-bracket-at-the-start-of-a-staff-group.ly}
241
242 @lilypondfile[verbatim,quote,texidoc,doctitle]
243 {display-bracket-with-only-one-staff-in-a-system.ly}
244
245 @cindex mensurstriche layout
246 @cindex renaissance music
247 @cindex transcription of mensural music
248 @cindex mensural music, transcription of
249
250 @lilypondfile[verbatim,quote,texidoc,doctitle]
251 {mensurstriche-layout-bar-lines-between-the-staves.ly}
252
253 @seealso
254 Music Glossary:
255 @rglos{brace},
256 @rglos{bracket},
257 @rglos{grand staff}.
258
259 Notation Reference:
260 @ref{Instrument names},
261 @ref{Defining new contexts}.
262
263 Snippets:
264 @rlsr{Staff notation}.
265
266 Internals Reference:
267 @rinternals{Staff},
268 @rinternals{StaffGroup},
269 @rinternals{ChoirStaff},
270 @rinternals{GrandStaff},
271 @rinternals{PianoStaff},
272 @rinternals{SystemStartBar},
273 @rinternals{SystemStartBrace},
274 @rinternals{SystemStartBracket},
275 @rinternals{SystemStartSquare}.
276
277 @knownissues
278 @code{PianoStaff} does not, by default, accept @code{ChordNames}.
279
280
281 @node Nested staff groups
282 @unnumberedsubsubsec Nested staff groups
283
284 @cindex staff, nested
285 @cindex staves, nested
286 @cindex nesting of staves
287 @cindex system start delimiters, nested
288 @cindex nested staff brackets
289 @cindex brackets, nesting of
290 @cindex braces, nesting of
291
292 Staff-group contexts can be nested to arbitrary depths.  In this
293 case, each child context creates a new bracket adjacent to the
294 bracket of its parent group.
295
296 @lilypond[verbatim,quote,relative=2]
297 \new StaffGroup <<
298   \new Staff { c2 c | c2 c }
299   \new StaffGroup <<
300     \new Staff { g2 g | g2 g }
301     \new StaffGroup \with {
302       systemStartDelimiter = #'SystemStartSquare
303     }
304     <<
305       \new Staff { e2 e | e2 e }
306       \new Staff { c2 c | c2 c }
307     >>
308   >>
309 >>
310 @end lilypond
311
312 New nested staff group contexts can be defined.  For details, see
313 @ref{Defining new contexts}.
314
315
316 @snippets
317
318 @lilypondfile[verbatim,quote,texidoc,doctitle]
319 {nesting-staves.ly}
320
321 @seealso
322 Notation Reference:
323 @ref{Grouping staves},
324 @ref{Instrument names},
325 @ref{Defining new contexts}.
326
327 Snippets:
328 @rlsr{Staff notation}.
329
330 Internals Reference:
331 @rinternals{StaffGroup},
332 @rinternals{ChoirStaff},
333 @rinternals{SystemStartBar},
334 @rinternals{SystemStartBrace},
335 @rinternals{SystemStartBracket},
336 @rinternals{SystemStartSquare}.
337
338
339 @node Separating systems
340 @unnumberedsubsubsec Separating systems
341
342 @cindex system separator mark
343
344 If the number of systems per page changes from page to page it is
345 customary to separate the systems by placing a system separator mark
346 between them.  By default the system separator is blank, but can be
347 turned on with a @code{\paper} option.
348
349 @c \book is required here to display the system separator
350 @c ragged-right is required as there are two systems
351 @lilypond[verbatim,quote,ragged-right]
352 \book {
353   \score {
354     \new StaffGroup <<
355       \new Staff {
356         \relative c'' {
357           c4 c c c
358           \break
359           c4 c c c
360         }
361       }
362       \new Staff {
363         \relative c'' {
364           c4 c c c
365           \break
366           c4 c c c
367         }
368       }
369     >>
370   }
371   \paper {
372     system-separator-markup = \slashSeparator
373     % following commands are needed only to format this documentation
374     paper-width = 100\mm
375     paper-height = 100\mm
376     tagline = ##f
377   }
378 }
379 @end lilypond
380
381 @seealso
382 Notation Reference:
383 @ref{Page layout}.
384
385 Snippets:
386 @rlsr{Staff notation}.
387
388
389 @node Modifying single staves
390 @subsection Modifying single staves
391
392 This section explains how to change specific attributes of one
393 staff: for example, modifying the number of staff lines or the
394 staff size.  Methods to start and stop staves and set ossia
395 sections are also described.
396
397 @menu
398 * Staff symbol::
399 * Ossia staves::
400 * Hiding staves::
401 @end menu
402
403
404 @node Staff symbol
405 @unnumberedsubsubsec Staff symbol
406
407 @cindex staff symbol
408 @cindex staff lines, stopping and starting
409 @cindex staff lines, modifying
410 @cindex ledger lines
411 @cindex ledger lines, internal
412 @cindex ledger lines, modifying
413
414 @funindex \startStaff
415 @funindex startStaff
416 @funindex \stopStaff
417 @funindex stopStaff
418
419 The @code{\stopStaff} and @code{\startStaff} commands can be used to
420 stop or (re)start the staff lines respectively, from being printed at
421 any point witin a score.
422
423 @lilypond[verbatim,quote,relative=2]
424 \stopStaff f4 d \startStaff g, e
425 f'4 d \stopStaff g, e
426 f'4 d \startStaff g, e
427 @end lilypond
428
429 @predefined
430 @code{\startStaff},
431 @code{\stopStaff}.
432 @endpredefined
433
434 The lines of a staff belong to the @code{StaffSymbol} grob (including
435 ledger lines) can be modified using @code{StaffSymbol} properties, but
436 these modifications must be made before the staff is (re)started.
437
438 The number of staff lines can be altered,
439
440 @lilypond[verbatim,quote,relative=2]
441 f4 d \stopStaff
442 \override Staff.StaffSymbol.line-count = #2
443 \startStaff g, e |
444
445 f'4 d \stopStaff
446 \revert Staff.StaffSymbol.line-count
447 \startStaff g, e |
448 @end lilypond
449
450 The position of each the staff lines can also be altered.  The values
451 used are @emph{half} staff line spaces and the new position is relative
452 to the normal center line.  A single staff line is printed for every
453 value entered so that the number of staff lines, as well as their
454 position in the staff, can be changed with a single override.
455
456 @lilypond[verbatim,quote,relative=2]
457 f4 d \stopStaff
458 \override Staff.StaffSymbol.line-positions = #'(1 3 5 -1 -3)
459 \startStaff g, e |
460 f'4 d \stopStaff
461 \override Staff.StaffSymbol.line-positions = #'(8 6.5 -6 -8 -0.5)
462 \startStaff g, e
463 @end lilypond
464
465 The clef position and the position of middle C may need to be adjusted
466 accordingly to fit the new lines.  See @ref{Clef}.
467
468 Staff line thickness can be altered.  Ledger lines and note stems, by
469 default, are also affected.
470
471 @lilypond[verbatim,quote,relative=2]
472 \new Staff \with {
473   \override StaffSymbol.thickness = #3
474 }
475 { f4 d g, e }
476 @end lilypond
477
478 However, it is possible to set ledger line thickness independently of
479 staff lines.  The two values required multiply the staff line thickness
480 with the staff line spacing and are then added together to give the
481 ledger line thickness.
482
483 @lilypond[verbatim,quote,relative=2]
484 \new Staff \with {
485   \override StaffSymbol.thickness = #2
486   \override StaffSymbol.ledger-line-thickness = #'(0.5 . 0.4)
487 }
488 { f'4 a, a,, f }
489 @end lilypond
490
491 The vertical positions of ledger lines can be altered,
492
493 @lilypond[verbatim,quote,relative=2]
494 \new Staff \with {
495   \override StaffSymbol.ledger-positions = #'(-3 -2 -1 2 5 6)
496 }
497 { f'4 a, a,, f }
498 @end lilypond
499
500 Additional ledger lines can be made to appear above or below note heads
501 depending on the current position relative to other note heads that
502 also have their own ledger lines.
503
504 @lilypond[verbatim,quote,relative=2]
505 \new Staff \with {
506   \override StaffSymbol.ledger-extra = #4
507 }
508 { f'4 a, d, f, }
509 @end lilypond
510
511 Legder lines can also be made to appear inside the staff where custom
512 staff lines are required.  The example shows the default position of
513 ledger lines when the explicit @code{legder-position} is and is not set.
514 The @code{stopStaff} is needed in the example to revert the
515 @code{\override} for the whole @code{StaffSymbol}.
516
517 @lilypond[fragment,quote,relative=1]
518 \override Staff.StaffSymbol.line-positions =   #'(-8 0 2 4)
519 d4 e f g
520 \stopStaff
521 \startStaff
522 \override Staff.StaffSymbol.ledger-positions = #'(-8 -6 (-4 -2) 0)
523 d4 e f g
524 @end lilypond
525
526 The distance between staff lines can be altered.  This affects ledger
527 line spacing as well.
528
529 @lilypond[verbatim,quote,relative=2]
530 \new Staff \with {
531   \override StaffSymbol.staff-space = #1.5
532 }
533 { f'4 d, g, e, }
534 @end lilypond
535
536 @snippets
537 @lilypondfile[verbatim,quote,texidoc,doctitle]
538 {making-some-staff-lines-thicker-than-the-others.ly}
539
540 @seealso
541 Music Glossary:
542 @rglos{line},
543 @rglos{ledger line},
544 @rglos{staff}.
545
546 Notation Reference:
547 @ref{Clef}.
548
549 Snippets:
550 @rlsr{Staff notation}.
551
552 Internals Reference:
553 @rinternals{StaffSymbol},
554 @rinternals{staff-symbol-interface}.
555
556
557 @node Ossia staves
558 @unnumberedsubsubsec Ossia staves
559
560 @cindex staff, Frenched
561 @cindex ossia
562 @cindex Frenched staves
563 @cindex staff, resizing of
564 @cindex resizing of staves
565
566 @funindex \startStaff
567 @funindex startStaff
568 @funindex \stopStaff
569 @funindex stopStaff
570
571 @notation{Ossia} staves can be set by creating a new simultaneous
572 staff in the appropriate location:
573
574 @lilypond[verbatim,quote]
575 \new Staff \relative c'' {
576   c4 b d c
577   <<
578     { c4 b d c }
579     \new Staff { e4 d f e }
580   >>
581   c4 b c2
582 }
583 @end lilypond
584
585 @noindent
586 However, the above example is not what is usually desired.  To
587 create ossia staves that are above the original staff, have no
588 time signature or clef, and have a smaller font size, tweaks must
589 be used.  The Learning Manual describes a specific technique to
590 achieve this goal, beginning with
591 @rlearning{Nesting music expressions}.
592
593 The following example uses the @code{alignAboveContext} property
594 to align the ossia staff.  This method is most appropriate when
595 only a few ossia staves are needed.
596
597 @lilypond[verbatim,quote]
598 \new Staff = main \relative c'' {
599   c4 b d c
600   <<
601     { c4 b d c }
602
603     \new Staff \with {
604       \remove "Time_signature_engraver"
605       alignAboveContext = #"main"
606       fontSize = #-3
607       \override StaffSymbol.staff-space = #(magstep -3)
608       \override StaffSymbol.thickness = #(magstep -3)
609       firstClef = ##f
610     }
611     { e4 d f e }
612   >>
613   c4 b c2
614 }
615 @end lilypond
616
617 If many isolated ossia staves are needed, creating an empty
618 @code{Staff} context with a specific @emph{context id} may be more
619 appropriate; the ossia staves may then be created by
620 @emph{calling} this context and using @code{\startStaff} and
621 @code{\stopStaff} at the desired locations.  The benefits of this
622 method are more apparent if the piece is longer than the following
623 example.
624
625 @lilypond[verbatim,quote,ragged-right]
626 <<
627   \new Staff = ossia \with {
628     \remove "Time_signature_engraver"
629     \override Clef.transparent = ##t
630     fontSize = #-3
631     \override StaffSymbol.staff-space = #(magstep -3)
632     \override StaffSymbol.thickness = #(magstep -3)
633   }
634   { \stopStaff s1*6 }
635
636   \new Staff \relative c' {
637     c4 b c2
638     <<
639       { e4 f e2 }
640       \context Staff = ossia {
641         \startStaff e4 g8 f e2 \stopStaff
642       }
643     >>
644     g4 a g2 \break
645     c4 b c2
646     <<
647       { g4 a g2 }
648       \context Staff = ossia {
649         \startStaff g4 e8 f g2 \stopStaff
650       }
651     >>
652     e4 d c2
653   }
654 >>
655 @end lilypond
656
657
658 Using the @code{\Staff \RemoveEmptyStaves} command to create ossia
659 staves may be used as an alternative.  This method is most
660 convenient when ossia staves occur immediately following a line
661 break.  For more information about
662 @code{\Staff \RemoveEmptyStaves}, see @ref{Hiding staves}.
663
664 @lilypond[verbatim,quote,ragged-right]
665 <<
666   \new Staff = ossia \with {
667     \remove "Time_signature_engraver"
668     \override Clef.transparent = ##t
669     fontSize = #-3
670     \override StaffSymbol.staff-space = #(magstep -3)
671     \override StaffSymbol.thickness = #(magstep -3)
672   } \relative c'' {
673     R1*3
674     c4 e8 d c2
675   }
676   \new Staff \relative c' {
677     c4 b c2
678     e4 f e2
679     g4 a g2 \break
680     c4 b c2
681     g4 a g2
682     e4 d c2
683   }
684 >>
685
686 \layout {
687   \context {
688     \Staff \RemoveEmptyStaves
689     \override VerticalAxisGroup.remove-first = ##t
690   }
691 }
692 @end lilypond
693
694
695 @snippets
696
697 @lilypondfile[verbatim,quote,texidoc,doctitle]
698 {vertically-aligning-ossias-and-lyrics.ly}
699
700 @seealso
701 Music Glossary:
702 @rglos{ossia},
703 @rglos{staff},
704 @rglos{Frenched staff}.
705
706 Learning Manual:
707 @rlearning{Nesting music expressions},
708 @rlearning{Size of objects},
709 @rlearning{Length and thickness of objects}.
710
711 Notation Reference:
712 @ref{Hiding staves}.
713
714 Snippets:
715 @rlsr{Staff notation}.
716
717 Internals Reference:
718 @rinternals{StaffSymbol}.
719
720
721 @node Hiding staves
722 @unnumberedsubsubsec Hiding staves
723
724 @cindex Frenched score
725 @cindex Frenched staff
726 @cindex staff, hiding
727 @cindex staff, empty
728 @cindex hiding of staves
729 @cindex empty staves
730
731 @funindex \RemoveEmptyStaves
732 @funindex Staff_symbol_engraver
733 @funindex \stopStaff
734 @funindex stopStaff
735
736
737 Staff lines can be hidden by removing the
738 @code{Staff_symbol_engraver} from the @code{Staff} context.  As an
739 alternative, @code{\stopStaff} may be used.
740
741 @lilypond[verbatim,quote]
742 \new Staff \with {
743   \remove "Staff_symbol_engraver"
744 }
745 \relative c''' { a8 f e16 d c b a2 }
746 @end lilypond
747
748
749 Empty staves can be hidden by setting the
750 @code{\Staff \RemoveEmptyStaves} command in the @code{\layout}
751 block.  In orchestral scores, this style is known as @q{Frenched
752 Score}.  By default, this command hides and removes all empty
753 staves in a score except for those in the first system.
754
755 @warning{A staff is considered empty when it contains only
756 multi-measure rests, rests, skips, spacer rests, or a combination of these
757 elements.}
758
759 @lilypond[verbatim,quote,ragged-right]
760 \layout {
761   \context {
762     \Staff \RemoveEmptyStaves
763   }
764 }
765
766 \relative c' <<
767   \new Staff {
768     e4 f g a \break
769     b1 \break
770     a4 b c2
771   }
772   \new Staff {
773     c,4 d e f \break
774     R1 \break
775     f4 g c,2
776   }
777 >>
778 @end lilypond
779
780 @cindex ossia
781
782 @noindent
783 @code{\Staff \RemoveEmptyStaves} can also be used to create ossia
784 sections for a staff.  For details, see @ref{Ossia staves}.
785
786 @cindex hiding ancient staves
787 @cindex hiding rhythmic staves
788
789 @funindex \RemoveEmptyStaves
790
791 The @code{\VaticanaStaff \RemoveEmptyStaves} command may be used to
792 hide empty staves in ancient music contexts.  Similarly,
793 @code{\RhythmicStaff \RemoveEmptyStaves} may be used to hide empty
794 @code{RhythmicStaff} contexts.
795
796
797 @predefined
798 @code{\Staff \RemoveEmptyStaves},
799 @code{\VaticanaStaff \RemoveEmptyStaves},
800 @code{\RhythmicStaff \RemoveEmptyStaves}.
801 @endpredefined
802
803
804 @snippets
805
806 @lilypondfile[verbatim,quote,texidoc,doctitle]
807 {removing-the-first-empty-line.ly}
808
809 @seealso
810 Music Glossary:
811 @rglos{Frenched staff}.
812
813 Learning Manual:
814 @rlearning{Visibility and color of objects}.
815
816 Notation Reference:
817 @ref{Changing context default settings},
818 @ref{Staff symbol},
819 @ref{Ossia staves},
820 @ref{Hidden notes},
821 @ref{Invisible rests},
822 @ref{Visibility of objects}.
823
824 Snippets:
825 @rlsr{Staff notation}.
826
827 Internals Reference:
828 @rinternals{ChordNames},
829 @rinternals{FiguredBass},
830 @rinternals{Lyrics},
831 @rinternals{Staff},
832 @rinternals{VerticalAxisGroup},
833 @rinternals{Staff_symbol_engraver}.
834
835 @knownissues
836 Removing @code{Staff_symbol_engraver} also hides bar lines.  If
837 bar line visibility is forced, formatting errors may occur.  In
838 this case, use the following overrides instead of removing the
839 engraver:
840
841 @example
842 \override StaffSymbol.stencil = ##f
843 \override NoteHead.no-ledgers = ##t
844 @end example
845
846 For the Known issues and warnings associated with
847 @code{\Staff \RemoveEmptyStaves} see
848 @ref{Changing context default settings}.
849
850
851 @node Writing parts
852 @subsection Writing parts
853
854 This section explains how to insert tempo indications and
855 instrument names into a score.  Methods to quote other voices and
856 format cue notes are also described.
857
858 @menu
859 * Instrument names::
860 * Quoting other voices::
861 * Formatting cue notes::
862 @end menu
863
864 @node Instrument names
865 @unnumberedsubsubsec Instrument names
866
867 @cindex instrument names
868 @cindex instrument names, short
869
870 Instrument names can be printed on the left side of staves in the
871 @code{Staff}, @code{PianoStaff}, @code{StaffGroup}, @code{GrandStaff}
872 and @code{ChoirStaff} contexts.  The value of
873 @code{instrumentName} is used for the first staff, and the value
874 of @code{shortInstrumentName} is used for all succeeding staves.
875
876 @lilypond[verbatim,quote,ragged-right,relative=1]
877 \new Staff \with {
878   instrumentName = #"Violin "
879   shortInstrumentName = #"Vln. "
880 }
881 { c4.. g'16 c4.. g'16 \break | c1 }
882 @end lilypond
883
884 @cindex instrument names, complex
885
886 @code{\markup} can be used to create more complex instrument names:
887
888 @lilypond[verbatim,quote,relative=2]
889 \new Staff \with {
890   instrumentName = \markup {
891     \column { "Clarinetti"
892       \line { "in B" \smaller \flat }
893     }
894   }
895 }
896 { c4 c,16 d e f g2 }
897 @end lilypond
898
899 @cindex instrument names, centering
900
901 When two or more staff contexts are grouped together, the instrument
902 names and short instrument names are centered by default.  To center
903 multi-line instrument names, @code{\center-column} must be used:
904
905 @lilypond[verbatim,quote,indent=1.5\cm,relative=2]
906 <<
907   \new Staff \with {
908     instrumentName = #"Flute"
909   }
910   { f2 g4 f }
911   \new Staff \with {
912     instrumentName = \markup {
913       \center-column { "Clarinet"
914         \line { "in B" \smaller \flat }
915       }
916     }
917   }
918   { c4 b c2 }
919 >>
920 @end lilypond
921
922 @funindex indent
923 @funindex short-indent
924
925 However, if the instrument names are longer, the instrument names in a
926 staff group may not be centered unless the @code{indent} and
927 @code{short-indent} settings are increased.  For details about these
928 settings, see @ref{\paper variables for shifts and indents}.
929
930 @lilypond[verbatim,quote,ragged-right]
931 \relative c'' {
932   <<
933     \new Staff \with {
934       instrumentName = #"Alto Flute in G"
935       shortInstrumentName = #"Flt."
936     }
937     {
938       f2 g4 f \break
939       g4 f g2
940     }
941     \new Staff \with {
942       instrumentName = #"Clarinet"
943       shortInstrumentName = #"Clar."
944     }
945     {
946       c,4 b c2 \break
947       c2 b4 c
948     }
949   >>
950 }
951
952 \layout {
953   indent = 3.0\cm
954   short-indent = 1.5\cm
955 }
956 @end lilypond
957
958 @cindex instrument names, adding to other contexts
959
960 To add instrument names to other contexts (such as @code{ChordNames} or
961 @code{FiguredBass}), @code{Instrument_name_engraver} must be added to
962 that context.  For details, see @ref{Modifying context plug-ins}.
963
964 @cindex instrument names, changing
965 @cindex changing instrument names
966
967 The @code{shortInstrumentName} may be changed in the middle of a piece.
968 However, only the first instance of @code{instrumentName} will be
969 printed and subsequent changes will be ignored:
970
971 @lilypond[verbatim,quote,ragged-right,relative=1]
972 \new Staff \with {
973   instrumentName = #"Flute"
974   shortInstrumentName = #"Flt."
975 }
976 {
977   c1 c c c \break
978   c1 c c c \break
979   \set Staff.instrumentName = #"Clarinet"
980   \set Staff.shortInstrumentName = #"Clt."
981   c1 c c c \break
982   c1 c c c \break
983 }
984 @end lilypond
985
986 @cindex instrument switch
987 @cindex switching instruments
988
989 @funindex \addInstrumentDefinition
990 @funindex addInstrumentDefinition
991 @funindex \instrumentSwitch
992 @funindex instrumentSwitch
993
994 If an instrument @emph{switch} is needed,
995 @code{\addInstrumentDefinition} may be used in combination with
996 @code{\instrumentSwitch} to create a detailed list of the
997 necessary changes for the switch.  The
998 @code{\addInstrumentDefinition} command has two arguments: an
999 identifying string, and an association list of context properties
1000 and values to be used for the instrument.  It must be placed in
1001 the toplevel scope.  @code{\instrumentSwitch} is used in the music
1002 expression to declare the instrument switch:
1003
1004 @lilypond[verbatim,quote,ragged-right]
1005 \addInstrumentDefinition #"contrabassoon"
1006   #`((instrumentTransposition . ,(ly:make-pitch -1 0 0))
1007      (shortInstrumentName . "Cbsn.")
1008      (clefGlyph . "clefs.F")
1009      (middleCPosition . 6)
1010      (clefPosition . 2)
1011      (instrumentCueName . ,(make-bold-markup "cbsn."))
1012      (midiInstrument . "bassoon"))
1013
1014 \new Staff \with {
1015   instrumentName = #"Bassoon"
1016 }
1017 \relative c' {
1018   \clef tenor
1019   \compressFullBarRests
1020   c2 g'
1021   R1*16
1022   \instrumentSwitch "contrabassoon"
1023   c,,2 g \break
1024   c,1 ~ | c1
1025 }
1026 @end lilypond
1027
1028 @seealso
1029 Notation Reference:
1030 @ref{\paper variables for shifts and indents},
1031 @ref{Modifying context plug-ins}.
1032
1033 Snippets:
1034 @rlsr{Staff notation}.
1035
1036 Internals Reference:
1037 @rinternals{InstrumentName},
1038 @rinternals{PianoStaff},
1039 @rinternals{Staff}.
1040
1041
1042 @node Quoting other voices
1043 @unnumberedsubsubsec Quoting other voices
1044
1045 @cindex quote, voices
1046 @cindex voices, quoting
1047 @cindex fragments, quoting
1048 @cindex cue notes
1049
1050 @funindex \addQuote
1051 @funindex addQuote
1052 @funindex \quoteDuring
1053 @funindex quoteDuring
1054 @funindex \transposition
1055 @funindex transposition
1056
1057 It is very common for one voice to use the same notes as those from
1058 another voice.  For example, first and second violins playing the same
1059 phrase during a particular passage of the music.  This is done by
1060 letting one voice @emph{quote} the other, without having to re-enter the
1061 music all over again for the second voice.
1062
1063 The @code{\addQuote} command, used in the top level scope, defines a
1064 stream of music from which fragments can be quoted.
1065
1066 The @code{\quoteDuring} command is used to indicate the point where the
1067 quotation begins.  It is followed by two arguments: the name of the
1068 quoted voice, as defined with @code{\addQuote}, and a music expression
1069 for the duration of the quote.
1070
1071 @lilypond[verbatim,quote]
1072 fluteNotes = \relative c'' {
1073   a4 gis g gis | b4^"quoted" r8 ais\p a4( f)
1074 }
1075
1076 oboeNotes = \relative c'' {
1077   c4 cis c b \quoteDuring #"flute" { s1 }
1078 }
1079
1080 \addQuote "flute" { \fluteNotes }
1081
1082 \score {
1083   <<
1084     \new Staff \with { instrumentName = "Flute" } \fluteNotes
1085     \new Staff \with { instrumentName = "Oboe" } \oboeNotes
1086   >>
1087 }
1088 @end lilypond
1089
1090 If the music expression used in @code{\quoteDuring} contains notes
1091 instead of spacer or multimeasure rests then the quote will appear as
1092 polyphony and may produce unexpected results.
1093
1094 @lilypond[verbatim,quote]
1095 fluteNotes = \relative c'' {
1096   a4 gis g gis | b4^"quoted" r8 ais\p a4( f)
1097 }
1098
1099 oboeNotes = \relative c'' {
1100   c4 cis c b \quoteDuring #"flute" { e4 r8 ais b4 a }
1101 }
1102
1103 \addQuote "flute" { \fluteNotes }
1104
1105 \score {
1106   <<
1107     \new Staff \with { instrumentName = "Flute" } \fluteNotes
1108     \new Staff \with { instrumentName = "Oboe" } \oboeNotes
1109   >>
1110 }
1111 @end lilypond
1112
1113 The @code{\quoteDuring} command uses the @code{\transposition} settings
1114 of both quoted and quoting parts to produce notes for the quoting part
1115 that have the same sounding pitch as those in the quoted part.
1116
1117 @lilypond[verbatim,quote]
1118 clarinetNotes = \relative c'' {
1119   \transposition bes
1120   \key d \major
1121   b4 ais a ais | cis4^"quoted" r8 bis\p b4( f)
1122 }
1123
1124 oboeNotes = \relative c'' {
1125   c4 cis c b \quoteDuring #"clarinet" { s1 }
1126 }
1127
1128 \addQuote "clarinet" { \clarinetNotes }
1129
1130
1131 \score {
1132   <<
1133     \new Staff \with { instrumentName = "Clarinet" } \clarinetNotes
1134     \new Staff \with { instrumentName = "Oboe" } \oboeNotes
1135   >>
1136 }
1137 @end lilypond
1138
1139 @cindex note-event
1140 @cindex articulation-event
1141 @cindex dynamic-event
1142 @cindex rest-event
1143 @cindex slur-event
1144 @cindex crescendo-event
1145
1146 @funindex quotedEventTypes
1147 @funindex quotedCueEventTypes
1148
1149 By default quoted music will include all articulations, dynamics,
1150 markups, etc., in the quoted expression.  It is possible to choose which
1151 of these objects from the quoted music are displayed by using the
1152 @code{quotedEventTypes} context property.
1153
1154 @lilypond[verbatim,quote]
1155 fluteNotes = \relative c'' {
1156   a2 g2 |
1157   b4\<^"quoted" r8 ais a4\f( c->)
1158  }
1159
1160 oboeNotes = \relative c'' {
1161   c2. b4 |
1162   \quoteDuring #"flute" { s1 }
1163 }
1164
1165 \addQuote "flute" { \fluteNotes }
1166
1167 \score {
1168   <<
1169     \set Score.quotedEventTypes = #'(note-event articulation-event
1170                                      crescendo-event rest-event
1171                                      slur-event dynamic-event)
1172     \new Staff \with { instrumentName = "Flute" } \fluteNotes
1173     \new Staff \with { instrumentName = "Oboe" } \oboeNotes
1174   >>
1175  }
1176 @end lilypond
1177
1178 Quotes can also be tagged, see @ref{Using tags}.
1179
1180 @seealso
1181 Notation Reference:
1182 @ref{Instrument transpositions},
1183 @ref{Using tags}.
1184
1185 Installed Files:
1186 @file{scm/define-event-classes.scm}.
1187
1188 Snippets:
1189 @rlsr{Staff notation}.
1190
1191 Internals Reference:
1192 @rinternals{Music classes},
1193 @rinternals{QuoteMusic},
1194 @rinternals{Voice}.
1195
1196 @knownissues
1197 Only the contents of the first @code{Voice} occurring in an
1198 @code{\addQuote} command will be considered for quotation, so if the music
1199 expression contains @code{\new} or @code{\context Voice}
1200 statements, their contents will not be quoted.  Quoting grace notes
1201 is unsupported and may cause LilyPond to crash whereas quoting nested
1202 triplets may result in poor notation.
1203
1204
1205 @node Formatting cue notes
1206 @unnumberedsubsubsec Formatting cue notes
1207
1208 @cindex cue notes
1209 @cindex fragments
1210 @cindex cue notes, formatting
1211 @cindex formatting, cue notes
1212 @cindex voices, quoting
1213
1214
1215 @funindex \cueDuring
1216 @funindex cueDuring
1217 @funindex \cueClef
1218 @funindex cueClef
1219 @funindex \cueDuringWithClef
1220 @funindex cueDuringWithClef
1221 @funindex \quoteDuring
1222 @funindex quoteDuring
1223
1224 @cindex notes, smaller
1225 @cindex smaller notes
1226 @cindex CueVoice
1227
1228 The simplest way to format cue notes is to explicitly create a
1229 @code{CueVoice} context within the part.
1230
1231 @lilypond[verbatim,relative=1]
1232 R1
1233 <<
1234   { e2\rest r4. e8 }
1235   \new CueVoice {
1236     \stemUp d'8^"flute" c d e fis2
1237   }
1238 >>
1239 d,4 r a r
1240 @end lilypond
1241
1242 The @code{\cueClef} command can also be used with an explict
1243 @code{CueVoice} context if a change of clef is required and will print
1244 an appropriately sized clef for the cue notes.  The @code{\cueClefUnset}
1245 command can then be used to switch back to the original clef, again with
1246 an appropriately sized clef.
1247
1248 @lilypond[verbatim,noragged-right,relative=1]
1249 \clef "bass"
1250 R1
1251 <<
1252   { e2\rest r4. \cueClefUnset e,8 }
1253   \new CueVoice {
1254     \cueClef "treble" \stemUp d''8^"flute" c d e fis2
1255   }
1256 >>
1257 d,,4 r a r
1258 @end lilypond
1259
1260 The @code{\cueClef} and @code{\cueClefUnset} command can also be used
1261 without a @code{CueVoice} if required.
1262
1263 @lilypond[verbatim,noragged-right,relative=1]
1264 \clef "bass"
1265 R1
1266 \cueClef "treble"
1267 d'8^"flute" c d e fis2
1268 \cueClefUnset
1269 d,,4 r a r
1270 @end lilypond
1271
1272 For more complex cue note placement, e.g including transposition, or
1273 inserting cue notes from multiple music sources the @code{\cueDuring} or
1274 @code{\cueDuringWithClef} commands can be used.  These are more
1275 specialized form of @code{\quoteDuring}, see @ref{Quoting other voices}
1276 in the previous section.
1277
1278 The syntax is:
1279
1280 @example
1281 \cueDuring #@var{quotename} #@var{direction} #@var{music}
1282 @end example
1283
1284 and
1285
1286 @example
1287 \cueDuringWithClef #@var{quotename} #@var{direction} #@var{clef} #@var{music}
1288 @end example
1289
1290 The music from the corresponding measures of the @code{@var{quote name}}
1291 is added as a @code{CueVoice} context and occurs simultaneously with the
1292 @code{@var{music}}, which then creates a polyphonic situation.  The
1293 @code{@var{direction}} takes the argument @code{UP} or @code{DOWN}, and
1294 corresponds to the first and second voices respectively, determining how
1295 the cue notes are printed in relation to the other voice.
1296
1297 @lilypond[verbatim,quote]
1298 fluteNotes = \relative c'' {
1299   r2. c4 | d8 c d e fis2 | g2 d |
1300 }
1301
1302 oboeNotes = \relative c'' {
1303   R1
1304   \new CueVoice { \set instrumentCueName = "flute" }
1305   \cueDuring #"flute" #UP { R1 }
1306   g2 c,
1307 }
1308
1309 \addQuote "flute" { \fluteNotes }
1310
1311 \new Staff {
1312   \oboeNotes
1313 }
1314 @end lilypond
1315
1316 @noindent
1317
1318
1319 It is possible to adjust which aspects of the music are quoted with
1320 @code{\cueDuring} by setting the @code{quotedCueEventTypes}
1321 property.  Its default value is @code{'(note-event rest-event
1322 tie-event beam-event tuplet-span-event)}, which means that only
1323 notes, rests, ties, beams and tuplets are quoted, but not
1324 articulations, dynamic marks, markup etc.
1325
1326 @warning{When a @code{Voice} starts with @code{\cueDuring}, as in the
1327 following example, the @code{Voice} context must be explicitly declared,
1328 or else the entire music expression would belong to the @code{CueVoice}
1329 context.}
1330
1331 @lilypond[verbatim,quote]
1332 oboeNotes = \relative c'' {
1333   r2 r8 d16(\f f e g f a)
1334   g8 g16 g g2.
1335 }
1336 \addQuote "oboe" { \oboeNotes }
1337
1338 \new Voice \relative c'' {
1339   \set Score.quotedCueEventTypes = #'(note-event rest-event tie-event
1340                                       beam-event tuplet-span-event
1341                                       dynamic-event slur-event)
1342   \cueDuring #"oboe" #UP { R1 }
1343   g2 c,
1344 }
1345 @end lilypond
1346
1347 The name of the instrument playing the cue can be printed by setting
1348 the @code{instrumentCueName} property in a temporary @code{CueVoice}
1349 context.  The placement and style of the @code{instrumentCueName} is
1350 controlled by the @code{\instrumentSwitch} object, see
1351 @ref{Instrument names}.  If the cue notes require a change in clef,
1352 this can be done manually but the original clef should also be
1353 restored manually at the end of the cue notes.
1354
1355 @lilypond[verbatim,quote]
1356 fluteNotes = \relative c'' {
1357   r2. c4 d8 c d e fis2 g2 d2
1358 }
1359
1360 bassoonNotes = \relative c {
1361   \clef bass
1362   R1
1363   \clef treble
1364   \new CueVoice { \set instrumentCueName = "flute" }
1365   \cueDuring #"flute" #UP { R1 }
1366   \clef bass
1367   g4. b8 d2
1368 }
1369
1370 \addQuote "flute" { \fluteNotes }
1371
1372 \new Staff {
1373   \bassoonNotes
1374 }
1375 @end lilypond
1376
1377 Alternatively, the @code{\cueDuringWithClef} function can be used
1378 instead.  This command takes an extra argument to specify the change of
1379 clef that needs to be printed for the cue notes but will automatically
1380 print the original clef once the cue notes have finished.
1381
1382 @lilypond[verbatim,quote]
1383 fluteNotes = \relative c'' {
1384   r2. c4 d8 c d e fis2 g2 d2
1385 }
1386
1387 bassoonNotes = \relative c {
1388   \clef bass
1389   R1
1390   \new CueVoice { \set instrumentCueName = "flute" }
1391   \cueDuringWithClef #"flute" #UP #"treble" { R1 }
1392   g4. b8 d2
1393 }
1394
1395 \addQuote "flute" { \fluteNotes }
1396
1397 \new Staff {
1398   \bassoonNotes
1399 }
1400 @end lilypond
1401
1402 @funindex \transposedCueDuring
1403 @funindex transposedCueDuring
1404
1405 Like @code{\quoteDuring}, @code{\cueDuring} takes instrument
1406 transpositions into account.  Cue notes are produced at the
1407 pitches that would be written for the instrument receiving the cue
1408 to produce the sounding pitches of the source instrument.
1409
1410 To transpose cue notes differently, use
1411 @code{\transposedCueDuring}.  This command takes an extra argument
1412 to specify (in absolute mode) the printed pitch that you want to
1413 represent the sound of a concert middle C.  This is useful for
1414 taking cues from an instrument in a completely different register.
1415
1416 @lilypond[verbatim,quote]
1417 piccoloNotes = \relative c''' {
1418   \clef "treble^8"
1419   R1
1420   c8 c c e g2
1421   c4 g g2
1422 }
1423
1424 bassClarinetNotes = \relative c' {
1425   \key d \major
1426   \transposition bes,
1427   d4 r a r
1428   \transposedCueDuring #"piccolo" #UP d { R1 }
1429   d4 r a r
1430 }
1431
1432 \addQuote "piccolo" { \piccoloNotes }
1433
1434 <<
1435   \new Staff \piccoloNotes
1436   \new Staff \bassClarinetNotes
1437 >>
1438 @end lilypond
1439
1440 @cindex removing cue notes
1441 @cindex cue notes, removing
1442
1443 @funindex \killCues
1444 @funindex killCues
1445 @funindex \addInstrumentDefinition
1446 @funindex addInstrumentDefinition
1447
1448 The @code{\killCues} command removes cue notes from a music
1449 expression, so the same music expression can be used to produce
1450 the instrument part with cues and the score.  The @code{\killCues}
1451 command removes only the notes and events that were quoted by
1452 @code{\cueDuring}.  Other markup associated with cues, such as clef
1453 changes and a label identifying the source instrument, can be
1454 tagged for selective inclusion in the score; see @ref{Using tags}.
1455
1456 @lilypond[verbatim,quote]
1457 fluteNotes = \relative c'' {
1458   r2. c4 d8 c d e fis2 g2 d2
1459 }
1460
1461 bassoonNotes = \relative c {
1462   \clef bass
1463   R1
1464   \tag #'part {
1465     \clef treble
1466     \new CueVoice { \set instrumentCueName = "flute" }
1467   }
1468   \cueDuring #"flute" #UP { R1 }
1469   \tag #'part \clef bass
1470   g4. b8 d2
1471 }
1472
1473 \addQuote "flute" { \fluteNotes }
1474
1475 \new Staff {
1476   \bassoonNotes
1477 }
1478
1479 \new StaffGroup <<
1480   \new Staff {
1481     \fluteNotes
1482   }
1483   \new Staff {
1484     \removeWithTag #'part { \killCues { \bassoonNotes } }
1485   }
1486 >>
1487 @end lilypond
1488
1489 Alternatively, Clef changes and instrument labels can be
1490 collected into an instrument definition for repeated use, using
1491 @code{\addInstrumentDefinition} described in @ref{Instrument names}.
1492
1493 @seealso
1494 Notation Reference:
1495 @ref{Quoting other voices},
1496 @ref{Instrument transpositions},
1497 @ref{Instrument names},
1498 @ref{Clef},
1499 @ref{Musical cues},
1500 @ref{Using tags}.
1501
1502 Snippets:
1503 @rlsr{Staff notation}.
1504
1505 Internals Reference:
1506 @rinternals{CueVoice},
1507 @rinternals{Voice}.
1508
1509 @knownissues
1510 Collisions can occur with rests, when using @code{\cueDuring},
1511 between @code{Voice} and @code{CueVoice} contexts.  When using
1512 @code{\cueDuringWithClef} or @code{\transposedCueDuring} the extra
1513 argument required for each case must come after the quote and the
1514 direction.
1515