Generating guitar tabs? Write the shortest program that generates guitar tabs for the chords given as input.

So that the guitarists among you don't have an advantage, and to make it deterministic (and probably easier to code), here are the only forms of the chords authorized:

Major chords:

  E   F   F#  G   G#  A   A#  B   C   C#  D   D#
e 0---1---2---3---4---0---1---2---3---4---5---6---
B 0---1---2---3---4---2---3---4---5---6---7---8---
G 1---2---3---4---5---2---3---4---5---6---7---8---
D 2---3---4---5---6---2---3---4---5---6---7---8---
A 2---3---4---5---6---0---1---2---3---4---5---6---
E 0---1---2---3---4---0---1---2---3---4---5---6---

Minor chords:

  Em  Fm  F#m Gm  G#m Am  A#m Bm  Cm  C#m Dm  D#m
e 0---1---2---3---4---0---1---2---3---4---5---6---
B 0---1---2---3---4---1---2---3---4---5---6---7---
G 0---1---2---3---4---2---3---4---5---6---7---8---
D 2---3---4---5---6---2---3---4---5---6---7---8---
A 2---3---4---5---6---0---1---2---3---4---5---6---
E 0---1---2---3---4---0---1---2---3---4---5---6---


Note that the 5 first chords and the 7 last chords of each series have different forms.

All the chords are simple major or minor chords (no 7th or other variations).

You should take care of flats too. Reminder:

A# = Bb
C# = Db
D# = Eb
F# = Gb
G# = Ab

B#, Cb, E# and Fb are not used


Output must include the first column with the cord names, as shown above. It does not have to include the chord name on top. Chords must be separated by 3 - as shown above. The final 3 - are optional.

Input is a string consisting of chord names, separated by spaces.

An example input is:

Bm Gb A E G D Em F#


and the corresponding output is:

e 2---2---0---0---3---5---0---2---
B 3---2---2---0---3---7---0---2---
G 4---3---2---1---4---7---0---3---
D 4---4---2---2---5---7---2---4---
A 2---4---0---2---5---5---2---4---
E 2---2---0---0---3---5---0---2---
JavaScript, 297 277 262 235 223 chars

No carriage returns in the golfed version are significant; they are there only to make the answer readable. Semicolons are significant.

Edit: Replaced the outer map with a while loop and other edits. Finally inside of 2&times; the size of the Golfscript version (for now)!

Edit: Replaced the indexOf with math, broke down the lookup table, other small improvements.

Edit: Another map to for and put in a final \n I had been unnecessarily eating. Finally inside of Jules's Python version.



i=prompt(o='').split(' ');for(r=6;o+=' EADGBe'[r]+' ',r--;o+='\n')
for(j=0;n=i[j++];o+=(([84,13,52,5][2*/m/.test(n)+x]*8&gt;&gt;2*r&amp;3)+y-7*x)+'---')
y=n.charCodeAt(0),y=(2*y-(y&gt;66)-(y&gt;69)+(n[1]&lt;'$')-(n[1]=='b')+2)%12,x=y&gt;6;alert(o)


Output no longer takes advantage of the trailing --- being optional as:

e 2---2---0---0---3---5---0---2---
B 3---2---2---0---3---7---0---2---
G 4---3---2---1---4---7---0---3---
D 4---4---2---2---5---7---2---4---
A 2---4---0---2---5---5---2---4---
E 2---2---0---0---3---5---0---2---