shithub: aubio

Download patch

ref: 5c4ec3cb6b9cafcc5a953f2176c6069ed02fe4e2
parent: 2f64b0eb35fd560567f08ac95d974014ea353fac
author: Paul Brossier <piem@piem.org>
date: Thu Oct 1 21:19:10 EDT 2009

src/mathutils.{c,h}: rename all vec_ to fvec_

--- a/examples/utils.c
+++ b/examples/utils.c
@@ -476,7 +476,7 @@
   for (i = 0; i < note_buffer->length; i++) {
     note_buffer2->data[0][i] = note_buffer->data[0][i];
   }
-  return vec_median (note_buffer2);
+  return fvec_median (note_buffer2);
 }
 
 #if HAVE_LASH
--- a/examples/utils.h
+++ b/examples/utils.h
@@ -65,7 +65,7 @@
 
 void send_noteon (int pitch, int velo);
 /** append new note candidate to the note_buffer and return filtered value. we
- * need to copy the input array as vec_median destroy its input data.*/
+ * need to copy the input array as fvec_median destroy its input data.*/
 void note_append (fvec_t * note_buffer, smpl_t curnote);
 uint_t get_note (fvec_t * note_buffer, fvec_t * note_buffer2);
 
--- a/src/mathutils.c
+++ b/src/mathutils.c
@@ -92,7 +92,7 @@
   return tmp/(smpl_t)(s->length);
 }
 
