src/mathutils.{c,h}: rename all vec_ to fvec_
authorPaul Brossier <piem@piem.org>
Thu, 1 Oct 2009 23:19:10 +0000 (01:19 +0200)
committerPaul Brossier <piem@piem.org>
Thu, 1 Oct 2009 23:19:10 +0000 (01:19 +0200)
12 files changed:
examples/utils.c
examples/utils.h
src/mathutils.c
src/mathutils.h
src/onset/peakpick.c
src/pitch/pitchmcomb.c
src/pitch/pitchyin.c
src/pitch/pitchyinfft.c
src/spectral/mfcc.c
src/spectral/phasevoc.c
src/tempo/beattracking.c
swig/aubio.i

index 6b6e337..304fb47 100644 (file)
@@ -476,7 +476,7 @@ get_note (fvec_t * note_buffer, fvec_t * note_buffer2)
   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
index 1228a15..5901c1f 100644 (file)
@@ -65,7 +65,7 @@ void flush_process (aubio_process_func_t process_func,
 
 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);
 
index 5cd6fe5..c92155e 100644 (file)
@@ -92,7 +92,7 @@ smpl_t fvec_mean(fvec_t *s) {
   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 @@ uint_t fvec_max_elem(fvec_t *s) {
   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 @@ void vec_shift(fvec_t *s) {
     }
 }
 
-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 @@ smpl_t vec_local_energy(fvec_t * f) {
   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 @@ smpl_t vec_local_hfc(fvec_t * f) {
   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 @@ smpl_t vec_alpha_norm(fvec_t * DF, smpl_t alpha) {
   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,31 +189,31 @@ void vec_dc_removal(fvec_t * mag) {
     }
 }
 
-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;
   }
 }
 
-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 @@ smpl_t vec_moving_thres(fvec_t * vec, fvec_t * tmpvec,
     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_median(fvec_t * input) {
   }
 }
 
-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 @@ smpl_t aubio_quadfrac(smpl_t s0, smpl_t s1, smpl_t s2, smpl_t pf) {
   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]
index 6014756..295de4b 100644 (file)
@@ -96,19 +96,19 @@ uint_t fvec_max_elem(fvec_t *s);
  * 
  * 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 @@ smpl_t vec_local_hfc(fvec_t * f);
  *
  * \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 @@ void vec_adapt_thres(fvec_t * vec, fvec_t * tmp,
  *    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 @@ smpl_t vec_moving_thres(fvec_t * vec, fvec_t * tmp,
  *  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 vec_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);
 
 /** 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);
index 8ec8459..1ed0fe8 100644 (file)
@@ -160,8 +160,8 @@ aubio_pickpeak_t * new_aubio_peakpicker(smpl_t threshold) {
        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);
index 5cd23ff..68964a1 100644 (file)
@@ -98,8 +98,8 @@ smpl_t aubio_pitchmcomb_detect(aubio_pitchmcomb_t * p, cvec_t * fftgrain) {
   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 @@ uint_t aubio_pitch_cands(aubio_pitchmcomb_t * p, cvec_t * fftgrain,
   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 @@ void aubio_pitchmcomb_spectral_pp(aubio_pitchmcomb_t * p, fvec_t * newmag) {
   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 aubio_pitchmcomb_quadpick(aubio_spectralpeak_t * spectral_peaks, fvec_t *
   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;
index 78d13ff..30309e0 100644 (file)
@@ -106,10 +106,10 @@ smpl_t aubio_pitchyin_getpitchfast(fvec_t * input, fvec_t * yin, smpl_t tol){
     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;
 }
 
index 8d8d031..0c41209 100644 (file)
@@ -124,17 +124,17 @@ smpl_t aubio_pitchyinfft_detect(aubio_pitchyinfft_t * p, fvec_t * input, smpl_t
     /* 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.;
index 4d46b50..840c60e 100644 (file)
@@ -107,7 +107,7 @@ aubio_mfcc_do (aubio_mfcc_t * mf, cvec_t * in, fvec_t * out)
   fvec_log10 (mf->in_dct);
 
   /* raise power */
-  //vec_pow (mf->in_dct, 3.);
+  //fvec_pow (mf->in_dct, 3.);
 
   /* zeros output */
   fvec_zeros(out);
index f502254..7c5b9c5 100644 (file)
@@ -56,7 +56,7 @@ void aubio_pvoc_do(aubio_pvoc_t *pv, fvec_t * datanew, cvec_t *fftgrain) {
   /* 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 @@ void aubio_pvoc_rdo(aubio_pvoc_t *pv,cvec_t * fftgrain, fvec_t * synthnew) {
   /* 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);
index 45311e0..47ea1b9 100644 (file)
@@ -169,7 +169,7 @@ aubio_beattracking_do (aubio_beattracking_t * bt, fvec_t * dfframe,
 
   /* 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 @@ aubio_beattracking_do (aubio_beattracking_t * bt, fvec_t * dfframe,
 #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 @@ aubio_beattracking_checkstate (aubio_beattracking_t * bt)
       }
     }
     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 @@ smpl_t
 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.;
   }
index 8900bf1..651f249 100644 (file)
@@ -134,20 +134,20 @@ smpl_t fvec_max(fvec_t *s);
 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);