Tag Archives: music

Pics & video of my Geiger counter powered ambient music demo @ Maker Faire

IMG_5420.jpg
(photo credit: alvaroprieto)

This year I decided (in true last-minute fashion) to build a couple demos to show off my Geiger Counter kit at the Maker Faire Bay Area. One of these demos used my Geiger Counter kit to create ambient music:

(Thanks to @j_jwalrus for the interview and video!)

I used a five MightyOhm Geiger Counter kits, an Arduino Uno R3, a Sparkfun Music Instrument Shield, and an Adafruit Protoshield to make the demo.

Last minute project for the Maker Faire

The PULSE output of each Geiger counter is connected to one input of a 74LS04 hex inverter on the Protoshield. Each time a Geiger counter detects a radioactive decay, it sends a 0.1ms 3V high pulse to one input of the inverter. The 74LS04 functions as a level shifter and outputs an (inverted) 5V pulse that is suitable for driving an ordinary (5V) Arduino.

Five outputs of the 74LS04 are connected to input pins on the Arduino. For convenience, I used Analog inputs 0-1 as digital input pins. The rest of the gates are connected to digital pins 10-12.

I used the PinChangeInt library on the Arduino to trigger an interrupt handler every time a falling edge is detected on one of the geiger inputs. This interrupt handler stores the pin number to a variable and sets a flag to tell the main() function that something has happened.

The main() loop polls the interrupt flag and waits for something to happen. When it detects that an interrupt has occured, it sends a “Note On” midi message to the Music Instrument Shield, using the SoftwareSerial library built in to Arduino 1.0. I had to hack the library a bit to get it to work in conjuction with the PinChangeInt library, since the SoftwareSerial library automatically installs interrupts for all pins (bad, bad SoftwareSerial!)

The value of the note depends on which Geiger counter triggered the interrupt. In the video I am using note ‘C’ over five octaves, centered around middle C (midi note 60). (I am not a musician, but this seemed to provide a pleasing sound that wouldn’t annoy me or my neighbors at the Faire too much.)

The Arduino sketch is a complete disaster right now, having been thrown together at the last minute, but I plan to clean it up and post it soon.

Things I learned while creating this demo:

  • Sparkfun doesn’t include stacking headers with their shields unless you buy them in retail packaging. $30 in overnight shipping fixed that.
  • Arduino is still a pain to program for if you do anything moderately unusual, like try to use two libraries together that both use pin change interrupts.
  • You can get away without issuing “Note Off” commands for midi instruments that fully decay. (I think the MIDI spec frowns on this, but it works on the Sparkfun shield, at least.) This greatly simplified programming the demo, so I took advantage of it!

Building a Wifi Radio – Part 5, Let’s Make Some Noise!

This is the fifth part of an ongoing series at mightyOhm about building a low cost, open source streaming internet radio.  If you haven’t already, check out the previous parts below for some background about the project.

Building a Wifi Radio – Part 1, Introduction

Building a Wifi Radio – Part 2, Choosing an Embedded Platform

Building a Wifi Radio – Part 3, Hacking the Asus WL-520GU

Building a Wifi Radio – Part 4, Installing OpenWrt

Note:

The instructions that follow assume that you have an Asus WL-520GU wireless router with the following modifications: an externally accessible serial port, OpenWrt installed and working, and a configured network connection on the router.  If not, check out the previous parts of the series to learn more.

Using opkg to customize OpenWrt:

OpenWrt includes a utility called opkg that allows the end user to easily add and remove optional software packages.  These packages include functionality that is not a part of the OpenWrt base image, such as hardware drivers (including USB), optional software, and utilities.  Most packages are not installed by default (after all, the router only contains 4MB of flash storage).  The OpenWrt Community Wiki includes a very helpful page about Packages that contains a lot of useful information about configuring and using opkg.

Before we can use opkg we need to configure it.  The file /etc/opkg.conf contains a few options, including the URL of the server opkg uses to find and download packages.  We need to change this server from the default by modifying the config file:

root@OpenWrt:~# vi /etc/opkg.conf

Modify the first line to look like this:

src/gz snapshots http://mightyohm.com/files/kamikaze-2.4/packages/mipsel 
dest root /
dest ram /tmp
lists_dir ext /var/opkg-lists

You can also download the complete set of packages and set up a server of your own for opkg to access.  I have had great success using the apache server included with OS X, but I won’t cover the setup here.

The following command tells opkg to fetch a list of available packages from the server:

root@OpenWrt:~# opkg update

You should see the following response:

Downloading http://mightyohm.com/files/kamikaze-2.4/packages/mipsel/Packages.gz
Connecting to mightyohm.com (72.32.209.132:80)
Packages.gz          100% |*******************************|  8326  --:--:-- ETA
Inflating http://mightyohm.com/files/kamikaze-2.4/packages/mipsel/Packages.gz
Updated list of available packages in /var/opkg-lists/snapshots
Signiture check for snapshots skipped because GPG support was not enabled in this build

Now we can start installing packages.  To access our USB-audio converter, we need to install USB 1.1 (OHCI) support and some sound drivers:

root@OpenWrt:~# opkg install kmod-usb-audio kmod-usb-ohci