-smpl_t vec_sum(fvec_t *s) {
+smpl_t fvec_sum(fvec_t *s) {
   uint_t i,j;
   smpl_t tmp = 0.0f;
   for (i=0; i < s->channels; i++)
@@ -141,7 +141,7 @@
   return pos;
 }
 
-void vec_shift(fvec_t *s) {
+void fvec_shift(fvec_t *s) {
   uint_t i,j;
   //smpl_t tmp = 0.0f;
   for (i=0; i < s->channels; i++)
@@ -153,7 +153,7 @@
     }
 }
 
-smpl_t vec_local_energy(fvec_t * f) {
+smpl_t fvec_local_energy(fvec_t * f) {
   smpl_t locE = 0.;
   uint_t i,j;
   for (i=0;i<f->channels;i++)
@@ -162,7 +162,7 @@
   return locE;
 }
 
-smpl_t vec_local_hfc(fvec_t * f) {
+smpl_t fvec_local_hfc(fvec_t * f) {
   smpl_t locE = 0.;
   uint_t i,j;
   for (i=0;i<f->channels;i++)
@@ -171,7 +171,7 @@
   return locE;
 }
 
-smpl_t vec_alpha_norm(fvec_t * DF, smpl_t alpha) {
+smpl_t fvec_alpha_norm(fvec_t * DF, smpl_t alpha) {
   smpl_t tmp = 0.;
   uint_t i,j;
   for (i=0;i<DF->channels;i++)
@@ -180,7 +180,7 @@
   return POW(tmp/DF->length,1./alpha);
 }
 
-void vec_dc_removal(fvec_t * mag) {
+void fvec_dc_removal(fvec_t * mag) {
     smpl_t mini = 0.;
     uint_t length = mag->length, i=0, j;
     mini = fvec_min(mag);
@@ -189,16 +189,16 @@
     }
 }
 
-void vec_alpha_normalise(fvec_t * mag, uint_t alpha) {
+void fvec_alpha_normalise(fvec_t * mag, uint_t alpha) {
   smpl_t alphan = 1.;
   uint_t length = mag->length, i=0, j;
-  alphan = vec_alpha_norm(mag,alpha);
+  alphan = fvec_alpha_norm(mag,alpha);
   for (j=0;j<length;j++){
     mag->data[i][j] /= alphan;
   }
 }
 
-void vec_add(fvec_t * mag, smpl_t threshold) {
+void fvec_add(fvec_t * mag, smpl_t threshold) {
   uint_t length = mag->length, i=0, j;
   for (j=0;j<length;j++) {
     mag->data[i][j] += threshold;
@@ -205,15 +205,15 @@
   }
 }
 
-void vec_adapt_thres(fvec_t * vec, fvec_t * tmp,
+void fvec_adapt_thres(fvec_t * vec, fvec_t * tmp,
     uint_t post, uint_t pre) {
   uint_t length = vec->length, i=0, j;
   for (j=0;j<length;j++) {
-    vec->data[i][j] -= vec_moving_thres(vec, tmp, post, pre, j);
+    vec->data[i][j] -= fvec_moving_thres(vec, tmp, post, pre, j);
   }
 }
 
-smpl_t vec_moving_thres(fvec_t * vec, fvec_t * tmpvec,
+smpl_t fvec_moving_thres(fvec_t * vec, fvec_t * tmpvec,
     uint_t post, uint_t pre, uint_t pos) {
   smpl_t * medar = (smpl_t *)tmpvec->data[0];
   uint_t k;
@@ -236,10 +236,10 @@
     for (k=length-pos+post;k<win_length;k++)
       medar[k] = 0.; /* 0-padding at the end */
   }
-  return vec_median(tmpvec);
+  return fvec_median(tmpvec);
 }
 
-smpl_t vec_median(fvec_t * input) {
+smpl_t fvec_median(fvec_t * input) {
   uint_t n = input->length;
   smpl_t * arr = (smpl_t *) input->data[0];
   uint_t low, high ;
@@ -290,7 +290,7 @@
   }
 }
 
-smpl_t vec_quadint(fvec_t * x,uint_t pos, uint_t span) {
+smpl_t fvec_quadint(fvec_t * x,uint_t pos, uint_t span) {
   smpl_t s0, s1, s2;
   uint_t x0 = (pos < span) ? pos : pos - span;
   uint_t x2 = (pos + span < x->length) ? pos + span : pos;
@@ -307,7 +307,7 @@
   return tmp;
 }
 
-uint_t vec_peakpick(fvec_t * onset, uint_t pos) {
+uint_t fvec_peakpick(fvec_t * onset, uint_t pos) {
   uint_t i=0, tmp=0;
   /*for (i=0;i<onset->channels;i++)*/
   tmp = (onset->data[i][pos] > onset->data[i][pos-1]
--- a/src/mathutils.h
+++ b/src/mathutils.h
@@ -96,19 +96,19 @@
  * 
  * a[n/2+1],...a[n],a[0]...,a[n/2]
  */
-void vec_shift(fvec_t *s);
+void fvec_shift(fvec_t *s);
 /** returns sum */
-smpl_t vec_sum(fvec_t *s);
+smpl_t fvec_sum(fvec_t *s);
 
 /** returns energy 
  *
  * \bug mono 
  */
-smpl_t vec_local_energy(fvec_t * f);
+smpl_t fvec_local_energy(fvec_t * f);
 /** returns High Frequency Energy Content
  *
  * \bug mono */
-smpl_t vec_local_hfc(fvec_t * f);
+smpl_t fvec_local_hfc(fvec_t * f);
 /** return alpha norm.
  *
  * alpha=2 means normalise variance. 
@@ -118,16 +118,16 @@
  *
  * \bug should not use POW :(
  */
-smpl_t vec_alpha_norm(fvec_t * DF, smpl_t alpha);
+smpl_t fvec_alpha_norm(fvec_t * DF, smpl_t alpha);
 /**  dc(min) removal */
-void vec_dc_removal(fvec_t * mag);
+void fvec_dc_removal(fvec_t * mag);
 /**  alpha normalisation */
-void vec_alpha_normalise(fvec_t * mag, uint_t alpha);
+void fvec_alpha_normalise(fvec_t * mag, uint_t alpha);
 /** add a constant to all members of a vector */
-void vec_add(fvec_t * mag, smpl_t threshold);
+void fvec_add(fvec_t * mag, smpl_t threshold);
 
 /** compute adaptive threshold of input vector */ 
-void vec_adapt_thres(fvec_t * vec, fvec_t * tmp, 
+void fvec_adapt_thres(fvec_t * vec, fvec_t * tmp, 
     uint_t win_post, uint_t win_pre);
 /**  adaptative thresholding 
  *
@@ -148,7 +148,7 @@
  *    minima=fn_thresh(min,x,8,8)  
  * see SPARMS for explanation of post and pre
  */
-smpl_t vec_moving_thres(fvec_t * vec, fvec_t * tmp, 
+smpl_t fvec_moving_thres(fvec_t * vec, fvec_t * tmp, 
     uint_t win_post, uint_t win_pre, uint_t win_pos);
 
 /** returns the median of the vector 
@@ -160,10 +160,10 @@
  *  This code by Nicolas Devillard - 1998. Public domain,
  *  available at http://ndevilla.free.fr/median/median/
  */
-smpl_t vec_median(fvec_t * input);
+smpl_t fvec_median(fvec_t * input);
 
 /** finds exact peak index by quadratic interpolation*/
-smpl_t vec_quadint(fvec_t * x, uint_t pos, uint_t span);
+smpl_t fvec_quadint(fvec_t * x, uint_t pos, uint_t span);
 
 /** Quadratic interpolation using Lagrange polynomial.
  *
@@ -178,7 +178,7 @@
 smpl_t aubio_quadfrac(smpl_t s0, smpl_t s1, smpl_t s2, smpl_t pf);
 
 /** returns 1 if X1 is a peak and positive */
-uint_t vec_peakpick(fvec_t * input, uint_t pos);
+uint_t fvec_peakpick(fvec_t * input, uint_t pos);
 
 /** convert frequency bin to midi value */
 smpl_t aubio_bintomidi(smpl_t bin, smpl_t samplerate, smpl_t fftsize);
--- a/src/onset/peakpick.c
+++ b/src/onset/peakpick.c
@@ -160,8 +160,8 @@
 	t->win_post  = 5;
 	t->win_pre   = 1;
 
-	t->thresholdfn = (aubio_thresholdfn_t)(vec_median); /* (fvec_mean); */
-	t->pickerfn = (aubio_pickerfn_t)(vec_peakpick);
+	t->thresholdfn = (aubio_thresholdfn_t)(fvec_median); /* (fvec_mean); */
+	t->pickerfn = (aubio_pickerfn_t)(fvec_peakpick);
 
 	t->scratch = new_fvec(t->win_post+t->win_pre+1,1);
 	t->onset_keep = new_fvec(t->win_post+t->win_pre+1,1);
--- a/src/pitch/pitchmcomb.c
+++ b/src/pitch/pitchmcomb.c
@@ -98,8 +98,8 @@
   for (j=0; j< newmag->length; j++)
     newmag->data[i][j]=fftgrain->norm[i][j];
   /* detect only if local energy > 10. */
-  //if (vec_local_energy(newmag)>10.) {
-    //hfc = vec_local_hfc(newmag); //not used
+  //if (fvec_local_energy(newmag)>10.) {
+    //hfc = fvec_local_hfc(newmag); //not used
     aubio_pitchmcomb_spectral_pp(p, newmag);
     aubio_pitchmcomb_combdet(p,newmag);
     //aubio_pitchmcomb_sort_cand_freq(p->candidates,p->ncand);
@@ -131,8 +131,8 @@
   for (j=0; j< newmag->length; j++)
     newmag->data[i][j]=fftgrain->norm[i][j];
   /* detect only if local energy > 10. */
-  if (vec_local_energy(newmag)>10.) {
-    /* hfc = vec_local_hfc(newmag); do not use */
+  if (fvec_local_energy(newmag)>10.) {
+    /* hfc = fvec_local_hfc(newmag); do not use */
     aubio_pitchmcomb_spectral_pp(p, newmag);
     aubio_pitchmcomb_combdet(p,newmag);
     aubio_pitchmcomb_sort_cand_freq(scands,p->ncand);
@@ -158,12 +158,12 @@
   for (j=0;j<length;j++) {
     mag->data[i][j] = newmag->data[i][j];
   }
-  vec_dc_removal(mag);               /* dc removal           */
-  vec_alpha_normalise(mag,p->alpha); /* alpha normalisation  */
+  fvec_dc_removal(mag);               /* dc removal           */
+  fvec_alpha_normalise(mag,p->alpha); /* alpha normalisation  */
   /* skipped */                      /* low pass filtering   */
-  /** \bug vec_moving_thres may write out of bounds */
-  vec_adapt_thres(mag,tmp,p->win_post,p->win_pre); /* adaptative threshold */
-  vec_add(mag,-p->threshold);        /* fixed threshold      */
+  /** \bug fvec_moving_thres may write out of bounds */
+  fvec_adapt_thres(mag,tmp,p->win_post,p->win_pre); /* adaptative threshold */
+  fvec_add(mag,-p->threshold);        /* fixed threshold      */
   {
     aubio_spectralpeak_t * peaks = (aubio_spectralpeak_t *)p->peaks;
     uint_t count;
@@ -268,11 +268,11 @@
   uint_t i, j, ispeak, count = 0;
   for (i=0;i<X->channels;i++)
     for (j=1;j<X->length-1;j++) {
-      ispeak = vec_peakpick(X,j);
+      ispeak = fvec_peakpick(X,j);
       if (ispeak) {
         count += ispeak;
         spectral_peaks[count-1].bin = j;
-        spectral_peaks[count-1].ebin = vec_quadint(X, j, 1) - 1.;
+        spectral_peaks[count-1].ebin = fvec_quadint(X, j, 1) - 1.;
       }
     }
   return count;
--- a/src/pitch/pitchyin.c
+++ b/src/pitch/pitchyin.c
@@ -106,10 +106,10 @@
     period = tau-3;
     if(tau > 4 && (yin->data[c][period] < tol) && 
         (yin->data[c][period] < yin->data[c][period+1])) {
-      return vec_quadint(yin,period,1);
+      return fvec_quadint(yin,period,1);
     }
   }
-  return vec_quadint(yin,fvec_min_elem(yin),1);
+  return fvec_quadint(yin,fvec_min_elem(yin),1);
   //return 0;
 }
 
--- a/src/pitch/pitchyinfft.c
+++ b/src/pitch/pitchyinfft.c
@@ -124,17 +124,17 @@
     /* no interpolation */
     //return tau;
     /* 3 point quadratic interpolation */
-    //return vec_quadint_min(yin,tau,1);
+    //return fvec_quadint_min(yin,tau,1);
     /* additional check for (unlikely) octave doubling in higher frequencies */
     if (tau>35) {
-      return vec_quadint(yin,tau,1);
+      return fvec_quadint(yin,tau,1);
     } else {
       /* should compare the minimum value of each interpolated peaks */
       halfperiod = FLOOR(tau/2+.5);
       if (yin->data[0][halfperiod] < tol)
-        return vec_quadint(yin,halfperiod,1);
+        return fvec_quadint(yin,halfperiod,1);
       else
-        return vec_quadint(yin,tau,1);
+        return fvec_quadint(yin,tau,1);
     }
   } else
     return 0.;
--- a/src/spectral/mfcc.c
+++ b/src/spectral/mfcc.c
@@ -107,7 +107,7 @@
   fvec_log10 (mf->in_dct);
 
   /* raise power */
-  //vec_pow (mf->in_dct, 3.);
+  //fvec_pow (mf->in_dct, 3.);
 
   /* zeros output */
   fvec_zeros(out);
--- a/src/spectral/phasevoc.c
+++ b/src/spectral/phasevoc.c
@@ -56,7 +56,7 @@
   /* windowing */
   fvec_weight(pv->data, pv->w);
   /* shift */
-  vec_shift(pv->data);
+  fvec_shift(pv->data);
   /* calculate fft */
   aubio_fft_do (pv->fft,pv->data,fftgrain);
 }
@@ -66,7 +66,7 @@
   /* calculate rfft */
   aubio_fft_rdo(pv->fft,fftgrain,pv->synth);
   /* unshift */
-  vec_shift(pv->synth);
+  fvec_shift(pv->synth);
   for (i=0; i<pv->channels; i++) {
     aubio_pvoc_addsynth(pv->synth->data[i],pv->synthold->data[i],
         synthnew->data[i],pv->win_s,pv->hop_s);
--- a/src/tempo/beattracking.c
+++ b/src/tempo/beattracking.c
@@ -169,7 +169,7 @@
 
   /* find non-zero Rayleigh period */
   maxindex = fvec_max_elem (bt->acfout);
-  bt->rp = maxindex ? vec_quadint (bt->acfout, maxindex, 1) : 1;
+  bt->rp = maxindex ? fvec_quadint (bt->acfout, maxindex, 1) : 1;
   //rp = (maxindex==127) ? 43 : maxindex; //rayparam
   bt->rp = (maxindex == bt->acfout->length - 1) ? bt->rayparam : maxindex;      //rayparam
 
@@ -202,7 +202,7 @@
 #endif /* AUBIO_BEAT_WARNINGS */
     phase = step - bt->lastbeat;
   } else {
-    phase = vec_quadint (bt->phout, maxindex, 1);
+    phase = fvec_quadint (bt->phout, maxindex, 1);
   }
   /* take back one frame delay */
   phase += 1.;
@@ -304,7 +304,7 @@
       }
     }
     fvec_weight (acfout, bt->gwv);
-    gp = vec_quadint (acfout, fvec_max_elem (acfout), 1);
+    gp = fvec_quadint (acfout, fvec_max_elem (acfout), 1);
     /*
        while(gp<32) gp =gp*2;
        while(gp>64) gp = gp/2;
@@ -408,7 +408,7 @@
 aubio_beattracking_get_bpm (aubio_beattracking_t * bt)
 {
   if (bt->timesig != 0 && bt->counter == 0 && bt->flagstep == 0) {
-    return 5168. / vec_quadint (bt->acfout, bt->bp, 1);
+    return 5168. / fvec_quadint (bt->acfout, bt->bp, 1);
   } else {
     return 0.;
   }
--- a/swig/aubio.i
+++ b/swig/aubio.i
@@ -134,20 +134,20 @@
 smpl_t fvec_min(fvec_t *s);
 uint_t fvec_min_elem(fvec_t *s);
 uint_t fvec_max_elem(fvec_t *s);
-void vec_shift(fvec_t *s);
-smpl_t vec_sum(fvec_t *s);
-smpl_t vec_local_energy(fvec_t * f);
-smpl_t vec_local_hfc(fvec_t * f);
-smpl_t vec_alpha_norm(fvec_t * DF, smpl_t alpha);
-void vec_dc_removal(fvec_t * mag);
-void vec_alpha_normalise(fvec_t * mag, uint_t alpha);
-void vec_add(fvec_t * mag, smpl_t threshold);
-void vec_adapt_thres(fvec_t * vec, fvec_t * tmp, uint_t post, uint_t pre);
-smpl_t vec_moving_thres(fvec_t * vec, fvec_t * tmp, uint_t post, uint_t pre, uint_t pos);
-smpl_t vec_median(fvec_t * input);
-smpl_t vec_quadint(fvec_t * x,uint_t pos, uint_t span);
+void fvec_shift(fvec_t *s);
+smpl_t fvec_sum(fvec_t *s);
+smpl_t fvec_local_energy(fvec_t * f);
+smpl_t fvec_local_hfc(fvec_t * f);
+smpl_t fvec_alpha_norm(fvec_t * DF, smpl_t alpha);
+void fvec_dc_removal(fvec_t * mag);
+void fvec_alpha_normalise(fvec_t * mag, uint_t alpha);
+void fvec_add(fvec_t * mag, smpl_t threshold);
+void fvec_adapt_thres(fvec_t * vec, fvec_t * tmp, uint_t post, uint_t pre);
+smpl_t fvec_moving_thres(fvec_t * vec, fvec_t * tmp, uint_t post, uint_t pre, uint_t pos);
+smpl_t fvec_median(fvec_t * input);
+smpl_t fvec_quadint(fvec_t * x,uint_t pos, uint_t span);
 smpl_t aubio_quadfrac(smpl_t s0, smpl_t s1, smpl_t s2, smpl_t pf);
-uint_t vec_peakpick(fvec_t * input, uint_t pos);
+uint_t fvec_peakpick(fvec_t * input, uint_t pos);
 smpl_t aubio_bintomidi(smpl_t bin, smpl_t samplerate, smpl_t fftsize);
 smpl_t aubio_miditobin(smpl_t midi, smpl_t samplerate, smpl_t fftsize);
 smpl_t aubio_bintofreq(smpl_t bin, smpl_t samplerate, smpl_t fftsize);