#!/usr/bin/perl
#---------------------------------------------------------------------------
# chord2html.pl - A Perl script to convert CHORD input files to HTML
# Copyright (C) 1998,2002 Claudio Matsuoka <claudio@helllabs.org>
#
# Lyrics only mode and meta data by Per Egil Kummervold <peregil@abex.no>
# HTML and CSS fixes by Erwin Burgstaller <i@wuell.net>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#---------------------------------------------------------------------------

use GD;
use Getopt::Std;

getopts ('d:hlno:qs:T:tVv');

# Defaults
chomp($date = `date`);
$version = "1.3";
$bg_color = "white";
$format = $opt_T || "png";
$color = "color=\"blue\"";
$style = $opt_s || "/usr/local/share/chord2html/chord2html.css";
$me = $0;

$opt_q && ($opt_v = 0);

if ($opt_V) {
    print STDERR "chord2html $version\n";
    exit 0;
}

if ($opt_h) {
    print STDERR <<EOF;
chord2html $version
Copyright (C) 1998,2002 Claudio Matsuoka <claudio\@helllabs.org>,
(C) 2002 Per Egil Kummervold <peregil\@abex.no>, (C) 2002 Erwin
Burgstaller <ber\@aon.at>

Usage: $me [options] input_file 
Options:
    -d dirname  Create images in the given directory (default is current)
    -h          Print a summary of the command line options
    -l          Print lyrics only
    -n          Don\'t overwrite chord images that already exist
    -o name     Write output to file (default is stdout)
    -q          Quiet mode (turn off warnings)
    -s filename Style sheet name (default is $style)
    -T format   Image format for generated chord grids (default is $format)
    -t          Add timestamp at the end of the generated page
    -V          Print version number
    -v          Verbose mode

This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.

This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
EOF
    exit 0;
}

$opt_o && (open (STDOUT, ">$opt_o") || die "$me: Can't create $opt_o\n");

if ($opt_d) {
    if (opendir TESTDIR, $opt_d) {
	closedir TESTDIR;
    } else {
	mkdir ($opt_d, 0755) || die "$me: Can't create directory $opt_d\n";
    }
    ($opt_d =~ m,/$,) || ($opt_d .= "/");
}


learn_chords ();

my $space = 1;		# Initialize as 1 to remove garbage before {t: }
my $line = 0;
my %header;

# Parse input file
while (<>) {
    $line++;
    s/^\s*#.*//;	# Clean up comments

    if (/{eot}/) { $tab = 0; %opt_l && next; print "\n</pre>\n"; next; }
    $opt_l && $tab && next;
    $tab && goto done;

    if (/{t:(.*)}/ || /{title:(.*)}/) {
	$opt_v && print STDERR "Title: $1\n";
	$header{'title'} = $1;
	next;
    }

    if (/{st:(.*)}/ || /{subtitle:(.*)}/) {
	$opt_v && print STDERR "Subtitle: $1\n";
	$header{'subtitle'} = $1;
	next;
    }

    if (%header) {
	do_header (\%header);
	%header = ();
    }

    # Print lyrics only if -l is used
    if ($opt_l) { 
	m!{c[ib]?:(.*)}! && next;
	m!{comment\w*:(.*)}! && next;
    } else {
	s!{c[ib]?:(.*)}!<h3>$1</h3>! && goto done;
	s!{comment\w*:(.*)}!<p class="comment">$1</p>! && goto done;
    }

    # Handle chord definition in old & new formats

    if (/{define:\s*([^\s]+) (\w) (\w) (\w) (\w) (\w) (\w) (\w)}/) {
	$opt_v && print STDERR "Chord $8$7$6$5$4$3:$2: $1 (old format)\n";
	$chord{$1} = [ "$8$7$6$5$4$3", $2 ];
	next;
    }

    if (/{define\s*([^\s]+) base-fret (.) frets (.) (.) (.) (.) (.) (.)}/) {
	$opt_v && print STDERR "Chord $8$7$6$5$4$3:$2: $1\n";
	$chord{$1} = [ "$8$7$6$5$4$3", $2 ];
	next;
    }

    if (/{sot}/) { $tab = 1; $opt_l && next; print "\n<pre>\n"; next; }

    s!{soc}!\n<div class="chorus">\n! && goto done;
    s!{eoc}!\n</div>\n! && goto done;

    if (/^\s*{(.*)}\s*$/) {
	$opt_q || print STDERR "Warning: $line: unknown directive {$1}\n";
	next;
    }
 
    if (!$space && s!^\s*$!\n<p>\n!) {
	$space = 1;
	goto done;
    }

    /^\s*$/ && next;
    $space = 0;

    # Lyrics only mode
    if ($opt_l) {
	s!\[[^\]]+\]!!g;
	goto done;
    }

    # Extract chords
    @c = /\[([^\]]+)\]/g;
    s!\[[^\]]+\]\s\s+!<td> &nbsp; &nbsp; &nbsp; &nbsp; !g;
    s!\[[^\]]+\]\s+!<td> &nbsp; &nbsp; !g;
    s!\[[^\]]+\]!<td>!g;
    s! <td>!&nbsp;<td>!g;

    print "<table cellspacing=0 cellpadding=0 border=0><tr>\n";
    $td = ""; unless (/^\s*\[/) { print $td = "<td>\n"; }
    foreach $i (@c) {
	$h{$i} = 1;
	print "<td class=\"chord\">$i</td>\n";
    }
    print "<tr>\n$td$_</tr></table>\n\n";

    next;

done:
    print;
    $space = 0;
    $opt_l && print "<br>";
}