This should automatically install kmod-usb-core and kmod-sound-core, but if not you can also install them manually with the opkg install command.

At this point you should insert the USB-audio converter if you haven’t already.  Then reboot the router:

root@OpenWrt:~# reboot

As the router is booting again, watch for new status messages like these:

...
usb-ohci.c: USB OHCI at membase 0xb8003000, IRQ 6
usb-ohci.c: usb-00:03.0, PCI device 14e4:471a
usb.c: new USB bus registered, assigned bus number 1
usb.c: registered new driver audio
audio.c: v1.0.0:USB Audio Class driver
usbaudio: device 2 audiocontrol interface 0 has 1 input and 1 output AudioStreaming interfaces
usbaudio: device 2 interface 2 altsetting 1 channels 1 framesize 2 configured
usbaudio: valid input sample rate 48000
usbaudio: valid input sample rate 44100
usbaudio: device 2 interface 2 altsetting 1: format 0x00000010 sratelo 44100 sratehi 48000 attributes 0x01
...
usbaudio: registered dsp 14,3
usbaudio: constructing mixer for Terminal 6 type 0x0301
...

If you see this, the USB-audio converter is most likely working and the correct drivers have been loaded.  At this point the green LED inside the USB-audio converter should be lit, another sign that everything is working correctly.

Installing mpd:

To actually play some tunes we need to install some additional software.  We can use opkg to do this, as follows:

root@OpenWrt:~# opkg update

root@OpenWrt:~# opkg install mpd mpc

This command installs mpd, the music player daemon.  mpd is an open source music server that can be accessed locally or across a network by using a variety of clients, which are available for many different platforms.  This includes the command line client mpc which is also now installed on the router.

mpd requires some setup before we can use it:

root@OpenWrt:~# cd ~
root@OpenWrt:~# mkdir .mpd
root@OpenWrt:~# mkdir music
root@OpenWrt:~# mkdir .mpd/playlists
root@OpenWrt:~# vi /etc/mpd.conf

Scroll down and look for the audio_output section of the mpd configuration file, and change the reference to /dev/dsp to make it look like this:

# An example of an OSS output:
#
audio_output {
        type                    "oss"
        name                    "My OSS Device"
        device                  "/dev/sound/dsp"
        format                  "44100:16:2"
}

There are many other options you can play with; mpd is very powerful.  There is a list of features here and a lot more information on the mpd wiki.

Exit vi, saving the changes to mpd.conf.  Now launch mpd with the following command:

root@OpenWrt:~# mpd

The player should start silently, without errors.  Run mpc and verify that it can talk to the server:

root@OpenWrt:~# mpc
volume:100%   repeat: off   random: off

If you see this, good news, the server is running and we have the ability to control it with mpc!

Now would be a good time to connect speakers or headphones to the USB-audio adapter’s headphone output.  Warning – the initial volume can be VERY LOUD. Don’t wear headphones during testing!  PC speakers with a volume control are best.  Start at a low volume.  (My ears are still ringing!)

We can add a streaming radio server to the playlist by executing

root@OpenWrt:~# mpc add http://relay3.slayradio.org:8000/
adding: http://relay3.slayradio.org:8000/

And finally, the moment of truth:

root@OpenWrt:~# mpc play
http://relay3.slayradio.org:8000/
[playing] #1/1   0:00/0:00 (100%)
volume:100%   repeat: off   random: off
root@OpenWrt:~#

If all goes well, within a few seconds you should hear Slay Radio playing on your headphones or speakers.  The Air light on the router should flicker as traffic crosses the WiFi interface, and the green light on the USB-audio converter should flash repeatedly to indicate that audio is being sent to the device.

If you’ve made it this far, I recommend celebrating with your favorite beverage and enjoying some tunes!  Congratulations!

You can add other servers to the playlist by executing the mpc add command again, and then play them with the mpc play n command, where n is the position of the server in the playlist.  mpc playlist will display the current playlist. mpc help will give you a list of available commands.

One very powerful feature of mpd is that it operates as a server on port 6600 of the router, so it can be controlled from any other device on your local network.  If you download an mpd client such as Theramin, you can control the router remotely from your desktop computer.  There is an excellent client for the iPhone too.

That’s it for part five.  I hope you have enjoyed the series thus far.  In part six, we’ll start writing some scripts to control mpd and talk about options for a user interface.  If you are building a Wifi Radio of your own, I’d love to hear about it – leave a comment below!

Update: Part six is now available.

Blip Festival 2008

Blip Festival 2007

Alex Mauer performing at Blip ’07.


Blip Festival 2008: The Promo from Richard Alexander Caraballo on Vimeo.

Blip Festival 2008 is coming up in just a few weeks, on December 4-7th, in Brooklyn, New York.  The Blip Festival is a yearly event in NYC promoted by The Tank, a performing arts space in lower Manhattan.  Last year was truly epic and featured many prominent artists in the 8-bit/lo-fi music scene, including Alex Mauer, Bitshifter, and my new favorite 8-bit artist, Markus Schrodt.

Here’s a direct link to Markus Schrodt’s latest release, i amar prestar aen.  All of his music is available for download here.

Buy your tickets now, make travel reservations, and I’ll see you in December at Blip!