Main Content

There are two ways to put MIDI files in your music box: the easy way, and the hard way. I tried both!

Background: the paper tape
This is the bit I didn’t build. A ready made music box mechanism with 30 tuned tines to its comb, and blank paper tape for you to punch your tunes into.

I really wonder how many people have actually gone to the trouble of punching an entire tune into the tape. Few things could beat it in terms of tediousness.

Midi To Moshi
It was the work of an afternoon to concoct a script that takes MIDI files as input and spits out .mdr vector files – the format used by MoshiDraw, that drives the dirt-cheap laser cutter I have.
This amounted to taking the script I used to transform MIDI files for playback on the ATtiny85 (itself ultimately a butchered edition of jasmid) and mangling it together with my SVG-to-Moshidraw script.

On the off chance that someone else out there has a laser cutter with Moshidraw 2015 and also a 30-note punched-card music box mechanism, the script is available for your perusal here.

It was a fairly obvious decision to cut out the outline of the tape too. Trying to line up the laser onto an original tape would have been a nightmare (and also, we would have quickly run out of them). But, perhaps a development would be to unplug the stepper motor for one axis and connect a roller in its place, that would let us feed the whole paper strip through regardless of its length.

The 30 note scale is not fully chromatic, only the middle 1½ octaves are, and the rest give you some extended range for certain keys. The lowest note is labelled a C, so I went with that, but by the sound of it the whole labelling scheme is a fifth away from what the box produces.

With the lowest and highest notes only provided for certain scales, the need to transpose a tune before committing it to paper is evident. The midi-to-moshi tool visualizes which notes will be played by overlapping them on the grey area (the notes available on the music box) and highlighting the notes outside of this in red. Since there’s a chromatic region, we have the option of jumping these up or down by an octave if it’s important that they sound, but in many cases this can weirdly distort the melody, so it’s not always a good option.

There’s also an adjustment for horizontal scale. I didn’t quite work out the minimum possible distance between notes of the same pitch, but it’s somewhere around 8mm. Closer together than that, and the second note won’t sound.

As demonstrated in the video, these laser cut paper tapes worked brilliantly, except for the fact that I had to cut them out in <30cm lengths and tape them together. That tape was ultimately the demise of the first mechanism: the thickness of the taped part adds a lot of resistance to winding the handle, which is why eventually the teeth on the pinion gear stripped out.

Left with a broken music box mechanism, I embarked on the more daring journey.

Imagining a Mechanism
There are many concerns that face us. The very first question: what will provide the motive force to pluck the metal comb? Solenoids would be best, in a sense, because they are essentially silent. Just an electromagnet that pulls a metal rod, with a spring to return it to place. Buying thirty solenoids would be quite expensive, although there’s the possibility of making them ourselves. They also need really beefy power supplies.
But more of a concern is how we can squeeze all the motors together, because the pitch of the comb means there’s just 2mm between each note. Unless we had very, very small solenoids, we’d need to have some kind of linkage system that transports the driving force from the distant motors down into the densely-packed comb area.

Another concern is the plucking action itself. It is not sufficient to simply whack the metal comb, the pluck needs to displace the tine, and then release it. A simple push action could do this, but then, some more complicated movement would be needed to draw the plucking rod back to its original position without hitting the tine again. Conceivably we could just hold it forwards, and pull back, plucking it again, when the next note was needed. But this necessitates equivalent pushing and pulling force, which would imply two solenoids per note – yikes!

I was also against directly plucking the comb because of geometry. The plucking action is at 90 degrees to the comb plane, so we either need to transfer the force through 90 degrees by linkages, or mount the motors above or below it. The sound quality depends enormously on being able to couple the comb firmly to the table it’s sitting on (playing the music box in your hand is almost inaudible).

So, solenoids? Stepper motors? Ultimately I decided to go with hobby servos, because the 9g ones are available for £1 each, which includes, of course, positional feedback, and the driving transistors, so they can be controlled directly from a microprocessor. The disadvantages are that the gear train is relatively noisy, and the servo arms still need some mechanism to linearly pluck the tine.

The original mechanism has a series of metal wafers on a shaft with plastic spacers. The shaft rotates, and the wafers are gently dragged around by friction, until the protruding tabs hit the paper tape. When a hole in the paper tape passes above, the wafers can rotate a little more, and from there the hole in the tape will catch the tab and continue to pull it for the rest of the quarter-turn. The tab 90 degrees away from the one being pulled is the one that plucks the metal comb.

So, if we keep that whole assembly in place, minus the paper tape, assuming the shaft is still driven we can pluck any note with a single forwards action. Using the wafers and friction drive of the original mechanism lets us both turn the force through 90 degrees, and also avoids the double-pluck problem, as the wafers only rotate in one direction.

If you have watched the video, you’ll know the arrangement I ultimately went with, but there were many iterations before I settled with that design.

I laser cut plastic fingers to actually do the pushing of the tabs, I used nominally 2mm thick acrylic. The pitch of the comb is 2mm too. So I should have ended up with lengths of plastic which were a perfect 2mm square in profile, but there were a few things that hindered this. The acrylic turned out to be only about 1.8mm thick. Also, there’s the kerf of the laser to contend with, which depends on how well it was in focus. And, cutting out lots of fingers next to each other causes the plastic to warm up and deform.

Well, the solution to the first problem is to keep every finger upright, so the uncontrollable dimension (the initial thickness of the sheet) is in a plane that doesn’t matter. The second fix is to account for the kerf. This is hard, because if the width isn’t spot on the error will accumulate. Because it’s only 2mm, I didn’t think there was room for any supporting structure between the fingers, so it’s only the fingers on either side that hold any given finger in the right place. Well, having cut out a few fingers that were too wide, and a few that were too small, I measured the ratio between their inaccuracies and interleaved them in a ratio to counteract it. I think it was three fat fingers, followed by one thin one, followed by another three fat ones, etc. By doing this I had perfect control of the error. A snagging point is that the fingers now have specific places, so removing all of them means taping them together so we don’t lose their order.

The other problem I mentioned, about the plastic deforming due to heat, is easy to compensate for. At the very simplest you could just wait for it to cool down between cuts, or space out the pieces (which is wasteful of plastic), but the best solution is to change the order in which they’re cut out. Something like 1, 5, 9, 3, 7… is enough to let things cool down.”

Link to article