2014-12-25

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:

t30   
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:

Stand Offs

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

#!/usr/bin/env python2
import urllibtime
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
  urllib.urlopen(url)
  xml f.read()
  #parse the XML
  obj parseString(xml)
  #get the first item
  item obj.getElementsByTagName("item")[0]
  #get the title
  title item.getElementsByTagName("title")[0]
  ttext title.firstChild.nodeValue.encode('utf8')
  #does the title contain 370?
  if "370" in ttext:
    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:

Comments
Name:
not required
Email:
not required (will not be displayed)
Website:
not required (will link your name to your site)
Comment:
required
Please do not post HTML code or bbcode unless you want it to show up as code in your post. (or if you are a blog spammer, in which case, you probably aren't reading this anyway).
Prove you are human by solving a math problem! I'm sorry, but due to an increase of blog spam, I've had to implement a CAPTCHA.
Problem:
1 plus 5
Answer:
required
subscribe
 
2016
2015
2014
2013
2012
2011
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008