Mercurial > hg > beaglert
diff examples/04-Audio/tremolo/render.cpp @ 547:a2096488a21a prerelease
Merge
author | chnrx <chris.heinrichs@gmail.com> |
---|---|
date | Fri, 24 Jun 2016 14:12:22 +0100 |
parents | a11814e864a8 |
children |
line wrap: on
line diff
--- a/examples/04-Audio/tremolo/render.cpp Fri Jun 24 14:11:32 2016 +0100 +++ b/examples/04-Audio/tremolo/render.cpp Fri Jun 24 14:12:22 2016 +0100 @@ -30,6 +30,12 @@ bool setup(BelaContext *context, void *userData) { + // Check that we have the same number of inputs and outputs. + if(context->audioInChannels != context->audioOutChannels || + context->analogInChannels != context-> analogOutChannels){ + printf("Error: for this project, you need the same number of input and output channels.\n"); + return false; + } gInverseSampleRate = 1.0 / context->audioSampleRate; gPhase = 0.0; @@ -50,7 +56,7 @@ if(gPhase > 2.0 * M_PI) gPhase -= 2.0 * M_PI; - for(unsigned int channel = 0; channel < context->audioChannels; channel++) { + for(unsigned int channel = 0; channel < context->audioOutChannels; channel++) { // Read the audio input and half the amplitude float input = audioRead(context, n, channel) * 0.5; // Write to audio output the audio input multiplied by the sinewave @@ -60,7 +66,7 @@ // Nested for loops for 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 < context->analogOutChannels; ch++) { // Read analog channel 0 and map the range from 0-1 to 0.25-20 // use this to set the value of gFrequency gFrequency = map(analogRead(context, n, 0), 0.0, 1.0, 0.25, 20.0);