Skip to content

Instantly share code, notes, and snippets.

@tepreece
Created June 26, 2017 20:58
Show Gist options
  • Save tepreece/0c948194c68aa40aa9c5af7ed448ebcd to your computer and use it in GitHub Desktop.
Save tepreece/0c948194c68aa40aa9c5af7ed448ebcd to your computer and use it in GitHub Desktop.
% Template for ukulele tablature
% by Thomas Preece
% Licence: CC0 / public domain
% This is a very quick primer in how to use Lilypond for ukulele tabs. It covers the very
% basics - play around with it, make changes and see what happens!
% To get started, open this file in Frescobaldi. You should see the code on the left and a
% blank space on the right. If you press Ctrl+M (Windows or Linux - I'm assuming it's Cmd+M
% on a Mac but don't know for sure), or choose Lilypond -> Engrave (Preview) from the menu,
% it will engrave the document and display it in the space on the right.
% You probably figured that the character "%" starts a comment. Comments are there to
% remind us what we're doing, and are ignored by Lilypond. You can put them in wherever
% you like. The rest of the comments explain what's going on with the code.
% Here we tell Lilypond which version we're using. This is sort of optional
% but recommended, and you'll get a warning if you don't include it. It
% prevents someone trying to compile the music with a too-old version. Don't
% worry about it. :)
\version "2.18.2"
% Here we tell Lilypond that we want to use English names for notes. Valid notes are:
% c d e f g a b (naturals)
% cs ds es fs gs as bs (sharps)
% cf df ef ff gf af bf (flats)
\include "english.ly"
% Here we tell Lilypond what our piece is called etc.
\header {
title = "Title of the Piece"
subtitle = ""
composer = "Composer of the Piece"
arranger = "arr Your Name Here"
tagline = ""
}
% Here we set our paper size and staff size. If you're American, you'll probably want
% to change the paper size to "letter". Make the staff size number smaller or larger
% to change the size of the printed music.
#(set-default-paper-size "a4")
#(set-global-staff-size 22)
% This is where we enter the music for our piece. There are a few things going on here:
% 1. We assign the music to the name "piece". This means that when we want to print it out
% (later in the document), we use this name to refer to it. This saves typing it in twice
% for both staff and tab.
% 2. We transpose the music up one octave. This is because the default octave in Lilypond is
% one octave too low for the ukulele. This means that the note "c" is now the lowest note
% on the uke.
piece = \transpose c c' {
% Enter the key signature and time signature for your piece of music.
% These should be fairly self explanatory. Note that "\time 4/4" is rendered as a "C" for
% common time - there is an option to change it to numbers if you want, but it doesn't
% really matter.
\key c \major
\time 4/4
% A tempo marking is optional. Here we say that a note of duration "4" (ie, a quarter note)
% is 120 beats per minute.
\tempo 4 = 120
% Now we enter the music! Let's start with a C major scale.
% The "4" after the first c means that this note, and all the notes that follow it until
% we change, should be quarter notes.
% The last note is c' - this means c an octave higher.
% We tell Lilypond which notes we want, and it calculates the tab for us.
c4 d e f g a b c'
% Notice that you can click on notes in the preview (right-hand pane), and it will
% highlight the relevant line in the code.
% This puts in a double bar. I'm using this to make the different sections clearer in the
% output. You'll see this below as well.
\bar "||"
% We can extend our scale to the next octave. This time let's use eighth notes.
c'8 d' e' f' g' a' b' c''
\bar "||"
% Now let's have another scale with some weird timings.
c1 d2 e4 f g8 a b4 c'2
\bar "||"
% It's good practice to include "bar checks" - enter a pipe at the end of each bar. If you
% entered the music wrong, you'll get a warning when you compile it.
c4 d e f | g a b c' |
\bar "||"
% You can specify which string to put the note on by adding the string number afterwards.
% Lilypond isn't smart enough to know how to put notes on the ukulele's high G string,
% so when you want a note there, you have to do it manually.
% The strings are numbered starting at the highest - ie:
% A => \1
% B => \2
% C => \3
% g => \4
% Here the scale climbs up the g string, instead of the A string.
c4 d e f | g\4 a\4 b\4 c'\4 |
\bar "||"
% Obviously you want to put the notes on sensible strings - ie, not like this:
% (Note that saying a\1 is redundant, as it'll put the note on string 1 anyway).
c d e f\3 | g\3 a\1 b\4 c'\3 |
\bar "||"
% If you want to play multiple notes at the same time, enclose them in <angle brackets>
% You have to tell it which string to put each note on - it's not usually smart enough to
% figure it out for itself. The note duration goes after the whole chord.
<c\3 e\2 g\4 c'\1>1
\bar "||"
% To do dotted rhythms, just add the dot after the note duration.
c4. d8 e4. f8 | g4. a8 b4. c'8 |
% For accidentals, just enter the name of the note. Note that each note is independent - if
% you say fs (F sharp), but then f (F natural) later in the bar, it will be rendered as an
% F natural. If you want them both to be F sharps, put fs for both. As G sharp and A flat
% are the same note, they are both assigned to the same fret in the tab.
cs4 d ef fs | gs af bf c' |
\bar "||"
% To change the key, just use the \key command again. Let's change to G major.
\key g \major
g a b c' d' e' f' g' |
\bar "||"
% That's not what we wanted - G major has an F sharp in it, but remember that f always means
% F natural, and fs always means F sharp. Let's try that again.
g a b c' d' e' fs' g' | % That's better
% Finish the piece with a nice double bar.
\bar "|."
}
% The rest of this is just boilerplate to tell Lilypond that we want to see a staff and a
% tab staff of the same music. Notice how we can say "\piece" to refer to the music we
% entered above, rather than having to type it out twice.
\score {
<<
\new StaffGroup \with {
instrumentName = #"Ukulele"
shortInstrumentName = #"Uke"
} <<
\new Staff \with {
} \new Voice \with {
\remove New_fingering_engraver
\remove Dynamic_engraver
\remove Text_engraver
} \piece
\new TabStaff \with {
stringTunings = #ukulele-tuning
\tabFullNotation
} \piece
>>
>>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment