]> git.donarmstrong.com Git - lilypond.git/blobdiff - Documentation/user/examples.itely
* Documentation/user/global.itely (Creating titles):
[lilypond.git] / Documentation / user / examples.itely
index 095d5d5c86d0bd2e4a216cfbeda8247883c19507..df4ed86b4e13b647ea6560ace5949d9e7e38f333 100644 (file)
@@ -8,64 +8,16 @@ beautiful printed scores!
 
 @c bad node name for ancient notation to avoid confict
 @menu
-* Suggestions for writing LilyPond files::
-* Single staff::
-* Piano templates::
-* String quartet::
-* Vocal ensembles::
-* Ancient notation templates::
-* Jazz combo::
-* Other templates::
-* Lilypond-book templates::
+* Single staff::                
+* Piano templates::             
+* String quartet::              
+* Vocal ensembles::             
+* Ancient notation templates::  
+* Jazz combo::                  
+* Other templates::             
+* Lilypond-book templates::     
 @end menu
 
-@c TODO explain \score{} ?  Maybe add a note to the tutorial?
-
-@node Suggestions for writing LilyPond files
-@section Suggestions for writing LilyPond files
-
-Now you're ready to begin writing larger LilyPond files -- not just the
-little examples in the tutorial, but whole pieces.  But how should you
-go about doing it?
-
-The best answer is ``however you want to do it.''  As long as LilyPond
-can understand your files and produces the output that you want, it
-doesn't matter what your files look like.  That said, sometimes we
-make mistakes when writing files.  If LilyPond can't understand your
-files, or produces output that you don't like, how do you fix the
-problem?
-
-Here are a few suggestions that can help you to avoid or fix
-problems:
-
-@itemize @bullet
-@item Include @code{\version} numbers in every file.  Note that all
-templates contain a @code{\version "2.4.0"} string.  We
-highly recommend that you always include the @code{\version}, no matter
-how small your file is.  Speaking from personal experience, it's
-quite frustrating to try to remember which version of LilyPond you were
-using a few years ago.  @code{convert-ly} requires you to declare
-which version of LilyPond you used.
-
-@item Include checks: See @ref{Bar check} and @ref{Octave check}.  If you
-include checks every so often, then if you make a mistake, you can pinpoint
-it quicker.  How often is ``every so often''?  It depends on the complexity
-of the music.  For very simple music, perhaps just once or twice.  For
-very complex music, every bar.
-
-@item One bar per line.  If there is anything complicated, either in the music
-itself or in the output you desire, it's often good to write only one bar
-per line.  Saving screen space by cramming eight bars per line just isn't
-worth it if you have to `debug' your files.
-
-@item Comment your files, with either bar numbers (every so often) or
-references to musical themes (``second theme in violins'', ``fourth
-variation'').  You may not need it when you're writing the piece for
-the first time, but if you want to go back and change something two
-or three years later, you won't know how your file is structured if you
-don't comment the file.
-
-@end itemize
 
 @node Single staff
 @section Single staff
@@ -76,7 +28,7 @@ instrument or a melodic fragment.  Cut and paste this into a file,
 add notes, and you're finished!
 
 @lilypond[quote,verbatim,raggedright]
-\version "2.4.0"
+\version "2.6.0"
 melody = \relative c' {
    \clef treble
    \key c \major
@@ -101,7 +53,7 @@ automatic beaming, you'll have to change or comment out the relevant
 line.
 
 @lilypond[quote,verbatim,raggedright]
-\version "2.4.0"
+\version "2.6.0"
 melody = \relative c' {
    \clef treble
    \key c \major
@@ -132,7 +84,7 @@ text = \lyricmode {
 Want to prepare a lead sheet with a melody and chords?  Look no further!
 
 @lilypond[quote,verbatim,raggedright]
-\version "2.4.0"
+\version "2.6.0"
 melody = \relative c' {
    \clef treble
    \key c \major
@@ -165,7 +117,7 @@ harmonies = \chordmode {
 This template allows you to prepare a song with melody, words, and chords.
 
 @lilypond[quote,verbatim,raggedright]
-\version "2.4.0"
+\version "2.6.0"
 melody = \relative c' {
    \clef treble
    \key c \major
@@ -206,7 +158,7 @@ harmonies = \chordmode {
 Here is a simple piano staff.
 
 @lilypond[quote,verbatim,raggedright]
-\version "2.4.0"
+\version "2.6.0"
 upper = \relative c'' {
    \clef treble
    \key c \major
@@ -240,7 +192,7 @@ Here is a typical song format: one staff with the melody and lyrics, with
 piano accompaniment underneath.
 
 @lilypond[quote,verbatim,raggedright]
-\version "2.4.0"
+\version "2.6.0"
 melody = \relative c'' {
    \clef treble
    \key c \major
@@ -296,7 +248,7 @@ Instead of having a full staff for the melody and lyrics, you can place
 the lyrics between the piano staff (and omit the separate melody staff).
 
 @lilypond[quote,verbatim,raggedright]
-\version "2.4.0"
+\version "2.6.0"
 upper = \relative c'' {
    \clef treble
    \key c \major
@@ -344,7 +296,7 @@ since the template is right here, you don't have to do the
 tweaking yourself.
 
 @lilypond[quote,verbatim,raggedright]
-\version "2.4.0"
+\version "2.6.0"
 upper = \relative c'' {
   \clef treble
   \key c \major
@@ -411,13 +363,18 @@ pedal = {
       \override VerticalAlignment #'forced-distance = #7
     }
   }
+}
+\score {
+  \context PianoStaff <<
+    \context Staff=upper << \upper \dynamics >>
+    \context Staff=lower << \lower \dynamics >>
+    \context Dynamics=pedal \pedal
+  >>
   \midi {
     \context {
       \type "Performer_group_performer"
       \name Dynamics
       \consists "Piano_pedal_performer"
-      \consists "Span_dynamic_performer"
-      \consists "Dynamic_performer"
     }
     \context {
       \PianoStaff
@@ -436,7 +393,7 @@ This template demonstrates a string quartet.  It also uses a @code{\global}
 section for time and key signatures.
 
 @lilypond[quote,verbatim,raggedright]
-\version "2.4.0"
+\version "2.6.0"
 
 global= {
   \time 4/4
@@ -496,7 +453,7 @@ contains all the music definitions.  The other files -- @code{score.ly},
 
 @verbatim
 %%%%% piece.ly
-\version "2.4.0"
+\version "2.6.0"
 
 global= {
   \time 4/4
@@ -542,7 +499,7 @@ music = {
 
 
 %%%%% score.ly
-\version "2.4.0"
+\version "2.6.0"
 \include "piece.ly"
 #(set-global-staff-size 14)
 \score {
@@ -553,7 +510,7 @@ music = {
 
 
 %%%%% vn1.ly
-\version "2.4.0"
+\version "2.6.0"
 \include "piece.ly"
 \score { 
   \keepWithTag #'vn1 \music
@@ -562,7 +519,7 @@ music = {
 
 
 %%%%% vn2.ly
-\version "2.4.0"
+\version "2.6.0"
 \include "piece.ly"
 \score { 
   \keepWithTag #'vn2 \music
@@ -571,7 +528,7 @@ music = {
 
 
 %%%%% vla.ly
-\version "2.4.0"
+\version "2.6.0"
 \include "piece.ly"
 \score { 
   \keepWithTag #'vla \music
@@ -580,7 +537,7 @@ music = {
 
 
 %%%%% vlc.ly
-\version "2.4.0"
+\version "2.6.0"
 \include "piece.ly"
 \score { 
   \keepWithTag #'vlc \music
@@ -600,7 +557,7 @@ parts.  For example, the time signature and key signatures are almost
 always the same for all parts.
 
 @lilypond[quote,verbatim,raggedright]
-\version "2.4.0"
+\version "2.6.0"
 global = {
    \key c \major
    \time 4/4
@@ -670,6 +627,102 @@ bassWords = \lyricmode {
 @end lilypond
 
 
+@subsection SATB vocal score and automatic piano reduction
+
+This template adds an automatic piano reduction to the SATB vocal
+score.  This demonstrates one of the strengths of LilyPond -- you
+can use a music definition more than once.  If you make any changes
+to the vocal notes (say, tenorMusic), then the changes will also
+apply to the piano reduction.
+
+@lilypond[quote,verbatim,raggedright]
+\version "2.6.0"
+global = {
+   \key c \major
+   \time 4/4
+}
+
+sopMusic = \relative c'' {
+   c4 c c8[( b)] c4
+}
+sopWords = \lyricmode {
+   hi hi hi hi
+}
+
+altoMusic = \relative c' {
+   e4 f d e
+}
+altoWords =\lyricmode {
+   ha ha ha ha
+}
+
+tenorMusic = \relative c' {
+   g4 a f g
+}
+tenorWords = \lyricmode {
+   hu hu hu hu
+}
+bassMusic = \relative c {
+   c4 c g c
+}
+bassWords = \lyricmode {
+   ho ho ho ho
+}
+
+\layout {
+  \context {
+         % a little smaller so lyrics
+         % can be closer to the staff
+         \Staff
+          minimumVerticalExtent = #'(-3 . 3)
+  }
+}
+
+<<
+  \context ChoirStaff
+  <<
+    \context Lyrics = sopranos { s1 }
+    \context Staff = women <<
+      \context Voice =
+        sopranos { \voiceOne << \global \sopMusic >> }
+      \context Voice =
+        altos { \voiceTwo << \global \altoMusic >> }
+    >>
+    \context Lyrics = altos { s1 }
+    \context Lyrics = tenors { s1 }
+    \context Staff = men <<
+      \clef bass
+      \context Voice =
+        tenors { \voiceOne <<\global \tenorMusic >> }
+      \context Voice =
+        basses { \voiceTwo <<\global \bassMusic >> }
+    >>
+    \context Lyrics = basses { s1 }
+    \context Lyrics = sopranos \lyricsto sopranos \sopWords
+    \context Lyrics = altos \lyricsto altos \altoWords
+    \context Lyrics = tenors \lyricsto tenors \tenorWords
+    \context Lyrics = basses \lyricsto basses \bassWords
+  >>
+  \new PianoStaff
+  <<
+    \new Staff <<
+      \set Staff.printPartCombineTexts = ##f
+      \partcombine
+      << \global \sopMusic >>
+      << \global \altoMusic >>
+    >>
+    \new Staff <<
+      \clef bass
+      \set Staff.printPartCombineTexts = ##f
+      \partcombine
+      << \global \tenorMusic >>
+      << \global \bassMusic >>
+    >>
+  >>
+>>
+@end lilypond
+
+
 @c bad node name to avoid node name confict
 @node Ancient notation templates
 @section Ancient notation templates
@@ -685,11 +738,14 @@ notes.  As a compromise, bar lines are often printed between the
 staves rather than on the staves.
 
 @lilypond[quote,verbatim,linewidth=11.0\cm]
-\version "2.4.0"
+\version "2.6.0"
 
 global = {
+  \set Score.skipBars = ##t
+
   % incipit
   \once \override Score.SystemStartBracket #'transparent = ##t
+  \override Score.SpacingSpanner #'spacing-increment = #1.0 % tight spacing
   \key f \major
   \time 2/2
   \once \override Staff.TimeSignature #'style = #'neomensural
@@ -705,6 +761,7 @@ global = {
   \bar ""
 
   % main
+  \revert Score.SpacingSpanner #'spacing-increment % CHECK: no effect?
   \cadenzaOff % turn bar lines on again
   \once \override Staff.Clef #'full-size-change = ##t
   \set Staff.forceClef = ##t
@@ -720,13 +777,7 @@ global = {
   \set Staff.printKeyCancellation = ##t
   \set Staff.forceClef = ##f
 
-  \skip 1*5
-
-  % last bar contains a brevis (i.e., spans 2 bars);
-  % therefore do not draw this particular bar
-  \cadenzaOn
-  \skip 1*2
-  \cadenzaOff
+  \skip 1*7 % the actual music
 
   % let finis bar go through all staves
   \override Staff.BarLine #'transparent = ##f
@@ -925,7 +976,7 @@ is within a @code{\transpose} section.
 @c The `linewidth' argument is for the \header.
 
 @lilypond[quote,verbatim,raggedright,linewidth]
