Step 5: How it all happened
Well, that's the end of the Instructable, but I'm sure many of you are the naturally inquisitive type and don't just want to churn out a product using someone else's code. You want to know the how it was done!
The toy is simple enough. A quick inspection reveals that the "head" of the record player's arm is a tiny musical box with 22 metal gears. The record has 11 groves and pins on either side that operate one of the 22 notes. Each groove forms a circle so the tune repeats once per revolution - there's no spiral track like we used to have on real vinyl records. It did take quite a while with some digital calipers to accurately measure the position of all the grooves and the holes that locate the disc on the turntable. All these measurements you'll find either in the 3D models I used to create the record blanks or the code that generates the music information.
The modelling software I used is CamBam. This is ideally suited to creating a model of something you're going to mill. The gcode this outputs is used to create the holes for the locating pegs and the groove required (along with the outer edge of the record) to locate the player head. You can get a fully-featured but time limited version of CamBam from http://www.cambam.info/ if you want to view or edit this file.
Next, a very basic text file to gcode conversion gave me an initial test record with a "scale" that played each note in turn. This let me test out a proof of concept and see whether it was possible to create a playable record. It also showed that the music box "head" wasn't quite in line with the centre of the record - I had to shift everything a couple of millimetres. I won't bore you with the maths, but there were lots of radians, sines and cosines involved. Check out the source code for details.
It also made it easier to work out what notes were available and what each pin represented. The box is not exactly hifi standard and with some help from a more musical friend we managed to work out that the 22 tracks are as follows working from the inside. The first 7 pins are D#, G#, A#, C#, D#, F, G. Then the follow 12 pins actually have each note repeated twice. Whether this is for durability (as these are used often) or a way for notes to be repeated in quick succession without jamming, I'm not sure. These are G#, A#, C, C#, D#, F. Finally we have G, G# and A#. This gives us most of 2 octaves from a G# major scale with a couple of extras at either end.
Finding music to put on the record in G# Major was going to be tricky so if this is transposed to a far more common C Major scale we can consider these to be: G, C, D, E, G, A, B, C x 2, D x 2, E x 2, F x 2, G x 2, A x 2, B, C, D. That's what I used in the music editor (no flats or sharps - very handy) and the preview.
So now we can try to get something a little less painful on the ears onto our shiny plastic disc. If you're at all musical you may find my music editor offensively basic. However it seems to do the job. You wouldn't believe the smile on my face when I finally heard a recognisable intro to "Stairway to Heaven" (as banned in all good guitar shops) coming from my little toy...
If you create your own record, please let me know. It would be great to hear that someone else found this useful. I'm also more likely to tweak the software if I know it's being used.