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