Running PureData patches on a Beagle Board.

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.

  1. 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.

  2. 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.

  1. 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.

  2. Angstrom Linux is a GNU/Linux distribution designed to run on embedded systems such as the BeagleBoard.

  3. 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.

  4. 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.

  5. 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 &amp;

Start a JACK client (jack_metro is a sample client that implements a metronome)

1
jack_metro -b 60 &amp;

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 &amp;
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 &amp;
sleep 3
xooky_nabox /var/xooky/patch.pd &amp;
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

71 thoughts on “Running PureData patches on a Beagle Board.

  1. 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?

  2. 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.

  3. 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) :)

  4. Well, I managed to fix the problems. Building XookyNabox against upstream libpd now. The changes are documented in my fork of the code.

  5. 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!

  6. 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.

  7. 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

  8. Your style is so unique in comparison to other folks I've read stuff from. Many thanks for posting when you've got the opportunity, Guess I'll just bookmark this web site.

  9. When someone writes an paragraph he/she keeps the idea of a user in his/her brain that how a
    user can be aware of it. So that's why this paragraph is amazing. Thanks!

  10. l sur la libert锟斤拷 religieuse et la fronti锟斤拷re entre l'锟斤拷glise et les dirigeants state.catholic, y compris le parrain de l'exposition, les chevaliers de colomb, a apport锟斤拷 les reliques mercredi apr锟斤拷s-midi 锟斤拷 la plus ancienne section de la cath锟斤拷drale, construite lorsque le texas 锟斤拷tait un colony.they espagnol dit qu'ils chronom锟斤拷tr锟斤拷s l' l'arriv锟斤拷e des reliques de san antonio dans le film comme un moyen de renforcer l'argument de l'锟斤拷glise que la libert锟斤拷 religieuse est tiss锟斤拷 dans le tissu culturel am锟斤拷ricain, mais perdre plus de terrain 锟斤拷 culture.us laques 锟斤拷v锟斤拷ques ont 锟斤拷t锟斤拷 ouvertement leur opposition 锟斤拷 un mandat f锟斤拷d锟斤拷ral exigeant des organismes confessionnels 锟斤拷 fournir une couverture de contrle des naissances sur les plans d'assurance de leurs employ锟斤拷s. il devait entrer en vigueur en aot et est contest锟斤拷e dans un proc锟斤拷s intent锟斤拷 par 43 entit锟斤拷s catholiqu
    http://www.franklinetmarshallprix.com

  11. I loved as much as you will receive carried out right here.
    The sketch is attractive, your authored subject
    matter stylish. nonetheless, you command get bought an
    edginess over that you wish be delivering the following.
    unwell unquestionably come further formerly again
    since exactly the same nearly very often inside case you shield this
    hike.

    Check out my page - webpage - wordpress.com
    -

  12. Exceptional post however , I was wondering if you
    could write a litte more on this topic? I'd
    be very grateful if you could elaborate a little bit
    further. Cheers!

  13. This is very attention-grabbing, You're an excessively skilled blogger.
    I have joined your rss feed and look forward to searching for more of your excellent post.

    Also, I've shared your site in my social networks

    Feel free to surf to my homepage :: SEO

  14. I don't leave a leave a response, but I read a few of the
    responses on this page Running PureData patches on a Beagle Board.
    | El Software Ha Muerto. I do have 2 questions for you if it's okay.
    Could it be only me or does it look like like some of these responses come across as if they are written by brain dead folks?
    :-P And, if you are posting at additional online sites, I'd like to follow you.
    Would you make a list of all of all your social pages like your
    linkedin profile, Facebook page or twitter feed?

  15. This is critical, as the size, color, shape and text with
    the logo should reflect whatever you asked for, and whatever you will accept as your company logo.
    When you are making a juice from dark, leafy greens, try
    adding a little cucumber. That makes a larger part in the MILLIONS of users downloading torrents every day.

  16. Its like you read my mind! You appear to know a lot about this, like you wrote the book in it or something.
    I think that you can do with some pics to drive the message home a bit, but other
    than that, this is excellent blog. An excellent read.

    I will certainly be back.

  17. As an example, in the event you conduct a quest for anything precise inside
    a filesharing method (including Limewire), youll observe numerous practical information on some of your results.
    Its a good elderly man travels backwards soon enough to when he would be a young handsome man within the 1970s.
    ISO Hunt provides a search engine, scouring other torrent sites to find the best results.

Deja un comentario

Tu dirección de correo electrónico no será publicada. Los campos necesarios están marcados *

*

Puedes usar las siguientes etiquetas y atributos HTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>