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