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.
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
#!/usr/bin/env python2 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
while looping: #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') f.write("sudo_modprobe.smn") f.close() looping = False
print time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) #sleep for 5 minutes time.sleep(300)
So now, within 5 minutes of the final episode being released, my Spiel device will play: