Mercurial > hg > beaglert
diff examples/01-Basics/passthrough/render.cpp @ 528:5c8f46fcd4d0 API-update
Updated BelaContext to use separate values for in/ou channels
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Thu, 23 Jun 2016 18:17:35 +0100 |
parents | 1cec96845a23 |
children | bfcbeb437869 |
line wrap: on
line diff
--- a/examples/01-Basics/passthrough/render.cpp Thu Jun 23 18:15:26 2016 +0100 +++ b/examples/01-Basics/passthrough/render.cpp Thu Jun 23 18:17:35 2016 +0100 @@ -22,37 +22,45 @@ */ #include <Bela.h> -#include <rtdk.h> +#include <Scope.h> + +Scope scope; bool setup(BelaContext *context, void *userData) { // Nothing to do here... + printf("%d %d\n", context->audioInChannels, context->audioOutChannels); + scope.setup(8, 44100); return true; } void render(BelaContext *context, void *userData) { + static const unsigned int audioChannels = min(context->audioInChannels, context->audioOutChannels); + static const unsigned int analogChannels = min(context->analogInChannels, context->analogOutChannels); + // Simplest possible case: pass inputs through to outputs for(unsigned int n = 0; n < context->audioFrames; n++) { - for(unsigned int ch = 0; ch < context->audioChannels; ch++){ + for(unsigned int ch = 0; ch < audioChannels; ch++){ // Two equivalent ways to write this code // The long way, using the buffers directly: - // context->audioOut[n * context->audioChannels + ch] = - // context->audioIn[n * context->audioChannels + ch]; + // context->audioOut[n * context->audioOutChannels + ch] = + // context->audioIn[n * context->audioInChannels + ch]; // Or using the macros: audioWrite(context, n, ch, audioRead(context, n, ch)); } } - // Same with analog channelss + // Same with analog channels for(unsigned int n = 0; n < context->analogFrames; n++) { - for(unsigned int ch = 0; ch < context->analogChannels; ch++) { + for(unsigned int ch = 0; ch < analogChannels; ch++) { // Two equivalent ways to write this code // The long way, using the buffers directly: - // context->analogOut[n * context->analogChannels + ch] = context->analogIn[n * context->analogChannels + ch]; + // context->analogOut[n * context->analogOutChannels + ch] = + // context->analogIn[n * context->analogInChannels + ch]; // Or using the macros: analogWrite(context, n, ch, analogRead(context, n, ch));