chris@552: #N canvas 959 597 692 1046 10; chris@552: #X obj 45 615 dac~ 1 2; chris@552: #X obj 45 574 *~ 0.1; chris@552: #X obj 45 553 osc~ 440; chris@552: #X text 464 21 ............................; chris@552: #X text 464 31 . ____ ._____ _ .......___ .; chris@552: #X text 464 41 .| __ )| ____| |....../ _ |.; chris@552: #X text 464 61 .| |_) | |___| |___ / ___ |.; chris@552: #X text 464 71 .|____/|_____|_____/_/..._|.io; chris@552: #X text 464 81 ............................; chris@552: #X text 464 51 .| __ || __|.| |...../ _| |.; chris@552: #X text 35 32 Using custom render.cpp files; chris@552: #X text 35 42 =============================; chris@552: #X text 35 58 It is possible to modify the default libpd and heavy chris@552: ; chris@552: #X text 35 72 wrapper templates in order to combine c++ code with; chris@552: #X text 35 86 your puredata patches.; chris@552: #X text 35 100 In this example you should hear a tremolo effect being chris@552: ; chris@552: #X text 35 114 applied to the output. This is done by taking the output chris@552: ; chris@552: #X text 35 128 buffer returned from libpd or heavy and applying further chris@552: ; chris@552: #X text 35 142 processing before writing the buffer to the Bela context. chris@552: ; chris@552: #X text 35 156 It is also possible to define more input or output channels chris@552: ; chris@552: #X text 35 170 within the render.cpp file in order to pass auxiliary chris@552: ; chris@552: #X text 35 198 code.; chris@552: #X text 35 184 signals (e.g. envelopes) across the pd patch and the chris@552: c++; chris@552: #X obj 46 716 adc~ 3; chris@552: #X obj 46 738 snapshot~; chris@552: #X obj 97 694 loadbang; chris@552: #X obj 97 716 metro 5; chris@552: #X obj 46 804 * 20; chris@552: #X obj 46 826 + 0.5; chris@552: #X text 94 826 map to exponential range 0.5Hz<->20Hz; chris@552: #X obj 46 848 s tremoloRate; chris@552: #X text 154 848 <<< this receiver doesn't exist in the patch but is chris@552: parsed; chris@552: #X text 36 520 Simple 440Hz sine wave; chris@552: #X text 36 530 ----------------------; chris@552: #X text 36 660 Sending messages to modified render.cpp; chris@552: #X text 36 670 ---------------------------------------; chris@552: #X text 35 211 In this example we are sending float values to a receiver chris@552: ; chris@552: #X text 35 225 named 'tremoloRate' which is parsed by the modified chris@552: ; chris@552: #X text 35 239 render.cpp file and used to control the rate of the chris@552: tremolo; chris@552: #X text 35 253 effect applied to the output.; chris@552: #X obj 46 760 t f f; chris@552: #X obj 46 782 *; chris@552: #X text 35 267 See the render.cpp file in the project folder for the chris@552: libpd; chris@552: #X text 35 282 implementation. The heavy implementation can be found chris@552: inside; chris@552: #X text 35 295 the enclosed /heavy folder. (This is where custom render.cpp chris@552: ; chris@552: #X text 35 309 files for heavy need to be placed when compiling with chris@552: heavy); chris@552: #X text 179 860 by a hook function in the modified render.cpp file. chris@552: ; chris@552: #X text 200 897 Bela_floatHook(const char *source \, float value); chris@552: #X text 180 962 For heavy this is:; chris@552: #X text 179 884 For libpd this function is:; chris@552: #X text 200 973 sendHook( double timestamp \, const char *receiverName chris@552: ; chris@552: #X text 260 986 \, const HvMessage *const m \, void *userData); chris@552: #X text 180 911 Note that in libpd the receiver name needs to be registered chris@552: ; chris@552: #X text 180 925 using the libpd_bind(const char *sym) function (see chris@552: the; chris@552: #X text 180 939 contents of setup()); chris@552: #X text 180 1002 The receiver name does not need to be registered anywhere. chris@552: ; chris@552: #X text 35 324 Search for 'MODIFICATION' (no quotation marks) inside chris@552: either; chris@552: #X text 35 338 of the render files to inspect all the modifications chris@552: that; chris@552: #X text 36 352 were made for this example.; chris@552: #X text 36 386 Running the patch with the modified render.cpp file chris@552: ; chris@552: #X text 36 396 --------------------------------------------------- chris@552: ; chris@552: #X text 36 409 If using libpd \, you can simply run this patch from chris@552: the; chris@552: #X text 36 423 Bela IDE. The system will automatically detect the; chris@552: #X text 36 437 modified file use it instead of the template.; chris@552: #X text 36 457 Similarly \, the build script for the Heavy compiler chris@552: ; chris@552: #X text 36 471 will detect the presence of a render.cpp file inside chris@552: ; chris@552: #X text 36 485 the enclosed /heavy/ folder and bypass the default wrapper. chris@552: ; chris@552: #X connect 1 0 0 1; chris@552: #X connect 1 0 0 0; chris@552: #X connect 2 0 1 0; chris@552: #X connect 23 0 24 0; chris@552: #X connect 24 0 40 0; chris@552: #X connect 25 0 26 0; chris@552: #X connect 26 0 24 0; chris@552: #X connect 27 0 28 0; chris@552: #X connect 28 0 30 0; chris@552: #X connect 40 0 41 0; chris@552: #X connect 40 1 41 1; chris@552: #X connect 41 0 27 0;