- Timestamp:
- Jun 14, 2005, 1:07:08 AM (19 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:
- 1397c6e
- Parents:
- 0ce9acc3
- Location:
- src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/onsetdetection.c
r0ce9acc3 rb31f262 68 68 69 69 /* Complex Domain Method onset detection function */ 70 /* moved to /2 032402 */71 70 void aubio_onsetdetection_complex (aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset) { 72 71 uint_t i, j; … … 128 127 129 128 /* Spectral difference method onset detection function */ 130 /* moved to /2 032402 */131 129 void aubio_onsetdetection_specdiff(aubio_onsetdetection_t *o, 132 130 cvec_t * fftgrain, fvec_t * onset){ … … 157 155 } 158 156 157 /* Kullback Liebler onset detection function 158 * note we use ln(1+Xn/(Xn-1+0.0001)) to avoid 159 * negative (1.+) and infinite values (+1.e-10) */ 160 void aubio_onsetdetection_kl(aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset){ 161 uint_t i,j; 162 for (i=0;i<fftgrain->channels;i++) { 163 onset->data[i][0] = 0.; 164 for (j=0;j<fftgrain->length;j++) { 165 onset->data[i][0] += fftgrain->norm[i][j] 166 *LOG(1.+fftgrain->norm[i][j]/(o->oldmag->data[i][j]+1.e-10)); 167 o->oldmag->data[i][j] = fftgrain->norm[i][j]; 168 } 169 if (isnan(onset->data[i][0])) onset->data[i][0] = 0.; 170 } 171 } 172 173 /* Modified Kullback Liebler onset detection function 174 * note we use ln(1+Xn/(Xn-1+0.0001)) to avoid 175 * negative (1.+) and infinite values (+1.e-10) */ 176 void aubio_onsetdetection_mkl(aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset){ 177 uint_t i,j; 178 for (i=0;i<fftgrain->channels;i++) { 179 onset->data[i][0] = 0.; 180 for (j=0;j<fftgrain->length;j++) { 181 onset->data[i][0] += LOG(1.+fftgrain->norm[i][j]/(o->oldmag->data[i][j]+1.e-10)); 182 o->oldmag->data[i][j] = fftgrain->norm[i][j]; 183 } 184 if (isnan(onset->data[i][0])) onset->data[i][0] = 0.; 185 } 186 } 187 159 188 /* Generic function pointing to the choosen one */ 160 189 void … … 205 234 o->threshold = 0.1; 206 235 break; 236 case kl: 237 o->oldmag = new_fvec(rsize,channels); 238 break; 239 case mkl: 240 o->oldmag = new_fvec(rsize,channels); 241 break; 207 242 default: 208 243 break; … … 228 263 case specdiff: 229 264 o->funcpointer = aubio_onsetdetection_specdiff; 265 break; 266 case kl: 267 o->funcpointer = aubio_onsetdetection_kl; 268 break; 269 case mkl: 270 o->funcpointer = aubio_onsetdetection_mkl; 230 271 break; 231 272 default: -
src/onsetdetection.h
r0ce9acc3 rb31f262 54 54 hfc, /**< high frequency content */ 55 55 complexdomain, /**< complex domain */ 56 phase /**< phase fast */ 56 phase, /**< phase fast */ 57 kl, /**< Kullback Liebler (Hainsworth et al., Onset detection in musical audio signals) */ 58 mkl /**< modified Kullback Liebler (Hainsworth et al., Onset detection in musical audio signals) */ 57 59 } aubio_onsetdetection_type; 58 60 … … 99 101 */ 100 102 void aubio_onsetdetection_specdiff(aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset); 103 /** Kullback-Liebler onset detection function */ 104 void aubio_onsetdetection_kl(aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset); 105 /** Modified Kullback-Liebler onset detection function */ 106 void aubio_onsetdetection_mkl(aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset); 101 107 /** Generic function pointing to the choosen one */ 102 108 void aubio_onsetdetection(aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset);
Note: See TracChangeset
for help on using the changeset viewer.