Tips, Techniques, Examples about my favorite musical instrument, the Twelve-String Guitar.

If you play guitar check out Playing Technique, or Strings / Setup. There are also some interesting posts about guitars at, you guessed it, Guitars.

If you want to spread your musical talents around, you will find some good info at Recording.

Marketing - meh - I'm probably the world's best bad example. Although you could find funny stuff there.

I've made some music videos through the years, and you can find them and other interesting music at Music I Like, Music I Play.

Thursday, March 29, 2007

Lilypond, a notation program




Whenever I post images of music, they are screenshots of PDF files generated by my favorite Linux based music notation program Lilypond.

It took me a long time to find a good notation program. Back when I could run a Windows emulator under OS/2, I used Studio from Midisoft. This is still around, in several incarnations. It was a WYSIWYG interface and I learned a lot about creating and editing midi files. It printed scores that were ok for personal use, but not good enough to publish. There are a lot of choices in Linux and I looked for a similar program. Rosegarden came closest, but during the search I happened upon Lilypond. Lilypond is about as different from the wysiwyg interface as one could possibly be.

My old cycling buddy and guitar teacher, Allan Alexander, uses Fronimo, which he calls "the best tablature notation software".
As he described Fronimo, it reminded me of my first computer mentor describing the wonders of WordPerfect running on CPM - a PC operating system prior to Microsoft's DOS. He would argue that one could type and format anything without lifting their hands from the first position of the keyboard. Allan said much the same thing about Fronimo.

Fronimo doesn't run on Linux, unfortunately. However Lilypond does seem to share some of those characteristics. Once you get all the setup syntax in place, typing scores is almost as easy as, well, typing. For example, here's a C7 chord with piano fingering:

< c-1 e-2 g-3 b-5 >4
The typing and score results of this and other examples are at Fingering Instructions. Click on each image and you can see the code that you need to type to generate it. The code is simple - it follows the line "ly snippet contents follows:". All of the other code above that is duplicated for each snippet and describes how to display the score.

Notes are simply a b c d e f g. To flatten, add es, to sharpen add is. The tutorial explains this better than I. Let me just point out a few guitar specific items.


Guitar Specific Notation

Guitar music typically has at least two voices. The upper is usually played with the fingers and the lower with the thumb. There are several ways to stack notes in lilypond, but I find it easiest to write each voice out separately. In the example below, the upper voice is uI (Up 1), and the lower is dI. This is what I named them; you can give them any name you like, as long as it starts with a letter. Usually Lilypond stems the music correctly, but it's pretty easy to over-ride the stem direction when you need to with a stemDown or stemUp directive.

Since some guitarists prefer tabs, you will probably want to generate tabs as well as standard notation. It's easy to do, and can be done independently of writing out the notes; but it's important to indicate all unusual fingerings, even if they are intuitive because Lilypond will always assume first position fingering. Here is tablature for the snippet:


For standard notation, you can indicate right and left hand fingering and string indications. I notated the fragment specifically to show a new way to finger a difficult set of measures, so it shows all of these fingering options. Here's the upper voice of the first measure in the snippet:

r16^\markup {IX} <e'\3> <gis'\2> <d''\1_2> gis' e' gis' e' b e' gis e'
This starts with a 16th note rest, r16, and the fret position, IX, is generated with the directive. The strings are always indicated with '\StringNumber', as in \1, \2, \3. This always shows up on the tab score, but is only visible in the standard score if you enclose the note in angle brackets. So the first note, e, has the string 3 indicated and the second note, g sharp, is on string 2. The third note, d, has both a string indicated, 1, and a left finger indicated, 2. The left finger indication is placed under the staff by prefacing it with '_'. If you wanted it above the staff, use '^'. Or you can leave it out and let Lilypond figure it out.

I use a kind of generic score section that starts with the headers - titles and such, followed by the paper layout for the pdf file. I want standard letter for the pdf file. Following that are the notes themselves. You can break them into many expressions (enclosed in curly brackets) or write them in one big expression. The complexity of the music and the orderliness of your mind dictates how you do this. After that I follow with a section that describes how I want the standard notation to print out, another section with some directives for the tablature, and finally a little bit of code that combines the tab and the standard notation. Add comments anywhere on a single line by starting them with '%'; comment out a block anywhere by bracketing with '%{' and '%}'. Later you will see how you can generate tab or score or both by commenting out a line.

Here is the lilypond code for the entire snippet of measures 22 to 27.

\version "2.10.0"
\header {
title = "Lute Prelude BWV999 - fragment"
arranger = "Art Sulger"
instrument = "12-string Guitar"
}

\paper{
#(set-paper-size "letter")
#(define bottom-margin (* 2 cm))
}

