Print This Post Print This Post

Guitar Chord Repositories

Over 1500 ready-made SVG guitar chords, either to download or use online

Amaj

I resisted the temptation to make this post the 4th in the recent series: Guitar Chord Diagrams in SVG? It is a little more than that.
Over the 3 posts on SVG chords I’ve emphasized that my aim was to achieve an easy method of putting chord diagrams alongside text in what would ultimately be PDF documents. With the recent added support for SVG in OpenOffice.Org Writer et al, this is now possible, so I turned my attention to producing a repository of the most-used chords, and making these available to drag and drop into the Writer document.

What is presented here is a working 1st cut, implementing as it does 1,584 SVG chords supported by the following:

  • A directory structure of 12 keys, with each directory containing the base and CAGED-derived chords, written in SVG.
  • A Chord definition meta-file ChordDefs.xml, which contains the data (string-fret positions) and tuning information for each chord.
  • A simple MySQL database schema, holding all the SVG chords.
  • A set of HTML files (web pages), to display chords in each individual key, plus a single web page with all of the chords in it. This latter web page is long – you have been warned!

In addition, two Python scripts which generate the above, for ‘normal’ Guitar tuning, or several common ‘alternative’ Guitar tunings.

Use of the material presented here can be multi-level. Simple drag-and-drop from the web page containing the full chord set, into a document; scripting OpenOffice.org Writer to use the directory-based, or database copies of the SVG chords; or installing the chords manually, using the Insert Picture (from file) menu.

Also since the full source-code is given, complete customisation of this can be done also. Newcomers to Python, may find the source-code useful in showing examples of accessing files, and of a MySQL database using embedded SQL.

I also provide the schema creation script, (and a fully populated export) should anyone want to reproduce the database on their machine. I used the (rather excellent) dbForge package installed on my Windows XP/SP3 machine to produce the simple schema, which comprises only 3 tables.

The table below holds links to each key-based chord web page, together with the page containing all chords.

Links to web pages of SVG Chords in each key
Chords in A Chords in A# (Bb) Chords in B Chords in C Chords in C# (Db) Chords in D Chords in D# (Eb) Chords in E Chords in F Chords in F# (Gb) Chords in G Chords in G# (Ab) Chords in all keys – warning! over 1500 chords.

An XML meta-file, defining each chord shape is here: http://joebrown.org.uk/GuitarChords/Python/ChordDefs.xml
A zip file of the web pages in the table above is here: http://joebrown.org.uk/GuitarChords/Python/SVGChordWebPages.zip
A zip file of all 12 key directories and the SVG chords therein is here: http://joebrown.org.uk/GuitarChords/Python/SVGChordDirectories.zip

Database Schema

The schema is simple – only three tables as follows:

Entity relationship diagram for SVG Chord Database (dbForge)

Entity relationship diagram for SVG Chord Database (dbForge)

An SQL script to create an empty schema is here: http://joebrown.org.uk/GuitarChords/Python/mydb 20120703 0708.sql This script was generated using dbForge.
An SQL script to create the schema complete with all chords is here: http://joebrown.org.uk/GuitarChords/Python/Dump20120704.sql
This script was generated using MySQL Workbench V5.234 CE, as the free dbForge program has 1Mb size limit on exported SQL.

genchord.py
The Python script used to generate all of the repositories above is here, zipped together with the python class script file SVGChordV2_2.py: http://joebrown.org.uk/GuitarChords/Python/genSVGChord_July_04_2012.zip
Any changes I make to this file will be posted here as an update, in addition to these files. I used Python version 2.7, part of the ‘ActiveStatePython 2.7 (32-bit)’ distribution.

The genchord.py script should be invoked from the command line thus (example shows root directory Python27 on drive G: of my XP machine, user-supplied text is in bold italics, and a (useful?) comment in brackets):

Examples:
  • G:\Python27> python genchord.py -h (invoke module help only)
  • G:\Python27> python genchord.py (no added options: produce SVG chords only)
  • G:\Python27> python genchord.py -d (produce SVG chords and update the MySQL database)
  • G:\Python27> python genchord.py -x (produce SVG chords and also the ChordDefs XML metafile)
  • G:\Python27> python genchord.py --web="s" (produce SVG chords and a single web page showing all chords)
  • G:\Python27> python genchord.py --web="m" -d -x (do all three options above, with a separate web page for each key)


Please refer to the command help for other options.

There are 3 other posts related to this topic. The following links can be accessed for easy browsing across all posts.

Drag it, Drop it, Resize it.
I hesitated about including this section, as almost everyone I know is aware of drag and drop, but since there may be at least one guitarist unsure about embedding graphics files in OpenOffice.Org Writer, I thought I’d include the following screen-scrapes.
The 1st shows an opened text document in Writer with a chord already installed, together with a ‘C’ chord being dragged from one of the web pages I’ve thoughtfully provided.

Dragging the C Chord from the web page

Dragging the 'C' Chord from the web page


The 2nd picture shows the chord after dropping it onto the Writer text document.
The C chord after dropping it onto the text document.

The 'C' chord after dropping it onto the text document.


Note how big it is, so we need to resize.
Re-sizing the rather large chord.

Re-sizing the rather large chord.


Now reset the scale to 100%. I also anchored the resultant image as a character, so it can be manipulated just like text.
C chord now normal size and should be anchored as character

'C' chord now 'normal' size and should be anchored as character


Acknowledgements
‘genesis’ for the chords is (mostly) based on a table stolen from jTab code written by Paul Gallagher (http://tardate.com), 2009. See genchord.py for further details.

Copy the code below to your web site.
x 
  • Share/Bookmark
Create PDF    Send article as PDF   

Comments are closed.