On Music Tabs

I love music. I love playing music. I love making musical instruments and music software. I don’t have formal musical training. I’ve never taken lessons, and honestly, I’m a pretty bad musician. What I do excel at, though, is hoarding musical instruments.

At this point, name any instrument, and there’s a decent chance I have it somewhere in my room. Some of these instruments never played anything better than “Twinkle, Twinkle Little Star”, others featured in a recording or two, and only a few see regular play. Most, however, gather dust.

Why? Because I’m bad at music notation and I can’t memorise notes or chords of any song. I can read sheet music, but not fast enough to make it useful. However, when you start with a new instrument that requires you to learn fingerings, and I find it enormously difficult to have this translation pipeline in my brain: read sheet music, parse visually the notes, map them to some fingering chart, cover holes or press strings or move lips or perform some other physical action to the instrument.

In defense of tabs

That is why I love tablatures. I love ABC notation and Jianpu notation. Because there is already a trained part of my brain that can translate incoming bitmaps into meaningful tokens: I can read letters and digits.

Fortunately, for almost every instrument there is a plain text notation that tells uneducated musicians directly what to do. For guitars, ukuleles, mandolinas we have chords and we have text tabs that are read left-to-right, top-to-bottom and tell you which string on which fret to press. For harmonica the numbers show which hole to blow or to draw. For flutes they tell you which holes to cover. Even kids instruments like glockenspiel/xylophone or kalimba often have numbers on them that match with the melody the child is playing.

Tabs turn you into a simple machine: scan the instructions, apply the motions – and music happens! Yes, they strip away the nuance of rhythm or dynamics, but for beginners, that’s fine. Most people starting an instrument play songs they already know well enough to hum from memory, so rhythm and expression come naturally.

I know that professional musicians dislike tabs a lot and in every music community there are people replying “just learn how to read musical notation”. That’s fair. You probably shouldn’t use MicroPython or Arduino for embedded development and should just learn proper C. Then, you also shouldn’t use C and should rather learn safer languages. You probably shouldn’t use Scratch for building games and robots, but instead learn Python or any other real programming language.

And this is where fun and professionalism differ. I’m not a professional musician and merely want to have fun, with tabs helping me.

My tab script

Many years ago, in my school days, I was learning how to play harmonica. The trick is that harmonicas have a limited range of notes. Some are easy, others require difficult techniques like bending, and a few are nearly impossible on cheaper instruments.

When trying to pick out melodies by ear, I found myself wondering: what if I could transpose these melodies into keys that are easier to play? That’s when I wrote my little tab script.

The idea was simple:

import re, sys
ABC = "C C# D D# E F F# G G# A A# B c c# d d# e f f# g g# a a# b"
N = {n: i for i, n in enumerate(ABC.split())}
print([N.get(t, t) for t in re.findall(r"[A-Ga-g]#?|.", sys.argv[1])])

# python3 tab.py "CDEFGABcdefgab"
# [0, 2, 4, 5, 7, 9, 11, 12, 14, 16, 17, 19, 21, 23]

Once I had note numbers, I created mappings for harmonica tabs:

def inst(s): return {i: val for i, val in enumerate(s.split())}
harmonica = inst("+1 -1' -1 +1' +2 -2\" -2' +3 -3‴ -3\" -3' -3 +4 -4' -4 +4' +5 -5 +5' +6 -6' -6 +6' -7 +7 -7' -8 +8' +8 -9 +9' +9 -9' -10 +10\" +10' +10")
n = [N.get(t, t) for t in re.findall(r"[A-Ga-g]#?|.", sys.argv[1])]
print(" ".join([harmonica.get(t, '?') if isinstance(t, int) else t for t in n]))

# python3 tab.py "CDEFGABcdefgab"
# +1 -1 +2 -2" +3 -3" -3 +4 -4 +5 -5 +6 -6 -7

With a few tweaks, the script could automatically find the best key for a melody by trying different transpositions and picking the one with the fewest difficult notes. This made harmonica playing much more accessible.

Other instruments

Years later, I picked up the tin whistle, which has its own quirks:

Adding tin whistle tabs to my script was as simple as creating a new mapping:

