]> git.donarmstrong.com Git - lilypond.git/blobdiff - Documentation/user/refman.itely
release: 1.3.144
[lilypond.git] / Documentation / user / refman.itely
index 3ec63950395a5db5f5b6b27912795023b351a88a..4f3e0a3fab7914daf0f05f51c4a419f5a18f59b7 100644 (file)
@@ -41,7 +41,7 @@ revision of this document was for LilyPond 1.3.141.
 * Page layout::                 
 * Sound::                       
 * Music entry::                 
-* Using LilyPond::              
+* Skipping corrected music::    
 * Interpretation context::      
 * Syntactic details::           
 * Lexical details::             
@@ -675,80 +675,77 @@ settings.
 @c .   {Polyphony}
 @node Polyphony
 @section Polyphony
-@cindex Polyphony
+@cindex polyphony
 
-[TODO: collisions, rest-collisinos, voiceX identifiers, how to
-which  contexts to instantiate.  some small examples? ]
+Polyphonic parts, i.e. parts with more than one voice on a staff can be
+typeset with LilyPond.   To use this, instantiate a separate Voice
+context for each part, and assign a stem direction to each part. 
+@lilypond[fragment,verbatim]
+\context Staff
+< \context Voice = VA { \stemUp b'4 a' g' f' e' }
+  \context Voice = VB { \stemDown g'4 g' g' g' g' } >
+@end lilypond
 
+When there are more than two voices on a staff, you must also indicate
+which voice should moved horizontally in case of a collision. This can
+be done with the identifiers @code{\shiftOff}, @code{\shiftOn},
+@code{\shiftOnn}, etc. (which sets grob property @code{horizontal-shift}
+in @code{NoteColumn}).
+
+@lilypond[fragment, verbatim]
+  \context Staff \notes\relative c''<
+       \context Voice=one {
+       \shiftOff \stemUp e4
+       }
+       \context Voice=two {
+         \shiftOn \stemUp cis
+       }
+       \context Voice=three {
+         \shiftOnn \stemUp ais
+       }
+       \context Voice=four {
+         \shiftOnnn \stemUp fis-2
+       }
+  >
+@end lilypond
 
-@table @code
-@cindex @code{\shiftOff}  
-  @item @code{\shiftOff}
-    Disable horizontal shifting of note heads that collide. 
-
-@cindex @code{\shiftOn}  
-  @item @code{\shiftOn}
-    Enable note heads that collide with other note heads to be
-    shifted horiztonally. Also @code{\shiftOnn} and @code{\shiftOnnn}
-set different shift values.
-
-@cindex @code{\stemBoth} 
-  @item @code{\stemBoth}
-    Allow stems and beams to point either upwards or
-    downwards, decided automatically by LilyPond.
-
-@cindex @code{\stemDown}  
-  @item @code{\stemDown}
-    Force stems and beams to point down.
-
-@cindex @code{\stemUp}  
-  @item @code{\stemUp}
-    Force stems and beams to point up.
-@end table
+The most convenient way is to use the identifiers @code{\voiceOne}
+through @code{\voiceFour}, which also set slur and tie directions in the
+correct manner.
+
+@lilypond[singleline, verbatim]
+\relative c''
+\context Staff < \context Voice = VA { \voiceOne cis2 b  }
+  \context Voice = VB { \voiceThree b4 ais ~ ais4 gis4 } 
+  \context Voice = VC { \voiceTwo fis4~  fis4 f ~ f  } >
+@end lilypond
+
+
+LilyPond also vertically shifts rests that are opposite of a stem. 
+
+@lilypond[singleline,verbatim]
+\context Staff <
+\context Voice {  \stemUp c''4  }
+\context Voice =VB { r4 }
+>
+@end lilypond
+
+Note head collisions (horizontal shifting of note heads) are handled by
+the @code{NoteCollision} grob. @code{RestCollision} handles vertical
+shifting of rests.
+
+@cindex @code{NoteCollision}
+@cindex @code{RestCollision}
+
+
+@refbugs
 
-@cindex @code{\slurBoth}
-@cindex @code{\slurDown} 
-@cindex @code{\slurUp}
-Similarly, for slurs use
-@code{\slurBoth}, 
-@code{\slurDown}, 
-@code{\slurUp}.
-
-@cindex @code{\tieBoth}
-@cindex @code{\tieDown} 
-@cindex @code{\tieUp}
-For ties use
-@code{\tieBoth}, 
-@code{\tieDown}, 
-@code{\tieUp}.
-
-@cindex @code{\dynacmicBoth}
-@cindex @code{\dynamicDown} 
-@cindex @code{\dynamicUp}
-For dynamics use
-@code{\dynamicBoth}, 
-@code{\dynamicDown}, 
-@code{\dynamicUp}.
-
-@c text scripts? articulation scripts? fingering?
-
-@cindex @code{\voiceOne}
-@cindex @code{\voiceTwo}
-@cindex @code{\voiceThree}
-@cindex @code{\voiceFour}
-@cindex @code{\oneVoice}
-@cindex @code{\shiftOn}
-@cindex @code{\shiftOff}
-
-If two voices sharing one staff have the same stem directions, their
-note heads may collide.  You can shift the note heads of one voice by
-setting @code{\shiftOn}.  This can be undone by setting
-@code{\shiftOff}.
-
-For simple polyphonic music, shorthands are available that combine
-directions and shift settings: @code{\voiceOne}, @code{\voiceTwo},
-@code{\voiceThree}, @code{\voiceFour} and @code{\oneVoice}.
+Resolving collisions is a very intricate subject, and LilyPond only
+handles a few situations. When it can not cope, you are advised to use
+@code{force-hshift} of the NoteColumn grob and @code{staff-position} of
+the Rest grob to override typesetting decisions.
 
+[TODO: doc merge-differently-dotted]
 
 @node Beaming
 @section Beaming
@@ -823,9 +820,11 @@ note they contain. For a beam ending rule that only applies to beams
 with 32nd notes (and no shorter notes), you would use @code{(end * * 1
 32)}.
 
-[say something about irregular meters. eg 5/8 = 2+3/8, 3+2/8] 
+@c not true
+@c Automatic beams can not be put on the last note in a score.
 
-Automatic beams can not be put on the last note in a score.
+If a score ends while an automatic beam has not been ended and is still
+accepting notes, this last beam will not be typeset at all.
 
 @cindex automatic beam generation
 @cindex autobeam
@@ -837,15 +836,19 @@ a melody that goes with lyrics.
 
 @refbugs
 
-It is not possible to specify beaming for beams with mixed durations,
-that differs from the beaming of all separate durations, ie, you'll
-have to specify manual beams to get:
+It is not possible to specify beaming parameters for beams with mixed
+durations, that differ from the beaming parameters of all separate
+durations, ie, you'll have to specify manual beams to get:
 @lilypond[fragment,singleline,relative]
   \property Voice.autoBeamSettings
-    \override #'(end * * * *) = #(make-moment 3 8)
-  \time 12/8; c'8 c c  c16 c c c c c  [c c c c] c8 c  c4
+  \override #'(end * * * *) = #(make-moment 3 8)
+  \time 12/8; c'8 c c c16 c c c c c [c c c c] c8 c c4
 @end lilypond
 
+It is not possible to specify beaming parameters that act differently in
+different parts of a measure, eg, in irregular meters such as @code{5/8}
+that breaks down to @code{2/8 +3/8} or @code{3/8 + 2/8}, automatic beams
+won't act according to the broken down parts @code{2/8} and @code{3/8}.
 
 @c .    {Manual beams}
 @cindex Automatic beams
@@ -1367,11 +1370,9 @@ want to get several marks during one note, you must use spacer notes.
 
 @lilypond[fragment,verbatim,center]
   c'' \< \! c''   d'' \decr e'' \rced 
-  < f''1 { s4 \< \! s2 \> \! s4 } >
+  < f''1 { s4 s4 \< \! s4 \> \! s4 } >
 @end lilypond
 
-[BUG in \> ! ]
-
 You can also use a text saying @emph{cresc.} instead of hairpins. Here
 is an example how to do it:
 
@@ -1385,9 +1386,6 @@ is an example how to do it:
 
 
 
-
-
-
 @c .  {Repeats}
 @node Repeats
 @section Repeats
@@ -1583,10 +1581,15 @@ In the @code{percent} style, a note pattern can be repeated. It is
 printed once, and then the pattern is replaced with a special sign.
 
 @lilypond[verbatim,singleline]
- \context Voice { \repeat  "percent" 5  { c'1 } }  
+ \context Voice { \repeat  "percent" 4  { c'4 }
+    \repeat "percent" 2 { c'2 es'2 f'4 fis'4 g'4 c''4 }
+}
 @end lilypond
 
-At present, only repeats of whole measures are supported.
+@refbugs
+
+You can not nest percent repeats, filling in the first measure with
+slashes, and repeating that measure with percents.
 
 @node Rhythmic music
 @section Rhythmic music
@@ -1691,11 +1694,11 @@ context which is a direct child of the a context of type
 @cindex Pedals
 
 Piano pedal instruction can be expressed using 
-@code{\sustainDown}, @code{\sustainUp}, @code{\unaChorda},
-@code{\treChorde}, @code{\sostenutoDown} and @code{\sostenutoUp}.
+@code{\sustainDown}, @code{\sustainUp}, @code{\unaCorda},
+@code{\treCorde}, @code{\sostenutoDown} and @code{\sostenutoUp}.
 
 These identifiers are shorthands for spanner commands of the types
-@code{Sustain}, @code{UnaChorda} and @code{Sostenuto}:
+@code{Sustain}, @code{UnaCorda} and @code{Sostenuto}:
 
 @lilypond[fragment,verbatim]
 c''4 \spanrequest \start "Sustain" c''4 c''4 \spanrequest \stop "Sustain"
@@ -2155,10 +2158,8 @@ scheme = \chords {
 
 LilyPond examines chords specified as lists of notes to determine a name
 to give the chord. LilyPond will not try to identify chord inversions or
-added base, which may result in strange chord names when chords are
-entered as a list of pitches:
-
-[base vs. bass ?]
+an added bass note, which may result in strange chord names when chords
+are entered as a list of pitches:
 
 @lilypond[verbatim,center,singleline]
 scheme = \notes {
@@ -2169,7 +2170,7 @@ scheme = \notes {
 
 \score {
   <
-    \context ChordNamesVoice \scheme
+    \context ChordNames \scheme
     \context Staff \scheme
   >
 }
@@ -2185,9 +2186,33 @@ chordnames.
 
 Routines that determine the names to be printed are written in Scheme,
 and may be customized by the user.  The code can be found in
-@file{scm/chord-name.scm}.
+@file{scm/chord-name.scm}.  Here's an example showing the differences in
+chord name styles:
+
+@c too long?
+@c maybe just junk verbatim option?
+@lilypond[verbatim,singleline]
+scheme = \chords {
+  c1 c:5^3 c:4^3 c:5+
+  c:m7+ c:m5-.7
+  c:5-.7 c:5+.7
+  c:9^7
+}
+
+\score {
+  \notes <
+    \context ChordNames = banter \scheme
+    \context ChordNames = american {
+      \property ChordNames.ChordName \override
+        #'style = #'american \scheme }
+    \context ChordNames = jazz {
+      \property ChordNames.ChordName \override
+        #'style = #'jazz \scheme }
+    \context Staff \transpose c'' \scheme
+  >
+}
+@end lilypond
 
-[3 short examples showing differences between american, banter and jazz]
 
 @node Writing parts
 @section Writing parts
@@ -2268,9 +2293,32 @@ used, for the next ones @code{instr} is used.
 @end lilypond
 
 This requires  that you add the @code{Instrument_name_engraver} to the
-staff context.
+staff context. You can also  use markup texts to construct more
+complicated instrument names:
 
 
+@lilypond[verbatim,singleline]
+#(define text-flat
+  '((font-relative-size . -2 ) (music "accidentals--1")))
+
+\score { \notes {
+  \property Staff.instrument = #`((kern . 0.5) (lines
+    "2 Clarinetti" (rows "     (B" ,text-flat ")")))
+    c'' 4 }
+  \paper { 
+    \translator { \StaffContext
+    \consists "Instrument_name_engraver"; } } }
+@end lilypond
+
+
+@refbugs
+
+When you put a name on a grand staff or piano staff (By adding an
+@code{Instrument_name_engraver} to that context and setting
+e.g. @code{\property GrandStaff.instrument}), the width of the brace is
+not taken into account. You must add extra spaces to the end of the name
+to avoid a collision.
+
 @node Transpose
 @subsection Transpose
 @cindex Transpose
@@ -2363,11 +2411,9 @@ The syntax for part combining is
 @end example
 
 where the pieces of music @var{musicexpr1} and @var{musicexpr2} will be
-combined into one context @var{context}.  The names of the music
+combined into one context @var{context}.  The context names of the music
 expressions must start with the prefixes @code{one} and @code{two}.
 
-[Name of music expressions?  is that context name? ]
-
 The most useful function of the part combiner to combining threads into
 one voice, as common for wind parts in orchestral scores:
 
@@ -2549,6 +2595,7 @@ grob property.
 * What to tune?::               
 * Font selection::              
 * Text markup::                 
+* Embedded @TeX{}::             
 @end menu
 
 @node Tuning groups of grobs 
@@ -2561,12 +2608,17 @@ property.  By assigning to that property (using plain @code{\property}),
 you can change the resulting grobs.
 
 @lilypond[verbatim, fragment]
-c'4 \property Voice.Stem \override #'meta = #'((interfaces . ())) c'4
+c'4 \property Voice.Stem  = #'((meta . ((interfaces . ())))) c'4
 @end lilypond
 
-The @code{\property} statement effectively empties the definition of the
-Stem object. One of the effects is that property specifying how it
+The @code{\property} assignment effectively empties the definition of
+the Stem object. One of the effects is that property specifying how it
 should be printed is erased, with the effect of rendering it invisible.
+The above assignment is available as a standard identifier, lest you
+find this useful:
+@example
+  \property Voice.Stem = \turnOff
+@end example
 
 @cindex \override
 @cindex \revert
@@ -2611,6 +2663,29 @@ Formally the syntax for these constructions is
 Here @var{symbol} is a Scheme expression of symbol type, @var{context}
 and @var{grobname} are strings and @var{value} is a Scheme expression.
 
+If you want to be
+Correct nesting of @code{\override}, @code{\set}, @code{\revert} is as
+follows
+
+@example 
+\override \set \set \set \set
+\revert
+@end example
+
+This is always correct, but if you know the default value, you can also use 
+@example
+\set \set \set \set
+\set @var{to default value}
+@end example
+
+If there is no default (i.e. by default, the grob property is unset),
+then you can use
+@example
+\set \set \set \set \set
+\revert
+@end example
+
+
 @refbugs
 
 LilyPond will hang or crash if @var{value} contains cyclic references.
@@ -2875,6 +2950,71 @@ avoided because this makes it impossible for LilyPond to compute the
 exact length of the string, which may lead to collisions.  Also, @TeX{}
 commands won't work with direct postscript output.
 
+@cindex metronome mark
+
+One practical application of complicated markup is to fake a metronome
+marking:
+
+@lilypond[verbatim]
+#(define note '(rows
+  (music "noteheads-2" ((kern . -0.1) "flags-stem"))))
+#(define eight-note `(rows ,note ((kern . -0.1)
+  (music ((raise . 3.5) "flags-u3")))))
+#(define dotted-eight-note
+  `(rows ,eight-note (music "dots-dot")))
+
+\score {
+  \notes\relative c'' {
+    a1^#`((rows (font-relative-size . -1)) ,dotted-eight-note " = 64")
+  }
+  \paper {
+    linewidth = -1.;
+    \translator{
+      \ScoreContext
+      TextScript \override #'font-shape = #'upright
+    }
+  }
+}
+@end lilypond
+
+@node Embedded @TeX{}
+@subsection Embeded @TeX{}
+@cindex embedded tex
+@cindex embedded tex
+
+You can use @TeX{} commands in text scripts, but this should be avoided
+because this makes it impossible for LilyPond to compute the exact
+length of the string, which may lead to collisions.  Also, @TeX{}
+commands won't work with direct PostScript output.
+
+@lilypond[fragment,relative,verbatim]
+  a''^"3 $\\times$ \\`a deux"
+@end lilypond
+
+@subsection Embedded PostScript
+@cindex embedded postscript
+@cindex embedded postscript
+
+You can also use raw PostScript commands embedded in text scripts.  This
+offers ultimate flexibitily, but you'll have to learn the arcane
+PostScript language.  Currently, embedded PostScript will @strong{not}
+work with direct PostScript output.  Note that all dimensions that you
+use are in @code{staff-space}s.
+
+@lilypond[verbatim]
+\score {
+  \notes \relative c'' {
+    a-#"\\embeddedps{3 4 moveto 5 3 rlineto stroke}"
+    -#"\\embeddedps{ [ 0 1 ] 0 setdash 3 5 moveto 5 -3 rlineto stroke}"
+    b-#"\\embeddedps{3 4 moveto 0 0 1 2 8 4 20 3.5 rcurveto stroke}"
+    s2
+    a'1
+  }
+  \paper { linewidth = 70 * \staffspace; }
+}
+@end lilypond
+
+
 @c . {Page layout}
 @node Page layout
 @section Page layout
@@ -3100,13 +3240,25 @@ details, see the example file @file{input/test/between-systems.ly}
 @cindex Sound
 
 LilyPond can produce MIDI output.  The performance lacks lots of
-interesting effects, such as swing, articulation, slurring, tieing,
-etc., but it is good enough for proof-hearing the music you enter.
-
-Dynamics and tempo changes are interpreted.
-
-[TODO: mention volume control/Instrument Equaliser]
-
+interesting effects, such as swing, articulation, slurring, etc., but it
+is good enough for proof-hearing the music you have entered.  Ties,
+dynamics and tempo changes are interpreted.
+
+The MIDI volume is composed of two elements: the current dynamics of the
+voice and the type of musical instrument.
+
+Dynamic marks, crescendi and decrescendi translate into MIDI volume
+levels.  Dynamic marks translate to a fixed fraction of the available
+MIDI volume range, crescendi and decrescendi make the the volume vary
+linearly between their two extremities.  The fractions be adjusted by
+overriding the @code{absolute-volume-alist} defined in
+@file{scm/midi.scm}.
+
+For each type of musical instrument (that MIDI supports), a volume range
+can be defined.  This gives you basic equaliser control, which can
+enhance the quality of the MIDI output remarkably.  You can add
+instruments and ranges or change the default settings by overriding
+the @code{instrument-equaliser-alist} defined in @file{scm/midi.scm}.
 
 @refbugs
 
@@ -3268,8 +3420,6 @@ relocated, so this can also be used to shorten measures.
 
 A bar check is entered using the bar symbol, @code{|}
 
-
-
 @c .  {Point and click}
 @node Point and click
 @subsection Point and click
@@ -3291,7 +3441,6 @@ Xdvi} version 22.36 or newer.
 @item emacs
 @end itemize
 
-
 Add one these lines to the top of your .ly file. The first one is for
 line location only. The second one is more convenient, but requires
 patching @code{emacsclient}.
@@ -3338,105 +3487,22 @@ will complain about not finding @code{src:X:Y} files. Those complaints are
 harmless, and can be ignored.
 
 
-@c . {Using LilyPond}
-@node Using LilyPond
-@section Using LilyPond
-@cindex Using LilyPond
-@cindex Generating output
-
-@c slaat dit ergens op?
-
-@c direct postscript?
-
-@table @code
-@item plain lilypond
-@example
-lilypond foo.ly
-@end example
-For more information on how to use lilypond see
-@ifnottex
-@ref{Invoking LilyPond}.
-@end ifnottex
-@iftex
-the online manual.
-@end iftex
-
-@item ly2dvi
-Ly2dvi produces titling from @code{\header} fields.
-@example
-ly2dvi foo.ly
-@end example
-For more information on how to use ly2dvi see
-@ifnottex
-@ref{ly2dvi}.
-@end ifnottex
-@iftex
-the online manual.
-@end iftex
-
-@item lilypond-book
-Lilypond-book supports interleaving text and music.
-@example
-lilypond-book foo.doc
-@end example
-For more information on how to use lilypond-book see
-@ifnottex
-@ref{lilypond-book}.
-@end ifnottex
-@iftex
-the online manual.
-@end iftex
-@end table
-
-
-An emacs mode for LilyPond is included with the source archive as
-@file{lilypond-mode.el} and @file{lilypond-font-lock.el}.  If you have
-an RPM, it is in @file{/usr/share/doc/lilypond-X/}.  You have to install
-it yourself.
-
-Add this to your ~/.emacs or ~/.emacs.el:
-@example 
-    (load-library "lilypond-mode.el")
-    (setq auto-mode-alist
-      (cons '("\\.ly$" . LilyPond-mode) auto-mode-alist))
-    (add-hook 'LilyPond-mode-hook (lambda () (turn-on-font-lock)))
-@end example
-
-If you have the latest LilyPond-1.3.x Debian package, LilyPond-mode
-is automatically loaded, so you need not modify your ~/.emacs file.
-
-@menu
-* Pre-cooked makefile::         
-@end menu
-
-@node Pre-cooked makefile
-@subsection Pre-cooked makefile
-
-@c waar deze info?  is uiteindelijk wel handig, schat ik.
-[TODO: cut blabla]
-If you have a big music project, or just a lot of LilyPond input files,
-all generated output from LilyPond, @TeX{} and metafont will clutter
-your working directory.  LilyPond comes with a one-size-fits-all
-pre-cooked makefile that helps you manage producing ouptut.  It will
-produce all output in @file{out}, generate and track dependencies.
-Also, it helps in preparing your submission to the @ref{Mutopia
-project}.
+@node Skipping corrected music
+@section Skipping corrected music
 
-@file{make/ly.make}
-@example
-mkdir my-project
-cd my-project
-cp /usr/share/lilypond/make/ly.make GNUmakefile
-cp /usr/share/doc/lilypond/examples/input/tutorial/menuet.ly .
-make menuet
-[..]
-Generated out/menuet.ps for target menuet.
-@end example
-
-Type @samp{make help} to see possible targets.
+The property @code{Score.skipTypesetting} can be used to switch on and
+off typesetting completely during the interpretation phase. When
+typesetting is switched off, the music is processed much more quickly.
+You can use this to skip over the parts of a score that you have already
+checked for errors. 
 
-[TODO]
-@file{/usr/share/lilypond/doc/lilypond/examples/input/mutopia-header.ly}
+@lilypond[fragment,singleline,verbatim]
+\relative c'' { c8 d
+\property Score.skipTypesetting = ##t
+  e f g a g c, f e d
+\property Score.skipTypesetting = ##f
+c d b bes a g c2 } 
+@end lilypond
 
 
 @node Interpretation context
@@ -3981,7 +4047,8 @@ This means that @var{func} is applied to @var{music}.  The function
 This example replaces the text string of a script. It also shows a dump
 of the music it processes, which is useful if you want to know more
 about how music is stored.
-@lilypond[verbatim]
+
+@lilypond[verbatim,singleline]
 #(define (testfunc x)
         (if (equal? (ly-get-mus-property x 'text) "foo")
                 (ly-set-mus-property x 'text "bar"))
@@ -3996,15 +4063,36 @@ about how music is stored.
 } 
 @end lilypond
 
-For more information on what is possible, see the @ref{Tricks} and the
-automatically generated documentation.
+For more information on what is possible, see the automatically
+generated documentation.
 
 
 Directly accessing internal representations is dangerous: the
 implementation is subject to changes, so you should avoid this feature
 if possible.
-  
-  
+
+A final example is a function that reverses a piece of music in time:
+
+@lilypond[verbatim,singleline]
+#(define (reverse-music music)
+  (let* ((elements (ly-get-mus-property music 'elements))
+         (reversed (reverse elements))
+         (span-dir (ly-get-mus-property music 'span-direction)))
+    (ly-set-mus-property music 'elements reversed)
+    (if (dir? span-dir)
+        (ly-set-mus-property music 'span-direction (- span-dir)))
+    (map reverse-music reversed)
+    music))
+
+music = \notes { c'4 d'4( e'4 f'4 }
+
+\score { \context Voice {
+    \music
+    \apply #reverse-music \music
+  }
+}
+@end lilypond
+
 
 @c .   {Span requests}
 @menu