-\version "2.4.0"
+\version "2.6.0"
 \header {
   title = "Song"
   subtitle = "(tune)"
@@ -1191,7 +1242,7 @@ violin concerto as TchaikovskyPI, whereas perhaps you wish to print
 
 @ The `linewidth' is for \header.
 @lilypond[quote,verbatim,raggedright,linewidth]
-\version "2.4.0"
+\version "2.6.0"
 \header {
   dedication = "dedication"
   title = "Title"
@@ -1200,6 +1251,7 @@ violin concerto as TchaikovskyPI, whereas perhaps you wish to print
   composer = "Composer (xxxx-yyyy)"
   opus = "Opus 0"
   piece = "Piece I"
+  meter = "meter"
   instrument = "Instrument"
   arranger = "Arranger"
   poet = "Poet"
@@ -1221,19 +1273,19 @@ violin concerto as TchaikovskyPI, whereas perhaps you wish to print
 }
 
 \score {
+  { c'4 }
   \header {
     piece = "piece1"
     opus = "opus1"
   }
-  { c'4 }
 }
 
 \score {
+  { c'4 }
   \header {
     piece = "piece2"
     opus = "opus2"
   }
-  { c'4 }
 }
 @end lilypond
 
@@ -1350,6 +1402,7 @@ You can include LilyPond fragments in a LaTeX document.
 
 @example
 \documentclass[]@{article@}
+\usepackage@{graphics@}
 \begin@{document@}
 
 Normal LaTeX text.