 Timestamp:
 Nov 3, 2007, 2:22:14 PM (13 years ago)
 Branches:
 feature/autosink, feature/constantq, feature/pitchshift, feature/pydocstrings, feature/timestretch, master, pitchshift, sampler, timestretch, yinfft+
 Children:
 a47cd35
 Parents:
 55e030d
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

src/fft.c
r55e030d r01af943 55 55 s>in = AUBIO_ARRAY(real_t,size); 56 56 s>out = AUBIO_ARRAY(real_t,size); 57 s>specdata = (fft_data_t*)fftw_malloc(sizeof(fft_data_t)*size);58 57 /* create plans */ 59 58 #ifdef HAVE_COMPLEX_H 59 s>fft_size = size/2+1; 60 s>specdata = (fft_data_t*)fftw_malloc(sizeof(fft_data_t)*s>fft_size); 60 61 s>pfw = fftw_plan_dft_r2c_1d(size, s>in, s>specdata, FFTW_ESTIMATE); 61 62 s>pbw = fftw_plan_dft_c2r_1d(size, s>specdata, s>out, FFTW_ESTIMATE); 62 63 #else 64 s>fft_size = size; 65 s>specdata = (fft_data_t*)fftw_malloc(sizeof(fft_data_t)*s>fft_size); 63 66 s>pfw = fftw_plan_r2r_1d(size, s>in, s>specdata, FFTW_R2HC, FFTW_ESTIMATE); 64 67 s>pbw = fftw_plan_r2r_1d(size, s>specdata, s>out, FFTW_HC2R, FFTW_ESTIMATE); … … 83 86 for (i=0;i<size;i++) s>in[i] = data[i]; 84 87 fftw_execute(s>pfw); 85 for (i=0; i<size;i++) spectrum[i] = s>specdata[i];88 for (i=0; i < s>fft_size; i++) spectrum[i] = s>specdata[i]; 86 89 } 87 90 … … 92 95 uint_t i; 93 96 const smpl_t renorm = 1./(smpl_t)size; 94 for (i=0; i<size;i++) s>specdata[i] = spectrum[i];97 for (i=0; i < s>fft_size; i++) s>specdata[i] = spectrum[i]; 95 98 fftw_execute(s>pbw); 96 99 for (i=0;i<size;i++) data[i] = s>out[i]*renorm; … … 123 126 void aubio_fft_getnorm(smpl_t * norm, fft_data_t * spectrum, uint_t size) { 124 127 uint_t i; 125 norm[0] = spectrum[0]; 126 for (i=1;i<size/2+1;i++) norm[i] = SQRT(SQR(spectrum[i]) + SQR(spectrum[sizei])); 128 norm[0] = SQR(spectrum[0]); 129 for (i=1;i<size/2;i++) norm[i] = (SQR(spectrum[i]) + SQR(spectrum[sizei])); 130 norm[size/2] = SQR(spectrum[size/2]); 127 131 //for (i=0;i<size/2+1;i++) AUBIO_DBG("%f\n", norm[i]); 128 132 } … … 130 134 void aubio_fft_getphas(smpl_t * phas, fft_data_t * spectrum, uint_t size) { 131 135 uint_t i; 132 phas[0] = PI;136 phas[0] = 0; 133 137 for (i=1;i<size/2+1;i++) phas[i] = atan2f(spectrum[sizei] , spectrum[i]); 138 phas[size/2] = 0; 134 139 //for (i=0;i<size/2+1;i++) AUBIO_DBG("%f\n", phas[i]); 135 140 }
Note: See TracChangeset
for help on using the changeset viewer.