What is TexTab?

TexTab is a simple language for defining conventional music notation (henceforth called `CMN' and tablature notation (henceforth called `TN') for the banjo and other fretted stringed instruments. It was developed because I was fed up with the ugly hand-drawn tablature that permeates so much sheet music. You write a TexTab document using your favourite text generator (e.g. `EDIT' in DOS, or MS-Word).

Three application programs are provided:

  1. A program called `tabmusic' which converts a TexTab file in TN (i.e. string and fret defined) to CMN (i.e. `A'-`G'; natural, sharp or flat).
  2. A program called `musictab' which converts a TexTab file in CMN to TN. This is a much more powerful program than `tabmusic' as it attempts to make an optimal choice of strings and frets to be played, based on a set of rules (e.g. it tries not to play the same string for two adjacent notes).
  3. A program called `showtab' which translates a TexTab file in TN to a sequence of pages of tablature in PostScript format. If you have a PostScript printer you then just send the file to the printer. Alternatively you view and print the file using an application such as Ghostview. You may view an example of the tablature produced by TexTab.
The TexTab application programs are free software, provided as executable code for DOS-type machines. Special arrangements can be made for Unix machines.

Note that this is rather old (1990s) technology - but it still works!

Why is it Called TexTab?

It is called TexTab as an allusion to, and in gratitude for, the marvellous scientific typesetting programs called `TeX' (by Donald Knuth) and `LaTeX' (by Leslie Lamport).

The Home Page

You may either look at this home page in full or in sections, as follows:

The Language Tutorial

There are two types of TexTab text file:
  1. those in conventional music notation (CMN), and
  2. those in tablature notation (TN).
The only difference between the file formats is in the way in which the pitch is defined. For example, the second fret of the second string of a banjo tuned to GDGBD gives the C# note above middle C. This pitch is called `C4S' in CMN, where the `4' denotes the octave and the `S' denotes the sharp. Middle C is called `C4' and the note below that is called `B3' (i.e. the octave numbering increases by one between B and C). In TN this note is called `202', where the first `2' denotes the second string and the `02' the denotes the second fret.

We'll start by defining a single note. Let's choose C# above middle C, as above, which is called `C4S' in CMN and `202' in TN on a banjo tuned to GDGBD. We also need to define the length of the note, which is done by placing a `/' and two digits after the `C4S' or `202'. This uses the conventional fractional notation, where `/01' represents a semibreve, `/02' a minim, `/04' a crotchet, `/08' a quaver, `/16' a semiquaver etc. - lets choose a semiquaver, so the full note is indicated by `202/16' in TN. In tablature, this looks like:

There are a two things to note about this. Firstly the `2' is placed in between the horizontal lines - if you prefer it intersecting one line, then that is easily changed (see later). Also, although this is a very short tune, it also needs vertical lines to show the beginning and end of a bar. TexTab indicates these by the symbol `|'. The full TN code for the above is therefore `|202/16|'. Similarly, in CMN, this would be `|C4S/16|'.

The rest of this tutorial will deal only with TN - if you want to change the notation to CMN, just change each note as described above (e.g. `202' becomes `C4S').

Let's now add another note after this, a semiquaver at the third fret of the second string. This note is called `203/16' and must be separated from the first note in some way. We do this by using either a `&' character when the notes are within a single bar, or with a `|' character when the notes span two bars (the `|' character is also the bar separator). The two notes together are therefore coded as `|202/16&203/16|', which looks like:

We now often want to group notes by connecting the tails together. We do this by enclosing a set of notes in square brackets (`[' and `]'). The above pair of notes would then be coded as `|[202/16&203/16]|', which looks like:

We may then want to add an additional note, say, an open first string, in conjunction with the second note shown above. An open first string is coded as `100' (since the fret number of the open string is called `00'), and this is just added to the `203' of the existing second note to give `|[202/16&203100/16]|', which looks like:

Now, let's make the `202' note and the `203' note be connected by a slide, hammer, push or pull. This is done by enclosing the relevant notes in round brackets (`(' and `)') to give `|[(202/16&203)100/16]|', which looks like:

There is normally a series of letters along the bottom of the tablature to indicate (a) the finger used to pluck the string and (b) the presence of a slide, hammer, push or pull. TexTab does this by the underline character (`_'). Each time you insert a `_' for a given note, the annotation line moves down one level. To insert a single character, on the first annotation level, the `_' and the character are placed immediately after the note. Therefore to insert an `I' (for index finger) under the first note of the above and an `M' (for middle finger) under the second note, the code becomes `|[(202/16_I&203)100/16_M]|', which looks like:

Let's now assume that the `202' note and the `203' note are connected by a hammer. This requires a `H' underneath the `M' that is already there - i.e. on the next level of annotation down. This is done by adding a `_H' after the `_M' to give `|[(202/16_I&203)100/16_M_H]|', which looks like:

