gtrtab2midi - converts ascii-tab guitar tablature to MIDI


 gtrtab2midi | aplaymidi -
 gtrtab2midi | fluadity -

 gtrtab2midi -p  24 | aplaymidi -   # patch 24
 gtrtab2midi -t 140 | aplaymidi -   # 140mS/pulse
 gtrtab2midi -T 8 | aplaymidi -   # 8 pulses/sec

 gtrtab2midi > outfile.mid
 midiedit outfile.mid


gtrtab2midi converts ascii-tab guitar tablature to MIDI, which can then be played using fluadity or aplaymidi, or edited using midiedit

gtrtab2midi uses a more compact and rhythmic version of ascii-tab guitar tablature, in which each character represents a particular elapsed time (by default one sixth of a second).   This means the ascii text is (at least) twice as compact, and the rhythm is clearly specified.   The following example is the first four bars of The London Rag, and an MP3 of   gtrtab2midi | fluadity -   can be heard here.


Therefore, to represent the high frets with one character, gtrtab2midi supports the following extension to standard guitar tablature notation: within the system, using hexadecimal notation for the high frets :
    A   play the tenth 10th fret
    B   play the eleventh 11th fret
    C   play the twelfth 12th fret (the octave)
    D   play the thirteenth 13th fret
    E   play the fourteenth 14th fret
    F   play the fifteenth 15th fret

gtrtab2midi supports only the following on-string symbols, which have the same rhythmic value as a dash -   :
    x   ends the note on that string
    *   the adjoining number on the left (C,7,5 or 4) was a harmonic
    b   bend up one semitone
    ^   bend up two semitones
    p   pre-bend one semitone
    P   pre-bend two semitones
    r   release the one-semitone bend
    R   release the two-semitone bend

Bending is only offered over one or two semitones. An example of bending: on the B-string,   ---3-b3---   plays a d which bends smoothly up the eb, followed immediately by a new d. Or   ---3-b--rx---   plays a d which bends smoothly up the eb and then releases back down again fo the d.

An example of pre-bending: on the B-string,   ----5--p8-r-x--   plays an e then a pre-bent g# releasing back down to a g

Conventional ascii-tab guitar tablature is described in


Since version 1.6, gtrtab2midi offers a syntax for setting a voice-line. The voice-line starts with VF| or VM| for female or male voices respectively. It looks something like this example:

  d|---------------|---------- -----|---------------|- --------------|
  A|---------------|---------- -----|---------------|- --------------|
  G|-----77-7--77-7|-----77-7- -77-7|-----77-7--77-7|- ----77-7--77-7|
  D|7--7--7--7--7--|7--7--7--7 --7--|7--7--7--7--7--|7 --7--7--7--7--|
  A|0--------0-----|0--------0 -----|0--------0-----|0 --------0-----|
  D|0--------0-----|0--------0 -----|0--------0-----|0 --------0-----|
Voices don't have frets, so the pitches are notated differently, using a notation which borrows from muscript but uses the tablature-time-pulse for rhythm.

Near the middle of each clef there is a "c". This note is written c and the notes above it are written c# d eb en f f# g g# a bb b c~ c~# d~ e~b and so on up to b~. Likewise, the notes below c are B Bb A Ab G F# F E Eb D C# C B_ B_b A_ and so on down to C_. Thus on each voice-line you can write a range of nearly four octaves.

Each such note is one time-pulse long even if it uses two characters like F# so you may find it neater to pad the guitar-strings with a blank underneath the # or b in order to preserve the vertical alignment.

The default midi-patch for the voice is 82, but you can change this with the -P option.


-p 24

This option sets the MIDI Patch, to 24 = Acoustic Guitar(nylon) in this example. The default is 25 = Acoustic Guitar(steel). See for a list of the General-MIDI patch numbers.

-P 85

This option sets the MIDI Voice-patch, to 85 = Lead 6 (voice) in this example. The default is 82 = Lead 3 (calliope). See for a list of the General-MIDI patch numbers.

-t 140

This options sets the Tempo, in milliseconds per pulse, where a pulse is the time taken by a - in the ascii-tab input. The pulse is therefore the shortest time-interval you can express in ascii-tab, a sixteenth-note (semiquaver) for example. The default is 167, meaning a sixth of a second.

-T 8

This option is an alternative to the -t option; it sets the Tempo in pulses per second, where a pulse is the time taken by a - in the ascii-tab input. The pulse is therefore the shortest time-interval you can express in ascii-tab. The default is 6, meaning 167 milliseconds.


Print the Version


This script is freely available at
Move it to somewhere in your $PATH, and if necessary change the first line to reflect where lua is installed.

It needs the MIDI.lua module, which is available from so you should be able to install it by:
    luarocks install midi


 20200602 1.7 add back-compatible argument *a for
 20180826 1.6 add a VM or VF voice-line
 20180819 1.5 -T option for pulses/sec
 20180809 1.4 bending with -3-b3- and -p3-r1- also ^, P and R
 20180807 1.3 C* 7* 5* 4* 9* are the natural harmonics
 20180806 1.2 x ends the note on that string
 20180804 1.1 introduce -t and -p options
 20180801 1.0 initial release


Peter J Billam,