Mercurial > hg > beaglert
diff projects/audio_in_FFT/render.cpp @ 14:06f93bef7dd2
Updated remaining examples to new API
author | andrewm |
---|---|
date | Fri, 23 Jan 2015 15:35:10 +0000 |
parents | 09f03ac40fcc |
children | a6d223473ea2 |
line wrap: on
line diff
--- a/projects/audio_in_FFT/render.cpp Fri Jan 23 15:17:09 2015 +0000 +++ b/projects/audio_in_FFT/render.cpp Fri Jan 23 15:35:10 2015 +0000 @@ -13,7 +13,6 @@ int gFFTSize; float gFFTScaleFactor = 0; -int gNumChannels; int gReadPointer = 0; int gWritePointer = 0; @@ -33,14 +32,15 @@ // // Return true on success; returning false halts the program. -bool initialise_render(int numChannels, int numMatrixFramesPerPeriod, - int numAudioFramesPerPeriod, float matrixSampleRate, - float audioSampleRate, void *userData) +bool initialise_render(int numMatrixChannels, int numAudioChannels, + int numMatrixFramesPerPeriod, + int numAudioFramesPerPeriod, + float matrixSampleRate, float audioSampleRate, + void *userData) { // Retrieve a parameter passed in from the initAudio() call gFFTSize = *(int *)userData; gFFTScaleFactor = 1.0f / (float)gFFTSize; - gNumChannels = numChannels; timeDomainIn = (ne10_fft_cpx_float32_t*) NE10_MALLOC (gFFTSize * sizeof (ne10_fft_cpx_float32_t)); timeDomainOut = (ne10_fft_cpx_float32_t*) NE10_MALLOC (gFFTSize * sizeof (ne10_fft_cpx_float32_t)); @@ -61,7 +61,7 @@ uint16_t *matrixIn, uint16_t *matrixOut) { for(int n = 0; n < numAudioFrames; n++) { - timeDomainIn[gReadPointer].r = (ne10_float32_t) ((audioIn[n*gNumChannels] + audioIn[n*gNumChannels+1]) * 0.5); + timeDomainIn[gReadPointer].r = (ne10_float32_t) ((audioIn[n*gNumAudioChannels] + audioIn[n*gNumAudioChannels+1]) * 0.5); timeDomainIn[gReadPointer].i = 0; if(++gReadPointer >= gFFTSize) @@ -78,8 +78,8 @@ gWritePointer = 0; } - for(int channel = 0; channel < gNumChannels; channel++) - audioOut[n * gNumChannels + channel] = (float) timeDomainOut[gWritePointer].r * gFFTScaleFactor; + for(int channel = 0; channel < gNumAudioChannels; channel++) + audioOut[n * gNumAudioChannels + channel] = (float) timeDomainOut[gWritePointer].r * gFFTScaleFactor; gWritePointer++; } }