Changeset 237f632
- Timestamp:
- Sep 29, 2006, 4:19:55 PM (18 years ago)
- Branches:
- feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
- Children:
- 3b3ec6c
- Parents:
- be929a5
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
configure.ac
rbe929a5 r237f632 106 106 AC_HEADER_STDC 107 107 AC_CHECK_HEADERS([string.h stdlib.h stdio.h math.h errno.h stdarg.h unistd.h signal.h],,) 108 AC_CHECK_HEADERS(complex.h,,AC_MSG_ERROR([Ouch! missing complex.h header]))109 108 AC_CHECK_HEADERS(fftw3.h ,,AC_MSG_ERROR([Ouch! missing fftw3.h header])) 109 AC_ARG_ENABLE(complex, 110 AC_HELP_STRING([--enable-complex],[compile with complex.h [[default=auto]]]), 111 [with_complex=$enableval], 112 with_complex="yes") 113 if test "$with_complex" = "yes"; then 114 AC_CHECK_HEADERS(complex.h,,AC_MSG_WARN([Ouch! missing complex.h header])) 115 fi 110 116 111 117 dnl Check for __VAR_ARGS__ support -
src/fft.c
rbe929a5 r237f632 29 29 #define fftw_plan_dft_r2c_1d fftwf_plan_dft_r2c_1d 30 30 #define fftw_plan_dft_c2r_1d fftwf_plan_dft_c2r_1d 31 #define fftw_plan_r2r_1d fftwf_plan_r2r_1d 31 32 #define fftw_plan fftwf_plan 32 33 #define fftw_destroy_plan fftwf_destroy_plan … … 47 48 }; 48 49 50 static void aubio_fft_getspectrum(fft_data_t * spectrum, smpl_t *norm, smpl_t * phas, uint_t size); 51 49 52 aubio_fft_t * new_aubio_fft(uint_t size) { 50 53 aubio_fft_t * s = AUBIO_NEW(aubio_fft_t); … … 54 57 s->specdata = (fft_data_t*)fftw_malloc(sizeof(fft_data_t)*size); 55 58 /* create plans */ 59 #ifdef HAVE_COMPLEX_H 56 60 s->pfw = fftw_plan_dft_r2c_1d(size, s->in, s->specdata, FFTW_ESTIMATE); 57 61 s->pbw = fftw_plan_dft_c2r_1d(size, s->specdata, s->out, FFTW_ESTIMATE); 62 #else 63 s->pfw = fftw_plan_r2r_1d(size, s->in, s->specdata, FFTW_R2HC, FFTW_ESTIMATE); 64 s->pbw = fftw_plan_r2r_1d(size, s->specdata, s->out, FFTW_HC2R, FFTW_ESTIMATE); 65 #endif 58 66 return s; 59 67 } … … 89 97 } 90 98 99 #ifdef HAVE_COMPLEX_H 91 100 92 101 void aubio_fft_getnorm(smpl_t * norm, fft_data_t * spectrum, uint_t size) { 93 102 uint_t i; 94 for (i=0;i<size;i++) norm[i] = ABSC(spectrum[i]); 103 for (i=0;i<size/2+1;i++) norm[i] = ABSC(spectrum[i]); 104 //for (i=0;i<size/2+1;i++) AUBIO_DBG("%f\n", norm[i]); 95 105 } 96 106 97 107 void aubio_fft_getphas(smpl_t * phas, fft_data_t * spectrum, uint_t size) { 98 108 uint_t i; 99 for (i=0;i<size;i++) phas[i] = ARGC(spectrum[i]); 109 for (i=0;i<size/2+1;i++) phas[i] = ARGC(spectrum[i]); 110 //for (i=0;i<size/2+1;i++) AUBIO_DBG("%f\n", phas[i]); 100 111 } 101 112 113 void aubio_fft_getspectrum(fft_data_t * spectrum, smpl_t *norm, smpl_t * phas, uint_t size) { 114 uint_t j; 115 for (j=0; j<size/2+1; j++) { 116 spectrum[j] = CEXPC(I*phas[j]); 117 spectrum[j] *= norm[j]; 118 } 119 } 120 121 #else 122 123 void aubio_fft_getnorm(smpl_t * norm, fft_data_t * spectrum, uint_t size) { 124 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[size-i])); 127 //for (i=0;i<size/2+1;i++) AUBIO_DBG("%f\n", norm[i]); 128 } 129 130 void aubio_fft_getphas(smpl_t * phas, fft_data_t * spectrum, uint_t size) { 131 uint_t i; 132 phas[0] = PI; 133 for (i=1;i<size/2+1;i++) phas[i] = atan2f(spectrum[size-i] , spectrum[i]); 134 //for (i=0;i<size/2+1;i++) AUBIO_DBG("%f\n", phas[i]); 135 } 136 137 void aubio_fft_getspectrum(fft_data_t * spectrum, smpl_t *norm, smpl_t * phas, uint_t size) { 138 uint_t j; 139 for (j=0; j<size/2+1; j++) { 140 spectrum[j] = norm[j]*COS(phas[j]); 141 } 142 for (j=1; j<size/2+1; j++) { 143 spectrum[size-j] = norm[j]*SIN(phas[j]); 144 } 145 } 146 147 #endif 102 148 103 149 /* new interface aubio_mfft */ … … 128 174 aubio_fft_do (fft->fft,in->data[i],fft->spec[i],fft->winsize); 129 175 /* put norm and phase into fftgrain */ 130 aubio_fft_getnorm(fftgrain->norm[i], fft->spec[i], fft->winsize /2+1);131 aubio_fft_getphas(fftgrain->phas[i], fft->spec[i], fft->winsize /2+1);176 aubio_fft_getnorm(fftgrain->norm[i], fft->spec[i], fft->winsize); 177 aubio_fft_getphas(fftgrain->phas[i], fft->spec[i], fft->winsize); 132 178 } 133 179 } … … 135 181 /* execute inverse fourier transform */ 136 182 void aubio_mfft_rdo(aubio_mfft_t * fft,cvec_t * fftgrain, fvec_t * out){ 137 uint_t i=0 ,j;183 uint_t i=0; 138 184 for (i=0; i < fft->channels; i++) { 139 for (j=0; j<fft->winsize/2+1; j++) { 140 fft->spec[i][j] = CEXPC(I*aubio_unwrap2pi(fftgrain->phas[i][j])); 141 fft->spec[i][j] *= fftgrain->norm[i][j]; 142 } 185 aubio_fft_getspectrum(fft->spec[i],fftgrain->norm[i],fftgrain->phas[i],fft->winsize); 143 186 aubio_fft_rdo(fft->fft,fft->spec[i],out->data[i],fft->winsize); 144 187 } -
src/onsetdetection.c
rbe929a5 r237f632 77 77 -2.0*o->theta1->data[i][j]+ 78 78 o->theta2->data[i][j]); 79 #ifdef HAVE_COMPLEX_H 79 80 o->meas[j] = fftgrain->norm[i][j]*CEXPC(I*o->dev1->data[i][j]); 80 81 /* sum on all bins */ … … 83 84 + SQR( IMAG(o->oldmag->data[i][j]-o->meas[j]) ) 84 85 ); 86 #else 87 o->meas[j] = (fftgrain->norm[i][j])*COS(o->dev1->data[i][j]); 88 o->meas[(nbins-1)*2-j] = (fftgrain->norm[i][j])*SIN(o->dev1->data[i][j]); 89 /* sum on all bins */ 90 onset->data[i][0] += //(fftgrain->norm[i][j]); 91 SQRT(SQR( (o->oldmag->data[i][j]-o->meas[j]) ) 92 + SQR( (-o->meas[(nbins-1)*2-j]) ) 93 ); 94 #endif 85 95 /* swap old phase data (need to remember 2 frames behind)*/ 86 96 o->theta2->data[i][j] = o->theta1->data[i][j]; … … 200 210 aubio_onsetdetection_t * o = AUBIO_NEW(aubio_onsetdetection_t); 201 211 uint_t rsize = size/2+1; 212 uint_t i; 202 213 switch(type) { 203 214 /* for both energy and hfc, only fftgrain->norm is required */ … … 210 221 o->oldmag = new_fvec(rsize,channels); 211 222 /** bug: must be complex array */ 212 o->meas = AUBIO_ARRAY(fft_data_t,size); 223 o->meas = AUBIO_ARRAY(fft_data_t,size+1); 224 for (i=0; i<size+1; i++) o->meas[i] = 0; 213 225 o->dev1 = new_fvec(rsize,channels); 214 226 o->theta1 = new_fvec(rsize,channels);
Note: See TracChangeset
for help on using the changeset viewer.