July 2005


So I’ve released the GuitarChordsPlugin 1.0. It’s free. Download away.

Note that is NOT the same thing as the GuitarChords widget also developed by me and featured on Apple’s website. Instead, this plugin is used by the GuitarChords widget to generate MIDI sounds with the DLS Synth built in to Tiger. Widget developers can use the plugin in their own widgets to play single notes, chords, or a sequence of notes. So if you’re looking to add generated sounds to your own widgets, then feel free to use this. Included in the download are documentation and a sample widget demonstrating how everything works.

Let me know if you have any questions. And have fun with it!

Fixed another memory leak, and added code to make sure your saved preferences are valid. Tons of thanks go to Matt for all the help debugging.

Download away from the usual link.

I’ve gotten a few reports of the new sound module in GuitarChords crashing people’s machines. I’m not sure what might be causing it, but I went ahead and added a lot more defensive programming to the module to try and alleviate the problem. So if you had problems before, try out version 1.5.1 and let me know if it fixes things.

If it’s still crashing, then I’ll go ahead and release a secondary version of the product without the audio module. That way you still get the UI enhancements over version 1.0 but without the crashing. ;)

Thanks for all the positive feedback. To date, there’s been over 32,000 downloads of GuitarChords and the software reached #4 on the Apple Top 50 Dashboard Widget list. But rather than rest on our laurels, you can now download GuitarChords 1.5. Additional features in this release include:

- Sound! Click the play button and hear what the chord sounds like. Each string is played one at a time, and then the chord is played all at once.
- Choose from all the guitar sounds in Apple’s built-in synthesizer
- Control the speed of playback for the chord
- View the fretboard left-handed or right-handed
- Partially displayed chords are auto-scrolled so that they appear fully on the screen
- Get feedback if a chord cannot be found to display on the fretboard

Two highly requested features that did NOT make it into this version, but should make it into the next one are horizontal views and four-note chords (7th, add9, etc.). Look for those to be added before the end of the summer.

As for the future, soon I’ll also be releasing the GuitarChordsPlugin. It’s a custom plugin written in Objective-C that other Dashboard developers can use to play sound in their own widgets. It’s mostly finished, but I need to write some decent documentation for it first. More about that later. For now, let me know if version 1.5 gives you any problems.

I’ve been getting a lot of feedback from people wanting to see variations on chords or wanting to modify which chords are displayed, so I thought I would take a break and talk about how the chord selection process currently works in the widget. First of all, the entire chord calculation is done mathematically. There are no data files with lists of chords in them. It’s all calculated on the fly. This is essential in order to support the ability to change the tuning of each guitar string. So there are no master files you can manipulate by hand, so you’ll have to bear with me while I walk you through what happens.

First, the code looks at the fretboard layout and determines the lowest visible fret on-screen. Initially, this is an open string, but as you scroll up the neck it could be the 3rd fret, the 5th fret, or the 12th fret.

Once the code has determined the lowest fret shown, then it calculates five different sets of test ranges used to evaluate fingerings. The first set is a four fret range starting from the lowest fret shown. This set also allows open strings as a possibility. The remaining four sets are barre chord ranges for each of the four frets listed in the first range. However, since they are barre chords their fret range is limited to two frets. Confused yet? Here’s an example. Say the lowest fret shown was the 5th fret, then the ranges considered would be:
- frets 5,6,7,8, and open strings
- frets 6,7 with a barre on the 5th fret
- frets 7,8 with a barre on the 6th fret
- frets 8,9 with a barre on the 7th fret
- frets 9,10 with a barre on the 8th fret

Once the ranges have been determined, the code starts with the bass string and looks through the fret range to see if any of the notes match the root of the chord. The algorithm insists that the root of the chord be the lowest note played. So it automatically eliminates options like a simple D major with a F# bass note.

Once the code find a string containing the root of the chord, it starts looking for strings that contain ANY note in the chord, and records all frets that satisfy this test. After this step, the code has created an array of six elements, one for each string. Each element might contain a -1, meaning no possible note found, or it could contain a single digit meaning only one note was found, or it could contain an array of numbers for all the fret options on that string. For example, if you looked for a C major chord with a lowest visible fret of 5, then the five ranges would look like this:
[8,7,5,[0,5],[5,8],[0,8]]
[8,7,-1,-1,8,8]
[8,7,-1,9,8,8]
[8,10,10,9,8,8]
[-,1-,1,10,9,-1,-1]

Since the first range contains several sub-arrays, the next step is to break that array out into as many combinations as possible. After calculating all the combinations, the code ends up with 12 different options for playing the C major chord:
[8,7,5,0,5,0]
[8,7,5,0,5,8]
[8,7,5,0,8,0]
[8,7,5,0,8,8]
[8,7,5,5,5,0]
[8,7,5,5,5,8]
[8,7,5,5,8,0]
[8,7,5,5,8,8]
[8,7,-1,-1,8,8]
[8,7,-1,9,8,8]
[8,10,10,9,8,8]
[-,1-,1,10,9,-1,-1]

