To answer the Lilypond part of the question: as Tim mentioned, they're two voices on the same staff, so that reflects what you need to do in Lilypond.
When typesetting classical guitar pieces with Lilypond, I usually use 3 separate voices and put them on the same staff. Here it clearly needs only two. I would recommend you to use a structure like this
global = {
\time 4/4
\key c \major
}
melody = {
\global
\voiceOne
c'4. g4 c'4. |
}
bass = {
\global
\voiceTwo
c4 e c e |
}
This defines three variables: \global
(I put global settings that need to be put in every voice and staff there, i. e. time signature (omitted in the image), key, and any "style" settings you may want to use), \melody
(that keeps the upper voice of the guitar: we put the contents of \global
into it and declare it to be the first voice, so it has stems up) and \bass
(ditto for the lower voice).
To combine them, we need a single Staff that has both of the voices in it. So we use the following \score
block:
\score {
\new Staff <<
\clef "treble_8"
\new Voice \melody
\new Voice \bass
>>
\layout{}
\midi{}
}
The \score
block just contains whatever you want to output. We specify that we need one staff with the clef "treble_8" (the guitar is written in the treble clef, but it actually sounds an octave lower than what is written (that's the "_8" part)) and two voices, one containing \melody
and the other \bass
. The <<
and >>
just say that you are going to put multiple things (in this case voices) into the staff (or anything else). After that, we just need to put in a \layout{}
(which tells Lilypond to output to PDF, with default settings) and \midi{}
(which activates the MIDI output, with default settings). If you had any special settings for them, you could set them inside those empty braces.
By the way, for this example, the structure I gave is an overkill since this one line: << { \clef "G_8" c'4. g4 c'4. } \\ { c4 e c e } >>
does just the same thing. However, this quietly sets a lot of things to default values (so if you want to change anything, you would still need to introduce parts of the bigger structure), and it just doesn't scale (typesetting more than 5 bars of music like this is going to be a huge pain). So I would recommend to go with the explicit structure from the start.