pDuino

pDuino is an object created by Hans Christoph Steiner. It handles communication between Arduino microcontrollers and the PureData software. This is important to us because it allows us to integrate electronic components like knobs and switches that can change parameters in our Pd patch. This is what allows us to construct a physical device that can control our patch dynamically.

The first thing to do is to visit:
http://at.or.at/hans/pd/objects.html

1. Download the pDuino object and Firmata firmware.
Firmata is what will be loaded onto the Arduino and allows PureData complete control in terms of turning on digital and analog inputs on the Arduino board.

2. Extract the pDuino archive to a known location on your computer.

3. Create a path in PureData to the archive location so that PureData can reference it and create arduino objects. 
This is done by going to preferences – path – new. You should browse to the folder and apply the changes.

More documentation here.

Using a USB Audio Interface with Rasberry Pi and PureData

Setting up a USB Audio Interface with the pi and using alsamixer to record/play audio from command line.

Some USB interfaces are compatible with the pi. In my case I am using an Audiobox USB.

Using alsamixer will allow you to select your sound card instead of the default hdmi.
to record a file called “rectest” into the current directory…​arecord -D plughw:0 –duration=10 -f cd -vv ~/rectest.wav​

to play it back (using the soundcards output)…
aplay -D plughw:0 ~/rectest.wav

​The 0 after plughw: refers to my interface. It was listed as 0 as you can see here…

alsa

Installing and Configuring PureData with the pi.

Whether sharing internet from ethernet or just plugging right in to your router, install PureData. Note: This will only install PD-Vanilla. To use the Arduino controller we will have to install other packages. This will be discussed later…

sudo apt-get install puredata

vnc

You can see in the image above that I am VNCed into my pi and accessing PureData through the gui. Once PD is done installing it will be listed under the sound and video menu on the pi.

Navigate to preferences in PD and make sure your usb interface is selected as audio input/output.

pd_audio_settings

2. Running PD “headless” on the pi

In order to get patches running on the pi with no need for monitor/keyboard/mouse there are two things that must be accomplished. The first thing is that you need to create a script that tells the pi to open the Pd patch on start up and the second is handled in the Pd patch itself.

Cron jobs are perfect for having Pd patches run at startup.

Once that is complete, you need to add the following string into PD.

This will delay the patch from loading immediately which is required in order for it to run properly on startup.

One other tip…

this is what the post that helped me looked like…

[loadbang]
|
[delay 100]
|
[; pd dsp 1(

Raspberry Pi Setup

Setting up your Pi

This first step is to setup your pi. I am going into detail with each step because I am assuming some out there have not done this and I hope to be a help by breaking down these first steps into detail. That being said, some of these steps are quite basic. If you are familiar with these steps and your pi is already setup you can most likely skip a few of them.

I will also make a point to say the reason why I want to elaborate heavily on these parts is because I use a console cable and ethernet to SSH into my pi at different times. I find this the easiest way to communicate with the pi and work on it dirrectly from laptop. I do not always do this but I find it way easier than having to setup and HDMI monitor keyboard and mouse just for the pi.

1. Download Raspbian Wheezy

This is the webpage where you will find the freshest install of Raspbian Wheezy available. If you have not formatted an SD card for the pi in the past, I recommend looking up a tutorial on how to do it on youtube. You could also use Apple Pi Baker. There are many different examples of how to do this whether you are on Mac, Windows, or Linux. It is quite easy to write a card from the command line.

2. raspi-config

This is a good time to change your password.

This is also quite basic but necessary. Adafruit has a really short and sweet tutorial on how to use raspi-config to setup a lot of different functions. If you plan on using ssh, which we do, you will definitely need to enable it here.

3. Change your Hostname
How to Change your Hostname.

sudo nano /etc/hostname
sudo nano /etc/hosts
sudo /etc/init.d/hostname.sh

replace ‘raspberrypi’

ctrl + x 
sudo reboot 
 
 after restart:
hostname --fqd 

4. Setup Console Cable (not required)
How to use a console cable with Raspberry Pi.

I recommend the console cable as it is easy to use and you don’t need to setup an extra monitor, keyboard, and mouse to work on the pi.

cc

sudo apt-get install screen

Mac software is built in unless you are using Lion or Mountain Lion.
Windows – download Putty. Install PL2303 Drivers.

DO NOT attach the Pi’s USB power adapter. If you would rather power the Pi from your USB power adapter then leave the Red lead from the Serial lead un attached.

Open up a terminal…

screen /dev/cu.PL2303-00001004 115200


Accessing the USB port in the terminal. On a Mac…

Open the terminal then connect the usb lead.
Enter screen /dev/cu.PL into the terminal.
The first time you do this, hit tab to autocomplete the name of your port.
Add 115200 to then end.
I find most success when you recall the screen /dev command with the up arrow key. Once you have your usb devices name, you can unplug, close the terminal and repeat the process.

You can do this with two pis, I have tried. This is where using that Tab command comes in handy.

If you get a ‘Resource busy’ error, try again but enter the command while the pi is booting up.

Note: If it is the first time you boot up your pi from a Raspbian image you need to setup raspi-config using an hdmi monitor and keyboard before you use the console cable.

5. SSHing into the Pi

Using the terminal you have open with the console cable,  type:

ifconfig

This will list the ip address you need to ssh into your pi from your other machine. Open a new terminal window and use the command:

ssh pi@xxx.xxx.xxx

In my case I am using an ethernet cable plugged in between my Pi and my ethernet port on my Macbook. Therefore, I will use the eth0 inet addressthat is listed after using ifconfig!

Once you enter the pi’s password you should be good to go.

6. TightVNCServer

sudo apt-get install tightvncserver

You are going to need to install tightvncserver on your pi to view the gui (desktop environment) through your main machine. After it is done installing you can run:

tightvncserver

and

vncserver :0 -geometry 1920x1080 -depth 24

This will create a virtual instance of your pi’s gui.

You must also download and install tightvncserver on your laptop/computer. You can find a download here.
I use the java version on my macbook.

More Documentation on VNC here.

Pi / Arduino / pD Audio effects processor

This project uses Raspberry Pi, Arduino, and PureData to create a digital multi-fx pedal to process sound in real time. The tutorial covers setup with the pi to both PureData and Arduino.

The end goal is to use PureData (a visual programming language developed for creating multimedia works) to manipulate audio in real time with the help of a usb audio interface. PureData can be easily installed on a Pi and through some setup, an Arduino can be used to control parameters in the PureData patch.

The main focus of this tutorial is to share my path in integrating PD to run “headlessly” on the Raspberry Pi. Despite a more extensive setup with the pi, the lack of computer peripherals and components opens up many opportunities in creating interactive systems.

In this post I will jump right into using a USB audio interface with the pi and move into configuring it with pureData. If you still need to setup your pi, you can check out my extensive posts below.