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