]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/notation/staff.itely
Docs: run convert-ly for 2.14.0.
[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,lilyquote,texidoc,doctitle]
239 {use-square-bracket-at-the-start-of-a-staff-group.ly}
240
241 @lilypondfile[verbatim,lilyquote,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,lilyquote,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,lilyquote,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 adjusting staff symbol
408 @cindex drawing staff symbol
409 @cindex staff symbol, setting of
410 @cindex staff symbol, drawing
411 @cindex stop staff lines
412 @cindex start staff lines
413 @cindex staff lines, amount of
414 @cindex staff lines, number of
415 @cindex staff line, thickness of
416 @cindex amount of staff lines
417 @cindex thickness of staff lines
418 @cindex ledger lines, setting
419 @cindex setting of ledger lines
420 @cindex spacing of ledger lines
421 @cindex number of staff lines
422
423 The lines of a staff belong to the @code{StaffSymbol} grob.
424 @code{StaffSymbol} properties can be modified to change the
425 appearance of a staff, but they must be modified before the staff
426 is created.
427
428 The number of staff lines may be changed.  The clef position and
429 the position of middle C may need to be modified to fit the new
430 staff.  For an explanation, refer to the snippet section in
431 @ref{Clef}.
432
433 @lilypond[verbatim,quote,relative=2]
434 \new Staff \with {
435   \override StaffSymbol #'line-count = #3
436 }
437 { d4 d d d }
438 @end lilypond
439
440 Staff line thickness can be modified.  The thickness of ledger
441 lines and stems are also affected, since they depend on staff line
442 thickness.
443
444 @lilypond[verbatim,quote,relative=1]
445 \new Staff \with {
446   \override StaffSymbol #'thickness = #3
447 }
448 { e4 d c b }
449 @end lilypond
450
451 Ledger line thickness can be set independently of staff line
452 thickness.  In the example the two numbers are factors multiplying
453 the staff line thickness and the staff line spacing.  The two
454 contributions are added to give the ledger line thickness.
455
456 @lilypond[verbatim,quote,relative=1]
457 \new Staff \with {
458   \override StaffSymbol #'ledger-line-thickness = #'(1 . 0.2)
459 }
460 { e4 d c b }
461 @end lilypond
462
463 The distance between staff lines can be changed.  This setting
464 affects the spacing of ledger lines as well.
465
466 @lilypond[verbatim,quote,relative=1]
467 \new Staff \with {
468   \override StaffSymbol #'staff-space = #1.5
469 }
470 { a4 b c d }
471 @end lilypond
472
473 Further details about the properties of @code{StaffSymbol} can be
474 found in @rinternals{staff-symbol-interface}.
475
476 @cindex stopping a staff
477 @cindex starting a staff
478 @cindex staff, starting
479 @cindex staff, stopping
480
481 @funindex \startStaff
482 @funindex startStaff
483 @funindex \stopStaff
484 @funindex stopStaff
485
486 Modifications to staff properties in the middle of a score can be
487 placed between @code{\stopStaff} and @code{\startStaff}:
488
489 @lilypond[verbatim,quote,relative=2]
490 c2 c
491 \stopStaff
492 \override Staff.StaffSymbol #'line-count = #2
493 \startStaff
494 b2 b
495 \stopStaff
496 \revert Staff.StaffSymbol #'line-count
497 \startStaff
498 a2 a
499 @end lilypond
500
501 @noindent
502 In general, @code{\startStaff} and @code{\stopStaff} can be used
503 to stop or start a staff in the middle of a score.
504
505 @lilypond[verbatim,quote,relative=2]
506 c4 b a2
507 \stopStaff
508 b4 c d2
509 \startStaff
510 e4 d c2
511 @end lilypond
512
513
514 @predefined
515 @code{\startStaff},
516 @code{\stopStaff}.
517 @endpredefined
518
519
520 @snippets
521
522 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
523 {making-some-staff-lines-thicker-than-the-others.ly}
524
525
526 @seealso
527 Music Glossary:
528 @rglos{line},
529 @rglos{ledger line},
530 @rglos{staff}.
531
532 Notation Reference:
533 @ref{Clef}.
534
535 Snippets:
536 @rlsr{Staff notation}.
537
538 Internals Reference:
539 @rinternals{StaffSymbol},
540 @rinternals{staff-symbol-interface}.
541
542
543 @node Ossia staves
544 @unnumberedsubsubsec Ossia staves
545
546 @cindex staff, Frenched
547 @cindex ossia
548 @cindex Frenched staves
549 @cindex staff, resizing of
550 @cindex resizing of staves
551
552 @funindex \startStaff
553 @funindex startStaff
554 @funindex \stopStaff
555 @funindex stopStaff
556
557 @notation{Ossia} staves can be set by creating a new simultaneous
558 staff in the appropriate location:
559
560 @lilypond[verbatim,quote]
561 \new Staff \relative c'' {
562   c4 b d c
563   <<
564     { c4 b d c }
565     \new Staff { e4 d f e }
566   >>
567   c4 b c2
568 }
569 @end lilypond
570
571 @noindent
572 However, the above example is not what is usually desired.  To
573 create ossia staves that are above the original staff, have no
574 time signature or clef, and have a smaller font size, tweaks must
575 be used.  The Learning Manual describes a specific technique to
576 achieve this goal, beginning with
577 @rlearning{Nesting music expressions}.
578
579 The following example uses the @code{alignAboveContext} property
580 to align the ossia staff.  This method is most appropriate when
581 only a few ossia staves are needed.
582
583 @lilypond[verbatim,quote]
584 \new Staff = main \relative c'' {
585   c4 b d c
586   <<
587     { c4 b d c }
588
589     \new Staff \with {
590       \remove "Time_signature_engraver"
591       alignAboveContext = #"main"
592       fontSize = #-3
593       \override StaffSymbol #'staff-space = #(magstep -3)
594       \override StaffSymbol #'thickness = #(magstep -3)
595       firstClef = ##f
596     }
597     { e4 d f e }
598   >>
599   c4 b c2
600 }
601 @end lilypond
602
603 If many isolated ossia staves are needed, creating an empty
604 @code{Staff} context with a specific @emph{context id} may be more
605 appropriate; the ossia staves may then be created by
606 @emph{calling} this context and using @code{\startStaff} and
607 @code{\stopStaff} at the desired locations.  The benefits of this
608 method are more apparent if the piece is longer than the following
609 example.
610
611 @lilypond[verbatim,quote,ragged-right]
612 <<
613   \new Staff = ossia \with {
614     \remove "Time_signature_engraver"
615     \override Clef #'transparent = ##t
616     fontSize = #-3
617     \override StaffSymbol #'staff-space = #(magstep -3)
618     \override StaffSymbol #'thickness = #(magstep -3)
619   }
620   { \stopStaff s1*6 }
621
622   \new Staff \relative c' {
623     c4 b c2
624     <<
625       { e4 f e2 }
626       \context Staff = ossia {
627         \startStaff e4 g8 f e2 \stopStaff
628       }
629     >>
630     g4 a g2 \break
631     c4 b c2
632     <<
633       { g4 a g2 }
634       \context Staff = ossia {
635         \startStaff g4 e8 f g2 \stopStaff
636       }
637     >>
638     e4 d c2
639   }
640 >>
641 @end lilypond
642
643
644 Using the @code{\Staff \RemoveEmptyStaves} command to create ossia
645 staves may be used as an alternative.  This method is most
646 convenient when ossia staves occur immediately following a line
647 break.  For more information about
648 @code{\Staff \RemoveEmptyStaves}, see @ref{Hiding staves}.
649
650 @lilypond[verbatim,quote,ragged-right]
651 <<
652   \new Staff = ossia \with {
653     \remove "Time_signature_engraver"
654     \override Clef #'transparent = ##t
655     fontSize = #-3
656     \override StaffSymbol #'staff-space = #(magstep -3)
657     \override StaffSymbol #'thickness = #(magstep -3)
658   } \relative c'' {
659     R1*3
660     c4 e8 d c2
661   }
662   \new Staff \relative c' {
663     c4 b c2
664     e4 f e2
665     g4 a g2 \break
666     c4 b c2
667     g4 a g2
668     e4 d c2
669   }
670 >>
671
672 \layout {
673   \context {
674     \Staff \RemoveEmptyStaves
675     \override VerticalAxisGroup #'remove-first = ##t
676   }
677 }
678 @end lilypond
679
680
681 @snippets
682
683 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
684 {vertically-aligning-ossias-and-lyrics.ly}
685
686
687 @seealso
688 Music Glossary:
689 @rglos{ossia},
690 @rglos{staff},
691 @rglos{Frenched staff}.
692
693 Learning Manual:
694 @rlearning{Nesting music expressions},
695 @rlearning{Size of objects},
696 @rlearning{Length and thickness of objects}.
697
698 Notation Reference:
699 @ref{Hiding staves}.
700
701 Snippets:
702 @rlsr{Staff notation}.
703
704 Internals Reference:
705 @rinternals{StaffSymbol}.
706
707
708 @node Hiding staves
709 @unnumberedsubsubsec Hiding staves
710
711 @cindex Frenched score
712 @cindex Frenched staff
713 @cindex staff, hiding
714 @cindex staff, empty
715 @cindex hiding of staves
716 @cindex empty staves
717
718 @funindex \RemoveEmptyStaves
719 @funindex Staff_symbol_engraver
720 @funindex \stopStaff
721 @funindex stopStaff
722
723
724 Staff lines can be hidden by removing the
725 @code{Staff_symbol_engraver} from the @code{Staff} context.  As an
726 alternative, @code{\stopStaff} may be used.
727
728 @lilypond[verbatim,quote]
729 \new Staff \with {
730   \remove "Staff_symbol_engraver"
731 }
732 \relative c''' { a8 f e16 d c b a2 }
733 @end lilypond
734
735
736 Empty staves can be hidden by setting the
737 @code{\Staff \RemoveEmptyStaves} command in the @code{\layout}
738 block.  In orchestral scores, this style is known as @q{Frenched
739 Score}.  By default, this command hides and removes all empty
740 staves in a score except for those in the first system.
741
742 @warning{A staff is considered empty when it contains only
743 multi-measure rests, rests, skips, spacer rests, or a combination of these
744 elements.}
745
746 @lilypond[verbatim,quote,ragged-right]
747 \layout {
748   \context {
749     \Staff \RemoveEmptyStaves
750   }
751 }
752
753 \relative c' <<
754   \new Staff {
755     e4 f g a \break
756     b1 \break
757     a4 b c2
758   }
759   \new Staff {
760     c,4 d e f \break
761     R1 \break
762     f4 g c,2
763   }
764 >>
765 @end lilypond
766
767 @cindex ossia
768
769 @noindent
770 @code{\Staff \RemoveEmptyStaves} can also be used to create ossia
771 sections for a staff.  For details, see @ref{Ossia staves}.
772
773 @cindex hiding ancient staves
774 @cindex hiding rhythmic staves
775
776 @funindex \RemoveEmptyStaves
777
778 The @code{\VaticanaStaff \RemoveEmptyStaves} command may be used to
779 hide empty staves in ancient music contexts.  Similarly,
780 @code{\RhythmicStaff \RemoveEmptyStaves} may be used to hide empty
781 @code{RhythmicStaff} contexts.
782
783
784 @predefined
785 @code{\Staff \RemoveEmptyStaves},
786 @code{\VaticanaStaff \RemoveEmptyStaves},
787 @code{\RhythmicStaff \RemoveEmptyStaves}.
788 @endpredefined
789
790
791 @snippets
792
793 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
794 {removing-the-first-empty-line.ly}
795
796
797 @seealso
798 Music Glossary:
799 @rglos{Frenched staff}.
800
801 Learning Manual:
802 @rlearning{Visibility and color of objects}.
803
804 Notation Reference:
805 @ref{Changing context default settings},
806 @ref{Staff symbol},
807 @ref{Ossia staves},
808 @ref{Hidden notes},
809 @ref{Invisible rests},
810 @ref{Visibility of objects}.
811
812 Snippets:
813 @rlsr{Staff notation}.
814
815 Internals Reference:
816 @rinternals{ChordNames},
817 @rinternals{FiguredBass},
818 @rinternals{Lyrics},
819 @rinternals{Staff},
820 @rinternals{VerticalAxisGroup},
821 @rinternals{Staff_symbol_engraver}.
822
823
824 @knownissues
825
826 Removing @code{Staff_symbol_engraver} also hides bar lines.  If
827 bar line visibility is forced, formatting errors may occur.  In
828 this case, use the following overrides instead of removing the
829 engraver:
830
831 @example
832 \override StaffSymbol #'stencil = ##f
833 \override NoteHead #'no-ledgers = ##t
834 @end example
835
836 For the Known issues and warnings associated with
837 @code{\Staff \RemoveEmptyStaves} see
838 @ref{Changing context default settings}.
839
840 @node Writing parts
841 @subsection Writing parts
842
843 This section explains how to insert tempo indications and
844 instrument names into a score.  Methods to quote other voices and
845 format cue notes are also described.
846
847 @menu
848 * Instrument names::
849 * Quoting other voices::
850 * Formatting cue notes::
851 @end menu
852
853 @node Instrument names
854 @unnumberedsubsubsec Instrument names
855
856 @cindex instrument names
857 @cindex instrument names, short
858
859 Instrument names can be printed on the left side of staves in the
860 @code{Staff}, @code{PianoStaff}, @code{StaffGroup}, @code{GrandStaff}
861 and @code{ChoirStaff} contexts.  The value of
862 @code{instrumentName} is used for the first staff, and the value
863 of @code{shortInstrumentName} is used for all succeeding staves.
864
865 @lilypond[verbatim,quote,ragged-right,relative=1]
866 \set Staff.instrumentName = #"Violin "
867 \set Staff.shortInstrumentName = #"Vln "
868 c4.. g'16 c4.. g'16
869 \break
870 c1
871 @end lilypond
872
873 Markup mode can be used to create more complicated instrument
874 names:
875
876 @lilypond[verbatim,quote,relative=2]
877 \set Staff.instrumentName = \markup {
878   \column { "Clarinetti"
879             \line { "in B" \smaller \flat } } }
880 c4 c,16 d e f g2
881 @end lilypond
882
883 @cindex instrument names, centering
884
885 When two or more staff contexts are grouped together, the
886 instrument names and short instrument names are centered by
887 default.  To center multi-line instrument names,
888 @code{\center-column} must be used:
889
890 @lilypond[verbatim,quote,indent=1.5\cm,relative=2]
891 <<
892   \new Staff {
893     \set Staff.instrumentName = #"Flute"
894     f2 g4 f
895   }
896   \new Staff {
897     \set Staff.instrumentName = \markup \center-column {
898       Clarinet
899       \line { "in B" \smaller \flat }
900     }
901     c4 b c2
902   }
903 >>
904 @end lilypond
905
906 @funindex indent
907 @funindex short-indent
908
909 However, if the instrument names are longer, the instrument names
910 in a staff group may not be centered unless the @code{indent} and
911 @code{short-indent} settings are increased.  For details about
912 these settings, see @ref{\paper variables for shifts and indents}.
913
914 @lilypond[verbatim,quote,ragged-right]
915 \layout {
916   indent = 3.0\cm
917   short-indent = 1.5\cm
918 }
919
920 \relative c'' <<
921   \new Staff {
922     \set Staff.instrumentName = #"Alto Flute in G"
923     \set Staff.shortInstrumentName = #"Fl."
924     f2 g4 f \break
925     g4 f g2
926   }
927   \new Staff {
928     \set Staff.instrumentName = #"Clarinet"
929     \set Staff.shortInstrumentName = #"Clar."
930     c,4 b c2 \break
931     c2 b4 c
932   }
933 >>
934 @end lilypond
935
936 @cindex instrument names, adding to other contexts
937
938 To add instrument names to other contexts (such as
939 @code{ChordNames} or @code{FiguredBass}),
940 @code{Instrument_name_engraver} must be added to that context.
941 For details, see @ref{Modifying context plug-ins}.
942
943 @cindex instrument names, changing
944 @cindex changing instrument names
945
946 Instrument names may be changed in the middle of a piece.
947 However, remember that @code{instrumentName} will not be
948 displayed in the middle of the piece, as it only appears
949 on the first staff:
950
951 @lilypond[verbatim,quote,ragged-right,relative=1]
952 \set Staff.instrumentName = #"First"
953 \set Staff.shortInstrumentName = #"one"
954 c1 c c c \break
955 c1 c c c \break
956 \set Staff.instrumentName = #"Second"
957 \set Staff.shortInstrumentName = #"two"
958 c1 c c c \break
959 c1 c c c \break
960 @end lilypond
961
962 @cindex instrument switch
963 @cindex switching instruments
964
965 @funindex \addInstrumentDefinition
966 @funindex addInstrumentDefinition
967 @funindex \instrumentSwitch
968 @funindex instrumentSwitch
969
970 If an instrument @emph{switch} is needed,
971 @code{\addInstrumentDefinition} may be used in combination with
972 @code{\instrumentSwitch} to create a detailed list of the
973 necessary changes for the switch.  The
974 @code{\addInstrumentDefinition} command has two arguments: an
975 identifying string, and an association list of context properties
976 and values to be used for the instrument.  It must be placed in
977 the toplevel scope.  @code{\instrumentSwitch} is used in the music
978 expression to declare the instrument switch:
979
980 @lilypond[verbatim,quote,ragged-right]
981 \addInstrumentDefinition #"contrabassoon"
982   #`((instrumentTransposition . ,(ly:make-pitch -1 0 0))
983      (shortInstrumentName . "Cbsn.")
984      (clefGlyph . "clefs.F")
985      (middleCPosition . 6)
986      (clefPosition . 2)
987      (instrumentCueName . ,(make-bold-markup "cbsn."))
988      (midiInstrument . "bassoon"))
989
990 \new Staff \with {
991   instrumentName = #"Bassoon"
992 }
993 \relative c' {
994   \clef tenor
995   \compressFullBarRests
996   c2 g'
997   R1*16
998   \instrumentSwitch "contrabassoon"
999   c,,2 g \break
1000   c,1 ~ | c1
1001 }
1002 @end lilypond
1003
1004
1005 @seealso
1006 Notation Reference:
1007 @ref{\paper variables for shifts and indents},
1008 @ref{Modifying context plug-ins}.
1009
1010 Snippets:
1011 @rlsr{Staff notation}.
1012
1013 Internals Reference:
1014 @rinternals{InstrumentName},
1015 @rinternals{PianoStaff},
1016 @rinternals{Staff}.
1017
1018
1019 @node Quoting other voices
1020 @unnumberedsubsubsec Quoting other voices
1021
1022 @cindex quote, voices
1023 @cindex voices, quoting
1024 @cindex fragments, quoting
1025 @cindex cue notes
1026
1027 @funindex \addQuote
1028 @funindex addQuote
1029 @funindex \quoteDuring
1030 @funindex quoteDuring
1031 @funindex \transposition
1032 @funindex transposition
1033
1034 It is very common for one voice to use the same notes as those from
1035 another voice.  For example, first and second violins playing the same
1036 phrase during a particular passage of the music.  This is done by
1037 letting one voice @emph{quote} the other, without having to re-enter the
1038 music all over again for the second voice.
1039
1040 The @code{\addQuote} command, used in the top level scope, defines a
1041 stream of music from which fragments can be quoted.
1042
1043 The @code{\quoteDuring} command is used to indicate the point where the
1044 quotation begins.  It is followed by two arguments: the name of the
1045 quoted voice, as defined with @code{\addQuote}, and a music expression
1046 for the duration of the quote.
1047
1048 @lilypond[verbatim,quote]
1049 fluteNotes = \relative c'' {
1050   a4 gis g gis | b4^"quoted" r8 ais\p a4( f)
1051 }
1052
1053 oboeNotes = \relative c'' {
1054   c4 cis c b \quoteDuring #"flute" { s1 }
1055 }
1056
1057 \addQuote "flute" { \fluteNotes }
1058
1059 \score {
1060   <<
1061     \new Staff \with { instrumentName = "Flute" } \fluteNotes
1062     \new Staff \with { instrumentName = "Oboe" } \oboeNotes
1063   >>
1064 }
1065 @end lilypond
1066
1067 If the music expression used in @code{\quoteDuring} contains notes
1068 instead of spacer or multimeasure rests then the quote will appear as
1069 polyphony and may produce unexpected results.
1070
1071 @lilypond[verbatim,quote]
1072 fluteNotes = \relative c'' {
1073   a4 gis g gis | b4^"quoted" r8 ais\p a4( f)
1074 }
1075
1076 oboeNotes = \relative c'' {
1077   c4 cis c b \quoteDuring #"flute" { e4 r8 ais b4 a }
1078 }
1079
1080 \addQuote "flute" { \fluteNotes }
1081
1082 \score {
1083   <<
1084     \new Staff \with { instrumentName = "Flute" } \fluteNotes
1085     \new Staff \with { instrumentName = "Oboe" } \oboeNotes
1086   >>
1087 }
1088 @end lilypond
1089
1090 The @code{\quoteDuring} command uses the @code{\transposition} settings
1091 of both quoted and quoting parts to produce notes for the quoting part
1092 that have the same sounding pitch as those in the quoted part.
1093
1094 @lilypond[verbatim,quote]
1095 clarinetNotes = \relative c'' {
1096   \transposition bes
1097   \key d \major
1098   b4 ais a ais | cis4^"quoted" r8 bis\p b4( f)
1099 }
1100
1101 oboeNotes = \relative c'' {
1102   c4 cis c b \quoteDuring #"clarinet" { s1 }
1103 }
1104
1105 \addQuote "clarinet" { \clarinetNotes }
1106
1107
1108 \score {
1109   <<
1110     \new Staff \with { instrumentName = "Clarinet" } \clarinetNotes
1111     \new Staff \with { instrumentName = "Oboe" } \oboeNotes
1112   >>
1113 }
1114 @end lilypond
1115
1116 By default quoted music will include all articulations, dynamics,
1117 markups, etc., in the quoted expression.  It is possible to choose which
1118 of these objects from the quoted music are displayed by using the
1119 @code{quotedEventTypes} context property.
1120
1121 @lilypond[verbatim,quote]
1122 fluteNotes = \relative c'' {
1123   a2 g2 |
1124   b4\<^"quoted" r8 ais a4\f( c->)
1125  }
1126
1127 oboeNotes = \relative c'' {
1128   c2. b4 |
1129   \quoteDuring #"flute" { s1 }
1130 }
1131
1132 \addQuote "flute" { \fluteNotes }
1133
1134 \score {
1135   <<
1136     \set Score.quotedEventTypes = #'(note-event articulation-event
1137                                      crescendo-event rest-event
1138                                      slur-event dynamic-event)
1139     \new Staff \with { instrumentName = "Flute" } \fluteNotes
1140     \new Staff \with { instrumentName = "Oboe" } \oboeNotes
1141   >>
1142  }
1143 @end lilypond
1144
1145 Quotes can also be tagged, see @ref{Using tags}.
1146
1147 @snippets
1148
1149 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
1150 {quoting-another-voice-with-transposition.ly}
1151
1152 @cindex note-event
1153 @cindex articulation-event
1154 @cindex dynamic-event
1155 @cindex rest-event
1156
1157 @funindex quotedEventTypes
1158 @funindex quotedCueEventTypes
1159
1160 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
1161 {quoting-another-voice.ly}
1162
1163
1164 @seealso
1165 Notation Reference:
1166 @ref{Instrument transpositions},
1167 @ref{Using tags}.
1168
1169 Snippets:
1170 @rlsr{Staff notation}.
1171
1172 Internals Reference:
1173 @rinternals{Music classes},
1174 @rinternals{QuoteMusic},
1175 @rinternals{Voice}.
1176
1177 Installed Files:
1178 @file{scm/define-event-classes.scm}.
1179
1180
1181 @knownissues
1182
1183 Only the contents of the first @code{Voice} occurring in an
1184 @code{\addQuote} command will be considered for quotation, so
1185 @code{@var{music}} cannot contain @code{\new} and
1186 @code{\context Voice} statements that would switch to a different
1187 Voice.
1188
1189 Quoting grace notes is broken and can even cause LilyPond to
1190 crash.
1191
1192 Quoting nested triplets may result in poor notation.
1193
1194 In earlier versions of LilyPond (pre 2.11), @code{addQuote} was
1195 written entirely in lower-case letters: @code{\addquote}.
1196
1197
1198 @node Formatting cue notes
1199 @unnumberedsubsubsec Formatting cue notes
1200
1201 @cindex cues
1202 @cindex cue notes
1203 @cindex cue notes, formatting
1204 @cindex fragments
1205 @cindex quoting other voices
1206 @cindex cues, formatting
1207
1208 @funindex \cueDuring
1209 @funindex cueDuring
1210 @funindex \quoteDuring
1211 @funindex quoteDuring
1212
1213 The previous section explains how to create quotations.  The
1214 @code{\cueDuring} command is a more specialized form of
1215 @code{\quoteDuring}, being particularly useful for inserting cue
1216 notes into a part.  The syntax is as follows:
1217
1218 @example
1219 \cueDuring #@var{partname} #@var{voice} @var{music}
1220 @end example
1221
1222 This command copies only the notes and rests from the
1223 corresponding measures from @code{@var{partname}} into a
1224 @code{CueVoice} context.  The @code{CueVoice} is created
1225 implicitly, and occurs simultaneously with @code{@var{music}},
1226 which creates a polyphonic situation.  The @code{@var{voice}}
1227 argument determines whether the cue notes should be notated as a
1228 first or second voice; @code{UP} corresponds to the first voice,
1229 and @code{DOWN} corresponds to the second.
1230
1231 @lilypond[verbatim,quote]
1232 oboe = \relative c'' {
1233   r2 r8 d16(\f f e g f a)
1234   g8 g16 g g2.
1235 }
1236 \addQuote "oboe" { \oboe }
1237
1238 \new Voice \relative c'' {
1239   \cueDuring #"oboe" #UP { R1 }
1240   g2 c,
1241 }
1242 @end lilypond
1243
1244 @noindent
1245 In the above example, the @code{Voice} context had to be
1246 explicitly declared, or else the entire music expression would
1247 belong to the @code{CueVoice} context.
1248
1249 It is possible to adjust which aspects of the music are quoted with
1250 @code{\cueDuring} by setting the @code{quotedCueEventTypes}
1251 property.  Its default value is @code{#'(note-event rest-event
1252 tie-event beam-event tuplet-span-event)}, which means that only
1253 notes, rests, ties, beams and tuplets are quoted, but not
1254 articulations, dynamic marks, markup etc.
1255
1256 @lilypond[verbatim,quote]
1257 oboe = \relative c'' {
1258   r2 r8 d16(\f f e g f a)
1259   g8 g16 g g2.
1260 }
1261 \addQuote "oboe" { \oboe }
1262
1263 \new Voice \relative c'' {
1264   \set Score.quotedCueEventTypes = #'(note-event rest-event tie-event
1265                                       beam-event tuplet-span-event
1266                                       dynamic-event slur-event)
1267   \cueDuring #"oboe" #UP { R1 }
1268   g2 c,
1269 }
1270 @end lilypond
1271
1272 Markup can be used to show the name of the quoted instrument.  Also,
1273 if the cue notes require a change in clef, the original clef should
1274 be restored at the end of the cue notes.
1275
1276 @lilypond[verbatim,quote]
1277 flute = \relative c'' {
1278   r2. c4 d8 c d e fis2 g2 d2
1279 }
1280 bassoon = \relative c {
1281   \clef bass
1282   R1
1283   \clef treble
1284   s1*0^\markup { \tiny "flute" }
1285   \cueDuring #"flute" #UP { R1 }
1286   \clef bass
1287   g4. b8 d2
1288 }
1289 \addQuote "flute" { \flute }
1290 \new Staff {
1291   \bassoon
1292 }
1293 @end lilypond
1294
1295 @cindex removing cues
1296 @cindex removing cue notes
1297 @cindex cue notes, removing
1298
1299 @funindex \killCues
1300 @funindex killCues
1301
1302 The @code{\killCues} command removes cue notes from a music
1303 expression, so the same music expression can be used to produce
1304 the instrument part with cues and the score.  The @code{\killCues}
1305 command removes only the notes and events that were quoted by
1306 @code{\cueDuring}.  Other markup associated with cues, such as clef
1307 changes and a label identifying the source instrument, can be
1308 tagged for selective inclusion in the score; see @ref{Using tags}.
1309
1310 @lilypond[verbatim,quote]
1311 flute = \relative c'' {
1312   r2. c4 d8 c d e fis2 g2 d2
1313 }
1314 bassoon = \relative c {
1315   \clef bass
1316   R1
1317   \tag #'part {
1318     \clef treble
1319     s1*0^\markup { \tiny "flute" }
1320   }
1321   \cueDuring #"flute" #UP { R1 }
1322   \tag #'part \clef bass
1323   g4. b8 d2
1324 }
1325 \addQuote "flute" { \flute }
1326
1327 \new Staff {
1328   \bassoon
1329 }
1330 \new StaffGroup <<
1331   \new Staff {
1332     \flute
1333   }
1334   \new Staff {
1335     \removeWithTag #'part { \killCues { \bassoon } }
1336   }
1337 >>
1338 @end lilypond
1339
1340 Alternatively, Clef changes and instrument labels can be
1341 collected into an instrument definition for repeated use, using
1342 @code{\addInstrumentDefinition} described in
1343 @ref{Instrument names}.
1344
1345 @funindex \transposedCueDuring
1346 @funindex transposedCueDuring
1347
1348 Like @code{\quoteDuring}, @code{\cueDuring} takes instrument
1349 transpositions into account.  Cue notes are produced at the
1350 pitches that would be written for the instrument receiving the cue
1351 to produce the sounding pitches of the source instrument.
1352
1353 To transpose cue notes differently, use
1354 @code{\transposedCueDuring}.  This command takes an extra argument
1355 to specify (in absolute mode) the printed pitch that you want to
1356 represent the sound of a concert middle C.  This is useful for
1357 taking cues from an instrument in a completely different register.
1358
1359 @lilypond[verbatim,quote]
1360 piccolo = \relative c''' {
1361   \clef "treble^8"
1362   R1
1363   c8 c c e g2
1364   c4 g g2
1365 }
1366 bassClarinet = \relative c' {
1367   \key d \major
1368   \transposition bes,
1369   d4 r a r
1370   \transposedCueDuring #"piccolo" #UP d { R1 }
1371   d4 r a r
1372 }
1373
1374 \addQuote "piccolo" { \piccolo }
1375
1376 <<
1377   \new Staff \piccolo
1378   \new Staff \bassClarinet
1379 >>
1380 @end lilypond
1381
1382 @cindex notes, smaller
1383 @cindex smaller notes
1384
1385 A @code{CueVoice} context may be created explicitly if notes of a
1386 smaller size are required, for example to set an alternative
1387 sequence of notes more suitable for a higher or lower voice.
1388
1389 @lilypond[verbatim,relative=2]
1390 \time 12/8
1391 \key ees \major
1392 g4 ees8 f4 g8
1393 \stemDown
1394 <<
1395   { d4. bes4 c8 }
1396   \new CueVoice
1397   { g'4. f4 ees8 }
1398 >>
1399 \stemUp
1400 d2. d2.
1401 @end lilypond
1402
1403
1404 @seealso
1405 Notation Reference:
1406 @ref{Instrument transpositions},
1407 @ref{Instrument names},
1408 @ref{Musical cues},
1409 @ref{Using tags}.
1410
1411 Snippets:
1412 @rlsr{Staff notation}.
1413
1414 Internals Reference:
1415 @rinternals{CueVoice},
1416 @rinternals{Voice}.
1417
1418
1419 @knownissues
1420
1421 Collisions can occur with rests, when using @code{\cueDuring},
1422 between @code{Voice} and @code{CueVoice} contexts.
1423