diff examples/audio_in_FFT/render.cpp @ 373:3bed6b09223c prerelease

Updated NE10 library to the latest version; needs a corresponding update to the /usr/include/ne10 header files on the SD image. Updated examples to compile against new version, and reordered D-Box channels to account for new PRU-based DAC channel reordering.
author andrewm
date Thu, 09 Jun 2016 20:03:09 +0100
parents db2fe4e1b88e
children 24c3a0663d54
line wrap: on
line diff
--- a/examples/audio_in_FFT/render.cpp	Thu Jun 09 18:16:05 2016 +0100
+++ b/examples/audio_in_FFT/render.cpp	Thu Jun 09 20:03:09 2016 +0100
@@ -11,7 +11,7 @@
  * render.cpp
  *
  *  Created on: Oct 24, 2014
- *      Author: parallels
+ *      Author: Andrew McPherson, C4DM, QMUL
  */
 
 /**
@@ -40,16 +40,15 @@
 #include <cmath>
 
 int gFFTSize;
-float gFFTScaleFactor = 0;
 
 int gReadPointer = 0;
 int gWritePointer = 0;
 
 // FFT vars
-ne10_fft_cpx_float32_t* timeDomainIn;
-ne10_fft_cpx_float32_t* timeDomainOut;
-ne10_fft_cpx_float32_t* frequencyDomain;
-ne10_fft_cfg_float32_t cfg;
+static ne10_fft_cpx_float32_t* timeDomainIn;
+static ne10_fft_cpx_float32_t* timeDomainOut;
+static ne10_fft_cpx_float32_t* frequencyDomain;
+static ne10_fft_cfg_float32_t cfg;
 
 // setup() is called once before the audio rendering starts.
 // Use it to perform any initialisation and allocation which is dependent
@@ -64,12 +63,11 @@
 {
 	// Retrieve a parameter passed in from the initAudio() call
 	gFFTSize = *(int *)userData;
-	gFFTScaleFactor = 1.0f / (float)gFFTSize;
 
 	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));
 	frequencyDomain = (ne10_fft_cpx_float32_t*) NE10_MALLOC (gFFTSize * sizeof (ne10_fft_cpx_float32_t));
-	cfg = ne10_fft_alloc_c2c_float32 (gFFTSize);
+	cfg = ne10_fft_alloc_c2c_float32_neon (gFFTSize);
 
 	memset(timeDomainOut, 0, gFFTSize * sizeof (ne10_fft_cpx_float32_t));
 
@@ -91,19 +89,19 @@
 		if(++gReadPointer >= gFFTSize)
 		{
 			//FFT
-			ne10_fft_c2c_1d_float32_neon (frequencyDomain, timeDomainIn, cfg->twiddles, cfg->factors, gFFTSize, 0);
+			ne10_fft_c2c_1d_float32_neon (frequencyDomain, timeDomainIn, cfg, 0);
 
 			//Do frequency domain stuff
 
 			//IFFT
-			ne10_fft_c2c_1d_float32_neon (timeDomainOut, frequencyDomain, cfg->twiddles, cfg->factors, gFFTSize, 1);
+			ne10_fft_c2c_1d_float32_neon (timeDomainOut, frequencyDomain, cfg, 1);
 
 			gReadPointer = 0;
 			gWritePointer = 0;
 		}
 
 		for(unsigned int channel = 0; channel < context->audioChannels; channel++)
-			context->audioOut[n * context->audioChannels + channel] = (float) timeDomainOut[gWritePointer].r * gFFTScaleFactor;
+			context->audioOut[n * context->audioChannels + channel] = (float) timeDomainOut[gWritePointer].r;
 		gWritePointer++;
 	}
 }