Changeset 5c4ec3c


Ignore:
Timestamp:
Oct 2, 2009, 1:19:10 AM (15 years ago)
Author:
Paul Brossier <piem@piem.org>
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
Message:

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

Files:
12 edited

Legend:

Unmodified
Added
Removed
  • examples/utils.c

    r2f64b0e r5c4ec3c  
    477477    note_buffer2->data[0][i] = note_buffer->data[0][i];
    478478  }
    479   return vec_median (note_buffer2);
     479  return fvec_median (note_buffer2);
    480480}
    481481
  • examples/utils.h

    r2f64b0e r5c4ec3c  
    6666void send_noteon (int pitch, int velo);
    6767/** append new note candidate to the note_buffer and return filtered value. we
    68  * need to copy the input array as vec_median destroy its input data.*/
     68 * need to copy the input array as fvec_median destroy its input data.*/
    6969void note_append (fvec_t * note_buffer, smpl_t curnote);
    7070uint_t get_note (fvec_t * note_buffer, fvec_t * note_buffer2);
  • src/mathutils.c

    r2f64b0e r5c4ec3c  
    9393}
    9494
    95 smpl_t vec_sum(fvec_t *s) {
     95smpl_t fvec_sum(fvec_t *s) {
    9696  uint_t i,j;
    9797  smpl_t tmp = 0.0f;
     
    142142}
    143143
    144 void vec_shift(fvec_t *s) {
     144void fvec_shift(fvec_t *s) {
    145145  uint_t i,j;
    146146  //smpl_t tmp = 0.0f;
     
    154154}
    155155
    156 smpl_t vec_local_energy(fvec_t * f) {
     156smpl_t fvec_local_energy(fvec_t * f) {
    157157  smpl_t locE = 0.;
    158158  uint_t i,j;
     
    163163}
    164164
    165 smpl_t vec_local_hfc(fvec_t * f) {
     165smpl_t fvec_local_hfc(fvec_t * f) {
    166166  smpl_t locE = 0.;
    167167  uint_t i,j;
     
    172172}
    173173
    174 smpl_t vec_alpha_norm(fvec_t * DF, smpl_t alpha) {
     174smpl_t fvec_alpha_norm(fvec_t * DF, smpl_t alpha) {
    175175  smpl_t tmp = 0.;
    176176  uint_t i,j;
     
    181181}
    182182
    183 void vec_dc_removal(fvec_t * mag) {
     183void fvec_dc_removal(fvec_t * mag) {
    184184    smpl_t mini = 0.;
    185185    uint_t length = mag->length, i=0, j;
     
    190190}
    191191
    192 void vec_alpha_normalise(fvec_t * mag, uint_t alpha) {
     192void fvec_alpha_normalise(fvec_t * mag, uint_t alpha) {
    193193  smpl_t alphan = 1.;
    194194  uint_t length = mag->length, i=0, j;
    195   alphan = vec_alpha_norm(mag,alpha);
     195  alphan = fvec_alpha_norm(mag,alpha);
    196196  for (j=0;j<length;j++){
    197197    mag->data[i][j] /= alphan;
     
    199199}
    200200
    201 void vec_add(fvec_t * mag, smpl_t threshold) {
     201void fvec_add(fvec_t * mag, smpl_t threshold) {
    202202  uint_t length = mag->length, i=0, j;
    203203  for (j=0;j<length;j++) {
     
    206206}
    207207
    208 void vec_adapt_thres(fvec_t * vec, fvec_t * tmp,
     208void fvec_adapt_thres(fvec_t * vec, fvec_t * tmp,
    209209    uint_t post, uint_t pre) {
    210210  uint_t length = vec->length, i=0, j;
    211211  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
     216smpl_t fvec_moving_thres(fvec_t * vec, fvec_t * tmpvec,
    217217    uint_t post, uint_t pre, uint_t pos) {
    218218  smpl_t * medar = (smpl_t *)tmpvec->data[0];
     
    237237      medar[k] = 0.; /* 0-padding at the end */
    238238  }
    239   return vec_median(tmpvec);
    240 }
    241 
    242 smpl_t vec_median(fvec_t * input) {
     239  return fvec_median(tmpvec);
     240}
     241
     242smpl_t fvec_median(fvec_t * input) {
    243243  uint_t n = input->length;
    244244  smpl_t * arr = (smpl_t *) input->data[0];
     
    291291}
    292292
    293 smpl_t vec_quadint(fvec_t * x,uint_t pos, uint_t span) {
     293smpl_t fvec_quadint(fvec_t * x,uint_t pos, uint_t span) {
    294294  smpl_t s0, s1, s2;
    295295  uint_t x0 = (pos < span) ? pos : pos - span;
     
    308308}
    309309
    310 uint_t vec_peakpick(fvec_t * onset, uint_t pos) {
     310uint_t fvec_peakpick(fvec_t * onset, uint_t pos) {
    311311  uint_t i=0, tmp=0;
    312312  /*for (i=0;i<onset->channels;i++)*/
  • src/mathutils.h

    r2f64b0e r5c4ec3c  
    9797 * a[n/2+1],...a[n],a[0]...,a[n/2]
    9898 */
    99 void vec_shift(fvec_t *s);
     99void fvec_shift(fvec_t *s);
    100100/** returns sum */
    101 smpl_t vec_sum(fvec_t *s);
     101smpl_t fvec_sum(fvec_t *s);
    102102
    103103/** returns energy
     
    105105 * \bug mono
    106106 */
    107 smpl_t vec_local_energy(fvec_t * f);
     107smpl_t fvec_local_energy(fvec_t * f);
    108108/** returns High Frequency Energy Content
    109109 *
    110110 * \bug mono */
    111 smpl_t vec_local_hfc(fvec_t * f);
     111smpl_t fvec_local_hfc(fvec_t * f);
    112112/** return alpha norm.
    113113 *
     
    119119 * \bug should not use POW :(
    120120 */
    121 smpl_t vec_alpha_norm(fvec_t * DF, smpl_t alpha);
     121smpl_t fvec_alpha_norm(fvec_t * DF, smpl_t alpha);
    122122/**  dc(min) removal */
    123 void vec_dc_removal(fvec_t * mag);
     123void fvec_dc_removal(fvec_t * mag);
    124124/**  alpha normalisation */
    125 void vec_alpha_normalise(fvec_t * mag, uint_t alpha);
     125void fvec_alpha_normalise(fvec_t * mag, uint_t alpha);
    126126/** add a constant to all members of a vector */
    127 void vec_add(fvec_t * mag, smpl_t threshold);
     127void fvec_add(fvec_t * mag, smpl_t threshold);
    128128
    129129/** compute adaptive threshold of input vector */
    130 void vec_adapt_thres(fvec_t * vec, fvec_t * tmp,
     130void fvec_adapt_thres(fvec_t * vec, fvec_t * tmp,
    131131    uint_t win_post, uint_t win_pre);
    132132/**  adaptative thresholding
     
    149149 * see SPARMS for explanation of post and pre
    150150 */
    151 smpl_t vec_moving_thres(fvec_t * vec, fvec_t * tmp,
     151smpl_t fvec_moving_thres(fvec_t * vec, fvec_t * tmp,
    152152    uint_t win_post, uint_t win_pre, uint_t win_pos);
    153153
     
    161161 *  available at http://ndevilla.free.fr/median/median/
    162162 */
    163 smpl_t vec_median(fvec_t * input);
     163smpl_t fvec_median(fvec_t * input);
    164164
    165165/** finds exact peak index by quadratic interpolation*/
    166 smpl_t vec_quadint(fvec_t * x, uint_t pos, uint_t span);
     166smpl_t fvec_quadint(fvec_t * x, uint_t pos, uint_t span);
    167167
    168168/** Quadratic interpolation using Lagrange polynomial.
     
    179179
    180180/** returns 1 if X1 is a peak and positive */
    181 uint_t vec_peakpick(fvec_t * input, uint_t pos);
     181uint_t fvec_peakpick(fvec_t * input, uint_t pos);
    182182
    183183/** convert frequency bin to midi value */
  • src/onset/peakpick.c

    r2f64b0e r5c4ec3c  
    161161        t->win_pre   = 1;
    162162
    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);
    165165
    166166        t->scratch = new_fvec(t->win_post+t->win_pre+1,1);
  • src/pitch/pitchmcomb.c

    r2f64b0e r5c4ec3c  
    9999    newmag->data[i][j]=fftgrain->norm[i][j];
    100100  /* detect only if local energy > 10. */
    101   //if (vec_local_energy(newmag)>10.) {
    102     //hfc = vec_local_hfc(newmag); //not used
     101  //if (fvec_local_energy(newmag)>10.) {
     102    //hfc = fvec_local_hfc(newmag); //not used
    103103    aubio_pitchmcomb_spectral_pp(p, newmag);
    104104    aubio_pitchmcomb_combdet(p,newmag);
     
    132132    newmag->data[i][j]=fftgrain->norm[i][j];
    133133  /* 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 */
    136136    aubio_pitchmcomb_spectral_pp(p, newmag);
    137137    aubio_pitchmcomb_combdet(p,newmag);
     
    159159    mag->data[i][j] = newmag->data[i][j];
    160160  }
    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  */
    163163  /* 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      */
    167167  {
    168168    aubio_spectralpeak_t * peaks = (aubio_spectralpeak_t *)p->peaks;
     
    269269  for (i=0;i<X->channels;i++)
    270270    for (j=1;j<X->length-1;j++) {
    271       ispeak = vec_peakpick(X,j);
     271      ispeak = fvec_peakpick(X,j);
    272272      if (ispeak) {
    273273        count += ispeak;
    274274        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.;
    276276      }
    277277    }
  • src/pitch/pitchyin.c

    r2f64b0e r5c4ec3c  
    107107    if(tau > 4 && (yin->data[c][period] < tol) &&
    108108        (yin->data[c][period] < yin->data[c][period+1])) {
    109       return vec_quadint(yin,period,1);
     109      return fvec_quadint(yin,period,1);
    110110    }
    111111  }
    112   return vec_quadint(yin,fvec_min_elem(yin),1);
     112  return fvec_quadint(yin,fvec_min_elem(yin),1);
    113113  //return 0;
    114114}
  • src/pitch/pitchyinfft.c

    r2f64b0e r5c4ec3c  
    125125    //return tau;
    126126    /* 3 point quadratic interpolation */
    127     //return vec_quadint_min(yin,tau,1);
     127    //return fvec_quadint_min(yin,tau,1);
    128128    /* additional check for (unlikely) octave doubling in higher frequencies */
    129129    if (tau>35) {
    130       return vec_quadint(yin,tau,1);
     130      return fvec_quadint(yin,tau,1);
    131131    } else {
    132132      /* should compare the minimum value of each interpolated peaks */
    133133      halfperiod = FLOOR(tau/2+.5);
    134134      if (yin->data[0][halfperiod] < tol)
    135         return vec_quadint(yin,halfperiod,1);
     135        return fvec_quadint(yin,halfperiod,1);
    136136      else
    137         return vec_quadint(yin,tau,1);
     137        return fvec_quadint(yin,tau,1);
    138138    }
    139139  } else
  • src/spectral/mfcc.c

    r2f64b0e r5c4ec3c  
    108108
    109109  /* raise power */
    110   //vec_pow (mf->in_dct, 3.);
     110  //fvec_pow (mf->in_dct, 3.);
    111111
    112112  /* zeros output */
  • src/spectral/phasevoc.c

    r2f64b0e r5c4ec3c  
    5757  fvec_weight(pv->data, pv->w);
    5858  /* shift */
    59   vec_shift(pv->data);
     59  fvec_shift(pv->data);
    6060  /* calculate fft */
    6161  aubio_fft_do (pv->fft,pv->data,fftgrain);
     
    6767  aubio_fft_rdo(pv->fft,fftgrain,pv->synth);
    6868  /* unshift */
    69   vec_shift(pv->synth);
     69  fvec_shift(pv->synth);
    7070  for (i=0; i<pv->channels; i++) {
    7171    aubio_pvoc_addsynth(pv->synth->data[i],pv->synthold->data[i],
  • src/tempo/beattracking.c

    r2f64b0e r5c4ec3c  
    170170  /* find non-zero Rayleigh period */
    171171  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;
    173173  //rp = (maxindex==127) ? 43 : maxindex; //rayparam
    174174  bt->rp = (maxindex == bt->acfout->length - 1) ? bt->rayparam : maxindex;      //rayparam
     
    203203    phase = step - bt->lastbeat;
    204204  } else {
    205     phase = vec_quadint (bt->phout, maxindex, 1);
     205    phase = fvec_quadint (bt->phout, maxindex, 1);
    206206  }
    207207  /* take back one frame delay */
     
    305305    }
    306306    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);
    308308    /*
    309309       while(gp<32) gp =gp*2;
     
    409409{
    410410  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);
    412412  } else {
    413413    return 0.;
  • swig/aubio.i

    r2f64b0e r5c4ec3c  
    135135uint_t fvec_min_elem(fvec_t *s);
    136136uint_t fvec_max_elem(fvec_t *s);
    137 void vec_shift(fvec_t *s);
    138 smpl_t vec_sum(fvec_t *s);
    139 smpl_t vec_local_energy(fvec_t * f);
    140 smpl_t vec_local_hfc(fvec_t * f);
    141 smpl_t vec_alpha_norm(fvec_t * DF, smpl_t alpha);
    142 void vec_dc_removal(fvec_t * mag);
    143 void vec_alpha_normalise(fvec_t * mag, uint_t alpha);
    144 void vec_add(fvec_t * mag, smpl_t threshold);
    145 void vec_adapt_thres(fvec_t * vec, fvec_t * tmp, uint_t post, uint_t pre);
    146 smpl_t vec_moving_thres(fvec_t * vec, fvec_t * tmp, uint_t post, uint_t pre, uint_t pos);
    147 smpl_t vec_median(fvec_t * input);
    148 smpl_t vec_quadint(fvec_t * x,uint_t pos, uint_t span);
     137void fvec_shift(fvec_t *s);
     138smpl_t fvec_sum(fvec_t *s);
     139smpl_t fvec_local_energy(fvec_t * f);
     140smpl_t fvec_local_hfc(fvec_t * f);
     141smpl_t fvec_alpha_norm(fvec_t * DF, smpl_t alpha);
     142void fvec_dc_removal(fvec_t * mag);
     143void fvec_alpha_normalise(fvec_t * mag, uint_t alpha);
     144void fvec_add(fvec_t * mag, smpl_t threshold);
     145void fvec_adapt_thres(fvec_t * vec, fvec_t * tmp, uint_t post, uint_t pre);
     146smpl_t fvec_moving_thres(fvec_t * vec, fvec_t * tmp, uint_t post, uint_t pre, uint_t pos);
     147smpl_t fvec_median(fvec_t * input);
     148smpl_t fvec_quadint(fvec_t * x,uint_t pos, uint_t span);
    149149smpl_t aubio_quadfrac(smpl_t s0, smpl_t s1, smpl_t s2, smpl_t pf);
    150 uint_t vec_peakpick(fvec_t * input, uint_t pos);
     150uint_t fvec_peakpick(fvec_t * input, uint_t pos);
    151151smpl_t aubio_bintomidi(smpl_t bin, smpl_t samplerate, smpl_t fftsize);
    152152smpl_t aubio_miditobin(smpl_t midi, smpl_t samplerate, smpl_t fftsize);
Note: See TracChangeset for help on using the changeset viewer.