The next step is to run all the combinations through a validator. Currently, the only rule in the validator is that the chord needs to be able to play on at least the top four strings. This eliminates three of the combinations, so now we’re left with:
[8,7,5,0,5,0]
[8,7,5,0,5,8]
[8,7,5,0,8,0]
[8,7,5,0,8,8]
[8,7,5,5,5,0]
[8,7,5,5,5,8]
[8,7,5,5,8,0]
[8,7,5,5,8,8]
[8,10,10,9,8,8]

Now comes the ranking. Each one of the remaining chords is evaluated using a scoring system. The scoring system has each chord start with 6 points. Then each chord receives an additional point for each string that is played (so 6 string chords are rated higher than 4 string chords). Next, each chord loses one point for each finger that is required to fret the chord. Note, however, that the fret for the barre chord does not count against the score. The reasoning here is that since a barre chord has a shorter fret range than an open chord, then it would be easier to play. So in our current dataset, once the scoring is done, here are the results:

8 - [8,7,5,0,5,0]
7 - [8,7,5,0,5,8]
8 - [8,7,5,0,8,0]
7 - [8,7,5,0,8,8]
7 - [8,7,5,5,5,0]
9 - [8,7,5,5,5,8]
7 - [8,7,5,5,8,0]
8 - [8,7,5,5,8,8]
9 - [8,10,10,9,8,8]

This leaves a two-way tie between the fingering [8,7,5,5,5,8] and [8,10,10,9,8,8]. Ties are broken by giving preference to open-string tunings, and even though [8,7,5,5,5,8] is not an open tuning it was derived using the ranges from the open tuning option, so it wins.

And that’s how it works. There are clearly some ways I can still optimize this including making the fret range be based on a physical distance and not just a fret number. This would create more options at the higher end of the neck where it’s easier to have a seven fret range.

But I’m curious what insights people have.

Wow. That’s all I can say. Wow. In just FIVE DAYS there have been over 11,000 downloads of the GuitarChords widget, and it’s reached #10 on Apple’s Top 50 widgets list. You all rock.

I’ve received plenty of great feedback, so I wanted to post a list of the features that will be included in version 1.5 of the widget. I’m hoping to complete this next rev by the end of the week, so check back for an annoucement. In the meantime, here’s a list of what will be included in version 1.5.

- Audio! Using a custom widgetplugin and Quicktime, you’ll be able to hear the chord played string by string as well as all at once.
- Audio playback options - Related to the new audio feature, you will be able to turn the audio on and off, choose the type of guitar (acoustic, electric, etc.) used to play the chord and also control the speed at which the chord is played.
- Lefty fretboard option - I received many comments from people wanting a left-handed view of the fretboard. Considering I play lefty and am always complaining about lack of support for lefties, this feature will be included ASAP.
- Auto-scrolling - If the chord isn’t displayed entirely on screen, then it will now auto-scroll so you’ll be able to see the whole chord. Also, if no chord can be drawn, then you’ll receive a notice as well.

There isn’t going to be a major facelift, and the physical dimensions of the widget will NOT change, so don’t worry that more features equals bigger widget. Though I do suspect the download file size will increase by 50K or so, but personally I think it’s still easily manageable even for dial-up users.

Back to work…

GuitarChords 1.0, a Dashboard widget for Mac OS X has been released. Download away.

Just pick a note and type of chord. Then watch as the widget displays how to fret that chord on the guitar. Scroll up the neck and see alternate ways of playing that same chord. When you get tired of that, flip the widget around and change the tuning on your guitar. Ever wondered how to play a E-flat augmented chord in Open G tuning? Now you can find out.

In the future, I’ll be adding who knows what to the widget. Maybe nothing. Maybe other cool things depending on what kind of feedback I get. Anyway, hope you like it.

OFFICIAL APPLE DOWNLOAD INSTRUCTIONS
Mac OS X 10.4 Tiger is required. If you’re using Safari, click the download link. When the widget download is complete, show Dashboard, click the Plus sign to display the Widget Bar and click the widget’s icon in the Widget Bar to open it. If you’re using a browser other than Safari, click the download link. When the widget download is complete, unarchive it and place it in /Library/Widgets/ in your home folder. show Dashboard, click the Plus sign to display the Widget Bar and click the widget’s icon in the Widget Bar to open it.

I found a database of long/lat addresses for the NYC subway, so I’ve got those compiled now, but the problem is that it’s just the stations, so there is no order for which station belongs to which line and what order the stops are in. Plus, you have to take in weird directional things to like the fact that you can switch to the B/D/F/V at Broadway/Lafayette from the 6 train southbound, but going northbound, you have to leave the station and walk outside. Anyway, it’s an evolving project, so stay tuned, it’s always changing.

And I promise I’ll pick up the guitar chord stuff in another week or so.