Changeset dc467b5d for src


Ignore:
Timestamp:
Oct 27, 2013, 12:44:29 PM (10 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:
8247249
Parents:
dd15573 (diff), 7fc5ba2 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'develop' of aubio.org:/git/aubio/aubio into wavetable

Location:
src
Files:
2 added
14 edited

Legend:

Unmodified
Added
Removed
  • src/aubio.h

    rdd15573 rdc467b5d  
    110110
    111111  Several examples of C programs are available in the \p examples/ and \p tests/src
    112   directory of the source tree.
     112  directories of the source tree.
    113113
    114114  \subsection unstable_api Unstable API
     
    185185#include "io/source.h"
    186186#include "io/sink.h"
     187#include "io/audio_unit.h"
    187188#include "synth/sampler.h"
    188189#include "synth/wavetable.h"
  • src/fmat.c

    rdd15573 rdc467b5d  
    5555  s->data[channel] = data;
    5656}
    57 smpl_t * fmat_get_channel(fmat_t *s, uint_t channel) {
    58   return s->data[channel];
     57void fmat_get_channel(fmat_t *s, uint_t channel, fvec_t *output) {
     58  output->data = s->data[channel];
     59  output->length = s->length;
     60  return;
    5961}
    6062
  • src/fmat.h

    rdd15573 rdc467b5d  
    9292
    9393*/
    94 smpl_t * fmat_get_channel(fmat_t *s, uint_t channel);
     94void fmat_get_channel (fmat_t *s, uint_t channel, fvec_t *output);
    9595/** write channel vector into a buffer
    9696
  • src/io/source_sndfile.c

    rdd15573 rdc467b5d  
    5959  // some temporary memory for sndfile to write at
    6060  uint_t scratch_size;
    61   smpl_t *scratch_data;
     61  float *scratch_data;
    6262};
    6363
     
    199199  }
    200200
    201   /* de-interleaving data */
    202   for (j = 0; j < read_samples / input_channels; j++) {
    203     for (i = 0; i < input_channels; i++) {
    204       data[i][j] = (smpl_t)s->scratch_data[input_channels*j+i];
    205     }
    206   }
    207   // if read_data has more channels than the file
     201  if (read_data->height < input_channels) {
     202    // destination matrix has less channels than the file; copy only first
     203    // channels of the file, de-interleaving data
     204    for (j = 0; j < read_samples / input_channels; j++) {
     205      for (i = 0; i < read_data->height; i++) {
     206        data[i][j] = (smpl_t)s->scratch_data[j * input_channels + i];
     207      }
     208    }
     209  } else {
     210    // destination matrix has as many or more channels than the file; copy each
     211    // channel from the file to the destination matrix, de-interleaving data
     212    for (j = 0; j < read_samples / input_channels; j++) {
     213      for (i = 0; i < input_channels; i++) {
     214        data[i][j] = (smpl_t)s->scratch_data[j * input_channels + i];
     215      }
     216    }
     217  }
     218
    208219  if (read_data->height > input_channels) {
    209     // copy last channel to all additional channels
     220    // destination matrix has more channels than the file; copy last channel
     221    // of the file to each additional channels, de-interleaving data
    210222    for (j = 0; j < read_samples / input_channels; j++) {
    211223      for (i = input_channels; i < read_data->height; i++) {
    212         data[i][j] = s->scratch_data[ j * input_channels + (input_channels - 1)];
     224        data[i][j] = (smpl_t)s->scratch_data[j * input_channels + (input_channels - 1)];
    213225      }
    214226    }
  • src/mathutils.c

    rdd15573 rdc467b5d  
    2727#include "config.h"
    2828
     29#ifdef HAVE_ACCELERATE
     30#include <Accelerate/Accelerate.h>
     31#endif
    2932
    3033/** Window types */
     
    170173fvec_max (fvec_t * s)
    171174{
     175#ifndef HAVE_ACCELERATE
    172176  uint_t j;
    173177  smpl_t tmp = 0.0;
     
    175179    tmp = (tmp > s->data[j]) ? tmp : s->data[j];
    176180  }
     181#else
     182  smpl_t tmp = 0.;
     183#if !HAVE_AUBIO_DOUBLE
     184  vDSP_maxv(s->data, 1, &tmp, s->length);
     185#else
     186  vDSP_maxvD(s->data, 1, &tmp, s->length);
     187#endif
     188#endif
    177189  return tmp;
    178190}
     
    181193fvec_min (fvec_t * s)
    182194{
     195#ifndef HAVE_ACCELERATE
    183196  uint_t j;
    184197  smpl_t tmp = s->data[0];
     
    186199    tmp = (tmp < s->data[j]) ? tmp : s->data[j];
    187200  }
     201#else
     202  smpl_t tmp = 0.;
     203#if !HAVE_AUBIO_DOUBLE
     204  vDSP_minv(s->data, 1, &tmp, s->length);
     205#else
     206  vDSP_minvD(s->data, 1, &tmp, s->length);
     207#endif
     208#endif
    188209  return tmp;
    189210}
     
    192213fvec_min_elem (fvec_t * s)
    193214{
     215#ifndef HAVE_ACCELERATE
    194216  uint_t j, pos = 0.;
    195217  smpl_t tmp = s->data[0];
     
    198220    tmp = (tmp < s->data[j]) ? tmp : s->data[j];
    199221  }
     222#else
     223  smpl_t tmp = 0.;
     224  uint_t pos = 0.;
     225#if !HAVE_AUBIO_DOUBLE
     226  vDSP_minvi(s->data, 1, &tmp, (vDSP_Length *)&pos, s->length);
     227#else
     228  vDSP_minviD(s->data, 1, &tmp, (vDSP_Length *)&pos, s->length);
     229#endif
     230#endif
    200231  return pos;
    201232}
     
    204235fvec_max_elem (fvec_t * s)
    205236{
     237#ifndef HAVE_ACCELERATE
    206238  uint_t j, pos = 0;
    207239  smpl_t tmp = 0.0;
     
    210242    tmp = (tmp > s->data[j]) ? tmp : s->data[j];
    211243  }
     244#else
     245  smpl_t tmp = 0.;
     246  uint_t pos = 0.;
     247#if !HAVE_AUBIO_DOUBLE
     248  vDSP_maxvi(s->data, 1, &tmp, (vDSP_Length *)&pos, s->length);
     249#else
     250  vDSP_maxviD(s->data, 1, &tmp, (vDSP_Length *)&pos, s->length);
     251#endif
     252#endif
    212253  return pos;
    213254}
     
    368409}
    369410
    370 smpl_t fvec_quadint (fvec_t * x, uint_t pos) {
    371   smpl_t s0, s1, s2;
    372   uint_t x0 = (pos < 1) ? pos : pos - 1;
    373   uint_t x2 = (pos + 1 < x->length) ? pos + 1 : pos;
    374   if (x0 == pos) return (x->data[pos] <= x->data[x2]) ? pos : x2;
    375   if (x2 == pos) return (x->data[pos] <= x->data[x0]) ? pos : x0;
    376   s0 = x->data[x0];
    377   s1 = x->data[pos];
    378   s2 = x->data[x2];
    379   return pos + 0.5 * (s2 - s0 ) / (s2 - 2.* s1 + s0);
    380 }
    381 
    382411smpl_t fvec_quadratic_peak_pos (fvec_t * x, uint_t pos) {
    383412  smpl_t s0, s1, s2;
     413  if (pos == 0 || pos == x->length - 1) return pos;
    384414  uint_t x0 = (pos < 1) ? pos : pos - 1;
    385415  uint_t x2 = (pos + 1 < x->length) ? pos + 1 : pos;
  • src/mathutils.h

    rdd15573 rdc467b5d  
    232232smpl_t fvec_median (fvec_t * v);
    233233
    234 /** finds exact peak index by quadratic interpolation*/
    235 smpl_t fvec_quadint (fvec_t * x, uint_t pos);
    236 
    237234/** finds exact peak index by quadratic interpolation
    238235
  • src/onset/onset.c

    rdd15573 rdc467b5d  
    9393smpl_t aubio_onset_get_last_ms (aubio_onset_t *o)
    9494{
    95   return aubio_onset_get_last_s (o) / 1000.;
     95  return aubio_onset_get_last_s (o) * 1000.;
    9696}
    9797
  • src/onset/peakpicker.c

    rdd15573 rdc467b5d  
    125125  out->data[0] = (p->pickerfn) (onset_peek, 1);
    126126  if (out->data[0]) {
    127     out->data[0] = fvec_quadint (onset_peek, 1);
     127    out->data[0] = fvec_quadratic_peak_pos (onset_peek, 1);
    128128  }
    129129}
  • src/pitch/pitchspecacf.c

    rdd15573 rdc467b5d  
    5050  p->acf = new_fvec (bufsize / 2 + 1);
    5151  p->tol = 1.;
     52  p->confidence = 0.;
    5253  return p;
    5354}
     
    9293smpl_t
    9394aubio_pitchspecacf_get_confidence (aubio_pitchspecacf_t * o) {
    94   return 0;
     95  // no confidence for now
     96  return o->confidence;
    9597}
    9698
  • src/spectral/fft.c

    rdd15573 rdc467b5d  
    100100#ifdef HAVE_ACCELERATE        // using ACCELERATE
    101101  int log2fftsize;
     102#if !HAVE_AUBIO_DOUBLE
    102103  FFTSetup fftSetup;
    103104  DSPSplitComplex spec;
    104105  float *in, *out;
     106#else
     107  FFTSetupD fftSetup;
     108  DSPDoubleSplitComplex spec;
     109  double *in, *out;
     110#endif
    105111#else                         // using OOURA
    106112  double *in, *out;
     
    148154  s->compspec = new_fvec(winsize);
    149155  s->log2fftsize = (uint_t)log2f(s->fft_size);
     156#if !HAVE_AUBIO_DOUBLE
    150157  s->in = AUBIO_ARRAY(float, s->fft_size);
    151158  s->out = AUBIO_ARRAY(float, s->fft_size);
     
    153160  s->spec.imagp = AUBIO_ARRAY(float, s->fft_size/2);
    154161  s->fftSetup = vDSP_create_fftsetup(s->log2fftsize, FFT_RADIX2);
     162#else
     163  s->in = AUBIO_ARRAY(double, s->fft_size);
     164  s->out = AUBIO_ARRAY(double, s->fft_size);
     165  s->spec.realp = AUBIO_ARRAY(double, s->fft_size/2);
     166  s->spec.imagp = AUBIO_ARRAY(double, s->fft_size/2);
     167  s->fftSetup = vDSP_create_fftsetupD(s->log2fftsize, FFT_RADIX2);
     168#endif
    155169#else                         // using OOURA
    156170  s->winsize = winsize;
     
    219233#else /* HAVE_FFTW3 */
    220234#ifdef HAVE_ACCELERATE        // using ACCELERATE
     235#if !HAVE_AUBIO_DOUBLE
    221236  // convert real data to even/odd format used in vDSP
    222   vDSP_ctoz((COMPLEX*)s->in, 2, &s->spec, 1, s->fft_size/2);
     237  vDSP_ctoz((DSPComplex*)s->in, 2, &s->spec, 1, s->fft_size/2);
    223238  // compute the FFT
    224239  vDSP_fft_zrip(s->fftSetup, &s->spec, 1, s->log2fftsize, FFT_FORWARD);
     240#else
     241  // convert real data to even/odd format used in vDSP
     242  vDSP_ctozD((DSPDoubleComplex*)s->in, 2, &s->spec, 1, s->fft_size/2);
     243  // compute the FFT
     244  vDSP_fft_zripD(s->fftSetup, &s->spec, 1, s->log2fftsize, FFT_FORWARD);
     245#endif
    225246  // convert from vDSP complex split to [ r0, r1, ..., rN, iN-1, .., i2, i1]
    226247  compspec->data[0] = s->spec.realp[0];
     
    232253  // apply scaling
    233254  smpl_t scale = 1./2.;
     255#if !HAVE_AUBIO_DOUBLE
    234256  vDSP_vsmul(compspec->data, 1, &scale, compspec->data, 1, s->fft_size);
     257#else
     258  vDSP_vsmulD(compspec->data, 1, &scale, compspec->data, 1, s->fft_size);
     259#endif
    235260#else                         // using OOURA
    236261  rdft(s->winsize, 1, s->in, s->ip, s->w);
     
    275300    s->out[2 * i + 1] = compspec->data[s->winsize - i];
    276301  }
     302#if !HAVE_AUBIO_DOUBLE
    277303  // convert to split complex format used in vDSP
    278   vDSP_ctoz((COMPLEX*)s->out, 2, &s->spec, 1, s->fft_size/2);
     304  vDSP_ctoz((DSPComplex*)s->out, 2, &s->spec, 1, s->fft_size/2);
    279305  // compute the FFT
    280306  vDSP_fft_zrip(s->fftSetup, &s->spec, 1, s->log2fftsize, FFT_INVERSE);
    281307  // convert result to real output
    282   vDSP_ztoc(&s->spec, 1, (COMPLEX*)output->data, 2, s->fft_size/2);
     308  vDSP_ztoc(&s->spec, 1, (DSPComplex*)output->data, 2, s->fft_size/2);
    283309  // apply scaling
    284310  smpl_t scale = 1.0 / s->winsize;
    285311  vDSP_vsmul(output->data, 1, &scale, output->data, 1, s->fft_size);
     312#else
     313  // convert to split complex format used in vDSP
     314  vDSP_ctozD((DSPDoubleComplex*)s->out, 2, &s->spec, 1, s->fft_size/2);
     315  // compute the FFT
     316  vDSP_fft_zripD(s->fftSetup, &s->spec, 1, s->log2fftsize, FFT_INVERSE);
     317  // convert result to real output
     318  vDSP_ztocD(&s->spec, 1, (DSPDoubleComplex*)output->data, 2, s->fft_size/2);
     319  // apply scaling
     320  smpl_t scale = 1.0 / s->winsize;
     321  vDSP_vsmulD(output->data, 1, &scale, output->data, 1, s->fft_size);
     322#endif
    286323#else                         // using OOURA
    287324  smpl_t scale = 2.0 / s->winsize;
  • src/spectral/filterbank.h

    rdd15573 rdc467b5d  
    5555/** destroy filterbank object
    5656
    57   \param fb filterbank, as returned by new_aubio_filterbank() method
     57  \param f filterbank object, as returned by new_aubio_filterbank()
    5858
    5959*/
    60 void del_aubio_filterbank (aubio_filterbank_t * fb);
     60void del_aubio_filterbank (aubio_filterbank_t * f);
    6161
    6262/** compute filterbank
    6363
    64   \param fb filterbank containing     nfilt x win_s filter coefficients
    65   \param in input spectrum containing chans x win_s spectrum
    66   \param out output vector containing chans x nfilt output values
     64  \param f filterbank object, as returned by new_aubio_filterbank()
     65  \param in input spectrum containing an input spectrum of length `win_s`
     66  \param out output vector containing the energy found in each band, `nfilt` output values
    6767
    6868*/
    69 void aubio_filterbank_do (aubio_filterbank_t * fb, cvec_t * in, fvec_t * out);
     69void aubio_filterbank_do (aubio_filterbank_t * f, cvec_t * in, fvec_t * out);
    7070
    71 /** return a pointer to the matrix object containing all filter coefficients 
     71/** return a pointer to the matrix object containing all filter coefficients
    7272
    73   \param f filterbank object to get coefficients from
     73  \param f filterbank object, as returned by new_aubio_filterbank()
    7474
    7575 */
     
    7878/** copy filter coefficients to the filterbank
    7979
    80   \param f filterbank object to set coefficients
     80  \param f filterbank object, as returned by new_aubio_filterbank()
    8181  \param filters filter bank coefficients to copy from
    8282
  • src/tempo/beattracking.c

    rdd15573 rdc467b5d  
    171171  /* find non-zero Rayleigh period */
    172172  maxindex = fvec_max_elem (bt->acfout);
    173   bt->rp = maxindex ? fvec_quadint (bt->acfout, maxindex) : 1;
     173  bt->rp = maxindex ? fvec_quadratic_peak_pos (bt->acfout, maxindex) : 1;
    174174  //rp = (maxindex==127) ? 43 : maxindex; //rayparam
    175175  bt->rp = (maxindex == bt->acfout->length - 1) ? bt->rayparam : maxindex;      //rayparam
     
    183183  /* end of biased filterbank */
    184184
     185  if (bp == 0) {
     186    output->data[0] = 0;
     187    return;
     188  }
    185189
    186190  /* deliberate integer operation, could be set to 3 max eventually */
     
    204208    phase = step - bt->lastbeat;
    205209  } else {
    206     phase = fvec_quadint (bt->phout, maxindex);
     210    phase = fvec_quadratic_peak_pos (bt->phout, maxindex);
    207211  }
    208212  /* take back one frame delay */
     
    306310    }
    307311    fvec_weight (acfout, bt->gwv);
    308     gp = fvec_quadint (acfout, fvec_max_elem (acfout));
     312    gp = fvec_quadratic_peak_pos (acfout, fvec_max_elem (acfout));
    309313    /*
    310314       while(gp<32) gp =gp*2;
     
    382386
    383387  /* if tempo is > 206 bpm, half it */
    384   while (bp < 25) {
     388  while (0 < bp && bp < 25) {
    385389#if AUBIO_BEAT_WARNINGS
    386390    AUBIO_WRN ("doubling from %f (%f bpm) to %f (%f bpm)\n",
     
    409413aubio_beattracking_get_bpm (aubio_beattracking_t * bt)
    410414{
    411   if (bt->timesig != 0 && bt->counter == 0 && bt->flagstep == 0) {
    412     return 5168. / fvec_quadint (bt->acfout, bt->bp);
     415  if (bt->bp != 0 && bt->timesig != 0 && bt->counter == 0 && bt->flagstep == 0) {
     416    return 5168. / fvec_quadratic_peak_pos (bt->acfout, bt->bp);
    413417  } else {
    414418    return 0.;
  • src/tempo/tempo.c

    rdd15573 rdc467b5d  
    113113smpl_t aubio_tempo_get_last_ms (aubio_tempo_t *o)
    114114{
    115   return aubio_tempo_get_last_s (o) / 1000.;
     115  return aubio_tempo_get_last_s (o) * 1000.;
    116116}
    117117
  • src/wscript_build

    rdd15573 rdc467b5d  
    1212# build libaubio
    1313from waflib import Options
    14 if Options.platform == 'ios': build_lib_func = ctx.stlib
    15 else: build_lib_func = ctx.shlib
     14if Options.platform in ['ios', 'iosimulator']:
     15    build_lib_func = ctx.stlib
     16else:
     17    build_lib_func = ctx.shlib
     18
    1619build_lib_func(
    1720    includes = ['.'],
     
    2023    lib = 'm',
    2124    uselib = uselib,
     25    install_path = '${PREFIX}/lib',
    2226    vnum = ctx.env['LIB_VERSION'])
    2327
    2428# install headers, except _priv.h ones
    2529ctx.install_files('${PREFIX}/include/aubio/',
    26 
    2730    ctx.path.ant_glob('**/*.h', excl = ['**_priv.h', 'config.h']),
    2831    relative_trick=True)
Note: See TracChangeset for help on using the changeset viewer.