]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/staff.itely
bar space line.
[lilypond.git] / Documentation / user / 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.  See TRANSLATION for details.
7 @end ignore
8
9 @node Staff notation
10 @section Staff notation
11
12 Notes, dynamic signs, etc., are grouped with a set of horizontal
13 lines, called a staff (plural @q{staves}).  In LilyPond, these
14 lines are drawn using a separate layout object called @code{staff
15 symbol}.
16
17 Two or more staves can be grouped vertically in a
18 @internalsref{GrandStaff}, a @internalsref{StaffGroup}, or a
19 @internalsref{ChoirStaff}.
20
21
22 @menu
23 * Displaying staves::           
24 * Writing parts::               
25 @end menu
26
27
28 @node Displaying staves
29 @subsection Displaying staves
30
31 @menu
32 * System start delimiters::     
33 * Staff symbol::                
34 * Hiding staves::               
35 @end menu
36
37 @node System start delimiters
38 @unnumberedsubsubsec System start delimiters
39
40 @cindex start of system
41 @cindex Staff, multiple
42 @cindex bracket, vertical
43 @cindex brace, vertical
44 @cindex grand staff
45 @cindex staff group
46 @cindex staff, choir
47
48 Many scores consist of more than one staff.  These staves can be
49 grouped in several different ways:
50
51 @itemize
52 @item
53 In a @internalsref{GrandStaff}, the group is started with a brace
54 at the left, and bar lines are connected between the staves. 
55
56 @lilypond[verbatim,ragged-right,quote]
57 \new GrandStaff
58 \relative <<
59   \new Staff { c1 c }
60   \new Staff { c c }
61 >>
62 @end lilypond
63
64 @item
65 In a @internalsref{StaffGroup}, the bar lines will be drawn through
66 all the staves, but the group is started with a bracket.
67
68 @lilypond[verbatim,ragged-right,quote]
69 \new StaffGroup
70 \relative <<
71   \new Staff { c1 c }
72   \new Staff { c c }
73 >>
74 @end lilypond
75
76 @item
77 In a @internalsref{ChoirStaff}, the group is started with a
78 bracket, but bar lines are not connected. 
79
80 @lilypond[verbatim,ragged-right,quote]
81 \new ChoirStaff
82 \relative <<
83   \new Staff { c1 c }
84   \new Staff { c c }
85 >>
86 @end lilypond
87
88 @item
89 If no context is specified, the default properties for the score
90 will be used: the group is started with a vertical line, and the
91 bar lines are not connected.  
92
93 @lilypond[verbatim,ragged-right,quote]
94 \relative <<
95   \new Staff { c1 c }
96   \new Staff { c c }
97 >>
98 @end lilypond
99 @end itemize
100
101 In addition to these four staff group types, other groupings can
102 be produced by changing various properties. E.g., the
103 @q{Mensurstriche} layout common in Renaissance music, with
104 bar lines running between but not through the staves, can be
105 produced from a @code{StaffGroup} or @code{GrandStaff} context if
106 the bar lines are made transparent in the @code{Staff} itself, with
107 the command @code{\override Staff.BarLine #'transparent = ##t}
108
109 @cindex staff, nested
110
111 Staff groups can be nested, using the context
112 @code{InnerStaffGroup} or @code{InnerChoirStaff}; see
113 @lsr{staff,staff-brackets.ly}
114 @c snippet 137
115
116 @commonprop
117
118 More complex nesting can be accomplished using the property
119 @internalsref{systemStartDelimiterHierarchy}: 
120
121 @lilypond[quote,ragged-right,verbatim]
122 \new StaffGroup
123 \relative <<
124   \set StaffGroup.systemStartDelimiterHierarchy
125     = #'(SystemStartSquare (SystemStartBracket a
126                              (SystemStartSquare b)) d)
127   \new Staff { c1 }
128   \new Staff { c1 }
129   \new Staff { c1 }
130   \new Staff { c1 }
131   \new Staff { c1 }
132 >>
133 @end lilypond
134
135 @seealso
136
137 Snippets: @lsrdir{staff}
138
139 Each staff group context sets the property
140 @code{systemStartDelimiter} to one of the values
141 @internalsref{SystemStartBar}, @internalsref{SystemStartBrace},
142 and @internalsref{SystemStartBracket}.  A fourth delimiter,
143 @code{systemStartSquare}, is also available, but must be
144 instantiated manually.
145
146 @commonprop
147
148 To display a bracket even if there is only one staff, see
149 @lsr{staff,display-bracket-with-only-one-staff-in-a
150 system.ly}
151 @c snippet 201
152
153 @node Staff symbol
154 @unnumberedsubsubsec Staff symbol
155
156 @cindex adjusting staff symbol
157
158 The layout object which draws the lines of a staff is called
159 @code{staff symbol}.  The staff symbol may be tuned in the number,
160 thickness and distance of lines, using properties.  This is
161 demonstrated in the example files
162 @lsr{staff,changing-the-number-of-lines-in-a-staff.ly} and
163 @lsr{staff,changing-the-staff-size.ly}.
164
165 In addition, staves may be started and stopped at will.  This is
166 done with @code{\startStaff} and @code{\stopStaff}.
167
168 @lilypond[verbatim,relative=2,fragment]
169 b4 b
170 \override Staff.StaffSymbol #'line-count = 2
171 \stopStaff \startStaff
172 b b
173 \revert Staff.StaffSymbol #'line-count
174 \stopStaff \startStaff
175 b b
176 @end lilypond
177
178 In combination with Frenched staves, this may be used to typeset
179 @emph{ossia} sections.  An example is shown here
180
181 @cindex staves, Frenched 
182 @cindex ossia
183
184 @lilypond[verbatim,relative=2,quote]
185 <<
186   \new Staff \with
187   {
188     \remove "Time_signature_engraver"
189     fontSize = #-2
190     \override StaffSymbol #'staff-space = #(magstep -2)
191     firstClef = ##f
192   }
193   \relative c'' {
194     \stopStaff
195     \skip 2
196
197     \startStaff
198     \clef treble
199     bes8[^"ossia" g bes g]
200     \stopStaff
201
202     s2
203
204     \startStaff
205     f8 d g4 
206   }
207   \new Staff  \relative
208   {
209     \time 2/4
210     c4 c g' g a a g2
211   }
212
213 >>
214 @end lilypond
215
216 @cindex staff lines, setting number of
217 @cindex staff lines, setting thickness of
218 @cindex thickness of staff lines, setting
219 @cindex number of staff lines, setting
220
221 @seealso
222
223 Snippets: @lsrdir{staff}
224
225 Internals Reference: @internalsref{StaffSymbol},
226 @internalsref{DrumStaff}.
227
228 Examples: @lsrdir{staff}
229
230
231 @node Hiding staves
232 @unnumberedsubsubsec Hiding staves
233
234 @cindex Frenched scores
235 @cindex staves, hiding 
236
237 In orchestral scores, staff lines that only have rests are usually
238 removed; this saves some space.  This style is called @q{French
239 Score}.  For @internalsref{Lyrics}, @internalsref{ChordNames} and
240 @internalsref{FiguredBass}, this is switched on by default.  When
241 the lines of these contexts turn out empty after the line-breaking
242 process, they are removed.
243
244 For normal staves, a specialized @internalsref{Staff} context is
245 available, which does the same: staves containing nothing (or only
246 multi-measure rests) are removed.  The context definition is
247 stored in @code{\RemoveEmptyStaffContext} variable.  Observe how
248 the second staff in this example disappears in the second line
249
250 @lilypond[quote,ragged-right,verbatim]
251 \layout {
252   \context { \RemoveEmptyStaffContext }
253 }
254
255 {
256   \relative c' <<
257     \new Staff { e4 f g a \break c1 }
258     \new Staff { c4 d e f \break R1 }
259   >>
260 }
261 @end lilypond
262
263 The first system shows all staves in full.  If empty staves should
264 be removed from the first system too, set @code{remove-first} to
265 true in @internalsref{VerticalAxisGroup}.
266
267 @example
268 \override Score.VerticalAxisGroup #'remove-first = ##t
269 @end example
270
271 To remove other types of contexts, use
272 @code{\AncientRemoveEmptyStaffContext} or
273 @code{\RemoveEmptyRhythmicStaffContext}.
274
275 Another application of the @code{\RemoveEmptyStaffContext} is to
276 make ossia sections, i.e., alternative melodies on a separate
277 piece of staff, with help of a Frenched staff.  See @ref{Staff
278 symbol}. 
279
280 You can make the staff lines invisible by removing the
281 @code{Staff_symbol_engraver} from the @code{Staff} context.
282
283
284 @lilypond[quote,ragged-right,verbatim]
285 \score {
286   \context Staff \relative c'' { c8 c c16 c c c }
287   \layout{
288     \context {
289       \Staff
290       \remove Staff_symbol_engraver
291     }
292   }
293 }
294 @end lilypond
295
296 @seealso
297
298 Snippets: @lsrdir{staff}
299
300 @node Writing parts
301 @subsection Writing parts
302
303 @menu
304 * Metronome marks::             
305 * Instrument names::            
306 * Quoting other voices::        
307 * Formatting cue notes::        
308 @end menu
309
310 @node Metronome marks
311 @unnumberedsubsubsec Metronome marks
312
313 @cindex Tempo
314 @cindex beats per minute
315 @cindex metronome marking
316
317 Metronome settings can be entered as follows
318
319 @example
320 \tempo @var{duration} = @var{per-minute}
321 @end example
322
323 In the MIDI output, they are interpreted as a tempo change.  In
324 the layout output, a metronome marking is printed
325
326 @funindex \tempo
327
328 @lilypond[quote,ragged-right,verbatim,fragment]
329 \tempo 8.=120 c''1
330 @end lilypond
331
332
333 @commonprop
334
335 To change the tempo in the MIDI output without printing anything,
336 make the metronome marking invisible @example \once \override
337 Score.MetronomeMark #'transparent = ##t @end example
338
339 To print other metronome markings, use these markup commands
340 @lilypond[quote,ragged-right,verbatim,relative,fragment]
341 c4^\markup {
342   (
343   \smaller \general-align #Y #DOWN \note #"16." #1
344   =
345   \smaller \general-align #Y #DOWN \note #"8" #1
346   ) }
347 @end lilypond
348
349 @noindent
350 For more details, see @ref{Text markup}.
351
352
353 @seealso
354
355 Internals Reference: @internalsref{MetronomeMark}, @ref{MIDI
356 output}.
357
358
359 @refbugs
360
361 Collisions are not checked.  If you have notes above the top line
362 of the staff (or notes with articulations, slurs, text, etc), then
363 the metronome marking may be printed on top of musical symbols.
364 If this occurs, increase the padding of the metronome mark to
365 place it further away from the staff.
366
367 @example
368 \override Score.MetronomeMark #'padding = #2.5
369 @end example
370
371 @c perhaps also an example of how to move it horizontally?
372
373 @seealso
374
375 Snippets: @lsrdir{staff}
376
377 @node Instrument names
378 @unnumberedsubsubsec Instrument names
379
380 In an orchestral score, instrument names are printed at the left
381 side of the staves.
382
383 This can be achieved by setting
384 @internalsref{Staff}.@code{instrumentName} and
385 @internalsref{Staff}.@code{shortInstrumentName}, or
386 @internalsref{PianoStaff}.@code{instrumentName} and
387 @internalsref{PianoStaff}.@code{shortInstrumentName}.  This will
388 print text before the start of the staff.  For the first staff,
389 @code{instrumentName} is used.  If set, @code{shortInstrumentName}
390 is used for the following staves.
391
392 @lilypond[quote,verbatim,ragged-right,relative=1,fragment]
393 \set Staff.instrumentName = "Ploink "
394 \set Staff.shortInstrumentName = "Plk "
395 c1
396 \break
397 c''
398 @end lilypond
399
400 You can also use markup texts to construct more complicated
401 instrument names, for example
402
403 @lilypond[quote,fragment,verbatim,ragged-right]
404 \set Staff.instrumentName = \markup {
405   \column { "Clarinetti"
406             \line { "in B" \smaller \flat } } }
407 c''1
408 @end lilypond
409
410 If you wish to center the instrument names, you must center all of
411 them individually:
412
413 @lilypond[quote,verbatim,ragged-right]
414 { <<
415 \new Staff {
416   \set Staff.instrumentName = \markup {
417     \center-align { "Clarinetti"
418       \line { "in B" \smaller \flat } } }
419   c''1
420 }
421 \new Staff {
422   \set Staff.instrumentName =
423        \markup{ \center-align { Vibraphone }}
424   c''1
425 }
426 >>
427 }
428 @end lilypond
429
430 For longer instrument names, it may be useful to increase the
431 @code{indent} setting in the @code{\layout} block.
432
433 To center instrument names while leaving extra space to the right,
434
435 @lilypond[quote,verbatim,ragged-right]
436 \new StaffGroup \relative
437 <<
438   \new Staff {
439     \set Staff.instrumentName =
440         \markup { \hcenter-in #10 "blabla" }
441     c1 c1
442   }
443   \new Staff {
444     \set Staff.instrumentName =
445          \markup { \hcenter-in #10 "blo" }
446     c1 c1
447   }
448 >>
449 @end lilypond
450
451 To add instrument names to other contexts (such as
452 @code{GrandStaff}, @code{ChoirStaff}, or @code{StaffGroup}), the
453 engraver must be added to that context.
454
455 @example
456 \layout@{
457   \context @{\GrandStaff \consists "Instrument_name_engraver"@}
458 @}
459 @end example
460
461 @noindent
462 More information about adding and removing engravers can be found
463 in @ref{Modifying context plug-ins}.
464
465 Instrument names may be changed in the middle of a piece,
466
467 @lilypond[quote,fragment,verbatim,ragged-right]
468 \set Staff.instrumentName = "First"
469 \set Staff.shortInstrumentName = "one"
470 c1 c c c \break
471 c1 c c c \break
472 \set Staff.instrumentName = "Second"
473 \set Staff.shortInstrumentName = "two"
474 c1 c c c \break
475 c1 c c c \break
476 @end lilypond
477
478
479 @seealso
480
481 Snippets: @lsrdir{staff}
482
483 Internals Reference: @internalsref{InstrumentName}.
484
485
486 @node Quoting other voices
487 @unnumberedsubsubsec Quoting other voices
488
489 @cindex cues
490
491 With quotations, fragments of other parts can be inserted into a
492 part directly.  Before a part can be quoted, it must be marked
493 especially as quotable.  This is done with the @code{\addQuote}
494 command.
495
496 @example
497 \addQuote @var{name} @var{music}
498 @end example
499
500
501 @noindent
502 Here, @var{name} is an identifying string.  The @var{music} is any
503 kind of music.  Here is an example of @code{\addQuote}
504
505 @example
506 \addQuote clarinet \relative c' @{
507   f4 fis g gis
508 @}
509 @end example
510
511 This command must be entered at toplevel, i.e., outside any music
512 blocks.  Typically, one would use an already defined music event
513 as the @var{music}:
514
515 @example
516 clarinet = \relative c' @{
517   f4 fis g gis
518 @}
519 \addQuote clarinet @{ \clarinet @}
520 @end example
521
522
523 After calling @code{\addQuote}, the quotation may then be done
524 with @code{\quoteDuring} or @code{\cueDuring},
525
526 @example
527 \quoteDuring #@var{name} @var{music}
528 @end example
529
530 During a part, a piece of music can be quoted with the
531 @code{\quoteDuring} command.
532
533 @example
534 \quoteDuring #"clarinet" @{ s2. @}
535 @end example
536
537 This would cite three quarter notes (the duration of @code{s2.})
538 of the previously added @code{clarinet} voice.
539
540 More precisely, it takes the current time-step of the part being
541 printed, and extracts the notes at the corresponding point of the
542 @code{\addQuote}d voice.  Therefore, the argument to
543 @code{\addQuote} should be the entire part of the voice to be
544 quoted, including any rests at the beginning.
545
546 It is possible to use another music expression instead of
547 @code{s}, thus creating a polyphonic section, but this may not
548 always give the desired result.
549
550 Quotations take into account the transposition of both source and
551 target instruments, if they are specified using the
552 @code{\transposition} command.
553
554 @lilypond[quote,ragged-right,verbatim]
555 \addQuote clarinet \relative c' {
556   \transposition bes
557   f4 fis g gis
558 }
559
560 {
561   e'8 f'8 \quoteDuring #"clarinet" { s2 }
562 }
563 @end lilypond
564
565 The type of events that are present in the quoted music can be
566 trimmed with the @code{quotedEventTypes} property.  The default
567 value is @code{(note-event rest-event)}, which means that only
568 notes and rests of the quoted voice end up in the
569 @code{\quoteDuring}.  Setting
570
571 @example
572 \set Staff.quotedEventTypes =
573        #'(note-event articulation-event dynamic-event)
574 @end example
575
576 @noindent
577 will quote notes (but no rests), together with scripts and
578 dynamics.
579
580 @refbugs
581
582 Only the contents of the first @internalsref{Voice} occurring in
583 an @code{\addQuote} command will be considered for quotation, so
584 @var{music} can not contain @code{\new} and @code{\context Voice}
585 statements that would switch to a different Voice.
586
587 Quoting grace notes is broken and can even cause LilyPond to
588 crash.
589
590 Quoting nested triplets may result in poor notation.
591
592 In earlier versions of LilyPond (pre 2.11), @code{addQuote} was
593 written entirely in lower-case letters: @code{\addquote}.
594
595 @seealso
596
597 Notation Reference: @ref{Instrument transpositions}.
598
599 Snippets: @lsrdir{staff}
600
601 Internals Reference: @internalsref{QuoteMusic}.
602
603
604 @node Formatting cue notes
605 @unnumberedsubsubsec Formatting cue notes
606
607 @cindex cues, formatting
608
609 The previous section deals with inserting notes from another
610 voice.  There is a more advanced music function called
611 @code{\cueDuring}, which makes formatting cue notes easier.
612
613 The syntax is
614
615 @example
616   \cueDuring #@var{name} #@var{updown} @var{music}
617 @end example
618
619 This will insert notes from the part @var{name} into a
620 @internalsref{Voice} called @code{cue}.  This happens
621 simultaneously with @var{music}, which usually is a rest.  When
622 the cue notes start, the staff in effect becomes polyphonic for a
623 moment.  The argument @var{updown} determines whether the cue
624 notes should be notated as a first or second voice.
625
626
627 @lilypond[verbatim,ragged-right]
628 smaller = {
629   \set fontSize = #-2
630   \override Stem #'length-fraction = #0.8
631   \override Beam #'thickness = #0.384
632   \override Beam #'length-fraction = #0.8
633 }
634
635 \addQuote clarinet \relative {
636   R1*20
637   r2 r8 c' f f
638 }
639
640 \new Staff \relative  <<
641
642   % setup a context for cue notes.
643   \new Voice = "cue" { \smaller \skip 1*21 }
644
645   \set Score.skipBars = ##t
646
647   \new Voice {
648     R1*20
649     \cueDuring #"clarinet" #UP {
650       R1
651     }
652     g4 g2.
653   }
654 >>
655 @end lilypond
656
657
658 Here are a couple of hints for successful cue notes
659
660 @itemize
661 @item
662 Cue notes have smaller font sizes.
663
664 @item
665 the cued part is marked with the instrument playing the cue.
666
667 @item
668 when the original part takes over again, this should be marked
669 with the name of the original instrument.
670
671 Any other changes introduced by the cued part should also be
672 undone.  For example, if the cued instrument plays in a different
673 clef, the original clef should be stated once again.
674
675 @end itemize
676
677 The macro @code{\transposedCueDuring} is useful to add cues to
678 instruments which use a completely different octave range (for
679 example, having a cue of a piccolo flute within a contra bassoon
680 part).
681
682 @lilypond[verbatim,ragged-right,quote]
683 picc = \relative c''' {
684   \clef "treble^8"
685   R1 |
686   c8 c c e g2 |
687   a4 g g2 |
688 }
689 \addQuote "picc" { \picc }
690
691 cbsn = \relative c, {
692   \clef "bass_8"
693   c4 r g r
694   \transposedCueDuring #"picc" #UP c,, { R1 } |
695   c4 r g r |
696 }
697
698 <<
699   \context Staff = "picc" \picc
700   \context Staff = "cbsn" \cbsn
701 >>
702 @end lilypond
703
704 @seealso
705
706 Snippets: @lsrdir{staff}
707
708
709
710