unless ($opt_l) {
    # Display chord grids
    
    print "<div class=\"grids\">\n";
    foreach $i (keys (%h)) {
        unless ($chord{$i}) {
	    $opt_q || print STDERR "Warning: unknown chord '$i'\n";
	    next;
        }
        $_ = "chord_$chord{$i}[0]_$chord{$i}[1].$format";
        print "<img alt=\"$i\" src=\"$opt_d$_\"> \n";
        build_chord ($i, $_);
    }
    print "</div>\n";
}


if ($opt_t) {
	print <<EOF;
<br>
<div class="timestamp">
Generated with chord2html $version, $date.
</div>
EOF
}

print <<EOF;
</body>
</html>
EOF

#---------------------------------------------------------------------------
# Create html header
#---------------------------------------------------------------------------

sub do_header {
    $header_done && return;

    my $t = shift;
    print <<EOF;
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <title>$$t{title}</title>
  <meta name="generator" content="chord2html $version">
  <meta name="description" content="$$t{subtitle}">
  <meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
  <link rel="StyleSheet" href="$style" type="text/css">
</head>
<body bgcolor="$bg_color">
EOF

    $opt_l || print "<h1>$$t{title}</h1>\n<h2>$$t{subtitle}</h2>\n";

    $header_done = 1;
}

#---------------------------------------------------------------------------
# Create PNG image of chord using GD
#---------------------------------------------------------------------------

sub build_chord {
    my $c = shift;
    my $image = shift;
    my $s = $chord{$c}[0]; 
    my $f = $chord{$c}[1]; 

    if ($opt_n && -f "${opt_d}$image") {
	$opt_v && print STDERR "chord image $s:$f already exists -- skipping\n";
	return;
    }

    my $im = new GD::Image (64, 64);
    my $white = $im->colorAllocate (0xff, 0xff, 0xff);
    my $black = $im->colorAllocate (0, 0, 0);
    my $h = gdLargeFont->height + 7;
    my $i;

    $im->transparent ($white);
    $im->interlaced (0);
    $im->string (gdSmallFont, 12, 0, $c, $black);
    ($f != 1) && $im->string (gdSmallFont, 0, $h, $f, $black);

    for ($i = 0; $i < 6; $i++) {
	my $c = substr ($s, $i, 1);
	if ($c =~ m/[NnXx-]/) {
	    $im->line (10 + $i * 8, $h - 7, 14 + $i * 8, $h - 3, $black);
	    $im->line (14 + $i * 8, $h - 7, 10 + $i * 8, $h - 3, $black);
	} elsif ($c =~ m/[1234]/) {
	    $im->arc (12 + $i * 8, $h + $c * 10 - 5, 5, 6, 0, 360, $black);
	    $im->fill (12 + $i * 8, $h + $c * 10 - 5, $black);
	} elsif ($c =~ m/0/) {
	    $im->arc (12 + $i * 8, $h - 5, 6, 6, 0, 360, $black);
	}
    }

    for ($i = 12; $i < 60; $i += 8) {
	$im->line ($i, $h, $i, 64, $black);
    }

    for ($i = $h; $i <= 64; $i += 10) {
	$im->line (12, $i, 52, $i, $black);
    }

    $opt_v && print STDERR "Creating chord image $s:$f > $opt_d$image\n";

    open FILE, ">$opt_d$image";
    binmode FILE;
    if ($format eq "png") {
	print FILE $im->png;
    } elsif ($format eq "gif") {
	print FILE $im->gif;
    } else {
	die "Unknown image format: $format\n";
    }
    close FILE;
}