#!/usr/bin/env python3
import re,sys
ABC = "C C# D D# E F F# G G# A A# B c c# d d# e f f# g g# a a# b"
N = {n: i for i, n in enumerate(ABC.split())}
def inst(s): return {i: val for i, val in enumerate(s.split())}
I = {
    'a': inst(ABC),
    'b': inst("0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25"),
    'c': inst("0 ~0 1 ~1 2 3 ~3 4 ~4 5 6 7 8 ~8 9 ~9 10 11"),
    'j': inst("1 #1 2 #2 3 4 #4 5 #5 6 #6 7 1' #1' 2' #2' 3' 4' #4' 5' #5' 6' #6' 7'"),
    'h': inst("+1 -1' -1 +1' +2 -2\" -2' +3 -3‴ -3\" -3' -3 +4 -4' -4 +4' +5 -5 +5' +6 -6' -6 +6' -7 +7 -7' -8 +8' +8 -9 +9' +9 -9' -10 +10\" +10' +10"),
    'H': inst("+1 <+1 -1 <-1 +2 -2 <-2 +3 <+3 -3 <-3 -4 +5 <+5 -5 <-5 +6 -6 <-6 +7 <+7 -7 <-7 -8 +9 <+9 -9 <-9 +10 -10 <-10 +11 <+11 -11 <-11 -12"),
    'w': inst("6 ~6 5 ~5 4 3 ~3 2 (14) 1 (02) 0 (05) ~6+ 5+ ~5+ 4+ 3+ (22+) 2+ (11+) 1+ (013+) 0+ (05)+"),
    't': inst("_123 _13 _23 _12 _1 _2 _0 123 13 23 12 1 2 0 +23 +12 +1 +2 +0 *12 *1 *2 *0 ^1 ^2 ^0 !23 !12 !1 !2 !0"),
}

n = [N.get(t, t) for t in re.findall(r"[A-Ga-g]#?|.", sys.argv[2])]
x = int(sys.argv[3]) if len(sys.argv) > 3 else 0
print(" ".join([I[sys.argv[1]].get(t+x, '?') if isinstance(t, int) else t for t in n]))

Here ‘a’ is the same ABC notation I use as an input. That’s what they teach here in primary schools and that’s the notation I usually “think” in. “B” is a “diddley bow”, or simply a guitar string with frets. “C” is a cute little instrument called Canjo, which I highly recommend building with kids! It lacks some frets and is almost diatonic (can play a major scale), so it also needs some careful transposition of the melodies. “H” and “h” are chromatic and diatonic harmonicas, “w” is a tin whistle and “t” is a trumpet.

I could have used more descriptive names and less cryptic notations, but being the only user of this script I got used to it.

I often use it in scripts to print my practice plans:

#!/bin/sh
cat << EOF
# Tin Whistle Practice

## Saints Go Marching In

$(tp w "CEFG CEFG CEFGECED")
$(tp w "EEDC CEGGF EFGECDC")

## Bella Ciao

$(tp w "F#Bc#dB F#Bc#dB F#Bc#dc#Bdc#Bf#f#f# f#ef#gg gf#egf# f#edc#f#dc#B" -2)

## ...
EOF

This script outputs some whistle tabs that are very terse: they usually fit one screen or a small piece of paper.

As a next step, I usually print tiny “zines” – little books of melodies or chords for instruments to memorise and practice. Here’s an example of one such zine for tin whistles – it can be printed and folded as a tiny book, and easily fits into a wallet or a pocket next to your whistle:

A “zine” of tin whistle tabs

I don’t think I could ever fit five melodies of staff musical notation into such a small format.

Unicode

Recently I decided to make a step forward and convert this little script of mine into something others could use. I’ve made https://github.com/zserge/tab - a command-line tablature printer for many exotic music instruments.

Unlike this original script, tab outputs multiline unicode texts with colour and allows to visualise tabs much better:

Tabs output

With terminal graphics it’s now possible to render tabs for Klavarscribo, ocarinas or even saxophones. But the core functionality is still the same - you pick an instrument, optionally transpose the melody – and see the tabs on the screen, ready to be played.

Join the Fun

I’m curious – are there other musicians out there who love tabs as much as I do? Whether you’re a harmonica enthusiast, tin whistle fan, or kalimba player, I’d love to hear your thoughts. And if you have favorite songs or practice lists, feel free to contribute to the repository examples! Let’s make music fun and accessible for everyone.

I hope you’ve enjoyed this article. You can follow – and contribute to – on Github, Mastodon, Twitter or subscribe via rss.

Nov 22, 2024

See also: On Poetry and more.