# HG changeset patch # User Robert Jack # Date 1466771769 -3600 # Node ID a11814e864a872a525b7444f12e131efe8d0e7c5 # Parent cdabbaf3a25201bc039a460dd83e189fc8dd1a54 Tremolo updated diff -r cdabbaf3a252 -r a11814e864a8 examples/04-Audio/tremolo/render.cpp --- a/examples/04-Audio/tremolo/render.cpp Fri Jun 24 13:32:07 2016 +0100 +++ b/examples/04-Audio/tremolo/render.cpp Fri Jun 24 13:36:09 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);