Mercurial > hg > beaglert
diff examples/04-Audio/FFT-phase-vocoder/render.cpp @ 544:cdabbaf3a252 prerelease
Updated Audio examples for audioOutChannels etc.
author | Robert Jack <robert.h.jack@gmail.com> |
---|---|
date | Fri, 24 Jun 2016 13:32:07 +0100 |
parents | 1cec96845a23 |
children |
line wrap: on
line diff
--- a/examples/04-Audio/FFT-phase-vocoder/render.cpp Fri Jun 24 13:19:52 2016 +0100 +++ b/examples/04-Audio/FFT-phase-vocoder/render.cpp Fri Jun 24 13:32:07 2016 +0100 @@ -121,6 +121,13 @@ // Return true on success; returning false halts the program. 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; + } + midi.readFrom(0); midi.setParserCallback(midiCallback); // Retrieve a parameter passed in from the initAudio() call @@ -138,7 +145,7 @@ memset(gOutputBuffer, 0, BUFFER_SIZE * sizeof(float)); // Allocate buffer to mirror and modify the input - gInputAudio = (float *)malloc(context->audioFrames * context->audioChannels * sizeof(float)); + gInputAudio = (float *)malloc(context->audioFrames * context->audioOutChannels * sizeof(float)); if(gInputAudio == 0) return false; @@ -232,7 +239,7 @@ { float* audioOut = context->audioOut; int numAudioFrames = context->audioFrames; - int numAudioChannels = context->audioChannels; + int numAudioChannels = context->audioOutChannels; // ------ this code internal to the demo; leave as is ---------------- // Prep the "input" to be the sound file played in a loop