PureData patch Running on a BeagleBoard from Rafael Vega on Vimeo.
If you don't want to read the whole thing and just want to play a PD patch on your
BeagleBoard, read part 2 of this article.
0. Motivation.
-
There is a large number of open-source software tools for working with audio. From low level programming tools to full-fledged digital audio workstations. On another side, there are musicians, producers and sound designers who use many hardware tools and there are few open-hardware alternatives for musical applications.
-
Audio designers, musicians and producers don't usually have software development skills and need graphic tools for audio processing. Many of them want to take their algorythms to stage or to the studio "in a box".
This is a small step towards the possible development of an open and portable audio processing platform.
1. High level description of the system.
-
The BeagleBoard is an open-hardware, portable, low cost, low power, compact and expandable computer. It is ideal for deploying applications that need a certain amount of processing but don't need all the paraphernalia that a regular computer has (keyboard, display, etc.) A stomp-box is a good example of such an application.
-
Angstrom Linux is a GNU/Linux distribution designed to run on embedded systems such as the BeagleBoard.
-
ALSA (Advanced Linux Audio Architecture) is a part of the Linux operative system that provides a consistent API to work with different audio hardware devices and implements drivers for such devices.
-
JACK Is a system for handling real-time audio and MIDI. It can connect a number of applications to an audio device and allows them to share audio between them. It runs as a system daemon.
-
Xooky Nabox is an application that I wrote in C++ that uses the libpd library to interpret pd patches. It puts pd patches to work as DSP engines and exposes their functionality as a JACK client. In other words, it's an adapter between PD and JACK, without a GUI.
2. How to use.
What you need:
- A BeagleBoard, I used revision C4.
- A 5 volt AC to DC converter.
- A 1GB or larger SD card and a way to connect it to your computer.
- A computer running Mac OS or Linux (you can use one of the many live CD distributions if youu're running something else and don't want to install Linux on your hard drive).
- A PD patch that you want to play with.
Instructions:
1. Connect the SD card to your computer and immediately run sudo dmesg | tail on a terminal to determine the name that your system is giving the SD card.
2. Download this script and run it. This will erase all the data in the card!
1 | sudo ./formatear_tarjeta.sh /dev/sdc |
/dev/sdc is the name that my system assigned to the SD card, it will be different on your system. Alternatively, you can create parted or a similar program to create a two partitions on the card labeled "boot" and "Angstrom" and formated as FT32 and ext4 respectively.
3. Download this file, uncompress it and copy the contained files to the boot partition in your SD card. (the order in which you copy the files is important).
1 2 3 4 | tar xvfz boot.tar.gz sudo cp boot/MLO /media/boot sudo cp boot/u-boot.bin /media/boot sudo cp boot/uImage /media/boot |
4. Download this file, uncompress it and copy the contained files to the Angstrom partition in the SD card.
5. Copy your PD patch to /media/Angstrom/var/xooky/patch.pd
6. Put the SD card on the BeagleBoard, turn the BB on and make some noise :)
3. Building the system from scratch.
3.1. Establish serial communication between the BB and your computer
If your computer does not have a serial port, you need an RS232 to USB cable. Linux systems include a driver for such cables. If you're on Mac OS, you need to get drivers from http://osx-pl2303.sourceforge.net (Snow Leopard) or http://xbsd.nl/2011/07/pl2303-serial-usb-on-osx-lion.html (Lion).
Use an AT/Everex cable to connect the BB to your serial port as described here. If the physical connection is okay, the BB should show up on your system as /dev/tty.PL232<something>. Use the ls /dev/tty* command to find out the identifier that your system assigned to it.
Now, establish serial communication with the board using minicom:
1 | sudo minicom -s |
Follow the configuration screens to set these parameters: 115200 8N1, no flow control.
To verify that there's proper communication between the board and your computer, leave minicom open and connected and power cycle the BB. You should see something similar to the following in minicom:
1 2 3 4 5 6 | U-Boot 2010.03-dirty (Oct 18 2010 - 11:31:58) OMAP3530-GP ES3.1, CPU-OPP2, L3-165MHz, Max clock-720Mhz OMAP3 Beagle board + LPDDR/NAND I2C: ready DRAM: 256 MB NAND: 256 MiB |
2. Install Angstrom Linux==
First, follow steps 1, and 2 of part 2 of this article.
Then, download the boot files from http://www.angstrom-distribution.org/demo/beagleboard and copy them to the boot partition of the SD card as explained in step 3 of part 2.
Now, download the Angstrom distro and the BB kernel modules from http://www.angstrom-distribution.org/demo/beagleboard/ and copy them to the Angstrom partition of the SD card with the following commands:
1 2 3 4 5 6 7 | sudo cp Angstrom-Beagleboard-demo-image..... /media/Angstrom sudo cp modules-2.6.X-rX-beagleboard.tgz /media/Angstrom cd /media/Angstrom sudo tar -jxvf Angstrom-Beagleboard-demo-image.... sudo rm Angstrom-Beagleboard-demo-image.... sudo tar -xvf modules-2.6.X-rX-beagleboard.tgz sudo rm modules-2.6.X-rX-beagleboard.tgz |
Go ahead and put the SC card back in the BB, fire up minicom and power up the BB, you should see Angstrom Linux booting up.
3. Share your computer's internet connection with the BeagleBoard
I chose an IP of198.168.2.202 for the BB and 192.168.2.200 for my computer, you can choose whatever makes sense to you.
First, connect a USB cable between your computer and the BB. Then, using the serial terminal, log in to the linux shell in the BB (root user, empty password) and create the /etc/init.d/local_network file with the following content:
1 2 3 4 | modprobe g_ether host_addr=16:0F:15:5A:E1:21 dev_addr=16:0F:15:5A:E1:20 ifconfig usb0 192.168.2.202 netmask 255.255.255.0 route add default gw 192.168.2.200 echo "nameserver 208.67.222.222" >> /etc/resolv.conf |
and execute:
1 2 | chmod +x /etc/init.d/local_network update-rc.d /etc/init.d/local_network defaults |
Everything is set up on the BB side, now you need to set-up your computer to do packet forwarding or share your internet connection with the BB connected on the USB port. On Mac OS, you can do it using the Network Preference Pane:
On Linux, you can do the same by following the instructions here.
Back on the BB terminal, test the internet connection with wget:
1 | wget `http://elsoftwarehamuerto.org` |
If everything was set up correctly, you can disconnect minicom and the serial cable, leave only the USB connected and ssh from your computer to the BB (It's way more comfortable and simple to do so than using minicom):
1 | ssh root@192.168.2.202 |
4. Installing packages and testing audio i/o
Now that your BB has an active intener connection, you can use Angstrom's package manager to install the stuff needed to start making sounds. First, update the package manager:
1 2 | opkg uodate opkg upgrade |
Then, configure Angstrom to start in mode 3 (command-line only mode) by default. This will ensure that no GUI programs are running that might use the ALSA driver. When you use ALSA, only one program can access the sound card at the same time.
In /etc/inittab:
1 2 | #The default runlevel. id:3:initdefault: |
Now, install the aplay and arecord programs:
1 | opkg install alsa-utils-aplay |
And set the audio levels with alsamixer. (For some reason, the tab key wasn't working for me. You can use f4 and f5 instead):
Left Digital Loopback: Mute
Right Digital Loopback: Mute
DAC2 Analog: 6dB
DAC2 Digital Coarse: 6dB
DAC2 Digital Fine: -10dB
Headset: 6dB
Quit alsamixer and store the levels permanently:
1 | alsactl store |
Now, connect a microphone or any sound source to the audio in jack in the BB, connect a speaker or headphones to the audio out jack, record to a wav file and play it back
1 2 | arecord -t wav -c 2 -r 44100 -f S16_LE -v recorded aplay recorded.wav |
If the file is successfully created and it sounds when you play it, everything is going just fine.
5. Installing and testing JACK
Install the jack packages:
1 2 3 | opkg install jack opkg install jack-dev opkg install jack-examples |
Start the JACK server:
1 | jackd -d alsa -p 256 -n 4 -P hw:0 -C hw:0 -S -r 48000 & |
Start a JACK client (jack_metro is a sample client that implements a metronome)
1 | jack_metro -b 60 & |
And connect jack_metro's audio ports to the system's audio outputs. You should hear the metronome clicking every second.
1 2 3 4 5 6 7 8 9 10 11 | jack_lsp jack_connect system:playback_1 metro:60_bpm jack_connect system:playback_3 metro:60_bpm[cc] <h3>6. Finally, compile and execute XookyNabox</h3> <p>In your computer, download the XookyNabox sources:</p> [cc lang="bash"]git clone git://github.com/rvega/XookyNabox.git git submodule init git submodule update |
Copy them to the BB:
1 | scp -R XookyNabox/ root@192.168.2.202:/home/root/XookyNabox |
And copy a PD patch:
1 | scp -R any/patch.pd root@192.168.2.202:/var/xooky/patch.pd |
Then, in the BB, install the tools for compiling programs:
1 | opkg install task-native-sdk |
And compile XookyNabox:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | cd XookyNabox/vendor/libpd make sudo make install cd ../src make sudo make install[cc] <p>To test it, load a patch and connect to the JACK server:</p> [cc lang="bash"]xooky_nabox /var/xooky/patch.pd & jack_connect xooky_nabox:out1 system:playback_1 jack_connect xooky_nabox:out2 system:playback_3 jack_connect xooky_nabox:in1 system:capture_1 jack_connect xooky_nabox:in2 system:capture_3 |
And you should hear your patch!
The last step is to create an init script so that JACK and XookyNabox start automatically when the BB powers up. In /etc/init.d/xooky
1 2 3 4 5 6 7 8 | jackd -d alsa -p 256 -n 4 -P hw:0 -C hw:0 -S -r 48000 & sleep 3 xooky_nabox /var/xooky/patch.pd & sleep 3 jack_connect xooky_nabox:out1 system:playback_1 jack_connect xooky_nabox:out2 system:playback_3 jack_connect xooky_nabox:in1 system:capture_1 jack_connect xooky_nabox:in2 system:capture_3 |
And execute:
1 2 | chmod +x /etc/init.d/xooky update-rc.d /etc/init.d/xooky defaults |



I have to say that for the last couple of hours i have been hooked by the impressive articles on this website. Keep up the good work.
Thanks for posting this and walking throught the code, I think I will grab a Beagle Board now.
Would this whole thing also work on the Beagle Bone?
I'm not familiar with the BeagleBone but I guess it depends on how processor intensive (DSP) are the pd patches you are loading.
If you're grabbing a BB, I recommend getting one with ethernet. It'll be a lot easier to connect a cable to your router or computer and ssh into it instead of doing the USB network thing.
This XooyNabox looks really interesting, however I can't build it.
Following your instructions, I get:
# cd XookyNabox/vendor/libpd
# make
libpd_wrapper/z_jni.c:10:17: fatal error: jni.h: No such file or directory
When I install the latest official libpd version and I try to make XookyNabox (including /usr/include/pd with the z_libpd.h file in the makefile), I get the following error:
g++ -Wall -g -c -I/usr/include/pd main.cpp -o main.o
main.cpp: In function 'void initLibPd()':
main.cpp:132:39: error: too many arguments to function 'int libpd_init_audio(int, int, int)'
/usr/include/pd/z_libpd.h:30:12: note: declared here
main.cpp: In function 'int process(jack_nframes_t, void*)':
main.cpp:199:36: error: invalid conversion from 'float*' to 'int'
main.cpp:199:36: error: too few arguments to function 'int libpd_process_float(int, float*, float*)'
/usr/include/pd/z_libpd.h:33:12: note: declared here
Perhaps I'm missing something obvious here, I'm not very experienced with any kind of C code (or packaging it) :)
Well, I managed to fix the problems. Building XookyNabox against upstream libpd now. The changes are documented in my fork of the code.
Thank you for your great post! Have you ever tried running a Pure Data patch on an Odroid X or Odroid X2 or any Odroid platform? I am wondering if there would be more processing power available for complicated patches and perhaps smaller buffer sizes possible when using the Odroid platform? Please let me know if you have any experience or opinion on this: http://www.hardkernel.com/renewal_2011/products/prdt_info.php
Thank you!
Frank. I was not aware of the Odroid platform, their tech specs look very impressive. It sure looks like their boards would have more processing power than the Beagle.
Whats up very cool blog!! Man .. Beautiful .. Superb .
. I will bookmark your website and take the feeds also?
I'm satisfied to search out numerous useful information here in the put up, we'd like develop
more strategies on this regard, thank you for sharing.
. . . . .
Here is my web page :: shapewear