Not too long about I built a tubular music thingy, and while it is nice and fun to play, I really wanted to automate the playing of some tunes as well as giving myself the ability to play certain tunes at certain times.
To be fair, this was the plan all along and I'm calling this thing "Spiel", which I guess is short for glockenspiel.
Before the tubular music thingy was built, I came up with a fairly plain-text music notation format that I call SMN: the Spiel Music Notation format. In a nutshell, SMN files start with "tNUMBER" where NUMBER is the number of beats per second, and then there will be a series of notes: G a b c d e f g, and rests: r. Both notes are rests will be considered whole notes unless followed by a number.
For example, Sudo Modprobe in SMN would be:
a4 G8 a4 G8 a8
b8 c2 e4 d2 r8
e4 d8 c8 d8 c8
d8 c8 b8 a4 G8
a4 G8 a8 b8
c2-8 b8 G1-2
On To the Build
For the automation, I used the following:
What are these things called? I don't know.
What I do know, is that once the spiky bits are bent down, these things make amazing stand offs for just about any computer build.
Mount the computer and relay board
After the stand offs were put on the Beaglebone Black and the 8 channel relay, the stand offs were hot glued to the frame of the Tubular Music Thingy.
Place the solenoids
More hot glue was used to place the solenoid bell hammers.
When the solenoids are energized, they produce heat, and if they stay energized long enough, they get hot enough to melt the glue.
This led me to write a script called 'heat' that will heat up a solenoid so that I can realign the hammer for a better sound.
Wire it up!
The Beaglebone was wired to the relay (I later changed the beaglebone to relay wiring).
The relay is wired to the solenoids, and the 12V power adapter was spliced into the relay and common ground of the solenoids.
Plug it in and run some code
Here is the finished product, ready to be played, or automated over the network.
What about some code?
The code for controlling Spiel is available at https://gitorious.org/spiel/spiel
The documentation is non-existent, but there are a few .smn files in the SMN directory. If you have any questions about the code, send me an email and I'll help as I can.
My last Linux Outlaws related script
The final episode of the Linux Outlaws is nearly upon us, and I needed a script that will check if the last episode has been released, and if so, trigger the Spiel device to play the Sudo Modprobe melody.
Basically, this is a Final Episode Alarm
import urllib, time
from xml.dom.minidom import parseString
url = "http://feeds.feedburner.com/linuxoutlaws-ogg?format=xml"
#we need to loop for a while
looping = True
#read the URL
f = urllib.urlopen(url)
xml = f.read()
#parse the XML
obj = parseString(xml)
#get the first item
item = obj.getElementsByTagName("item")
#get the title
title = item.getElementsByTagName("title")
ttext = title.firstChild.nodeValue.encode('utf8')
#does the title contain 370?
if "370" in ttext:
f = open('play_smn','w')
looping = False
print time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
#sleep for 5 minutes
So now, within 5 minutes of the final episode being released, my Spiel device will play: