1

I have a piece of lilypond code here:

\version "2.20.0"
#(set-global-staff-size 20)

\score{

    \new GrandStaff
<<

    \new Staff {  \tempo 4 = 126
    <<
\new Voice 
    { \voiceOne e'1~e'1  z1 z1}

\new Voice 
    { \voiceTwo e1~e1 z1 z1}

\new Voice 
    { \voiceThree d1~d1 z1 z1 }

\new Voice 
    { \voiceFour b1~b1  z1 z1}

\new Voice 
    { \voiceFive r1 r1 g1~g1 }

\new Voice 
    { \voiceSix r1 r1 g'1~g'1 }

\new Voice 
    { \voiceSeven r1 r1 c1~c1 }

\new Voice 
    { \voiceEight r1 r1 f'1~f'1 }

    >>
    }
    
\new Staff { \stemUp \clef bass r1 r1 a8 c'8 a8 c'8 a8 c'8 a8 c'8   a8 c'8 a8 c'8 a8 c'8 a8 c'8 }   
    
>>
   \layout{}
    \midi{\tempo 4 = 126} 
}

whose output is :

enter image description here

Why the 3rd measure in treble staff is a whole note rest?

I have seen this: lilypond rests making an empty whole measure but it is due to extra rest r8.

I would like to have grand staff.

1
5

You don't need that many voices. You may write chords. For example your upper stave may be written

<d e b e'>1 ~ q <c g f' g'> ~ q

Pitches within single angle brackets are put into a chord in a single voice. q is a shorthand for whichever chord was mentioned most recently.

Here is one way to Lilypond both staves of your excerpt. From the code you put in your question, it appeared that you wanted only 4 measures and that the rest in the upper stave was a mistake. Sorry if I've misunderstood what you wanted.

\version "2.18.2"

global = {
    \tempo 4=126
    s1*4
}

rh = {
    <d e b e'>1 ~ q <c g f' g'> ~ q
}

lh = {
    \clef bass R1*2
    \repeat unfold 8 { a8 c' }
}

\score
{
    \new GrandStaff
    <<
        \new Staff << \global \rh >>
        \new Staff << \global \lh >>
    >>
}

I've assigned a music expression to the variable global. It is not necessary to do this, but I find it useful because there are going to be things that pertain to all the parts, e.g. changes of tempo and the positions of double-bars.

6
  • How to show both the treble and bass clef – Vinod May 20 at 12:20
  • Suppose If I want to add another voice rh1 = { <f a c d'>1 ~ q <d e g' a'> ~ q } in treble and lh1 = { \clef bass R1*2 \repeat unfold 8 { b8 d' } } in bass what should I do. I need to have multiple voices in both treble and bass clef seperately. – Vinod May 20 at 12:46
  • 1
    If you wanted to have multiple voices on the same stave, then you can use the << { ... } \\ { ... } >> construction which Elements In Space has shown in their answer. Depending on what you wanted to happen at the same time, this might look cluttered and hard to read. Alternatively, you could use more than two staves, in which case you can put three or more \new Staff objects inside the GrandStaff. (BTW you couldn't have rh1 as a name -- Lilypond allows only letters.) – Rosie F May 20 at 12:51
  • This is clearly a much better approach.  But this would be a better answer if it also explained why the code in the question fails. – gidds May 20 at 20:27
  • 2
    OP's code fails because \voiceFive (etc) isn't a thing, so LilyPond leaves a space that has the value of the last note (a whole note / semibreve). This is why voices 5-8 are all misaligned. – Elements in Space May 22 at 7:03
4

Too many voices.

The commands for \voiceOne ... \voiceFour are defined but \voiceFive and above are not commands that are recognised by LilyPond.

However you can have more than four voices if you use the construct:

<< 
   { ... } \\ 
   { ... } \\ 
   { ... } \\ 
   { ... } \\
   { ... } \\
   { ... } 
>>

See this page of the documentation for how to use multiple voices.


Also, (unrelated) what is z supposed to be? (perhaps you mean s for space / invisible rest)

1
  • How to show both the treble and bass clef – Vinod May 20 at 12:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.