Changeset 252a080
- Timestamp:
- Oct 1, 2009, 5:36:01 PM (15 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:
- e6c11e3
- Parents:
- 04d50b0
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/onset/onsetdetection.c
r04d50b0 r252a080 35 35 smpl_t threshold; /**< minimum norm threshold for phase and specdiff */ 36 36 fvec_t *oldmag; /**< previous norm vector */ 37 fft_data_t *meas; /**< current onset detection measure complex vector */38 37 fvec_t *dev1 ; /**< current onset detection measure vector */ 39 38 fvec_t *theta1; /**< previous phase vector, one frame behind */ … … 75 74 onset->data[i][0] = 0.; 76 75 for (j=0;j<nbins; j++) { 77 o->dev1->data[i][j] = aubio_unwrap2pi( 78 fftgrain->phas[i][j] 79 -2.0*o->theta1->data[i][j]+ 80 o->theta2->data[i][j]); 81 #ifdef HAVE_COMPLEX_H 82 o->meas[j] = fftgrain->norm[i][j]*CEXPC(I*o->dev1->data[i][j]); 83 /* sum on all bins */ 84 onset->data[i][0] += //(fftgrain->norm[i][j]); 85 SQRT(SQR( REAL(o->oldmag->data[i][j]-o->meas[j]) ) 86 + SQR( IMAG(o->oldmag->data[i][j]-o->meas[j]) ) 87 ); 88 #else 89 o->meas[j] = (fftgrain->norm[i][j])*COS(o->dev1->data[i][j]); 90 o->meas[(nbins-1)*2-1-j] = (fftgrain->norm[i][j])*SIN(o->dev1->data[i][j]); 91 /* sum on all bins */ 92 onset->data[i][0] += //(fftgrain->norm[i][j]); 93 SQRT(SQR( (o->oldmag->data[i][j]-o->meas[j]) ) 94 + SQR( (-o->meas[(nbins-1)*2-1-j]) ) 95 ); 96 #endif 76 // compute the predicted phase 77 o->dev1->data[i][j] = 2. * o->theta1->data[i][j] - o->theta2->data[i][j]; 78 // compute the euclidean distance in the complex domain 79 // sqrt ( r_1^2 + r_2^2 - 2 * r_1 * r_2 * \cos ( \phi_1 - \phi_2 ) ) 80 onset->data[i][0] += 81 SQRT (ABS (SQR (o->oldmag->data[i][j]) + SQR (fftgrain->norm[i][j]) 82 - 2. * o->oldmag->data[i][j] * fftgrain->norm[i][j] 83 * COS (o->dev1->data[i][j] - fftgrain->phas[i][j]))); 97 84 /* swap old phase data (need to remember 2 frames behind)*/ 98 85 o->theta2->data[i][j] = o->theta1->data[i][j]; … … 235 222 case aubio_onset_complex: 236 223 o->oldmag = new_fvec(rsize,channels); 237 /** bug: must be complex array */238 o->meas = AUBIO_ARRAY(fft_data_t,size+1);239 for (i=0; i<size+1; i++) o->meas[i] = 0;240 224 o->dev1 = new_fvec(rsize,channels); 241 225 o->theta1 = new_fvec(rsize,channels); … … 309 293 /* the other approaches will need some more memory spaces */ 310 294 case aubio_onset_complex: 311 AUBIO_FREE(o->meas);312 295 del_fvec(o->oldmag); 313 296 del_fvec(o->dev1);
Note: See TracChangeset
for help on using the changeset viewer.