]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/working.itely
Doc-es: pre-merge update of texidoc committishes.
[lilypond.git] / Documentation / user / working.itely
1 @c -*- coding: utf-8; mode: texinfo; -*-
2 @c This file is part of lilypond-learning.tely
3 @ignore
4     Translation of GIT committish: FILL-IN-HEAD-COMMITTISH
5
6     When revising a translation, copy the HEAD committish of the
7     version that you are working on.  See TRANSLATION for details.
8 @end ignore
9
10 @c \version "2.12.0"
11
12 @node Working on LilyPond projects
13 @chapter Working on LilyPond projects
14
15 This section explains how to solve or avoid certain common
16 problems.  If you have programming experience, many of these
17 tips may seem obvious, but it is still advisable to read
18 this chapter.
19
20
21 @menu
22 * Suggestions for writing LilyPond input files::
23 * When things don't work::
24 * Scores and parts::
25 @end menu
26
27
28 @node Suggestions for writing LilyPond input files
29 @section Suggestions for writing LilyPond input files
30
31 Now you're ready to begin writing larger LilyPond input files --
32 not just the little examples in the tutorial, but whole pieces.
33 But how should you go about doing it?
34
35 As long as LilyPond can understand your input files and produce
36 the output that you want, it doesn't matter what your input files
37 look like.  However, there are a few other things to consider when
38 writing LilyPond input files.
39
40 @itemize
41 @item What if you make a mistake?  The structure of a LilyPond
42 file can make certain errors easier (or harder) to find.
43
44 @item What if you want to share your input files with somebody
45 else?  In fact, what if you want to alter your own input files in
46 a few years?  Some LilyPond input files are understandable at
47 first glance; others may leave you scratching your head
48 for an hour.
49
50 @item What if you want to upgrade your LilyPond file for use
51 with a later version of LilyPond?  The input syntax changes
52 occasionally as LilyPond improves.  Most changes can be
53 done automatically with @code{convert-ly}, but some changes
54 might require manual assistance.  LilyPond input files can be
55 structured in order to be easier (or harder) to update.
56
57 @end itemize
58
59 @menu
60 * General suggestions::
61 * Typesetting existing music::
62 * Large projects::
63 * Saving typing with variables and functions::
64 * Style sheets::
65 @end menu
66
67
68 @node General suggestions
69 @subsection General suggestions
70
71 Here are a few suggestions that can help you to avoid or fix
72 problems:
73
74 @itemize
75 @item @strong{Include @code{\version} numbers in every file}.  Note that all
76 templates contain @code{\version} information.  We
77 highly recommend that you always include the @code{\version}, no matter
78 how small your file is.  Speaking from personal experience, it's
79 quite frustrating to try to remember which version of LilyPond you were
80 using a few years ago.  @command{convert-ly} requires you to declare
81 which version of LilyPond you used.
82
83 @item @strong{Include checks}: @ruser{Bar and bar number checks},
84 @ruser{Octave checks}.  If you include checks every so often, then
85 if you make a mistake, you can pinpoint it quicker.  How often is
86 @q{every so often}?  It depends on the complexity of the music.
87 For very simple music, perhaps just once or twice.  For very
88 complex music, perhaps every bar.
89
90 @item @strong{One bar per line of text}.  If there is anything complicated,
91 either in the music
92 itself or in the output you desire, it's often good to write only one bar
93 per line.  Saving screen space by cramming eight bars per line just isn't
94 worth it if you have to @q{debug} your input files.
95
96 @item @strong{Comment your input files}.  Use either bar numbers
97 (every so often) or
98 references to musical themes (@q{second theme in violins,} @q{fourth
99 variation,} etc.).  You may not need comments when you're writing the piece
100 for the first time, but if you want to go back to change something two or
101 three years later, or if you pass the source over to a friend, it will
102 be much more
103 challenging to determine your intentions or how your file is structured if
104 you didn't comment the file.
105
106 @item @strong{Indent your braces}.  A lot of problems are caused by an
107 imbalance
108 in the number of @code{@{} and @code{@}}.
109
110 @item @strong{Explicitly add durations} at the beginnings of sections
111 and variables.  If you specify @code{c4 d e} at the beginning of a
112 phrase (instead of just @code{c d e}) you can save yourself some
113 problems if you rearrange your music later.
114
115 @item @strong{Separate tweaks} from music definitions.  See
116 @ref{Saving typing with variables and functions}, and
117 @ref{Style sheets}.
118
119 @end itemize
120
121
122 @node Typesetting existing music
123 @subsection Typesetting existing music
124
125 If you are entering music from an existing score (i.e., typesetting a
126 piece of existing sheet music),
127
128 @itemize
129
130 @item Enter one manuscript (the physical copy) system at a time (but still
131 only one bar per line of text), and
132 check each system when you finish it.  You may use the
133 @code{showLastLength} or @code{showFirstLength} properties to speed up
134 processing -- see @ruser{Skipping corrected music}.
135
136 @item Define @code{mBreak = @{ \break @}} and insert @code{\mBreak}
137 in the input file whenever the manuscript has a line break.  This
138 makes it much easier to compare the LilyPond music to the original
139 music.  When you are finished proofreading your score, you may
140 define @code{mBreak = @{ @}} to remove all those line breaks.  This
141 will allow LilyPond to place line breaks wherever it feels are
142 best.
143
144 @item When entering a part for a transposing instrument into a
145 variable, it is recommended that the notes are wrapped in
146
147 @example
148 \transpose c natural-pitch @{...@}
149 @end example
150 (where @code{natural-pitch} is the open pitch of the instrument) so
151 that the music in the variable is effectively in C. You can transpose
152 it back again when the variable is used, if required, but you might
153 not want to (e.g., when printing a score in concert pitch,
154 converting a trombone part from treble to bass clef, etc.)
155 Mistakes in transpositions are less likely if all the music in
156 variables is at a consistent pitch.
157
158 Also, only ever transpose to/from C. That means that the only other
159 keys you will use are the natural pitches of the instruments - bes
160 for a B-flat trumpet, aes for an A-flat clarinet, etc.
161
162 @end itemize
163
164
165 @node Large projects
166 @subsection Large projects
167
168 When working on a large project, having a clear structure to your
169 lilypond input files becomes vital.
170
171 @itemize
172
173 @item @strong{Use an variable for each voice}, with a minimum of
174 structure inside the definition.  The structure of the
175 @code{\score} section is the most likely thing to change;
176 the @code{violin} definition is extremely unlikely to change
177 in a new version of LilyPond.
178
179 @example
180 violin = \relative c'' @{
181 g4 c'8. e16
182 @}
183 ...
184 \score @{
185   \new GrandStaff @{
186     \new Staff @{
187       \violin
188     @}
189   @}
190 @}
191 @end example
192
193 @item @strong{Separate tweaks from music definitions}.  This
194 point was made in previously, but for large
195 projects it is absolutely vital.  We might need to change
196 the definition of @code{fthenp}, but then we only need
197 to do this once, and we can still avoid touching anything
198 inside @code{violin}.
199
200 @example
201 fthenp = _\markup@{
202   \dynamic f \italic \small @{ 2nd @} \hspace #0.1 \dynamic p @}
203 violin = \relative c'' @{
204 g4\fthenp c'8. e16
205 @}
206 @end example
207
208 @end itemize
209
210
211 @node Saving typing with variables and functions
212 @subsection Saving typing with variables and functions
213
214 @cindex variables
215 @cindex variables
216
217 By this point, you've seen this kind of thing:
218
219 @lilypond[quote,verbatim,ragged-right]
220 hornNotes = \relative c'' { c4 b dis c }
221 \score {
222   {
223     \hornNotes
224   }
225 }
226 @end lilypond
227
228 You may even realize that this could be useful in minimalist music:
229
230 @lilypond[quote,verbatim,ragged-right]
231 fragmentA = \relative c'' { a4 a8. b16 }
232 fragmentB = \relative c'' { a8. gis16 ees4 }
233 violin = \new Staff { \fragmentA \fragmentA \fragmentB \fragmentA }
234 \score {
235   {
236     \violin
237   }
238 }
239 @end lilypond
240
241 However, you can also use these variables (also known as
242 variables, macros, or (user-defined) command) for tweaks:
243
244 @lilypond[quote,verbatim,ragged-right]
245 dolce = \markup{ \italic \bold dolce }
246 padText = { \once \override TextScript #'padding = #5.0 }
247 fthenp=_\markup{ \dynamic f \italic \small { 2nd } \hspace #0.1 \dynamic p }
248 violin = \relative c'' {
249   \repeat volta 2 {
250     c4._\dolce b8 a8 g a b |
251     \padText
252     c4.^"hi there!" d8 e' f g d |
253     c,4.\fthenp b8 c4 c-. |
254   }
255 }
256 \score {
257   {
258     \violin
259   }
260 \layout{ragged-right=##t}
261 }
262 @end lilypond
263
264 These variables are obviously useful for saving
265 typing.  But they're worth considering even if you
266 only use them once -- they reduce complexity.  Let's
267 look at the previous example without any
268 variables.  It's a lot harder to read, especially
269 the last line.
270
271 @example
272 violin = \relative c'' @{
273   \repeat volta 2 @{
274     c4._\markup@{ \italic \bold dolce @} b8 a8 g a b |
275     \once \override TextScript #'padding = #5.0
276     c4.^"hi there!" d8 e' f g d |
277     c,4.\markup@{ \dynamic f \italic \small @{ 2nd @}
278       \hspace #0.1 \dynamic p @} b8 c4 c-. |
279   @}
280 @}
281 @end example
282
283 @c TODO Replace the following with a better example  -td
284 @c Skylining handles this correctly without padText
285
286 So far we've seen static substitution -- when LilyPond
287 sees @code{\padText}, it replaces it with the stuff that
288 we've defined it to be (ie the stuff to the right of
289 @code{padtext=}).
290
291 LilyPond can handle non-static substitution, too (you
292 can think of these as functions).
293
294 @lilypond[quote,verbatim,ragged-right]
295 padText =
296 #(define-music-function (parser location padding) (number?)
297   #{
298     \once \override TextScript #'padding = #$padding
299   #})
300
301 \relative c''' {
302   c4^"piu mosso" b a b
303   \padText #1.8
304   c4^"piu mosso" d e f
305   \padText #2.6
306   c4^"piu mosso" fis a g
307 }
308 @end lilypond
309
310 Using variables is also a good way to reduce work if the
311 LilyPond input syntax changes (see @ref{Updating old input files}).  If
312 you have a single definition (such as @code{\dolce}) for all your
313 input files (see @ref{Style sheets}), then if the syntax changes, you
314 only need to update your single @code{\dolce} definition,
315 instead of making changes throughout every @code{.ly} file.
316
317
318 @node Style sheets
319 @subsection Style sheets
320
321 The output that LilyPond produces can be heavily modified; see
322 @ref{Tweaking output}, for details.  But what if you have many
323 input files that you want to apply your tweaks to?  Or what if you
324 simply want to separate your tweaks from the actual music?  This
325 is quite easy to do.
326
327 Let's look at an example.  Don't worry if you don't understand
328 the parts with all the @code{#()}.  This is explained in
329 @ref{Advanced tweaks with Scheme}.
330
331 @lilypond[quote,verbatim,ragged-right]
332 mpdolce = #(make-dynamic-script (markup #:hspace 0 #:translate '(5 . 0)
333   #:line(#:dynamic "mp" #:text #:italic "dolce" )))
334
335 inst = #(define-music-function (parser location string) (string?)
336   (make-music
337     'TextScriptEvent
338     'direction UP
339     'text (markup #:bold (#:box string))))
340
341 \relative c'' {
342   \tempo 4=50
343   a4.\mpdolce d8 cis4--\glissando a | b4 bes a2
344   \inst "Clarinet"
345   cis4.\< d8 e4 fis | g8(\! fis)-. e( d)-. cis2
346 }
347 @end lilypond
348
349 There are some problems with overlapping output; we'll fix those using
350 the techniques in @ref{Moving objects}.  But let's also
351 do something about the @code{mpdolce} and @code{inst}
352 definitions.  They produce the output we desire, but we might want
353 to use them in another piece.  We could simply copy-and-paste them
354 at the top of every file, but that's an annoyance.  It also leaves
355 those definitions in our input files, and I personally find all
356 the @code{#()} somewhat ugly.  Let's hide them in another file:
357
358 @example
359 %%% save this to a file called "definitions.ly"
360 mpdolce = #(make-dynamic-script (markup #:hspace 0 #:translate '(5 . 0)
361   #:line(#:dynamic "mp" #:text #:italic "dolce" )))
362
363 inst = #(define-music-function (parser location string) (string?)
364   (make-music
365     'TextScriptEvent
366     'direction UP
367     'text (markup #:bold (#:box string))))
368 @end example
369
370 Now let's modify our music (let's save this file as @file{"music.ly"}).
371
372 @c  We have to do this awkward example/lilypond-non-verbatim
373 @c  because we can't do the \include stuff in the manual.
374
375 @example
376 \include "definitions.ly"
377
378 \relative c'' @{
379   \tempo 4=50
380   a4.\mpdolce d8 cis4--\glissando a | b4 bes a2
381   \inst "Clarinet"
382   cis4.\< d8 e4 fis | g8(\! fis)-. e( d)-. cis2
383 @}
384 @end example
385
386 @lilypond[quote,ragged-right]
387 mpdolce = #(make-dynamic-script (markup #:hspace 0 #:translate '(5 . 0)
388   #:line(#:dynamic "mp" #:text #:italic "dolce" )))
389
390 inst = #(define-music-function (parser location string) (string?)
391   (make-music
392     'TextScriptEvent
393     'direction UP
394     'text (markup #:bold (#:box string))))
395
396 \relative c'' {
397   \tempo 4=50
398   a4.\mpdolce d8 cis4--\glissando a | b4 bes a2
399   \inst "Clarinet"
400   cis4.\< d8 e4 fis | g8(\! fis)-. e( d)-. cis2
401 }
402 @end lilypond
403
404 That looks better, but let's make a few changes.  The glissando is hard
405 to see, so let's make it thicker and closer to the note heads.  Let's
406 put the metronome marking above the clef, instead of over the first
407 note.  And finally, my composition professor hates @q{C} time signatures,
408 so we'd better make that @q{4/4} instead.
409
410 Don't change @file{music.ly}, though.  Replace our @file{definitions.ly}
411 with this:
412
413 @example
414 %%%  definitions.ly
415 mpdolce = #(make-dynamic-script (markup #:hspace 0 #:translate '(5 . 0)
416   #:line( #:dynamic "mp" #:text #:italic "dolce" )))
417
418 inst = #(define-music-function (parser location string) (string?)
419   (make-music
420     'TextScriptEvent
421     'direction UP
422     'text (markup #:bold (#:box string))))
423
424 \layout@{
425   \context @{ \Score
426     \override MetronomeMark #'extra-offset = #'(-9 . 0)
427     \override MetronomeMark #'padding = #'3
428   @}
429   \context @{ \Staff
430     \override TimeSignature #'style = #'numbered
431   @}
432   \context @{ \Voice
433     \override Glissando #'thickness = #3
434     \override Glissando #'gap = #0.1
435   @}
436 @}
437 @end example
438
439 @lilypond[quote,ragged-right]
440 mpdolce = #(make-dynamic-script (markup #:hspace 0 #:translate '(5 . 0)
441   #:line( #:dynamic "mp" #:text #:italic "dolce" )))
442
443 inst = #(define-music-function (parser location string) (string?)
444   (make-music
445     'TextScriptEvent
446     'direction UP
447     'text (markup #:bold (#:box string))))
448
449 \layout{
450   \context { \Score
451     \override MetronomeMark #'extra-offset = #'(-9 . 0)
452     \override MetronomeMark #'padding = #'3
453   }
454   \context { \Staff
455     \override TimeSignature #'style = #'numbered
456   }
457   \context { \Voice
458     \override Glissando #'thickness = #3
459     \override Glissando #'gap = #0.1
460   }
461 }
462
463 \relative c'' {
464   \tempo 4=50
465   a4.\mpdolce d8 cis4--\glissando a | b4 bes a2
466   \inst "Clarinet"
467   cis4.\< d8 e4 fis | g8(\! fis)-. e( d)-. cis2
468 }
469 @end lilypond
470
471 That looks nicer!  But now suppose that I want to publish this
472 piece.  My composition professor doesn't like @q{C} time
473 signatures, but I'm somewhat fond of them.  Let's copy the
474 current @file{definitions.ly} to @file{web-publish.ly} and
475 modify that.  Since this music is aimed at producing a pdf which
476 will be displayed on the screen, we'll also increase the
477 overall size of the output.
478
479 @example
480 %%%  definitions.ly
481 mpdolce = #(make-dynamic-script (markup #:hspace 0 #:translate '(5 . 0)
482   #:line( #:dynamic "mp" #:text #:italic "dolce" )))
483
484 inst = #(define-music-function (parser location string) (string?)
485   (make-music
486     'TextScriptEvent
487     'direction UP
488     'text (markup #:bold (#:box string))))
489
490 #(set-global-staff-size 23)
491 \layout@{
492   \context @{ \Score
493     \override MetronomeMark #'extra-offset = #'(-9 . 0)
494     \override MetronomeMark #'padding = #'3
495   @}
496   \context @{ \Staff
497   @}
498   \context @{ \Voice
499     \override Glissando #'thickness = #3
500     \override Glissando #'gap = #0.1
501   @}
502 @}
503 @end example
504
505 @lilypond[quote,ragged-right]
506 mpdolce = #(make-dynamic-script (markup #:hspace 0 #:translate '(5 . 0)
507   #:line( #:dynamic "mp" #:text #:italic "dolce" )))
508
509 inst = #(define-music-function (parser location string) (string?)
510   (make-music
511     'TextScriptEvent
512     'direction UP
513     'text (markup #:bold (#:box string))))
514
515 #(set-global-staff-size 23)
516 \layout{
517   \context { \Score
518     \override MetronomeMark #'extra-offset = #'(-9 . 0)
519     \override MetronomeMark #'padding = #'3
520   }
521   \context { \Voice
522     \override Glissando #'thickness = #3
523     \override Glissando #'gap = #0.1
524   }
525 }
526
527 \relative c'' {
528   \tempo 4=50
529   a4.\mpdolce d8 cis4--\glissando a | b4 bes a2
530   \inst "Clarinet"
531   cis4.\< d8 e4 fis | g8(\! fis)-. e( d)-. cis2
532 }
533 @end lilypond
534
535 Now in our music, I simply replace
536 @code{\include "definitions.ly"} with
537 @code{\include "web-publish.ly"}.  Of course, we could make this
538 even more convenient.  We could make a @file{definitions.ly} file which
539 contains only the definitions of @code{mpdolce} and @code{inst}, a
540 @file{web-publish.ly} file which contains only the @code{\layout}
541 section listed above, and a @file{university.ly} file which
542 contains only the tweaks to produce the output that my professor
543 prefers.  The top of @file{music.ly} would then look like this:
544
545 @example
546 \include "definitions.ly"
547
548 %%%  Only uncomment one of these two lines!
549 \include "web-publish.ly"
550 %\include "university.ly"
551 @end example
552
553 This approach can be useful even if you are only producing
554 one set of parts.  I use half a dozen different
555 @q{style sheet} files for my projects.  I begin every music
556 file with @code{\include "../global.ly"}, which contains
557
558 @example
559 %%%   global.ly
560 \version @w{"@version{}"}
561 #(ly:set-option 'point-and-click #f)
562 \include "../init/init-defs.ly"
563 \include "../init/init-layout.ly"
564 \include "../init/init-headers.ly"
565 \include "../init/init-paper.ly"
566 @end example
567
568
569 @node When things don't work
570 @section When things don't work
571
572 @menu
573 * Updating old input files::
574 * Troubleshooting (taking it all apart)::
575 * Minimal examples::
576 @end menu
577
578 @node Updating old input files
579 @subsection Updating old input files
580
581 The LilyPond input syntax occasionally changes.  As LilyPond itself
582 improves, the syntax (input language) is modified accordingly.  Sometimes
583 these changes are made to make the input easier to read and write or
584 sometimes the changes are made to accommodate new features of LilyPond.
585
586 LilyPond comes with a file that makes this updating easier:
587 @code{convert-ly}.  For details about how to run this program, see
588 @rprogram{Updating files with convert-ly}.
589
590 Unfortunately, @code{convert-ly} cannot handle all input changes.  It
591 takes care of simple search-and-replace changes (such as @code{raggedright}
592 becoming @code{ragged-right}), but some changes are too
593 complicated.  The syntax changes that @code{convert-ly} cannot handle
594 are listed in @rprogram{Updating files with convert-ly}.
595
596 For example, in LilyPond 2.4 and earlier, accents and non-English
597 letters were entered using LaTeX -- for example,
598 @code{No\"el} (this would print the French word for
599 @q{Christmas}).  In LilyPond 2.6 and above, the special
600 @code{ë} must be entered directly into the LilyPond file as an
601 UTF-8 character.  @code{convert-ly} cannot change all the LaTeX
602 special characters into UTF-8 characters; you must manually update
603 your old LilyPond input files.
604
605
606 @node Troubleshooting (taking it all apart)
607 @subsection Troubleshooting (taking it all apart)
608
609 Sooner or later, you will write a file that LilyPond cannot
610 compile.  The messages that LilyPond gives may help
611 you find the error, but in many cases you need to do some
612 investigation to determine the source of the problem.
613
614 The most powerful tools for this purpose are the
615 single line comment (indicated by @code{%}) and the block
616 comment (indicated by @code{%@{ ... %@}}).  If you don't
617 know where a problem is, start commenting out huge portions
618 of your input file.  After you comment out a section, try
619 compiling the file again.  If it works, then the problem
620 must exist in the portion you just commented.  If it doesn't
621 work, then keep on commenting out material until you have
622 something that works.
623
624 In an extreme case, you might end up with only
625
626 @example
627 \score @{
628   <<
629     % \melody
630     % \harmony
631     % \bass
632   >>
633   \layout@{@}
634 @}
635 @end example
636
637 @noindent
638 (in other words, a file without any music)
639
640 If that happens, don't give up.  Uncomment a bit -- say,
641 the bass part -- and see if it works.  If it doesn't work,
642 then comment out all of the bass music (but leave
643 @code{\bass} in the @code{\score} uncommented.
644
645 @example
646 bass = \relative c' @{
647 %@{
648   c4 c c c
649   d d d d
650 %@}
651 @}
652 @end example
653
654 Now start slowly uncommenting more and more of the
655 @code{bass} part until you find the problem line.
656
657 Another very useful debugging technique is constructing
658 @ref{Minimal examples}.
659
660
661 @node Minimal examples
662 @subsection Minimal examples
663
664 A minimal example is an example which is as small as possible.  These
665 examples are much easier to understand than long examples.  Minimal
666 examples are used for
667
668 @itemize
669 @item Bug reports
670 @item Sending a help request to mailing lists
671 @item Adding an example to the @uref{http://lsr.dsi.unimi.it/,
672 LilyPond Snippet Repository}
673 @end itemize
674
675 To construct an example which is as small as possible, the rule is
676 quite simple: remove anything which is not necessary.  When trying to
677 remove unnecessary parts of a file, it is a very good idea to comment
678 out lines instead of deleting them.  That way, if you discover that you
679 actually @emph{do} need some lines, you can uncomment them, instead of
680 typing them in from scratch.
681
682 There are two exceptions to the @qq{as small as possible} rule:
683
684 @itemize
685 @item Include the @code{\version} number.
686 @item If possible, use @code{\paper@{ ragged-right=##t @}} at the
687 top of your example.
688 @end itemize
689
690 The whole point of a minimal example is to make it easy to read:
691
692 @itemize
693 @item Avoid using complicated notes, keys, or time signatures, unless you
694 wish to demonstrate something is about the behavior of those items.
695 @item Do not use @code{\override} commands unless that is the point of the
696 example.
697 @end itemize
698
699
700
701 @node Scores and parts
702 @section Scores and parts
703
704 TODO: this is really old stuff from the really old tutorial.
705 Rewrite, fix, etc.  Or maybe delete entirely.  -gp
706 Include section on tags   -td
707 and then move to section 5. Working ...  -td
708
709 In orchestral music, all notes are printed twice.  Once in a part for
710 the musicians, and once in a full score for the conductor.  Variables can
711 be used to avoid double work.  The music is entered once, and stored in
712 a variable.  The contents of that variable is then used to generate
713 both the part and the full score.
714
715 It is convenient to define the notes in a special file.  For example,
716 suppose that the file @file{horn-music.ly} contains the following part
717 of a horn/@/bassoon duo
718
719 @example
720 hornNotes = \relative c @{
721   \time 2/4
722   r4 f8 a cis4 f e d
723 @}
724 @end example
725
726 @noindent
727 Then, an individual part is made by putting the following in a file
728
729 @example
730 \include "horn-music.ly"
731 \header @{
732   instrument = "Horn in F"
733 @}
734
735 @{
736  \transpose f c' \hornNotes
737 @}
738 @end example
739
740 The line
741
742 @example
743 \include "horn-music.ly"
744 @end example
745
746 @noindent
747 substitutes the contents of @file{horn-music.ly} at this position in
748 the file, so @code{hornNotes} is defined afterwards.  The command
749 @code{\transpose f@tie{}c'} indicates that the argument, being
750 @code{\hornNotes}, should be transposed by a fifth upwards.  Sounding
751 @code{f} is denoted by notated @code{c'}, which corresponds with the
752 tuning of a normal French Horn in@tie{}F.  The transposition can be seen
753 in the following output
754
755 @lilypond[quote,ragged-right]
756 \transpose f c' \relative c {
757   \time 2/4
758   r4 f8 a cis4 f e d
759 }
760 @end lilypond
761
762 In ensemble pieces, one of the voices often does not play for many
763 measures.  This is denoted by a special rest, the multi-measure
764 rest.  It is entered with a capital @code{R} followed by a duration
765 (@code{1}@tie{}for a whole note, @code{2}@tie{}for a half note,
766 etc.).  By multiplying the
767 duration, longer rests can be constructed.  For example, this rest
768 takes 3@tie{}measures in 2/4 time
769
770 @example
771 R2*3
772 @end example
773
774 When printing the part, multi-rests
775 must be condensed.  This is done by setting a run-time variable
776
777 @example
778 \set Score.skipBars = ##t
779 @end example
780
781 @noindent
782 This command sets the property @code{skipBars} in the
783 @code{Score} context to true (@code{##t}).  Prepending the rest and
784 this option to the music above, leads to the following result
785
786 @lilypond[quote,ragged-right]
787 \transpose f c' \relative c {
788   \time 2/4
789   \set Score.skipBars = ##t
790   R2*3
791   r4 f8 a cis4 f e d
792 }
793 @end lilypond
794
795
796 The score is made by combining all of the music together.  Assuming
797 that the other voice is in @code{bassoonNotes} in the file
798 @file{bassoon-music.ly}, a score is made with
799
800 @example
801 \include "bassoon-music.ly"
802 \include "horn-music.ly"
803
804 <<
805   \new Staff \hornNotes
806   \new Staff \bassoonNotes
807 >>
808 @end example
809
810 @noindent
811 leading to
812
813 @lilypond[quote,ragged-right]
814 \relative c <<
815   \new Staff {
816     \time 2/4 R2*3
817     r4 f8 a cis4 f e d
818   }
819   \new Staff {
820     \clef bass
821     r4 d,8 f | gis4 c | b bes |
822     a8 e f4 | g d | gis f
823   }
824 >>
825 @end lilypond
826
827