chris@521
|
1 #N canvas 736 167 442 1518 10;
|
chris@521
|
2 #X text 32 20 Using Puredata (libpd) on Bela;
|
chris@521
|
3 #X text 32 30 ==============================;
|
chris@543
|
4 #X obj 100 598 osc~ 440;
|
chris@543
|
5 #X obj 100 620 *~ 0.1;
|
chris@543
|
6 #X obj 100 642 dac~;
|
chris@543
|
7 #X text 33 561 Here's how you produce a sine wave out of Bela's stereo
|
chris@521
|
8 output:;
|
chris@543
|
9 #X text 33 671 Similarly \, Bela's stereo input can be addressed as
|
chris@521
|
10 follows:;
|
chris@543
|
11 #X obj 100 702 adc~;
|
chris@543
|
12 #X obj 100 724 dac~;
|
chris@543
|
13 #X text 177 713 Audio pass-through;
|
chris@543
|
14 #X text 33 1791 Supported objects;
|
chris@543
|
15 #X text 33 1801 -----------------;
|
chris@543
|
16 #X text 33 1835 All native pd (vanilla) objects can be used.;
|
chris@543
|
17 #X text 33 1821 By default Bela uses libpd to run puredata patches.
|
chris@521
|
18 ;
|
chris@543
|
19 #X text 33 1855 It is also possible to compile pd objects to optimised
|
chris@521
|
20 ;
|
chris@543
|
21 #X text 33 1868 C code using the Heavy Cloud Compiler \, in which case
|
chris@521
|
22 ;
|
chris@543
|
23 #X text 33 1881 a different set of objects is supported (see below).
|
chris@521
|
24 ;
|
chris@543
|
25 #X text 33 761 Analog I/O;
|
chris@543
|
26 #X text 33 771 ----------;
|
chris@543
|
27 #X text 33 791 Analog inputs and outputs are treated as audio signals
|
chris@521
|
28 and;
|
chris@543
|
29 #X text 33 805 are addressed using the next 8 channels of the [adc~]
|
chris@521
|
30 and;
|
chris@543
|
31 #X text 33 819 [dac~] objects:;
|
chris@543
|
32 #X obj 36 845 adc~ 3 4 5 6 7 8 9 10;
|
chris@543
|
33 #X text 191 845 Analog Inputs 0 \, 1 \, 2 \, 3 \, 4 \, 5 \, 6 \, 7
|
chris@521
|
34 ;
|
chris@543
|
35 #X text 191 875 Analog Outputs 0 \, 1 \, 2 \, 3 \, 4 \, 5 \, 6 \, 7
|
chris@521
|
36 ;
|
chris@543
|
37 #X obj 36 875 dac~ 3 4 5 6 7 8 9 10;
|
chris@543
|
38 #X text 33 913 examples.;
|
chris@543
|
39 #X text 33 1101 MIDI;
|
chris@543
|
40 #X text 33 1111 ----;
|
chris@543
|
41 #X text 99 1131 and;
|
chris@543
|
42 #X obj 36 1130 notein;
|
chris@543
|
43 #X obj 125 1130 ctlin;
|
chris@543
|
44 #X text 183 1131 objects can be used to interface MIDI devices;
|
chris@543
|
45 #X text 33 1149 with the patch.;
|
chris@543
|
46 #X text 33 1164 Most MIDI devices can be plugged into the Beaglebone's
|
chris@521
|
47 USB;
|
chris@543
|
48 #X text 33 1178 port and can be used with these objects.;
|
chris@543
|
49 #X text 33 899 See the 'BasicAnalogIn' and 'BasicAnalogOut' projects
|
chris@521
|
50 for;
|
chris@543
|
51 #X text 33 1193 See the 'hello-midi' and 'midi-poly-synth' projects
|
chris@521
|
52 for more;
|
chris@543
|
53 #X text 33 1207 for examples.;
|
chris@543
|
54 #X obj 57 1268 print;
|
chris@543
|
55 #X text 33 1268 The;
|
chris@543
|
56 #X text 115 1268 object can be used to log messages directly to Bela's
|
chris@521
|
57 ;
|
chris@543
|
58 #X text 33 1286 terminal output (e.g. as viewable in the browser IDE).
|
chris@521
|
59 ;
|
chris@543
|
60 #X obj 100 1312 loadbang;
|
chris@543
|
61 #X obj 100 1356 print;
|
chris@543
|
62 #X msg 100 1334 Puredata says: 'Hello Bela!';
|
chris@543
|
63 #X text 33 1251 ----------------;
|
chris@543
|
64 #X text 33 1241 Debugging: print;
|
chris@543
|
65 #X text 33 1401 ----------------;
|
chris@543
|
66 #X text 33 1391 Debugging: scope;
|
chris@543
|
67 #X text 33 1418 Any signal can be visualised using Bela's browser-based
|
chris@521
|
68 ;
|
chris@543
|
69 #X text 33 1432 scope. DAC channels 27 \, 28 \, 29 \, 30 address four
|
chris@521
|
70 separate;
|
chris@543
|
71 #X text 33 1446 scope channels.;
|
chris@543
|
72 #X obj 147 1519 dac~ 27 28 29 30;
|
chris@543
|
73 #X obj 79 1471 osc~ 440;
|
chris@543
|
74 #X obj 149 1471 noise~;
|
chris@543
|
75 #X obj 209 1471 osc~ 880;
|
chris@543
|
76 #X obj 209 1493 *~;
|
chris@543
|
77 #X text 33 1574 visualised.;
|
chris@543
|
78 #X text 33 1920 Compiling Puredata patches with Heavy;
|
chris@543
|
79 #X text 33 1930 -------------------------------------;
|
chris@543
|
80 #X text 33 1950 As an alternative to libpd \, Puredata patches can
|
chris@521
|
81 be;
|
chris@543
|
82 #X text 33 1964 converted into optimised C code using the Heavy Cloud
|
chris@521
|
83 ;
|
chris@543
|
84 #X text 33 1978 Compiler by Enzien Audio. The resulting code can result
|
chris@521
|
85 ;
|
chris@543
|
86 #X text 33 1992 in large increases in performance and is therefore
|
chris@521
|
87 well;
|
chris@543
|
88 #X text 33 2006 suited for complex patches and final stages of development.
|
chris@521
|
89 ;
|
chris@543
|
90 #X text 33 2020 We recommend to use libpd for prototyping and less
|
chris@521
|
91 CPU;
|
chris@543
|
92 #X text 33 2034 intensive patches.;
|
chris@543
|
93 #X text 33 2048 See our documentation to learn more about compiling
|
chris@521
|
94 patches;
|
chris@543
|
95 #X text 33 2061 using Heavy \, and visit enzienaudio.com for more info
|
chris@521
|
96 and;
|
chris@543
|
97 #X text 33 2075 a list of currently supported objects.;
|
chris@543
|
98 #X text 33 1611 Combining Pd and C++;
|
chris@543
|
99 #X text 33 1621 --------------------;
|
chris@543
|
100 #X text 33 1638 There are many cases where it is useful to combine
|
chris@521
|
101 Pd;
|
chris@543
|
102 #X text 33 1652 patches with C++ code \, for example when needing to
|
chris@521
|
103 ;
|
chris@543
|
104 #X text 33 1666 incorporate system calls (e.g. networking) or for;
|
chris@543
|
105 #X text 33 1680 sample-accurate dsp processes that are inconvenient
|
chris@521
|
106 ;
|
chris@543
|
107 #X text 33 1694 to program in Puredata.;
|
chris@543
|
108 #X text 33 1727 is used \, which functions as a libpd wrapper. It is
|
chris@521
|
109 ;
|
chris@543
|
110 #X text 33 1714 When running Puredata patches a template render.cpp
|
chris@521
|
111 file;
|
chris@543
|
112 #X text 33 1741 possible to modify this file when starting a new pd
|
chris@521
|
113 project.;
|
chris@543
|
114 #X text 33 1755 See the 'CustomRenderFile' example project for more
|
chris@521
|
115 info.;
|
chris@543
|
116 #X text 177 620 Sine Wave;
|
chris@543
|
117 #X obj 149 1493 *~ 0.1;
|
chris@543
|
118 #X obj 279 1471 osc~ 0.5;
|
chris@543
|
119 #X text 33 1560 click the scope button to see the above signals being
|
chris@521
|
120 ;
|
chris@543
|
121 #X text 33 1546 If you're viewing this patch using the Bela IDE you
|
chris@521
|
122 can;
|
chris@521
|
123 #X text 33 221 Patches can be drag-and-dropped into the browser IDE
|
chris@521
|
124 ;
|
chris@521
|
125 #X text 33 235 and will be added to the current project that is open.
|
chris@521
|
126 ;
|
chris@521
|
127 #X text 33 249 In order for the patch to run you need to fulfill the
|
chris@521
|
128 ;
|
chris@521
|
129 #X text 33 263 following two requirements:;
|
chris@521
|
130 #X text 59 285 a) The top-level patch needs to be named '_main.pd'
|
chris@521
|
131 ;
|
chris@521
|
132 #X text 77 298 (you can still use abstractions);
|
chris@521
|
133 #X text 59 315 b) Make sure there is no 'render.cpp' file inside;
|
chris@521
|
134 #X text 77 328 the project. A template file will be used instead;
|
chris@521
|
135 #X text 77 342 which acts as a wrapper for libpd.;
|
chris@521
|
136 #X text 77 355 Alternatively you can modify this wrapper and place
|
chris@521
|
137 ;
|
chris@521
|
138 #X text 77 368 it inside the project. See below for more information.
|
chris@521
|
139 ;
|
chris@521
|
140 #X text 33 61 Puredata patches can easily be run on Bela. There are
|
chris@521
|
141 two;
|
chris@521
|
142 #X text 33 75 ways of doing this: using libpd (which is compatible
|
chris@521
|
143 with;
|
chris@521
|
144 #X text 33 89 the browser-based IDE) or using the Heavy cloud compiler
|
chris@521
|
145 ;
|
chris@521
|
146 #X text 33 103 by Enzien Audio.;
|
chris@521
|
147 #X text 33 123 This guide focuses mainly on using libpd via the browser
|
chris@521
|
148 \,;
|
chris@521
|
149 #X text 33 137 however most of the functionality is compatible across
|
chris@521
|
150 both;
|
chris@521
|
151 #X text 33 151 solutions.;
|
chris@521
|
152 #X text 33 191 Loading and running patches in the Bela IDE;
|
chris@521
|
153 #X text 33 201 -------------------------------------------;
|
chris@543
|
154 #X text 33 531 Audio I/O;
|
chris@543
|
155 #X text 33 541 ---------;
|
chris@521
|
156 #X text 33 392 If you're viewing this inside the Bela IDE \, then you've
|
chris@521
|
157 ;
|
chris@521
|
158 #X text 33 406 noticed by now that all pd patches can be previewed
|
chris@521
|
159 within;
|
chris@521
|
160 #X text 33 420 the browser. Note \, however \, that patches cannot
|
chris@521
|
161 currently;
|
chris@521
|
162 #X text 33 434 be edited or interacted with inside this preview.;
|
chris@543
|
163 #X text 33 464 To view the contents of abstractions supplied with a
|
chris@543
|
164 ;
|
chris@543
|
165 #X text 33 477 project in the IDE \, simply go to the project navigator
|
chris@543
|
166 ;
|
chris@543
|
167 #X text 33 490 and open the corresponding patches from there.;
|
chris@543
|
168 #X text 33 951 Digital I/O;
|
chris@543
|
169 #X text 33 961 -----------;
|
chris@543
|
170 #X text 33 981 Digital pins can also be addressed from within a patch.
|
chris@543
|
171 ;
|
chris@543
|
172 #X text 33 994 Unlike analog pins \, digital pins can be set to work
|
chris@543
|
173 as;
|
chris@543
|
174 #X text 33 1007 inputs or outputs and can be read/written as signals
|
chris@543
|
175 or;
|
chris@543
|
176 #X text 33 1020 as messages.;
|
chris@543
|
177 #X text 33 1033 See the 'digital' example for instructions on how to
|
chris@543
|
178 ;
|
chris@543
|
179 #X text 33 1047 initialise \, read and write to digital pins as well
|
chris@543
|
180 as some;
|
chris@543
|
181 #X text 33 1060 usage examples;
|
chris@521
|
182 #X connect 2 0 3 0;
|
chris@521
|
183 #X connect 3 0 4 0;
|
chris@521
|
184 #X connect 3 0 4 1;
|
chris@521
|
185 #X connect 7 0 8 0;
|
chris@521
|
186 #X connect 7 1 8 1;
|
chris@521
|
187 #X connect 43 0 45 0;
|
chris@521
|
188 #X connect 45 0 44 0;
|
chris@521
|
189 #X connect 54 0 53 0;
|
chris@521
|
190 #X connect 55 0 83 0;
|
chris@521
|
191 #X connect 56 0 57 0;
|
chris@521
|
192 #X connect 57 0 53 2;
|
chris@521
|
193 #X connect 83 0 53 1;
|
chris@521
|
194 #X connect 84 0 57 1;
|
chris@521
|
195 #X connect 84 0 53 3;
|