1 #include "sonic_reducer.h"
2 
3 /*
4 This routine takes in a data structure that is the output
5 of an fftw FFT operation.  The input to this routine
6 is in the frequency domain.  The power is integrated over
7 NUM_BANDS non-overrlapping frequency bands.  These band
8 energies are returned to the caller in the array be[].
9 */
10 
calc_band_energies(fftw_complex * out,double * be)11 void calc_band_energies(fftw_complex *out, double *be) {
12 	int xovr[NUM_BANDS + 1] = {3, 15, 90, 600, 5000};
13 	int b;
14 	for(b = 0; b < NUM_BANDS; b++) {
15 		int i;
16 		be[b] = 0;
17 		for (i = xovr[b]; i < xovr[b+1]; i++) {
18 		double re, im;
19 			re = out[i][0];
20 			im = out[i][1];
21 			be[b] += re*re + im*im;
22 		}
23 		be[b] /= CHUNKSAMPS;
24 		be[b] = sqrt(be[b]);
25 	} /* post: be[] is full of the band energies */
26 }
27