chris@521: #N canvas 736 167 442 1518 10; chris@521: #X text 32 20 Using Puredata (libpd) on Bela; chris@521: #X text 32 30 ==============================; chris@521: #X obj 100 538 osc~ 440; chris@521: #X obj 100 560 *~ 0.1; chris@521: #X obj 100 582 dac~; chris@521: #X text 33 501 Here's how you produce a sine wave out of Bela's stereo chris@521: output:; chris@521: #X text 33 611 Similarly \, Bela's stereo input can be addressed as chris@521: follows:; chris@521: #X obj 100 642 adc~; chris@521: #X obj 100 664 dac~; chris@521: #X text 177 653 Audio pass-through; chris@521: #X text 33 1581 Supported objects; chris@521: #X text 33 1591 -----------------; chris@521: #X text 33 1625 All native pd (vanilla) objects can be used.; chris@521: #X text 33 1611 By default Bela uses libpd to run puredata patches. chris@521: ; chris@521: #X text 33 1645 It is also possible to compile pd objects to optimised chris@521: ; chris@521: #X text 33 1658 C code using the Heavy Cloud Compiler \, in which case chris@521: ; chris@521: #X text 33 1671 a different set of objects is supported (see below). chris@521: ; chris@521: #X text 33 701 Analog I/O; chris@521: #X text 33 711 ----------; chris@521: #X text 33 731 Analog inputs and outputs are treated as audio signals chris@521: and; chris@521: #X text 33 745 are addressed using the next 8 channels of the [adc~] chris@521: and; chris@521: #X text 33 759 [dac~] objects:; chris@521: #X obj 36 785 adc~ 3 4 5 6 7 8 9 10; chris@521: #X text 191 785 Analog Inputs 0 \, 1 \, 2 \, 3 \, 4 \, 5 \, 6 \, 7 chris@521: ; chris@521: #X text 191 815 Analog Outputs 0 \, 1 \, 2 \, 3 \, 4 \, 5 \, 6 \, 7 chris@521: ; chris@521: #X obj 36 815 dac~ 3 4 5 6 7 8 9 10; chris@521: #X text 33 853 examples.; chris@521: #X text 33 891 MIDI; chris@521: #X text 33 901 ----; chris@521: #X text 99 921 and; chris@521: #X obj 36 920 notein; chris@521: #X obj 125 920 ctlin; chris@521: #X text 183 921 objects can be used to interface MIDI devices; chris@521: #X text 33 939 with the patch.; chris@521: #X text 33 954 Most MIDI devices can be plugged into the Beaglebone's chris@521: USB; chris@521: #X text 33 968 port and can be used with these objects.; chris@521: #X text 33 839 See the 'BasicAnalogIn' and 'BasicAnalogOut' projects chris@521: for; chris@521: #X text 33 983 See the 'hello-midi' and 'midi-poly-synth' projects chris@521: for more; chris@521: #X text 33 997 for examples.; chris@521: #X obj 57 1058 print; chris@521: #X text 33 1058 The; chris@521: #X text 115 1058 object can be used to log messages directly to Bela's chris@521: ; chris@521: #X text 33 1076 terminal output (e.g. as viewable in the browser IDE). chris@521: ; chris@521: #X obj 100 1102 loadbang; chris@521: #X obj 100 1146 print; chris@521: #X msg 100 1124 Puredata says: 'Hello Bela!'; chris@521: #X text 33 1041 ----------------; chris@521: #X text 33 1031 Debugging: print; chris@521: #X text 33 1191 ----------------; chris@521: #X text 33 1181 Debugging: scope; chris@521: #X text 33 1208 Any signal can be visualised using Bela's browser-based chris@521: ; chris@521: #X text 33 1222 scope. DAC channels 27 \, 28 \, 29 \, 30 address four chris@521: separate; chris@521: #X text 33 1236 scope channels.; chris@521: #X obj 147 1309 dac~ 27 28 29 30; chris@521: #X obj 79 1261 osc~ 440; chris@521: #X obj 149 1261 noise~; chris@521: #X obj 209 1261 osc~ 880; chris@521: #X obj 209 1283 *~; chris@521: #X text 33 1364 visualised.; chris@521: #X text 33 1710 Compiling Puredata patches with Heavy; chris@521: #X text 33 1720 -------------------------------------; chris@521: #X text 33 1740 As an alternative to libpd \, Puredata patches can chris@521: be; chris@521: #X text 33 1754 converted into optimised C code using the Heavy Cloud chris@521: ; chris@521: #X text 33 1768 Compiler by Enzien Audio. The resulting code can result chris@521: ; chris@521: #X text 33 1782 in large increases in performance and is therefore chris@521: well; chris@521: #X text 33 1796 suited for complex patches and final stages of development. chris@521: ; chris@521: #X text 33 1810 We recommend to use libpd for prototyping and less chris@521: CPU; chris@521: #X text 33 1824 intensive patches.; chris@521: #X text 33 1838 See our documentation to learn more about compiling chris@521: patches; chris@521: #X text 33 1852 using Heavy \, and visit enzienaudio.com for more info chris@521: and; chris@521: #X text 33 1866 a list of currently supported objects.; chris@521: #X text 33 1401 Combining Pd and C++; chris@521: #X text 33 1411 --------------------; chris@521: #X text 33 1428 There are many cases where it is useful to combine chris@521: Pd; chris@521: #X text 33 1442 patches with C++ code \, for example when needing to chris@521: ; chris@521: #X text 33 1456 incorporate system calls (e.g. networking) or for; chris@521: #X text 33 1470 sample-accurate dsp processes that are inconvenient chris@521: ; chris@521: #X text 33 1484 to program in Puredata.; chris@521: #X text 33 1517 is used \, which functions as a libpd wrapper. It is chris@521: ; chris@521: #X text 33 1504 When running Puredata patches a template render.cpp chris@521: file; chris@521: #X text 33 1531 possible to modify this file when starting a new pd chris@521: project.; chris@521: #X text 33 1545 See the 'CustomRenderFile' example project for more chris@521: info.; chris@521: #X text 177 560 Sine Wave; chris@521: #X obj 149 1283 *~ 0.1; chris@521: #X obj 279 1261 osc~ 0.5; chris@521: #X text 33 1350 click the scope button to see the above signals being chris@521: ; chris@521: #X text 33 1336 If you're viewing this patch using the Bela IDE you chris@521: can; chris@521: #X text 33 221 Patches can be drag-and-dropped into the browser IDE chris@521: ; chris@521: #X text 33 235 and will be added to the current project that is open. chris@521: ; chris@521: #X text 33 249 In order for the patch to run you need to fulfill the chris@521: ; chris@521: #X text 33 263 following two requirements:; chris@521: #X text 59 285 a) The top-level patch needs to be named '_main.pd' chris@521: ; chris@521: #X text 77 298 (you can still use abstractions); chris@521: #X text 59 315 b) Make sure there is no 'render.cpp' file inside; chris@521: #X text 77 328 the project. A template file will be used instead; chris@521: #X text 77 342 which acts as a wrapper for libpd.; chris@521: #X text 77 355 Alternatively you can modify this wrapper and place chris@521: ; chris@521: #X text 77 368 it inside the project. See below for more information. chris@521: ; chris@521: #X text 33 61 Puredata patches can easily be run on Bela. There are chris@521: two; chris@521: #X text 33 75 ways of doing this: using libpd (which is compatible chris@521: with; chris@521: #X text 33 89 the browser-based IDE) or using the Heavy cloud compiler chris@521: ; chris@521: #X text 33 103 by Enzien Audio.; chris@521: #X text 33 123 This guide focuses mainly on using libpd via the browser chris@521: \,; chris@521: #X text 33 137 however most of the functionality is compatible across chris@521: both; chris@521: #X text 33 151 solutions.; chris@521: #X text 33 191 Loading and running patches in the Bela IDE; chris@521: #X text 33 201 -------------------------------------------; chris@521: #X text 33 471 Audio I/O; chris@521: #X text 33 481 ---------; chris@521: #X text 33 392 If you're viewing this inside the Bela IDE \, then you've chris@521: ; chris@521: #X text 33 406 noticed by now that all pd patches can be previewed chris@521: within; chris@521: #X text 33 420 the browser. Note \, however \, that patches cannot chris@521: currently; chris@521: #X text 33 434 be edited or interacted with inside this preview.; chris@521: #X connect 2 0 3 0; chris@521: #X connect 3 0 4 0; chris@521: #X connect 3 0 4 1; chris@521: #X connect 7 0 8 0; chris@521: #X connect 7 1 8 1; chris@521: #X connect 43 0 45 0; chris@521: #X connect 45 0 44 0; chris@521: #X connect 54 0 53 0; chris@521: #X connect 55 0 83 0; chris@521: #X connect 56 0 57 0; chris@521: #X connect 57 0 53 2; chris@521: #X connect 83 0 53 1; chris@521: #X connect 84 0 57 1; chris@521: #X connect 84 0 53 3;