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