Changeset d4791e5 for src


Ignore:
Timestamp:
Jan 3, 2014, 12:47:22 AM (11 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:
2e01060
Parents:
89e9e71 (diff), 4fe62ba (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 develop

Location:
src
Files:
24 edited

Legend:

Unmodified
Added
Removed
  • src/aubio_priv.h

    r89e9e71 rd4791e5  
    3434 */
    3535
    36 #if 1 //HAVE_CONFIG_H
    3736#include "config.h"
    38 #endif
    3937
    4038#if HAVE_STDLIB_H
     
    4745
    4846/* must be included before fftw3.h */
    49 #if HAVE_COMPLEX_H
     47#ifdef HAVE_COMPLEX_H
    5048#include <complex.h>
    5149#endif
    5250
    53 #if HAVE_FFTW3 || HAVE_FFTW3F
     51#if defined(HAVE_FFTW3) || defined(HAVE_FFTW3F)
    5452#include <fftw3.h>
    5553#endif
    5654
    57 #if HAVE_MATH_H
     55#ifdef HAVE_MATH_H
    5856#include <math.h>
    5957#endif
    6058
    61 #if HAVE_STRING_H
     59#ifdef HAVE_STRING_H
    6260#include <string.h>
    6361#endif
    6462
    65 #if HAVE_LIMITS_H
     63#ifdef HAVE_LIMITS_H
    6664#include <limits.h> // for CHAR_BIT, in C99 standard
    6765#endif
  • src/cvec.c

    r89e9e71 rd4791e5  
    2323
    2424cvec_t * new_cvec( uint_t length) {
     25  cvec_t * s;
    2526  if ((sint_t)length <= 0) {
    2627    return NULL;
    2728  }
    28   cvec_t * s = AUBIO_NEW(cvec_t);
     29  s = AUBIO_NEW(cvec_t);
    2930  s->length = length/2 + 1;
    3031  s->norm = AUBIO_ARRAY(smpl_t,s->length);
  • src/fmat.c

    r89e9e71 rd4791e5  
    2323
    2424fmat_t * new_fmat (uint_t height, uint_t length) {
     25  fmat_t * s;
     26  uint_t i,j;
    2527  if ((sint_t)length <= 0 || (sint_t)height <= 0 ) {
    2628    return NULL;
    2729  }
    28   fmat_t * s = AUBIO_NEW(fmat_t);
    29   uint_t i,j;
     30  s = AUBIO_NEW(fmat_t);
    3031  s->height = height;
    3132  s->length = length;
     
    127128
    128129void fmat_copy(fmat_t *s, fmat_t *t) {
     130  uint_t i;
     131#if !HAVE_MEMCPY_HACKS
     132  uint_t i,j;
     133#endif
    129134  if (s->height != t->height) {
    130135    AUBIO_ERR("trying to copy %d rows to %d rows \n",
     
    138143  }
    139144#if HAVE_MEMCPY_HACKS
    140   uint_t i;
    141145  for (i=0; i< s->height; i++) {
    142146    memcpy(t->data[i], s->data[i], t->length * sizeof(smpl_t));
    143147  }
    144148#else
    145   uint_t i,j;
    146149  for (i=0; i< t->height; i++) {
    147150    for (j=0; j< t->length; j++) {
  • src/fvec.c

    r89e9e71 rd4791e5  
    2323
    2424fvec_t * new_fvec( uint_t length) {
     25  fvec_t * s;
    2526  if ((sint_t)length <= 0) {
    2627    return NULL;
    2728  }
    28   fvec_t * s = AUBIO_NEW(fvec_t);
     29  s = AUBIO_NEW(fvec_t);
    2930  s->length = length;
    3031  s->data = AUBIO_ARRAY(smpl_t, s->length);
  • src/io/sink_sndfile.c

    r89e9e71 rd4791e5  
    4747aubio_sink_sndfile_t * new_aubio_sink_sndfile(char_t * path, uint_t samplerate) {
    4848  aubio_sink_sndfile_t * s = AUBIO_NEW(aubio_sink_sndfile_t);
     49  SF_INFO sfinfo;
    4950
    5051  if (path == NULL) {
     
    5960
    6061  /* set output format */
    61   SF_INFO sfinfo;
    6262  AUBIO_MEMSET(&sfinfo, 0, sizeof (sfinfo));
    6363  sfinfo.samplerate = s->samplerate;
     
    9292  int nsamples = channels*write;
    9393  smpl_t *pwrite;
     94  sf_count_t written_frames;
    9495
    9596  if (write > s->max_size) {
     
    107108  }
    108109
    109   sf_count_t written_frames = sf_write_float (s->handle, s->scratch_data, nsamples);
     110  written_frames = sf_write_float (s->handle, s->scratch_data, nsamples);
    110111  if (written_frames/channels != write) {
    111112    AUBIO_WRN("trying to write %d frames to %s, but only %d could be written",
  • src/io/source_avcodec.c

    r89e9e71 rd4791e5  
    6262// hack to create or re-create the context the first time _do or _do_multi is called
    6363void aubio_source_avcodec_reset_resampler(aubio_source_avcodec_t * s, uint_t multi);
     64void aubio_source_avcodec_readframe(aubio_source_avcodec_t *s, uint_t * read_samples);
    6465
    6566aubio_source_avcodec_t * new_aubio_source_avcodec(char_t * path, uint_t samplerate, uint_t hop_size) {
     
    279280        (uint8_t **)avFrame->data, in_linesize, in_samples);
    280281  if (out_samples <= 0) {
    281     AUBIO_ERR("No sample found while converting frame (%s)\n", s->path);
     282    //AUBIO_ERR("No sample found while converting frame (%s)\n", s->path);
    282283    goto beach;
    283284  }
  • src/io/source_sndfile.c

    r89e9e71 rd4791e5  
    6464aubio_source_sndfile_t * new_aubio_source_sndfile(char_t * path, uint_t samplerate, uint_t hop_size) {
    6565  aubio_source_sndfile_t * s = AUBIO_NEW(aubio_source_sndfile_t);
     66  SF_INFO sfinfo;
    6667
    6768  if (path == NULL) {
     
    8384
    8485  // try opening the file, getting the info in sfinfo
    85   SF_INFO sfinfo;
    8686  AUBIO_MEMSET(&sfinfo, 0, sizeof (sfinfo));
    8787  s->handle = sf_open (s->path, SFM_READ, &sfinfo);
  • src/lvec.c

    r89e9e71 rd4791e5  
    2323
    2424lvec_t * new_lvec( uint_t length) {
     25  lvec_t * s;
    2526  if ((sint_t)length <= 0) {
    2627    return NULL;
    2728  }
    28   lvec_t * s = AUBIO_NEW(lvec_t);
     29  s = AUBIO_NEW(lvec_t);
    2930  s->length = length;
    3031  s->data = AUBIO_ARRAY(lsmp_t, s->length);
     
    3738}
    3839
    39 void lvec_write_sample(lvec_t *s, lsmp_t data, uint_t position) {
     40void lvec_set_sample(lvec_t *s, lsmp_t data, uint_t position) {
    4041  s->data[position] = data;
    4142}
     43
    4244lsmp_t lvec_get_sample(lvec_t *s, uint_t position) {
    4345  return s->data[position];
  • src/mathutils.c

    r89e9e71 rd4791e5  
    5050{
    5151  fvec_t * win = new_fvec (length);
     52  uint_t err;
    5253  if (win == NULL) {
    5354    return NULL;
    5455  }
    55   uint_t err = fvec_set_window (win, window_type);
     56  err = fvec_set_window (win, window_type);
    5657  if (err != 0) {
    5758    del_fvec(win);
     
    417418
    418419smpl_t fvec_quadratic_peak_pos (fvec_t * x, uint_t pos) {
    419   smpl_t s0, s1, s2;
     420  smpl_t s0, s1, s2; uint_t x0, x2;
    420421  if (pos == 0 || pos == x->length - 1) return pos;
    421   uint_t x0 = (pos < 1) ? pos : pos - 1;
    422   uint_t x2 = (pos + 1 < x->length) ? pos + 1 : pos;
     422  x0 = (pos < 1) ? pos : pos - 1;
     423  x2 = (pos + 1 < x->length) ? pos + 1 : pos;
    423424  if (x0 == pos) return (x->data[pos] <= x->data[x2]) ? pos : x2;
    424425  if (x2 == pos) return (x->data[pos] <= x->data[x0]) ? pos : x0;
     
    448449aubio_freqtomidi (smpl_t freq)
    449450{
     451  smpl_t midi;
    450452  if (freq < 2. || freq > 100000.) return 0.; // avoid nans and infs
    451453  /* log(freq/A-2)/log(2) */
    452   smpl_t midi = freq / 6.875;
     454  midi = freq / 6.875;
    453455  midi = LOG (midi) / 0.69314718055995;
    454456  midi *= 12;
     
    460462aubio_miditofreq (smpl_t midi)
    461463{
     464  smpl_t freq;
    462465  if (midi > 140.) return 0.; // avoid infs
    463   smpl_t freq = (midi + 3.) / 12.;
     466  freq = (midi + 3.) / 12.;
    464467  freq = EXP (freq * 0.69314718055995);
    465468  freq *= 6.875;
  • src/onset/peakpicker.c

    r89e9e71 rd4791e5  
    166166
    167167aubio_peakpicker_t *
    168 new_aubio_peakpicker ()
     168new_aubio_peakpicker (void)
    169169{
    170170  aubio_peakpicker_t *t = AUBIO_NEW (aubio_peakpicker_t);
  • src/pitch/pitch.c

    r89e9e71 rd4791e5  
    367367aubio_pitch_do_specacf (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * out)
    368368{
     369  smpl_t pitch = 0., period;
    369370  aubio_pitch_slideblock (p, ibuf);
    370371  aubio_pitchspecacf_do (p->p_object, p->buf, out);
    371372  //out->data[0] = aubio_bintofreq (out->data[0], p->samplerate, p->bufsize);
    372   smpl_t pitch = 0., period = out->data[0];
     373  period = out->data[0];
    373374  if (period > 0) {
    374375    pitch = p->samplerate / period;
  • src/pitch/pitchspecacf.c

    r89e9e71 rd4791e5  
    5757aubio_pitchspecacf_do (aubio_pitchspecacf_t * p, fvec_t * input, fvec_t * output)
    5858{
    59   uint_t l;
     59  uint_t l, tau;
    6060  fvec_t *fftout = p->fftout;
    6161  // window the input
     
    7575  }
    7676  // get the minimum
    77   uint_t tau = fvec_min_elem (p->acf);
     77  tau = fvec_min_elem (p->acf);
    7878  // get the interpolated minimum
    7979  output->data[0] = fvec_quadratic_peak_pos (p->acf, tau) * 2.;
  • src/pitch/pitchyinfft.c

    r89e9e71 rd4791e5  
    5858new_aubio_pitchyinfft (uint_t samplerate, uint_t bufsize)
    5959{
     60  uint_t i = 0, j = 1;
     61  smpl_t freq = 0, a0 = 0, a1 = 0, f0 = 0, f1 = 0;
    6062  aubio_pitchyinfft_t *p = AUBIO_NEW (aubio_pitchyinfft_t);
    6163  p->winput = new_fvec (bufsize);
     
    6769  p->win = new_aubio_window ("hanningz", bufsize);
    6870  p->weight = new_fvec (bufsize / 2 + 1);
    69   uint_t i = 0, j = 1;
    70   smpl_t freq = 0, a0 = 0, a1 = 0, f0 = 0, f1 = 0;
    7171  for (i = 0; i < p->weight->length; i++) {
    7272    freq = (smpl_t) i / (smpl_t) bufsize *(smpl_t) samplerate;
  • src/spectral/filterbank_mel.c

    r89e9e71 rd4791e5  
    2525#include "cvec.h"
    2626#include "spectral/filterbank.h"
     27#include "spectral/filterbank_mel.h"
    2728#include "mathutils.h"
    2829
     
    3435  fmat_t *filters = aubio_filterbank_get_coeffs (fb);
    3536  uint_t n_filters = filters->height, win_s = filters->length;
     37  fvec_t *lower_freqs, *upper_freqs, *center_freqs;
     38  fvec_t *triangle_heights, *fft_freqs;
    3639
    3740  uint_t fn;                    /* filter counter */
    3841  uint_t bin;                   /* bin counter */
     42
     43  smpl_t riseInc, downInc;
    3944
    4045  /* freqs define the bands of triangular overlapping windows.
     
    5661
    5762  /* convenience reference to lower/center/upper frequency for each triangle */
    58   fvec_t *lower_freqs = new_fvec (n_filters);
    59   fvec_t *upper_freqs = new_fvec (n_filters);
    60   fvec_t *center_freqs = new_fvec (n_filters);
     63  lower_freqs = new_fvec (n_filters);
     64  upper_freqs = new_fvec (n_filters);
     65  center_freqs = new_fvec (n_filters);
    6166
    6267  /* height of each triangle */
    63   fvec_t *triangle_heights = new_fvec (n_filters);
     68  triangle_heights = new_fvec (n_filters);
    6469
    6570  /* lookup table of each bin frequency in hz */
    66   fvec_t *fft_freqs = new_fvec (win_s);
     71  fft_freqs = new_fvec (win_s);
    6772
    6873  /* fill up the lower/center/upper */
     
    112117
    113118    /* compute positive slope step size */
    114     smpl_t riseInc =
     119    riseInc =
    115120        triangle_heights->data[fn] /
    116121        (center_freqs->data[fn] - lower_freqs->data[fn]);
     
    128133
    129134    /* compute negative slope step size */
    130     smpl_t downInc =
     135    downInc =
    131136        triangle_heights->data[fn] /
    132137        (upper_freqs->data[fn] - center_freqs->data[fn]);
     
    176181  uint_t fn;                    /* filter counter */
    177182
     183  smpl_t lastlinearCF;
     184
    178185  /* buffers to compute filter frequencies */
    179186  fvec_t *freqs = new_fvec (n_filters + 2);
     
    183190    freqs->data[fn] = lowestFrequency + fn * linearSpacing;
    184191  }
    185   smpl_t lastlinearCF = freqs->data[fn - 1];
     192  lastlinearCF = freqs->data[fn - 1];
    186193
    187194  /* second step: fill all the log filter frequencies */
  • src/spectral/mfcc.c

    r89e9e71 rd4791e5  
    5252  /* allocate space for mfcc object */
    5353  aubio_mfcc_t *mfcc = AUBIO_NEW (aubio_mfcc_t);
     54  smpl_t scaling;
    5455
    5556  uint_t i, j;
     
    7172  /* compute DCT transform dct_coeffs[i][j] as
    7273     cos ( j * (i+.5) * PI / n_filters ) */
    73   smpl_t scaling = 1. / SQRT (n_filters / 2.);
     74  scaling = 1. / SQRT (n_filters / 2.);
    7475  for (i = 0; i < n_filters; i++) {
    7576    for (j = 0; j < n_coefs; j++) {
  • src/spectral/ooura_fft8g.c

    r89e9e71 rd4791e5  
    1 // 2 modifications made for aubio:
     1// modifications made for aubio:
    22//  - replace all 'double' with 'smpl_t'
    33//  - include "aubio_priv.h" (for config.h and types.h)
     4//  - add missing prototypes
    45
    56#include "aubio_priv.h"
     7
     8void cdft(int n, int isgn, smpl_t *a, int *ip, smpl_t *w);
     9void rdft(int n, int isgn, smpl_t *a, int *ip, smpl_t *w);
     10void ddct(int n, int isgn, smpl_t *a, int *ip, smpl_t *w);
     11void ddst(int n, int isgn, smpl_t *a, int *ip, smpl_t *w);
     12void dfct(int n, smpl_t *a, smpl_t *t, int *ip, smpl_t *w);
     13void dfst(int n, smpl_t *a, smpl_t *t, int *ip, smpl_t *w);
     14void makewt(int nw, int *ip, smpl_t *w);
     15void makect(int nc, int *ip, smpl_t *c);
     16void bitrv2(int n, int *ip, smpl_t *a);
     17void bitrv2conj(int n, int *ip, smpl_t *a);
     18void cftfsub(int n, smpl_t *a, smpl_t *w);
     19void cftbsub(int n, smpl_t *a, smpl_t *w);
     20void cft1st(int n, smpl_t *a, smpl_t *w);
     21void cftmdl(int n, int l, smpl_t *a, smpl_t *w);
     22void rftfsub(int n, smpl_t *a, int nc, smpl_t *c);
     23void rftbsub(int n, smpl_t *a, int nc, smpl_t *c);
     24void dctsub(int n, smpl_t *a, int nc, smpl_t *c);
     25void dstsub(int n, smpl_t *a, int nc, smpl_t *c);
    626
    727/*
  • src/spectral/phasevoc.c

    r89e9e71 rd4791e5  
    120120    const smpl_t * datanew, uint_t win_s, uint_t hop_s)
    121121{
     122#if !HAVE_MEMCPY_HACKS
    122123  uint_t i;
    123124  for (i = 0; i < win_s - hop_s; i++)
     
    127128  for (i = 0; i < win_s - hop_s; i++)
    128129    dataold[i] = data[i + hop_s];
     130#else
     131  memcpy(data, dataold, (win_s - hop_s) * sizeof(smpl_t));
     132  data += win_s - hop_s;
     133  memcpy(data, datanew, hop_s * sizeof(smpl_t));
     134  data -= win_s - hop_s;
     135  data += hop_s;
     136  memcpy(dataold, data, (win_s - hop_s) * sizeof(smpl_t));
     137#endif
    129138}
    130139
  • src/spectral/statistics.c

    r89e9e71 rd4791e5  
    2222#include "cvec.h"
    2323#include "spectral/specdesc.h"
     24
     25void aubio_specdesc_centroid (aubio_specdesc_t * o, cvec_t * spec,
     26    fvec_t * desc);
     27void aubio_specdesc_spread (aubio_specdesc_t * o, cvec_t * spec,
     28    fvec_t * desc);
     29void aubio_specdesc_skewness (aubio_specdesc_t * o, cvec_t * spec,
     30    fvec_t * desc);
     31void aubio_specdesc_kurtosis (aubio_specdesc_t * o, cvec_t * spec,
     32    fvec_t * desc);
     33void aubio_specdesc_slope (aubio_specdesc_t * o, cvec_t * spec,
     34    fvec_t * desc);
     35void aubio_specdesc_decrease (aubio_specdesc_t * o, cvec_t * spec,
     36    fvec_t * desc);
     37void aubio_specdesc_rolloff (aubio_specdesc_t * o, cvec_t * spec,
     38    fvec_t * desc);
     39
     40
     41smpl_t cvec_sum (cvec_t * s);
     42smpl_t cvec_mean (cvec_t * s);
     43smpl_t cvec_centroid (cvec_t * s);
     44smpl_t cvec_moment (cvec_t * s, uint_t moment);
    2445
    2546smpl_t
  • src/synth/wavetable.c

    r89e9e71 rd4791e5  
    4343aubio_wavetable_t *new_aubio_wavetable(uint_t samplerate, uint_t blocksize)
    4444{
     45  uint_t i = 0;
    4546  aubio_wavetable_t *s = AUBIO_NEW(aubio_wavetable_t);
    4647  if ((sint_t)samplerate <= 0) {
     
    4849    goto beach;
    4950  }
    50   uint_t i = 0;
    5151  s->samplerate = samplerate;
    5252  s->blocksize = blocksize;
     
    115115    for (j = 0; j < output->length; j++) {
    116116      smpl_t inc = aubio_parameter_get_next_value( s->freq );
     117      smpl_t amp = aubio_parameter_get_next_value ( s->amp );
    117118      inc *= (smpl_t)(s->wavetable_length) / (smpl_t) (s->samplerate);
    118119      pos += inc;
     
    120121        pos -= s->wavetable_length;
    121122      }
    122       smpl_t amp = aubio_parameter_get_next_value ( s->amp );
    123123      for (i = 0; i < output->height; i++) {
    124124        output->data[i][j] = amp * interp_2(s->wavetable, pos);
  • src/tempo/beattracking.c

    r89e9e71 rd4791e5  
    6262  aubio_beattracking_t *p = AUBIO_NEW (aubio_beattracking_t);
    6363  uint_t i = 0;
    64   p->hop_size = hop_size;
    65   p->samplerate = samplerate;
    6664  /* default value for rayleigh weighting - sets preferred tempo to 120bpm */
    6765  smpl_t rayparam = 60. * samplerate / 120. / hop_size;
     
    7371  uint_t step = winlen / 4;     /* 1.5 seconds */
    7472
     73  p->hop_size = hop_size;
     74  p->samplerate = samplerate;
    7575  p->lastbeat = 0;
    7676  p->counter = 0;
  • src/tempo/tempo.c

    r89e9e71 rd4791e5  
    2828#include "mathutils.h"
    2929#include "tempo/tempo.h"
     30
     31// TODO implement get/set_delay
     32
     33/** set current delay
     34
     35  \param o beat tracking object
     36
     37  \return current delay, in samples
     38
     39 */
     40uint_t aubio_tempo_get_delay(aubio_tempo_t * o);
     41
     42/** set current delay
     43
     44  \param o beat tracking object
     45  \param delay delay to set tempo to, in samples
     46
     47  \return `0` if successful, non-zero otherwise
     48
     49 */
     50uint_t aubio_tempo_set_delay(aubio_tempo_t * o, uint_t delay);
    3051
    3152/* structure to store object state */
  • src/temporal/a_weighting.c

    r89e9e71 rd4791e5  
    2929aubio_filter_set_a_weighting (aubio_filter_t * f, uint_t samplerate)
    3030{
     31  uint_t order; lsmp_t *a, *b; lvec_t *as, *bs;
    3132  aubio_filter_set_samplerate (f, samplerate);
    32   lvec_t *bs = aubio_filter_get_feedforward (f);
    33   lvec_t *as = aubio_filter_get_feedback (f);
    34   lsmp_t *b = bs->data, *a = as->data;
    35   uint_t order = aubio_filter_get_order (f);
     33  bs = aubio_filter_get_feedforward (f);
     34  as = aubio_filter_get_feedback (f);
     35  b = bs->data, a = as->data;
     36  order = aubio_filter_get_order (f);
    3637
    3738  if (order != 7) {
  • src/temporal/biquad.c

    r89e9e71 rd4791e5  
    2323#include "lvec.h"
    2424#include "temporal/filter.h"
     25#include "temporal/biquad.h"
    2526
    2627uint_t
  • src/temporal/c_weighting.c

    r89e9e71 rd4791e5  
    2929aubio_filter_set_c_weighting (aubio_filter_t * f, uint_t samplerate)
    3030{
     31  uint_t order; lsmp_t *a, *b; lvec_t *as, *bs;
    3132  aubio_filter_set_samplerate (f, samplerate);
    32   lvec_t *bs = aubio_filter_get_feedforward (f);
    33   lvec_t *as = aubio_filter_get_feedback (f);
    34   lsmp_t *b = bs->data, *a = as->data;
    35   uint_t order = aubio_filter_get_order (f);
     33  bs = aubio_filter_get_feedforward (f);
     34  as = aubio_filter_get_feedback (f);
     35  b = bs->data, a = as->data;
     36  order = aubio_filter_get_order (f);
    3637
    3738  if ( order != 5 ) {
Note: See TracChangeset for help on using the changeset viewer.