- Timestamp:
- Oct 2, 2009, 1:19:10 AM (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:
- 38e9732
- Parents:
- 2f64b0e
- Location:
- src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mathutils.c
r2f64b0e r5c4ec3c 93 93 } 94 94 95 smpl_t vec_sum(fvec_t *s) {95 smpl_t fvec_sum(fvec_t *s) { 96 96 uint_t i,j; 97 97 smpl_t tmp = 0.0f; … … 142 142 } 143 143 144 void vec_shift(fvec_t *s) {144 void fvec_shift(fvec_t *s) { 145 145 uint_t i,j; 146 146 //smpl_t tmp = 0.0f; … … 154 154 } 155 155 156 smpl_t vec_local_energy(fvec_t * f) {156 smpl_t fvec_local_energy(fvec_t * f) { 157 157 smpl_t locE = 0.; 158 158 uint_t i,j; … … 163 163 } 164 164 165 smpl_t vec_local_hfc(fvec_t * f) {165 smpl_t fvec_local_hfc(fvec_t * f) { 166 166 smpl_t locE = 0.; 167 167 uint_t i,j; … … 172 172 } 173 173 174 smpl_t vec_alpha_norm(fvec_t * DF, smpl_t alpha) {174 smpl_t fvec_alpha_norm(fvec_t * DF, smpl_t alpha) { 175 175 smpl_t tmp = 0.; 176 176 uint_t i,j; … … 181 181 } 182 182 183 void vec_dc_removal(fvec_t * mag) {183 void fvec_dc_removal(fvec_t * mag) { 184 184 smpl_t mini = 0.; 185 185 uint_t length = mag->length, i=0, j; … … 190 190 } 191 191 192 void vec_alpha_normalise(fvec_t * mag, uint_t alpha) {192 void fvec_alpha_normalise(fvec_t * mag, uint_t alpha) { 193 193 smpl_t alphan = 1.; 194 194 uint_t length = mag->length, i=0, j; 195 alphan = vec_alpha_norm(mag,alpha);195 alphan = fvec_alpha_norm(mag,alpha); 196 196 for (j=0;j<length;j++){ 197 197 mag->data[i][j] /= alphan; … … 199 199 } 200 200 201 void vec_add(fvec_t * mag, smpl_t threshold) {201 void fvec_add(fvec_t * mag, smpl_t threshold) { 202 202 uint_t length = mag->length, i=0, j; 203 203 for (j=0;j<length;j++) { … … 206 206 } 207 207 208 void vec_adapt_thres(fvec_t * vec, fvec_t * tmp,208 void fvec_adapt_thres(fvec_t * vec, fvec_t * tmp, 209 209 uint_t post, uint_t pre) { 210 210 uint_t length = vec->length, i=0, j; 211 211 for (j=0;j<length;j++) { 212 vec->data[i][j] -= vec_moving_thres(vec, tmp, post, pre, j);213 } 214 } 215 216 smpl_t vec_moving_thres(fvec_t * vec, fvec_t * tmpvec,212 vec->data[i][j] -= fvec_moving_thres(vec, tmp, post, pre, j); 213 } 214 } 215 216 smpl_t fvec_moving_thres(fvec_t * vec, fvec_t * tmpvec, 217 217 uint_t post, uint_t pre, uint_t pos) { 218 218 smpl_t * medar = (smpl_t *)tmpvec->data[0]; … … 237 237 medar[k] = 0.; /* 0-padding at the end */ 238 238 } 239 return vec_median(tmpvec);240 } 241 242 smpl_t vec_median(fvec_t * input) {239 return fvec_median(tmpvec); 240 } 241 242 smpl_t fvec_median(fvec_t * input) { 243 243 uint_t n = input->length; 244 244 smpl_t * arr = (smpl_t *) input->data[0]; … … 291 291 } 292 292 293 smpl_t vec_quadint(fvec_t * x,uint_t pos, uint_t span) {293 smpl_t fvec_quadint(fvec_t * x,uint_t pos, uint_t span) { 294 294 smpl_t s0, s1, s2; 295 295 uint_t x0 = (pos < span) ? pos : pos - span; … … 308 308 } 309 309 310 uint_t vec_peakpick(fvec_t * onset, uint_t pos) {310 uint_t fvec_peakpick(fvec_t * onset, uint_t pos) { 311 311 uint_t i=0, tmp=0; 312 312 /*for (i=0;i<onset->channels;i++)*/ -
src/mathutils.h
r2f64b0e r5c4ec3c 97 97 * a[n/2+1],...a[n],a[0]...,a[n/2] 98 98 */ 99 void vec_shift(fvec_t *s);99 void fvec_shift(fvec_t *s); 100 100 /** returns sum */ 101 smpl_t vec_sum(fvec_t *s);101 smpl_t fvec_sum(fvec_t *s); 102 102 103 103 /** returns energy … … 105 105 * \bug mono 106 106 */ 107 smpl_t vec_local_energy(fvec_t * f);107 smpl_t fvec_local_energy(fvec_t * f); 108 108 /** returns High Frequency Energy Content 109 109 * 110 110 * \bug mono */ 111 smpl_t vec_local_hfc(fvec_t * f);111 smpl_t fvec_local_hfc(fvec_t * f); 112 112 /** return alpha norm. 113 113 * … … 119 119 * \bug should not use POW :( 120 120 */ 121 smpl_t vec_alpha_norm(fvec_t * DF, smpl_t alpha);121 smpl_t fvec_alpha_norm(fvec_t * DF, smpl_t alpha); 122 122 /** dc(min) removal */ 123 void vec_dc_removal(fvec_t * mag);123 void fvec_dc_removal(fvec_t * mag); 124 124 /** alpha normalisation */ 125 void vec_alpha_normalise(fvec_t * mag, uint_t alpha);125 void fvec_alpha_normalise(fvec_t * mag, uint_t alpha); 126 126 /** add a constant to all members of a vector */ 127 void vec_add(fvec_t * mag, smpl_t threshold);127 void fvec_add(fvec_t * mag, smpl_t threshold); 128 128 129 129 /** compute adaptive threshold of input vector */ 130 void vec_adapt_thres(fvec_t * vec, fvec_t * tmp,130 void fvec_adapt_thres(fvec_t * vec, fvec_t * tmp, 131 131 uint_t win_post, uint_t win_pre); 132 132 /** adaptative thresholding … … 149 149 * see SPARMS for explanation of post and pre 150 150 */ 151 smpl_t vec_moving_thres(fvec_t * vec, fvec_t * tmp,151 smpl_t fvec_moving_thres(fvec_t * vec, fvec_t * tmp, 152 152 uint_t win_post, uint_t win_pre, uint_t win_pos); 153 153 … … 161 161 * available at http://ndevilla.free.fr/median/median/ 162 162 */ 163 smpl_t vec_median(fvec_t * input);163 smpl_t fvec_median(fvec_t * input); 164 164 165 165 /** finds exact peak index by quadratic interpolation*/ 166 smpl_t vec_quadint(fvec_t * x, uint_t pos, uint_t span);166 smpl_t fvec_quadint(fvec_t * x, uint_t pos, uint_t span); 167 167 168 168 /** Quadratic interpolation using Lagrange polynomial. … … 179 179 180 180 /** returns 1 if X1 is a peak and positive */ 181 uint_t vec_peakpick(fvec_t * input, uint_t pos);181 uint_t fvec_peakpick(fvec_t * input, uint_t pos); 182 182 183 183 /** convert frequency bin to midi value */ -
src/onset/peakpick.c
r2f64b0e r5c4ec3c 161 161 t->win_pre = 1; 162 162 163 t->thresholdfn = (aubio_thresholdfn_t)( vec_median); /* (fvec_mean); */164 t->pickerfn = (aubio_pickerfn_t)( vec_peakpick);163 t->thresholdfn = (aubio_thresholdfn_t)(fvec_median); /* (fvec_mean); */ 164 t->pickerfn = (aubio_pickerfn_t)(fvec_peakpick); 165 165 166 166 t->scratch = new_fvec(t->win_post+t->win_pre+1,1); -
src/pitch/pitchmcomb.c
r2f64b0e r5c4ec3c 99 99 newmag->data[i][j]=fftgrain->norm[i][j]; 100 100 /* detect only if local energy > 10. */ 101 //if ( vec_local_energy(newmag)>10.) {102 //hfc = vec_local_hfc(newmag); //not used101 //if (fvec_local_energy(newmag)>10.) { 102 //hfc = fvec_local_hfc(newmag); //not used 103 103 aubio_pitchmcomb_spectral_pp(p, newmag); 104 104 aubio_pitchmcomb_combdet(p,newmag); … … 132 132 newmag->data[i][j]=fftgrain->norm[i][j]; 133 133 /* detect only if local energy > 10. */ 134 if ( vec_local_energy(newmag)>10.) {135 /* hfc = vec_local_hfc(newmag); do not use */134 if (fvec_local_energy(newmag)>10.) { 135 /* hfc = fvec_local_hfc(newmag); do not use */ 136 136 aubio_pitchmcomb_spectral_pp(p, newmag); 137 137 aubio_pitchmcomb_combdet(p,newmag); … … 159 159 mag->data[i][j] = newmag->data[i][j]; 160 160 } 161 vec_dc_removal(mag); /* dc removal */162 vec_alpha_normalise(mag,p->alpha); /* alpha normalisation */161 fvec_dc_removal(mag); /* dc removal */ 162 fvec_alpha_normalise(mag,p->alpha); /* alpha normalisation */ 163 163 /* skipped */ /* low pass filtering */ 164 /** \bug vec_moving_thres may write out of bounds */165 vec_adapt_thres(mag,tmp,p->win_post,p->win_pre); /* adaptative threshold */166 vec_add(mag,-p->threshold); /* fixed threshold */164 /** \bug fvec_moving_thres may write out of bounds */ 165 fvec_adapt_thres(mag,tmp,p->win_post,p->win_pre); /* adaptative threshold */ 166 fvec_add(mag,-p->threshold); /* fixed threshold */ 167 167 { 168 168 aubio_spectralpeak_t * peaks = (aubio_spectralpeak_t *)p->peaks; … … 269 269 for (i=0;i<X->channels;i++) 270 270 for (j=1;j<X->length-1;j++) { 271 ispeak = vec_peakpick(X,j);271 ispeak = fvec_peakpick(X,j); 272 272 if (ispeak) { 273 273 count += ispeak; 274 274 spectral_peaks[count-1].bin = j; 275 spectral_peaks[count-1].ebin = vec_quadint(X, j, 1) - 1.;275 spectral_peaks[count-1].ebin = fvec_quadint(X, j, 1) - 1.; 276 276 } 277 277 } -
src/pitch/pitchyin.c
r2f64b0e r5c4ec3c 107 107 if(tau > 4 && (yin->data[c][period] < tol) && 108 108 (yin->data[c][period] < yin->data[c][period+1])) { 109 return vec_quadint(yin,period,1);109 return fvec_quadint(yin,period,1); 110 110 } 111 111 } 112 return vec_quadint(yin,fvec_min_elem(yin),1);112 return fvec_quadint(yin,fvec_min_elem(yin),1); 113 113 //return 0; 114 114 } -
src/pitch/pitchyinfft.c
r2f64b0e r5c4ec3c 125 125 //return tau; 126 126 /* 3 point quadratic interpolation */ 127 //return vec_quadint_min(yin,tau,1);127 //return fvec_quadint_min(yin,tau,1); 128 128 /* additional check for (unlikely) octave doubling in higher frequencies */ 129 129 if (tau>35) { 130 return vec_quadint(yin,tau,1);130 return fvec_quadint(yin,tau,1); 131 131 } else { 132 132 /* should compare the minimum value of each interpolated peaks */ 133 133 halfperiod = FLOOR(tau/2+.5); 134 134 if (yin->data[0][halfperiod] < tol) 135 return vec_quadint(yin,halfperiod,1);135 return fvec_quadint(yin,halfperiod,1); 136 136 else 137 return vec_quadint(yin,tau,1);137 return fvec_quadint(yin,tau,1); 138 138 } 139 139 } else -
src/spectral/mfcc.c
r2f64b0e r5c4ec3c 108 108 109 109 /* raise power */ 110 // vec_pow (mf->in_dct, 3.);110 //fvec_pow (mf->in_dct, 3.); 111 111 112 112 /* zeros output */ -
src/spectral/phasevoc.c
r2f64b0e r5c4ec3c 57 57 fvec_weight(pv->data, pv->w); 58 58 /* shift */ 59 vec_shift(pv->data);59 fvec_shift(pv->data); 60 60 /* calculate fft */ 61 61 aubio_fft_do (pv->fft,pv->data,fftgrain); … … 67 67 aubio_fft_rdo(pv->fft,fftgrain,pv->synth); 68 68 /* unshift */ 69 vec_shift(pv->synth);69 fvec_shift(pv->synth); 70 70 for (i=0; i<pv->channels; i++) { 71 71 aubio_pvoc_addsynth(pv->synth->data[i],pv->synthold->data[i], -
src/tempo/beattracking.c
r2f64b0e r5c4ec3c 170 170 /* find non-zero Rayleigh period */ 171 171 maxindex = fvec_max_elem (bt->acfout); 172 bt->rp = maxindex ? vec_quadint (bt->acfout, maxindex, 1) : 1;172 bt->rp = maxindex ? fvec_quadint (bt->acfout, maxindex, 1) : 1; 173 173 //rp = (maxindex==127) ? 43 : maxindex; //rayparam 174 174 bt->rp = (maxindex == bt->acfout->length - 1) ? bt->rayparam : maxindex; //rayparam … … 203 203 phase = step - bt->lastbeat; 204 204 } else { 205 phase = vec_quadint (bt->phout, maxindex, 1);205 phase = fvec_quadint (bt->phout, maxindex, 1); 206 206 } 207 207 /* take back one frame delay */ … … 305 305 } 306 306 fvec_weight (acfout, bt->gwv); 307 gp = vec_quadint (acfout, fvec_max_elem (acfout), 1);307 gp = fvec_quadint (acfout, fvec_max_elem (acfout), 1); 308 308 /* 309 309 while(gp<32) gp =gp*2; … … 409 409 { 410 410 if (bt->timesig != 0 && bt->counter == 0 && bt->flagstep == 0) { 411 return 5168. / vec_quadint (bt->acfout, bt->bp, 1);411 return 5168. / fvec_quadint (bt->acfout, bt->bp, 1); 412 412 } else { 413 413 return 0.;
Note: See TracChangeset
for help on using the changeset viewer.