Home

Awesome

tbon

Typographic Beat-Oriented Notation for music

Tbon aims to be the fastest way to enter pitches, rhythms, meter and dynamic levels from a computer keyboard.

Tbon is a musical language I developed for my own use about a decade ago. It's a quick notation shorthand for writing melodies -- by hand or with a computer keyboard -- that also aims to be 'readable' in the sense that it's possible to play from it by sight.

Tbon borrows ideas from Lilypond, ABC, and music21's TinyNotation. What makes it different is that it's never necessary to explicity specify a note duration (e.g. 1/2, 1/4) or a meter (e.g. 4/4, 6/8, etc). Beats are groups of notes separated by whitespace.

Tbon produces MIDI files with tempo, key, and meter changes correctly specified. So far, I've verified that the files can be imported to:

Any DAW or notation program that correctly reads MIDI files should be able to import, play, and edit the files produced by Tbon. (Note: Garage Band does not support changes of meter in imported MIDI files. I don't recommend it.)

This repo is very much alpha software. That being said, the parser and evaluator are passing all tests and it's possible to write melodies and convert them to midi files quite easily. Moreover, I don't anticipate making any breaking changes to the language at this point (I've been tinkering with the design for ten years now so it feels pretty much final in terms of basic syntax and capabilities).

Live Demo

You can try tbon without installing anything. There's a demo server that's running at (http://ellisgrant.pythonanywhere.com) but do skip down and skim the Tutorial section of this page beforehand. The demo works best on a computer with a physical keyboard. Your smartphone's virtual keyboard layout and autocorrection will make it a frustrating experience.

If you decide you'd like to install and run tbon on your own computer, see the Local Installation section of this README.

Acknowledgments

Tbon's niche in the music software ecosytem

There are dozens of great (and not-so-great) music software programs available. I mentioned a few I use regularly in the introduction at the top of this README. Some specialize in typesetting -- the creation of printed music notation -- while others, usually known as DAWs (Digital Audio Workstations), focus on editing and mixing recorded MIDI and audio.

Tbon is intended as a front-end for either category. Its strength is easy entry and editing of pitches, rhythms and dynamics with a simple and clean syntax that covers the broadest possible range of notatable music. Much of the simplicity comes from a design decision to favor quickly getting to output you can hear without worrying about what printed notes will represent the music.

Here are some ways I'm using Tbon.

For learning music: I sing baritone in several different choral groups. Some the works we perform are quite complex with time signatures that change every measure and frequent shifts of tonality. Like many choristers, I'm musically knowledgable but I don't play piano accurately (at least not without a lot of practice on any given passage). I use Tbon to quickly create accurate midi files of parts I need to learn with proper tempi and dynamics.

For my own use, midi playback is usually all that's needed. For files I share with others, I usually improve the sound by importing the midi files into a DAW (Reaper) and output an mp3 rendered through a sampled grand piano synth. Using a DAW also permits fine-scale editing for special articulations e.g szforando, subito piano etc. (For simplicity, Tbon ignores the possibility of tempo and dynamic changes at durations smaller than an entire beat.)

For ear training: In my experience, the most valuable ear training is learning to hear and write out the pitches and rhythms of real music. Tbon's numeric relative pitch option (1, 2, 3, ... == do, re, mi ...) is expressly included for that purpose. For a good video discussion of the merits of relative pitch ear training, see this video by music educator Julian Bradley.

For composition: I first developed Tbon as a pencil-and-paper notation for quickly writing down melodic ideas anywhere on any available scrap of paper. It's still useful in that way. In implementing it as a computer language, I've extended it to make it possible to write out music in multiple polyphonic parts. (Now if I can only manage to spend less time developing and documenting Tbon, I might actually find time to write some more music :-)

I'm not a music teacher so I can't say I'm using Tbon for teaching music but I do believe a musically inclined child could grasp the basics in a very short time.

Tutorial

Let's begin with a couple of familiar tunes that illustrate the majority of tbon's notation syntax.

  K=F
  z - cc | d c f  | e - cc | d c ^g | f - cc |
  ^c a f | e d ^bb | a f g  | f - - |

Happy Birthday score

<tiny>Except where otherwise noted, musical images in this document were created by importing tbon midi files directly into MuseScore 2.1 without further editing.</tiny>

If you've used other text-based note entry systems, this should look somewhat familiar. You've probably guessed that the K=F in the first line tells tbon that the pitches should be interpreted as being in F major, i.e. that 'b' is flatted unless modified by an accidental.

Now look at the first measure, z - cc |. You've just met the 4 most important symbols in tbon.

We use z for rests. By itself, the z indicates that the first beat is silent.

The next symbol is a dash (-, keyboard 'minus'). Dashes extend the preceding note or rest. In this case it comes after a rest, meaning that beat two of this measure is also silent. (Note: We could have written Beats 1 and 2 as z z and produced the same music)

Beat 3 of the first measure is cc. It represents a pair of 'c' notes, each lasting half the beat. That's a really important principle in tbon: When notes or rests or dashes appear together without spaces between them, they divide one beat into equal parts. So if the beat is a quarter-note, cc represents two eighth-notes.

Similarly, ccc would be a triplet beat, cccc four sixteenths, ccccc a quintuplet and so on. Want to divide a beat into notes of different length? No problem, just use dashes. Here's a dotted-eighth + sixteenth division: c--c. The first 'c' gets 3/4 of the beat and the second one gets the remaining 1/4 of the beat.

Ok, back to Happy Birthday. As you might guess, measures are separated by barlines (the | symbol). When Tbon sees one of those, it counts the beats in the measure and inserts a time-signature at the beginning of the measure. Our first measure has 3 beats and Tbon assumes a quarter-note beat unless you indicate otherwise, so our first measure is in 3/4 time.

If you look ahead you'll see that all the remaining measures also have 3 beats. Tbon won't insert unneeded time signatures in those measures.

There's one more new symbol in measures 4, 6 and 7. It's an octave mark, ^. Until the fourth measure, all the pitches in the melody have been within a musical 4th of the preceeding pitch. Now the melody needs to leap up by a 5th from c to g. Without the ^ octave mark, tbon would have pitched the g a 4th below the c.

We'll meet the downward octave mark, /, in our next example melody.

The first line, K=C B=4. tells tbon that the key is C major and that the beat note, B=4. is a dotted quarter-note. This tune is in 6/8 time. Musicians call 6/8, 9/8, etc compound meters, meaning that the beat is a multiple of the duration given in the time signature's denominator.

The second line, /* I like to be in America ... */, is a comment. It has no effect on the music tbon produces. (C programmers will recognize the syntax. For everyone else, just know that anything you enclose between /* and */ is a comment.)

Let's look at the 1st measure, ^555 111 |. The up octave mark is familiar, but what's with those numbers? They're tbon's other pitch format. The numbers are what musicians call diatonic scale degrees, which for our example is an overblown way of saying "1 is c, 2 is d, 3 is e, 4 is f, 5 is g, 6 is a, 7 is b." But it's really more than that because tbon takes the key signature into account when deciding which number matches which note name. If we changed K=C to K=E, 1 would be 'e', 2 #f, 3 #g, and so on.

The very first note in our example, ^5, is the fifth note of the C major scale, g. We need the octave mark because tbon assigns the pitch of the first note in a tune by assuming it was preceded by Middle C and we want the g in this melody to be the note above.

Before moving on to measure 2, notice that there are 2 beats in measure 1 and each is divided in to 3 parts. Tbon will notice the 2 beats and the dotted-quarter beat note (B=4.) and insert a 6/8 time signature.

Now look at measure two, 6-4 -1- |. Mr. Bernstein used a rhythmic pattern that's common in Latin American music, "3 against 2", by breaking the two beats of 6/8 into 3 notes of equal length as if the meter had changed from 6/8 to 3/4. (in fact we could have notated that second measure as B=4 6 4 1 | and tbon would have inserted the 3/4 signature.)

Measure two shows how to handle triplets that span 2 beats. That happens frequently in music and it's worthwhile to see how it works. To split two beats into 3 parts, start by splitting each beat into 3 parts. Then give each note two of those parts so that the note in the middle spans from the end of the first beat into the start of the second. The same logic can be applied to more difficult cases, e.g, splitting 3 beats into a quintuplet: 1--2- -3--4 --5--.

We've not yet encountered sharps, flats, and naturals (aka accidentals) so look at measure 4. The @ before the 7 and the 3 means to flat them. Tbon follows the conventions of printed music: Accidentals are put before the note and they persist for the remainder of the measure. So all the 7's and all the 3's in measure four are flatted.

The symbols for sharp and natural are # and %.

Lastly, as promised in first example, we see the down octave mark on the c in the last measure to force the leap down from the high 'e' above.

Here endeth the tutorial. The notation reference below contains the fine print and more illustrations of the concepts we've just covered plus some other considerations that include tempo, volume, downbeat emphasis and MIDI Channel. The extended notation section explains how to write chords and multiple voices. (tbon is quite capable of representing an entire symphony score).

Notation Reference

Basic notation

Beats

are groups of pitches, rests and holds followed by whitespace.

Meter

is determined by the number of beats between barlines ('|')

Pitch names

are represented by a b c d e f g.

Dash -

continues notes and rests within and across beats (i.e. a tie). The tbon documentation sometimes refers to dashes as "holds."

Rests

are indicated by letter z or underscore _.

Note durations

tbon can represent any rhythm that can be represented in conventional music notation.

Accidentals

Sharps,flats and naturals are '#', '@' and '%' respectively.

Octave marks

Pitches move up or down using the Lilypond relative pitch entry convention.

Beat Note

Tempo

Key Signatures

Velocity (Loudness)

De-emphasis

controls the amount of emphasis given to the downbeat. It's specified as the amount of de-emphasis applied to the other beats in the measure to make the math cleaner. A little de-emphasis will bring out the meter and make the output sound more musical.

Comments

 /* 
 This is a comment that
 spans three lines and that, 
 my friends, is perfectly fine. 
 */
 1 2 3 - | /* comment between bars */ 1 2 3 - |
 /* Coment at end of file */

Extended Notation

With the basic notation you can quickly write any single voice melody no matter how complex the rhythm. That's quite a lot for only a handful of symbols. Continue reading to learn how to write chords, ornaments, percussion and multiple voices with different instrument sounds.

Chords

Polyphony

In the chord examples above, all the notes in each chord end when the next chord or note begins. But sometimes, we want to sustain notes into the the next chord. In tbon, this is accomplished with the 'hold' symbol '-'. Within a chord, the hold symbol means 'sustain the corresponding note from the previous chord'.

By adding holds in the 'oompah' example from the preceding section, we can make the bass notes continuous, like so:

You may use rests within chords to stop one or more voices while sustaining others.

Rolls and Ornaments

Multiple Voices

Use the partswitch, P=n to write music in multiple parts.

Channel

By default, tbon assigns MIDI channel number 1 to all notes in all parts. You can explicitly assign different channel numbers. The most common reasons for changing the channel number is to specify a different instrument sound or to write percussion.

Percussion

Instruments

You may conveniently specify the instrument for each part using the numbering scheme from the General Midi GM 1 Sound Set. GM 1 provides for 128 different instrument sounds.

  /* Duet */

  /* Flute (GM 74) */
  P=1 C=1 I=74 c d e f | g a g - |  a g f e | d -  - -  | c d c - |
  /* Nylon string guitar (GM 25) */
  P=2 C=2 I=25 a g f e | d - b c | ^c d c g | a g fe d  | c - - - |

Local Installation

There's no installer at present so if you want to run tbon on your own computer, you'll need to clone this repository or copy the files. Installing tbon locally provides some advantages over the Live Demo site. You can

Dependencies

Quick Start

Begin by building the examples. Assuming you've cloned into ~/tbon do the following:

cd ~/tbon
./tbon.py examples/*.tb*

Tbon will process the notation source files in the examples directory and create MIDI files you can play or import into your favorite notation editor or DAW.

You can create your own input files with a text editor using the syntax described below. I suggest making a symbolic link from somewhere in your path to ~/tbon.py so you can save your work outside the repo.

To dive deeper, look at parser.py and test_parser.py.

Command line

The top level executable is tbon.py. As I mentioned earlier it's useful to make a symbolic link to it somewhere in your path. For example, I did ln -s ~/tbon.py ~/bin/tbon so I can type tbon from any directory to process input files. Here's the help available by typing tbon -h.

$ tbon -h
usage: tbon [-h] [-b FIRSTBAR] [-q] [-v]
            filename [filename ...]

positional arguments:
  filename              one or more files of tbon notation

optional arguments:
  -h, --help            show this help message and exit
  -b FIRSTBAR, --firstbar FIRSTBAR
                        The measure number of the first measure. (Used to
                        align beat map output)
  -q, --quiet           Don't print the input file and bar map to stdout.
  -v, --verbose         dump the MidiEvaluator output to stdout

File extensions

Beat maps

 $ tbon examples/minorscale.tbn
 Processing examples/minorscale.tbn
 /* Melodic minor scale */
 /* Written first in C major, then in c minor */
 K=C 12 @34 56 71 | 1@7 @65 4@3 21 |
 K=c 12 34 5%6 %71 | 17 65 43 21 |

 Beat Map: Number of beats in each bar
 0:    4    4    4    4
 Created examples/minorscale.mid
Beat Map: Number of beats in each bar
10:                   4    4    4    4

Contributing

All suggestions and questions are welcome. I'd especially welcome help putting together a good setup.py to make it easy to put tbon on PyPi. As this is my first serious attempt at writing a parser, I'd also welcome suggestions for improving what I presently have (though it seems to be working rather well at the moment). See the issues section for more ideas.

Oh, and one more thing ...

I'd love to be able to include clickable links to MIDI files for the examples but GitHub doesn't support linking to them in comments and README files. They tell me that hearing requests from more people would increase the chance they'll get around to adding MIDI files to the many filetypes they already support. So please send a note to support@github.com asking them to make it so. Thanks!