REBOL [ title: "Guitar Chords" date: 9-Dec-2009 file: %guitar-chords.r author: Nick Antonaccio purpose: { Create and print instant guitar chord diagram charts for songs. Taken from the tutorial at http://re-bol.com } ] help: { This program creates guitar chord diagram charts for songs. It was written to help students in highschool jazz band quickly play all of the common extended, altered, and complex chord types. It can also be used to create chord charts for any other type of music (with simpler chords): folk, rock, blues, pop, etc. To select chords for your song, click the root note (letter name: A, Bb, C#, etc.), and then the sonority (major, minor, 7(#5b9), etc.) of each chord. The list of chords you've selected will be shown in the text area below. When you've added all the chords needed to play your song, click the "Create Chart" button. Your browser will open, with a complete graphic rendering of all chords in your song. You can use your browser's page settings to print charts at different sizes. Two versions of each chord are presented: 1 with the root note on the 6th string, and another with the root note on the 5th string. Chord lists can be saved and reloaded with the "Save" and "Load" buttons. The rendered images and the HTML that displays them are all saved to the "./chords" folder (a subfolder of wherever this script is run). You can create a zip file of all the contents of that folder to play your song later, upload it to a web server to share with the world, etc. -- THEORY -- Here are the formulas and fingering patterns used to create chords in this program: 6th string notes: 5th string notes: 0 1 3 5 7 8 10 12 0 2 3 5 7 8 10 12 E F G A B C D E A B C D E F G A The sharp symbol ("#") moves notes UP one fret The flat symbol ("b") moves notes DOWN one fret Root 6 interval shapes: Root 5 interval shapes: ___________ ___________ | | | | 4 | | | | | | | | 3 6 9 | 7 | | | | | | 1 | | | 5 1 | | | | 1 4 | | 7 3 | | | | 3 6 | | | 5 1 4 6 9 5 1 4 | 9 5 | | | | | | | | | 7 | | | | 9 | 7 | | | 5 1 3 6 To create any chord, slide either shape up the fretboard until the number "1" is on the correct root note (i.e., for a "G" chord, slide the root 6 shape up to the 3rd fret, or the root 5 shape up to the 10th fret). Then pick out the required intervals: CHORD TYPE: INTERVALS: SYMBOLS: Power Chord 1 5 5 Major Triad 1 3 5 none (just a root noot) Minor Triad 1 b3 5 m, min, mi, - Dominant 7 1 3 (5) b7 7 Major 7 1 3 (5) 7 maj7, M7, (triangle) 7 Minor 7 1 b3 (5) b7 m7, min7, mi7, -7 Half Diminished 7 1 b3 b5 b7 m7b5, (circle with line) 7 Diminished 7 1 b3 b5 bb7 (6) dim7, (circle) 7 Augmented 7 1 3 #5 b7 7aug, 7(#5), 7(+5) Add these intervals to the above 7th chords to create extended chords: 9 (is same as 2) 11 (is same as 4) 13 (is same as 6) Examples: 9 = 1 3 (5) b7 9 min9 = 1 b3 (5) b7 9 13 = 1 3 5 b7 13 9(+5) = 1 3 #5 b7 9 maj9(#11) = 1 3 (5) 7 9 #11 Here are some more common chord types: "sus" = change 3 to 4 "sus2" = change 3 to 2 "add9" = 1 3 5 9 (same as "add2", there's no 7 in "add" chords) "6, maj6" = 1 3 5 6 "m6, min6" = 1 b3 5 6 "6/9" = 1 3 5 6 9 11 = 1 b7 9 11 "/" = Bassist plays the note after the slash NOTE: When playing complex chords (jazz chords) in a band setting, guitarists typically SHOULD NOT PLAY THE ROOT NOTE of the chord (the bassist or keyboardist will play it). In diagrams created by this program, unnecessary notes are indicated by light circles, and required notes are indicated by dark circles. Here are the formulas and fingering patters used to create chords in this program: } root6-shapes: [ "." "major triad, no symbol (just a root note)" [1 3 5 11 55 111] "m" "minor triad, min, mi, m, -" [1 b3 5 11 55 111] "aug" "augmented triad, aug, #5, +5" [1 3 b6 11 111] "dim" "diminished triad, dim, b5, -5" [1 b3 b5 11] "5" "power chord, 5" [1 55] "sus4" "sus4, sus" [1 4 5 11 55 111] "sus2" "sus2, 2" [1 99 5 11] "6" "major 6, maj6, ma6, 6" [1 3 5 6 11] "m6" "minor 6, min6, mi6, m6" [1 b3 5 6 11] "69" "major 6/9, 6/9, add6/9" [1 111 3 13 9] "maj7" "major 7, maj7, ma7, M7, (triangle) 7" [1 3 5 7 11 55] "7" "dominant 7, 7" [1 3 5 b7 11 55] "m7" "minor 7, min7, mi7, m7, -7" [1 b3 5 b7 11 55] "m7(b5)" "half diminished, min7(b5), (circle w/ line), m7(-5), -7(b5)" [1 b3 b5 b7 11] "dim7" "diminished 7, dim7, (circle) 7" [1 b3 b5 6 11] "7sus4" "dominant 7 sus4 (7sus4)" [1 4 5 b7 55 11] "7sus2" "dominant 7 sus2 (7sus2)" [1 b7 99 5 11] "7(b5)" "dominant 7 flat 5, 7(b5), 7(-5)" [1 3 b5 b7 11] "7(+5)" "augmented 7, 7(#5), 7(+5)" [1 3 b6 b7 11] "7(b9)" "dominant 7 flat 9, 7(b9), 7(-9)" [1 3 5 b7 b9] "7(+9)" "dominant 7 sharp 9, 7(#9), 7(+9)" [1 111 3 b77 b33] "7(b5b9)" "dominant 7 b5 b9, 7(b5b9), 7(-5-9)" [1 3 b5 b7 b9] "7(b5+9)" "dominant 7 b5 #9, 7(b5#9), 7(-5+9)" [1 3 b5 b7 b33] "7(+5b9)" "augmented 7 flat 9, aug7(b9), 7(#5b9)" [1 3 b6 b7 b9] "7(+5+9)" "augmented 7 sharp 9, aug7(#9), 7(#5#9)" [1 3 b6 b7 b33] "add9" "add9, add2" [1 3 5 999 55 11] "madd9" "minor add9, min add9, m add9, m add2" [1 b3 5 999 55 11] "maj9" "major 9, maj9, ma9, M9, (triangle) 9" [1 3 5 7 9] "maj9(+11)" "major 9 sharp 11, maj9(#11), M9(+11)" [1 3 7 9 b5] "9" "dominant 9, 9" [1 3 5 b7 9 55] "9sus" "dominant 9 sus4, 9sus4, 9sus" [1 4 5 b7 9 55] "9(+11)" "dominant 9 sharp 11, 9(#11), 9(+11)" [1 3 b7 9 b5] "m9" "minor 9, min9, mi9, m9, -9" [1 b3 5 b7 9 55] "11" "dominant 11, 11" [1 b7 99 44 11] "maj13" "major 13, maj13, ma13, M13, (triangle) 13" [1 3 55 7 11 13] "13" "dominant 13, 13" [1 3 55 b7 11 13] "m13" "minor 13, min13, mi13, m13, -13" [1 b3 55 b7 11 13] ] root6-map: [ 1 20x70 11 120x70 111 60x110 3 80x90 33 40x50 b3 80x70 5 100x70 55 40x110 b5 100x50 7 60x90 b7 60x70 9 120x110 99 80x50 6 60x50 13 100x110 4 80x110 44 100x30 999 60x150 b77 100x130 b33 120x130 b9 120x90 b6 100x90 b55 40x90 ] root5-shapes: [ "." "major triad, no symbol (just a root note)" [1 3 5 11 55] "m" "minor triad, min, mi, m, -" [1 b3 5 11 55] "aug" "augmented triad, aug, #5, +5" [1 3 b6 11 b66] "dim" "diminished triad, dim, b5, -5" [1 b3 b5 11] "5" "power chord, 5" [1 55] "sus4" "sus4, sus" [1 4 5 11 55] "sus2" "sus2, 2" [1 9 5 11 55] "6" "major 6, maj6, ma6, 6" [1 3 55 13 11] "m6" "minor 6, min6, mi6, m6" [1 b3 55 13 11] "69" "major 6/9, 6/9, add6/9" [1 33 6 9 5] "maj7" "major 7, maj7, ma7, M7, (triangle) 7" [1 3 5 7 55] "7" "dominant 7, 7" [1 3 5 b7 55] "m7" "minor 7, min7, mi7, m7, -7" [1 b3 5 b7 55] "m7(b5)" "half diminished, min7(b5), (circle w/ line), m7(-5), -7(b5)" [1 b3 b5 b7 b55] "dim7" "diminished 7, dim7, (circle) 7" [1 b33 b5 6 111] "7sus4" "dominant 7 sus4, 7sus4" [1 4 5 b7 55] "7sus2" "dominant 7 sus2, 7sus2" [1 9 5 b7 55] "7(b5)" "dominant 7 flat 5, 7(b5), 7(-5)" [1 33 b5 b7 111] "7(+5)" "augmented 7, 7(#5), 7(+5)" [1 33 b6 b7 111] "7(b9)" "dominant 7 flat 9, 7(b9), 7(-9)" [1 33 5 b7 b9] "7(+9)" "dominant 7 sharp 9, 7(#9), 7(+9)" [1 33 b7 b3] "7(b5b9)" "dominant 7 b5 b9, 7(b5b9), 7(-5-9)" [1 33 b5 b7 b9] "7(b5+9)" "dominant 7 b5 #9, 7(b5#9), 7(-5+9)" [1 33 b5 b7 b3] "7(+5b9)" "augmented 7 flat 9, aug7(b9), 7(#5b9)" [1 33 b6 b7 b9] "7(+5+9)" "augmented 7 sharp 9, aug7(#9), 7(#5#9)" [1 33 b7 b3 b6] "add9" "major add9, add9, add2" [1 3 5 99 55] "madd9" "minor add9, min add9, m add9, m add2" [1 b3 5 99 55] "maj9" "major 7, maj9, ma9, M9, (triangle) 9" [1 33 5 7 9] "maj9(+11)" "major 9 sharp 11, maj9(#11), M9(+11)" [1 33 b5 7 9] "9" "dominant 9, 9" [1 33 5 b7 9] "9sus" "dominant 9 sus4, 9sus4, 9sus" [1 44 5 b7 9] "9(+11)" "dominant 9 sharp 11, 9(#11), 9(+11)" [1 33 b5 b7 9] "m9" "minor 9, min9, mi9, m9, -9" [1 b33 5 b7 9] "11" "dominant 11, 11" [1 b7 9 44 444] "maj13" "major 13, maj13, ma13, M13, (triangle) 13" [1 3 55 7 13] "13" "dominant 13, 13" [1 3 55 b7 13] "m13" "minor 13, min13, mi13, m13, -13" [1 b3 55 b7 13] ] root5-map: [ 1 40x70 11 80x110 111 100x30 3 100x110 33 60x50 b33 60x30 5 120x70 55 60x110 b5 120x50 7 80x90 b7 80x70 9 100x70 6 80x50 13 120x110 4 100x130 44 60x70 444 120x30 99 80x150 b3 100x90 b9 100x50 b6 120x90 b66 60x130 b55 60x90 ] root6-notes: [ "e" {12} "f" {1} "f#" {2} "gb" {2} "g" {3} "g#" {4} "ab" {4} "a" {5} "a#" {6} "bb" {6} "b" {7} "c" {8} "c#" {9} "db" {9} "d" {10} "d#" {11} "eb" {11} ] root5-notes: [ "a" {12} "a#" {1} "bb" {1} "b" {2} "c" {3} "c#" {4} "db" {4} "d" {5} "d#" {6} "eb" {6} "e" {7} "f" {8} "f#" {9} "gb" {9} "g" {10} "g#" {11} "ab" {11} ] f: copy [] for n 20 160 20 [append f reduce ['line (as-pair 20 n) (as-pair 120 n)]] for n 20 120 20 [append f reduce ['line (as-pair n 20) (as-pair n 160)]] fretboard: to-image layout/tight [box white 150x180 effect [draw f]] ; spacer: to-image layout/tight [box white 20x20] view center-face layout [ across t1: text-list 60x270 data [ "E" "F" "F#" "Gb" "G" "G#" "Ab" "A" "A#" "Bb" "B" "C" "C#" "Db" "D" "D#" "Eb" ] t2: text-list 330x270 data extract/index root6-shapes 3 2 [ either empty? a/text [ a/text: rejoin [ copy t1/picked " " pick root6-shapes ((index? find root6-shapes value) - 1) ] ] [ a/text: rejoin [ a/text newline copy t1/picked " " pick root6-shapes ((index? find root6-shapes value) - 1) ] ] show a ] return a: area return btn "Create Chart" [if error? try [ make-dir %chords delete/any %chords/*.* ; save/bmp %./chords/spacer.bmp spacer html: copy "
" foreach [root spacer1 spacer2 type] (parse/all form a/text " ") [ diagram: copy [image fretboard] diagram2: copy [image fretboard] root1: copy root foreach itvl (third find root6-shapes type) [ either find [1 55] itvl [ append diagram reduce [ 'fill-pen white 'circle (select root6-map itvl) 5 ] ] [ append diagram reduce [ 'fill-pen black 'circle (select root6-map itvl) 5 ] ] ] append diagram reduce ['text (trim/all join root1 type) 20x0] append diagram reduce [ 'text trim/all to-string ( select root6-notes trim/all to-string root1 ) 130x65 ] save/png to-file trim/all rejoin [ %./chords/ (replace/all root1 {#} {sharp}) type ".png" ] to-image layout/tight [ box white 150x180 effect [draw diagram] ] append html rejoin [ {