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