Julian Vogels


The Lyrabox is a versatile and handy little musical controller. You can take it on stage and enjoy playing a device that is unique in every way. And I guarantee that you’ll find it pretty awesome! It is small enough to carry it around, and you only have to plug it in to play it. Nothing else needed. Although you can also bring your laptop and have the synthesizer running on there while sending the controller data wirelessly. Further down you can learn how to build your own Lyrabox! Yay!


Disclaimer: This information and the circuits are provided as is without any express or implied warranties. While every effort has been taken to ensure the accuracy of the information contained in this text, the author assumes no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein.

Here’s how it works: The Lyrabox has a big red button. If you press it, an LED starts flashing and you can record whatever you want. Press again and the recording is played back immediately. Well, but you have to turn the hand crank in order to maintain it. Otherwise, it will slow down like an old cassette tape. Now, you can choose what effect you want to apply to the recording by switching a fancy little switch at the side of the Lyrabox. On the top, an infrared light proximity sensor lets you choose how much you want to distort, bitcrush, ringmodulate … well, to destroy the signal, just by approaching your left hand while cranking with your riht hand. Now comes the awesome part: As you crank, the recording is looped, and the effects applied to the recording stay. So you can destroy the recording over and over again, until your signal sounds like a puking alien monkey with rabies.

Let’s look inside. The heart of the Lyrabox is a RaspberryPi (Model B). That little guy is a fully-fledged Linux computer. You can get it for only 35 bucks and is actually pretty powerful, kind of like a netbook. The Pi has an interface called GPIO (General Purpose Input/Output), that you can use to connect any electric component that you like, in a 3.3v circuit. I attached the button, the LED, the switch, a rotary encoder (the hand crank!) and the infrared light sensor (that thing measures the reflection of infrared light by your hand). As the infrared sensor is analog and outputs not only 0 or 1, but a continuous value between them, I had to convert that with an Analog-to-Digital converter (ADC). The ADC has a range of 10 bit, i.e. 1096 discrete steps between off and on. There is also a little capacitor in that circuit that smoothes out the signal a little bit. For the Audio In/Out, I use an external USB Soundcard called “C-Media USB Headset” or so. Because it is only 7$ and it works.

The RaspberryPi executes a shell script on start up which then start a python script and the PureData program. The Python script reads the sensor values from the GPIO by using the Python GPIO library and the Gaugette Library for easy reading of the rotary encoder. The data is then perpared for the use with Libmapper (an awesome program that organizes and maps your OSC messages). Libmapper has an own GUI application, in which the Device LyraBox appears when the script is executed. You could now connect the sensor data to whatever Libmapper-compatible Synthesizer or write your own PureData patch to treat the data. But originally, a specific PureData patch with the Libmapper name LyraSound is connected automatically to the Lyrabox. That happens internally on the Pi, or externally, on the same network, on as many clients you want. How splendid! The PureData patch is responsible of recording audio and signal processing of the recording, as well as of treating the sensor input values that it receives through Libmapper.

Currently, I still experience problems with the quality odf the audio input signal to the RaspberryPi. Whil recording through the ALSA driver works very well, recording through PureData results in a very distorted signal (which is a pity, because I want to destroy it myself)!

Do It Yourself

This is the first time that I give something back to the community. I am very happy to be able to contribute after hvaing read about so many great open source projects. I recommend this DIY project only for people both experienced in handling the RaspberryPi and PureData (or to people with a lot of ambition and faliure tolerance) as the current version still often breaks the audio pipe of the ALSA driver (that’s a PureData problem).

What you need


  • A wooden box (1.50$ at Dollarama)
  • Some standard tools (saw, drill, …)
  • A hand crank (I made mine out of spare parts in the lab)


General Electronics:

  • A red button with enclosure
  • A red LED with enclosure
  • A switch (two stages, or more if you want, but then change the code)
  • A rotary encoder
  • A SHARP analog infrared light proximity sensor
  • Screws for attaching the proximity sensor to the box
  • A MPC3008 Analog-to-Digital Converter
  • A Proto-Board with cobbler
  • A ribbon connector cable for the RaspberryPi
  • A 10 µf capacitor * 220 Ω resitor
  • 4 10 kΩ resistors
  • 2 1 kΩ resistors
  • 1 220 Ω resistor
  • Some shrink-tubing (if you want to be professionally clean in your work)

