Ceci est une ancienne révision du document !
As a guitarist who is also a geek at heart, I’m always looking for a way to organise my various tab books alongside my PDF tabs. In preparation for my summer, I’ve therefore started collecting some of the tabs I like in an electronic format. At first, it was via scanning, but the quality of that was often less than overwhelming. Instead, I’ve begun writing the musical notation and tabs using LilyPond.
What is LilyPond? For anyone who knows what LaTeX is, LilyPond is (in very basic terms) a typesetting language for music. In the music world, it’s not called typesetting, but engraving. LilyPond is a language where you describe the music, and it then takes the information (keys, notes, etc), and generates staffs and/or tabs. Quality-wise, I’ve found the PDFs it produces to be better quality (from font-size, to spacing in general) than things like TuxGuitar or Tab Pro. Best of all, it is cross-platform, and editable from anywhere (as the source files are just text).
How does it Work? LilyPond uses *.ly files as source code. Once the code has been written, it is then compiled into a PDF using the lilypond CLI tool. The way the source code works is by defining a Staff - this is the normal musical notation, or TabStaff (tablature), or a variety of other options, none of which I have tried thus far. Each Staff can have multiple voices (for splitting up upper and lower registers, for example).
How can I get started? The website is http://lilypond.org, although the odds are the CLI tools are already in your local repository. The Manuals section of the site (http://lilypond.org/manuals.html) offers a good place to start. Once you’ve gotten comfortable with the syntax (or have run into a use case that doesn’t seem officially supported), then the user repository of snippets is an excellent spot to look: http://lsr.di.unimi.it/LSR/Search. For anyone who wants some actual examples, jump to the section called “The Basics”, as I will walk you through some examples.
It seems complicated - why can’t I just drag and drop? If you want to edit visually, you’ll need to look for other software to work with. Instead, I recommend LilyPond for anyone who prefers having total control (and finds a keyboard to be faster and more efficient than a mouse). I also highly recommend this approach to anyone who wants to learn to read musical notation better (as you’ll learn the note names, and therefore the location on the staff), or for anyone who wants to learn the locations of the notes on their instrument (specifically, guitar). This is because in thinking about the music in terms of notes (instead of string or fret numbers), you’ll learn which note is where - especially as you move on to more complex songs.
The Basics The template for the file can be found here: http://pastebin.com/pyJS56zj. Copy and save the template as FCM-example.ly (or any other name you may want). A single Voice, on a normal musical staff (no Tab): • Add the following between \pointAndClickOff and \score scale= \relative c { a ais b c cis d dis e f fis g gis \bar “|.” } • As you can see, you’re simply defining the notes that are to appear (and terminating with a closing bar). In LilyPond is stands for sharp (#), and es is flat (b). Keep in mind that a# is also bb (hence why no flats are present in the example above). • Before you can compile it, you’ll need to add a Staff to the score. Inserting a Staff into the score is done by placing the following between the « and » inside the \score{} \new Staff = “guitar” \with { } « \time 4/4 \context Voice = “guitar” { \clef “G_8” \voiceOne \scale } » • The \new Staff should be self-explanatory. The “guitar” simply assigns a name (in case you have multiple instruments on one page, for example). The \with{} is used for settings, and I leave it in my template so that I can more easily change settings for a Staff. If you prefer to leave it out, you can do so (but leave the «). The \time is the time signature. Then comes the important step - defining a Voice. I’ve defined it as “guitar”, with a G_8 clef (the clef is the symbol right at the beginning of the Staff), and defined VoiceOne using the variable scale we created earlier (step 1). • Compilation time! Be sure to replace FCM-example.ly with whatever you called your file. lilypond FCM-example.ly • This should result in a PDF, showing a scale of the notes. If this is the case, move on. If not, double-check the steps and the error messages. • What if we want to add in another octave? To do so, you can use ‘ and , to increase, and lower, the octave of a note. See the example below. scale= \relative c { a ais b c cis d dis e f fis g gis a’ ais b c cis d dis e f fis g gis \bar “|.” } • If you look at this example, you’ll see that I’ve inserted only one apostrophe. This is because it is a toggle, and not a one-time modifier. Meaning if you use two, your second note will be two octaves higher. Also, most people will notice that this actually skipped an octave. This is due to the fact that LilyPond is smart enough to realise that, after an increasing scale like above, that a new a should probably be an octave higher. You can disable this feature, but I find it quite useful. So to get the first 3 octaves, you can do this instead: scale= \relative c { a ais b c cis d dis e f fis g gis a ais b c cis d dis e f fis g gis a ais b c cis d dis e f fis g gis \bar “|.” } • This should result in a single scale, covering three octaves. LilyPond does offer a \repeat unfold option, to avoid having to type the same line multiple times. However, it would not work in this case, as there is an implied difference between each line (their octave). The below will repeat the same scale 3 times, in the same octave. This is useful to keep in mind. scale= \relative c { \repeat unfold 3 { a ais b c cis d dis e f fis g gis } \bar “|.” } • Prettying up the source code is useful, especially when you write whole songs. A bar division is indicated with “|”, and LilyPond will track the number of notes in a bar (to ensure you keep the time signature). It will throw warnings, but still compile, if this is wrong. See below: scale= \relative c { a ais b c | cis d dis2 | e f | fis | g gis \bar “|.” } • This example will result in the warning “barcheck failed at 1/2”. This is because I changed the d# into a half note (2 beats), and this change is automatically carried through to all following notes. By placing the f# in a bar by itself (and therefore being only 2/4), it results in the warning. In the PDF, there is no noticeable issue, but this will cause problems if using multiple voices (or if the song were longer). Instead, we need either a rest, or to adjust the duration of the notes. Correct the bar to read: fis r2 | • This adds a 2 beat rest into the bar, and fixes the timing issue. • Lastly, let us add a TabStaff, in order to create actual tablature. To do so, insert the following after the first » (following the closing bracket of \context Voice). \new TabStaff = “guitar” « \time 4/4 \context TabVoice = “guitar” { \clef “G_8” \voiceOne \scale } » • As you can see, it’s a similar approach. We’re even reusing the same variable with the notes. Compiling at this time will yield a typical guitar tablature
There are many other things you can do - chords, multiple voices, arpeggios, repeats, etc. But for a basic example, this will have to do. If you want to see what my file looked like at the end of this tutorial, it can be found here: http://pastebin.com/eqBwrkX9 If you have any issues, or questions, feel free to contact me. For some more examples, I highly recommend the snippets and documentation page. Or just simply creating a tab you already know. As always, I can be reached at lswest34+fcm@gmail.com.