Monday, 11 October 2010

Guitar tabs with LilyPond

Adding guitar tablature to the existing LilyPond score cannot be easier. By default, LilyPond generates tabs for Spanish guitar in standard tuning. So, I took the score of Autumn Leaves and inserted
\new TabStaff
\staffMelody
in the score section. However, by some obscure reason, the resulting tab is one octave off the notes on the staff. To remediate this, I transposed \staffMelody one octave lower:
{ \transpose c' c \staffMelody }
To add a nice header to the whole thing:
\header {
 title = "Les Feuilles mortes (Autumn Leaves)"
 composer = "Joseph Kosma"
}
Still, I thought that was not enough changes for today’s post, so I replaced the chord progression (with a simpler one). Here’s the final version:
% ****************************************************************
% Autumn Leaves (Joseph Kosma)
% ****************************************************************
\version "2.12.3"
\header {
 title = "Les Feuilles mortes (Autumn Leaves)"
 composer = "Joseph Kosma"
}
\sourcefilename "display-predefined-fretboards.ly"
\include "predefined-guitar-fretboards.ly"
\storePredefinedDiagram \chordmode {a:m6}
                        #guitar-tuning
                        #"x;o;2-2;2-3;1-1;2-4;"
\storePredefinedDiagram \chordmode {b:9-}
                        #guitar-tuning
                        #"x;2-2;1-1-(;2-3;1-1-);2-4;"
\storePredefinedDiagram \chordmode {g:maj7}
                        #guitar-tuning
                        #"3-2;2-1;o;o;o;2-3;"
theChords = \chordmode {
  \set majorSevenSymbol = \markup { maj7 }
  \partial 4 r4 
  \repeat volta 2 {
  a2:m7 d2:7 
  g2:maj7 c2
  a2:m6 b2 
  e1:m
  a2:m7 d2:7 
  g2:maj7 c2 
  a2:m6 b2:9-
  e1:m 
  b1
  e1:m
  d1
  g1
  b1:9- 
  e1:m7 
  a2:m6 b2:7}
 \alternative {
  { e1:m }
  { e1:m }
 }
}
staffMelody = {
   \key e \minor
   \partial 4 \times 2/3 { e'8 fis'8 g'8 } 
   \repeat volta 2 {
    c''2. \times 2/3 { d'8 e'8 fis'8 }
    b'4 b'4( b'8) r8 \times 2/3 { c'8 d'8 e'8 } 
    a'2. \times 2/3 { b8 cis'8 dis'8 } 
    g'2 (g'8) r8 \times 2/3 { e'8 fis'8 g'8 } \break
    c''2. \times 2/3 { d'8 e'8 fis'8 } 
    b'4 b'4( b'8) r8 \times 2/3 { c'8 d'8 e'8 }
    a'2( a'8) fis'8 a'8 g'8 
    e'2( e'8) r8 dis'8 e'8 \break
    fis'8 b8 fis'2 e'8 fis'8 
    g'4 g'4( g'8) g'8 fis'8 g'8
    a'2( a'8) d'8 d''8. c''16 
    b'2. ais'8 b'8 \break
    c''8 c''8 a'!8 a'8 fis'4 c''4
    b'4 b'2 e'4 
    a'4 a'8 g'8 fis'4 g'8. b16 }
   \alternative {
  { e'2( e'8) e'8 fis'8 g'8 }
  { e'2( e'8) r8 r4 \bar "|." }
 }
}
\score {
  <<
    \context ChordNames { \theChords }
    \context FretBoards { \theChords }
    \new Staff 
      \with {
      \consists "Volta_engraver"
    }
    {
      \context Voice = "voiceMelody" { \staffMelody }
    }
    \new TabStaff 
    { \transpose c' c \staffMelody }
  >>
\layout {
    \context {
      \Score
      \remove "Volta_engraver"
    }
  }
}
And the output:

3 comments:

  1. The original was actually not off by an octave. Many guitarists don't realise that the guitar is a transposing instrument, and sounds one octave lower than written. Lilypond does not take this into account when you write tabs ...
    regards,
    Thomas Evdokimoff

    ReplyDelete
  2. Thanks for the comment!

    ReplyDelete
  3. http://www.learnandlistenguitar.blogspot.com

    A great Blog For learning and listening Guitar!
    Must Visit.

    ReplyDelete