Mercurial > hg > beaglert
diff examples/10-Instruments/d-box/render.cpp @ 543:8f8809c77dda prerelease
updated basics, digital, instruments, extras examples
author | chnrx <chris.heinrichs@gmail.com> |
---|---|
date | Fri, 24 Jun 2016 13:19:52 +0100 |
parents | 8fcfbfb32aa0 |
children |
line wrap: on
line diff
--- a/examples/10-Instruments/d-box/render.cpp Fri Jun 24 13:00:31 2016 +0100 +++ b/examples/10-Instruments/d-box/render.cpp Fri Jun 24 13:19:52 2016 +0100 @@ -159,27 +159,33 @@ bool setup(BelaContext *context, void *userData) { int oscBankHopSize = *(int *)userData; - if(context->analogChannels != 8) { - printf("Error: D-Box needs matrix enabled with 8 channels.\n"); + if(context->analogOutChannels <= 8 || context->analogInChannels <= 8) { + printf("Error: D-Box needs at least 8 analog IO channels.\n"); + return false; + } + + 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; } // Allocate two buffers for rendering oscillator bank samples // One will be used for writing in the background while the other is used for reading // on the audio thread. 8-byte alignment needed for the NEON code. - if(posix_memalign((void **)&gOscillatorBuffer1, 8, oscBankHopSize * context->audioChannels * sizeof(float))) { + if(posix_memalign((void **)&gOscillatorBuffer1, 8, oscBankHopSize * context->audioOutChannels * sizeof(float))) { printf("Error allocating render buffers\n"); return false; } - if(posix_memalign((void **)&gOscillatorBuffer2, 8, oscBankHopSize * context->audioChannels * sizeof(float))) { + if(posix_memalign((void **)&gOscillatorBuffer2, 8, oscBankHopSize * context->audioOutChannels * sizeof(float))) { printf("Error allocating render buffers\n"); return false; } gOscillatorBufferWrite = gOscillatorBuffer1; gOscillatorBufferRead = gOscillatorBuffer2; - memset(gOscillatorBuffer1, 0, oscBankHopSize * context->audioChannels * sizeof(float)); - memset(gOscillatorBuffer2, 0, oscBankHopSize * context->audioChannels * sizeof(float)); + memset(gOscillatorBuffer1, 0, oscBankHopSize * context->audioOutChannels * sizeof(float)); + memset(gOscillatorBuffer2, 0, oscBankHopSize * context->audioOutChannels * sizeof(float)); // Initialise the dynamic wavetable used by the oscillator bank // It should match the size of the static one already allocated in the OscillatorBank object @@ -250,7 +256,7 @@ if(gOscBanks[gCurrentOscBank]->state==bank_playing) { - assert(context->audioChannels == 2); + assert(context->audioOutChannels == 2); #ifdef OLD_OSCBANK memset(audioOut, 0, numAudioFrames * * sizeof(float));