RaspberryPi and accessories:

  • RaspberryPI 512MB Model B
  • A compatible USB sound card (List of supported sound cards)
  • A micro USB cable
  • A USB charger with 1A-1.2A power output (a good one!)
  • A WIFI adapter, or Ethernet cable (to communicate with the Pi via SSH)
  • You should have a keyboard and HDMI monitor and cable around, for setting up the WIFI connection for the first time



Operating System:

  • Adafruit Occidentalis Image for RaspberryPi (Python GPIO is then preinstalled)

    Update: You could try the CCRMA Satellite Image with preinstalled Pd-Extended

Software on the Pi:

  • PureData Extended
  • LibLo
  • Libmapper
  • Gaugette GPIO library
  • Modifications to rc.local and asound.conf

Software on the Computer:

  • PureData Extended
  • LibLo
  • Libmapper
  • Libmapper GUI

Step-by-step guide

Note: This guide assumes that you have loaded the Occidentalis RPi Image onto the Pi and that you are able to SSH into it. Guides on how to accomplish that are to be found here and here.


First of all, make sure the RaspberryPi fits into the wooden box you bought, and think about the cable outlets of the box. You might want to attach the Pi directly to the box or but some antistatic foam underneath it. Drill holes into the sides of the box, big enough to serve as cable outlets for the power plug and the audio in and out (in my case, I just cut out a little piece so that the external soundcard outlets are aligned with the side of the box).

Now to something completely different. Grab your favourite soldering iron, some solder, wires and the Proto-Board and solder in everything except the sensors and switches according to this scheme:


You can download this scheme by clicking on LyraBox.fzz. Use the Fritzing software to open it.

As you can see, the MCP3008 Analog-to-Digital Converter is there to connect the analog proximity sensor to the Pi. The RaspberryPi has to communicate with four wires to the MCP3008 in order to get the sensor reading right. By default, these pins are 12 for SPICLK (clock), 16 for SPIMISO (master input, slave output), 18 for MOSI (master output, slave input), 22 for SPICS (chip select). The little capacitor in the circuit is not crucial, but helps smoothening the sensor’s input signal to get rid of spikes and noise. It acts just like a Low-Pass Filter. The other electonic components are easier to handle, as they already output a digital signal. That is, they output a series of high and low current, interpreted by the RaspberryPi as zeroes and ones. That is why you can connect the rotary encoder directly to the GPIO pins 7 and 9. The buttons and switches are connected using a so called voltage divider. Sounds fancy, but it is basically just a little special connection in order to prevent an input signal from floating. Learn more about it by looking at the Arduino Button tutorial in the Fritzing Software’s examples in the File menu.

Note: If you want to use another sensor than the proximity sensor, make sure it runs with 3.3 Volt, as the RaspberryPi is only capable of 3.3 Volt in the standard setup. Be careful with voltages, as 5 Volt can cause damage to the Pi’s processor.

After having soldered the base on the Proto-Board, you can now solder some wires to the pins of the button, LED, rotary encoder and switch. The proximity sensor should come with some wires attached to it already. Put some shrink-tubing around the pins and wires and heat ’em up to make sure that they won’t touch at any time.

Now, drill holes into the box where you want the button, switch, LED and rotary encoder to be. they usually have a standard size so you’ll find the right drill by holding it against the component. Drill the holes from the outside of the box, so the wood will be frayed at the inside. You can prevent that by glueing a piece of scotch tape on the inside where you drill, too. Now drill two holes for the screws that will attach the proximity sensot and another little hole for its wires. Now, place the components in the holes and the Proto-Board in the top of the box (upside down). Cut the wires to an adequate length and solder them into the right places in the Proto-Board (that step can be a little difficult!).

Your Lyrabox should now look something like this:


Now attach the ribbon cable to connect the Proto-Board and the RaspberryPi.


Be creative in painting the Lyrabox in neon colours with a zombie face and manufacture the most awesome little hand crank.


Before you can enjoy your own little Lyrabox, you’ll have to install a bunch of software onto your RaspberryPi. As you use the Adafruit Occidenatlis Image, the GPIO library is already installed. Also, you can easily configure your RaspberryPi to work with a Wi-Fi adapter by following this guide, or just use an ethernet cable.

Note: I assume that you are somewhat familiar to the command line on a RaspberryPi, although I explain everything step by step.

1. SSH into your RaspberryPi

