My Journal and Diary
2005
January
Sunday, January 30th, 2005
Chord Transposer Script
I wrote a new program this morning/this evening that transposes guitar chords automatically. You paste in a chart, then choose the half-steps to transpose by. Choose whether you prefer "sharps" or "flats" or "easy" to name chords, and press the button. Voila! The song is automatically transposed and ready for you to use.
The logic for transposing a song is suprisingly complicated. I had to go through the chart a line at a time, looking for lines that had only chords and chord symbols. My assumption: every chord will start with a captital letter between A and G, or a slash (for bass notation). Or a bracket ( to indicate a special chord-- or other special characters I use in transcriptions (|,[:,:], etc).
When I find a line with only chord symbols, I convert all the chords to numbers, one through twelve. Then I do the transposition math on them, before converting them back to letters (sharps or flats-- depending on your preference).
Maybe sounds easy in English, but try telling a computer to do it. ;)
The reason for this script is to integrate it into ServiceBuilder. Then worship leaders can change the keys for the songs if they wish, and we don't have to change what's in the database. The next step is to rewrite the program in Visual Basic. Fun fun fun!
~Jason
Tags:webdesign perl_scripts 0 likes ↑