Running Puredata patches on Bela » History » Version 11

Giulio Moro, 2016-02-06 12:20 AM

1 1 Christian Heinrichs
h1.  Compiling Puredata patches on Bela
2 1 Christian Heinrichs
3 1 Christian Heinrichs
Here's a quick guide to compiling Pd patches on Bela. Currently this only works on OSX and Linux, but Windows support will be coming soon.
4 1 Christian Heinrichs
5 2 Christian Heinrichs
You can also access the slides from the latest Bela workshop on compiling Pd patches at the following link: https://goo.gl/59hShW This also includes some handy tips for handling Bela's sensor inputs using Puredata.
6 1 Christian Heinrichs
7 1 Christian Heinrichs
h2.  Getting everything up and running
8 1 Christian Heinrichs
9 1 Christian Heinrichs
Follow the following steps to get everything up and running on your Beaglebone Black:
10 1 Christian Heinrichs
11 1 Christian Heinrichs
*1. Download the project archive from https://code.soundsoftware.ac.uk/attachments/download/1723/bela_4-12-2015.zip*
12 1 Christian Heinrichs
13 1 Christian Heinrichs
* Extract the archive (and remember where you extracted it to)
14 1 Christian Heinrichs
15 1 Christian Heinrichs
*2. Make sure python is installed:*
16 1 Christian Heinrichs
17 1 Christian Heinrichs
* Type `which python` in a terminal window. If not installed, follow instructions here: https://wiki.python.org/moin/BeginnersGuide/Download
18 1 Christian Heinrichs
19 1 Christian Heinrichs
* Install the most up-to-date version of the *requests* python package (version 2.7.0). You can get it from http://docs.python-requests.org/en/latest/user/install/
20 1 Christian Heinrichs
     or typing the following in a terminal window (make sure it is not currently installed):
21 1 Christian Heinrichs
22 1 Christian Heinrichs
@curl -OL https://github.com/kennethreitz/requests/zipball/master && unzip master && cd kenneth* && sudo python setup.py install@
23 8 Giulio Moro
24 8 Giulio Moro
if the above does not work, try this:
25 8 Giulio Moro
26 8 Giulio Moro
<pre>curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"
27 9 Giulio Moro
sudo python get-pip.py #install pip packet manager for python
28 9 Giulio Moro
pip install request
29 8 Giulio Moro
</pre>
30 1 Christian Heinrichs
*3. Create an account on enzienaudio.com:*
31 1 Christian Heinrichs
32 1 Christian Heinrichs
* Go to http://www.enzienaudio.com
33 1 Christian Heinrichs
34 1 Christian Heinrichs
* Click *Login* on the top right corner of the page
35 1 Christian Heinrichs
36 1 Christian Heinrichs
* Create a new account
37 1 Christian Heinrichs
38 1 Christian Heinrichs
* Create a new patch and call it **bbb** _(N.B. compiling won't work if you use a different name)_
39 1 Christian Heinrichs
40 5 Christian Heinrichs
*4. Make sure the Beaglebone is plugged in to laptop and open a terminal window:*
41 1 Christian Heinrichs
42 1 Christian Heinrichs
* Navigate to the _scripts_ folder @cd /path/to/folder/scripts@
43 1 Christian Heinrichs
44 1 Christian Heinrichs
* If running for the first time @sh setup_board.sh@
45 1 Christian Heinrichs
46 1 Christian Heinrichs
*5. Compile your first project!*
47 11 Giulio Moro
* If you are on a Mac, you can browse to the BeagleRT/resources/MacOS folder and you will find an app called BelaPdBuild. You just have to drag and drop the folder containing your files on this icon and in a matter of seconds your Pd patch will be running on the Beaglebone.
48 11 Giulio Moro
The first time you do this, you will be prompted for your enzienaudio credentials, which you just created in the steps above.
49 1 Christian Heinrichs
50 11 Giulio Moro
Alternatively:
51 1 Christian Heinrichs
* @./build_pd.sh -i ../projects/heavy/pd/hello-world/@
52 10 Giulio Moro
This script compiles your project, uploads it to the Beaglebone and starts it.
53 10 Giulio Moro
If you run this script with the --watch --screen flags, it will check automatically for edits in your Pd files and refresh your build automatically: no need to touch the terminal again, as long as you keep working in the same folder. For example:
54 10 Giulio Moro
@./build_pd.sh -i ../projects/heavy/pd/hello-world/ --screen --watch@
55 1 Christian Heinrichs
56 1 Christian Heinrichs
*6. Create a new pd project*
57 1 Christian Heinrichs
58 1 Christian Heinrichs
* Create a new folder inside the /pd directory
59 1 Christian Heinrichs
60 1 Christian Heinrichs
* The pd patch must exist in its own folder and be named *_main.pd*. You can use abstractions if you like.
61 1 Christian Heinrichs
62 1 Christian Heinrichs
63 1 Christian Heinrichs
h3.  Using analog ins/outs
64 1 Christian Heinrichs
65 1 Christian Heinrichs
* You can directly address the analog ins and outs from within PD (note that you have to compile and run the patch onto the BeagleBone to receive the data)
66 1 Christian Heinrichs
67 1 Christian Heinrichs
* Use the [adc~] and [dac~] objects to receive and send the data
68 1 Christian Heinrichs
69 1 Christian Heinrichs
* [adc~ 3] refers to Analog Input 0 (first two channels of [adc~] are audio inputs), likewise for [dac~]
70 1 Christian Heinrichs
71 1 Christian Heinrichs
* These inputs are sampled at audio sampling rate, so handle them as you would audio signals. (Use [snapshot~] if you want to turn them into control-rate values)
72 1 Christian Heinrichs
73 1 Christian Heinrichs
* See the example patches in the /pd folder for more information
74 1 Christian Heinrichs
75 1 Christian Heinrichs
76 1 Christian Heinrichs
h2.  Important notes
77 1 Christian Heinrichs
78 6 Christian Heinrichs
* Make sure you aren't using any unsupported objects. For a full list of objects go to https://enzienaudio.com/docs/pdobjects.html
79 1 Christian Heinrichs
80 6 Christian Heinrichs
* The Pd patch must exist in its own folder and be named *_main.pd*. You can use abstractions if you like.
81 1 Christian Heinrichs
82 7 Christian Heinrichs
* See the example pd patches for more information.
83 1 Christian Heinrichs
84 1 Christian Heinrichs
85 1 Christian Heinrichs
*Have fun!*