Thursday, 19 November 2015

Optimising MIDI-based guitar tablature

Creating guitar tablature from MIDI files is great. But sometimes the results are less than optimal. For example, you might be playing a lead riff high up the guitar neck, when suddenly the MIDI-derived tab puts you back down on the first or seconds frets, mixing it up with some nasty open strings. Open strings when playing licks is seriously uncool! (unless you're playing rockabilly, in which case it's double-awesome).

Here's how our MIDI-to-tablature routines are drawing some chords from the tune "Need Your Love So Bad". Nothing fancy or clever, just some simple triads.


The first chord is the higher notes of a regular A major "open" chord.


(the full A major chord is shown, and the notes displayed in our midi-derived tab appear in red)

Similarly just by looking at the derived tab, we can also see the "higher" end of a regular D major chord, with the frets 2-3-2 held on the high E, B and G strings. But what if playing the open A chord isn't convenient? Wouldn't it be great if we could move these notes and put them on other frets (while maintaining their musical pitch values?)

A bit of javascript later, and that's exactly what we've got!
Basically, when you click on a number in the tab, the javascript looks at the fret number and tries to add five (four if the note is on the B string). If this sum total is less than 21 (the maximum number of frets on our guitar) it puts the note on the next lower string, and increases the fret value by five (or four if jumping from the B to the G string).

This means that our A chord can also appear like this:


Here we can see that the 5-6-7 variation of the A major chord is simply the "middle" of a barre chord at the fifth fret:


Likewise, where we've been clicking about with some of the D major chords on the next line, we can see that 2-3-2 becomes 2+5 = 7 and 3+4 = 7 and 2+5 = 7. As it turns out, this is the middle-finger barre on an A-shape barre chord at the 5th fret - exactly where you'll find your A-shape D major chord!


And when we take these values one string lower, we get 7+5 = 12 and 7+5 = 12 and 7+4 (since we've moving off the B string to the G string) = 11.

And when we plot these onto a guitar neck, we can see we're looking at an E-shape barre chord at the 10th fret - another well-known place where you'll find a D major chord!


So not only have we successfully parsed a MIDI file and been able to place all the "on notes" on the correct frets/strings on our guitar tablature, we've also got a really easy way of allowing players to choose alternative positions/finger placements for each note - either individually, or shift all of the notes to move an entire chord into a new shape.

Very exciting stuff!

No comments:

Post a Comment