]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/notation/staff.itely
Merge branch 'master' into lilypond/translation
[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.13.36"
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
278 @node Nested staff groups
279 @unnumberedsubsubsec Nested staff groups
280
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
288
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.
292
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   >>
306 >>
307 @end lilypond
308
309 New nested staff group contexts can be defined.  For details, see
310 @ref{Defining new contexts}.
311
312
313 @snippets
314
315 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
316 {nesting-staves.ly}
317
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 @node Separating systems
337 @unnumberedsubsubsec Separating systems
338
339 @cindex system separator mark
340
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.
345
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   }
375 }
376 @end lilypond
377
378 @seealso
379 Notation Reference:
380 @ref{Page formatting}.
381
382 Snippets:
383 @rlsr{Staff notation}.
384
385
386 @node Modifying single staves
387 @subsection Modifying single staves
388
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.
393
394 @menu
395 * Staff symbol::
396 * Ossia staves::
397 * Hiding staves::
398 @end menu
399
400
401 @node Staff symbol
402 @unnumberedsubsubsec Staff symbol
403
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
419
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.
424
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}.
429
430 @lilypond[verbatim,quote,relative=2]
431 \new Staff \with {
432   \override StaffSymbol #'line-count = #3
433 }
434 { d4 d d d }
435 @end lilypond
436
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.
440
441 @lilypond[verbatim,quote,relative=1]
442 \new Staff \with {
443   \override StaffSymbol #'thickness = #3
444 }
445 { e4 d c b }
446 @end lilypond
447
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.
452
453 @lilypond[verbatim,quote,relative=1]
454 \new Staff \with {
455   \override StaffSymbol #'ledger-line-thickness = #'(1 . 0.2)
456 }
457 { e4 d c b }
458 @end lilypond
459
460 The distance between staff lines can be changed.  This setting
461 affects the spacing of ledger lines as well.
462
463 @lilypond[verbatim,quote,relative=1]
464 \new Staff \with {
465   \override StaffSymbol #'staff-space = #1.5
466 }
467 { a4 b c d }
468 @end lilypond
469
470 Further details about the properties of @code{StaffSymbol} can be
471 found in @rinternals{staff-symbol-interface}.
472
473 @cindex stopping a staff
474 @cindex starting a staff
475 @cindex staff, starting
476 @cindex staff, stopping
477
478 @funindex \startStaff
479 @funindex startStaff
480 @funindex \stopStaff
481 @funindex stopStaff
482
483 Modifications to staff properties in the middle of a score can be
484 placed between @code{\stopStaff} and @code{\startStaff}:
485
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
497
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.
501
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
509
510
511 @predefined
512 @code{\startStaff},
513 @code{\stopStaff}.
514 @endpredefined
515
516
517 @snippets
518
519 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
520 {making-some-staff-lines-thicker-than-the-others.ly}
521
522
523 @seealso
524 Music Glossary:
525 @rglos{line},
526 @rglos{ledger line},
527 @rglos{staff}.
528
529 Notation Reference:
530 @ref{Clef}.
531
532 Snippets:
533 @rlsr{Staff notation}.
534
535 Internals Reference:
536 @rinternals{StaffSymbol},
537 @rinternals{staff-symbol-interface}.
538
539
540 @node Ossia staves
541 @unnumberedsubsubsec Ossia staves
542
543 @cindex staff, Frenched
544 @cindex ossia
545 @cindex Frenched staves
546 @cindex staff, resizing of
547 @cindex resizing of staves
548
549 @funindex \startStaff
550 @funindex startStaff
551 @funindex \stopStaff
552 @funindex stopStaff
553
554 @notation{Ossia} staves can be set by creating a new simultaneous
555 staff in the appropriate location:
556
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
565 }
566 @end lilypond
567
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}.
575
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.
579
580 @lilypond[verbatim,quote]
581 \new Staff = main \relative c'' {
582   c4 b d c
583   <<
584     { c4 b d c }
585
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
597 }
598 @end lilypond
599
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.
607
608 @lilypond[verbatim,quote,ragged-right]
609 <<
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 }
618
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   }
637 >>
638 @end lilypond
639
640
641 Using the @code{\Staff \RemoveEmptyStaves} 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{\Staff \RemoveEmptyStaves}, see @ref{Hiding staves}.
646
647 @lilypond[verbatim,quote,ragged-right]
648 <<
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   }
667 >>
668
669 \layout {
670   \context {
671     \Staff \RemoveEmptyStaves
672     \override VerticalAxisGroup #'remove-first = ##t
673   }
674 }
675 @end lilypond
676
677
678 @snippets
679
680 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
681 {vertically-aligning-ossias-and-lyrics.ly}
682
683
684 @seealso
685 Music Glossary:
686 @rglos{ossia},
687 @rglos{staff},
688 @rglos{Frenched staff}.
689
690 Learning Manual:
691 @rlearning{Nesting music expressions},
692 @rlearning{Size of objects},
693 @rlearning{Length and thickness of objects}.
694
695 Notation Reference:
696 @ref{Hiding staves}.
697
698 Snippets:
699 @rlsr{Staff notation}.
700
701 Internals Reference:
702 @rinternals{StaffSymbol}.
703
704
705 @node Hiding staves
706 @unnumberedsubsubsec Hiding staves
707
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
714
715 @funindex \RemoveEmptyStaves
716 @funindex Staff_symbol_engraver
717 @funindex \stopStaff
718 @funindex stopStaff
719
720
721 Staff lines can be hidden by removing the
722 @code{Staff_symbol_engraver} from the @code{Staff} context.  As an
723 alternative, @code{\stopStaff} may be used.
724
725 @lilypond[verbatim,quote]
726 \new Staff \with {
727   \remove "Staff_symbol_engraver"
728 }
729 \relative c''' { a8 f e16 d c b a2 }
730 @end lilypond
731
732
733 Empty staves can be hidden by setting the
734 @code{\Staff \RemoveEmptyStaves} command in the @code{\layout}
735 block.  In orchestral scores, this style is known as @q{Frenched
736 Score}.  By default, this command hides and removes all empty
737 staves in a score except for those in the first system.
738
739 @warning{A staff is considered empty when it contains only
740 multi-measure rests, rests, skips, spacer rests, or a combination of these
741 elements.}
742
743 @lilypond[verbatim,quote,ragged-right]
744 \layout {
745   \context {
746     \Staff \RemoveEmptyStaves
747   }
748 }
749
750 \relative c' <<
751   \new Staff {
752     e4 f g a \break
753     b1 \break
754     a4 b c2
755   }
756   \new Staff {
757     c,4 d e f \break
758     R1 \break
759     f4 g c,2
760   }
761 >>
762 @end lilypond
763
764 @cindex ossia
765
766 @noindent
767 @code{\Staff \RemoveEmptyStaves} can also be used to create ossia
768 sections for a staff.  For details, see @ref{Ossia staves}.
769
770 @cindex hiding ancient staves
771 @cindex hiding rhythmic staves
772
773 @funindex \RemoveEmptyStaves
774
775 The @code{\VaticanaStaff \RemoveEmptyStaves} command may be used to
776 hide empty staves in ancient music contexts.  Similarly,
777 @code{\RhythmicStaff \RemoveEmptyStaves} may be used to hide empty
778 @code{RhythmicStaff} contexts.
779
780
781 @predefined
782 @code{\Staff \RemoveEmptyStaves},
783 @code{\VaticanaStaff \RemoveEmptyStaves},
784 @code{\RhythmicStaff \RemoveEmptyStaves}.
785 @endpredefined
786
787
788 @snippets
789
790 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
791 {removing-the-first-empty-line.ly}
792
793
794 @seealso
795 Music Glossary:
796 @rglos{Frenched staff}.
797
798 Learning Manual:
799 @rlearning{Visibility and color of objects}.
800
801 Notation Reference:
802 @ref{Changing context default settings},
803 @ref{Staff symbol},
804 @ref{Ossia staves},
805 @ref{Hidden notes},
806 @ref{Invisible rests},
807 @ref{Visibility of objects}.
808
809 Snippets:
810 @rlsr{Staff notation}.
811
812 Internals Reference:
813 @rinternals{ChordNames},
814 @rinternals{FiguredBass},
815 @rinternals{Lyrics},
816 @rinternals{Staff},
817 @rinternals{VerticalAxisGroup},
818 @rinternals{Staff_symbol_engraver}.
819
820
821 @knownissues
822
823 Removing @code{Staff_symbol_engraver} also hides bar lines.  If
824 bar line visibility is forced, formatting errors may occur.  In
825 this case, use the following overrides instead of removing the
826 engraver:
827
828 @example
829 \override StaffSymbol #'stencil = ##f
830 \override NoteHead #'no-ledgers = ##t
831 @end example
832
833 For the Known issues and warnings associated with
834 @code{\Staff \RemoveEmptyStaves} see 
835 @ref{Changing context default settings}.
836
837 @node Writing parts
838 @subsection Writing parts
839
840 This section explains how to insert tempo indications and
841 instrument names into a score.  Methods to quote other voices and
842 format cue notes are also described.
843
844 @menu
845 * Instrument names::
846 * Quoting other voices::
847 * Formatting cue notes::
848 @end menu
849
850 @node Instrument names
851 @unnumberedsubsubsec Instrument names
852
853 @cindex instrument names
854 @cindex instrument names, short
855
856 Instrument names can be printed on the left side of staves in the
857 @code{Staff} and @code{PianoStaff} contexts.  The value of
858 @code{instrumentName} is used for the first staff, and the value
859 of @code{shortInstrumentName} is used for all succeeding staves.
860
861 @lilypond[verbatim,quote,ragged-right,relative=1]
862 \set Staff.instrumentName = #"Violin "
863 \set Staff.shortInstrumentName = #"Vln "
864 c4.. g'16 c4.. g'16
865 \break
866 c1
867 @end lilypond
868
869 Markup mode can be used to create more complicated instrument
870 names:
871
872 @lilypond[verbatim,quote,relative=2]
873 \set Staff.instrumentName = \markup {
874   \column { "Clarinetti"
875             \line { "in B" \smaller \flat } } }
876 c4 c,16 d e f g2
877 @end lilypond
878
879 @cindex instrument names, centering
880
881 When two or more staff contexts are grouped together, the
882 instrument names and short instrument names are centered by
883 default.  To center multi-line instrument names,
884 @code{\center-column} must be used:
885
886 @lilypond[verbatim,quote,indent=1.5\cm,relative=2]
887 <<
888   \new Staff {
889     \set Staff.instrumentName = #"Flute"
890     f2 g4 f
891   }
892   \new Staff {
893     \set Staff.instrumentName = \markup \center-column {
894       Clarinet
895       \line { "in B" \smaller \flat }
896     }
897     c4 b c2
898   }
899 >>
900 @end lilypond
901
902 @funindex indent
903 @funindex short-indent
904
905 However, if the instrument names are longer, the instrument names
906 in a staff group may not be centered unless the @code{indent} and
907 @code{short-indent} settings are increased.  For details about
908 these settings, see @ref{Horizontal dimensions}.
909
910 @lilypond[verbatim,quote,ragged-right]
911 \layout {
912   indent = 3.0\cm
913   short-indent = 1.5\cm
914 }
915
916 \relative c'' <<
917   \new Staff {
918     \set Staff.instrumentName = #"Alto Flute in G"
919     \set Staff.shortInstrumentName = #"Fl."
920     f2 g4 f \break
921     g4 f g2
922   }
923   \new Staff {
924     \set Staff.instrumentName = #"Clarinet"
925     \set Staff.shortInstrumentName = #"Clar."
926     c,4 b c2 \break
927     c2 b4 c
928   }
929 >>
930 @end lilypond
931
932 @cindex instrument names, adding to other contexts
933
934 To add instrument names to other contexts (such as
935 @code{GrandStaff}, @code{ChoirStaff}, or @code{StaffGroup}),
936 @code{Instrument_name_engraver} must be added to that context.
937 For details, see @ref{Modifying context plug-ins}.
938
939 @cindex instrument names, changing
940 @cindex changing instrument names
941
942 Instrument names may be changed in the middle of a piece.
943 However, remember that @code{instrumentName} will not be
944 displayed in the middle of the piece, as it only appears
945 on the first staff:
946
947 @lilypond[verbatim,quote,ragged-right,relative=1]
948 \set Staff.instrumentName = #"First"
949 \set Staff.shortInstrumentName = #"one"
950 c1 c c c \break
951 c1 c c c \break
952 \set Staff.instrumentName = #"Second"
953 \set Staff.shortInstrumentName = #"two"
954 c1 c c c \break
955 c1 c c c \break
956 @end lilypond
957
958 @cindex instrument switch
959 @cindex switching instruments
960
961 @funindex \addInstrumentDefinition
962 @funindex addInstrumentDefinition
963 @funindex \instrumentSwitch
964 @funindex instrumentSwitch
965
966 If an instrument @emph{switch} is needed,
967 @code{\addInstrumentDefinition} may be used in combination with
968 @code{\instrumentSwitch} to create a detailed list of the
969 necessary changes for the switch.  The
970 @code{\addInstrumentDefinition} command has two arguments: an
971 identifying string, and an association list of context properties
972 and values to be used for the instrument.  It must be placed in
973 the toplevel scope.  @code{\instrumentSwitch} is used in the music
974 expression to declare the instrument switch:
975
976 @lilypond[verbatim,quote,ragged-right]
977 \addInstrumentDefinition #"contrabassoon"
978   #`((instrumentTransposition . ,(ly:make-pitch -1 0 0))
979      (shortInstrumentName . "Cbsn.")
980      (clefGlyph . "clefs.F")
981      (middleCPosition . 6)
982      (clefPosition . 2)
983      (instrumentCueName . ,(make-bold-markup "cbsn."))
984      (midiInstrument . "bassoon"))
985
986 \new Staff \with {
987   instrumentName = #"Bassoon"
988 }
989 \relative c' {
990   \clef tenor
991   \compressFullBarRests
992   c2 g'
993   R1*16
994   \instrumentSwitch "contrabassoon"
995   c,,2 g \break
996   c,1 ~ | c1
997 }
998 @end lilypond
999
1000
1001 @seealso
1002 Notation Reference:
1003 @ref{Horizontal dimensions},
1004 @ref{Modifying context plug-ins}.
1005
1006 Snippets:
1007 @rlsr{Staff notation}.
1008
1009 Internals Reference:
1010 @rinternals{InstrumentName},
1011 @rinternals{PianoStaff},
1012 @rinternals{Staff}.
1013
1014
1015 @node Quoting other voices
1016 @unnumberedsubsubsec Quoting other voices
1017
1018 @cindex cues
1019 @cindex quoting other voices
1020 @cindex fragments
1021 @cindex cue notes
1022
1023 @funindex \addQuote
1024 @funindex addQuote
1025 @funindex \quoteDuring
1026 @funindex quoteDuring
1027 @funindex \transposition
1028 @funindex transposition
1029
1030 It is very common for one voice to double some of the music from
1031 another voice.  For example, the first and second violins may play the
1032 same notes during a passage of music.  In LilyPond this is accomplished
1033 by letting one voice @emph{quote} the other voice without having to
1034 re-enter it.
1035
1036 Before a part can be quoted, the @code{\addQuote} command must be used
1037 to initialize the quoted fragment.  This command must be used in the
1038 toplevel scope.  The first argument is an identifying string, and the
1039 second is a music expression:
1040
1041 @example
1042 flute = \relative c'' @{
1043   a4 gis g gis
1044 @}
1045 \addQuote "flute" @{ \flute @}
1046 @end example
1047
1048 The @code{\quoteDuring} command is used to indicate the point where the
1049 quotation begins.  It is followed by two arguments: the name of the
1050 quoted voice, as defined with @code{\addQuote}, and a music expression
1051 that indicates the duration of the quote, usually spacer rests or
1052 multi-measure rests.  The corresponding music (including all articulations,
1053 dynamics, markup, etc.) from the quoted voice is inserted into the music
1054 expression:
1055
1056 @lilypond[verbatim,quote]
1057 flute = \relative c'' {
1058   a4 gis g->\f gis^\markup{quoted}
1059 }
1060 \addQuote "flute" { \flute }
1061
1062 \relative c' {
1063   c4 cis \quoteDuring #"flute" { s2 }
1064 }
1065 @end lilypond
1066
1067 If the music expression used for @code{\quoteDuring} contains
1068 anything but a spacer rest or multi-measure rest, a polyphonic
1069 situation is created, which is often not desirable:
1070
1071 @lilypond[verbatim,quote]
1072 flute = \relative c'' {
1073   a4 gis g gis
1074 }
1075 \addQuote "flute" { \flute }
1076
1077 \relative c' {
1078   c4 cis \quoteDuring #"flute" { c4 b }
1079 }
1080 @end lilypond
1081
1082 Quotations recognize instrument transposition settings for both
1083 the source and target instruments if the @code{\transposition}
1084 command is used.  For details about @code{\transposition}, see
1085 @ref{Instrument transpositions}.
1086
1087 @lilypond[verbatim,quote]
1088 clarinet = \relative c'' {
1089   \transposition bes
1090   a4 gis g gis
1091 }
1092 \addQuote "clarinet" { \clarinet }
1093
1094 \relative c' {
1095   c4 cis \quoteDuring #"clarinet" { s2 }
1096 }
1097 @end lilypond
1098
1099 It is possible to tag quotations with unique names in order to
1100 process them in different ways.  For details about this procedure,
1101 see @ref{Using tags}.
1102
1103 It is also possible to adjust which objects from the original voice are quoted
1104 by changing the @code{quotedEventTypes} property.  By default, its value is
1105 @code{#'(StreamEvent)}, which means that everything is quoted.  Setting it
1106 to e.g. @code{#'(note-event rest-event tie-event)} causes lilypond to quote
1107 only notes, rests and ties, but no articulations, markup or dynamics.
1108
1109 @lilypond[verbatim,quote]
1110 clarinet = \relative c'' {
1111   a4 gis g->\f gis^\markup{quoted}
1112 }
1113 \addQuote "clarinet" { \clarinet }
1114
1115 \relative c' {
1116   \set Score.quotedEventTypes = #'(note-event rest-event tie-event)
1117   c4 cis \quoteDuring #"clarinet" { s2 }
1118 }
1119 @end lilypond
1120
1121 @snippets
1122
1123 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
1124 {quoting-another-voice-with-transposition.ly}
1125
1126 @cindex note-event
1127 @cindex articulation-event
1128 @cindex dynamic-event
1129 @cindex rest-event
1130
1131 @funindex quotedEventTypes
1132 @funindex quotedCueEventTypes
1133
1134 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
1135 {quoting-another-voice.ly}
1136
1137
1138 @seealso
1139 Notation Reference:
1140 @ref{Instrument transpositions},
1141 @ref{Using tags}.
1142
1143 Snippets:
1144 @rlsr{Staff notation}.
1145
1146 Internals Reference:
1147 @rinternals{QuoteMusic},
1148 @rinternals{Voice}.
1149
1150
1151 @knownissues
1152
1153 Only the contents of the first @code{Voice} occurring in an
1154 @code{\addQuote} command will be considered for quotation, so
1155 @code{@var{music}} cannot contain @code{\new} and
1156 @code{\context Voice} statements that would switch to a different
1157 Voice.
1158
1159 Quoting grace notes is broken and can even cause LilyPond to
1160 crash.
1161
1162 Quoting nested triplets may result in poor notation.
1163
1164 In earlier versions of LilyPond (pre 2.11), @code{addQuote} was
1165 written entirely in lower-case letters: @code{\addquote}.
1166
1167
1168 @node Formatting cue notes
1169 @unnumberedsubsubsec Formatting cue notes
1170
1171 @cindex cues
1172 @cindex cue notes
1173 @cindex cue notes, formatting
1174 @cindex fragments
1175 @cindex quoting other voices
1176 @cindex cues, formatting
1177
1178 @funindex \cueDuring
1179 @funindex cueDuring
1180 @funindex \quoteDuring
1181 @funindex quoteDuring
1182
1183 The previous section explains how to create quotations.  The
1184 @code{\cueDuring} command is a more specialized form of
1185 @code{\quoteDuring}, being particularly useful for inserting cue
1186 notes into a part.  The syntax is as follows:
1187
1188 @example
1189 \cueDuring #@var{partname} #@var{voice} @var{music}
1190 @end example
1191
1192 This command copies only the notes and rests from the
1193 corresponding measures from @code{@var{partname}} into a
1194 @code{CueVoice} context.  The @code{CueVoice} is created
1195 implicitly, and occurs simultaneously with @code{@var{music}},
1196 which creates a polyphonic situation.  The @code{@var{voice}}
1197 argument determines whether the cue notes should be notated as a
1198 first or second voice; @code{UP} corresponds to the first voice,
1199 and @code{DOWN} corresponds to the second.
1200
1201 @lilypond[verbatim,quote]
1202 oboe = \relative c'' {
1203   r2 r8 d16(\f f e g f a)
1204   g8 g16 g g2.
1205 }
1206 \addQuote "oboe" { \oboe }
1207
1208 \new Voice \relative c'' {
1209   \cueDuring #"oboe" #UP { R1 }
1210   g2 c,
1211 }
1212 @end lilypond
1213
1214 @noindent
1215 In the above example, the @code{Voice} context had to be
1216 explicitly declared, or else the entire music expression would
1217 belong to the @code{CueVoice} context.
1218
1219 It is possible to adjust which aspects of the music are quoted with
1220 @code{\cueDuring} by setting the @code{quotedCueEventTypes}
1221 property.  Its default value is @code{#'(note-event rest-event
1222 tie-event beam-event tuplet-span-event)}, which means that only
1223 notes, rests, ties, beams and tuplets are quoted, but not
1224 articulations, dynamic marks, markup etc.
1225
1226 @lilypond[verbatim,quote]
1227 oboe = \relative c'' {
1228   r2 r8 d16(\f f e g f a)
1229   g8 g16 g g2.
1230 }
1231 \addQuote "oboe" { \oboe }
1232
1233 \new Voice \relative c'' {
1234   \set Score.quotedCueEventTypes = #'(note-event rest-event tie-event
1235                                       beam-event tuplet-span-event
1236                                       dynamic-event slur-event)
1237   \cueDuring #"oboe" #UP { R1 }
1238   g2 c,
1239 }
1240 @end lilypond
1241
1242 Markup can be used to show the name of the quoted instrument.  Also,
1243 if the cue notes require a change in clef, the original clef should
1244 be restored at the end of the cue notes.
1245
1246 @lilypond[verbatim,quote]
1247 flute = \relative c'' {
1248   r2. c4 d8 c d e fis2 g2 d2
1249 }
1250 bassoon = \relative c {
1251   \clef bass
1252   R1
1253   \clef treble
1254   s1*0^\markup { \tiny "flute" }
1255   \cueDuring #"flute" #UP { R1 }
1256   \clef bass
1257   g4. b8 d2
1258 }
1259 \addQuote "flute" { \flute }
1260 \new Staff {
1261   \bassoon
1262 }
1263 @end lilypond
1264
1265 @cindex removing cues
1266 @cindex removing cue notes
1267 @cindex cue notes, removing
1268
1269 @funindex \killCues
1270 @funindex killCues
1271
1272 The @code{\killCues} command removes cue notes from a music
1273 expression, so the same music expression can be used to produce
1274 the instrument part with cues and the score.  The @code{\killCues}
1275 command removes only the notes and events that were quoted by
1276 @code{\cueDuring}.  Other markup associated with cues, such as clef
1277 changes and a label identifying the source instrument, can be
1278 tagged for selective inclusion in the score; see @ref{Using tags}.
1279
1280 @lilypond[verbatim,quote]
1281 flute = \relative c'' {
1282   r2. c4 d8 c d e fis2 g2 d2
1283 }
1284 bassoon = \relative c {
1285   \clef bass
1286   R1
1287   \tag #'part {
1288     \clef treble
1289     s1*0^\markup { \tiny "flute" }
1290   }
1291   \cueDuring #"flute" #UP { R1 }
1292   \tag #'part \clef bass
1293   g4. b8 d2
1294 }
1295 \addQuote "flute" { \flute }
1296
1297 \new Staff {
1298   \bassoon
1299 }
1300 \new StaffGroup <<
1301   \new Staff {
1302     \flute
1303   }
1304   \new Staff {
1305     \removeWithTag #'part { \killCues { \bassoon } }
1306   }
1307 >>
1308 @end lilypond
1309
1310 Alternatively, Clef changes and instrument labels can be
1311 collected into an instrument definition for repeated use, using
1312 @code{\addInstrumentDefinition} described in 
1313 @ref{Instrument names}.
1314
1315 @funindex \transposedCueDuring
1316 @funindex transposedCueDuring
1317
1318 Like @code{\quoteDuring}, @code{\cueDuring} takes instrument
1319 transpositions into account.  Cue notes are produced at the
1320 pitches that would be written for the instrument receiving the cue
1321 to produce the sounding pitches of the source instrument.
1322
1323 To transpose cue notes differently, use
1324 @code{\transposedCueDuring}.  This command takes an extra argument
1325 to specify (in absolute mode) the printed pitch that you want to
1326 represent the sound of a concert middle C.  This is useful for
1327 taking cues from an instrument in a completely different register.
1328
1329 @lilypond[verbatim,quote]
1330 piccolo = \relative c''' {
1331   \clef "treble^8"
1332   R1
1333   c8 c c e g2
1334   c4 g g2
1335 }
1336 bassClarinet = \relative c' {
1337   \key d \major
1338   \transposition bes,
1339   d4 r a r
1340   \transposedCueDuring #"piccolo" #UP d { R1 }
1341   d4 r a r
1342 }
1343
1344 \addQuote "piccolo" { \piccolo }
1345
1346 <<
1347   \new Staff \piccolo
1348   \new Staff \bassClarinet
1349 >>
1350 @end lilypond
1351
1352 @cindex notes, smaller
1353 @cindex smaller notes
1354
1355 A @code{CueVoice} context may be created explicitly if notes of a
1356 smaller size are required, for example to set an alternative
1357 sequence of notes more suitable for a higher or lower voice.
1358
1359 @lilypond[verbatim,relative=2]
1360 \time 12/8
1361 \key ees \major
1362 g4 ees8 f4 g8
1363 \stemDown
1364 <<
1365   { d4. bes4 c8 }
1366   \new CueVoice
1367   { g'4. f4 ees8 }
1368 >>
1369 \stemUp
1370 d2. d2.
1371 @end lilypond
1372
1373
1374 @seealso
1375 Notation Reference:
1376 @ref{Instrument transpositions},
1377 @ref{Instrument names},
1378 @ref{Musical cues},
1379 @ref{Using tags}.
1380
1381 Snippets:
1382 @rlsr{Staff notation}.
1383
1384 Internals Reference:
1385 @rinternals{CueVoice},
1386 @rinternals{Voice}.
1387
1388
1389 @knownissues
1390
1391 Collisions can occur with rests, when using @code{\cueDuring},
1392 between @code{Voice} and @code{CueVoice} contexts.
1393