On Linux, open the Command Prompt Terminal. On Mac OSX, open the Terminal app (in the Utilities folder). On Windows, download and open PuTTY (http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html). Type in

ping raspberrypi.local

If you get a response like that

64 bytes from raspberrypi.local: icmp_seq=0 ttl=64 time=0.097 ms

everything’s fine. But if it says

ping: sendto: No route to host
ping: sendto: Host is down

Something went wrong with the Bonjour Service that gives the RaspberryPi its name “raspberrypi.local” as a shortcut to whatever IP is was assigned.

To solve that problem, open your Router webpage and lookup the network devices that are connected. Do you see an IP-Address that is unfamiliar? That’s probably your RaspberryPi.

You can also try to list the network devices that your computer sees with

arp -a

and try the IP-addresses listed there by typing something like

ping 192.168.XXX.XXX

If you get back the 64 bytes from 192.168.XXX.XXX: icmp_seq=0 ttl=64 time=0.097 ms you are ready to SSH in. Type

ssh pi@raspberrypi.local

or in the second case

ssh pi@192.168.XXX.XXX

and when prompted with the password, type in the default Password: raspberry Unix never shows you the password you type, not even stars. Your prompt will change to

pi@raspberrypi ~ $

and your are now working remotely on the RaspberryPi command line. Yay! Now change your password in the general configuration by typing

sudo rpi-config

2. Let’s make sure your soundcard works

Attach your soundcard to a free USB slot on your RaspberryPi. Plug in some headphones or speakers and a microphone. We are using the ALSA audio driver. Everything that follows is to configure this driver correctly. In the command line, type in


Hit enter. A little control screen opens. You should see more than one little slider. Press F6. Now you should see the Name of your soundcard.


If it is not the upmost name, the soundcard is not the default card and you have to change that. Type

sudo nano /etc/asound.conf

You should replace the file contents with this:

pcm.!default {
type hw card 0
}ctl.!default {
type hw card 0

Press Ctrl+O, Return and then Ctrl+X to save and quit.

Restart the ALSA driver with

sudo /etc/init.d/alsa-utils restart

Verify any changes with alsamixer

Now, test the sound output with

aplay /usr/share/scratch/Media/Sounds/Vocals/Singer2.wav

The Pi sings! Well it SHOULD. However, the ALSA driver is still under development and the RaspberryPi is not a consumer computer, so if you get stuck here, you should read some forum posts and get into ALSA configuration. Fortunately, there are some nice guides out there if you google the right words.

Let’s try to record something. Type

arecord -f dat -d 10 ~/recording.wav

The RaspberryPi now records a 10 second audio to the file “recording.wav” with DAT quality (48kHz sampling rate, 16 bit resolution). Test the file by typing

aplay ~/recording.wav

You can remove the file with

sudo rm ~/recording.wav

3. Install a bunch of software

As the Occidentalis OS Image running on the RaspberryPi is a fully-fledged Linux distribution, the Advanced Packaging Tool is already preinstalled. With that piece of software, installing and removing programs works like a charm. First update the APT:

sudo apt-get upgrade

upgrades the APT to the newest version and

sudo apt-get update

updates the software repository.

Now you can install the Git Core in order to get the software you need

sudo apt-get install git-core
  PureData Extended

For installing the PureData Extended on the RaspberryPi, you’ll need a lot of patience and maybe even a little bit of luck. Please refer to this guide to install Pd-Extended:


I didn’t test this distribution, but supposedly it works. I build Pd-Extended from source. The installation took about 16 hours.

Note: In the current form, you don’t need Pd-Extended on the RaspberryPi, as the onboard sound synthesis doesn’t work yet. But if you’re trigger happy and want to tackle that problem, I would appreciate it!

Update: After I build the Lyrabox, I found the CCRMA Satellite RaspberryPi Image, which comes with a pre-installed Pd-Extended. I didn’t yet test it, but if it works, that would save you a lot of trouble!


Now we need RPi-Gaugette, the library that lets us read the rotary encoder easily. First, we create a new folder in the home directory.

sudo mkdir ~/py-gaugette

Then, we clone the git repository.

git clone https://github.com/guyc/py-gaugette

Make sure you find the files in the py-gaugette folder cd ~/py-gaugette ls Now, run the setup script.

sudo python setup.py

Next, let’s install LibLo, the main dependancy of Libmapper. We create another folder in the home directory.

sudo mkdir ~/liblo
cd ~/liblo

And clone the repository

git clone git://liblo.git.sourceforge.net/gitroot/liblo/liblo

We install it with the autogen.sh script

sudo make install

Now we can install Libmapper. First, the new folder:

sudo mkdir ~/libmapper
cd ~/libmapper

Let’s get the source files with wget

wget http://idmil.org/pub/software/libmapper/libmapper-0.3.tar.gz

And unpack them

tar -zxvf libmapper-0.3.tar.gz

And install

sudo make install

Note: Libmapper is still in development. If you encounter any difficulties with installing or using the software, please refer to http://libmapper.github.io

  Libmapper PureData Externals

PureData needs the Libmapper object to communicate with other Libmapper devices in the network.
It can also be downloaded on http://libmapper.github.io

Unzip the downloaded file and put it into the PureData folder. Make sure the folder is added to the search path of PureData.
On your RaspberryPi, follow these steps:

sudo mkdir ~/mapper-max-pd
cd ~/mapper-max-pd
git clone git://github.com/malloch/mapper-max-pd.git
  The Libmapper GUI

Get the Libmapper GUI for your Platform from http://libmapper.github.io/downloads.html (“Session Managers”).
  Finally, get the Lyrabox files!

Create a new folder

sudo mkdir ~/Lyrabox
cd ~/Lyrabox

Clone the repository

git clone git://github.com/julianvogels/LyraBox

Move and overwrite the rc.local file (the startup script of the RaspberryPi)

sudo mv ~/Lyrabox/rc.local /etc/rc.local

You should also clone the repository to your personal computer with an installed copy of Pd-Extended, so that you can open the sound synthesis PureData patch on your computer.

Test your setup

1. Without onboard sound synthesis and microphone

  • Make sure you have the electronics connected to the GPIO pins of the Pi via the ribbon cable. Plug in the external sound card and power the Pi.
  • Run the Lyrabox python script cd ~/Lyrabox sudo python lyrabox.py Now open the Libmapper GUI on your computer. You should see a device called /lyrabox.1 with 1 input and 5 outputs on port 9000.
  • Open the mainpatch.pd from the downloaded Lyrabox repository in Puredata Extended.
  • You should now see a second device called /lyraxound.1 in the Libmapper GUI. Click on refresh. Now you should see that the devices are automatically coupled.
  • Start the DSP in PureData. Turn the hand crank. Do you see some numbers change in the number boxes in PureData, some little bang object blink? Awesome!
  • Click down the hand crank button, that resets the sound file. It should start playing. Crank to keep it playing. Now you can switch the switch and apply effects by approaching the proximity sensor!

2. With onboard sound synthesis and microphone (!only for pros because doesn’t work at all yet!)

The sound synthesis doesn’t work yet entirely on the Lyrabox. I still encounter an issue with the ALSA driver telling me that it’s pipe is broken. I think it is mainly due to the CPU intensity of the PureData patch. I would really appreciate if you wanted to look into that problem.

First move the other rc.local file to the /etc/ folder and overwrite

sudo mv ~/Lyrabox/rc.local2 /etc/rc.local

Now that should result in starting the RaspberryPi not only with the python script but also with the PureData script in headless mode like so:

pd-extended -nogui -alsa -alsaadd default -path /home/pi/mapper-max-pd/ -listdev -audioindev 5 -audiooutdev 5 /home/pi/Lyrabox/mainpatch_stipped.pd

This works just like above, only that now the PureData copy is running on the Pi, and Libmapper connects the script and the PureData patch on the Pi. There are several flags set:

  • -nogui: Starts PureData in Headless-Mode (without GUI in the command line)
  • -alsa: Use the ALSA audio driver
  • -alsaadd default: Use the default ALSA device
  • -path /home/pi/mapper-max-pd/: Add Libmapper object folder to search path
  • -listdev: List available devices
  • -audioindev 5: Select audio input device No. 5
  • -audiooutdev 5: Select audio output device No. 5

These are followed by the path to the Pd patch that will be opened.

The first thing to do would be to get the adctest.pd to run on the RaspberryPi with a decent sound quality. In my tests, the sound was horribly distorted when using the adc-object in PureData. However, getting the ADC to work is a crucial step to have the Lyrabox be stand-alone.

Pages: 1 2 3 4 5