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