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