uI = {
\voiceOne
r16^\markup {IX} <e'\3> <gis'\2> <d''\1_2> gis'\2 e'\3 gis'\2 e'\3 b\4 e'\3 gis\5 e'\3 |
r16 <ees'\3_2> <a'\2_4> <c''\1_1> a'\2 ees'\3 a'\2 ees'\3 a\4 ees'\3 f\5 ees'\3 |r16 d'\3-2 f'\2-1 b'\1-3 f'\2 d'\3 f'\2 d'\3 gis\4 d'\3 e\5 d'\3 |
r16 c'\3-2 fis'\2-4 a'\1-1 fis'\2 c'\3 fis'\2 c'\3 fis\4-1 c'\3 dis\5-3 c'\3 |
r16 b\3-3 d'\2-1 a'\1-4 d'\2 b\3 d'\2 b\3 f\4-1 b\3 d\5-0 b\3 |
r16 b\3-3 d'\2-2 gis'\1-4 d'\2 b\3 d'\2 b\3 e\4-1 b\3 b,\5-1 b\3 |
}
dI = {
\voiceTwo
e,4 \tag #'bassnotes { r4 <b\4_1>8 <gis\5-3>8 } \tag #'restnotes {s4 s8 s8} |
e,4 \tag #'bassnotes { r4 <a\4_1>8 <f\5_3>8 } \tag #'restnotes {s4 s8 s8} |
e,4 \tag #'bassnotes { r4 <gis\4_1>8 <e\5_3> } \tag #'restnotes {s4 s8 s8} |
e,4 \tag #'bassnotes { r4 <fis\4>8 <dis\5> } \tag #'restnotes {s4 s8 s8}|
e,4 \tag #'bassnotes { r4 f8 d8\5 } \tag #'restnotes {s4 s8 s8}|
e,4 \tag #'bassnotes { r4 e8 b,8 } \tag #'restnotes {s4 s8 s8}|
}
Notation = \simultaneous { %% Combine both parts for notation
\time 3/4
\clef "G_8"
\key d \minor
\override Score.MetronomeMark #'padding = #6.0 \tempo 4=95
% \override StringNumber #'self-alignment-Y = #-1
\override Score.StringNumber #'padding = #3.5
\set fingeringOrientations = #'(up left down)
<< \context Voice=VoiceA \uI >>
<< \context Voice=VoiceB \keepWithTag #'bassnotes \dI >>
}

Tablature = \simultaneous { %% Combine both parts for Tablature
\time 3/4
\override TabStaff.Stem #'transparent = ##t %% Makes stems transparent
\override TabStaff.Beam #'transparent = ##t %% Makes beams transparent
<< \context TabVoice=TabVoiceA \uI >>
<< \context TabVoice=TabVoiceB \keepWithTag #'restnotes \dI >>
}


\score {
\context StaffGroup {
\simultaneous {
<< \context Staff=FullNotation \Notation >>
<< \context TabStaff=FullTab \Tablature >>
}
}
}


You can see that I separated tabs and score, but the same bundles of notes for the upper voice, uI, and the lower voice, dI, are used for both. You can print the score or tab individually, or have them both printed together by commenting out the last two lines of code. Here is the snippet with standard notation, followed by tab plus standard:


One last note on a workaround for polyphonic guitar tablature: When notes are shared by the upper and lower voice, as they are in the Lute piece in every measure, Lilypond does a great job with the standard notation, but you have to fiddle with it a little to get the tab right, otherwise the finger number for the shared note is repeated. That makes the tab look really odd, especially when you start seeing fret numbers that look like 88 or 1212! The workaround is to write two expressions where the shared notes appear. The first expression will be used in the score and the second, with silent rests, is used in the tab. Then you write a little command to filter out one or the other in the tab and score sections. Here are the notes with the two 'versions'. One expression is tagged restnotes and the other is tagged bassnotes.

\tag #'bassnotes { r4 <b\4_1>8 <gis\5-3>8 } \tag #'restnotes {s4 s8 s8}

In the part of the code that generates the music, we do the filtering of the tags:

Standard:
<< \context Voice=VoiceB \keepWithTag #'bassnotes \dI >>

Tab:
<< \context TabVoice=TabVoiceB \keepWithTag #'restnotes \dI >>


Edited for clarity Friday, March 30, 1:00 PM

4 comments:

Anonymous said...

Grazie, Thanks!

-Mattia Giovanetti

Shane Layden said...

Hello. I am a guitar teacher from Durban, South Africa. I have been using Lilypond to print out exercises for my students and I was really struggling to get polyphonic music notation with guitar tab to work correctly until I happened to find your blog. It was very helpful indeed and I just want to say thank you for having taken the time to post the information. Thank you.
Shane Layden

Jazz4Sale said...

Hello, I saw your post and I was wondering if you can give me an example on how to use guitar chords with Lilypond. I have done some reasearch and the samples I've found don't work for some reason.

12String said...

Jazz4Sale:
I haven't had a problem with chord diagrams. Here's a bit from my prelude transcription of Bach's first Cello Suite that works ok:


g16-2 ^\markup \fret-diagram #"6-5;5-x;4-o;4-5;3-4;2-x;1-x;"
d'^"G" b'-1 a-4 b d, b' d, g, d' b' a b d, b' d, |
g, ^\markup \fret-diagram #"6-5;5-7;4-x;3-4;3-5;2-x;1-x;"
e'-4^"Em" c'-2 b-1 c e, c' e, g, e' c' b c e, c' e, |
g,-2 ^\markup \fret-diagram #"6-5;5-x;4-4;3-4;3-5;2-x;1-x;"

Post a Comment