We now almost have the first bar of a tune (e.g. one version of Foggy Mountain Breakdown), which is coded as:

`|[(202/16_I&203)100/16_M_H&(202/16_T&203)100/16_M_H]&

[500/16_T&200/16_I&100/16_M&500/16_T]|',

(the code has here been split over two lines - line breaks make no difference to TexTab) which looks like:

You may now want to indicate a chord above the beginning of the bar. This is done using the `^' symbol, which works in the same way as `_' (underline) - each time you insert a `^' for a given note, the annotation line moves up one level. Therefore to indicate a G-chord, insert `^G' after the note, so that the code becomes:

`|[(202/16_I^G&203)100/16_M_H&(202/16_T&203)100/16_M_H]&

[500/16_T&200/16_I&100/16_M&500/16_T]|',

which looks like:

If you want to add more than one character on a given annotation line, just enclose it in double quotes ("). It should be noted that a region within quotes is one of the few places where spaces mean anything in the TexTab code - otherwise spaces (and also end-of-line characters) are generally ignored and may be used by yourself to make the code easier to read (e.g. by putting spaces between each bar, or by putting each bar on a separate line). The exceptions to this rule are that you should not:

Therefore, to put `G-chord' instead of just `G', the code becomes:

`|[(202/16_I^"G-chord"&203)100/16_M_H&(202/16_T&203)100/16_M_H]&

[500/16_T&200/16_I&100/16_M&500/16_T]|',

which looks like:

Also, to add subscripts and superscripts, you use the `_' (underline) and `^' characters, respectively. Note that this meaning (i.e. when within double quotes) is different from usage above. Therefore to insert the annotation line `Em' (for an E minor chord), instead of `G' or `G-chord', the code becomes: `|[(202/16_I^"E_m"&203)100/16_M_H&(202/16_T&203)100/16_M_H]&

[500/16_T&200/16_I&100/16_M&500/16_T]|',

which looks like:

Here are a few more useful items: A `$' is used to indicate a double vertical line at the beginning or end of a bar (i.e. instead of `|'). Our bar of the tune then becomes (going back to the G-chord):

`$[(202/16_I^G&203)100/16_M_H&(202/16_T&203)100/16_M_H]&

[500/16_T&200/16_I&100/16_M&500/16_T]$',

which looks like:

If you want to repeat this bar, then the `repeat' character is a `:', and our tune becomes:

`$:[(202/16_I^G&203)100/16_M_H&(202/16_T&203)100/16_M_H]&

[500/16_T&200/16_I&100/16_M&500/16_T]:$',

which looks like:

Finally, you may want to add a time signature. This is indicated by the `#' character. The actual numbers used are specified elsewhere (see `Parameter File', below). Our tune becomes:

`$:#[(202/16_I^G&203)100/16_M_H&(202/16_T&203)100/16_M_H]&

[500/16_T&200/16_I&100/16_M&500/16_T]:$',

which looks like:

Summary of the TexTab Code

The following table shows the major elements of the TexTab format. In this table, a general character sequence is indicated by a description enclosed in angled brackets. For example, an instance of <two capital letters> could be EF. Quotation marks are used to indicate specific instances, so that `A'-`G' represents any letter in the range `A' to `G'. Although upper case letters are used in the table, upper or lower case letters may be used in TexTab.

SYMBOL DESCRIPTION EXAMPLE MEANING
<`A'-`G'> <`0'-`9'> <`N', `S' or `F'> Pitch (CMN) `D4S' D above middle C, sharp
`RST' A rest (CMN) - -
<`0'-`9'> <`00'-`99'> String number and fret number (TN) `204' 2nd string, 4th fret
`000' A rest (TN) - -
`|' Beginning or end of bar (single line) - -
`$' Beginning or end of bar (double line) - -
`[' ..... `]' Tail connector `[202/16&203/16]' Tails of `202/16' and `203/16' connected
`(' ..... `)' Slide, hammer push or pull connector `(202/16&203)100/16' `202' and `203' connected
`_' (underline) Moves `lower' annotation down one level

OR

subscript to annotation

`202/16_I'

`202/16_I^"E_m"'

Note annotated below with `I'

Note annotated above with `Em'

`^' Moves `upper' annotation up one level

OR

superscript to annotation

`202/16^G'

`202/16_"H^2"'

Note annotated above with `G'

Note annotated below with `H2' (whatever that means!)

`"' Encloses annotation `202/16_I^"E_m"' `Em' is multi-character annotation
`:' Repeat character - -
`#' Time signature - -
`!' Everything following this until the end of the line is a comment - -

The Parameter File

Input to the TexTab programs is through the use of a Parameter File. This file contains the TexTab code (as described above) and also a set of numbers that define the way in which the programs work. Here is a specimen Parameter File.

Firstly, note the lines starting with a `#' character. These are just comments and are not used by any of the TexTab program - they just help you remember what the various things mean. Secondly, note that most of the other lines start with a word in capitals (the `keyword') followed by a number, numbers or a set of characters. Let's just look at the first line containing a keyword:

N_STRING 5
This tells the TexTab programs how many strings your instrument has - this is for a 5-string banjo. For a tenor banjo, you would put `N_STRING 4', and for a guitar you might put `N_STRING 6'.

The next line with a keyword is:

MAX_FRET 22
which tells the programs that your instrument has 22 frets.

The keyword lines may be in any order in the file, the exception being the special keywords `TABLATURE' and `MUSIC' which are followed by the TexTab code in TN and CMN, respectively (this specific parameter file has the tune in TN, but it could equally well be in CMN). The `TABLATURE' and `MUSIC' keywords must be the last keywords in the file and must be followed by the TexTab code, until the end of the file is reached. Keywords must alway start at the beginning of a line. Some way down the file you will find the line:

# MusicTab constants - MODIFY AT YOUR PERIL!!
The keywords between this statement and the TexTab code are used by `musictab' (the program which converts CMN into TN). They should only be altered if you really understand how this program works.

The following table describes the meaning of the the Parameter File keywords.

KEYWORD DESCRIPTION
N_STRING The number of strings to your instrument
MAX_FRET The number of frets to your instrument
LINE_OFF The vertical distance between the lines of tablature (cm)
STAVE_OFF The vertical distance between individual staves of tablature (cm)
NOTE_OFF The horizontal distance between tablature notes (cm)
BAR_OFF The horizontal distance between double vertical bar lines (cm)
TITLE_OFF The vertical distance between the tablature and its title (cm)
PAGE_WIDTH The page width (cm)
PAGE_LENGTH The page length (cm)
LEFT_MARGIN The left margin (cm)
RIGHT_MARGIN The right margin (cm)
TOP_MARGIN The top margin (cm)
BOTTOM_MARGIN The bottom margin (cm)
OUTPUT_FILE The name of the output file (conventionally `textab.op')
N_TITLE The number of title lines, followed by the title lines. Each title line contains the text in double quotes ("), followed by the size of the text (cm).
TIME_SIGNATURE The time signature, as a fraction (e.g. `2/4')
TUNING The tuning of the open strings, starting from the lowest. Each string is represented by a note in CMN, enclosed in double quotes (").
OFFSET The `offset' of each open string as a number of frets, starting from the lowest. For a tenor banjo or guitar this is zero for all the strings, but for the fifth string of a 5-string banjo it is 5.
DEBUG This is either `T' (if you want the output of a `debug' file from the `musictab' program), or `F' (it you don't). The debug file indicates how well the program has converted CNM into TN.
DEBUG_FILE The name of the debug file (conventionally `textab.deb')
YOU SHOULDN'T NEED TO CHANGE THE FOLLOWING KEYWORDS:
COST_FRET_STRING A measure of how much you don't like fretting each string, starting from the lowest
DEL_FRET_SCALE A measure of how hard it is to stretch between different frets
MAX_NOTE_SEP A measure of the time separation between notes
ULT_COST A large number, to stop the `musictab' program allocating two notes on the same string at the same time
COST_SAME_STRING A measure of how much you don't like playing the same string in sequence
TAU_SUST A measure of the sustain of a note
TAU_HAND A measure of how fast you can move your hand
TEMP_FAC A measure of how fast the `temperature' is reduced in the simulated annealing algorithm
TEMP_START The starting `temperature' for the simulated annealing algorithm
N_STEP A computational constant used in the simulated annealing algorithm
N_LOOP Ditto
N_RED Ditto
N_NO_RED Ditto
AND NOW FOR THE TUNE:
TABLATURE To be followed by the tune in Tablature Notation (TN)
MUSIC To be followed by the tune in Conventional Music Notation (CMN)

Note the comments at the end of each line of tablature, separated from the main code by an exclamation mark (`!').

The Programs

All the programs read in a single input file (an appropriate Parameter File) and generally produce a single output file. In addition, `musictab' may output a `debug' file.

The following table show the input and output for each program:

PROGRAM INPUT OUTPUT
tabmusic Parameter File containing tune in TN Parameter File containing tune in CMN
musictab Parameter File containing tune in CMN Parameter File containing tune in TN
showtab Parameter File containing tune in TN PostScript file of tablature, suitable for printing

The programs should run under Windows. To run a program, click on the program filename (e.g. `tabmusic') (which will open a dialogue box) and reply with the name of the parameter file (e.g. `foggy.tab') when prompted.

Please note that the program `musictab' may take quite a time, especially for a few pages of music.

If you are interested in numerical algorithms, the `musictab' program uses the method of `simulated annealing' (for a good description, read the book `Numerical Recipes').

Error Messages

The programs may give out error messages if you enter data incorrectly. Error messages are in the form:

ifail returned as 22 at error point 2 ..... program terminated

The number after `error point' (in this case `2') gives a clue as to where you went wrong. The following tables give you an idea of where to look if you get an error message.

Program `tabmusic'

Error point Where to look
1 Input filename
2 Input file, which does not open
3 Keyword `OUTPUT_FILE'
4 Output file, which does not open
5 Keyword `N_STRING'
6 Keyword `TUNING'
7 Notes defined for `TUNING'
8 Keyword `OFFSET'
9 Numbers defined for `OFFSET'
10 Keyword `TABLATURE'
11 An error within the tablature
12 An invalid note within the tablature

Program `musictab'

Error point Where to look
1 Input filename
2 Input file, which does not open
3 Keyword `OUTPUT_FILE'
4 Output file, which does not open
5 Keyword `N_STRING'
6 Keyword `MAX_FRET'
7 Keyword `TIME_SIGNATURE'
8 Numbers defined for `TIME_SIGNATURE'
9 Keyword `TUNING'
10 Notes defined for `TUNING'
11 Notes defined for `TUNING'
12 Keyword `OFFSET'
13 Numbers defined for `OFFSET'
14 Keyword `DEBUG'
15 Letter (`T' or `F') defined for `DEBUG'
16 Keyword `DEBUG_FILE'
17 Debug filename, which does not open
18 Keyword `COST_FRET_STRING'
19 Numbers defined for `COST_FRET_STRING'
20 Keyword `DEL_FRET_SCALE'
21 Keyword `MAX_NOTE_SEP'
22 Keyword `ULT_COST'
23 Keyword `COST_SAME_STRING'
24 Keyword `TAU_SUST'
25 Keyword `TAU_HAND'
26 Keyword `TEMP_FAC'
27 Keyword `TEMP_START'
28 Keyword `N_STEP'
29 Keyword `N_LOOP'
30 Keyword `N_RED'
31 Keyword `N_NO_RED'
32 Keyword `MUSIC'
33 An error within the music
34 Start of a slide, hammer push or pull connector
35 End of a slide, hammer push or pull connector
36 Length of a note within the music
37 An invalid note within the music
38 An error within the music
39 An error within the music
40 Something between the start of the parameter file and the keyword `MUSIC'
41 An error within the music

Program `showtab'

Error point Where to look
1 Input filename
2 Input file which does not open
3 Keyword `OUTPUT_FILE'
4 Output file, which does not open
5 Keyword `N_STRING'
6 Keyword `LINE_OFF'
7 Keyword `STAVE_OFF'
8 Keyword `NOTE_OFF'
9 Keyword `BAR_OFF'
10 Keyword `TITLE_OFF'
11 Keyword `PAGE_WIDTH'
12 Keyword `PAGE_LENGTH'
13 Keyword `LEFT_MARGIN'
14 Keyword `RIGHT_MARGIN'
15 Keyword `TOP_MARGIN'
16 Keyword `BOTTOM_MARGIN'
17 Keyword `N_TITLE'
18 Text following `N_TITLE'
19 Size of text following `N_TITLE'
20 Keyword `TIME_SIGNATURE'
21 Keyword `TIME_SIGNATURE'
22 Keyword `TABLATURE'
23 An error within the tablature
24 The length of the tablature (up to 10000 characters are allowed)
25 -
26 -
27 -
28 The length of the tablature (up to 998 bars are allowed)
29 -
30 -
31 -
32 -
33 -
34 -
35 Missing end to a slide, hammer push or pull connector
36 -
37 Length of a note within the tablature
38 String or fret number of a single note
39 String or fret number, or length, of a single note
40 String or fret number of a double note
41 String or fret number of a double note
42 String or fret number, or length, of a double note
43 Missing end to a slide, hammer push or pull connector after a double note
44 -
45 Missing double quote (") at end of text
46 Subscript or superscript in text

Software

You may copy the TexTab programs and appropriate demonstration files. Unfortunately, the way in which browsers transfer text and binary files is not always well defined, so I have resorted to a rather ugly (but safe) method of naming the files. My convention is as follows:

After you have downloaded the files, you will need to change the names as indicated. Note that, with Netscape, you will need to press <shift> (or some similar button) when you select a file.

The TexTab software is provided in two forms:

As PC Object Code:

These programs should run under Windows. The following files are available:

As Obfuscated Fortran Source Code:

This source code is written in Fortran-77, with some common language extensions. It has been `obfuscated' so that you will find it difficult to modify! The following files are available:

Also, a demonstration of `Foggy Mountain Breakdown' is available in both CMN and TN:



Return to the TexTab Home Page or contact John Hunter for help or further information.