Mercurial > hg > beaglert
diff examples/basic_libpd/render.cpp @ 338:1802f99cd77f prerelease
Initial support for thread-safe libpd (stil missing updated libpd binary), untested
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Sun, 05 Jun 2016 21:46:44 +0100 |
parents | 5e2780bfbfed |
children | 69d86429a1cf |
line wrap: on
line diff
--- a/examples/basic_libpd/render.cpp Sun Jun 05 20:28:43 2016 +0100 +++ b/examples/basic_libpd/render.cpp Sun Jun 05 21:46:44 2016 +0100 @@ -12,6 +12,7 @@ #include <PRU.h> #include <stdio.h> #include "z_libpd.h" +#include "z_queued.h" #include <UdpServer.h> #include <Midi.h> @@ -75,9 +76,9 @@ return false; } // init pd - libpd_set_printhook(Bela_printHook); // set this before calling libpd_init - libpd_set_noteonhook(pdnoteon); - libpd_init(); + libpd_set_queued_printhook(Bela_printHook); // set this before calling libpd_init + libpd_set_queued_noteonhook(pdnoteon); + libpd_queued_init(); //TODO: analyse the ASCII of the patch file and find the in/outs to use libpd_init_audio(gChannelsInUse, gChannelsInUse, context->audioSampleRate); @@ -220,6 +221,9 @@ // rt_printf("inW %d\n", inW); if(inW == 0){ //if the buffer is full, process it static int numberOfPdBlocksToProcess = gBufLength/gLibPdBlockSize; + // TODO: see if we can rewrite libpd_process_float so that it takes a buffer + // of interleaved channels of arbitrary length channels rather than a series of + // stacked buffers of size gLibPdBlockSize as it currently does. libpd_process_float(numberOfPdBlocksToProcess, gInBuf, gOutBuf); outR = 0; // reset the read pointer. NOTE: hopefully this is needed only the first time } @@ -263,6 +267,7 @@ void cleanup(BelaContext *context, void *userData) { + libpd_queued_release(); free(gInBuf); free(gOutBuf); }