4.4.1 Szoprán és cselló

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 the ‘Notes and lyrics’ template (for the soprano part).

\version "2.23.82"
melody = \relative {
  \clef treble
  \key c \major
  \time 4/4
  a4 b c d
}

text = \lyricmode {
  Aaa Bee Cee Dee
}

\score {
  <<
    \new Voice = "one" {
      \autoBeamOff
      \melody
    }
    \new Lyrics \lyricsto "one" \text
  >>
  \layout { }
  \midi { }
}

Now we want to add a cello part. Let’s look at the ‘Notes only’ example:

\version "2.23.82"
melody = \relative {
  \clef treble
  \key c \major
  \time 4/4
  a4 b c d
}

\score {
  \new Staff \melody
  \layout { }
  \midi { }
}

We don’t need two \version commands. We’ll need the melody section. We don’t want two \score sections – if we had two \scores, we’d get the two parts separately. We want them together, as a duet. Within the \score section, we don’t need two \layout or \midi.

If we simply cut and paste the melody section, we would end up with two melody definitions. This would not generate an error, but the second one would be used for both melodies. So let’s rename them to make them distinct. We’ll call the section for the soprano sopranoMusic and the section for the cello celloMusic. While we’re doing this, let’s rename text to be sopranoLyrics. Remember to rename both instances of all these names – both the initial definition (the melody = \relative c' { part) and the name’s use (in the \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.

\version "2.23.82"
sopranoMusic = \relative {
  \clef treble
  \key c \major
  \time 4/4
  a4 b c d
}

sopranoLyrics = \lyricmode {
  Aaa Bee Cee Dee
}

celloMusic = \relative {
  \clef bass
  \key c \major
  \time 4/4
  d4 g fis8 e d4
}

\score {
  <<
    \new Voice = "one" {
      \autoBeamOff
      \sopranoMusic
    }
    \new Lyrics \lyricsto "one" \sopranoLyrics
  >>
  \layout { }
  \midi { }
}

This is looking promising, but the cello part won’t appear in the score – we haven’t used it in the \score section. If we want the cello part to appear under the soprano part, we need to add

\new Staff \celloMusic

underneath the soprano stuff. We also need to add << and >> around the music – that tells LilyPond that there’s more than one thing (in this case, two Staves) happening at once. The \score looks like this now:

\score {
  <<
    <<
      \new Voice = "one" {
        \autoBeamOff
        \sopranoMusic
      }
      \new Lyrics \lyricsto "one" \sopranoLyrics
    >>
    \new Staff \celloMusic
  >>
  \layout { }
  \midi { }
}

This looks a bit messy; the indentation is messed up now. That is easily fixed. Here’s the complete soprano and cello template.

sopranoMusic = \relative {
  \clef treble
  \key c \major
  \time 4/4
  a4 b c d
}

sopranoLyrics = \lyricmode {
  Aaa Bee Cee Dee
}

celloMusic = \relative {
  \clef bass
  \key c \major
  \time 4/4
  d4 g fis8 e d4
}

\score {
  <<
    <<
      \new Voice = "one" {
        \autoBeamOff
        \sopranoMusic
      }
      \new Lyrics \lyricsto "one" \sopranoLyrics
    >>
    \new Staff \celloMusic
  >>
  \layout { }
  \midi { }
}

[image of music]

Lásd még

The starting templates can be found in the ‘Templates’ appendix, see Egy kottasor.


LilyPond — Tankönyv v2.23.82 (development-branch).