]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/notation/staff.itely
7093338b967912d3f394234106074cc7932c0356
[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.14.0"
11
12 @node Staff notation
13 @section Staff notation
14
15 @lilypondfile[quote]{staff-headword.ly}
16
17 This section explains how to influence the appearance of staves,
18 how to print scores with more than one staff, and how to add tempo
19 indications and cue notes to staves.
20
21 @menu
22 * Displaying staves::
23 * Modifying single staves::
24 * Writing parts::
25 @end menu
26
27
28 @node Displaying staves
29 @subsection Displaying staves
30
31 This section describes the different methods of creating and
32 grouping staves.
33
34 @menu
35 * Instantiating new staves::
36 * Grouping staves::
37 * Nested staff groups::
38 * Separating systems::
39 @end menu
40
41
42 @node Instantiating new staves
43 @unnumberedsubsubsec Instantiating new staves
44
45 @cindex new staff
46 @cindex staff initiation
47 @cindex staff instantiation
48 @cindex staff, new
49 @cindex staff, single
50 @cindex staff, drum
51 @cindex staff, percussion
52 @cindex drum staff
53 @cindex percussion staff
54 @cindex Gregorian transcription staff
55 @cindex rhythmic staff
56 @cindex tabstaff
57 @cindex tablature
58
59 @funindex \drummode
60 @funindex drummode
61 @funindex DrumStaff
62 @funindex RhythmicStaff
63 @funindex TabStaff
64 @funindex MensuralStaff
65 @funindex VaticanaStaff
66 @funindex GregorianTranscriptionStaff
67
68 @notation{Staves} (singular: @notation{staff}) are created with
69 the @code{\new} or @code{\context} commands.  For details, see
70 @ref{Creating contexts}.
71
72 The basic staff context is @code{Staff}:
73
74 @lilypond[verbatim,quote,relative=2]
75 \new Staff { c4 d e f }
76 @end lilypond
77
78 The @code{DrumStaff} context creates a five-line staff set up for
79 a typical drum set.  Each instrument is shown with a different
80 symbol.  The instruments are entered in drum mode following a
81 @code{\drummode} command, with each instrument specified by name.
82 For details, see @ref{Percussion staves}.
83
84 @lilypond[verbatim,quote]
85 \new DrumStaff {
86   \drummode { cymc hh ss tomh }
87 }
88 @end lilypond
89
90 @code{RhythmicStaff} creates a single-line staff that only
91 displays the rhythmic values of the input.  Real durations are
92 preserved.  For details, see @ref{Showing melody rhythms}.
93
94 @lilypond[verbatim,quote,relative=2]
95 \new RhythmicStaff { c4 d e f }
96 @end lilypond
97
98 @code{TabStaff} creates a tablature with six strings in standard
99 guitar tuning.  For details, see @ref{Default tablatures}.
100
101 @lilypond[verbatim,quote,relative=2]
102 \new TabStaff { c4 d e f }
103 @end lilypond
104
105 There are two staff contexts specific for the notation of ancient
106 music: @code{MensuralStaff} and @code{VaticanaStaff}.  They are
107 described in @ref{Pre-defined contexts}.
108
109 The @code{GregorianTranscriptionStaff} context creates a staff to
110 notate modern Gregorian chant.  It does not show bar lines.
111
112 @lilypond[verbatim,quote,relative=2]
113 \new GregorianTranscriptionStaff { c4 d e f e d }
114 @end lilypond
115
116 New single staff contexts may be defined.  For details, see
117 @ref{Defining new contexts}.
118
119
120 @seealso
121 Music Glossary:
122 @rglos{staff},
123 @rglos{staves}.
124
125 Notation Reference:
126 @ref{Creating contexts},
127 @ref{Percussion staves},
128 @ref{Showing melody rhythms},
129 @ref{Default tablatures},
130 @ref{Pre-defined contexts},
131 @ref{Staff symbol},
132 @ref{Gregorian chant contexts},
133 @ref{Mensural contexts},
134 @ref{Defining new contexts}.
135
136 Snippets:
137 @rlsr{Staff notation}.
138
139 Internals Reference:
140 @rinternals{Staff},
141 @rinternals{DrumStaff},
142 @rinternals{GregorianTranscriptionStaff},
143 @rinternals{RhythmicStaff},
144 @rinternals{TabStaff},
145 @rinternals{MensuralStaff},
146 @rinternals{VaticanaStaff},
147 @rinternals{StaffSymbol}.
148
149
150 @node Grouping staves
151 @unnumberedsubsubsec Grouping staves
152
153 @cindex start of system
154 @cindex staff, multiple
155 @cindex staves, multiple
156 @cindex system start delimiters
157 @cindex bracket, vertical
158 @cindex brace, vertical
159 @cindex choir staff
160 @cindex grand staff
161 @cindex piano staff
162 @cindex staff group
163 @cindex staff, choir
164 @cindex staff, piano
165 @cindex staff, grand
166 @cindex system
167
168 Various contexts exist to group single staves together in order to
169 form multi-stave systems.  Each grouping context sets the style of
170 the system start delimiter and the behavior of bar lines.
171
172 If no context is specified, the default properties will be used:
173 the group is started with a vertical line, and the bar lines are
174 not connected.
175
176 @lilypond[verbatim,quote,relative=2]
177 <<
178   \new Staff { c1 c }
179   \new Staff { c1 c }
180 >>
181 @end lilypond
182
183 In the @code{StaffGroup} context, the group is started with a
184 bracket and bar lines are drawn through all the staves.
185
186 @lilypond[verbatim,quote,relative=2]
187 \new StaffGroup <<
188   \new Staff { c1 c }
189   \new Staff { c1 c }
190 >>
191 @end lilypond
192
193 In a @code{ChoirStaff}, the group starts with a bracket, but bar
194 lines are not connected.
195
196 @lilypond[verbatim,quote,relative=2]
197 \new ChoirStaff <<
198   \new Staff { c1 c }
199   \new Staff { c1 c }
200 >>
201 @end lilypond
202
203 In a @code{GrandStaff}, the group begins with a brace, and bar
204 lines are connected between the staves.
205
206 @lilypond[verbatim,quote,relative=2]
207 \new GrandStaff <<
208   \new Staff { c1 c }
209   \new Staff { c1 c }
210 >>
211 @end lilypond
212
213 The @code{PianoStaff} is identical to a @code{GrandStaff}, except
214 that it supports printing the instrument name directly.  For
215 details, see @ref{Instrument names}.
216
217 @lilypond[verbatim,quote,relative=2]
218 \new PianoStaff <<
219   \set PianoStaff.instrumentName = #"Piano"
220   \new Staff { c1 c }
221   \new Staff { c1 c }
222 >>
223 @end lilypond
224
225 Each staff group context sets the property
226 @code{systemStartDelimiter} to one of the following values:
227 @code{SystemStartBar}, @code{SystemStartBrace}, or
228 @code{SystemStartBracket}.  A fourth delimiter,
229 @code{SystemStartSquare}, is also available, but it must be
230 explicitly specified.
231
232 New staff group contexts may be defined.  For details, see
233 @ref{Defining new contexts}.
234
235
236 @snippets
237
238 @lilypondfile[verbatim,quote,texidoc,doctitle]
239 {use-square-bracket-at-the-start-of-a-staff-group.ly}
240
241 @lilypondfile[verbatim,quote,texidoc,doctitle]
242 {display-bracket-with-only-one-staff-in-a-system.ly}
243
244 @cindex mensurstriche layout
245 @cindex renaissance music
246 @cindex transcription of mensural music
247 @cindex mensural music, transcription of
248
249 @lilypondfile[verbatim,quote,texidoc,doctitle]
250 {mensurstriche-layout-bar-lines-between-the-staves.ly}
251
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
322 @seealso
323 Notation Reference:
324 @ref{Grouping staves},
325 @ref{Instrument names},
326 @ref{Defining new contexts}.
327
328 Snippets:
329 @rlsr{Staff notation}.
330
331 Internals Reference:
332 @rinternals{StaffGroup},
333 @rinternals{ChoirStaff},
334 @rinternals{SystemStartBar},
335 @rinternals{SystemStartBrace},
336 @rinternals{SystemStartBracket},
337 @rinternals{SystemStartSquare}.
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
701 @seealso
702 Music Glossary:
703 @rglos{ossia},
704 @rglos{staff},
705 @rglos{Frenched staff}.
706
707 Learning Manual:
708 @rlearning{Nesting music expressions},
709 @rlearning{Size of objects},
710 @rlearning{Length and thickness of objects}.
711
712 Notation Reference:
713 @ref{Hiding staves}.
714
715 Snippets:
716 @rlsr{Staff notation}.
717
718 Internals Reference:
719 @rinternals{StaffSymbol}.
720
721
722 @node Hiding staves
723 @unnumberedsubsubsec Hiding staves
724
725 @cindex Frenched score
726 @cindex Frenched staff
727 @cindex staff, hiding
728 @cindex staff, empty
729 @cindex hiding of staves
730 @cindex empty staves
731
732 @funindex \RemoveEmptyStaves
733 @funindex Staff_symbol_engraver
734 @funindex \stopStaff
735 @funindex stopStaff
736
737
738 Staff lines can be hidden by removing the
739 @code{Staff_symbol_engraver} from the @code{Staff} context.  As an
740 alternative, @code{\stopStaff} may be used.
741
742 @lilypond[verbatim,quote]
743 \new Staff \with {
744   \remove "Staff_symbol_engraver"
745 }
746 \relative c''' { a8 f e16 d c b a2 }
747 @end lilypond
748
749
750 Empty staves can be hidden by setting the
751 @code{\Staff \RemoveEmptyStaves} command in the @code{\layout}
752 block.  In orchestral scores, this style is known as @q{Frenched
753 Score}.  By default, this command hides and removes all empty
754 staves in a score except for those in the first system.
755
756 @warning{A staff is considered empty when it contains only
757 multi-measure rests, rests, skips, spacer rests, or a combination of these
758 elements.}
759
760 @lilypond[verbatim,quote,ragged-right]
761 \layout {
762   \context {
763     \Staff \RemoveEmptyStaves
764   }
765 }
766
767 \relative c' <<
768   \new Staff {
769     e4 f g a \break
770     b1 \break
771     a4 b c2
772   }
773   \new Staff {
774     c,4 d e f \break
775     R1 \break
776     f4 g c,2
777   }
778 >>
779 @end lilypond
780
781 @cindex ossia
782
783 @noindent
784 @code{\Staff \RemoveEmptyStaves} can also be used to create ossia
785 sections for a staff.  For details, see @ref{Ossia staves}.
786
787 @cindex hiding ancient staves
788 @cindex hiding rhythmic staves
789
790 @funindex \RemoveEmptyStaves
791
792 The @code{\VaticanaStaff \RemoveEmptyStaves} command may be used to
793 hide empty staves in ancient music contexts.  Similarly,
794 @code{\RhythmicStaff \RemoveEmptyStaves} may be used to hide empty
795 @code{RhythmicStaff} contexts.
796
797
798 @predefined
799 @code{\Staff \RemoveEmptyStaves},
800 @code{\VaticanaStaff \RemoveEmptyStaves},
801 @code{\RhythmicStaff \RemoveEmptyStaves}.
802 @endpredefined
803
804
805 @snippets
806
807 @lilypondfile[verbatim,quote,texidoc,doctitle]
808 {removing-the-first-empty-line.ly}
809
810
811 @seealso
812 Music Glossary:
813 @rglos{Frenched staff}.
814
815 Learning Manual:
816 @rlearning{Visibility and color of objects}.
817
818 Notation Reference:
819 @ref{Changing context default settings},
820 @ref{Staff symbol},
821 @ref{Ossia staves},
822 @ref{Hidden notes},
823 @ref{Invisible rests},
824 @ref{Visibility of objects}.
825
826 Snippets:
827 @rlsr{Staff notation}.
828
829 Internals Reference:
830 @rinternals{ChordNames},
831 @rinternals{FiguredBass},
832 @rinternals{Lyrics},
833 @rinternals{Staff},
834 @rinternals{VerticalAxisGroup},
835 @rinternals{Staff_symbol_engraver}.
836
837
838 @knownissues
839
840 Removing @code{Staff_symbol_engraver} also hides bar lines.  If
841 bar line visibility is forced, formatting errors may occur.  In
842 this case, use the following overrides instead of removing the
843 engraver:
844
845 @example
846 \override StaffSymbol #'stencil = ##f
847 \override NoteHead #'no-ledgers = ##t
848 @end example
849
850 For the Known issues and warnings associated with
851 @code{\Staff \RemoveEmptyStaves} see
852 @ref{Changing context default settings}.
853
854 @node Writing parts
855 @subsection Writing parts
856
857 This section explains how to insert tempo indications and
858 instrument names into a score.  Methods to quote other voices and
859 format cue notes are also described.
860
861 @menu
862 * Instrument names::
863 * Quoting other voices::
864 * Formatting cue notes::
865 @end menu
866
867 @node Instrument names
868 @unnumberedsubsubsec Instrument names
869
870 @cindex instrument names
871 @cindex instrument names, short
872
873 Instrument names can be printed on the left side of staves in the
874 @code{Staff}, @code{PianoStaff}, @code{StaffGroup}, @code{GrandStaff}
875 and @code{ChoirStaff} contexts.  The value of
876 @code{instrumentName} is used for the first staff, and the value
877 of @code{shortInstrumentName} is used for all succeeding staves.
878
879 @lilypond[verbatim,quote,ragged-right,relative=1]
880 \new Staff \with {
881   instrumentName = #"Violin "
882   shortInstrumentName = #"Vln. "
883 }
884 { c4.. g'16 c4.. g'16 \break | c1 }
885 @end lilypond
886
887 @cindex instrument names, complex
888
889 @code{\markup} can be used to create more complex instrument names:
890
891 @lilypond[verbatim,quote,relative=2]
892 \new Staff \with {
893   instrumentName = \markup {
894     \column { "Clarinetti"
895       \line { "in B" \smaller \flat }
896     }
897   }
898 }
899 { c4 c,16 d e f g2 }
900 @end lilypond
901
902 @cindex instrument names, centering
903
904 When two or more staff contexts are grouped together, the instrument
905 names and short instrument names are centered by default.  To center
906 multi-line instrument names, @code{\center-column} must be used:
907
908 @lilypond[verbatim,quote,indent=1.5\cm,relative=2]
909 <<
910   \new Staff \with {
911     instrumentName = #"Flute"
912   }
913   { f2 g4 f }
914   \new Staff \with {
915     instrumentName = \markup {
916       \center-column { "Clarinet" }
917       \line { "in B" \smaller \flat }
918     }
919   }
920   { c4 b c2 }
921 >>
922 @end lilypond
923
924 @funindex indent
925 @funindex short-indent
926
927 However, if the instrument names are longer, the instrument names in a
928 staff group may not be centered unless the @code{indent} and
929 @code{short-indent} settings are increased.  For details about these
930 settings, see @ref{\paper variables for shifts and indents}.
931
932 @lilypond[verbatim,quote,ragged-right]
933 \relative c'' {
934   <<
935     \new Staff \with {
936       instrumentName = #"Alto Flute in G"
937       shortInstrumentName = #"Flt."
938     }
939     {
940       f2 g4 f \break
941       g4 f g2
942     }
943     \new Staff \with {
944       instrumentName = #"Clarinet"
945       shortInstrumentName = #"Clar."
946     }
947     {
948       c,4 b c2 \break
949       c2 b4 c
950     }
951   >>
952 }
953
954 \layout {
955   indent = 3.0\cm
956   short-indent = 1.5\cm
957 }
958 @end lilypond
959
960 @cindex instrument names, adding to other contexts
961
962 To add instrument names to other contexts (such as @code{ChordNames} or
963 @code{FiguredBass}), @code{Instrument_name_engraver} must be added to
964 that context.  For details, see @ref{Modifying context plug-ins}.
965
966 @cindex instrument names, changing
967 @cindex changing instrument names
968
969 The @code{shortInstrumentName} may be changed in the middle of a piece.
970 However, only the first instance of @code{instrumentName} will be
971 printed and subsequent changes will be ignored:
972
973 @lilypond[verbatim,quote,ragged-right,relative=1]
974 \new Staff \with {
975   instrumentName = #"Flute"
976   shortInstrumentName = #"Flt."
977 }
978 {
979   c1 c c c \break
980   c1 c c c \break
981   \set Staff.instrumentName = #"Clarinet"
982   \set Staff.shortInstrumentName = #"Clt."
983   c1 c c c \break
984   c1 c c c \break
985 }
986 @end lilypond
987
988 @cindex instrument switch
989 @cindex switching instruments
990
991 @funindex \addInstrumentDefinition
992 @funindex addInstrumentDefinition
993 @funindex \instrumentSwitch
994 @funindex instrumentSwitch
995
996 If an instrument @emph{switch} is needed,
997 @code{\addInstrumentDefinition} may be used in combination with
998 @code{\instrumentSwitch} to create a detailed list of the
999 necessary changes for the switch.  The
1000 @code{\addInstrumentDefinition} command has two arguments: an
1001 identifying string, and an association list of context properties
1002 and values to be used for the instrument.  It must be placed in
1003 the toplevel scope.  @code{\instrumentSwitch} is used in the music
1004 expression to declare the instrument switch:
1005
1006 @lilypond[verbatim,quote,ragged-right]
1007 \addInstrumentDefinition #"contrabassoon"
1008   #`((instrumentTransposition . ,(ly:make-pitch -1 0 0))
1009      (shortInstrumentName . "Cbsn.")
1010      (clefGlyph . "clefs.F")
1011      (middleCPosition . 6)
1012      (clefPosition . 2)
1013      (instrumentCueName . ,(make-bold-markup "cbsn."))
1014      (midiInstrument . "bassoon"))
1015
1016 \new Staff \with {
1017   instrumentName = #"Bassoon"
1018 }
1019 \relative c' {
1020   \clef tenor
1021   \compressFullBarRests
1022   c2 g'
1023   R1*16
1024   \instrumentSwitch "contrabassoon"
1025   c,,2 g \break
1026   c,1 ~ | c1
1027 }
1028 @end lilypond
1029
1030
1031 @seealso
1032 Notation Reference:
1033 @ref{\paper variables for shifts and indents},
1034 @ref{Modifying context plug-ins}.
1035
1036 Snippets:
1037 @rlsr{Staff notation}.
1038
1039 Internals Reference:
1040 @rinternals{InstrumentName},
1041 @rinternals{PianoStaff},
1042 @rinternals{Staff}.
1043
1044
1045 @node Quoting other voices
1046 @unnumberedsubsubsec Quoting other voices
1047
1048 @cindex quote, voices
1049 @cindex voices, quoting
1050 @cindex fragments, quoting
1051 @cindex cue notes
1052
1053 @funindex \addQuote
1054 @funindex addQuote
1055 @funindex \quoteDuring
1056 @funindex quoteDuring
1057 @funindex \transposition
1058 @funindex transposition
1059
1060 It is very common for one voice to use the same notes as those from
1061 another voice.  For example, first and second violins playing the same
1062 phrase during a particular passage of the music.  This is done by
1063 letting one voice @emph{quote} the other, without having to re-enter the
1064 music all over again for the second voice.
1065
1066 The @code{\addQuote} command, used in the top level scope, defines a
1067 stream of music from which fragments can be quoted.
1068
1069 The @code{\quoteDuring} command is used to indicate the point where the
1070 quotation begins.  It is followed by two arguments: the name of the
1071 quoted voice, as defined with @code{\addQuote}, and a music expression
1072 for the duration of the quote.
1073
1074 @lilypond[verbatim,quote]
1075 fluteNotes = \relative c'' {
1076   a4 gis g gis | b4^"quoted" r8 ais\p a4( f)
1077 }
1078
1079 oboeNotes = \relative c'' {
1080   c4 cis c b \quoteDuring #"flute" { s1 }
1081 }
1082
1083 \addQuote "flute" { \fluteNotes }
1084
1085 \score {
1086   <<
1087     \new Staff \with { instrumentName = "Flute" } \fluteNotes
1088     \new Staff \with { instrumentName = "Oboe" } \oboeNotes
1089   >>
1090 }
1091 @end lilypond
1092
1093 If the music expression used in @code{\quoteDuring} contains notes
1094 instead of spacer or multimeasure rests then the quote will appear as
1095 polyphony and may produce unexpected results.
1096
1097 @lilypond[verbatim,quote]
1098 fluteNotes = \relative c'' {
1099   a4 gis g gis | b4^"quoted" r8 ais\p a4( f)
1100 }
1101
1102 oboeNotes = \relative c'' {
1103   c4 cis c b \quoteDuring #"flute" { e4 r8 ais b4 a }
1104 }
1105
1106 \addQuote "flute" { \fluteNotes }
1107
1108 \score {
1109   <<
1110     \new Staff \with { instrumentName = "Flute" } \fluteNotes
1111     \new Staff \with { instrumentName = "Oboe" } \oboeNotes
1112   >>
1113 }
1114 @end lilypond
1115
1116 The @code{\quoteDuring} command uses the @code{\transposition} settings
1117 of both quoted and quoting parts to produce notes for the quoting part
1118 that have the same sounding pitch as those in the quoted part.
1119
1120 @lilypond[verbatim,quote]
1121 clarinetNotes = \relative c'' {
1122   \transposition bes
1123   \key d \major
1124   b4 ais a ais | cis4^"quoted" r8 bis\p b4( f)
1125 }
1126
1127 oboeNotes = \relative c'' {
1128   c4 cis c b \quoteDuring #"clarinet" { s1 }
1129 }
1130
1131 \addQuote "clarinet" { \clarinetNotes }
1132
1133
1134 \score {
1135   <<
1136     \new Staff \with { instrumentName = "Clarinet" } \clarinetNotes
1137     \new Staff \with { instrumentName = "Oboe" } \oboeNotes
1138   >>
1139 }
1140 @end lilypond
1141
1142 @cindex note-event
1143 @cindex articulation-event
1144 @cindex dynamic-event
1145 @cindex rest-event
1146 @cindex slur-event
1147 @cindex crescendo-event
1148
1149 @funindex quotedEventTypes
1150 @funindex quotedCueEventTypes
1151
1152 By default quoted music will include all articulations, dynamics,
1153 markups, etc., in the quoted expression.  It is possible to choose which
1154 of these objects from the quoted music are displayed by using the
1155 @code{quotedEventTypes} context property.
1156
1157 @lilypond[verbatim,quote]
1158 fluteNotes = \relative c'' {
1159   a2 g2 |
1160   b4\<^"quoted" r8 ais a4\f( c->)
1161  }
1162
1163 oboeNotes = \relative c'' {
1164   c2. b4 |
1165   \quoteDuring #"flute" { s1 }
1166 }
1167
1168 \addQuote "flute" { \fluteNotes }
1169
1170 \score {
1171   <<
1172     \set Score.quotedEventTypes = #'(note-event articulation-event
1173                                      crescendo-event rest-event
1174                                      slur-event dynamic-event)
1175     \new Staff \with { instrumentName = "Flute" } \fluteNotes
1176     \new Staff \with { instrumentName = "Oboe" } \oboeNotes
1177   >>
1178  }
1179 @end lilypond
1180
1181 Quotes can also be tagged, see @ref{Using tags}.
1182
1183 @seealso
1184 Notation Reference:
1185 @ref{Instrument transpositions},
1186 @ref{Using tags}.
1187
1188 Snippets:
1189 @rlsr{Staff notation}.
1190
1191 Internals Reference:
1192 @rinternals{Music classes},
1193 @rinternals{QuoteMusic},
1194 @rinternals{Voice}.
1195
1196 Installed Files:
1197 @file{scm/define-event-classes.scm}.
1198
1199
1200 @knownissues
1201 Only the contents of the first @code{Voice} occurring in an
1202 @code{\addQuote} command will be considered for quotation, so if the music
1203 expression contains @code{\new} or @code{\context Voice}
1204 statements, their contents will not be quoted.  Quoting grace notes
1205 is unsupported and may cause LilyPond to crash whereas quoting nested
1206 triplets may result in poor notation.
1207
1208
1209 @node Formatting cue notes
1210 @unnumberedsubsubsec Formatting cue notes
1211
1212 @cindex cue notes
1213 @cindex fragments
1214 @cindex cue notes, formatting
1215 @cindex formatting, cue notes
1216 @cindex voices, quoting
1217
1218
1219 @funindex \cueDuring
1220 @funindex cueDuring
1221 @funindex \cueClef
1222 @funindex cueClef
1223 @funindex \cueDuringWithClef
1224 @funindex cueDuringWithClef
1225 @funindex \quoteDuring
1226 @funindex quoteDuring
1227
1228 @cindex notes, smaller
1229 @cindex smaller notes
1230 @cindex CueVoice
1231
1232 The simplest way to format cue notes is to explicitly create a
1233 @code{CueVoice} context within the part.
1234
1235 @lilypond[verbatim,relative=1]
1236 R1
1237 <<
1238   { e2\rest r4. e8 }
1239   \new CueVoice {
1240     \stemUp d'8^"flute" c d e fis2
1241   }
1242 >>
1243 d,4 r a r
1244 @end lilypond
1245
1246 The @code{\cueClef} command can also be used with an explict
1247 @code{CueVoice} context if a change of clef is required and will print
1248 an appropriately sized clef for the cue notes.  The @code{\cueClefUnset}
1249 command can then be used to switch back to the original clef, again with
1250 an appropriately sized clef.
1251
1252 @lilypond[verbatim,noragged-right,relative=1]
1253 \clef "bass"
1254 R1
1255 <<
1256   { e2\rest r4. \cueClefUnset e,8 }
1257   \new CueVoice {
1258     \cueClef "treble" \stemUp d''8^"flute" c d e fis2
1259   }
1260 >>
1261 d,,4 r a r
1262 @end lilypond
1263
1264 The @code{\cueClef} and @code{\cueClefUnset} command can also be used
1265 without a @code{CueVoice} if required.
1266
1267 @lilypond[verbatim,noragged-right,relative=1]
1268 \clef "bass"
1269 R1
1270 \cueClef "treble"
1271 d'8^"flute" c d e fis2
1272 \cueClefUnset
1273 d,,4 r a r
1274 @end lilypond
1275
1276 For more complex cue note placement, e.g including transposition, or
1277 inserting cue notes from multiple music sources the @code{\cueDuring} or
1278 @code{\cueDuringWithClef} commands can be used.  These are more
1279 specialized form of @code{\quoteDuring}, see @ref{Quoting other voices}
1280 in the previous section.
1281
1282 The syntax is:
1283
1284 @example
1285 \cueDuring #@var{quotename} #@var{direction} #@var{music}
1286 @end example
1287
1288 and
1289
1290 @example
1291 \cueDuringWithClef #@var{quotename} #@var{direction} #@var{clef} #@var{music}
1292 @end example
1293
1294 The music from the corresponding measures of the @code{@var{quote name}}
1295 is added as a @code{CueVoice} context and occurs simultaneously with the
1296 @code{@var{music}}, which then creates a polyphonic situation.  The
1297 @code{@var{direction}} takes the argument @code{UP} or @code{DOWN}, and
1298 corresponds to the first and second voices respectively, determining how
1299 the cue notes are printed in relation to the other voice.
1300
1301 @lilypond[verbatim,quote]
1302 fluteNotes = \relative c'' {
1303   r2. c4 | d8 c d e fis2 | g2 d |
1304 }
1305
1306 oboeNotes = \relative c'' {
1307   R1
1308   s1*0^\markup { \tiny "flute" }
1309   \cueDuring #"flute" #UP { R1 }
1310   g2 c,
1311 }
1312
1313 \addQuote "flute" { \fluteNotes }
1314
1315 \new Staff {
1316   \oboeNotes
1317 }
1318 @end lilypond
1319
1320 @noindent
1321
1322
1323 It is possible to adjust which aspects of the music are quoted with
1324 @code{\cueDuring} by setting the @code{quotedCueEventTypes}
1325 property.  Its default value is @code{'(note-event rest-event
1326 tie-event beam-event tuplet-span-event)}, which means that only
1327 notes, rests, ties, beams and tuplets are quoted, but not
1328 articulations, dynamic marks, markup etc.
1329
1330 @warning{When a @code{Voice} starts with @code{\cueDuring}, as in the
1331 following example, the @code{Voice} context must be explicitly declared,
1332 or else the entire music expression would belong to the @code{CueVoice}
1333 context.}
1334
1335 @lilypond[verbatim,quote]
1336 oboeNotes = \relative c'' {
1337   r2 r8 d16(\f f e g f a)
1338   g8 g16 g g2.
1339 }
1340 \addQuote "oboe" { \oboeNotes }
1341
1342 \new Voice \relative c'' {
1343   \set Score.quotedCueEventTypes = #'(note-event rest-event tie-event
1344                                       beam-event tuplet-span-event
1345                                       dynamic-event slur-event)
1346   \cueDuring #"oboe" #UP { R1 }
1347   g2 c,
1348 }
1349 @end lilypond
1350
1351 Markup can be used to show the name of the quoted instrument.  Also,
1352 if the cue notes require a change in clef, this can be done manually but
1353 the original clef should also be restored manually at the end of the cue
1354 notes.
1355
1356 @lilypond[verbatim,quote]
1357 fluteNotes = \relative c'' {
1358   r2. c4 d8 c d e fis2 g2 d2
1359 }
1360
1361 bassoonNotes = \relative c {
1362   \clef bass
1363   R1
1364   \clef treble
1365   s1*0^\markup { \tiny "flute" }
1366   \cueDuring #"flute" #UP { R1 }
1367   \clef bass
1368   g4. b8 d2
1369 }
1370
1371 \addQuote "flute" { \fluteNotes }
1372
1373 \new Staff {
1374   \bassoonNotes
1375 }
1376 @end lilypond
1377
1378 Alternatively, the @code{\cueDuringWithClef} function can be used
1379 instead.  This command takes an extra argument to specify the change of
1380 clef that needs to be printed for the cue notes but will automatically
1381 print the original clef once the cue notes have finished.
1382
1383 @lilypond[verbatim,quote]
1384 fluteNotes = \relative c'' {
1385   r2. c4 d8 c d e fis2 g2 d2
1386 }
1387
1388 bassoonNotes = \relative c {
1389   \clef bass
1390   R1
1391   s1*0^\markup { \tiny "flute" }
1392   \cueDuringWithClef #"flute" #UP #"treble" { R1 }
1393   g4. b8 d2
1394 }
1395
1396 \addQuote "flute" { \fluteNotes }
1397
1398 \new Staff {
1399   \bassoonNotes
1400 }
1401 @end lilypond
1402
1403 @funindex \transposedCueDuring
1404 @funindex transposedCueDuring
1405
1406 Like @code{\quoteDuring}, @code{\cueDuring} takes instrument
1407 transpositions into account.  Cue notes are produced at the
1408 pitches that would be written for the instrument receiving the cue
1409 to produce the sounding pitches of the source instrument.
1410
1411 To transpose cue notes differently, use
1412 @code{\transposedCueDuring}.  This command takes an extra argument
1413 to specify (in absolute mode) the printed pitch that you want to
1414 represent the sound of a concert middle C.  This is useful for
1415 taking cues from an instrument in a completely different register.
1416
1417 @lilypond[verbatim,quote]
1418 piccoloNotes = \relative c''' {
1419   \clef "treble^8"
1420   R1
1421   c8 c c e g2
1422   c4 g g2
1423 }
1424
1425 bassClarinetNotes = \relative c' {
1426   \key d \major
1427   \transposition bes,
1428   d4 r a r
1429   \transposedCueDuring #"piccolo" #UP d { R1 }
1430   d4 r a r
1431 }
1432
1433 \addQuote "piccolo" { \piccoloNotes }
1434
1435 <<
1436   \new Staff \piccoloNotes
1437   \new Staff \bassClarinetNotes
1438 >>
1439 @end lilypond
1440
1441 @cindex removing cue notes
1442 @cindex cue notes, removing
1443
1444 @funindex \killCues
1445 @funindex killCues
1446 @funindex \addInstrumentDefinition
1447 @funindex addInstrumentDefinition
1448
1449 The @code{\killCues} command removes cue notes from a music
1450 expression, so the same music expression can be used to produce
1451 the instrument part with cues and the score.  The @code{\killCues}
1452 command removes only the notes and events that were quoted by
1453 @code{\cueDuring}.  Other markup associated with cues, such as clef
1454 changes and a label identifying the source instrument, can be
1455 tagged for selective inclusion in the score; see @ref{Using tags}.
1456
1457 @lilypond[verbatim,quote]
1458 fluteNotes = \relative c'' {
1459   r2. c4 d8 c d e fis2 g2 d2
1460 }
1461
1462 bassoonNotes = \relative c {
1463   \clef bass
1464   R1
1465   \tag #'part {
1466     \clef treble
1467     s1*0^\markup { \tiny "flute" }
1468   }
1469   \cueDuring #"flute" #UP { R1 }
1470   \tag #'part \clef bass
1471   g4. b8 d2
1472 }
1473
1474 \addQuote "flute" { \fluteNotes }
1475
1476 \new Staff {
1477   \bassoonNotes
1478 }
1479
1480 \new StaffGroup <<
1481   \new Staff {
1482     \fluteNotes
1483   }
1484   \new Staff {
1485     \removeWithTag #'part { \killCues { \bassoonNotes } }
1486   }
1487 >>
1488 @end lilypond
1489
1490 Alternatively, Clef changes and instrument labels can be
1491 collected into an instrument definition for repeated use, using
1492 @code{\addInstrumentDefinition} described in @ref{Instrument names}.
1493
1494
1495 @seealso
1496 Notation Reference:
1497 @ref{Quoting other voices},
1498 @ref{Instrument transpositions},
1499 @ref{Instrument names},
1500 @ref{Clef},
1501 @ref{Musical cues},
1502 @ref{Using tags}.
1503
1504 Snippets:
1505 @rlsr{Staff notation}.
1506
1507 Internals Reference:
1508 @rinternals{CueVoice},
1509 @rinternals{Voice}.
1510
1511
1512 @knownissues
1513
1514 Collisions can occur with rests, when using @code{\cueDuring},
1515 between @code{Voice} and @code{CueVoice} contexts.  When using
1516 @code{\cueDuringWithClef} or @code{\transposedCueDuring} the extra
1517 argument required for each case must come after the quote and the
1518 direction.
1519