Start pictograms branch.
[lilypond/mpolesky.git] / Documentation / notation / staff.itely
blob55bea3c9af6b3b913fd18e6edc5b8109a09427e1
1 @c -*- coding: utf-8; mode: texinfo; -*-
2 @ignore
3     Translation of GIT committish: FILL-IN-HEAD-COMMITTISH
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
10 @c \version "2.12.0"
12 @node Staff notation
13 @section Staff notation
15 @lilypondfile[quote]{staff-headword.ly}
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.
21 @menu
22 * Displaying staves::
23 * Modifying single staves::
24 * Writing parts::
25 @end menu
28 @node Displaying staves
29 @subsection Displaying staves
31 This section describes the different methods of creating and
32 grouping staves.
34 @menu
35 * Instantiating new staves::
36 * Grouping staves::
37 * Nested staff groups::
38 * Separating systems::
39 @end menu
42 @node Instantiating new staves
43 @unnumberedsubsubsec Instantiating new staves
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
59 @funindex \drummode
60 @funindex drummode
61 @funindex DrumStaff
62 @funindex RhythmicStaff
63 @funindex TabStaff
64 @funindex MensuralStaff
65 @funindex VaticanaStaff
66 @funindex GregorianTranscriptionStaff
68 @notation{Staves} (singular: @notation{staff}) are created with
69 the @code{\new} or @code{\context} commands.  For details, see
70 @ref{Creating contexts}.
72 The basic staff context is @code{Staff}:
74 @lilypond[verbatim,quote,relative=2]
75 \new Staff { c4 d e f }
76 @end lilypond
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}.
84 @lilypond[verbatim,quote]
85 \new DrumStaff {
86   \drummode { cymc hh ss tomh }
88 @end lilypond
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}.
94 @lilypond[verbatim,quote,relative=2]
95 \new RhythmicStaff { c4 d e f }
96 @end lilypond
98 @code{TabStaff} creates a tablature with six strings in standard
99 guitar tuning.  For details, see @ref{Default tablatures}.
101 @lilypond[verbatim,quote,relative=2]
102 \new TabStaff { c4 d e f }
103 @end lilypond
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}.
109 The @code{GregorianTranscriptionStaff} context creates a staff to
110 notate modern Gregorian chant.  It does not show bar lines.
112 @lilypond[verbatim,quote,relative=2]
113 \new GregorianTranscriptionStaff { c4 d e f e d }
114 @end lilypond
116 New single staff contexts may be defined.  For details, see
117 @ref{Defining new contexts}.
120 @seealso
121 Music Glossary:
122 @rglos{staff},
123 @rglos{staves}.
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}.
136 Snippets:
137 @rlsr{Staff notation}.
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}.
150 @node Grouping staves
151 @unnumberedsubsubsec Grouping staves
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
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.
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.
176 @lilypond[verbatim,quote,relative=2]
178   \new Staff { c1 c }
179   \new Staff { c1 c }
181 @end lilypond
183 In the @code{StaffGroup} context, the group is started with a
184 bracket and bar lines are drawn through all the staves.
186 @lilypond[verbatim,quote,relative=2]
187 \new StaffGroup <<
188   \new Staff { c1 c }
189   \new Staff { c1 c }
191 @end lilypond
193 In a @code{ChoirStaff}, the group starts with a bracket, but bar
194 lines are not connected.
196 @lilypond[verbatim,quote,relative=2]
197 \new ChoirStaff <<
198   \new Staff { c1 c }
199   \new Staff { c1 c }
201 @end lilypond
203 In a @code{GrandStaff}, the group begins with a brace, and bar
204 lines are connected between the staves.
206 @lilypond[verbatim,quote,relative=2]
207 \new GrandStaff <<
208   \new Staff { c1 c }
209   \new Staff { c1 c }
211 @end lilypond
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}.
217 @lilypond[verbatim,quote,relative=2]
218 \new PianoStaff <<
219   \set PianoStaff.instrumentName = #"Piano"
220   \new Staff { c1 c }
221   \new Staff { c1 c }
223 @end lilypond
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.
232 New staff group contexts may be defined.  For details, see
233 @ref{Defining new contexts}.
236 @snippets
238 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
239 {use-square-bracket-at-the-start-of-a-staff-group.ly}
241 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
242 {display-bracket-with-only-one-staff-in-a-system.ly}
244 @cindex mensurstriche layout
245 @cindex renaissance music
246 @cindex transcription of mensural music
247 @cindex mensural music, transcription of
249 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
250 {mensurstriche-layout-bar-lines-between-the-staves.ly}
253 @seealso
254 Music Glossary:
255 @rglos{brace},
256 @rglos{bracket},
257 @rglos{grand staff}.
259 Notation Reference:
260 @ref{Instrument names},
261 @ref{Defining new contexts}.
263 Snippets:
264 @rlsr{Staff notation}.
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}.
278 @node Nested staff groups
279 @unnumberedsubsubsec Nested staff groups
281 @cindex staff, nested
282 @cindex staves, nested
283 @cindex nesting of staves
284 @cindex system start delimiters, nested
285 @cindex nested staff brackets
286 @cindex brackets, nesting of
287 @cindex braces, nesting of
289 Staff-group contexts can be nested to arbitrary depths.  In this
290 case, each child context creates a new bracket adjacent to the
291 bracket of its parent group.
293 @lilypond[verbatim,quote,relative=2]
294 \new StaffGroup <<
295   \new Staff { c2 c | c2 c }
296   \new StaffGroup <<
297     \new Staff { g2 g | g2 g }
298     \new StaffGroup \with {
299       systemStartDelimiter = #'SystemStartSquare
300     }
301     <<
302       \new Staff { e2 e | e2 e }
303       \new Staff { c2 c | c2 c }
304     >>
305   >>
307 @end lilypond
309 New nested staff group contexts can be defined.  For details, see
310 @ref{Defining new contexts}.
313 @snippets
315 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
316 {nesting-staves.ly}
319 @seealso
320 Notation Reference:
321 @ref{Grouping staves},
322 @ref{Instrument names},
323 @ref{Defining new contexts}.
325 Snippets:
326 @rlsr{Staff notation}.
328 Internals Reference:
329 @rinternals{StaffGroup},
330 @rinternals{ChoirStaff},
331 @rinternals{SystemStartBar},
332 @rinternals{SystemStartBrace},
333 @rinternals{SystemStartBracket},
334 @rinternals{SystemStartSquare}.
336 @node Separating systems
337 @unnumberedsubsubsec Separating systems
339 @cindex system separator mark
341 If the number of systems per page changes from page to page it is
342 customary to separate the systems by placing a system separator mark
343 between them.  By default the system separator is blank, but can be
344 turned on with a @code{\paper} option.
346 @c \book is required here to display the system separator
347 @c ragged-right is required as there are two systems
348 @lilypond[verbatim,quote,ragged-right]
349 \book {
350   \score {
351     \new StaffGroup <<
352       \new Staff {
353         \relative c'' {
354           c4 c c c
355           \break
356           c4 c c c
357         }
358       }
359       \new Staff {
360         \relative c'' {
361           c4 c c c
362           \break
363           c4 c c c
364         }
365       }
366     >>
367   }
368   \paper {
369     system-separator-markup = \slashSeparator
370     % following commands are needed only to format this documentation
371     paper-width = 100\mm
372     paper-height = 100\mm
373     tagline = ##f
374   }
376 @end lilypond
378 @seealso
379 Notation Reference:
380 @ref{Page formatting}.
382 Snippets:
383 @rlsr{Staff notation}.
386 @node Modifying single staves
387 @subsection Modifying single staves
389 This section explains how to change specific attributes of one
390 staff: for example, modifying the number of staff lines or the
391 staff size.  Methods to start and stop staves and set ossia
392 sections are also described.
394 @menu
395 * Staff symbol::
396 * Ossia staves::
397 * Hiding staves::
398 @end menu
401 @node Staff symbol
402 @unnumberedsubsubsec Staff symbol
404 @cindex adjusting staff symbol
405 @cindex drawing staff symbol
406 @cindex staff symbol, setting of
407 @cindex staff symbol, drawing
408 @cindex stop staff lines
409 @cindex start staff lines
410 @cindex staff lines, amount of
411 @cindex staff lines, number of
412 @cindex staff line, thickness of
413 @cindex amount of staff lines
414 @cindex thickness of staff lines
415 @cindex ledger lines, setting
416 @cindex setting of ledger lines
417 @cindex spacing of ledger lines
418 @cindex number of staff lines
420 The lines of a staff belong to the @code{StaffSymbol} grob.
421 @code{StaffSymbol} properties can be modified to change the
422 appearance of a staff, but they must be modified before the staff
423 is created.
425 The number of staff lines may be changed.  The clef position and
426 the position of middle C may need to be modified to fit the new
427 staff.  For an explanation, refer to the snippet section in
428 @ref{Clef}.
430 @lilypond[verbatim,quote,relative=2]
431 \new Staff \with {
432   \override StaffSymbol #'line-count = #3
434 { d4 d d d }
435 @end lilypond
437 Staff line thickness can be modified.  The thickness of ledger
438 lines and stems are also affected, since they depend on staff line
439 thickness.
441 @lilypond[verbatim,quote,relative=1]
442 \new Staff \with {
443   \override StaffSymbol #'thickness = #3
445 { e4 d c b }
446 @end lilypond
448 Ledger line thickness can be set independently of staff line
449 thickness.  In the example the two numbers are factors multiplying
450 the staff line thickness and the staff line spacing.  The two
451 contributions are added to give the ledger line thickness.
453 @lilypond[verbatim,quote,relative=1]
454 \new Staff \with {
455   \override StaffSymbol #'ledger-line-thickness = #'(1 . 0.2)
457 { e4 d c b }
458 @end lilypond
460 The distance between staff lines can be changed.  This setting
461 affects the spacing of ledger lines as well.
463 @lilypond[verbatim,quote,relative=1]
464 \new Staff \with {
465   \override StaffSymbol #'staff-space = #1.5
467 { a4 b c d }
468 @end lilypond
470 Further details about the properties of @code{StaffSymbol} can be
471 found in @rinternals{staff-symbol-interface}.
473 @cindex stopping a staff
474 @cindex starting a staff
475 @cindex staff, starting
476 @cindex staff, stopping
478 @funindex \startStaff
479 @funindex startStaff
480 @funindex \stopStaff
481 @funindex stopStaff
483 Modifications to staff properties in the middle of a score can be
484 placed between @code{\stopStaff} and @code{\startStaff}:
486 @lilypond[verbatim,quote,relative=2]
487 c2 c
488 \stopStaff
489 \override Staff.StaffSymbol #'line-count = #2
490 \startStaff
491 b2 b
492 \stopStaff
493 \revert Staff.StaffSymbol #'line-count
494 \startStaff
495 a2 a
496 @end lilypond
498 @noindent
499 In general, @code{\startStaff} and @code{\stopStaff} can be used
500 to stop or start a staff in the middle of a score.
502 @lilypond[verbatim,quote,relative=2]
503 c4 b a2
504 \stopStaff
505 b4 c d2
506 \startStaff
507 e4 d c2
508 @end lilypond
511 @predefined
512 @code{\startStaff},
513 @code{\stopStaff}.
514 @endpredefined
517 @snippets
519 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
520 {making-some-staff-lines-thicker-than-the-others.ly}
523 @seealso
524 Music Glossary:
525 @rglos{line},
526 @rglos{ledger line},
527 @rglos{staff}.
529 Notation Reference:
530 @ref{Clef}.
532 Snippets:
533 @rlsr{Staff notation}.
535 Internals Reference:
536 @rinternals{StaffSymbol},
537 @rinternals{staff-symbol-interface}.
540 @node Ossia staves
541 @unnumberedsubsubsec Ossia staves
543 @cindex staff, Frenched
544 @cindex ossia
545 @cindex Frenched staves
546 @cindex staff, resizing of
547 @cindex resizing of staves
549 @funindex \startStaff
550 @funindex startStaff
551 @funindex \stopStaff
552 @funindex stopStaff
554 @notation{Ossia} staves can be set by creating a new simultaneous
555 staff in the appropriate location:
557 @lilypond[verbatim,quote]
558 \new Staff \relative c'' {
559   c4 b d c
560   <<
561     { c4 b d c }
562     \new Staff { e4 d f e }
563   >>
564   c4 b c2
566 @end lilypond
568 @noindent
569 However, the above example is not what is usually desired.  To
570 create ossia staves that are above the original staff, have no
571 time signature or clef, and have a smaller font size, tweaks must
572 be used.  The Learning Manual describes a specific technique to
573 achieve this goal, beginning with
574 @rlearning{Nesting music expressions}.
576 The following example uses the @code{alignAboveContext} property
577 to align the ossia staff.  This method is most appropriate when
578 only a few ossia staves are needed.
580 @lilypond[verbatim,quote]
581 \new Staff = main \relative c'' {
582   c4 b d c
583   <<
584     { c4 b d c }
586     \new Staff \with {
587       \remove "Time_signature_engraver"
588       alignAboveContext = #"main"
589       fontSize = #-3
590       \override StaffSymbol #'staff-space = #(magstep -3)
591       \override StaffSymbol #'thickness = #(magstep -3)
592       firstClef = ##f
593     }
594     { e4 d f e }
595   >>
596   c4 b c2
598 @end lilypond
600 If many isolated ossia staves are needed, creating an empty
601 @code{Staff} context with a specific @emph{context id} may be more
602 appropriate; the ossia staves may then be created by
603 @emph{calling} this context and using @code{\startStaff} and
604 @code{\stopStaff} at the desired locations.  The benefits of this
605 method are more apparent if the piece is longer than the following
606 example.
608 @lilypond[verbatim,quote,ragged-right]
610   \new Staff = ossia \with {
611     \remove "Time_signature_engraver"
612     \override Clef #'transparent = ##t
613     fontSize = #-3
614     \override StaffSymbol #'staff-space = #(magstep -3)
615     \override StaffSymbol #'thickness = #(magstep -3)
616   }
617   { \stopStaff s1*6 }
619   \new Staff \relative c' {
620     c4 b c2
621     <<
622       { e4 f e2 }
623       \context Staff = ossia {
624         \startStaff e4 g8 f e2 \stopStaff
625       }
626     >>
627     g4 a g2 \break
628     c4 b c2
629     <<
630       { g4 a g2 }
631       \context Staff = ossia {
632         \startStaff g4 e8 f g2 \stopStaff
633       }
634     >>
635     e4 d c2
636   }
638 @end lilypond
641 Using the @code{\RemoveEmptyStaffContext} command to create ossia
642 staves may be used as an alternative.  This method is most
643 convenient when ossia staves occur immediately following a line
644 break.  For more information about
645 @code{\RemoveEmptyStaffContext}, see @ref{Hiding staves}.
647 @lilypond[verbatim,quote,ragged-right]
649   \new Staff = ossia \with {
650     \remove "Time_signature_engraver"
651     \override Clef #'transparent = ##t
652     fontSize = #-3
653     \override StaffSymbol #'staff-space = #(magstep -3)
654     \override StaffSymbol #'thickness = #(magstep -3)
655   } \relative c'' {
656     R1*3
657     c4 e8 d c2
658   }
659   \new Staff \relative c' {
660     c4 b c2
661     e4 f e2
662     g4 a g2 \break
663     c4 b c2
664     g4 a g2
665     e4 d c2
666   }
669 \layout {
670   \context {
671     \RemoveEmptyStaffContext
672     \override VerticalAxisGroup #'remove-first = ##t
673   }
675 @end lilypond
678 @snippets
680 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
681 {vertically-aligning-ossias-and-lyrics.ly}
684 @seealso
685 Music Glossary:
686 @rglos{ossia},
687 @rglos{staff},
688 @rglos{Frenched staff}.
690 Learning Manual:
691 @rlearning{Nesting music expressions},
692 @rlearning{Size of objects},
693 @rlearning{Length and thickness of objects}.
695 Notation Reference:
696 @ref{Hiding staves}.
698 Snippets:
699 @rlsr{Staff notation}.
701 Internals Reference:
702 @rinternals{StaffSymbol}.
705 @node Hiding staves
706 @unnumberedsubsubsec Hiding staves
708 @cindex Frenched score
709 @cindex Frenched staff
710 @cindex staff, hiding
711 @cindex staff, empty
712 @cindex hiding of staves
713 @cindex empty staves
715 @funindex \RemoveEmptyStaffContext
716 @funindex RemoveEmptyStaffContext
717 @funindex Staff_symbol_engraver
718 @funindex \stopStaff
719 @funindex stopStaff
722 Staff lines can be hidden by removing the
723 @code{Staff_symbol_engraver} from the @code{Staff} context.  As an
724 alternative, @code{\stopStaff} may be used.
726 @lilypond[verbatim,quote]
727 \new Staff \with {
728   \remove "Staff_symbol_engraver"
730 \relative c''' { a8 f e16 d c b a2 }
731 @end lilypond
734 Empty staves can be hidden by setting the
735 @code{\RemoveEmptyStaffContext} command in the @code{\layout}
736 block.  In orchestral scores, this style is known as @q{Frenched
737 Score}.  By default, this command hides and removes all empty
738 staves in a score except for those in the first system.
740 @warning{A staff is considered empty when it contains only
741 multi-measure rests, rests, skips, spacer rests, or a combination of these
742 elements.}
744 @lilypond[verbatim,quote,ragged-right]
745 \layout {
746   \context {
747     \RemoveEmptyStaffContext
748   }
751 \relative c' <<
752   \new Staff {
753     e4 f g a \break
754     b1 \break
755     a4 b c2
756   }
757   \new Staff {
758     c,4 d e f \break
759     R1 \break
760     f4 g c,2
761   }
763 @end lilypond
765 @cindex ossia
767 @noindent
768 @code{\RemoveEmptyStaffContext} can also be used to create ossia
769 sections for a staff.  For details, see @ref{Ossia staves}.
771 @cindex hiding ancient staves
772 @cindex hiding rhythmic staves
774 @funindex \RemoveEmptyStaffContext
775 @funindex RemoveEmptyStaffContext
776 @funindex \AncientRemoveEmptyStaffContext
777 @funindex AncientRemoveEmptyStaffContext
778 @funindex \RemoveEmptyRhythmicStaffContext
779 @funindex RemoveEmptyRhythmicStaffContext
781 The @code{\AncientRemoveEmptyStaffContext} command may be used to
782 hide empty staves in ancient music contexts.  Similarly,
783 @code{\RemoveEmptyRhythmicStaffContext} may be used to hide empty
784 @code{RhythmicStaff} contexts.
787 @predefined
788 @code{\RemoveEmptyStaffContext},
789 @code{\AncientRemoveEmptyStaffContext},
790 @code{\RemoveEmptyRhythmicStaffContext}.
791 @endpredefined
794 @snippets
796 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
797 {removing-the-first-empty-line.ly}
800 @seealso
801 Music Glossary:
802 @rglos{Frenched staff}.
804 Learning Manual:
805 @rlearning{Visibility and color of objects}.
807 Notation Reference:
808 @ref{Changing context default settings},
809 @ref{Staff symbol},
810 @ref{Ossia staves},
811 @ref{Hidden notes},
812 @ref{Invisible rests},
813 @ref{Visibility of objects}.
815 Snippets:
816 @rlsr{Staff notation}.
818 Internals Reference:
819 @rinternals{ChordNames},
820 @rinternals{FiguredBass},
821 @rinternals{Lyrics},
822 @rinternals{Staff},
823 @rinternals{VerticalAxisGroup},
824 @rinternals{Staff_symbol_engraver}.
827 @knownissues
829 Removing @code{Staff_symbol_engraver} also hides bar lines.  If
830 bar line visibility is forced, formatting errors may occur.  In
831 this case, use the following overrides instead of removing the
832 engraver:
834 @example
835 \override StaffSymbol #'stencil = ##f
836 \override NoteHead #'no-ledgers = ##t
837 @end example
839 For the Known issues and warnings associated with
840 @code{\RemoveEmptyStaffContext} see @ref{Changing context default
841 settings}.
843 @node Writing parts
844 @subsection Writing parts
846 This section explains how to insert tempo indications and
847 instrument names into a score.  Methods to quote other voices and
848 format cue notes are also described.
850 @menu
851 * Instrument names::
852 * Quoting other voices::
853 * Formatting cue notes::
854 @end menu
856 @node Instrument names
857 @unnumberedsubsubsec Instrument names
859 @cindex instrument names
860 @cindex instrument names, short
862 Instrument names can be printed on the left side of staves in the
863 @code{Staff} and @code{PianoStaff} contexts.  The value of
864 @code{instrumentName} is used for the first staff, and the value
865 of @code{shortInstrumentName} is used for all succeeding staves.
867 @lilypond[verbatim,quote,ragged-right,relative=1]
868 \set Staff.instrumentName = #"Violin "
869 \set Staff.shortInstrumentName = #"Vln "
870 c4.. g'16 c4.. g'16
871 \break
873 @end lilypond
875 Markup mode can be used to create more complicated instrument
876 names:
878 @lilypond[verbatim,quote,relative=2]
879 \set Staff.instrumentName = \markup {
880   \column { "Clarinetti"
881             \line { "in B" \smaller \flat } } }
882 c4 c,16 d e f g2
883 @end lilypond
885 @cindex instrument names, centering
887 When two or more staff contexts are grouped together, the
888 instrument names and short instrument names are centered by
889 default.  To center multi-line instrument names,
890 @code{\center-column} must be used:
892 @lilypond[verbatim,quote,indent=1.5\cm,relative=2]
894   \new Staff {
895     \set Staff.instrumentName = #"Flute"
896     f2 g4 f
897   }
898   \new Staff {
899     \set Staff.instrumentName = \markup \center-column {
900       Clarinet
901       \line { "in B" \smaller \flat }
902     }
903     c4 b c2
904   }
906 @end lilypond
908 @funindex indent
909 @funindex short-indent
911 However, if the instrument names are longer, the instrument names
912 in a staff group may not be centered unless the @code{indent} and
913 @code{short-indent} settings are increased.  For details about
914 these settings, see @ref{Horizontal dimensions}.
916 @lilypond[verbatim,quote,ragged-right]
917 \layout {
918   indent = 3.0\cm
919   short-indent = 1.5\cm
922 \relative c'' <<
923   \new Staff {
924     \set Staff.instrumentName = #"Alto Flute in G"
925     \set Staff.shortInstrumentName = #"Fl."
926     f2 g4 f \break
927     g4 f g2
928   }
929   \new Staff {
930     \set Staff.instrumentName = #"Clarinet"
931     \set Staff.shortInstrumentName = #"Clar."
932     c,4 b c2 \break
933     c2 b4 c
934   }
936 @end lilypond
938 @cindex instrument names, adding to other contexts
940 To add instrument names to other contexts (such as
941 @code{GrandStaff}, @code{ChoirStaff}, or @code{StaffGroup}),
942 @code{Instrument_name_engraver} must be added to that context.
943 For details, see @ref{Modifying context plug-ins}.
945 @cindex instrument names, changing
946 @cindex changing instrument names
948 Instrument names may be changed in the middle of a piece.
949 However, remember that @code{instrumentName} will not be
950 displayed in the middle of the piece, as it only appears
951 on the first staff:
953 @lilypond[verbatim,quote,ragged-right,relative=1]
954 \set Staff.instrumentName = #"First"
955 \set Staff.shortInstrumentName = #"one"
956 c1 c c c \break
957 c1 c c c \break
958 \set Staff.instrumentName = #"Second"
959 \set Staff.shortInstrumentName = #"two"
960 c1 c c c \break
961 c1 c c c \break
962 @end lilypond
964 @cindex instrument switch
965 @cindex switching instruments
967 @funindex \addInstrumentDefinition
968 @funindex addInstrumentDefinition
969 @funindex \instrumentSwitch
970 @funindex instrumentSwitch
972 If an instrument @emph{switch} is needed,
973 @code{\addInstrumentDefinition} may be used in combination with
974 @code{\instrumentSwitch} to create a detailed list of the
975 necessary changes for the switch.  The
976 @code{\addInstrumentDefinition} command has two arguments: an
977 identifying string, and an association list of context properties
978 and values to be used for the instrument.  It must be placed in
979 the toplevel scope.  @code{\instrumentSwitch} is used in the music
980 expression to declare the instrument switch:
982 @lilypond[verbatim,quote,ragged-right]
983 \addInstrumentDefinition #"contrabassoon"
984   #`((instrumentTransposition . ,(ly:make-pitch -1 0 0))
985      (shortInstrumentName . "Cbsn.")
986      (clefGlyph . "clefs.F")
987      (middleCPosition . 6)
988      (clefPosition . 2)
989      (instrumentCueName . ,(make-bold-markup "cbsn."))
990      (midiInstrument . "bassoon"))
992 \new Staff \with {
993   instrumentName = #"Bassoon"
995 \relative c' {
996   \clef tenor
997   \compressFullBarRests
998   c2 g'
999   R1*16
1000   \instrumentSwitch "contrabassoon"
1001   c,,2 g \break
1002   c,1 ~ | c1
1004 @end lilypond
1007 @seealso
1008 Notation Reference:
1009 @ref{Horizontal dimensions},
1010 @ref{Modifying context plug-ins}.
1012 Snippets:
1013 @rlsr{Staff notation}.
1015 Internals Reference:
1016 @rinternals{InstrumentName},
1017 @rinternals{PianoStaff},
1018 @rinternals{Staff}.
1021 @node Quoting other voices
1022 @unnumberedsubsubsec Quoting other voices
1024 @cindex cues
1025 @cindex quoting other voices
1026 @cindex fragments
1027 @cindex cue notes
1029 @funindex \addQuote
1030 @funindex addQuote
1031 @funindex \quoteDuring
1032 @funindex quoteDuring
1033 @funindex \transposition
1034 @funindex transposition
1036 It is very common for one voice to double some of the music from
1037 another voice.  For example, the first and second violins may play the
1038 same notes during a passage of music.  In LilyPond this is accomplished
1039 by letting one voice @emph{quote} the other voice without having to
1040 re-enter it.
1042 Before a part can be quoted, the @code{\addQuote} command must be used
1043 to initialize the quoted fragment.  This command must be used in the
1044 toplevel scope.  The first argument is an identifying string, and the
1045 second is a music expression:
1047 @example
1048 flute = \relative c'' @{
1049   a4 gis g gis
1051 \addQuote "flute" @{ \flute @}
1052 @end example
1054 The @code{\quoteDuring} command is used to indicate the point where the
1055 quotation begins.  It is followed by two arguments: the name of the
1056 quoted voice, as defined with @code{\addQuote}, and a music expression
1057 that indicates the duration of the quote, usually spacer rests or
1058 multi-measure rests.  The corresponding music (including all articulations,
1059 dynamics, markup, etc.) from the quoted voice is inserted into the music
1060 expression:
1062 @lilypond[verbatim,quote]
1063 flute = \relative c'' {
1064   a4 gis g->\f gis^\markup{quoted}
1066 \addQuote "flute" { \flute }
1068 \relative c' {
1069   c4 cis \quoteDuring #"flute" { s2 }
1071 @end lilypond
1073 If the music expression used for @code{\quoteDuring} contains
1074 anything but a spacer rest or multi-measure rest, a polyphonic
1075 situation is created, which is often not desirable:
1077 @lilypond[verbatim,quote]
1078 flute = \relative c'' {
1079   a4 gis g gis
1081 \addQuote "flute" { \flute }
1083 \relative c' {
1084   c4 cis \quoteDuring #"flute" { c4 b }
1086 @end lilypond
1088 Quotations recognize instrument transposition settings for both
1089 the source and target instruments if the @code{\transposition}
1090 command is used.  For details about @code{\transposition}, see
1091 @ref{Instrument transpositions}.
1093 @lilypond[verbatim,quote]
1094 clarinet = \relative c'' {
1095   \transposition bes
1096   a4 gis g gis
1098 \addQuote "clarinet" { \clarinet }
1100 \relative c' {
1101   c4 cis \quoteDuring #"clarinet" { s2 }
1103 @end lilypond
1105 It is possible to tag quotations with unique names in order to
1106 process them in different ways.  For details about this procedure,
1107 see @ref{Using tags}.
1109 It is also possible to adjust which objects from the original voice are quoted
1110 by changing the @code{quotedEventTypes} property.  By default, its value is
1111 @code{#'(StreamEvent)}, which means that everything is quoted.  Setting it
1112 to e.g. @code{#'(note-event rest-event tie-event)} causes lilypond to quote
1113 only notes, rests and ties, but no articulations, markup or dynamics.
1115 @lilypond[verbatim,quote]
1116 clarinet = \relative c'' {
1117   a4 gis g->\f gis^\markup{quoted}
1119 \addQuote "clarinet" { \clarinet }
1121 \relative c' {
1122   \set Score.quotedEventTypes = #'(note-event rest-event tie-event)
1123   c4 cis \quoteDuring #"clarinet" { s2 }
1125 @end lilypond
1127 @snippets
1129 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
1130 {quoting-another-voice-with-transposition.ly}
1132 @cindex note-event
1133 @cindex articulation-event
1134 @cindex dynamic-event
1135 @cindex rest-event
1137 @funindex quotedEventTypes
1138 @funindex quotedCueEventTypes
1140 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
1141 {quoting-another-voice.ly}
1144 @seealso
1145 Notation Reference:
1146 @ref{Instrument transpositions},
1147 @ref{Using tags}.
1149 Snippets:
1150 @rlsr{Staff notation}.
1152 Internals Reference:
1153 @rinternals{QuoteMusic},
1154 @rinternals{Voice}.
1157 @knownissues
1159 Only the contents of the first @code{Voice} occurring in an
1160 @code{\addQuote} command will be considered for quotation, so
1161 @var{music} cannot contain @code{\new} and @code{\context Voice}
1162 statements that would switch to a different Voice.
1164 Quoting grace notes is broken and can even cause LilyPond to
1165 crash.
1167 Quoting nested triplets may result in poor notation.
1169 In earlier versions of LilyPond (pre 2.11), @code{addQuote} was
1170 written entirely in lower-case letters: @code{\addquote}.
1173 @node Formatting cue notes
1174 @unnumberedsubsubsec Formatting cue notes
1176 @cindex cues
1177 @cindex cue notes
1178 @cindex cue notes, formatting
1179 @cindex fragments
1180 @cindex quoting other voices
1181 @cindex cues, formatting
1183 @funindex \cueDuring
1184 @funindex cueDuring
1185 @funindex \quoteDuring
1186 @funindex quoteDuring
1188 The previous section explains how to create quotations.  The
1189 @code{\cueDuring} command is a more specialized form of
1190 @code{\quoteDuring}, being particularly useful for inserting cue
1191 notes into a part.  The syntax is as follows:
1193 @example
1194 \cueDuring #@var{partname} #@var{voice} @var{music}
1195 @end example
1197 This command copies only the notes and rests from the corresponding measures
1198 from @var{partname} into a @code{CueVoice} context.  The @code{CueVoice} is
1199 created implicitly, and occurs simultaneously with @var{music}, which
1200 creates a polyphonic situation.  The @var{voice} argument
1201 determines whether the cue notes should be notated as a first or
1202 second voice; @code{UP} corresponds to the first voice, and
1203 @code{DOWN} corresponds to the second.
1205 @lilypond[verbatim,quote]
1206 oboe = \relative c'' {
1207   r2 r8 d16(\f f e g f a)
1208   g8 g16 g g2.
1210 \addQuote "oboe" { \oboe }
1212 \new Voice \relative c'' {
1213   \cueDuring #"oboe" #UP { R1 }
1214   g2 c,
1216 @end lilypond
1218 @noindent
1219 In the above example, the @code{Voice} context had to be
1220 explicitly declared, or else the entire music expression would
1221 belong to the @code{CueVoice} context.
1223 It is possible to adjust which aspects of the music are quoted with
1224 @code{\cueDuring} by setting the @code{quotedCueEventTypes} property.  Its
1225 default value is @code{#'(note-event rest-event tie-event beam-event
1226 tuplet-span-event)}, which means that only notes, rest, ties, beams and
1227 tuplets are quoted, but not articulations, dynamic marks, markup etc.
1229 @lilypond[verbatim,quote]
1230 oboe = \relative c'' {
1231   r2 r8 d16(\f f e g f a)
1232   g8 g16 g g2.
1234 \addQuote "oboe" { \oboe }
1236 \new Voice \relative c'' {
1237   \set Score.quotedCueEventTypes = #'(note-event rest-event tie-event
1238                                       beam-event tuplet-span-event
1239                                       dynamic-event slur-event)
1240   \cueDuring #"oboe" #UP { R1 }
1241   g2 c,
1243 @end lilypond
1247 The name of the cued instrument can be printed by setting the
1248 @code{instrumentCueName} property in the @code{CueVoice} context.
1250 @lilypond[verbatim,quote]
1251 oboe = \relative c''' {
1252   g4 r8 e16 f e4 d
1254 \addQuote "oboe" { \oboe }
1256 \new Staff \relative c'' <<
1257   \new CueVoice \with {
1258     instrumentCueName = "ob."
1259   }
1260   \new Voice {
1261     \cueDuring #"oboe" #UP { R1 }
1262     g4. b8 d2
1263   }
1265 @end lilypond
1267 @cindex removing cues
1268 @cindex removing cue notes
1269 @cindex cue notes, removing
1271 @funindex \killCues
1272 @funindex killCues
1273 @funindex \transposedCueDuring
1274 @funindex transposedCueDuring
1276 In addition to printing the name of the cued instrument, when cue
1277 notes end, the name of the original instrument should be printed,
1278 and any other changes introduced by the cued part should be
1279 undone.  This can be accomplished by using
1280 @code{\addInstrumentDefinition} and @code{\instrumentSwitch}.  For
1281 an example and explanation, see @ref{Instrument names}.
1283 The @code{\killCues} command removes cue notes from a music
1284 expression.  This can be useful if cue notes need to be removed
1285 from a part but may be restored at a later time.
1287 @lilypond[verbatim,quote]
1288 flute = \relative c''' {
1289   r2 cis2 r2 dis2
1291 \addQuote "flute" { \flute }
1293 \new Voice \relative c'' {
1294   \killCues {
1295     \cueDuring #"flute" #UP { R1 }
1296     g4. b8 d2
1297   }
1299 @end lilypond
1301 The @code{\transposedCueDuring} command is useful for adding
1302 instrumental cues from a completely different register.  The
1303 syntax is similar to @code{\cueDuring}, but it requires one extra
1304 argument to specify the transposition of the cued instrument.  For
1305 more information about transposition, see
1306 @ref{Instrument transpositions}.
1308 @lilypond[verbatim,quote]
1309 piccolo = \relative c''' {
1310   \clef "treble^8"
1311   R1
1312   c8 c c e g2
1313   a4 g g2
1315 \addQuote "piccolo" { \piccolo }
1317 cbassoon = \relative c, {
1318   \clef "bass_8"
1319   c4 r g r
1320   \transposedCueDuring #"piccolo" #UP c,, { R1 }
1321   c4 r g r
1325   \new Staff = "piccolo" \piccolo
1326   \new Staff = "cbassoon" \cbassoon
1328 @end lilypond
1330 It is possible to tag cued parts with unique names in order to
1331 process them in different ways.  For details about this procedure,
1332 see @ref{Using tags}.
1334 @cindex notes, smaller
1335 @cindex smaller notes
1337 A @code{CueVoice} context may be created explicitly if notes of a
1338 smaller size are required, for example to set an alternative
1339 sequence of notes more suitable for a higher or lower voice.
1341 @lilypond[verbatim,relative=2]
1342 \time 12/8
1343 \key ees \major
1344 g4 ees8 f4 g8
1345 \stemDown
1347   { d4. bes4 c8 }
1348   \new CueVoice
1349   { g'4. f4 ees8 }
1351 \stemUp
1352 d2. d2.
1353 @end lilypond
1356 @seealso
1357 Notation Reference:
1358 @ref{Instrument transpositions},
1359 @ref{Instrument names},
1360 @ref{Using tags}.
1362 Snippets:
1363 @rlsr{Staff notation}.
1365 Internals Reference:
1366 @rinternals{CueVoice},
1367 @rinternals{Voice}.
1370 @knownissues
1372 Collisions can occur with rests, when using @code{\cueDuring},
1373 between @code{Voice} and @code{CueVoice} contexts.