@node Putting it all together
@chapter Putting it all together
-This section will demonstrate more complicated stuff in LilyPond, probably
-via annotated examples. It's currently incomplete and serves as a
-placeholder so that the chapter numbering doesn't change later.
+This section explains how to use the rest of the documentation and
+how to solve common problems.
@menu
* Suggestions for writing LilyPond files::
+* Extending the templates::
@end menu
-@c explain \score{} ? Add a note to the tutorial?
@node Suggestions for writing LilyPond files
@section Suggestions for writing LilyPond files
@end itemize
+@node Extending the templates
+@section Extending the templates
+
+You've read the tutorial, you know how to write music. But how can you
+get the staves that you want? The templates are ok, but what if you
+want something that isn't covered?
+
+Start off with the template that seems closest to what you want to end
+up with. Let's say that you want to write something for soprano and
+cello. In this case, we would start with ``Notes and lyrics'' (for the
+soprano part).
+
+@example
+\version "2.4.0"
+melody = \relative c' @{
+ \clef treble
+ \key c \major
+ \time 4/4
+
+ a4 b c d
+@}
+
+text = \lyricmode @{
+ Aaa Bee Cee Dee
+@}
+
+\score@{
+ <<
+ \context Voice = one @{
+ \autoBeamOff
+ \melody
+ @}
+ \lyricsto "one" \new Lyrics \text
+ >>
+ \layout @{ @}
+ \midi @{ \tempo 4=60 @}
+@}
+@end example
+
+Now we want to add a cello part. Let's look at the ``Notes only'' example:
+
+@example
+\version "2.4.0"
+melody = \relative c' @{
+ \clef treble
+ \key c \major
+ \time 4/4
+
+ a4 b c d
+@}
+
+\score @{
+\new Staff \melody
+\layout @{ @}
+\midi @{ \tempo 4=60 @}
+@}
+@end example
+
+We don't need two @code{\version} commands. We'll need the @code{melody}
+section. We don't want two @code{\score} sections -- if we had two
+@code{\score}s, we'd get the two parts separately. We want them together,
+as a duet. Within the @code{\score} section, we don't need two
+@code{\layout} or @code{\midi}.
+
+If we simply cut and paste the @code{melody} section, we would end up with
+two @code{melody} sections. So let's rename them. We'll call the one
+for the soprano @code{sopranoMusic}, and the one for the cello can be
+called @code{celloMusic}. While we're doing this, let's rename @code{text}
+to be @code{sopranoLyrics}. Remember to rename both instances of all
+these names -- both the initial definition (the
+@code{melody = relative c' @{ } part) and the name's use (in the
+@code{\score} section).
+
+While we're doing this, let's change the cello part's staff -- celli
+normally use bass clef. We'll also give the cello some different
+notes.
+
+@example
+\version "2.4.0"
+sopranoMusic = \relative c' @{
+ \clef treble
+ \key c \major
+ \time 4/4
+
+ a4 b c d
+@}
+
+sopranoLyrics = \lyricmode @{
+ Aaa Bee Cee Dee
+@}
+
+celloMusic = \relative c @{
+ \clef bass
+ \key c \major
+ \time 4/4
+
+ d4 g fis8 e d4
+@}
+
+\score@{
+ <<
+ \context Voice = one @{
+ \autoBeamOff
+ \sopranoMusic
+ @}
+ \lyricsto "one" \new Lyrics \sopranoLyrics
+ >>
+ \layout @{ @}
+ \midi @{ \tempo 4=60 @}
+@}
+@end example
+
+This is looking promising, but the cello part won't appear in the
+score -- we haven't used it in the @code{\score} section. If we
+want the cello part to appear under the soprano part, we need to add
+
+@example
+\new Staff \celloMusic
+@end example
+
+@noindent
+underneath the soprano stuff. We also need to add @code{<<} and
+@code{>>} around the music -- that tells LilyPond that there's
+more than one thing (in this case staff) happening at once. The
+@code{\score} looks like this now
+
+@example
+\score@{
+<<
+ <<
+ \context Voice = one @{
+ \autoBeamOff
+ \sopranoMusic
+ @}
+ \lyricsto "one" \new Lyrics \sopranoLyrics
+ >>
+ \new Staff \celloMusic
+>>
+ \layout @{ @}
+ \midi @{ \tempo 4=60 @}
+@}
+@end example
+
+@noindent
+This looks a bit messy; the indentation is messed up now. That is
+easily fixed. Here's the complete soprano and cello template.
+
+@lilypond[quote,verbatim,raggedright]
+\version "2.4.0"
+sopranoMusic = \relative c' {
+ \clef treble
+ \key c \major
+ \time 4/4
+
+ a4 b c d
+}
+
+sopranoLyrics = \lyricmode {
+ Aaa Bee Cee Dee
+}
+
+celloMusic = \relative c {
+ \clef bass
+ \key c \major
+ \time 4/4
+
+ d4 g fis8 e d4
+}
+
+\score{
+ <<
+ <<
+ \context Voice = one {
+ \autoBeamOff
+ \sopranoMusic
+ }
+ \lyricsto "one" \new Lyrics \sopranoLyrics
+ >>
+ \new Staff \celloMusic
+ >>
+ \layout { }
+ \midi { \tempo 4=60 }
+}
+@end lilypond
+
+