]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/staff.itely
Dist documentation text file too.
[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 If you wish to center the instrument names, you must center all of
443 them individually:
444
445 @lilypond[quote,verbatim,ragged-right]
446 { <<
447 \new Staff {
448   \set Staff.instrumentName = \markup {
449     \center-align { "Clarinetti"
450       \line { "in B" \smaller \flat } } }
451   c''1
452 }
453 \new Staff {
454   \set Staff.instrumentName =
455        \markup{ \center-align { 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 To center instrument names while leaving extra space to the right,
466
467 @lilypond[quote,verbatim,ragged-right]
468 \new StaffGroup \relative
469 <<
470   \new Staff {
471     \set Staff.instrumentName =
472         \markup { \hcenter-in #10 "blabla" }
473     c1 c1
474   }
475   \new Staff {
476     \set Staff.instrumentName =
477          \markup { \hcenter-in #10 "blo" }
478     c1 c1
479   }
480 >>
481 @end lilypond
482
483 To add instrument names to other contexts (such as
484 @code{GrandStaff}, @code{ChoirStaff}, or @code{StaffGroup}), the
485 engraver must be added to that context.
486
487 @example
488 \layout@{
489   \context @{\GrandStaff \consists "Instrument_name_engraver"@}
490 @}
491 @end example
492
493 @noindent
494 More information about adding and removing engravers can be found
495 in @ref{Modifying context plug-ins}.
496
497 @cindex instrument names, changing
498
499 Instrument names may be changed in the middle of a piece,
500
501 @lilypond[quote,fragment,verbatim,ragged-right]
502 \set Staff.instrumentName = "First"
503 \set Staff.shortInstrumentName = "one"
504 c1 c c c \break
505 c1 c c c \break
506 \set Staff.instrumentName = "Second"
507 \set Staff.shortInstrumentName = "two"
508 c1 c c c \break
509 c1 c c c \break
510 @end lilypond
511
512
513 @seealso
514
515 Notation Reference: @ref{Modifying context plug-ins}.
516
517 Snippets: @lsrdir{Staff,Staff-notation}
518
519 Internals Reference: @internalsref{InstrumentName},
520 @internalsref{PianoStaff}, @internalsref{Staff}.
521
522
523 @node Quoting other voices
524 @subsubsection Quoting other voices
525
526 @cindex cues
527 @cindex quoting other voices
528 @cindex fragments
529 @cindex cue notes
530
531 With quotations, fragments of other parts can be inserted into a
532 part directly.  Before a part can be quoted, it must be marked
533 especially as quotable.  This is done with the @code{\addQuote}
534 command.
535
536 @example
537 \addQuote @var{name} @var{music}
538 @end example
539
540
541 @noindent
542 Here, @var{name} is an identifying string.  The @var{music} is any
543 kind of music.  Here is an example of @code{\addQuote}
544
545 @example
546 \addQuote clarinet \relative c' @{
547   f4 fis g gis
548 @}
549 @end example
550
551 This command must be entered at toplevel, i.e., outside any music
552 blocks.  Typically, one would use an already defined music event
553 as the @var{music}:
554
555 @example
556 clarinet = \relative c' @{
557   f4 fis g gis
558 @}
559 \addQuote clarinet @{ \clarinet @}
560 @end example
561
562
563 After calling @code{\addQuote}, the quotation may then be done
564 with @code{\quoteDuring} or @code{\cueDuring},
565
566 @example
567 \quoteDuring #@var{name} @var{music}
568 @end example
569
570 During a part, a piece of music can be quoted with the
571 @code{\quoteDuring} command.
572
573 @example
574 \quoteDuring #"clarinet" @{ s2. @}
575 @end example
576
577 This would cite three quarter notes (the duration of @code{s2.})
578 of the previously added @code{clarinet} voice.
579
580 More precisely, it takes the current time-step of the part being
581 printed, and extracts the notes at the corresponding point of the
582 @code{\addQuote}d voice.  Therefore, the argument to
583 @code{\addQuote} should be the entire part of the voice to be
584 quoted, including any rests at the beginning.
585
586 It is possible to use another music expression instead of
587 @code{s}, thus creating a polyphonic section, but this may not
588 always give the desired result.
589
590 Quotations take into account the transposition of both source and
591 target instruments, if they are specified using the
592 @code{\transposition} command.
593
594 @lilypond[quote,ragged-right,verbatim]
595 \addQuote clarinet \relative c' {
596   \transposition bes
597   f4 fis g gis
598 }
599
600 {
601   e'8 f'8 \quoteDuring #"clarinet" { s2 }
602 }
603 @end lilypond
604
605 The type of events that are present in the quoted music can be
606 trimmed with the @code{quotedEventTypes} property.  The default
607 value is @code{(note-event rest-event)}, which means that only
608 notes and rests of the quoted voice end up in the
609 @code{\quoteDuring}.  Setting
610
611 @example
612 \set Staff.quotedEventTypes =
613        #'(note-event articulation-event dynamic-event)
614 @end example
615
616 @noindent
617 will quote notes (but no rests), together with scripts and
618 dynamics.
619
620 @refbugs
621
622 Only the contents of the first @code{Voice} occurring in an
623 @code{\addQuote} command will be considered for quotation, so
624 @var{music} can not contain @code{\new} and @code{\context Voice}
625 statements that would switch to a different Voice.
626
627 Quoting grace notes is broken and can even cause LilyPond to
628 crash.
629
630 Quoting nested triplets may result in poor notation.
631
632 In earlier versions of LilyPond (pre 2.11), @code{addQuote} was
633 written entirely in lower-case letters: @code{\addquote}.
634
635 @seealso
636
637 Notation Reference: @ref{Instrument transpositions}.
638
639 Snippets: @lsrdir{Staff,Staff-notation}
640
641 Internals Reference: @internalsref{QuoteMusic}, @internalsref{Voice}.
642
643
644 @node Formatting cue notes
645 @subsubsection Formatting cue notes
646
647 @cindex cues
648 @cindex cue notes
649 @cindex cue notes, formatting
650 @cindex fragments
651 @cindex quoting other voices 
652 @cindex cues, formatting
653
654 The previous section deals with inserting notes from another
655 voice.  There is a more advanced music function called
656 @code{\cueDuring}, which makes formatting cue notes easier.
657
658 The syntax is
659
660 @example
661   \cueDuring #@var{name} #@var{updown} @var{music}
662 @end example
663
664 This will insert notes from the part @var{name} into a
665 @code{Voice} called @code{cue}.  This happens
666 simultaneously with @var{music}, which usually is a rest.  When
667 the cue notes start, the staff in effect becomes polyphonic for a
668 moment.  The argument @var{updown} determines whether the cue
669 notes should be notated as a first or second voice.
670
671
672 @lilypond[verbatim,ragged-right]
673 smaller = {
674   \set fontSize = #-2
675   \override Stem #'length-fraction = #0.8
676   \override Beam #'thickness = #0.384
677   \override Beam #'length-fraction = #0.8
678 }
679
680 \addQuote clarinet \relative {
681   R1*20
682   r2 r8 c' f f
683 }
684
685 \new Staff \relative  <<
686
687   % setup a context for cue notes.
688   \new Voice = "cue" { \smaller \skip 1*21 }
689
690   \set Score.skipBars = ##t
691
692   \new Voice {
693     R1*20
694     \cueDuring #"clarinet" #UP {
695       R1
696     }
697     g4 g2.
698   }
699 >>
700 @end lilypond
701
702
703 Here are a couple of hints for successful cue notes:
704
705 @itemize
706 @item
707 Cue notes have smaller font sizes.
708
709 @item
710 The cued part is marked with the instrument playing the cue.
711
712 @item
713 When the original part takes over again, this should be marked
714 with the name of the original instrument.
715
716 @item
717 Any other changes introduced by the cued part should also be
718 undone.  For example, if the cued instrument plays in a different
719 clef, the original clef should be stated once again.
720
721 @end itemize
722
723 The macro @code{\transposedCueDuring} is useful to add cues to
724 instruments which use a completely different octave range (for
725 example, having a cue of a piccolo flute within a contra bassoon
726 part).
727
728 @lilypond[verbatim,ragged-right,quote]
729 picc = \relative c''' {
730   \clef "treble^8"
731   R1 |
732   c8 c c e g2 |
733   a4 g g2 |
734 }
735 \addQuote "picc" { \picc }
736
737 cbsn = \relative c, {
738   \clef "bass_8"
739   c4 r g r
740   \transposedCueDuring #"picc" #UP c,, { R1 } |
741   c4 r g r |
742 }
743
744 <<
745   \context Staff = "picc" \picc
746   \context Staff = "cbsn" \cbsn
747 >>
748 @end lilypond
749
750 @seealso
751
752 Snippets: @lsrdir{Staff,Staff-notation}.
753
754 Internals Reference: @internalsref{Voice}.
755
756