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