Mercurial > hg > beaglert
changeset 545:a11814e864a8 prerelease
Tremolo updated
author | Robert Jack <robert.h.jack@gmail.com> |
---|---|
date | Fri, 24 Jun 2016 13:36:09 +0100 |
parents | cdabbaf3a252 |
children | a2096488a21a |
files | examples/04-Audio/tremolo/render.cpp |
diffstat | 1 files changed, 8 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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);