#---------------------------------------------------------------------------
# Chord definitions from CHORD 3.5
# CHORD is Copyright (C) 1991-1993 by Martin Leclerc & Mario Dorion
#---------------------------------------------------------------------------

sub learn_chords {
    %chord = (
	"Ab"		=> [ "133211", 4 ],
	"Ab+"		=> [ "NN2110", 1 ],
	"Ab4"		=> [ "NN1124", 1 ],
	"Ab7"		=> [ "NN1112", 1 ],
	"Ab11"		=> [ "131311", 4 ],
	"Absus"		=> [ "NN1124", 1 ],
	"Absus4"	=> [ "NN1124", 1 ],
	"Abdim"		=> [ "NN0101", 1 ],
	"Abmaj"		=> [ "133211", 4 ],
	"Abmaj7"	=> [ "NN1113", 1 ],
	"Abmin"		=> [ "133111", 4 ],
	"Abm"		=> [ "133111", 4 ],
	"Abm7"		=> [ "NN1111", 4 ],
	"A"		=> [ "N02220", 1 ],
	"A+"		=> [ "N03221", 1 ],
	"A4"		=> [ "002200", 1 ],
	"A6"		=> [ "NN2222", 1 ],
	"A7"		=> [ "N02020", 1 ],
	"A7+"		=> [ "NN3221", 1 ],
	"A7(9+)"	=> [ "N22223", 1 ],
	"A9"		=> [ "N02100", 1 ],
	"A11"		=> [ "N42433", 1 ],
	"A13"		=> [ "N01231", 5 ],
	"A7sus4"	=> [ "002030", 1 ],
	"A9sus"		=> [ "N02100", 1 ],
	"Asus"		=> [ "NN2230", 1 ],
	"Asus2"		=> [ "002200", 1 ],
	"Asus4"		=> [ "NN2230", 1 ],
	"Adim"		=> [ "NN1212", 1 ],
	"Amaj"		=> [ "N02220", 1 ],
	"Amaj7"		=> [ "N02120", 1 ],
	"Adim"		=> [ "NN1212", 1 ],
	"Amin"		=> [ "N02210", 1 ],
	"A/D"		=> [ "NN0022", 1 ],
	"A/F#"		=> [ "202220", 1 ],
	"A/G#"		=> [ "402220", 1 ],
	"Am"		=> [ "N02210", 1 ],
	"Am#7"		=> [ "NN2110", 1 ],
	"Am(7#)"	=> [ "N02214", 1 ],
	"Am6"		=> [ "N02212", 1 ],
	"Am7"		=> [ "N02213", 1 ],
	"Am7sus4"	=> [ "000030", 1 ],
	"Am9"		=> [ "N01113", 5 ],
	"Am/G"		=> [ "302210", 1 ],
	"Amadd9"	=> [ "022210", 1 ],
	"Am(add9)"	=> [ "022210", 1 ],
	"A#"		=> [ "N13331", 1 ],
	"A#+"		=> [ "NN0332", 1 ],
	"A#4"		=> [ "NN3341", 1 ],
	"A#7"		=> [ "NN1112", 3 ],
	"A#sus"		=> [ "NN3341", 1 ],
	"A#sus4"	=> [ "NN3341", 1 ],
	"A#maj"		=> [ "N13331", 1 ],
	"A#maj7"	=> [ "N1323N", 1 ],
	"A#dim"		=> [ "NN2323", 1 ],
	"A#min"		=> [ "N13321", 1 ],
	"A#m"		=> [ "N13321", 1 ],
	"A#m7"		=> [ "N13121", 1 ],
	"Bb"		=> [ "N13331", 1 ],
	"Bb+"		=> [ "NN0332", 1 ],
	"Bb4"		=> [ "NN3341", 1 ],
	"Bb6"		=> [ "NN3333", 1 ],
	"Bb7"		=> [ "NN1112", 3 ],
	"Bb9"		=> [ "131213", 6 ],
	"Bb11"		=> [ "131341", 6 ],
	"Bbsus"		=> [ "NN3341", 1 ],
	"Bbsus4"	=> [ "NN3341", 1 ],
	"Bbmaj"		=> [ "N13331", 1 ],
	"Bbmaj7"	=> [ "N1323N", 1 ],
	"Bbdim"		=> [ "NN2323", 1 ],
	"Bbmin"		=> [ "N13321", 1 ],
	"Bbm"		=> [ "N13321", 1 ],
	"Bbm7"		=> [ "N13121", 1 ],
	"Bbm9"		=> [ "NNN113", 6 ],
	"B"		=> [ "N24442", 1 ],
	"B+"		=> [ "NN1004", 1 ],
	"B4"		=> [ "NN3341", 2 ],
	"B7"		=> [ "021202", 1 ],
	"B7+"		=> [ "N21203", 1 ],
	"B7+5"		=> [ "N21203", 1 ],
	"B7#9"		=> [ "N2123N", 1 ],
	"B7(#9)"	=> [ "N2123N", 1 ],
	"B9"		=> [ "131213", 7 ],
	"B11"		=> [ "133200", 7 ],
	"B11/13"	=> [ "N11113", 2 ],
	"B13"		=> [ "N21204", 1 ],
	"Bsus"		=> [ "NN3341", 2 ],
	"Bsus4"		=> [ "NN3341", 2 ],
	"Bmaj"		=> [ "N2434N", 1 ],
	"Bmaj7"		=> [ "N2434N", 1 ],
	"Bdim"		=> [ "NN0101", 1 ],
	"Bmin"		=> [ "N24432", 1 ],
	"B/F#"		=> [ "022200", 2 ],
	"BaddE"		=> [ "N24400", 1 ],
	"B(addE)"	=> [ "N24400", 1 ],
	"BaddE/F#"	=> [ "2N4400", 1 ],
	"Bm"		=> [ "N24432", 1 ],
	"Bm6"		=> [ "NN4434", 1 ],
	"Bm7"		=> [ "N13121", 2 ],
	"Bmmaj7"	=> [ "N1443N", 1 ],
	"Bm(maj7)"	=> [ "N1443N", 1 ],
	"Bmsus9"	=> [ "NN4422", 1 ],
	"Bm(sus9)"	=> [ "NN4422", 1 ],
	"Bm7b5"		=> [ "124231", 1 ],
	"C"		=> [ "N32010", 1 ],
	"C+"		=> [ "NN2110", 1 ],
	"C4"		=> [ "NN3013", 1 ],
	"C6"		=> [ "N02213", 1 ],
	"C7"		=> [ "032310", 1 ],
	"C9"		=> [ "131213", 8 ],
	"C9(11)"	=> [ "N3333N", 1 ],
	"C11"		=> [ "N13141", 3 ],
	"Csus"		=> [ "NN3013", 1 ],
	"Csus2"		=> [ "N3001N", 1 ],
	"Csus4"		=> [ "NN3013", 1 ],
	"Csus9"		=> [ "NN4124", 7 ],
	"Cmaj"		=> [ "032010", 1 ],
	"Cmaj7"		=> [ "N32000", 1 ],
	"Cmin"		=> [ "N13321", 3 ],
	"Cdim"		=> [ "NN1212", 1 ],
	"C/B"		=> [ "N22010", 1 ],
	"Cadd2/B"	=> [ "N20010", 1 ],
	"CaddD"		=> [ "N32030", 1 ],
	"C(addD)"	=> [ "N32030", 1 ],
	"Cadd9"		=> [ "N32030", 1 ],
	"C(add9)"	=> [ "N32030", 1 ],
	"Cm"		=> [ "N13321", 3 ],
	"Cm7"		=> [ "N13121", 3 ],
	"Cm11"		=> [ "N1314N", 3 ],
	"C#"		=> [ "NN3121", 1 ],
	"C#+"		=> [ "NN3221", 1 ],
	"C#4"		=> [ "NN3341", 4 ],
	"C#7"		=> [ "NN3424", 1 ],
	"C#7(b5)"	=> [ "N21212", 1 ],
	"C#sus"		=> [ "NN3341", 4 ],
	"C#sus4"	=> [ "NN3341", 4 ],
	"C#maj"		=> [ "N43111", 1 ],
	"C#maj7"	=> [ "N43111", 1 ],
	"C#dim"		=> [ "NN2323", 1 ],
	"C#min"		=> [ "NN2120", 1 ],
	"C#add9"	=> [ "N13311", 4 ],
	"C#(add9)"	=> [ "N13311", 4 ],
	"C#m"		=> [ "NN2120", 1 ],
	"C#m7"		=> [ "NN2424", 1 ],
	"Db"		=> [ "NN3121", 1 ],
	"Db+"		=> [ "NN3221", 1 ],
	"Db7"		=> [ "NN3424", 1 ],
	"Dbsus"		=> [ "NN3341", 4 ],
	"Dbsus4"	=> [ "NN3341", 4 ],
	"Dbmaj"		=> [ "NN3121", 1 ],
	"Dbmaj7"	=> [ "N43111", 1 ],
	"Dbdim"		=> [ "NN2323", 1 ],
	"Dbmin"		=> [ "NN2120", 1 ],
	"Dbm"		=> [ "NN2120", 1 ],
	"Dbm7"		=> [ "NN2424", 1 ],
	"D"		=> [ "NN0232", 1 ],
	"D+"		=> [ "NN0332", 1 ],
	"D4"		=> [ "NN0233", 1 ],
	"D6"		=> [ "N00202", 1 ],
	"D7"		=> [ "NN0212", 1 ],
	"D7#9"		=> [ "N21233", 4 ],
	"D7(#9)"	=> [ "N21233", 4 ],
	"D9"		=> [ "131213",10 ],
	"D11"		=> [ "300210", 1 ],
	"Dsus"		=> [ "NN0233", 1 ],
	"Dsus2"		=> [ "000230", 1 ],
	"Dsus4"		=> [ "NN0233", 1 ],
	"D7sus2"	=> [ "N00210", 1 ],
	"D7sus4"	=> [ "N00213", 1 ],
	"Dmaj"		=> [ "NN0232", 1 ],
	"Dmaj7"		=> [ "NN0222", 1 ],
	"Ddim"		=> [ "NN0101", 1 ],
	"Dmin"		=> [ "NN0231", 1 ],
	"D/A"		=> [ "N00232", 1 ],
	"D/B"		=> [ "N20232", 1 ],
	"D/C"		=> [ "N30232", 1 ],
	"D/C#"		=> [ "N40232", 1 ],
	"D/E"		=> [ "N1111N", 7 ],
	"D/G"		=> [ "3N0232", 1 ],
	"D5/E"		=> [ "0111NN", 7 ],
	"Dadd9"		=> [ "000232", 1 ],
	"D(add9)"	=> [ "000232", 1 ],
	"D9add6"	=> [ "133200",10 ],
	"D9(add6)"	=> [ "133200",10 ],
	"Dm"		=> [ "NN0231", 1 ],
	"Dm6(5b)"	=> [ "NN0101", 1 ],
	"Dm7"		=> [ "NN0211", 1 ],
	"Dm#5"		=> [ "NN0332", 1 ],
	"Dm(#5)"	=> [ "NN0332", 1 ],
	"Dm#7"		=> [ "NN0221", 1 ],
	"Dm(#7)"	=> [ "NN0221", 1 ],
	"Dm/A"		=> [ "N00231", 1 ],
	"Dm/B"		=> [ "N20231", 1 ],
	"Dm/C"		=> [ "N30231", 1 ],
	"Dm/C#"		=> [ "N40231", 1 ],
	"Dm9"		=> [ "NN3210", 1 ],
	"D#"		=> [ "NN3121", 3 ],
	"D#+"		=> [ "NN1004", 1 ],
	"D#4"		=> [ "NN1344", 1 ],
	"D#7"		=> [ "NN1323", 1 ],
	"D#sus"		=> [ "NN1344", 1 ],
	"D#sus4"	=> [ "NN1344", 1 ],
	"D#maj"		=> [ "NN3121", 3 ],
	"D#maj7"	=> [ "NN1333", 1 ],
	"D#dim"		=> [ "NN1212", 1 ],
	"D#min"		=> [ "NN4342", 1 ],
	"D#m"		=> [ "NN4342", 1 ],
	"D#m7"		=> [ "NN1322", 1 ],
	"Eb"		=> [ "NN3121", 3 ],
	"Eb+"		=> [ "NN1004", 1 ],
	"Eb4"		=> [ "NN1344", 1 ],
	"Eb7"		=> [ "NN1323", 1 ],
	"Ebsus"		=> [ "NN1344", 1 ],
	"Ebsus4"	=> [ "NN1344", 1 ],
	"Ebmaj"		=> [ "NN1333", 1 ],
	"Ebmaj7"	=> [ "NN1333", 1 ],
	"Ebdim"		=> [ "NN1212", 1 ],
	"Ebadd9"	=> [ "N11341", 1 ],
	"Eb(add9)"	=> [ "N11341", 1 ],
	"Ebmin"		=> [ "NN4342", 1 ],
	"Ebm"		=> [ "NN4342", 1 ],
	"Ebm7"		=> [ "NN1322", 1 ],
	"E"		=> [ "022100", 1 ],
	"E+"		=> [ "NN2110", 1 ],
	"E5"		=> [ "0133NN", 7 ],
	"E6"		=> [ "NN3333", 9 ],
	"E7"		=> [ "022130", 1 ],
	"E7#9"		=> [ "022133", 1 ],
	"E7(#9)"	=> [ "022133", 1 ],
	"E7(5b)"	=> [ "N10130", 1 ],
	"E7b9"		=> [ "020132", 1 ],
	"E7(b9)"	=> [ "020132", 1 ],
	"E7(11)"	=> [ "022230", 1 ],
	"E9"		=> [ "131213", 1 ],
	"E11"		=> [ "111122", 1 ],
	"Esus"		=> [ "022200", 1 ],
	"Esus4"		=> [ "022200", 0 ],
	"Emaj"		=> [ "022100", 1 ],
	"Emaj7"		=> [ "02110N", 1 ],
	"Edim"		=> [ "NN2323", 1 ],
	"Emin"		=> [ "022000", 1 ],
	"Em"		=> [ "022000", 1 ],
	"Em6"		=> [ "022020", 1 ],
	"Em7"		=> [ "022030", 1 ],
	"Em/B"		=> [ "N22000", 1 ],
	"Em/D"		=> [ "NN0000", 1 ],
	"Em7/D"		=> [ "NN0000", 1 ],
	"Emsus4"	=> [ "002000", 1 ],
	"Em(sus4)"	=> [ "002000", 1 ],
	"Emadd9"	=> [ "024000", 1 ],
	"Em(add9)"	=> [ "024000", 1 ],
	"F"		=> [ "133211", 1 ],
	"F+"		=> [ "NN3221", 1 ],
	"F+7+11"	=> [ "133200", 1 ],
	"F4"		=> [ "NN3311", 1 ],
	"F6"		=> [ "N3323N", 1 ],
	"F7"		=> [ "131211", 1 ],
	"F9"		=> [ "242324", 1 ],
	"F11"		=> [ "131311", 1 ],
	"Fsus"		=> [ "NN3311", 1 ],
	"Fsus4"		=> [ "NN3311", 1 ],
	"Fmaj"		=> [ "133211", 1 ],
	"Fmaj7"		=> [ "N33210", 1 ],
	"Fdim"		=> [ "NN0101", 1 ],
	"Fmin"		=> [ "133111", 1 ],
	"F/A"		=> [ "N03211", 1 ],
	"F/C"		=> [ "NN3211", 1 ],
	"F/D"		=> [ "NN0211", 1 ],
	"F/G"		=> [ "333211", 1 ],
	"F7/A"		=> [ "N03011", 1 ],
	"Fmaj7/A"	=> [ "N03210", 1 ],
	"Fmaj7/C"	=> [ "N33210", 1 ],
	"Fmaj7(+5)"	=> [ "NN3220", 1 ],
	"Fadd9"		=> [ "303211", 1 ],
	"F(add9)"	=> [ "303211", 1 ],
	"FaddG"		=> [ "1N3213", 1 ],
	"FaddG"		=> [ "1N3213", 1 ],
	"Fm"		=> [ "133111", 1 ],
	"Fm6"		=> [ "NN0111", 1 ],
	"Fm7"		=> [ "131111", 1 ],
	"Fmmaj7"	=> [ "N33110", 1 ],
	"F#"		=> [ "244322", 1 ],
	"F#+"		=> [ "NN4332", 1 ],
	"F#7"		=> [ "NN4320", 1 ],
	"F#9"		=> [ "N12122", 1 ],
	"F#11"		=> [ "242422", 1 ],
	"F#sus"		=> [ "NN4422", 1 ],
	"F#sus4"	=> [ "NN4422", 1 ],
	"F#maj"		=> [ "244322", 0 ],
	"F#maj7"	=> [ "NN4321", 1 ],
	"F#dim"		=> [ "NN1212", 1 ],
	"F#min"		=> [ "244222", 1 ],
	"F#/E"		=> [ "044322", 1 ],
	"F#4"		=> [ "NN4422", 1 ],
	"F#m"		=> [ "244222", 1 ],
	"F#m6"		=> [ "NN1222", 1 ],
	"F#m7"		=> [ "NN2222", 1 ],
	"F#m7-5"	=> [ "102333", 2 ],
	"F#m/C#m"	=> [ "NN4222", 1 ],
	"Gb"		=> [ "244322", 1 ],
	"Gb+"		=> [ "NN4332", 1 ],
	"Gb7"		=> [ "NN4320", 1 ],
	"Gb9"		=> [ "N12122", 1 ],
	"Gbsus"		=> [ "NN4422", 1 ],
	"Gbsus4"	=> [ "NN4422", 1 ],
	"Gbmaj"		=> [ "244322", 1 ],
	"Gbmaj7"	=> [ "NN4321", 1 ],
	"Gbdim"		=> [ "NN1212", 1 ],
	"Gbmin"		=> [ "244222", 1 ],
	"Gbm"		=> [ "244222", 1 ],
	"Gbm7"		=> [ "NN2222", 1 ],
	"G"		=> [ "320003", 1 ],
	"G+"		=> [ "NN1004", 1 ],
	"G4"		=> [ "NN0013", 1 ],
	"G6"		=> [ "3N0000", 1 ],
	"G7"		=> [ "320001", 1 ],
	"G7+"		=> [ "NN4332", 1 ],
	"G7b9"		=> [ "NN0101", 1 ],
	"G7(b9)"	=> [ "NN0101", 1 ],
	"G7#9"		=> [ "13N244", 3 ],
	"G7(#9)"	=> [ "13N244", 3 ],
	"G9"		=> [ "3N0201", 1 ],
	"G9(11)"	=> [ "131313", 3 ],
	"G11"		=> [ "3N0211", 1 ],
	"Gsus"		=> [ "NN0013", 1 ],
	"Gsus4"		=> [ "NN0011", 1 ],
	"G6sus4"	=> [ "020010", 1 ],
	"G6(sus4)"	=> [ "020010", 1 ],
	"G7sus4"	=> [ "330011", 1 ],
	"G7(sus4)"	=> [ "330011", 1 ],
	"Gmaj"		=> [ "320003", 1 ],
	"Gmaj7"		=> [ "NN1234", 2 ],
	"Gmaj7sus4"	=> [ "NN0012", 1 ],
	"Gmaj9"		=> [ "114121", 2 ],
	"Gmin"		=> [ "133111", 3 ],
	"Gdim"		=> [ "NN2323", 1 ],
	"Gadd9"		=> [ "13N213", 3 ],
	"G(add9)"	=> [ "13N213", 3 ],
	"G/A"		=> [ "N00003", 1 ],
	"G/B"		=> [ "N20003", 1 ],
	"G/D"		=> [ "N22100", 4 ],
	"G/F#"		=> [ "220003", 1 ],
	"Gm"		=> [ "133111", 3 ],
	"Gm6"		=> [ "NN2333", 1 ],
	"Gm7"		=> [ "131111", 3 ],
	"Gm/Bb"		=> [ "3221NN", 4 ],
	"G#"		=> [ "133211", 4 ],
	"G#+"		=> [ "NN2110", 1 ],
	"G#4"		=> [ "133111", 4 ],
	"G#7"		=> [ "NN1112", 1 ],
	"G#sus"		=> [ "NN1124", 1 ],
	"G#sus4"	=> [ "NN1124", 1 ],
	"G#maj"		=> [ "133211", 4 ],
	"G#maj7"	=> [ "NN1113", 1 ],
	"G#dim"		=> [ "NN0101", 1 ],
	"G#min"		=> [ "133111", 4 ],
	"G#m"		=> [ "133111", 4 ],
	"G#m6"		=> [ "NN1101", 1 ],
	"G#m7"		=> [ "NN1111", 4 ],
	"G#m9maj7"	=> [ "NN1303", 1 ],
	"G#m9(maj7)"	=> [ "NN1303", 1 ]
    );
}

