Changes in / [0536612:f658288]


Ignore:
Files:
4 added
102 edited

Legend:

Unmodified
Added
Removed
  • examples/aubiomfcc.c

    r0536612 rf658288  
    3333
    3434static int aubio_process(smpl_t **input, smpl_t **output, int nframes) {
    35   unsigned int i;       /*channels*/
    3635  unsigned int j;       /*frames*/
    3736 
    3837  for (j=0;j<(unsigned)nframes;j++) {
    3938    if(usejack) {
    40       for (i=0;i<channels;i++) {
    41         /* write input to datanew */
    42         fvec_write_sample(ibuf, input[i][j], i, pos);
    43         /* put synthnew in output */
    44         output[i][j] = fvec_read_sample(obuf, i, pos);
    45       }
     39      /* write input to datanew */
     40      fvec_write_sample(ibuf, input[0][j], pos);
     41      /* put synthnew in output */
     42      output[0][j] = fvec_read_sample(obuf, pos);
    4643    }
    4744    /*time for fft*/
     
    5047     
    5148      //compute mag spectrum
    52       aubio_pvoc_do (pv,ibuf, fftgrain);
     49      aubio_pvoc_do (pv, ibuf, fftgrain);
    5350     
    5451      //compute mfccs
     
    7269        outmsg("%f\t",frames*overlap_size/(float)samplerate);
    7370        for (coef_cnt = 0; coef_cnt < n_coefs; coef_cnt++) {
    74             outmsg("%f ", fvec_read_sample (mfcc_out, 0, coef_cnt) );
     71            outmsg("%f ", fvec_read_sample (mfcc_out, coef_cnt) );
    7572        }
    7673        outmsg("\n");
     
    8683
    8784  /* phase vocoder */
    88   pv = new_aubio_pvoc (buffer_size, overlap_size, channels);
     85  pv = new_aubio_pvoc (buffer_size, overlap_size);
    8986
    90   fftgrain = new_cvec (buffer_size, channels);
     87  fftgrain = new_cvec (buffer_size);
    9188
    9289  //populating the filter
    9390  mfcc = new_aubio_mfcc(buffer_size, n_filters, n_coefs, samplerate);
    9491 
    95   mfcc_out = new_fvec(n_coefs,channels);
     92  mfcc_out = new_fvec(n_coefs);
    9693 
    9794  //process
  • examples/aubionotes.c

    r0536612 rf658288  
    1919*/
    2020
    21 #define AUBIO_UNSTABLE 1 // for fvec_median_channel
     21#define AUBIO_UNSTABLE 1 // for fvec_median
    2222
    2323#include "utils.h"
     
    5050
    5151static int aubio_process(smpl_t **input, smpl_t **output, int nframes) {
    52   unsigned int i;       /*channels*/
    5352  unsigned int j;       /*frames*/
    5453  for (j=0;j<(unsigned)nframes;j++) {
    5554    if(usejack) {
    56       for (i=0;i<channels;i++) {
    57         /* write input to datanew */
    58         fvec_write_sample(ibuf, input[i][j], i, pos);
    59         /* put synthnew in output */
    60         output[i][j] = fvec_read_sample(obuf, i, pos);
    61       }
     55      /* write input to datanew */
     56      fvec_write_sample(ibuf, input[0][j], pos);
     57      /* put synthnew in output */
     58      output[0][j] = fvec_read_sample(obuf, pos);
    6259    }
    6360    /*time for fft*/
     
    6764     
    6865      aubio_pitch_do (pitchdet, ibuf, pitch_obuf);
    69       pitch = fvec_read_sample(pitch_obuf, 0, 0);
     66      pitch = fvec_read_sample(pitch_obuf, 0);
    7067      if(median){
    7168              note_append(note_buffer, pitch);
     
    7471      /* curlevel is negatif or 1 if silence */
    7572      curlevel = aubio_level_detection(ibuf, silence);
    76       if (fvec_read_sample(onset, 0, 0)) {
     73      if (fvec_read_sample(onset, 0)) {
    7774              /* test for silence */
    7875              if (curlevel == 1.) {
     
    9289
    9390                      for (pos = 0; pos < overlap_size; pos++){
    94                               obuf->data[0][pos] = woodblock->data[0][pos];
     91                              obuf->data[pos] = woodblock->data[pos];
    9592                      }
    9693              }
     
    112109              } // if median
    113110        for (pos = 0; pos < overlap_size; pos++)
    114           obuf->data[0][pos] = 0.;
     111          obuf->data[pos] = 0.;
    115112      }
    116113      /* end of block loop */
     
    131128  uint_t i = 0;
    132129  for (i = 0; i < note_buffer->length - 1; i++) {
    133     note_buffer->data[0][i] = note_buffer->data[0][i + 1];
     130    note_buffer->data[i] = note_buffer->data[i + 1];
    134131  }
    135   note_buffer->data[0][note_buffer->length - 1] = curnote;
     132  note_buffer->data[note_buffer->length - 1] = curnote;
    136133  return;
    137134}
     
    142139  uint_t i;
    143140  for (i = 0; i < note_buffer->length; i++) {
    144     note_buffer2->data[0][i] = note_buffer->data[0][i];
     141    note_buffer2->data[i] = note_buffer->data[i];
    145142  }
    146   return fvec_median_channel (note_buffer2, 0);
     143  return fvec_median (note_buffer2);
    147144}
    148145
     
    150147  examples_common_init(argc,argv);
    151148
    152   o = new_aubio_onset (onset_mode, buffer_size, overlap_size, channels,
    153           samplerate);
     149  o = new_aubio_onset (onset_mode, buffer_size, overlap_size, samplerate);
    154150  if (threshold != 0.) aubio_onset_set_threshold (o, threshold);
    155   onset = new_fvec (1, channels);
     151  onset = new_fvec (1);
    156152
    157153  pitchdet = new_aubio_pitch (pitch_mode, buffer_size * 4,
    158           overlap_size, channels, samplerate);
     154          overlap_size, samplerate);
    159155  aubio_pitch_set_tolerance (pitchdet, 0.7);
    160   pitch_obuf = new_fvec (1, channels);
     156  pitch_obuf = new_fvec (1);
    161157  if (median) {
    162       note_buffer = new_fvec (median, 1);
    163       note_buffer2 = new_fvec (median, 1);
     158      note_buffer = new_fvec (median);
     159      note_buffer2 = new_fvec (median);
    164160  }
    165161
  • examples/aubioonset.c

    r0536612 rf658288  
    3131  for (j=0;j<(unsigned)nframes;j++) {
    3232    if(usejack) {
    33       for (i=0;i<channels;i++) {
    34         /* write input to datanew */
    35         fvec_write_sample(ibuf, input[i][j], i, pos);
    36         /* put synthnew in output */
    37         output[i][j] = fvec_read_sample(obuf, i, pos);
    38       }
     33      /* write input to datanew */
     34      fvec_write_sample(ibuf, input[0][j], pos);
     35      /* put synthnew in output */
     36      output[0][j] = fvec_read_sample(obuf, pos);
    3937    }
    4038    /*time for fft*/
    41     if (pos == overlap_size-1) {         
     39    if (pos == overlap_size-1) {
    4240      /* block loop */
    4341      aubio_onset_do (o, ibuf, onset);
    44       if (fvec_read_sample(onset, 0, 0)) {
     42      if ( fvec_read_sample(onset, 0) ) {
    4543        fvec_copy (woodblock, obuf);
    4644      } else {
     
    5553}
    5654
    57 static void process_print (void) {
    58       /* output times in seconds, taking back some
    59        * delay to ensure the label is _before_ the
    60        * actual onset */
    61       if (!verbose && usejack) return;
    62       smpl_t onset_found = fvec_read_sample(onset, 0, 0);
    63       if (onset_found) {
    64         if(frames >= 4) {
    65           outmsg("%f\n",(frames - frames_delay + onset_found)
    66                   *overlap_size/(float)samplerate);
    67         } else if (frames < frames_delay) {
    68           outmsg("%f\n",0.);
    69         }
    70       }
     55static void
     56process_print (void)
     57{
     58  /* output times in seconds, taking back some delay to ensure the label is
     59   * _before_ the actual onset */
     60  if (!verbose && usejack)
     61    return;
     62  smpl_t onset_found = fvec_read_sample (onset, 0);
     63  if (onset_found) {
     64    if (frames >= 4) {
     65      outmsg ("%f\n", (frames - frames_delay + onset_found)
     66          * overlap_size / (float) samplerate);
     67    } else if (frames < frames_delay) {
     68      outmsg ("%f\n", 0.);
     69    }
     70  }
    7171}
    7272
     
    7575  examples_common_init(argc,argv);
    7676
    77   o = new_aubio_onset (onset_mode, buffer_size, overlap_size, channels,
    78           samplerate);
     77  o = new_aubio_onset (onset_mode, buffer_size, overlap_size, samplerate);
    7978  if (threshold != 0.) aubio_onset_set_threshold (o, threshold);
    80   onset = new_fvec (1, channels);
     79  onset = new_fvec (1);
    8180
    8281  examples_common_process(aubio_process,process_print);
  • examples/aubiopitch.c

    r0536612 rf658288  
    2727
    2828static int aubio_process(smpl_t **input, smpl_t **output, int nframes) {
    29   unsigned int i;       /*channels*/
    3029  unsigned int j;       /*frames*/
    3130  for (j=0;j<(unsigned)nframes;j++) {
    3231    if(usejack) {
    33       for (i=0;i<channels;i++) {
    34         /* write input to datanew */
    35         fvec_write_sample(ibuf, input[i][j], i, pos);
    36         /* put synthnew in output */
    37         output[i][j] = fvec_read_sample(obuf, i, pos);
    38       }
     32      /* write input to datanew */
     33      fvec_write_sample(ibuf, input[0][j], pos);
     34      /* put synthnew in output */
     35      output[0][j] = fvec_read_sample(obuf, pos);
    3936    }
    4037    /*time for fft*/
     
    4239      /* block loop */
    4340      aubio_pitch_do (o, ibuf, pitch);
    44       if (fvec_read_sample(pitch, 0, 0)) {
     41      if (fvec_read_sample(pitch, 0)) {
    4542        for (pos = 0; pos < overlap_size; pos++){
    4643          // TODO, play sine at this freq
     
    5956static void process_print (void) {
    6057      if (!verbose && usejack) return;
    61       smpl_t pitch_found = fvec_read_sample(pitch, 0, 0);
     58      smpl_t pitch_found = fvec_read_sample(pitch, 0);
    6259      outmsg("%f %f\n",(frames)
    6360              *overlap_size/(float)samplerate, pitch_found);
     
    6764  examples_common_init(argc,argv);
    6865
    69   o = new_aubio_pitch (onset_mode, buffer_size, overlap_size, channels,
    70           samplerate);
    71   pitch = new_fvec (1, channels);
     66  o = new_aubio_pitch (onset_mode, buffer_size, overlap_size, samplerate);
     67  pitch = new_fvec (1);
    7268
    7369  examples_common_process(aubio_process,process_print);
  • examples/aubioquiet.c

    r0536612 rf658288  
    2626int aubio_process(smpl_t **input, smpl_t **output, int nframes);
    2727int aubio_process(smpl_t **input, smpl_t **output, int nframes) {
    28   unsigned int i;       /*channels*/
    2928  unsigned int j;       /*frames*/
    3029  for (j=0;j<(unsigned)nframes;j++) {
    3130    if(usejack) {
    32       for (i=0;i<channels;i++) {
    33         /* write input to datanew */
    34         fvec_write_sample(ibuf, input[i][j], i, pos);
    35         /* put synthnew in output */
    36         output[i][j] = fvec_read_sample(obuf, i, pos);
    37       }
     31      /* write input to datanew */
     32      fvec_write_sample(ibuf, input[0][j], pos);
     33      /* put synthnew in output */
     34      output[0][j] = fvec_read_sample(obuf, pos);
    3835    }
    3936    /*time for fft*/
     
    4138      /* test for silence */
    4239      if (aubio_silence_detection(ibuf, silence)==1) {
    43         if (wassilence==1) issilence = 1;
    44         else issilence = 2;
     40        if (wassilence==1) issilence = 1;
     41        else issilence = 2;
    4542        wassilence=1;
    4643      } else {
    47         if (wassilence<=0) issilence = 0;
    48         else issilence = -1;
     44        if (wassilence<=0) issilence = 0;
     45        else issilence = -1;
    4946        wassilence=0;
    5047      }
  • examples/aubiotrack.c

    r0536612 rf658288  
    2929
    3030static int aubio_process(smpl_t **input, smpl_t **output, int nframes) {
    31   unsigned int i;       /*channels*/
    3231  unsigned int j;       /*frames*/
    3332  for (j=0;j<(unsigned)nframes;j++) {
    3433    if(usejack) {
    35       for (i=0;i<channels;i++) {
    36         /* write input to datanew */
    37         fvec_write_sample(ibuf, input[i][j], i, pos);
    38         /* put synthnew in output */
    39         output[i][j] = fvec_read_sample(obuf, i, pos);
    40       }
     34      /* write input to datanew */
     35      fvec_write_sample(ibuf, input[0][j], pos);
     36      /* put synthnew in output */
     37      output[0][j] = fvec_read_sample(obuf, pos);
    4138    }
    4239    /*time for fft*/
     
    4441      /* block loop */
    4542      aubio_tempo_do (bt,ibuf,tempo_out);
    46       istactus = fvec_read_sample (tempo_out, 0, 0);
    47       isonset = fvec_read_sample (tempo_out, 0, 1);
     43      istactus = fvec_read_sample (tempo_out, 0);
     44      isonset = fvec_read_sample (tempo_out, 1);
    4845      if (istactus > 0.) {
    4946        fvec_copy (woodblock, obuf);
     
    7673  examples_common_init(argc,argv);
    7774
    78   tempo_out = new_fvec(2,channels);
    79   bt = new_aubio_tempo(onset_mode,buffer_size,overlap_size,channels, samplerate);
     75  tempo_out = new_fvec(2);
     76  bt = new_aubio_tempo(onset_mode,buffer_size,overlap_size, samplerate);
    8077  if (threshold != 0.) aubio_tempo_set_threshold (bt, threshold);
    8178
  • examples/sndfileio.c

    r0536612 rf658288  
    9696        aubio_sndfile_t * f = AUBIO_NEW(aubio_sndfile_t);
    9797        f->samplerate    = fmodel->samplerate;
    98         f->channels      = fmodel->channels;
     98        f->channels      = 1; //fmodel->channels;
    9999        f->format        = fmodel->format;
    100100        aubio_sndfile_open_wo(f, outputname);
     
    125125/* read frames from file in data
    126126 *  return the number of frames actually read */
    127 int aubio_sndfile_read(aubio_sndfile_t * f, int frames, fvec_t * read) {
     127int aubio_sndfile_read(aubio_sndfile_t * f, int frames, fvec_t ** read) {
    128128        sf_count_t read_frames;
    129129        int i,j, channels = f->channels;
     
    150150        /* de-interleaving data  */
    151151        for (i=0; i<channels; i++) {
    152                 pread = (smpl_t *)fvec_get_channel(read,i);
     152                pread = (smpl_t *)fvec_get_data(read[i]);
    153153                for (j=0; j<aread; j++) {
    154154                        pread[j] = (smpl_t)f->tmpdata[channels*j+i];
     
    158158}
    159159
     160int
     161aubio_sndfile_read_mono (aubio_sndfile_t * f, int frames, fvec_t * read)
     162{
     163  sf_count_t read_frames;
     164  int i, j, channels = f->channels;
     165  int nsamples = frames * channels;
     166  int aread;
     167  smpl_t *pread;
     168
     169  /* allocate data for de/interleaving reallocated when needed. */
     170  if (nsamples >= f->size) {
     171    AUBIO_ERR ("Maximum aubio_sndfile_read buffer size exceeded.");
     172    return -1;
     173    /*
     174    AUBIO_FREE(f->tmpdata);
     175    f->tmpdata = AUBIO_ARRAY(float,nsamples);
     176    */
     177  }
     178  //f->size = nsamples;
     179
     180  /* do actual reading */
     181  read_frames = sf_read_float (f->handle, f->tmpdata, nsamples);
     182
     183  aread = (int) FLOOR (read_frames / (float) channels);
     184
     185  /* de-interleaving data  */
     186  pread = (smpl_t *) fvec_get_data (read);
     187  for (i = 0; i < channels; i++) {
     188    for (j = 0; j < aread; j++) {
     189      pread[j] += (smpl_t) f->tmpdata[channels * j + i];
     190    }
     191  }
     192  for (j = 0; j < aread; j++) {
     193    pread[j] /= (smpl_t)channels;
     194  }
     195
     196  return aread;
     197}
     198
    160199/* write 'frames' samples to file from data
    161200 *   return the number of frames actually written
    162201 */
    163 int aubio_sndfile_write(aubio_sndfile_t * f, int frames, fvec_t * write) {
     202int aubio_sndfile_write(aubio_sndfile_t * f, int frames, fvec_t ** write) {
    164203        sf_count_t written_frames = 0;
    165204        int i, j,       channels = f->channels;
     
    180219        /* interleaving data  */
    181220        for (i=0; i<channels; i++) {
    182                 pwrite = (smpl_t *)fvec_get_channel(write,i);
     221                pwrite = (smpl_t *)fvec_get_data(write[i]);
    183222                for (j=0; j<frames; j++) {
    184223                        f->tmpdata[channels*j+i] = (float)pwrite[j];
  • examples/sndfileio.h

    r0536612 rf658288  
    4949 * Read frames data from file
    5050 */
    51 int aubio_sndfile_read(aubio_sndfile_t * file, int frames, fvec_t * read);
     51int aubio_sndfile_read(aubio_sndfile_t * file, int frames, fvec_t ** read);
    5252/**
    5353 * Write data of length frames to file
    5454 */
    55 int aubio_sndfile_write(aubio_sndfile_t * file, int frames, fvec_t * write);
     55int aubio_sndfile_write(aubio_sndfile_t * file, int frames, fvec_t ** write);
    5656/**
    5757 * Close file and delete file object
  • examples/utils.c

    r0536612 rf658288  
    6161uint_t buffer_size = 512;       //1024;
    6262uint_t overlap_size = 256;      //512;
    63 uint_t channels = 1;
    6463uint_t samplerate = 44100;
    6564
     
    208207  parse_args (argc, argv);
    209208
    210   woodblock = new_fvec (buffer_size, 1);
     209  woodblock = new_fvec (overlap_size);
    211210  if (output_filename || usejack) {
    212211    /* dummy assignement to keep egcs happy */
     
    221220  if (onsetfile) {
    222221    /* read the output sound once */
    223     aubio_sndfile_read (onsetfile, overlap_size, woodblock);
     222    aubio_sndfile_read_mono (onsetfile, overlap_size, woodblock);
    224223  }
    225224
     
    233232    if (verbose)
    234233      aubio_sndfile_info (file);
    235     channels = aubio_sndfile_channels (file);
    236234    samplerate = aubio_sndfile_samplerate (file);
    237235    if (output_filename != NULL)
     
    256254#endif /* HAVE_LASH */
    257255
    258   ibuf = new_fvec (overlap_size, channels);
    259   obuf = new_fvec (overlap_size, channels);
     256  uint_t i;
     257  ibuf = new_fvec (overlap_size);
     258  obuf = new_fvec (overlap_size);
    260259
    261260}
     
    265264examples_common_del (void)
    266265{
     266  uint_t i;
    267267  del_fvec (ibuf);
    268268  del_fvec (obuf);
     
    283283#if HAVE_JACK
    284284    debug ("Jack init ...\n");
    285     jack_setup = new_aubio_jack (channels, channels,
     285    jack_setup = new_aubio_jack (1, 1,
    286286        0, 1, (aubio_process_func_t) process_func);
    287287    debug ("Jack activation ...\n");
     
    301301    frames = 0;
    302302
    303     while ((signed) overlap_size == aubio_sndfile_read (file, overlap_size,
    304             ibuf)) {
    305       process_func (ibuf->data, obuf->data, overlap_size);
     303    while ((signed) overlap_size ==
     304        aubio_sndfile_read_mono (file, overlap_size, ibuf)) {
     305      process_func (&ibuf->data, &obuf->data, overlap_size);
    306306      print ();
    307307      if (output_filename != NULL) {
    308         aubio_sndfile_write (fileout, overlap_size, obuf);
     308        aubio_sndfile_write (fileout, overlap_size, &obuf);
    309309      }
    310310      frames++;
     
    328328  fvec_zeros(obuf);
    329329  for (i = 0; (signed) i < frames_delay; i++) {
    330     process_func (ibuf->data, obuf->data, overlap_size);
     330    process_func (&ibuf->data, &obuf->data, overlap_size);
    331331    print ();
    332332  }
  • examples/utils.h

    r0536612 rf658288  
    7474extern uint_t buffer_size;
    7575extern uint_t overlap_size;
    76 extern uint_t channels;
    7776extern uint_t samplerate;
    7877
  • interfaces/python/aubio-types.h

    r0536612 rf658288  
    66#include <aubio.h>
    77
    8 #define Py_default_vector_length   1024
    9 #define Py_default_vector_channels 1
     8#define Py_default_vector_length 1024
     9#define Py_default_vector_height 1
    1010
    1111#define Py_aubio_default_samplerate 44100
     
    2525
    2626*/
    27 #define AUBIO_DO_CASTING 0
    2827
    2928typedef struct
     
    3231  fvec_t * o;
    3332  uint_t length;
    34   uint_t channels;
    3533} Py_fvec;
    3634extern PyTypeObject Py_fvecType;
     
    3836extern PyObject *PyAubio_CFvecToArray (fvec_t * self);
    3937extern Py_fvec *PyAubio_ArrayToFvec (PyObject * self);
     38
     39typedef struct
     40{
     41  PyObject_HEAD
     42  fmat_t * o;
     43  uint_t length;
     44  uint_t height;
     45} Py_fmat;
     46extern PyTypeObject Py_fmatType;
     47extern PyObject *PyAubio_FmatToArray (Py_fmat * self);
     48extern PyObject *PyAubio_CFmatToArray (fmat_t * self);
     49extern Py_fmat *PyAubio_ArrayToFmat (PyObject * self);
    4050
    4151typedef struct
  • interfaces/python/aubiomodule.c

    r0536612 rf658288  
    122122
    123123  if ((PyType_Ready (&Py_fvecType) < 0)
     124      || (PyType_Ready (&Py_fmatType) < 0)
    124125      || (PyType_Ready (&Py_cvecType) < 0)
    125126      || (PyType_Ready (&Py_filterType) < 0)
     
    148149  Py_INCREF (&Py_fvecType);
    149150  PyModule_AddObject (m, "fvec", (PyObject *) & Py_fvecType);
     151  Py_INCREF (&Py_fmatType);
     152  PyModule_AddObject (m, "fmat", (PyObject *) & Py_fmatType);
    150153  Py_INCREF (&Py_cvecType);
    151154  PyModule_AddObject (m, "cvec", (PyObject *) & Py_cvecType);
  • interfaces/python/aubiowraphell.h

    r0536612 rf658288  
    9494
    9595// some more helpers
    96 #define AUBIO_NEW_VEC(name, type, lengthval, channelsval) \
     96#define AUBIO_NEW_VEC(name, type, lengthval) \
    9797  name = (type *) PyObject_New (type, & type ## Type); \
    98   name->channels = channelsval; \
    9998  name->length = lengthval;
  • interfaces/python/gen_pyobject.py

    r0536612 rf658288  
    6969# move into the C library at some point.
    7070defaultsizes = {
    71     'resampler':    ('input->length * self->ratio', 'input->channels'),
    72     'specdesc':     ('1', 'fftgrain->channels'),
    73     'onset':        ('1', 'self->channels'),
    74     'pitchyin':     ('1', 'in->channels'),
    75     'pitchyinfft':  ('1', 'in->channels'),
    76     'pitchschmitt': ('1', 'in->channels'),
    77     'pitchmcomb':   ('1', 'self->channels'),
    78     'pitchfcomb':   ('1', 'self->channels'),
    79     'pitch':        ('1', 'self->channels'),
    80     'tss':          ('self->hop_size', 'self->channels'),
    81     'mfcc':         ('self->n_coeffs', 'in->channels'),
    82     'beattracking': ('self->hop_size', 'self->channels'),
    83     'tempo':        ('1', 'self->channels'),
    84     'peakpicker':   ('1', 'self->channels'),
     71    'resampler':    'input->length * self->ratio',
     72    'specdesc':     '1',
     73    'onset':        '1',
     74    'pitchyin':     '1',
     75    'pitchyinfft':  '1',
     76    'pitchschmitt': '1',
     77    'pitchmcomb':   '1',
     78    'pitchfcomb':   '1',
     79    'pitch':        '1',
     80    'tss':          'self->hop_size',
     81    'mfcc':         'self->n_coeffs',
     82    'beattracking': 'self->hop_size',
     83    'tempo':        '1',
     84    'peakpicker':   '1',
    8585}
    8686
     
    9999    'hop_size': 'Py_default_vector_length / 2',
    100100    # these should be alright
    101     'channels': 'Py_default_vector_channels',
    102101    'samplerate': 'Py_aubio_default_samplerate',
    103102    # now for the non obvious ones
     
    151150    newparams = get_params_types_names(newfunc)
    152151    # self->param1, self->param2, self->param3
    153     selfparams = ', self->'.join([p[1] for p in newparams])
     152    if len(newparams):
     153        selfparams = ', self->'+', self->'.join([p[1] for p in newparams])
     154    else:
     155        selfparams = ''
    154156    # "param1", "param2", "param3"
    155157    paramnames = ", ".join(["\""+p[1]+"\"" for p in newparams])
     
    179181Py_%(name)s_new (PyTypeObject * pytype, PyObject * args, PyObject * kwds)
    180182{
     183  Py_%(name)s *self;
    181184""" % locals()
    182185    for ptype, pname in newparams:
     
    186189""" % locals()
    187190    # now the actual PyArg_Parse
    188     s += """\
    189   Py_%(name)s *self;
     191    if len(paramnames):
     192        s += """\
    190193  static char *kwlist[] = { %(paramnames)s, NULL };
    191194
     
    194197    return NULL;
    195198  }
     199""" % locals()
     200    s += """\
    196201
    197202  self = (Py_%(name)s *) pytype->tp_alloc (pytype, 0);
     
    238243}
    239244
    240 AUBIO_INIT(%(name)s, self->%(selfparams)s)
     245AUBIO_INIT(%(name)s %(selfparams)s)
    241246
    242247AUBIO_DEL(%(name)s)
     
    287292        outputvecs = "\n  ".join([aubio2pyaubio[p[0]]+" * " + p[-1] + ";" for p in outputparams])
    288293        outputcreate = "\n  ".join(["""\
    289 AUBIO_NEW_VEC(%(name)s, %(pytype)s, %(length)s, %(channels)s)
    290   %(name)s->o = new_%(autype)s (%(length)s, %(channels)s);""" % \
     294AUBIO_NEW_VEC(%(name)s, %(pytype)s, %(length)s)
     295  %(name)s->o = new_%(autype)s (%(length)s);""" % \
    291296    {'name': p[-1], 'pytype': aubio2pyaubio[p[0]], 'autype': p[0][:-3],
    292         'length': defaultsizes[name][0], 'channels': defaultsizes[name][1]} \
     297        'length': defaultsizes[name]} \
    293298        for p in outputparams])
    294299        if len(outputparams) > 1:
  • interfaces/python/py-cvec.c

    r0536612 rf658288  
    44
    55class cvec():
    6     def __init__(self, length = 1024, channels = 1):
     6    def __init__(self, length = 1024):
    77        self.length = length
    8         self.channels = channels
    9         self.norm = array(length, channels)
    10         self.phas = array(length, channels)
     8        self.norm = array(length)
     9        self.phas = array(length)
     10
    1111*/
    12 
    1312
    1413static char Py_cvec_doc[] = "cvec object";
     
    1716Py_cvec_new (PyTypeObject * type, PyObject * args, PyObject * kwds)
    1817{
    19   int length= 0, channels = 0;
     18  int length= 0;
    2019  Py_cvec *self;
    21   static char *kwlist[] = { "length", "channels", NULL };
    22 
    23   if (!PyArg_ParseTupleAndKeywords (args, kwds, "|II", kwlist,
    24           &length, &channels)) {
     20  static char *kwlist[] = { "length", NULL };
     21
     22  if (!PyArg_ParseTupleAndKeywords (args, kwds, "|I", kwlist,
     23          &length)) {
    2524    return NULL;
    2625  }
     
    3029
    3130  self->length = Py_default_vector_length / 2 + 1;
    32   self->channels = Py_default_vector_channels;
    3331
    3432  if (self == NULL) {
     
    4442  }
    4543
    46   if (channels > 0) {
    47     self->channels = channels;
    48   } else if (channels < 0) {
    49     PyErr_SetString (PyExc_ValueError,
    50         "can not use negative number of channels");
    51     return NULL;
    52   }
    53 
    5444  return (PyObject *) self;
    5545}
     
    5848Py_cvec_init (Py_cvec * self, PyObject * args, PyObject * kwds)
    5949{
    60   self->o = new_cvec ((self->length - 1) * 2, self->channels);
     50  self->o = new_cvec ((self->length - 1) * 2);
    6151  if (self->o == NULL) {
    6252    return -1;
     
    8070  PyObject *result = NULL;
    8171
    82   format = PyString_FromString ("aubio cvec of %d elements with %d channels");
     72  format = PyString_FromString ("aubio cvec of %d elements");
    8373  if (format == NULL) {
    8474    goto fail;
    8575  }
    8676
    87   args = Py_BuildValue ("II", self->length, self->channels);
     77  args = Py_BuildValue ("I", self->length);
    8878  if (args == NULL) {
    8979    goto fail;
    9080  }
    91   //cvec_print ( self->o );
     81  cvec_print ( self->o );
    9282
    9383  result = PyString_Format (format, args);
     
    10494  PyObject *array;
    10595  Py_cvec *vec;
    106   uint_t i;
     96  if (input == NULL) {
     97    PyErr_SetString (PyExc_ValueError, "input array is not a python object");
     98    goto fail;
     99  }
    107100  // parsing input object into a Py_cvec
    108101  if (PyObject_TypeCheck (input, &Py_cvecType)) {
     
    115108      PyErr_SetString (PyExc_ValueError, "input array is a scalar");
    116109      goto fail;
     110    } else if (PyArray_NDIM (input) > 1) {
     111      PyErr_SetString (PyExc_ValueError,
     112          "input array has more than one dimensions");
     113      goto fail;
     114    }
     115
     116    if (!PyArray_ISFLOAT (input)) {
     117      PyErr_SetString (PyExc_ValueError, "input array should be float");
     118      goto fail;
     119    } else if (PyArray_TYPE (input) != AUBIO_NPY_SMPL) {
     120      PyErr_SetString (PyExc_ValueError, "input array should be float32");
     121      goto fail;
     122    } else {
     123      // input data type is float32, nothing else to do
     124      array = input;
     125    }
     126
     127    // create a new cvec object
     128    vec = (Py_cvec*) PyObject_New (Py_cvec, &Py_cvecType);
     129    if (PyArray_NDIM (array) != 2) {
     130      PyErr_SetString (PyExc_ValueError,
     131          "input array should be have exactly two rows for norm and phas");
     132      goto fail;
     133    } else {
     134      vec->length = PyArray_SIZE (array);
     135    }
     136
     137    // no need to really allocate cvec, just its struct member
     138    // vec->o = new_cvec (vec->length);
     139    vec->o = (cvec_t *)malloc(sizeof(cvec_t));
     140    vec->o->length = vec->length;
     141    // have norm and phas point to array rows
     142    vec->o->norm = (smpl_t *) PyArray_GETPTR1 (array, 0);
     143    vec->o->phas = (smpl_t *) PyArray_GETPTR1 (array, 1);
     144
     145  } else {
     146    PyErr_SetString (PyExc_ValueError, "can only accept array or cvec as input");
     147    return NULL;
     148  }
     149
     150  return vec;
     151
     152fail:
     153  return NULL;
     154}
     155
     156PyObject *
     157PyAubio_CvecToArray (Py_cvec * self)
     158{
     159  PyObject *array = NULL;
     160  npy_intp dims[] = { self->o->length, 1 };
     161  PyObject *concat = PyList_New (0), *tmp = NULL;
     162  tmp = PyArray_SimpleNewFromData (1, dims, NPY_FLOAT, self->o->norm);
     163  PyList_Append (concat, tmp);
     164  Py_DECREF (tmp);
     165  tmp = PyArray_SimpleNewFromData (1, dims, NPY_FLOAT, self->o->phas);
     166  PyList_Append (concat, tmp);
     167  Py_DECREF (tmp);
     168  array = PyArray_FromObject (concat, NPY_FLOAT, 2, 2);
     169  Py_DECREF (concat);
     170  return array;
     171}
     172
     173PyObject *
     174PyAubio_CvecNormToArray (Py_cvec * self)
     175{
     176  npy_intp dims[] = { self->o->length, 1 };
     177  return PyArray_SimpleNewFromData (1, dims, NPY_FLOAT, self->o->norm);
     178}
     179
     180
     181PyObject *
     182PyAubio_CvecPhasToArray (Py_cvec * self)
     183{
     184  npy_intp dims[] = { self->o->length, 1 };
     185  return PyArray_SimpleNewFromData (1, dims, NPY_FLOAT, self->o->phas);
     186}
     187
     188PyObject *
     189PyAubio_ArrayToCvecPhas (PyObject * self)
     190{
     191  return NULL;
     192}
     193
     194PyObject *
     195Py_cvec_get_norm (Py_cvec * self, void *closure)
     196{
     197  return PyAubio_CvecNormToArray(self);
     198}
     199
     200PyObject *
     201Py_cvec_get_phas (Py_cvec * self, void *closure)
     202{
     203  return PyAubio_CvecPhasToArray(self);
     204}
     205
     206static int
     207Py_cvec_set_norm (Py_cvec * vec, PyObject *input, void * closure)
     208{
     209  PyObject * array;
     210  if (input == NULL) {
     211    PyErr_SetString (PyExc_ValueError, "input array is not a python object");
     212    goto fail;
     213  }
     214  if (PyArray_Check(input)) {
     215
     216    // we got an array, convert it to a cvec.norm
     217    if (PyArray_NDIM (input) == 0) {
     218      PyErr_SetString (PyExc_ValueError, "input array is a scalar");
     219      goto fail;
    117220    } else if (PyArray_NDIM (input) > 2) {
    118221      PyErr_SetString (PyExc_ValueError,
     
    124227      PyErr_SetString (PyExc_ValueError, "input array should be float");
    125228      goto fail;
    126 #if AUBIO_DO_CASTING
    127     } else if (PyArray_TYPE (input) != AUBIO_NPY_SMPL) {
    128       // input data type is not float32, casting
    129       array = PyArray_Cast ( (PyArrayObject*) input, AUBIO_NPY_SMPL);
    130       if (array == NULL) {
    131         PyErr_SetString (PyExc_IndexError, "failed converting to NPY_FLOAT");
    132         goto fail;
    133       }
    134 #else
    135229    } else if (PyArray_TYPE (input) != AUBIO_NPY_SMPL) {
    136230      PyErr_SetString (PyExc_ValueError, "input array should be float32");
    137231      goto fail;
    138 #endif
     232    }
     233    array = input;
     234
     235    // check input array dimensions
     236    if (PyArray_NDIM (array) != 1) {
     237      PyErr_Format (PyExc_ValueError,
     238          "input array has %d dimensions, not 1",
     239          PyArray_NDIM (array));
     240      goto fail;
    139241    } else {
    140       // input data type is float32, nothing else to do
    141       array = input;
    142     }
    143 
    144     // create a new cvec object
    145     vec = (Py_cvec*) PyObject_New (Py_cvec, &Py_cvecType);
    146     if (PyArray_NDIM (array) == 1) {
    147       PyErr_SetString (PyExc_ValueError,
    148           "input array should be have at least two rows for norm and phas");
    149       goto fail;
    150     } else if (PyArray_NDIM (array) == 2) {
    151       vec->channels = 1;
    152       vec->length = PyArray_SIZE (array);
    153     } else {
    154       vec->channels = PyArray_DIM (array, 0) / 2;
    155       vec->length = PyArray_DIM (array, 1);
    156     }
    157 
    158     // no need to really allocate cvec, just its struct member
    159     // vec->o = new_cvec (vec->length, vec->channels);
    160     vec->o = (cvec_t *)malloc(sizeof(cvec_t));
    161     vec->o->length = vec->length; vec->o->channels = vec->channels;
    162     vec->o->norm = (smpl_t**)malloc(vec->o->channels * sizeof(smpl_t*));
    163     vec->o->phas = (smpl_t**)malloc(vec->o->channels * sizeof(smpl_t*));
    164     // hat data[i] point to array line
    165     for (i = 0; i < vec->channels; i+=2) {
    166       vec->o->norm[i] = (smpl_t *) PyArray_GETPTR1 (array, i);
    167       vec->o->phas[i] = (smpl_t *) PyArray_GETPTR1 (array, i+1);
    168     }
    169 
    170   } else {
    171     PyErr_SetString (PyExc_ValueError, "can only accept array or cvec as input");
    172     return NULL;
    173   }
    174 
    175   return vec;
    176 
    177 fail:
    178   return NULL;
    179 }
    180 
    181 PyObject *
    182 PyAubio_CvecToArray (Py_cvec * self)
    183 {
    184   PyObject *array = NULL;
    185   uint_t i;
    186   npy_intp dims[] = { self->o->length, 1 };
    187   PyObject *concat = PyList_New (0), *tmp = NULL;
    188   for (i = 0; i < self->channels; i++) {
    189     tmp = PyArray_SimpleNewFromData (1, dims, NPY_FLOAT, self->o->norm[i]);
    190     PyList_Append (concat, tmp);
    191     Py_DECREF (tmp);
    192     tmp = PyArray_SimpleNewFromData (1, dims, NPY_FLOAT, self->o->phas[i]);
    193     PyList_Append (concat, tmp);
    194     Py_DECREF (tmp);
    195   }
    196   array = PyArray_FromObject (concat, NPY_FLOAT, 2, 2);
    197   Py_DECREF (concat);
    198   return array;
    199 }
    200 
    201 PyObject *
    202 PyAubio_CvecNormToArray (Py_cvec * self)
    203 {
    204   PyObject *array = NULL;
    205   uint_t i;
    206   npy_intp dims[] = { self->o->length, 1 };
    207   PyObject *concat = PyList_New (0), *tmp = NULL;
    208   for (i = 0; i < self->channels; i++) {
    209     tmp = PyArray_SimpleNewFromData (1, dims, NPY_FLOAT, self->o->norm[i]);
    210     PyList_Append (concat, tmp);
    211     Py_DECREF (tmp);
    212   }
    213   array = PyArray_FromObject (concat, NPY_FLOAT, 2, 2);
    214   Py_DECREF (concat);
    215   return array;
    216 }
    217 
    218 
    219 PyObject *
    220 PyAubio_CvecPhasToArray (Py_cvec * self)
    221 {
    222   PyObject *array = NULL;
    223   uint_t i;
    224   npy_intp dims[] = { self->o->length, 1 };
    225   PyObject *concat = PyList_New (0), *tmp = NULL;
    226   for (i = 0; i < self->channels; i++) {
    227     tmp = PyArray_SimpleNewFromData (1, dims, NPY_FLOAT, self->o->phas[i]);
    228     PyList_Append (concat, tmp);
    229     Py_DECREF (tmp);
    230   }
    231   array = PyArray_FromObject (concat, NPY_FLOAT, 2, 2);
    232   Py_DECREF (concat);
    233   return array;
    234 }
    235 
    236 PyObject *
    237 PyAubio_ArrayToCvecPhas (PyObject * self)
    238 {
    239   return NULL;
    240 }
    241 
    242 PyObject *
    243 Py_cvec_get_norm (Py_cvec * self, void *closure)
    244 {
    245   return PyAubio_CvecNormToArray(self);
    246 }
    247 
    248 PyObject *
    249 Py_cvec_get_phas (Py_cvec * self, void *closure)
    250 {
    251   return PyAubio_CvecPhasToArray(self);
    252 }
    253 
    254 static int
    255 Py_cvec_set_norm (Py_cvec * vec, PyObject *input, void * closure)
    256 {
    257   uint_t i;
    258   PyObject * array;
    259   if (input == NULL) {
    260     PyErr_SetString (PyExc_ValueError, "input array is not a python object");
    261     goto fail;
    262   }
    263   if (PyArray_Check(input)) {
    264 
    265     // we got an array, convert it to a cvec.norm
    266     if (PyArray_NDIM (input) == 0) {
    267       PyErr_SetString (PyExc_ValueError, "input array is a scalar");
    268       goto fail;
    269     } else if (PyArray_NDIM (input) > 2) {
    270       PyErr_SetString (PyExc_ValueError,
    271           "input array has more than two dimensions");
    272       goto fail;
    273     }
    274 
    275     if (!PyArray_ISFLOAT (input)) {
    276       PyErr_SetString (PyExc_ValueError, "input array should be float");
    277       goto fail;
    278     } else if (PyArray_TYPE (input) != AUBIO_NPY_SMPL) {
    279       PyErr_SetString (PyExc_ValueError, "input array should be float32");
    280       goto fail;
    281     }
    282     array = input;
    283 
    284     // check input array dimensions
    285     if (PyArray_NDIM (array) == 1) {
    286       if (vec->channels != 1) {
    287           PyErr_SetString (PyExc_ValueError,
    288                   "input array should have more than one channel");
    289           goto fail;
    290       }
    291242      if (vec->o->length != PyArray_SIZE (array)) {
    292243          PyErr_Format (PyExc_ValueError,
     
    295246          goto fail;
    296247      }
    297     } else {
    298       if (vec->channels != PyArray_DIM (array, 0)) {
    299           PyErr_Format (PyExc_ValueError,
    300                   "input array has %d channels, but vector has %d channels",
    301                   PyArray_DIM (array, 0), vec->channels);
    302           goto fail;
    303       }
    304       if (vec->o->length != PyArray_DIM (array, 1)) {
    305           PyErr_Format (PyExc_ValueError,
    306                   "input array has length %d, but vector has length %d",
    307                   PyArray_DIM (array, 1), vec->o->length);
    308           goto fail;
    309       }
    310     }
    311 
    312     for (i = 0; i < vec->channels; i++) {
    313       vec->o->norm[i] = (smpl_t *) PyArray_GETPTR1 (array, i);
    314     }
     248    }
     249
     250    vec->o->norm = (smpl_t *) PyArray_GETPTR1 (array, 0);
    315251
    316252  } else {
     
    329265Py_cvec_set_phas (Py_cvec * vec, PyObject *input, void * closure)
    330266{
    331   uint_t i;
    332267  PyObject * array;
    333268  if (input == NULL) {
     
    357292
    358293    // check input array dimensions
    359     if (PyArray_NDIM (array) == 1) {
    360       if (vec->channels != 1) {
    361           PyErr_SetString (PyExc_ValueError,
    362                   "input array should have more than one channel");
    363           goto fail;
    364       }
     294    if (PyArray_NDIM (array) != 1) {
     295      PyErr_Format (PyExc_ValueError,
     296          "input array has %d dimensions, not 1",
     297          PyArray_NDIM (array));
     298      goto fail;
     299    } else {
    365300      if (vec->o->length != PyArray_SIZE (array)) {
    366301          PyErr_Format (PyExc_ValueError,
     
    369304          goto fail;
    370305      }
    371     } else {
    372       if (vec->channels != PyArray_DIM (array, 0)) {
    373           PyErr_Format (PyExc_ValueError,
    374                   "input array has %d channels, but vector has %d channels",
    375                   PyArray_DIM (array, 0), vec->channels);
    376           goto fail;
    377       }
    378       if (vec->o->length != PyArray_DIM (array, 1)) {
    379           PyErr_Format (PyExc_ValueError,
    380                   "input array has length %d, but vector has length %d",
    381                   PyArray_DIM (array, 1), vec->o->length);
    382           goto fail;
    383       }
    384     }
    385 
    386     for (i = 0; i < vec->channels; i++) {
    387       vec->o->phas[i] = (smpl_t *) PyArray_GETPTR1 (array, i);
    388     }
     306    }
     307
     308    vec->o->phas = (smpl_t *) PyArray_GETPTR1 (array, 0);
    389309
    390310  } else {
     
    398318fail:
    399319  return 1;
    400 }
    401 
    402 static Py_ssize_t
    403 Py_cvec_getchannels (Py_cvec * self)
    404 {
    405   return self->channels;
    406 }
    407 
    408 static PyObject *
    409 Py_cvec_getitem (Py_cvec * self, Py_ssize_t index)
    410 {
    411   PyObject *array;
    412 
    413   if (index < 0 || index >= self->channels) {
    414     PyErr_SetString (PyExc_IndexError, "no such channel");
    415     return NULL;
    416   }
    417 
    418   npy_intp dims[] = { self->length, 1 };
    419   array = PyArray_SimpleNewFromData (1, dims, NPY_FLOAT, self->o->norm[index]);
    420   return array;
    421 }
    422 
    423 static int
    424 Py_cvec_setitem (Py_cvec * self, Py_ssize_t index, PyObject * o)
    425 {
    426   PyObject *array;
    427 
    428   if (index < 0 || index >= self->channels) {
    429     PyErr_SetString (PyExc_IndexError, "no such channel");
    430     return -1;
    431   }
    432 
    433   array = PyArray_FROM_OT (o, NPY_FLOAT);
    434   if (array == NULL) {
    435     PyErr_SetString (PyExc_ValueError, "should be an array of float");
    436     goto fail;
    437   }
    438 
    439   if (PyArray_NDIM (array) != 1) {
    440     PyErr_SetString (PyExc_ValueError, "should be a one-dimensional array");
    441     goto fail;
    442   }
    443 
    444   if (PyArray_SIZE (array) != self->length) {
    445     PyErr_SetString (PyExc_ValueError,
    446         "should be an array of same length as target cvec");
    447     goto fail;
    448   }
    449 
    450   self->o->norm[index] = (smpl_t *) PyArray_GETPTR1 (array, 0);
    451 
    452   return 0;
    453 
    454 fail:
    455   return -1;
    456320}
    457321
     
    460324  {"length", T_INT, offsetof (Py_cvec, length), READONLY,
    461325      "length attribute"},
    462   {"channels", T_INT, offsetof (Py_cvec, channels), READONLY,
    463       "channels attribute"},
    464326  {NULL}                        /* Sentinel */
    465327};
     
    480342  {NULL} /* sentinel */
    481343};
    482 
    483 static PySequenceMethods Py_cvec_tp_as_sequence = {
    484   (lenfunc) Py_cvec_getchannels,        /* sq_length         */
    485   0,                                    /* sq_concat         */
    486   0,                                    /* sq_repeat         */
    487   (ssizeargfunc) Py_cvec_getitem,       /* sq_item           */
    488   0,                                    /* sq_slice          */
    489   (ssizeobjargproc) Py_cvec_setitem,    /* sq_ass_item       */
    490   0,                                    /* sq_ass_slice      */
    491   0,                                    /* sq_contains       */
    492   0,                                    /* sq_inplace_concat */
    493   0,                                    /* sq_inplace_repeat */
    494 };
    495 
    496344
    497345PyTypeObject Py_cvecType = {
     
    508356  (reprfunc) Py_cvec_repr,      /* tp_repr           */
    509357  0,                            /* tp_as_number      */
    510   &Py_cvec_tp_as_sequence,      /* tp_as_sequence    */
     358  0, //&Py_cvec_tp_as_sequence,      /* tp_as_sequence    */
    511359  0,                            /* tp_as_mapping     */
    512360  0,                            /* tp_hash           */
  • interfaces/python/py-fft.c

    r0536612 rf658288  
    33static char Py_fft_doc[] = "fft object";
    44
    5 AUBIO_DECLARE(fft, uint_t win_s; uint_t channels)
     5AUBIO_DECLARE(fft, uint_t win_s)
    66
    77//AUBIO_NEW(fft)
     
    99Py_fft_new (PyTypeObject * type, PyObject * args, PyObject * kwds)
    1010{
    11   int win_s = 0, channels = 0;
     11  int win_s = 0;
    1212  Py_fft *self;
    13   static char *kwlist[] = { "win_s", "channels", NULL };
     13  static char *kwlist[] = { "win_s", NULL };
    1414
    15   if (!PyArg_ParseTupleAndKeywords (args, kwds, "|II", kwlist,
    16           &win_s, &channels)) {
     15  if (!PyArg_ParseTupleAndKeywords (args, kwds, "|I", kwlist,
     16          &win_s)) {
    1717    return NULL;
    1818  }
     
    2525
    2626  self->win_s = Py_default_vector_length;
    27   self->channels = Py_default_vector_channels;
    2827
    2928  if (self == NULL) {
     
    3938  }
    4039
    41   if (channels > 0) {
    42     self->channels = channels;
    43   } else if (channels < 0) {
    44     PyErr_SetString (PyExc_ValueError,
    45         "can not use negative number of filters");
    46     return NULL;
    47   }
    48 
    4940  return (PyObject *) self;
    5041}
    5142
    5243
    53 AUBIO_INIT(fft, self->win_s, self->channels)
     44AUBIO_INIT(fft, self->win_s)
    5445
    5546AUBIO_DEL(fft)
     
    7364
    7465  output = (Py_cvec*) PyObject_New (Py_cvec, &Py_cvecType);
    75   output->channels = vec->channels;
    7666  output->length = ((Py_fft *) self)->win_s;
    77   output->o = new_cvec(((Py_fft *) self)->win_s, vec->channels);
     67  output->o = new_cvec(((Py_fft *) self)->win_s);
    7868
    7969  // compute the function
     
    8777  {"win_s", T_INT, offsetof (Py_fft, win_s), READONLY,
    8878    "size of the window"},
    89   {"channels", T_INT, offsetof (Py_fft, channels), READONLY,
    90     "number of channels"},
    9179AUBIO_MEMBERS_STOP(fft)
    9280
     
    10997
    11098  output = (Py_fvec*) PyObject_New (Py_fvec, &Py_fvecType);
    111   output->channels = vec->channels;
    11299  output->length = ((Py_fft *) self)->win_s;
    113   output->o = new_fvec(output->length, output->channels);
     100  output->o = new_fvec(output->length);
    114101
    115102  // compute the function
  • interfaces/python/py-filter.c

    r0536612 rf658288  
    66  aubio_filter_t * o;
    77  uint_t order;
    8   uint_t channels;
    98} Py_filter;
    109
     
    1413Py_filter_new (PyTypeObject * type, PyObject * args, PyObject * kwds)
    1514{
    16   int order= 0, channels = 0;
     15  int order= 0;
    1716  Py_filter *self;
    18   static char *kwlist[] = { "order", "channels", NULL };
     17  static char *kwlist[] = { "order", NULL };
    1918
    2019  if (!PyArg_ParseTupleAndKeywords (args, kwds, "|II", kwlist,
    21           &order, &channels)) {
     20          &order)) {
    2221    return NULL;
    2322  }
     
    3029
    3130  self->order = 7;
    32   self->channels = Py_default_vector_channels;
    3331
    3432  if (order > 0) {
     
    4038  }
    4139
    42   if (channels > 0) {
    43     self->channels = channels;
    44   } else if (channels < 0) {
    45     PyErr_SetString (PyExc_ValueError,
    46         "can not use negative number of channels");
    47     return NULL;
    48   }
    49 
    5040  return (PyObject *) self;
    5141}
     
    5444Py_filter_init (Py_filter * self, PyObject * args, PyObject * kwds)
    5545{
    56   self->o = new_aubio_filter (self->order, self->channels);
     46  self->o = new_aubio_filter (self->order);
    5747  if (self->o == NULL) {
    5848    return -1;
     
    9282#if 1
    9383  aubio_filter_do (((Py_filter *)self)->o, vec->o);
    94   Py_INCREF(vec);
     84  PyArray_INCREF((PyArrayObject*)vec);
    9585  return (PyObject *)vec;
    9686#else
    9787  Py_fvec *copy = (Py_fvec*) PyObject_New (Py_fvec, &Py_fvecType);
    98   copy->o = new_fvec(vec->o->length, vec->o->channels);
     88  copy->o = new_fvec(vec->o->length);
    9989  aubio_filter_do_outplace (((Py_filter *)self)->o, vec->o, copy->o);
    10090  return (PyObject *)copy;
     
    142132  {"order", T_INT, offsetof (Py_filter, order), READONLY,
    143133      "order of the filter"},
    144   {"channels", T_INT, offsetof (Py_filter, channels), READONLY,
    145       "number of channels"},
    146134  {NULL}                        /* Sentinel */
    147135};
  • interfaces/python/py-filterbank.c

    r0536612 rf658288  
    6868
    6969  output = (Py_fvec*) PyObject_New (Py_fvec, &Py_fvecType);
    70   output->channels = vec->channels;
    7170  output->length = self->n_filters;
    72   output->o = new_fvec(self->n_filters, vec->channels);
     71  output->o = new_fvec(self->n_filters);
    7372
    7473  // compute the function
     
    138137Py_filterbank_get_coeffs (Py_filterbank * self, PyObject *unused)
    139138{
    140   Py_fvec *output = (Py_fvec *) PyObject_New (Py_fvec, &Py_fvecType);
    141   output->channels = self->n_filters;
    142   output->length = self->win_s / 2 + 1;
     139  Py_fmat *output = (Py_fmat *) PyObject_New (Py_fmat, &Py_fvecType);
    143140  output->o = aubio_filterbank_get_coeffs (self->o);
    144   return (PyObject *)PyAubio_FvecToArray(output);
     141  return (PyObject *)PyAubio_FmatToArray(output);
    145142}
    146143
  • interfaces/python/py-fvec.c

    r0536612 rf658288  
    44
    55class fvec():
    6     def __init__(self, length = 1024, channels = 1):
     6    def __init__(self, length = 1024):
    77        self.length = length
    8         self.channels = channels
    9         self.data = array(length, channels)
     8        self.data = array(length)
    109
    1110*/
     
    1615Py_fvec_new (PyTypeObject * type, PyObject * args, PyObject * kwds)
    1716{
    18   int length= 0, channels = 0;
     17  int length= 0;
    1918  Py_fvec *self;
    20   static char *kwlist[] = { "length", "channels", NULL };
    21 
    22   if (!PyArg_ParseTupleAndKeywords (args, kwds, "|II", kwlist,
    23           &length, &channels)) {
    24     return NULL;
    25   }
    26 
     19  static char *kwlist[] = { "length", NULL };
     20
     21  if (!PyArg_ParseTupleAndKeywords (args, kwds, "|I", kwlist,
     22          &length)) {
     23    return NULL;
     24  }
    2725
    2826  self = (Py_fvec *) type->tp_alloc (type, 0);
    2927
    3028  self->length = Py_default_vector_length;
    31   self->channels = Py_default_vector_channels;
    3229
    3330  if (self == NULL) {
     
    4340  }
    4441
    45   if (channels > 0) {
    46     self->channels = channels;
    47   } else if (channels < 0) {
    48     PyErr_SetString (PyExc_ValueError,
    49         "can not use negative number of channels");
    50     return NULL;
    51   }
    52 
    5342  return (PyObject *) self;
    5443}
     
    5746Py_fvec_init (Py_fvec * self, PyObject * args, PyObject * kwds)
    5847{
    59   self->o = new_fvec (self->length, self->channels);
     48  self->o = new_fvec (self->length);
    6049  if (self->o == NULL) {
    6150    return -1;
     
    7564Py_fvec_repr (Py_fvec * self, PyObject * unused)
    7665{
     66#if 0
    7767  PyObject *format = NULL;
    7868  PyObject *args = NULL;
    7969  PyObject *result = NULL;
    8070
    81   format = PyString_FromString ("aubio fvec of %d elements with %d channels");
     71  format = PyString_FromString ("aubio fvec of %d elements");
    8272  if (format == NULL) {
    8373    goto fail;
    8474  }
    8575
    86   args = Py_BuildValue ("II", self->length, self->channels);
     76  args = Py_BuildValue ("I", self->length);
    8777  if (args == NULL) {
    8878    goto fail;
     
    9282  result = PyString_Format (format, args);
    9383
     84fail:
     85  Py_XDECREF (format);
     86  Py_XDECREF (args);
     87
     88  return result;
     89#endif
     90  PyObject *format = NULL;
     91  PyObject *args = NULL;
     92  PyObject *result = NULL;
     93
     94  format = PyString_FromString ("%s");
     95  if (format == NULL) {
     96    goto fail;
     97  }
     98
     99  args = Py_BuildValue ("O", PyAubio_FvecToArray (self));
     100  if (args == NULL) {
     101    goto fail;
     102  }
     103
     104  result = PyString_Format (format, args);
    94105fail:
    95106  Py_XDECREF (format);
     
    103114  PyObject *array;
    104115  Py_fvec *vec;
    105   uint_t i;
    106116  if (input == NULL) {
    107117    PyErr_SetString (PyExc_ValueError, "input array is not a python object");
     
    118128      PyErr_SetString (PyExc_ValueError, "input array is a scalar");
    119129      goto fail;
    120     } else if (PyArray_NDIM (input) > 2) {
     130    } else if (PyArray_NDIM (input) > 1) {
    121131      PyErr_SetString (PyExc_ValueError,
    122           "input array has more than two dimensions");
     132          "input array has more than one dimensions");
    123133      goto fail;
    124134    }
     
    127137      PyErr_SetString (PyExc_ValueError, "input array should be float");
    128138      goto fail;
    129 #if AUBIO_DO_CASTING
    130     } else if (PyArray_TYPE (input) != AUBIO_NPY_SMPL) {
    131       // input data type is not float32, casting
    132       array = PyArray_Cast ( (PyArrayObject*) input, AUBIO_NPY_SMPL);
    133       if (array == NULL) {
    134         PyErr_SetString (PyExc_IndexError, "failed converting to AUBIO_NPY_SMPL");
    135         goto fail;
    136       }
    137 #else
    138139    } else if (PyArray_TYPE (input) != AUBIO_NPY_SMPL) {
    139140      PyErr_SetString (PyExc_ValueError, "input array should be float32");
    140141      goto fail;
    141 #endif
    142142    } else {
    143143      // input data type is float32, nothing else to do
     
    147147    // create a new fvec object
    148148    vec = (Py_fvec*) PyObject_New (Py_fvec, &Py_fvecType);
    149     if (PyArray_NDIM (array) == 1) {
    150       vec->channels = 1;
    151       vec->length = PyArray_SIZE (array);
    152     } else {
    153       vec->channels = PyArray_DIM (array, 0);
    154       vec->length = PyArray_DIM (array, 1);
    155     }
     149    vec->length = PyArray_SIZE (array);
    156150
    157151    // no need to really allocate fvec, just its struct member
    158     // vec->o = new_fvec (vec->length, vec->channels);
     152    // vec->o = new_fvec (vec->length);
    159153    vec->o = (fvec_t *)malloc(sizeof(fvec_t));
    160     vec->o->length = vec->length; vec->o->channels = vec->channels;
    161     vec->o->data = (smpl_t**)malloc(vec->o->channels * sizeof(smpl_t*));
    162     // hat data[i] point to array line
    163     for (i = 0; i < vec->channels; i++) {
    164       vec->o->data[i] = (smpl_t *) PyArray_GETPTR1 (array, i);
    165     }
    166 
     154    vec->o->length = vec->length;
     155    vec->o->data = (smpl_t *) PyArray_GETPTR1 (array, 0);
     156
     157  } else if (PyObject_TypeCheck (input, &PyList_Type)) {
     158    PyErr_SetString (PyExc_ValueError, "does not convert from list yet");
     159    return NULL;
    167160  } else {
    168     PyErr_SetString (PyExc_ValueError, "can only accept array or fvec as input");
     161    PyErr_SetString (PyExc_ValueError, "can only accept vector or fvec as input");
    169162    return NULL;
    170163  }
     
    179172PyAubio_CFvecToArray (fvec_t * self)
    180173{
    181   PyObject *array = NULL;
    182   uint_t i;
    183174  npy_intp dims[] = { self->length, 1 };
    184   PyObject *concat = PyList_New (0), *tmp = NULL;
    185   for (i = 0; i < self->channels; i++) {
    186     tmp = PyArray_SimpleNewFromData (1, dims, AUBIO_NPY_SMPL, self->data[i]);
    187     PyList_Append (concat, tmp);
    188     Py_DECREF (tmp);
    189   }
    190   array = PyArray_FromObject (concat, AUBIO_NPY_SMPL, 2, 2);
    191   Py_DECREF (concat);
    192   return array;
     175  return  PyArray_SimpleNewFromData (1, dims, AUBIO_NPY_SMPL, self->data);
    193176}
    194177
     
    197180{
    198181  PyObject *array = NULL;
    199   if (self->channels == 1) {
    200     npy_intp dims[] = { self->length, 1 };
    201     array = PyArray_SimpleNewFromData (1, dims, AUBIO_NPY_SMPL, self->o->data[0]);
    202   } else {
    203     uint_t i;
    204     npy_intp dims[] = { self->length, 1 };
    205     PyObject *concat = PyList_New (0), *tmp = NULL;
    206     for (i = 0; i < self->channels; i++) {
    207       tmp = PyArray_SimpleNewFromData (1, dims, AUBIO_NPY_SMPL, self->o->data[i]);
    208       PyList_Append (concat, tmp);
    209       Py_DECREF (tmp);
    210     }
    211     array = PyArray_FromObject (concat, AUBIO_NPY_SMPL, 2, 2);
    212     Py_DECREF (concat);
    213   }
     182  npy_intp dims[] = { self->length, 1 };
     183  array = PyArray_SimpleNewFromData (1, dims, AUBIO_NPY_SMPL, self->o->data);
    214184  return array;
    215 }
    216 
    217 static Py_ssize_t
    218 Py_fvec_getchannels (Py_fvec * self)
    219 {
    220   return self->channels;
    221185}
    222186
     
    224188Py_fvec_getitem (Py_fvec * self, Py_ssize_t index)
    225189{
    226   PyObject *array;
    227 
    228   if (index < 0 || index >= self->channels) {
    229     PyErr_SetString (PyExc_IndexError, "no such channel");
    230     return NULL;
    231   }
    232 
    233   npy_intp dims[] = { self->length, 1 };
    234   array = PyArray_SimpleNewFromData (1, dims, AUBIO_NPY_SMPL, self->o->data[index]);
    235   return array;
     190  if (index < 0 || index >= self->length) {
     191    PyErr_SetString (PyExc_IndexError, "no such element");
     192    return NULL;
     193  }
     194
     195  return PyFloat_FromDouble (self->o->data[index]);
    236196}
    237197
     
    239199Py_fvec_setitem (Py_fvec * self, Py_ssize_t index, PyObject * o)
    240200{
    241   PyObject *array;
    242 
    243   if (index < 0 || index >= self->channels) {
    244     PyErr_SetString (PyExc_IndexError, "no such channel");
    245     return -1;
    246   }
    247 
    248   array = PyArray_FROM_OT (o, AUBIO_NPY_SMPL);
    249   if (array == NULL) {
    250     PyErr_SetString (PyExc_ValueError, "should be an array of float");
    251     goto fail;
    252   }
    253 
    254   if (PyArray_NDIM (array) != 1) {
    255     PyErr_SetString (PyExc_ValueError, "should be a one-dimensional array");
    256     goto fail;
    257   }
    258 
    259   if (PyArray_SIZE (array) != self->length) {
    260     PyErr_SetString (PyExc_ValueError,
    261         "should be an array of same length as target fvec");
    262     goto fail;
    263   }
    264 
    265   self->o->data[index] = (smpl_t *) PyArray_GETPTR1 (array, 0);
     201
     202  if (index < 0 || index >= self->length) {
     203    PyErr_SetString (PyExc_IndexError, "no such element");
     204    goto fail;
     205  }
     206
     207  if (PyFloat_Check (o)) {
     208    PyErr_SetString (PyExc_ValueError, "should be a float");
     209    goto fail;
     210  }
     211
     212  self->o->data[index] = (smpl_t) PyFloat_AsDouble(o);
    266213
    267214  return 0;
     
    269216fail:
    270217  return -1;
     218}
     219
     220int
     221Py_fvec_get_length (Py_fvec * self)                                                                                                                                     
     222{                                                                                                                                                                       
     223  return self->length;                                                                                                                                                 
    271224}
    272225
     
    275228  {"length", T_INT, offsetof (Py_fvec, length), READONLY,
    276229      "length attribute"},
    277   {"channels", T_INT, offsetof (Py_fvec, channels), READONLY,
    278       "channels attribute"},
    279230  {NULL}                        /* Sentinel */
    280231};
     
    287238
    288239static PySequenceMethods Py_fvec_tp_as_sequence = {
    289   (lenfunc) Py_fvec_getchannels,        /* sq_length         */
     240  (lenfunc) Py_fvec_get_length,        /* sq_length         */
    290241  0,                                    /* sq_concat         */
    291242  0,                                    /* sq_repeat         */
  • interfaces/python/py-phasevoc.c

    r0536612 rf658288  
    33static char Py_pvoc_doc[] = "pvoc object";
    44
    5 AUBIO_DECLARE(pvoc, uint_t win_s; uint_t hop_s; uint_t channels)
     5AUBIO_DECLARE(pvoc, uint_t win_s; uint_t hop_s)
    66
    77//AUBIO_NEW(pvoc)
     
    99Py_pvoc_new (PyTypeObject * type, PyObject * args, PyObject * kwds)
    1010{
    11   int win_s = 0, hop_s = 0, channels = 0;
     11  int win_s = 0, hop_s = 0;
    1212  Py_pvoc *self;
    13   static char *kwlist[] = { "win_s", "hop_s", "channels", NULL };
     13  static char *kwlist[] = { "win_s", "hop_s", NULL };
    1414
    15   if (!PyArg_ParseTupleAndKeywords (args, kwds, "|III", kwlist,
    16           &win_s, &hop_s, &channels)) {
     15  if (!PyArg_ParseTupleAndKeywords (args, kwds, "|II", kwlist,
     16          &win_s, &hop_s)) {
    1717    return NULL;
    1818  }
     
    2626  self->win_s = Py_default_vector_length;
    2727  self->hop_s = Py_default_vector_length/2;
    28   self->channels = Py_default_vector_channels;
    2928
    3029  if (self == NULL) {
     
    4847  }
    4948
    50   if (channels > 0) {
    51     self->channels = channels;
    52   } else if (channels < 0) {
    53     PyErr_SetString (PyExc_ValueError,
    54         "can not use negative number of filters");
    55     return NULL;
    56   }
    57 
    5849  return (PyObject *) self;
    5950}
    6051
    6152
    62 AUBIO_INIT(pvoc, self->win_s, self->hop_s, self->channels)
     53AUBIO_INIT(pvoc, self->win_s, self->hop_s)
    6354
    6455AUBIO_DEL(pvoc)
     
    8273
    8374  output = (Py_cvec*) PyObject_New (Py_cvec, &Py_cvecType);
    84   output->channels = vec->channels;
    8575  output->length = ((Py_pvoc *) self)->win_s;
    86   output->o = new_cvec(((Py_pvoc *) self)->win_s, vec->channels);
     76  output->o = new_cvec(((Py_pvoc *) self)->win_s);
    8777
    8878  // compute the function
     
    9888  {"hop_s", T_INT, offsetof (Py_pvoc, hop_s), READONLY,
    9989    "size of the hop"},
    100   {"channels", T_INT, offsetof (Py_pvoc, channels), READONLY,
    101     "number of channels"},
    10290AUBIO_MEMBERS_STOP(pvoc)
    10391
     
    120108
    121109  output = (Py_fvec*) PyObject_New (Py_fvec, &Py_fvecType);
    122   output->channels = vec->channels;
    123110  output->length = ((Py_pvoc *) self)->hop_s;
    124   output->o = new_fvec(output->length, output->channels);
     111  output->o = new_fvec(output->length);
    125112
    126113  // compute the function
  • interfaces/python/setup.py

    r0536612 rf658288  
    1111            ["aubiomodule.c",
    1212            "py-fvec.c",
     13            "py-fmat.c",
    1314            "py-cvec.c",
    1415            "py-filter.c",
  • interfaces/python/test_aubio.py

    r0536612 rf658288  
    33from _aubio import *
    44from numpy import array
    5 
    6 AUBIO_DO_CASTING = 0
    75
    86class aubiomodule_test_case(TestCase):
     
    119    """ try importing aubio """
    1210
    13   def test_vector(self):
    14     a = fvec()
    15     a.length, a.channels
    16     a[0]
    17     array(a)
    18     a = fvec(10)
    19     a = fvec(1, 2)
    20     array(a).T
    21     a[0] = range(a.length)
    22     a[1][0] = 2
    23 
    24   def test_wrong_values(self):
    25     self.assertRaises (ValueError, fvec, -10)
    26     self.assertRaises (ValueError, fvec, 1, -1)
    27  
    28     a = fvec(2, 3)
    29     self.assertRaises (IndexError, a.__getitem__, 3)
    30     self.assertRaises (IndexError, a[0].__getitem__, 2)
    31 
    32   def test_alpha_norm_of_fvec(self):
    33     a = fvec(2, 2)
    34     self.assertEquals (alpha_norm(a, 1), 0)
    35     a[0] = [1, 2]
    36     self.assertEquals (alpha_norm(a, 1), 1.5)
    37     a[1] = [1, 2]
    38     self.assertEquals (alpha_norm(a, 1), 3)
    39     a[0] = [0, 1]; a[1] = [1, 0]
    40     self.assertEquals (alpha_norm(a, 2), 1)
    41 
    42   def test_alpha_norm_of_array_of_float32(self):
    43     # check scalar fails
    44     a = array(1, dtype = 'float32')
    45     self.assertRaises (ValueError, alpha_norm, a, 1)
    46     # check 3d array fails
    47     a = array([[[1,2],[3,4]]], dtype = 'float32')
    48     self.assertRaises (ValueError, alpha_norm, a, 1)
    49     # check 1d array
    50     a = array(range(10), dtype = 'float32')
    51     self.assertEquals (alpha_norm(a, 1), 4.5)
    52     # check 2d array
    53     a = array([range(10), range(10)], dtype = 'float32')
    54     self.assertEquals (alpha_norm(a, 1), 9)
    55 
    56   def test_alpha_norm_of_array_of_int(self):
    57     a = array(1, dtype = 'int')
    58     self.assertRaises (ValueError, alpha_norm, a, 1)
    59     a = array([[[1,2],[3,4]]], dtype = 'int')
    60     self.assertRaises (ValueError, alpha_norm, a, 1)
    61     a = array(range(10), dtype = 'int')
    62     self.assertRaises (ValueError, alpha_norm, a, 1)
    63 
    64   def test_alpha_norm_of_array_of_string (self):
    65     a = "hello"
    66     self.assertRaises (ValueError, alpha_norm, a, 1)
    67 
    68   def test_zero_crossing_rate(self):
    69     a = array([0,1,-1], dtype='float32')
    70     self.assertEquals (zero_crossing_rate(a), 1./3 )
    71     a = array([0.]*100, dtype='float32')
    72     self.assertEquals (zero_crossing_rate(a), 0 )
    73     a = array([-1.]*100, dtype='float32')
    74     self.assertEquals (zero_crossing_rate(a), 0 )
    75     a = array([1.]*100, dtype='float32')
    76     self.assertEquals (zero_crossing_rate(a), 0 )
    77 
    78   def test_alpha_norm_of_array_of_float64(self):
    79     # check scalar fail
    80     a = array(1, dtype = 'float64')
    81     self.assertRaises (ValueError, alpha_norm, a, 1)
    82     # check 3d array fail
    83     a = array([[[1,2],[3,4]]], dtype = 'float64')
    84     self.assertRaises (ValueError, alpha_norm, a, 1)
    85     if AUBIO_DO_CASTING:
    86       # check float64 1d array fail
    87       a = array(range(10), dtype = 'float64')
    88       self.assertEquals (alpha_norm(a, 1), 4.5)
    89       # check float64 2d array fail
    90       a = array([range(10), range(10)], dtype = 'float64')
    91       self.assertEquals (alpha_norm(a, 1), 9)
    92     else:
    93       # check float64 1d array fail
    94       a = array(range(10), dtype = 'float64')
    95       self.assertRaises (ValueError, alpha_norm, a, 1)
    96       # check float64 2d array fail
    97       a = array([range(10), range(10)], dtype = 'float64')
    98       self.assertRaises (ValueError, alpha_norm, a, 1)
    99 
    100   def test_fvec_min_removal_of_array(self):
    101     a = array([20,1,19], dtype='float32')
    102     b = min_removal(a)
    103     assert_equal (array(b), [19, 0, 18])
    104     assert_equal (b, [19, 0, 18])
    105     assert_equal (a, b)
    106     a[0] = 0
    107     assert_equal (a, b)
    108 
    109   def test_fvec_min_removal_of_array_float64(self):
    110     a = array([20,1,19], dtype='float64')
    111     if AUBIO_DO_CASTING:
    112       b = min_removal(a)
    113       assert_equal (array(b), [19, 0, 18])
    114       assert_equal (b, [19, 0, 18])
    115       #assert_equal (a, b)
    116     else:
    117       self.assertRaises (ValueError, min_removal, a)
    118      
    119   def test_fvec_min_removal_of_fvec(self):
    120     a = fvec(3, 1)
    121     a[0] = [20, 1, 19]
    122     b = min_removal(a)
    123     assert_equal (array(b), [19, 0, 18])
    124     assert_equal (b, [19, 0, 18])
    125     assert_equal (a, b)
    12611
    12712if __name__ == '__main__':
  • src/aubio.h

    r0536612 rf658288  
    4949
    5050  Two basic structures are being used in aubio: ::fvec_t and ::cvec_t. The
    51   ::fvec_t structures are used to store vectors of floating pointer number,
    52   optionally on several channels. ::cvec_t are used to store complex number,
    53   as two vectors of norm and phase elements, also on several channels.
    54  
     51  ::fvec_t structures are used to store vectors of floating pointer number.
     52  ::cvec_t are used to store complex number, as two vectors of norm and phase
     53  elements.
     54
    5555  Additionally, the ::lvec_t structure can be used to store floating point
    5656  numbers in double precision. They are mostly used to store filter
    5757  coefficients, to avoid instability.
    58  
     58
    5959  \subsection objects Available objects
    6060
     
    6464
    6565  // fast Fourier transform (FFT)
    66   aubio_fft_t *fft = new_aubio_fft (winsize, channels);
     66  aubio_fft_t *fft = new_aubio_fft (winsize);
    6767  // phase vocoder
    68   aubio_pvoc_t *pv = new_aubio_pvoc (winsize, stepsize, channels);
    69   // onset detection 
    70   aubio_onset_t *onset = new_aubio_onset (method, winsize, stepsize, channels, samplerate);
    71   // pitch detection 
    72   aubio_pitch_t *pitch = new_aubio_pitch (method, winsize, stepsize, channels, samplerate);
     68  aubio_pvoc_t *pv = new_aubio_pvoc (winsize, stepsize);
     69  // onset detection
     70  aubio_onset_t *onset = new_aubio_onset (method, winsize, stepsize, samplerate);
     71  // pitch detection
     72  aubio_pitch_t *pitch = new_aubio_pitch (method, winsize, stepsize, samplerate);
    7373  // beat tracking
    74   aubio_tempo_t *tempo = new_aubio_tempo (method, winsize, stepsize, channels, samplerate);
     74  aubio_tempo_t *tempo = new_aubio_tempo (method, winsize, stepsize, samplerate);
    7575
    7676  \endcode
     
    8282  Here is a simple example that creates an A-Weighting filter and applies it to a
    8383  vector.
    84  
     84
    8585  \code
    8686
    87   // set channels, window size, and sampling rate
    88   uint_t channels = 2, winsize = 1024, sr = 44100;
     87  // set window size, and sampling rate
     88  uint_t winsize = 1024, sr = 44100;
    8989  // create a vector
    90   fvec_t *this_buffer = new_fvec (winsize, channels);
     90  fvec_t *this_buffer = new_fvec (winsize);
    9191  // create the a-weighting filter
    92   aubio_filter_t *this_filter = new_aubio_filter_a_weighting (channels, sr);
    93  
     92  aubio_filter_t *this_filter = new_aubio_filter_a_weighting (sr);
     93
    9494  while (running) {
    9595    // here some code to put some data in this_buffer
     
    9999    aubio_filter_do (this_filter, this_buffer);
    100100
    101     // here some code to get some data from this_buffer 
     101    // here some code to get some data from this_buffer
    102102    // ...
    103103  }
    104  
     104
    105105  // and free the structures
    106106  del_aubio_filter (this_filter);
     
    129129
    130130  \section download Download
    131  
     131
    132132  Latest versions, further documentation, examples, wiki, and mailing lists can
    133133  be found at http://aubio.org .
    134  
     134
    135135 */
    136136
     
    141141
    142142  Programmers just need to include this file as:
    143  
     143
    144144  @code
    145145    #include <aubio/aubio.h>
    146146  @endcode
    147  
     147
    148148 */
    149149
     
    158158#include "cvec.h"
    159159#include "lvec.h"
     160#include "fmat.h"
    160161#include "musicutils.h"
    161162#include "temporal/resampler.h"
  • src/cvec.c

    r0536612 rf658288  
    2222#include "cvec.h"
    2323
    24 cvec_t * new_cvec( uint_t length, uint_t channels) {
     24cvec_t * new_cvec( uint_t length) {
    2525  cvec_t * s = AUBIO_NEW(cvec_t);
    26   uint_t i,j;
    27   s->channels = channels;
     26  uint_t j;
    2827  s->length = length/2 + 1;
    29   s->norm = AUBIO_ARRAY(smpl_t*,s->channels);
    30   s->phas = AUBIO_ARRAY(smpl_t*,s->channels);
    31   for (i=0; i< s->channels; i++) {
    32     s->norm[i] = AUBIO_ARRAY(smpl_t,s->length);
    33     s->phas[i] = AUBIO_ARRAY(smpl_t,s->length);
    34     for (j=0; j< s->length; j++) {
    35       s->norm[i][j]=0.;
    36       s->phas[i][j]=0.;
    37     }
     28  s->norm = AUBIO_ARRAY(smpl_t,s->length);
     29  s->phas = AUBIO_ARRAY(smpl_t,s->length);
     30  for (j=0; j< s->length; j++) {
     31    s->norm[j]=0.;
     32    s->phas[j]=0.;
    3833  }
    3934  return s;
     
    4136
    4237void del_cvec(cvec_t *s) {
    43   uint_t i;
    44   for (i=0; i<s->channels; i++) {
    45     AUBIO_FREE(s->norm[i]);
    46     AUBIO_FREE(s->phas[i]);
    47   }
    4838  AUBIO_FREE(s->norm);
    4939  AUBIO_FREE(s->phas);
     
    5141}
    5242
    53 void cvec_write_norm(cvec_t *s, smpl_t data, uint_t channel, uint_t position) {
    54   s->norm[channel][position] = data;
     43void cvec_write_norm(cvec_t *s, smpl_t data, uint_t position) {
     44  s->norm[position] = data;
    5545}
    56 void cvec_write_phas(cvec_t *s, smpl_t data, uint_t channel, uint_t position) {
    57   s->phas[channel][position] = data;
     46void cvec_write_phas(cvec_t *s, smpl_t data, uint_t position) {
     47  s->phas[position] = data;
    5848}
    59 smpl_t cvec_read_norm(cvec_t *s, uint_t channel, uint_t position) {
    60   return s->norm[channel][position];
     49smpl_t cvec_read_norm(cvec_t *s, uint_t position) {
     50  return s->norm[position];
    6151}
    62 smpl_t cvec_read_phas(cvec_t *s, uint_t channel, uint_t position) {
    63   return s->phas[channel][position];
     52smpl_t cvec_read_phas(cvec_t *s, uint_t position) {
     53  return s->phas[position];
    6454}
    65 void cvec_put_norm_channel(cvec_t *s, smpl_t * data, uint_t channel) {
    66   s->norm[channel] = data;
    67 }
    68 void cvec_put_phas_channel(cvec_t *s, smpl_t * data, uint_t channel) {
    69   s->phas[channel] = data;
    70 }
    71 smpl_t * cvec_get_norm_channel(cvec_t *s, uint_t channel) {
    72   return s->norm[channel];
    73 }
    74 smpl_t * cvec_get_phas_channel(cvec_t *s, uint_t channel) {
    75   return s->phas[channel];
    76 }
    77 smpl_t ** cvec_get_norm(cvec_t *s) {
     55smpl_t * cvec_get_norm(cvec_t *s) {
    7856  return s->norm;
    7957}
    80 smpl_t ** cvec_get_phas(cvec_t *s) {
     58smpl_t * cvec_get_phas(cvec_t *s) {
    8159  return s->phas;
    8260}
     
    8563
    8664void cvec_print(cvec_t *s) {
    87   uint_t i,j;
    88   for (i=0; i< s->channels; i++) {
    89     AUBIO_MSG("norm: ");
    90     for (j=0; j< s->length; j++) {
    91       AUBIO_MSG(AUBIO_SMPL_FMT " ", s->norm[i][j]);
    92     }
    93     AUBIO_MSG("\n");
    94     AUBIO_MSG("phas: ");
    95     for (j=0; j< s->length; j++) {
    96       AUBIO_MSG(AUBIO_SMPL_FMT " ", s->phas[i][j]);
    97     }
    98     AUBIO_MSG("\n");
     65  uint_t j;
     66  AUBIO_MSG("norm: ");
     67  for (j=0; j< s->length; j++) {
     68    AUBIO_MSG(AUBIO_SMPL_FMT " ", s->norm[j]);
    9969  }
     70  AUBIO_MSG("\n");
     71  AUBIO_MSG("phas: ");
     72  for (j=0; j< s->length; j++) {
     73    AUBIO_MSG(AUBIO_SMPL_FMT " ", s->phas[j]);
     74  }
     75  AUBIO_MSG("\n");
    10076}
    10177
    10278void cvec_set(cvec_t *s, smpl_t val) {
    103   uint_t i,j;
    104   for (i=0; i< s->channels; i++) {
    105     for (j=0; j< s->length; j++) {
    106       s->norm[i][j] = val;
    107     }
     79  uint_t j;
     80  for (j=0; j< s->length; j++) {
     81    s->norm[j] = val;
    10882  }
    10983}
  • src/cvec.h

    r0536612 rf658288  
    3939typedef struct {
    4040  uint_t length;   /**< length of buffer = (requested length)/2 + 1 */
    41   uint_t channels; /**< number of channels */
    42   smpl_t **norm;   /**< norm array of size [length] * [channels] */
    43   smpl_t **phas;   /**< phase array of size [length] * [channels] */
     41  smpl_t *norm;   /**< norm array of size [length] */
     42  smpl_t *phas;   /**< phase array of size [length] */
    4443} cvec_t;
    4544
     
    4746
    4847  This function creates a cvec_t structure holding two arrays of size
    49   [length/2+1] * channels, corresponding to the norm and phase values of the
     48  [length/2+1], corresponding to the norm and phase values of the
    5049  spectral frame. The length stored in the structure is the actual size of both
    5150  arrays, not the length of the complex and symetrical vector, specified as
     
    5352
    5453  \param length the length of the buffer to create
    55   \param channels the number of channels in the buffer
    5654
    5755*/
    58 cvec_t * new_cvec(uint_t length, uint_t channels);
     56cvec_t * new_cvec(uint_t length);
    5957/** cvec_t buffer deletion function
    6058
     
    6664
    6765  Note that this function is not used in the aubio library, since the same
    68   result can be obtained by assigning vec->norm[channel][position]. Its purpose
     66  result can be obtained by assigning vec->norm[position]. Its purpose
    6967  is to access these values from wrappers, as created by swig.
    7068
    7169  \param s vector to write to
    72   \param data norm value to write in s->norm[channel][position]
    73   \param channel channel to write to
     70  \param data norm value to write in s->norm[position]
    7471  \param position sample position to write to
    7572
    7673*/
    77 void cvec_write_norm(cvec_t *s, smpl_t data, uint_t channel, uint_t position);
     74void cvec_write_norm(cvec_t *s, smpl_t data, uint_t position);
    7875/** write phase value in a complex buffer
    7976
    8077  Note that this function is not used in the aubio library, since the same
    81   result can be obtained by assigning vec->phas[channel][position]. Its purpose
     78  result can be obtained by assigning vec->phas[position]. Its purpose
    8279  is to access these values from wrappers, as created by swig.
    8380
    8481  \param s vector to write to
    85   \param data phase value to write in s->phas[channel][position]
    86   \param channel channel to write to
     82  \param data phase value to write in s->phas[position]
    8783  \param position sample position to write to
    8884
    8985*/
    90 void cvec_write_phas(cvec_t *s, smpl_t data, uint_t channel, uint_t position);
     86void cvec_write_phas(cvec_t *s, smpl_t data, uint_t position);
    9187/** read norm value from a complex buffer
    9288
    9389  Note that this function is not used in the aubio library, since the same
    94   result can be obtained with vec->norm[channel][position]. Its purpose is to
     90  result can be obtained with vec->norm[position]. Its purpose is to
    9591  access these values from wrappers, as created by swig.
    9692
    9793  \param s vector to read from
    98   \param channel channel to read from
    9994  \param position sample position to read from
    10095
    10196*/
    102 smpl_t cvec_read_norm(cvec_t *s, uint_t channel, uint_t position);
     97smpl_t cvec_read_norm(cvec_t *s, uint_t position);
    10398/** read phase value from a complex buffer
    10499
    105100  Note that this function is not used in the aubio library, since the same
    106   result can be obtained with vec->phas[channel][position]. Its purpose is to
     101  result can be obtained with vec->phas[position]. Its purpose is to
    107102  access these values from wrappers, as created by swig.
    108103
    109104  \param s vector to read from
    110   \param channel channel to read from
    111105  \param position sample position to read from
    112106
    113107*/
    114 smpl_t cvec_read_phas(cvec_t *s, uint_t channel, uint_t position);
    115 /** write norm channel in a complex buffer
    116 
    117   Note that this function is not used in the aubio library, since the same
    118   result can be obtained by assigning vec->norm[channel]. Its purpose is to
    119   access these values from wrappers, as created by swig.
    120 
    121   \param s vector to write to
    122   \param data norm vector of [length] samples to write in s->norm[channel]
    123   \param channel channel to write to
    124 
    125 */
    126 void cvec_put_norm_channel(cvec_t *s, smpl_t * data, uint_t channel);
    127 /** write phase channel in a complex buffer
    128 
    129   Note that this function is not used in the aubio library, since the same
    130   result can be obtained by assigning vec->phas[channel]. Its purpose is to
    131   access these values from wrappers, as created by swig.
    132 
    133   \param s vector to write to
    134   \param data phase vector of [length] samples to write in s->phas[channel]
    135   \param channel channel to write to
    136 
    137 */
    138 void cvec_put_phas_channel(cvec_t *s, smpl_t * data, uint_t channel);
    139 /** read norm channel from a complex buffer
    140 
    141   Note that this function is not used in the aubio library, since the same
    142   result can be obtained with vec->norm[channel]. Its purpose is to access
    143   these values from wrappers, as created by swig.
    144 
    145   \param s vector to read from
    146   \param channel channel to read from
    147 
    148 */
    149 smpl_t * cvec_get_norm_channel(cvec_t *s, uint_t channel);
    150 /** write phase channel in a complex buffer
    151 
    152   Note that this function is not used in the aubio library, since the same
    153   result can be obtained with vec->phas[channel]. Its purpose is to access
    154   these values from wrappers, as created by swig.
    155 
    156   \param s vector to read from
    157   \param channel channel to read from
    158 
    159 */
    160 smpl_t * cvec_get_phas_channel(cvec_t *s, uint_t channel);
     108smpl_t cvec_read_phas(cvec_t *s, uint_t position);
    161109/** read norm data from a complex buffer
    162110
     
    168116
    169117*/
    170 smpl_t ** cvec_get_norm(cvec_t *s);
     118smpl_t * cvec_get_norm(cvec_t *s);
    171119/** read phase data from a complex buffer
    172120
     
    178126
    179127*/
    180 smpl_t ** cvec_get_phas(cvec_t *s);
     128smpl_t * cvec_get_phas(cvec_t *s);
    181129
    182130/** print out cvec data
  • src/fvec.c

    r0536612 rf658288  
    2222#include "fvec.h"
    2323
    24 fvec_t * new_fvec( uint_t length, uint_t channels) {
     24fvec_t * new_fvec( uint_t length) {
    2525  fvec_t * s = AUBIO_NEW(fvec_t);
    26   uint_t i,j;
    27   s->channels = channels;
     26  uint_t j;
    2827  s->length = length;
    29   s->data = AUBIO_ARRAY(smpl_t*,s->channels);
    30   for (i=0; i< s->channels; i++) {
    31     s->data[i] = AUBIO_ARRAY(smpl_t, s->length);
    32     for (j=0; j< s->length; j++) {
    33       s->data[i][j]=0.;
    34     }
     28  s->data = AUBIO_ARRAY(smpl_t, s->length);
     29  for (j=0; j< s->length; j++) {
     30    s->data[j]=0.;
    3531  }
    3632  return s;
     
    3834
    3935void del_fvec(fvec_t *s) {
    40   uint_t i;
    41   for (i=0; i<s->channels; i++) {
    42     AUBIO_FREE(s->data[i]);
    43   }
    4436  AUBIO_FREE(s->data);
    4537  AUBIO_FREE(s);
    4638}
    4739
    48 void fvec_write_sample(fvec_t *s, smpl_t data, uint_t channel, uint_t position) {
    49   s->data[channel][position] = data;
    50 }
    51 smpl_t fvec_read_sample(fvec_t *s, uint_t channel, uint_t position) {
    52   return s->data[channel][position];
    53 }
    54 void fvec_put_channel(fvec_t *s, smpl_t * data, uint_t channel) {
    55   s->data[channel] = data;
    56 }
    57 smpl_t * fvec_get_channel(fvec_t *s, uint_t channel) {
    58   return s->data[channel];
     40void fvec_write_sample(fvec_t *s, smpl_t data, uint_t position) {
     41  s->data[position] = data;
    5942}
    6043
    61 smpl_t ** fvec_get_data(fvec_t *s) {
     44smpl_t fvec_read_sample(fvec_t *s, uint_t position) {
     45  return s->data[position];
     46}
     47
     48smpl_t * fvec_get_data(fvec_t *s) {
    6249  return s->data;
    6350}
     
    6653
    6754void fvec_print(fvec_t *s) {
    68   uint_t i,j;
    69   for (i=0; i< s->channels; i++) {
    70     for (j=0; j< s->length; j++) {
    71       AUBIO_MSG(AUBIO_SMPL_FMT " ", s->data[i][j]);
    72     }
    73     AUBIO_MSG("\n");
     55  uint_t j;
     56  for (j=0; j< s->length; j++) {
     57    AUBIO_MSG(AUBIO_SMPL_FMT " ", s->data[j]);
    7458  }
     59  AUBIO_MSG("\n");
    7560}
    7661
    7762void fvec_set(fvec_t *s, smpl_t val) {
    78   uint_t i,j;
    79   for (i=0; i< s->channels; i++) {
    80     for (j=0; j< s->length; j++) {
    81       s->data[i][j] = val;
    82     }
     63  uint_t j;
     64  for (j=0; j< s->length; j++) {
     65    s->data[j] = val;
    8366  }
    8467}
     
    9376
    9477void fvec_rev(fvec_t *s) {
    95   uint_t i,j;
    96   for (i=0; i< s->channels; i++) {
    97     for (j=0; j< FLOOR(s->length/2); j++) {
    98       ELEM_SWAP(s->data[i][j], s->data[i][s->length-1-j]);
    99     }
     78  uint_t j;
     79  for (j=0; j< FLOOR(s->length/2); j++) {
     80    ELEM_SWAP(s->data[j], s->data[s->length-1-j]);
    10081  }
    10182}
    10283
    10384void fvec_weight(fvec_t *s, fvec_t *weight) {
    104   uint_t i,j;
     85  uint_t j;
    10586  uint_t length = MIN(s->length, weight->length);
    106   for (i=0; i< s->channels; i++) {
    107     for (j=0; j< length; j++) {
    108       s->data[i][j] *= weight->data[0][j];
    109     }
     87  for (j=0; j< length; j++) {
     88    s->data[j] *= weight->data[j];
    11089  }
    11190}
    11291
    11392void fvec_copy(fvec_t *s, fvec_t *t) {
    114   uint_t i,j;
    115   uint_t channels = MIN(s->channels, t->channels);
     93  uint_t j;
    11694  uint_t length = MIN(s->length, t->length);
    117   if (s->channels != t->channels) {
    118     AUBIO_ERR("warning, trying to copy %d channels to %d channels\n",
    119             s->channels, t->channels);
    120   }
    12195  if (s->length != t->length) {
    122     AUBIO_ERR("warning, trying to copy %d elements to %d elements \n",
     96    AUBIO_WRN("trying to copy %d elements to %d elements \n",
    12397            s->length, t->length);
    12498  }
    125   for (i=0; i< channels; i++) {
    126     for (j=0; j< length; j++) {
    127       t->data[i][j] = s->data[i][j];
    128     }
     99  for (j=0; j< length; j++) {
     100    t->data[j] = s->data[j];
    129101  }
    130102}
  • src/fvec.h

    r0536612 rf658288  
    3838typedef struct {
    3939  uint_t length;   /**< length of buffer */
    40   uint_t channels; /**< number of channels */
    41   smpl_t **data;   /**< data array of size [length] * [channels] */
     40  smpl_t *data;   /**< data array of size [length] */
    4241} fvec_t;
    4342
     
    4544
    4645  \param length the length of the buffer to create
    47   \param channels the number of channels in the buffer
    4846
    4947*/
    50 fvec_t * new_fvec(uint_t length, uint_t channels);
     48fvec_t * new_fvec(uint_t length);
    5149/** fvec_t buffer deletion function
    5250
     
    5856
    5957  Note that this function is not used in the aubio library, since the same
    60   result can be obtained using vec->data[channel][position]. Its purpose is to
     58  result can be obtained using vec->data[position]. Its purpose is to
    6159  access these values from wrappers, as created by swig.
    6260
    6361  \param s vector to read from
    64   \param channel channel to read from
    6562  \param position sample position to read from
    6663
    6764*/
    68 smpl_t fvec_read_sample(fvec_t *s, uint_t channel, uint_t position);
     65smpl_t fvec_read_sample(fvec_t *s, uint_t position);
    6966/** write sample value in a buffer
    7067
    7168  Note that this function is not used in the aubio library, since the same
    72   result can be obtained by assigning vec->data[channel][position]. Its purpose
     69  result can be obtained by assigning vec->data[position]. Its purpose
    7370  is to access these values from wrappers, as created by swig.
    7471
    7572  \param s vector to write to
    76   \param data value to write in s->data[channel][position]
    77   \param channel channel to write to
     73  \param data value to write in s->data[position]
    7874  \param position sample position to write to
    7975
    8076*/
    81 void  fvec_write_sample(fvec_t *s, smpl_t data, uint_t channel, uint_t position);
    82 /** read channel vector from a buffer
     77void  fvec_write_sample(fvec_t *s, smpl_t data, uint_t position);
    8378
    84   Note that this function is not used in the aubio library, since the same
    85   result can be obtained with vec->data[channel]. Its purpose is to access
    86   these values from wrappers, as created by swig.
    87 
    88   \param s vector to read from
    89   \param channel channel to read from
    90 
    91 */
    92 smpl_t * fvec_get_channel(fvec_t *s, uint_t channel);
    93 /** write channel vector into a buffer
    94 
    95   Note that this function is not used in the aubio library, since the same
    96   result can be obtained by assigning vec->data[channel]. Its purpose is to
    97   access these values from wrappers, as created by swig.
    98 
    99   \param s vector to write to
    100   \param data vector of [length] values to write
    101   \param channel channel to write to
    102 
    103 */
    104 void fvec_put_channel(fvec_t *s, smpl_t * data, uint_t channel);
    10579/** read data from a buffer
    10680
     
    11286
    11387*/
    114 smpl_t ** fvec_get_data(fvec_t *s);
     88smpl_t * fvec_get_data(fvec_t *s);
    11589
    11690/** print out fvec data
  • src/lvec.c

    r0536612 rf658288  
    2222#include "lvec.h"
    2323
    24 lvec_t * new_lvec( uint_t length, uint_t channels) {
     24lvec_t * new_lvec( uint_t length) {
    2525  lvec_t * s = AUBIO_NEW(lvec_t);
    26   uint_t i,j;
    27   s->channels = channels;
     26  uint_t j;
    2827  s->length = length;
    29   s->data = AUBIO_ARRAY(lsmp_t*,s->channels);
    30   for (i=0; i< s->channels; i++) {
    31     s->data[i] = AUBIO_ARRAY(lsmp_t, s->length);
    32     for (j=0; j< s->length; j++) {
    33       s->data[i][j]=0.;
    34     }
     28  s->data = AUBIO_ARRAY(lsmp_t, s->length);
     29  for (j=0; j< s->length; j++) {
     30    s->data[j]=0.;
    3531  }
    3632  return s;
     
    3834
    3935void del_lvec(lvec_t *s) {
    40   uint_t i;
    41   for (i=0; i<s->channels; i++) {
    42     AUBIO_FREE(s->data[i]);
    43   }
    4436  AUBIO_FREE(s->data);
    4537  AUBIO_FREE(s);
    4638}
    4739
    48 void lvec_write_sample(lvec_t *s, lsmp_t data, uint_t channel, uint_t position) {
    49   s->data[channel][position] = data;
     40void lvec_write_sample(lvec_t *s, lsmp_t data, uint_t position) {
     41  s->data[position] = data;
    5042}
    51 lsmp_t lvec_read_sample(lvec_t *s, uint_t channel, uint_t position) {
    52   return s->data[channel][position];
    53 }
    54 void lvec_put_channel(lvec_t *s, lsmp_t * data, uint_t channel) {
    55   s->data[channel] = data;
    56 }
    57 lsmp_t * lvec_get_channel(lvec_t *s, uint_t channel) {
    58   return s->data[channel];
     43lsmp_t lvec_read_sample(lvec_t *s, uint_t position) {
     44  return s->data[position];
    5945}
    6046
    61 lsmp_t ** lvec_get_data(lvec_t *s) {
     47lsmp_t * lvec_get_data(lvec_t *s) {
    6248  return s->data;
    6349}
     
    6652
    6753void lvec_print(lvec_t *s) {
    68   uint_t i,j;
    69   for (i=0; i< s->channels; i++) {
    70     for (j=0; j< s->length; j++) {
    71       AUBIO_MSG(AUBIO_LSMP_FMT " ", s->data[i][j]);
    72     }
    73     AUBIO_MSG("\n");
     54  uint_t j;
     55  for (j=0; j< s->length; j++) {
     56    AUBIO_MSG(AUBIO_LSMP_FMT " ", s->data[j]);
    7457  }
     58  AUBIO_MSG("\n");
    7559}
    7660
    7761void lvec_set(lvec_t *s, smpl_t val) {
    78   uint_t i,j;
    79   for (i=0; i< s->channels; i++) {
    80     for (j=0; j< s->length; j++) {
    81       s->data[i][j] = val;
    82     }
     62  uint_t j;
     63  for (j=0; j< s->length; j++) {
     64    s->data[j] = val;
    8365  }
    8466}
  • src/lvec.h

    r0536612 rf658288  
    3939typedef struct {
    4040  uint_t length;   /**< length of buffer */
    41   uint_t channels; /**< number of channels */
    42   lsmp_t **data;   /**< data array of size [length] * [channels] */
     41  lsmp_t *data;   /**< data array of size [length] */
    4342} lvec_t;
    4443
     
    4645
    4746  \param length the length of the buffer to create
    48   \param channels the number of channels in the buffer
    4947
    5048*/
    51 lvec_t * new_lvec(uint_t length, uint_t channels);
     49lvec_t * new_lvec(uint_t length);
    5250/** lvec_t buffer deletion function
    5351
     
    5957
    6058  Note that this function is not used in the aubio library, since the same
    61   result can be obtained using vec->data[channel][position]. Its purpose is to
     59  result can be obtained using vec->data[position]. Its purpose is to
    6260  access these values from wrappers, as created by swig.
    6361
    6462  \param s vector to read from
    65   \param channel channel to read from
    6663  \param position sample position to read from
    6764
    6865*/
    69 lsmp_t lvec_read_sample(lvec_t *s, uint_t channel, uint_t position);
     66lsmp_t lvec_read_sample(lvec_t *s, uint_t position);
    7067/** write sample value in a buffer
    7168
    7269  Note that this function is not used in the aubio library, since the same
    73   result can be obtained by assigning vec->data[channel][position]. Its purpose
     70  result can be obtained by assigning vec->data[position]. Its purpose
    7471  is to access these values from wrappers, as created by swig.
    7572
    7673  \param s vector to write to
    77   \param data value to write in s->data[channel][position]
    78   \param channel channel to write to
     74  \param data value to write in s->data[position]
    7975  \param position sample position to write to
    8076
    8177*/
    82 void  lvec_write_sample(lvec_t *s, lsmp_t data, uint_t channel, uint_t position);
    83 /** read channel vector from a buffer
     78void  lvec_write_sample(lvec_t *s, lsmp_t data, uint_t position);
    8479
    85   Note that this function is not used in the aubio library, since the same
    86   result can be obtained with vec->data[channel]. Its purpose is to access
    87   these values from wrappers, as created by swig.
    88 
    89   \param s vector to read from
    90   \param channel channel to read from
    91 
    92 */
    93 lsmp_t * lvec_get_channel(lvec_t *s, uint_t channel);
    94 /** write channel vector into a buffer
    95 
    96   Note that this function is not used in the aubio library, since the same
    97   result can be obtained by assigning vec->data[channel]. Its purpose is to
    98   access these values from wrappers, as created by swig.
    99 
    100   \param s vector to write to
    101   \param data vector of [length] values to write
    102   \param channel channel to write to
    103 
    104 */
    105 void lvec_put_channel(lvec_t *s, lsmp_t * data, uint_t channel);
    10680/** read data from a buffer
    10781
     
    11387
    11488*/
    115 lsmp_t ** lvec_get_data(lvec_t *s);
     89lsmp_t * lvec_get_data(lvec_t *s);
    11690
    11791/** print out lvec data
  • src/mathutils.c

    r0536612 rf658288  
    4646new_aubio_window (char_t * window_type, uint_t size)
    4747{
    48   // create fvec of size x 1 channel
    49   fvec_t * win = new_fvec( size, 1);
    50   smpl_t * w = win->data[0];
     48  fvec_t * win = new_fvec (size);
     49  smpl_t * w = win->data;
    5150  uint_t i;
    5251  aubio_window_type wintype;
     
    134133fvec_mean (fvec_t * s)
    135134{
    136   uint_t i, j;
     135  uint_t j;
    137136  smpl_t tmp = 0.0;
    138   for (i = 0; i < s->channels; i++)
    139     for (j = 0; j < s->length; j++)
    140       tmp += s->data[i][j];
     137  for (j = 0; j < s->length; j++) {
     138    tmp += s->data[j];
     139  }
    141140  return tmp / (smpl_t) (s->length);
    142141}
    143142
    144143smpl_t
    145 fvec_mean_channel (fvec_t * s, uint_t i)
     144fvec_sum (fvec_t * s)
    146145{
    147146  uint_t j;
    148147  smpl_t tmp = 0.0;
    149   for (j = 0; j < s->length; j++)
    150       tmp += s->data[i][j];
    151   return tmp / (smpl_t) (s->length);
    152 }
    153 
    154 smpl_t
    155 fvec_sum (fvec_t * s)
    156 {
    157   uint_t i, j;
     148  for (j = 0; j < s->length; j++) {
     149    tmp += s->data[j];
     150  }
     151  return tmp;
     152}
     153
     154smpl_t
     155fvec_max (fvec_t * s)
     156{
     157  uint_t j;
    158158  smpl_t tmp = 0.0;
    159   for (i = 0; i < s->channels; i++) {
    160     for (j = 0; j < s->length; j++) {
    161       tmp += s->data[i][j];
    162     }
     159  for (j = 0; j < s->length; j++) {
     160    tmp = (tmp > s->data[j]) ? tmp : s->data[j];
    163161  }
    164162  return tmp;
     
    166164
    167165smpl_t
    168 fvec_max (fvec_t * s)
    169 {
    170   uint_t i, j;
    171   smpl_t tmp = 0.0;
    172   for (i = 0; i < s->channels; i++) {
    173     for (j = 0; j < s->length; j++) {
    174       tmp = (tmp > s->data[i][j]) ? tmp : s->data[i][j];
    175     }
    176   }
    177   return tmp;
    178 }
    179 
    180 smpl_t
    181166fvec_min (fvec_t * s)
    182167{
    183   uint_t i, j;
    184   smpl_t tmp = s->data[0][0];
    185   for (i = 0; i < s->channels; i++) {
    186     for (j = 0; j < s->length; j++) {
    187       tmp = (tmp < s->data[i][j]) ? tmp : s->data[i][j];
    188     }
     168  uint_t j;
     169  smpl_t tmp = s->data[0];
     170  for (j = 0; j < s->length; j++) {
     171    tmp = (tmp < s->data[j]) ? tmp : s->data[j];
    189172  }
    190173  return tmp;
     
    194177fvec_min_elem (fvec_t * s)
    195178{
    196   uint_t i, j, pos = 0.;
    197   smpl_t tmp = s->data[0][0];
    198   for (i = 0; i < s->channels; i++) {
    199     for (j = 0; j < s->length; j++) {
    200       pos = (tmp < s->data[i][j]) ? pos : j;
    201       tmp = (tmp < s->data[i][j]) ? tmp : s->data[i][j];
    202     }
     179  uint_t j, pos = 0.;
     180  smpl_t tmp = s->data[0];
     181  for (j = 0; j < s->length; j++) {
     182    pos = (tmp < s->data[j]) ? pos : j;
     183    tmp = (tmp < s->data[j]) ? tmp : s->data[j];
    203184  }
    204185  return pos;
     
    208189fvec_max_elem (fvec_t * s)
    209190{
    210   uint_t i, j, pos = 0;
     191  uint_t j, pos = 0;
    211192  smpl_t tmp = 0.0;
    212   for (i = 0; i < s->channels; i++) {
    213     for (j = 0; j < s->length; j++) {
    214       pos = (tmp > s->data[i][j]) ? pos : j;
    215       tmp = (tmp > s->data[i][j]) ? tmp : s->data[i][j];
    216     }
     193  for (j = 0; j < s->length; j++) {
     194    pos = (tmp > s->data[j]) ? pos : j;
     195    tmp = (tmp > s->data[j]) ? tmp : s->data[j];
    217196  }
    218197  return pos;
     
    222201fvec_shift (fvec_t * s)
    223202{
    224   uint_t i, j;
    225   for (i = 0; i < s->channels; i++) {
    226     for (j = 0; j < s->length / 2; j++) {
    227       ELEM_SWAP (s->data[i][j], s->data[i][j + s->length / 2]);
    228     }
     203  uint_t j;
     204  for (j = 0; j < s->length / 2; j++) {
     205    ELEM_SWAP (s->data[j], s->data[j + s->length / 2]);
    229206  }
    230207}
     
    234211{
    235212  smpl_t energy = 0.;
    236   uint_t i, j;
    237   for (i = 0; i < f->channels; i++) {
    238     for (j = 0; j < f->length; j++) {
    239       energy += SQR (f->data[i][j]);
    240     }
     213  uint_t j;
     214  for (j = 0; j < f->length; j++) {
     215    energy += SQR (f->data[j]);
    241216  }
    242217  return energy;
     
    247222{
    248223  smpl_t hfc = 0.;
    249   uint_t i, j;
    250   for (i = 0; i < v->channels; i++) {
    251     for (j = 0; j < v->length; j++) {
    252       hfc += (i + 1) * v->data[i][j];
    253     }
     224  uint_t j;
     225  for (j = 0; j < v->length; j++) {
     226    hfc += (j + 1) * v->data[j];
    254227  }
    255228  return hfc;
     
    266239fvec_alpha_norm (fvec_t * o, smpl_t alpha)
    267240{
    268   uint_t i, j;
     241  uint_t j;
    269242  smpl_t tmp = 0.;
    270   for (i = 0; i < o->channels; i++) {
    271     for (j = 0; j < o->length; j++) {
    272       tmp += POW (ABS (o->data[i][j]), alpha);
    273     }
     243  for (j = 0; j < o->length; j++) {
     244    tmp += POW (ABS (o->data[j]), alpha);
    274245  }
    275246  return POW (tmp / o->length, 1. / alpha);
     
    279250fvec_alpha_normalise (fvec_t * o, smpl_t alpha)
    280251{
    281   uint_t i, j;
     252  uint_t j;
    282253  smpl_t norm = fvec_alpha_norm (o, alpha);
    283   for (i = 0; i < o->channels; i++) {
    284     for (j = 0; j < o->length; j++) {
    285       o->data[i][j] /= norm;
    286     }
     254  for (j = 0; j < o->length; j++) {
     255    o->data[j] /= norm;
    287256  }
    288257}
     
    291260fvec_add (fvec_t * o, smpl_t val)
    292261{
    293   uint_t i, j;
    294   for (i = 0; i < o->channels; i++) {
    295     for (j = 0; j < o->length; j++) {
    296       o->data[i][j] += val;
    297     }
     262  uint_t j;
     263  for (j = 0; j < o->length; j++) {
     264    o->data[j] += val;
    298265  }
    299266}
    300267
    301268void fvec_adapt_thres(fvec_t * vec, fvec_t * tmp,
    302     uint_t post, uint_t pre, uint_t channel) {
    303   uint_t length = vec->length, i=channel, j;
     269    uint_t post, uint_t pre) {
     270  uint_t length = vec->length, j;
    304271  for (j=0;j<length;j++) {
    305     vec->data[i][j] -= fvec_moving_thres(vec, tmp, post, pre, j, i);
     272    vec->data[j] -= fvec_moving_thres(vec, tmp, post, pre, j);
    306273  }
    307274}
     
    309276smpl_t
    310277fvec_moving_thres (fvec_t * vec, fvec_t * tmpvec,
    311     uint_t post, uint_t pre, uint_t pos, uint_t channel)
    312 {
    313   uint_t i = channel, k;
    314   smpl_t *medar = (smpl_t *) tmpvec->data[i];
     278    uint_t post, uint_t pre, uint_t pos)
     279{
     280  uint_t k;
     281  smpl_t *medar = (smpl_t *) tmpvec->data;
    315282  uint_t win_length = post + pre + 1;
    316283  uint_t length = vec->length;
     
    320287      medar[k] = 0.;            /* 0-padding at the beginning */
    321288    for (k = post + 1 - pos; k < win_length; k++)
    322       medar[k] = vec->data[0][k + pos - post];
     289      medar[k] = vec->data[k + pos - post];
    323290    /* the buffer is fully defined */
    324291  } else if (pos + pre < length) {
    325292    for (k = 0; k < win_length; k++)
    326       medar[k] = vec->data[0][k + pos - post];
     293      medar[k] = vec->data[k + pos - post];
    327294    /* pre part of the buffer does not exist */
    328295  } else {
    329296    for (k = 0; k < length - pos + post; k++)
    330       medar[k] = vec->data[0][k + pos - post];
     297      medar[k] = vec->data[k + pos - post];
    331298    for (k = length - pos + post; k < win_length; k++)
    332299      medar[k] = 0.;            /* 0-padding at the end */
    333300  }
    334   return fvec_median_channel (tmpvec, i);
    335 }
    336 
    337 smpl_t fvec_median_channel (fvec_t * input, uint_t channel) {
     301  return fvec_median (tmpvec);
     302}
     303
     304smpl_t fvec_median (fvec_t * input) {
    338305  uint_t n = input->length;
    339   smpl_t * arr = (smpl_t *) input->data[channel];
     306  smpl_t * arr = (smpl_t *) input->data;
    340307  uint_t low, high ;
    341308  uint_t median;
     
    386353}
    387354
    388 smpl_t fvec_quadint (fvec_t * x, uint_t pos, uint_t i) {
     355smpl_t fvec_quadint (fvec_t * x, uint_t pos) {
    389356  smpl_t s0, s1, s2;
    390357  uint_t x0 = (pos < 1) ? pos : pos - 1;
    391358  uint_t x2 = (pos + 1 < x->length) ? pos + 1 : pos;
    392   if (x0 == pos) return (x->data[i][pos] <= x->data[i][x2]) ? pos : x2;
    393   if (x2 == pos) return (x->data[i][pos] <= x->data[i][x0]) ? pos : x0;
    394   s0 = x->data[i][x0];
    395   s1 = x->data[i][pos];
    396   s2 = x->data[i][x2];
     359  if (x0 == pos) return (x->data[pos] <= x->data[x2]) ? pos : x2;
     360  if (x2 == pos) return (x->data[pos] <= x->data[x0]) ? pos : x0;
     361  s0 = x->data[x0];
     362  s1 = x->data[pos];
     363  s2 = x->data[x2];
    397364  return pos + 0.5 * (s2 - s0 ) / (s2 - 2.* s1 + s0);
    398365}
    399366
    400367uint_t fvec_peakpick(fvec_t * onset, uint_t pos) {
    401   uint_t i=0, tmp=0;
    402   /*for (i=0;i<onset->channels;i++)*/
    403   tmp = (onset->data[i][pos] > onset->data[i][pos-1]
    404       &&  onset->data[i][pos] > onset->data[i][pos+1]
    405       &&  onset->data[i][pos] > 0.);
     368  uint_t tmp=0;
     369  tmp = (onset->data[pos] > onset->data[pos-1]
     370      &&  onset->data[pos] > onset->data[pos+1]
     371      &&  onset->data[pos] > 0.);
    406372  return tmp;
    407373}
     
    512478aubio_zero_crossing_rate (fvec_t * input)
    513479{
    514   uint_t i = 0, j;
     480  uint_t j;
    515481  uint_t zcr = 0;
    516482  for (j = 1; j < input->length; j++) {
    517483    // previous was strictly negative
    518     if (input->data[i][j - 1] < 0.) {
     484    if (input->data[j - 1] < 0.) {
    519485      // current is positive or null
    520       if (input->data[i][j] >= 0.) {
     486      if (input->data[j] >= 0.) {
    521487        zcr += 1;
    522488      }
     
    524490    } else {
    525491      // current is strictly negative
    526       if (input->data[i][j] < 0.) {
     492      if (input->data[j] < 0.) {
    527493        zcr += 1;
    528494      }
     
    535501aubio_autocorr (fvec_t * input, fvec_t * output)
    536502{
    537   uint_t i, j, k, length = input->length;
     503  uint_t i, j, length = input->length;
    538504  smpl_t *data, *acf;
    539505  smpl_t tmp = 0;
    540   for (k = 0; k < input->channels; k++) {
    541     data = input->data[k];
    542     acf = output->data[k];
    543     for (i = 0; i < length; i++) {
    544       tmp = 0.;
    545       for (j = i; j < length; j++) {
    546         tmp += data[j - i] * data[j];
    547       }
    548       acf[i] = tmp / (smpl_t) (length - i);
     506  data = input->data;
     507  acf = output->data;
     508  for (i = 0; i < length; i++) {
     509    tmp = 0.;
     510    for (j = i; j < length; j++) {
     511      tmp += data[j - i] * data[j];
    549512    }
     513    acf[i] = tmp / (smpl_t) (length - i);
    550514  }
    551515}
  • src/mathutils.h

    r0536612 rf658288  
    4141*/
    4242smpl_t fvec_mean (fvec_t * s);
    43 
    44 /** compute the mean of a vector channel
    45 
    46   \param s vector to compute mean from
    47   \param i channel to compute mean from
    48 
    49   \return the mean of v
    50 
    51 */
    52 smpl_t fvec_mean_channel (fvec_t * s, uint_t i);
    5343
    5444/** find the max of a vector
     
    205195*/
    206196smpl_t fvec_moving_thres (fvec_t * v, fvec_t * tmp, uint_t post, uint_t pre,
    207     uint_t pos, uint_t channel);
     197    uint_t pos);
    208198
    209199/** apply adaptive threshold to a vector
     
    218208
    219209*/
    220 void fvec_adapt_thres (fvec_t * v, fvec_t * tmp, uint_t post, uint_t pre,
    221     uint_t channel);
     210void fvec_adapt_thres (fvec_t * v, fvec_t * tmp, uint_t post, uint_t pre);
    222211
    223212/** returns the median of a vector
     
    232221
    233222  \param v vector to get median from
    234   \param channel channel to get median from
    235223
    236224  \return the median of v
    237225 
    238226*/
    239 smpl_t fvec_median_channel (fvec_t * v, uint_t channel);
     227smpl_t fvec_median (fvec_t * v);
    240228
    241229/** finds exact peak index by quadratic interpolation*/
    242 smpl_t fvec_quadint (fvec_t * x, uint_t pos, uint_t channel);
     230smpl_t fvec_quadint (fvec_t * x, uint_t pos);
    243231
    244232/** Quadratic interpolation using Lagrange polynomial.
  • src/onset/onset.c

    r0536612 rf658288  
    4848  smpl_t isonset = 0;
    4949  smpl_t wasonset = 0;
    50   uint_t i;
    5150  aubio_pvoc_do (o->pv,input, o->fftgrain);
    5251  aubio_specdesc_do (o->od,o->fftgrain, o->of);
    53   /*if (usedoubled) {
    54     aubio_specdesc_do (o2,fftgrain, onset2);
    55     onset->data[0][0] *= onset2->data[0][0];
    56   }*/
    5752  aubio_peakpicker_do(o->pp, o->of, onset);
    58   for (i = 0; i < input->channels; i++) {
    59   isonset = onset->data[i][0];
    60   wasonset = o->wasonset->data[i][0];
     53  isonset = onset->data[0];
     54  wasonset = o->wasonset->data[0];
    6155  if (isonset > 0.) {
    6256    if (aubio_silence_detection(input, o->silence)==1) {
     
    7468    wasonset++;
    7569  }
    76   o->wasonset->data[i][0] = wasonset;
    77   onset->data[i][0] = isonset;
    78   }
     70  o->wasonset->data[0] = wasonset;
     71  onset->data[0] = isonset;
    7972  return;
    8073}
     
    9891/* Allocate memory for an onset detection */
    9992aubio_onset_t * new_aubio_onset (char_t * onset_mode,
    100     uint_t buf_size, uint_t hop_size, uint_t channels, uint_t samplerate)
     93    uint_t buf_size, uint_t hop_size, uint_t samplerate)
    10194{
    10295  aubio_onset_t * o = AUBIO_NEW(aubio_onset_t);
     
    10598  o->minioi    = 4;
    10699  o->silence   = -70;
    107   o->wasonset  = new_fvec(1, channels);
     100  o->wasonset  = new_fvec(1);
    108101  o->samplerate = samplerate;
    109102  o->hop_size = hop_size;
    110   o->pv = new_aubio_pvoc(buf_size, hop_size, channels);
    111   o->pp = new_aubio_peakpicker(channels);
     103  o->pv = new_aubio_pvoc(buf_size, hop_size);
     104  o->pp = new_aubio_peakpicker();
    112105  aubio_peakpicker_set_threshold (o->pp, o->threshold);
    113   o->od = new_aubio_specdesc(onset_mode,buf_size,channels);
    114   o->fftgrain = new_cvec(buf_size,channels);
    115   o->of = new_fvec(1, channels);
     106  o->od = new_aubio_specdesc(onset_mode,buf_size);
     107  o->fftgrain = new_cvec(buf_size);
     108  o->of = new_fvec(1);
    116109  /*if (usedoubled)    {
    117     o2 = new_aubio_specdesc(onset_type2,buffer_size,channels);
    118     onset2 = new_fvec(1 , channels);
     110    o2 = new_aubio_specdesc(onset_type2,buffer_size);
     111    onset2 = new_fvec(1);
    119112  }*/
    120113  return o;
  • src/onset/onset.h

    r0536612 rf658288  
    5050  \param buf_size buffer size for phase vocoder
    5151  \param hop_size hop size for phase vocoder
    52   \param channels number of channels
    5352  \param samplerate sampling rate of the input signal
    5453
    5554*/
    5655aubio_onset_t * new_aubio_onset (char_t * method,
    57     uint_t buf_size, uint_t hop_size, uint_t channels, uint_t samplerate);
     56    uint_t buf_size, uint_t hop_size, uint_t samplerate);
    5857
    5958/** execute onset detection
  • src/onset/peakpicker.c

    r0536612 rf658288  
    2828
    2929/** function pointer to thresholding function */
    30 typedef smpl_t (*aubio_thresholdfn_t)(fvec_t *input, uint_t channel);
     30typedef smpl_t (*aubio_thresholdfn_t)(fvec_t *input);
    3131/** function pointer to peak-picking function */
    3232typedef uint_t (*aubio_pickerfn_t)(fvec_t *input, uint_t pos);
     
    6969  fvec_t *scratch;
    7070
    71   /** number of channels to analyse */
    72   uint_t channels;
    73 
    7471        /** \bug should be used to calculate filter coefficients */
    7572  /* cutoff: low-pass filter cutoff [0.34, 1] */
     
    9794  smpl_t mean = 0., median = 0.;
    9895  uint_t length = p->win_post + p->win_pre + 1;
    99   uint_t i, j = 0;
    100 
    101   for (i = 0; i < p->channels; i++) {
    102     /* store onset in onset_keep */
    103     /* shift all elements but last, then write last */
    104     for (j = 0; j < length - 1; j++) {
    105       onset_keep->data[i][j] = onset_keep->data[i][j + 1];
    106       onset_proc->data[i][j] = onset_keep->data[i][j];
    107     }
    108     onset_keep->data[i][length - 1] = onset->data[i][0];
    109     onset_proc->data[i][length - 1] = onset->data[i][0];
     96  uint_t j = 0;
     97
     98  /* store onset in onset_keep */
     99  /* shift all elements but last, then write last */
     100  for (j = 0; j < length - 1; j++) {
     101    onset_keep->data[j] = onset_keep->data[j + 1];
     102    onset_proc->data[j] = onset_keep->data[j];
    110103  }
     104  onset_keep->data[length - 1] = onset->data[0];
     105  onset_proc->data[length - 1] = onset->data[0];
    111106
    112107  /* filter onset_proc */
     
    114109  aubio_filter_do_filtfilt (p->biquad, onset_proc, scratch);
    115110
    116   for (i = 0; i < p->channels; i++) {
    117     /* calculate mean and median for onset_proc */
    118     mean = fvec_mean_channel (onset_proc, i);
    119     /* copy to scratch */
    120     for (j = 0; j < length; j++)
    121       scratch->data[i][j] = onset_proc->data[i][j];
    122     median = p->thresholdfn (scratch, i);
    123 
    124     /* shift peek array */
    125     for (j = 0; j < 3 - 1; j++)
    126       onset_peek->data[i][j] = onset_peek->data[i][j + 1];
    127     /* calculate new tresholded value */
    128     thresholded->data[i][0] =
    129         onset_proc->data[i][p->win_post] - median - mean * p->threshold;
    130     onset_peek->data[i][2] = thresholded->data[i][0];
    131     out->data[i][0] = (p->pickerfn) (onset_peek, 1);
    132     if (out->data[i][0]) {
    133       out->data[i][0] = fvec_quadint (onset_peek, 1, i);
    134     }
     111  /* calculate mean and median for onset_proc */
     112  mean = fvec_mean (onset_proc);
     113  /* copy to scratch */
     114  for (j = 0; j < length; j++)
     115    scratch->data[j] = onset_proc->data[j];
     116  median = p->thresholdfn (scratch);
     117
     118  /* shift peek array */
     119  for (j = 0; j < 3 - 1; j++)
     120    onset_peek->data[j] = onset_peek->data[j + 1];
     121  /* calculate new tresholded value */
     122  thresholded->data[0] =
     123      onset_proc->data[p->win_post] - median - mean * p->threshold;
     124  onset_peek->data[2] = thresholded->data[0];
     125  out->data[0] = (p->pickerfn) (onset_peek, 1);
     126  if (out->data[0]) {
     127    out->data[0] = fvec_quadint (onset_peek, 1);
    135128  }
    136129}
     
    173166
    174167aubio_peakpicker_t *
    175 new_aubio_peakpicker (uint_t channels)
     168new_aubio_peakpicker ()
    176169{
    177170  aubio_peakpicker_t *t = AUBIO_NEW (aubio_peakpicker_t);
     
    179172  t->win_post = 5;
    180173  t->win_pre = 1;
    181   //channels = 1;
    182   t->channels = channels;
    183 
    184   t->thresholdfn = (aubio_thresholdfn_t) (fvec_median_channel); /* (fvec_mean); */
     174
     175  t->thresholdfn = (aubio_thresholdfn_t) (fvec_median); /* (fvec_mean); */
    185176  t->pickerfn = (aubio_pickerfn_t) (fvec_peakpick);
    186177
    187   t->scratch = new_fvec (t->win_post + t->win_pre + 1, channels);
    188   t->onset_keep = new_fvec (t->win_post + t->win_pre + 1, channels);
    189   t->onset_proc = new_fvec (t->win_post + t->win_pre + 1, channels);
    190   t->onset_peek = new_fvec (3, channels);
    191   t->thresholded = new_fvec (1, channels);
     178  t->scratch = new_fvec (t->win_post + t->win_pre + 1);
     179  t->onset_keep = new_fvec (t->win_post + t->win_pre + 1);
     180  t->onset_proc = new_fvec (t->win_post + t->win_pre + 1);
     181  t->onset_peek = new_fvec (3);
     182  t->thresholded = new_fvec (1);
    192183
    193184  /* cutoff: low-pass filter with cutoff reduced frequency at 0.34
     
    195186   */
    196187  t->biquad = new_aubio_filter_biquad (0.15998789, 0.31997577, 0.15998789,
    197       -0.59488894, 0.23484048, channels);
     188      -0.59488894, 0.23484048);
    198189
    199190  return t;
  • src/onset/peakpicker.h

    r0536612 rf658288  
    3636
    3737/** peak-picker creation function */
    38 aubio_peakpicker_t * new_aubio_peakpicker(uint_t channels);
     38aubio_peakpicker_t * new_aubio_peakpicker(void);
    3939/** real time peak picking function */
    4040void aubio_peakpicker_do(aubio_peakpicker_t * p, fvec_t * in, fvec_t * out);
  • src/pitch/pitch.c

    r0536612 rf658288  
    114114aubio_pitch_t *
    115115new_aubio_pitch (char_t * pitch_mode,
    116     uint_t bufsize, uint_t hopsize, uint_t channels, uint_t samplerate)
     116    uint_t bufsize, uint_t hopsize, uint_t samplerate)
    117117{
    118118  aubio_pitch_t *p = AUBIO_NEW (aubio_pitch_t);
     
    142142  switch (p->type) {
    143143    case aubio_pitcht_yin:
    144       p->buf = new_fvec (bufsize, channels);
     144      p->buf = new_fvec (bufsize);
    145145      p->yin = new_aubio_pitchyin (bufsize);
    146146      p->callback = aubio_pitch_do_yin;
     
    148148      break;
    149149    case aubio_pitcht_mcomb:
    150       p->pv = new_aubio_pvoc (bufsize, hopsize, channels);
    151       p->fftgrain = new_cvec (bufsize, channels);
    152       p->mcomb = new_aubio_pitchmcomb (bufsize, hopsize, channels);
    153       p->filter = new_aubio_filter_c_weighting (samplerate, channels);
     150      p->pv = new_aubio_pvoc (bufsize, hopsize);
     151      p->fftgrain = new_cvec (bufsize);
     152      p->mcomb = new_aubio_pitchmcomb (bufsize, hopsize);
     153      p->filter = new_aubio_filter_c_weighting (samplerate);
    154154      p->callback = aubio_pitch_do_mcomb;
    155155      break;
    156156    case aubio_pitcht_fcomb:
    157       p->buf = new_fvec (bufsize, channels);
    158       p->fcomb = new_aubio_pitchfcomb (bufsize, hopsize, channels);
     157      p->buf = new_fvec (bufsize);
     158      p->fcomb = new_aubio_pitchfcomb (bufsize, hopsize);
    159159      p->callback = aubio_pitch_do_fcomb;
    160160      break;
    161161    case aubio_pitcht_schmitt:
    162       p->buf = new_fvec (bufsize, channels);
     162      p->buf = new_fvec (bufsize);
    163163      p->schmitt = new_aubio_pitchschmitt (bufsize);
    164164      p->callback = aubio_pitch_do_schmitt;
    165165      break;
    166166    case aubio_pitcht_yinfft:
    167       p->buf = new_fvec (bufsize, channels);
     167      p->buf = new_fvec (bufsize);
    168168      p->yinfft = new_aubio_pitchyinfft (bufsize);
    169169      p->callback = aubio_pitch_do_yinfft;
     
    211211aubio_pitch_slideblock (aubio_pitch_t * p, fvec_t * ibuf)
    212212{
    213   uint_t i, j = 0, overlap_size = 0;
     213  uint_t j = 0, overlap_size = 0;
    214214  overlap_size = p->buf->length - ibuf->length;
    215   for (i = 0; i < p->buf->channels; i++) {
    216     for (j = 0; j < overlap_size; j++) {
    217       p->buf->data[i][j] = p->buf->data[i][j + ibuf->length];
    218     }
    219   }
    220   for (i = 0; i < ibuf->channels; i++) {
    221     for (j = 0; j < ibuf->length; j++) {
    222       p->buf->data[i][j + overlap_size] = ibuf->data[i][j];
    223     }
     215  for (j = 0; j < overlap_size; j++) {
     216    p->buf->data[j] = p->buf->data[j + ibuf->length];
     217  }
     218  for (j = 0; j < ibuf->length; j++) {
     219    p->buf->data[j + overlap_size] = ibuf->data[j];
    224220  }
    225221}
     
    283279aubio_pitch_do (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf)
    284280{
    285   uint_t i;
    286281  p->callback (p, ibuf, obuf);
    287   for (i = 0; i < obuf->channels; i++) {
    288     p->freqconv (obuf->data[i][0], p->srate, p->bufsize);
    289   }
     282  obuf->data[0] = p->freqconv (obuf->data[0], p->srate, p->bufsize);
    290283}
    291284
     
    293286aubio_pitch_do_mcomb (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf)
    294287{
    295   uint_t i;
    296288  aubio_filter_do (p->filter, ibuf);
    297289  aubio_pvoc_do (p->pv, ibuf, p->fftgrain);
    298290  aubio_pitchmcomb_do (p->mcomb, p->fftgrain, obuf);
    299   for (i = 0; i < obuf->channels; i++) {
    300     obuf->data[i][0] = aubio_bintofreq (obuf->data[i][0], p->srate, p->bufsize);
    301   }
     291  obuf->data[0] = aubio_bintofreq (obuf->data[0], p->srate, p->bufsize);
    302292}
    303293
     
    306296{
    307297  smpl_t pitch = 0.;
    308   uint_t i;
    309298  aubio_pitch_slideblock (p, ibuf);
    310299  aubio_pitchyin_do (p->yin, p->buf, obuf);
    311   for (i = 0; i < obuf->channels; i++) {
    312     pitch = obuf->data[i][0];
    313     if (pitch > 0) {
    314       pitch = p->srate / (pitch + 0.);
    315     } else {
    316       pitch = 0.;
    317     }
    318     obuf->data[i][0] = pitch;
    319   }
     300  pitch = obuf->data[0];
     301  if (pitch > 0) {
     302    pitch = p->srate / (pitch + 0.);
     303  } else {
     304    pitch = 0.;
     305  }
     306  obuf->data[0] = pitch;
    320307}
    321308
     
    325312{
    326313  smpl_t pitch = 0.;
    327   uint_t i;
    328314  aubio_pitch_slideblock (p, ibuf);
    329315  aubio_pitchyinfft_do (p->yinfft, p->buf, obuf);
    330   for (i = 0; i < obuf->channels; i++) {
    331     pitch = obuf->data[i][0];
    332     if (pitch > 0) {
    333       pitch = p->srate / (pitch + 0.);
    334     } else {
    335       pitch = 0.;
    336     }
    337     obuf->data[i][0] = pitch;
    338   }
     316  pitch = obuf->data[0];
     317  if (pitch > 0) {
     318    pitch = p->srate / (pitch + 0.);
     319  } else {
     320    pitch = 0.;
     321  }
     322  obuf->data[0] = pitch;
    339323}
    340324
     
    342326aubio_pitch_do_fcomb (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * out)
    343327{
    344   uint_t i;
    345328  aubio_pitch_slideblock (p, ibuf);
    346329  aubio_pitchfcomb_do (p->fcomb, p->buf, out);
    347   for (i = 0; i < out->channels; i++) {
    348     out->data[i][0] = aubio_bintofreq (out->data[i][0], p->srate, p->bufsize);
    349   }
     330  out->data[0] = aubio_bintofreq (out->data[0], p->srate, p->bufsize);
    350331}
    351332
     
    354335{
    355336  smpl_t period, pitch = 0.;
    356   uint_t i;
    357337  aubio_pitch_slideblock (p, ibuf);
    358338  aubio_pitchschmitt_do (p->schmitt, p->buf, out);
    359   for (i = 0; i < out->channels; i++) {
    360     period = out->data[i][0];
    361     if (period > 0) {
    362       pitch = p->srate / period;
    363     } else {
    364       pitch = 0.;
    365     }
    366     out->data[i][0] = pitch;
    367   }
    368 }
     339  period = out->data[0];
     340  if (period > 0) {
     341    pitch = p->srate / period;
     342  } else {
     343    pitch = 0.;
     344  }
     345  out->data[0] = pitch;
     346}
  • src/pitch/pitch.h

    r0536612 rf658288  
    4141
    4242  \param o pitch detection object as returned by new_aubio_pitch()
    43   \param in input signal of size [hop_size x channels]
    44   \param out output pitch candidates of size [1 x channels]
     43  \param in input signal of size [hop_size]
     44  \param out output pitch candidates of size [1]
    4545
    4646*/
     
    6767  \param buf_size size of the input buffer to analyse
    6868  \param hop_size step size between two consecutive analysis instant
    69   \param channels number of channels to analyse
    7069  \param samplerate sampling rate of the signal
    7170
    7271*/
    7372aubio_pitch_t *new_aubio_pitch (char_t * method,
    74     uint_t buf_size, uint_t hop_size, uint_t channels, uint_t samplerate);
     73    uint_t buf_size, uint_t hop_size, uint_t samplerate);
    7574
    7675/** set the output unit of the pitch detection object
  • src/pitch/pitchfcomb.c

    r0536612 rf658288  
    4949
    5050aubio_pitchfcomb_t *
    51 new_aubio_pitchfcomb (uint_t bufsize, uint_t hopsize, uint_t channels)
     51new_aubio_pitchfcomb (uint_t bufsize, uint_t hopsize)
    5252{
    5353  aubio_pitchfcomb_t *p = AUBIO_NEW (aubio_pitchfcomb_t);
    5454  p->fftSize = bufsize;
    5555  p->stepSize = hopsize;
    56   p->winput = new_fvec (bufsize, 1);
    57   p->fftOut = new_cvec (bufsize, 1);
    58   p->fftLastPhase = new_fvec (bufsize, channels);
    59   p->fft = new_aubio_fft (bufsize, 1);
     56  p->winput = new_fvec (bufsize);
     57  p->fftOut = new_cvec (bufsize);
     58  p->fftLastPhase = new_fvec (bufsize);
     59  p->fft = new_aubio_fft (bufsize);
    6060  p->win = new_aubio_window ("hanning", bufsize);
    6161  return p;
     
    6666aubio_pitchfcomb_do (aubio_pitchfcomb_t * p, fvec_t * input, fvec_t * output)
    6767{
    68   uint_t i, k, l, maxharm = 0;
     68  uint_t k, l, maxharm = 0;
    6969  smpl_t phaseDifference = TWO_PI * (smpl_t) p->stepSize / (smpl_t) p->fftSize;
    7070  aubio_fpeak_t peaks[MAX_PEAKS];
    7171
    72   for (i = 0; i < input->channels; i++) {
     72  for (k = 0; k < MAX_PEAKS; k++) {
     73    peaks[k].db = -200.;
     74    peaks[k].bin = 0.;
     75  }
    7376
    74     for (k = 0; k < MAX_PEAKS; k++) {
    75       peaks[k].db = -200.;
    76       peaks[k].bin = 0.;
     77  for (k = 0; k < input->length; k++) {
     78    p->winput->data[k] = p->win->data[k] * input->data[k];
     79  }
     80  aubio_fft_do (p->fft, p->winput, p->fftOut);
     81
     82  for (k = 0; k <= p->fftSize / 2; k++) {
     83    smpl_t
     84        magnitude =
     85        20. * LOG10 (2. * p->fftOut->norm[k] / (smpl_t) p->fftSize),
     86        phase = p->fftOut->phas[k], tmp, bin;
     87
     88    /* compute phase difference */
     89    tmp = phase - p->fftLastPhase->data[k];
     90    p->fftLastPhase->data[k] = phase;
     91
     92    /* subtract expected phase difference */
     93    tmp -= (smpl_t) k *phaseDifference;
     94
     95    /* map delta phase into +/- Pi interval */
     96    tmp = aubio_unwrap2pi (tmp);
     97
     98    /* get deviation from bin frequency from the +/- Pi interval */
     99    tmp = p->fftSize / (smpl_t) p->stepSize * tmp / (TWO_PI);
     100
     101    /* compute the k-th partials' true bin */
     102    bin = (smpl_t) k + tmp;
     103
     104    if (bin > 0.0 && magnitude > peaks[0].db) {       // && magnitude < 0) {
     105      memmove (peaks + 1, peaks, sizeof (aubio_fpeak_t) * (MAX_PEAKS - 1));
     106      peaks[0].bin = bin;
     107      peaks[0].db = magnitude;
    77108    }
     109  }
    78110
    79     for (k = 0; k < input->length; k++) {
    80       p->winput->data[0][k] = p->win->data[0][k] * input->data[i][k];
    81     }
    82     aubio_fft_do (p->fft, p->winput, p->fftOut);
    83 
    84     for (k = 0; k <= p->fftSize / 2; k++) {
    85       smpl_t
    86           magnitude =
    87           20. * LOG10 (2. * p->fftOut->norm[0][k] / (smpl_t) p->fftSize),
    88           phase = p->fftOut->phas[0][k], tmp, bin;
    89 
    90       /* compute phase difference */
    91       tmp = phase - p->fftLastPhase->data[i][k];
    92       p->fftLastPhase->data[i][k] = phase;
    93 
    94       /* subtract expected phase difference */
    95       tmp -= (smpl_t) k *phaseDifference;
    96 
    97       /* map delta phase into +/- Pi interval */
    98       tmp = aubio_unwrap2pi (tmp);
    99 
    100       /* get deviation from bin frequency from the +/- Pi interval */
    101       tmp = p->fftSize / (smpl_t) p->stepSize * tmp / (TWO_PI);
    102 
    103       /* compute the k-th partials' true bin */
    104       bin = (smpl_t) k + tmp;
    105 
    106       if (bin > 0.0 && magnitude > peaks[0].db) {       // && magnitude < 0) {
    107         memmove (peaks + 1, peaks, sizeof (aubio_fpeak_t) * (MAX_PEAKS - 1));
    108         peaks[0].bin = bin;
    109         peaks[0].db = magnitude;
    110       }
    111     }
    112 
    113     k = 0;
    114     for (l = 1; l < MAX_PEAKS && peaks[l].bin > 0.0; l++) {
    115       sint_t harmonic;
    116       for (harmonic = 5; harmonic > 1; harmonic--) {
    117         if (peaks[0].bin / peaks[l].bin < harmonic + .02 &&
    118             peaks[0].bin / peaks[l].bin > harmonic - .02) {
    119           if (harmonic > (sint_t) maxharm && peaks[0].db < peaks[l].db / 2) {
    120             maxharm = harmonic;
    121             k = l;
    122           }
     111  k = 0;
     112  for (l = 1; l < MAX_PEAKS && peaks[l].bin > 0.0; l++) {
     113    sint_t harmonic;
     114    for (harmonic = 5; harmonic > 1; harmonic--) {
     115      if (peaks[0].bin / peaks[l].bin < harmonic + .02 &&
     116          peaks[0].bin / peaks[l].bin > harmonic - .02) {
     117        if (harmonic > (sint_t) maxharm && peaks[0].db < peaks[l].db / 2) {
     118          maxharm = harmonic;
     119          k = l;
    123120        }
    124121      }
    125122    }
    126     output->data[i][0] = peaks[k].bin;
    127     /* quick hack to clean output a bit */
    128     if (peaks[k].bin > 5000.)
    129       output->data[i][0] = 0.;
    130123  }
     124  output->data[0] = peaks[k].bin;
     125  /* quick hack to clean output a bit */
     126  if (peaks[k].bin > 5000.)
     127    output->data[0] = 0.;
    131128}
    132129
  • src/pitch/pitchfcomb.h

    r0536612 rf658288  
    5757  \param buf_size size of the input buffer to analyse
    5858  \param hop_size step size between two consecutive analysis instant
    59   \param channels number of channels to detect pitch on
    6059 
    6160*/
    62 aubio_pitchfcomb_t *new_aubio_pitchfcomb (uint_t buf_size, uint_t hop_size,
    63     uint_t channels);
     61aubio_pitchfcomb_t *new_aubio_pitchfcomb (uint_t buf_size, uint_t hop_size);
    6462
    6563/** deletion of the pitch detection object
  • src/pitch/pitchmcomb.c

    r0536612 rf658288  
    104104aubio_pitchmcomb_do (aubio_pitchmcomb_t * p, cvec_t * fftgrain, fvec_t * output)
    105105{
    106   uint_t i, j;
     106  uint_t j;
    107107  smpl_t instfreq;
    108108  fvec_t *newmag = (fvec_t *) p->newmag;
    109109  //smpl_t hfc; //fe=instfreq(theta1,theta,ops); //theta1=theta;
    110110  /* copy incoming grain to newmag */
    111   for (i = 0; i < fftgrain->channels; i++) {
    112     for (j = 0; j < newmag->length; j++)
    113       newmag->data[0][j] = fftgrain->norm[i][j];
    114     /* detect only if local energy > 10. */
    115     //if (fvec_local_energy(newmag)>10.) {
    116     //hfc = fvec_local_hfc(newmag); //not used
    117     aubio_pitchmcomb_spectral_pp (p, newmag);
    118     aubio_pitchmcomb_combdet (p, newmag);
    119     //aubio_pitchmcomb_sort_cand_freq(p->candidates,p->ncand);
    120     //return p->candidates[p->goodcandidate]->ebin;
    121     j = (uint_t) FLOOR (p->candidates[p->goodcandidate]->ebin + .5);
    122     instfreq = aubio_unwrap2pi (fftgrain->phas[i][j]
    123         - p->theta->data[i][j] - j * p->phasediff);
    124     instfreq *= p->phasefreq;
    125     /* store phase for next run */
    126     for (j = 0; j < p->theta->length; j++) {
    127       p->theta->data[i][j] = fftgrain->phas[i][j];
    128     }
    129     //return p->candidates[p->goodcandidate]->ebin;
    130     output->data[i][0] =
    131         FLOOR (p->candidates[p->goodcandidate]->ebin + .5) + instfreq;
    132     /*} else {
    133        return -1.;
    134        } */
    135   }
     111  for (j = 0; j < newmag->length; j++)
     112    newmag->data[j] = fftgrain->norm[j];
     113  /* detect only if local energy > 10. */
     114  //if (fvec_local_energy(newmag)>10.) {
     115  //hfc = fvec_local_hfc(newmag); //not used
     116  aubio_pitchmcomb_spectral_pp (p, newmag);
     117  aubio_pitchmcomb_combdet (p, newmag);
     118  //aubio_pitchmcomb_sort_cand_freq(p->candidates,p->ncand);
     119  //return p->candidates[p->goodcandidate]->ebin;
     120  j = (uint_t) FLOOR (p->candidates[p->goodcandidate]->ebin + .5);
     121  instfreq = aubio_unwrap2pi (fftgrain->phas[j]
     122      - p->theta->data[j] - j * p->phasediff);
     123  instfreq *= p->phasefreq;
     124  /* store phase for next run */
     125  for (j = 0; j < p->theta->length; j++) {
     126    p->theta->data[j] = fftgrain->phas[j];
     127  }
     128  //return p->candidates[p->goodcandidate]->ebin;
     129  output->data[0] =
     130      FLOOR (p->candidates[p->goodcandidate]->ebin + .5) + instfreq;
     131  /*} else {
     132     return -1.;
     133     } */
    136134}
    137135
     
    139137aubio_pitch_cands (aubio_pitchmcomb_t * p, cvec_t * fftgrain, smpl_t * cands)
    140138{
    141   uint_t i = 0, j;
     139  uint_t j;
    142140  uint_t k;
    143141  fvec_t *newmag = (fvec_t *) p->newmag;
     
    147145  /* copy incoming grain to newmag */
    148146  for (j = 0; j < newmag->length; j++)
    149     newmag->data[i][j] = fftgrain->norm[i][j];
     147    newmag->data[j] = fftgrain->norm[j];
    150148  /* detect only if local energy > 10. */
    151149  if (fvec_local_energy (newmag) > 10.) {
     
    172170  fvec_t *mag = (fvec_t *) p->scratch;
    173171  fvec_t *tmp = (fvec_t *) p->scratch2;
    174   uint_t i = 0, j;
     172  uint_t j;
    175173  uint_t length = mag->length;
    176174  /* copy newmag to mag (scracth) */
    177175  for (j = 0; j < length; j++) {
    178     mag->data[i][j] = newmag->data[i][j];
     176    mag->data[j] = newmag->data[j];
    179177  }
    180178  fvec_min_removal (mag);       /* min removal          */
     
    182180  /* skipped *//* low pass filtering   */
    183181  /** \bug fvec_moving_thres may write out of bounds */
    184   fvec_adapt_thres (mag, tmp, p->win_post, p->win_pre, i);      /* adaptative threshold */
     182  fvec_adapt_thres (mag, tmp, p->win_post, p->win_pre);      /* adaptative threshold */
    185183  fvec_add (mag, -p->threshold);        /* fixed threshold      */
    186184  {
     
    190188    count = aubio_pitchmcomb_quadpick (peaks, mag);
    191189    for (j = 0; j < count; j++)
    192       peaks[j].mag = newmag->data[i][peaks[j].bin];
     190      peaks[j].mag = newmag->data[peaks[j].bin];
    193191    /* reset non peaks */
    194192    for (j = count; j < length; j++)
     
    261259        candidate[l]->ecomb[k] = peaks[position].ebin;
    262260        candidate[l]->ene +=    /* ecomb rounded to nearest int */
    263             POW (newmag->data[0][(uint_t) FLOOR (candidate[l]->ecomb[k] + .5)],
     261            POW (newmag->data[(uint_t) FLOOR (candidate[l]->ecomb[k] + .5)],
    264262            0.25);
    265263        candidate[l]->len += 1. / curlen;
     
    290288aubio_pitchmcomb_quadpick (aubio_spectralpeak_t * spectral_peaks, fvec_t * X)
    291289{
    292   uint_t i, j, ispeak, count = 0;
    293   for (i = 0; i < X->channels; i++)
    294     for (j = 1; j < X->length - 1; j++) {
    295       ispeak = fvec_peakpick (X, j);
    296       if (ispeak) {
    297         count += ispeak;
    298         spectral_peaks[count - 1].bin = j;
    299         spectral_peaks[count - 1].ebin = fvec_quadint (X, j, i) - 1.;
    300       }
    301     }
     290  uint_t j, ispeak, count = 0;
     291  for (j = 1; j < X->length - 1; j++) {
     292    ispeak = fvec_peakpick (X, j);
     293    if (ispeak) {
     294      count += ispeak;
     295      spectral_peaks[count - 1].bin = j;
     296      spectral_peaks[count - 1].ebin = fvec_quadint (X, j) - 1.;
     297    }
     298  }
    302299  return count;
    303300}
     
    364361
    365362aubio_pitchmcomb_t *
    366 new_aubio_pitchmcomb (uint_t bufsize, uint_t hopsize, uint_t channels)
     363new_aubio_pitchmcomb (uint_t bufsize, uint_t hopsize)
    367364{
    368365  aubio_pitchmcomb_t *p = AUBIO_NEW (aubio_pitchmcomb_t);
     
    386383  //p->biquad = new_biquad(0.1600,0.3200,0.1600, -0.5949, 0.2348);
    387384  /* allocate temp memory */
    388   p->newmag = new_fvec (spec_size, 1);
     385  p->newmag = new_fvec (spec_size);
    389386  /* array for median */
    390   p->scratch = new_fvec (spec_size, 1);
     387  p->scratch = new_fvec (spec_size);
    391388  /* array for phase */
    392   p->theta = new_fvec (spec_size, channels);
     389  p->theta = new_fvec (spec_size);
    393390  /* array for adaptative threshold */
    394   p->scratch2 = new_fvec (p->win_post + p->win_pre + 1, 1);
     391  p->scratch2 = new_fvec (p->win_post + p->win_pre + 1);
    395392  /* array of spectral peaks */
    396393  p->peaks = AUBIO_ARRAY (aubio_spectralpeak_t, spec_size);
  • src/pitch/pitchmcomb.h

    r0536612 rf658288  
    5757  \param buf_size size of the input buffer to analyse
    5858  \param hop_size step size between two consecutive analysis instant
    59   \param channels number of channels to analyse
    6059  \param samplerate sampling rate of the signal
    6160 
    6261*/
    63 aubio_pitchmcomb_t *new_aubio_pitchmcomb (uint_t buf_size, uint_t hop_size,
    64     uint_t channels);
     62aubio_pitchmcomb_t *new_aubio_pitchmcomb (uint_t buf_size, uint_t hop_size);
    6563
    6664/** deletion of the pitch detection object
  • src/pitch/pitchschmitt.c

    r0536612 rf658288  
    5151    fvec_t * output)
    5252{
    53   uint_t i, j;
    54   for (i = 0; i < input->channels; i++) {
    55     for (j = 0; j < input->length; j++) {
    56       p->buf[j] = input->data[i][j] * 32768.;
    57     }
    58     output->data[i][0] = aubio_schmittS16LE (p, input->length, p->buf);
     53  uint_t j;
     54  for (j = 0; j < input->length; j++) {
     55    p->buf[j] = input->data[j] * 32768.;
    5956  }
     57  output->data[0] = aubio_schmittS16LE (p, input->length, p->buf);
    6058}
    6159
  • src/pitch/pitchyin.c

    r0536612 rf658288  
    6565{
    6666  aubio_pitchyin_t *o = AUBIO_NEW (aubio_pitchyin_t);
    67   o->yin = new_fvec (bufsize / 2, 1);
     67  o->yin = new_fvec (bufsize / 2);
    6868  o->tol = 0.15;
    6969  return o;
     
    8181aubio_pitchyin_diff (fvec_t * input, fvec_t * yin)
    8282{
    83   uint_t c, j, tau;
     83  uint_t j, tau;
    8484  smpl_t tmp;
    85   for (c = 0; c < input->channels; c++) {
    86     for (tau = 0; tau < yin->length; tau++) {
    87       yin->data[c][tau] = 0.;
    88     }
    89     for (tau = 1; tau < yin->length; tau++) {
    90       for (j = 0; j < yin->length; j++) {
    91         tmp = input->data[c][j] - input->data[c][j + tau];
    92         yin->data[c][tau] += SQR (tmp);
    93       }
     85  for (tau = 0; tau < yin->length; tau++) {
     86    yin->data[tau] = 0.;
     87  }
     88  for (tau = 1; tau < yin->length; tau++) {
     89    for (j = 0; j < yin->length; j++) {
     90      tmp = input->data[j] - input->data[j + tau];
     91      yin->data[tau] += SQR (tmp);
    9492    }
    9593  }
     
    10098aubio_pitchyin_getcum (fvec_t * yin)
    10199{
    102   uint_t c, tau;
     100  uint_t tau;
    103101  smpl_t tmp;
    104   for (c = 0; c < yin->channels; c++) {
    105     tmp = 0.;
    106     yin->data[c][0] = 1.;
    107     //AUBIO_DBG("%f\t",yin->data[c][0]);
    108     for (tau = 1; tau < yin->length; tau++) {
    109       tmp += yin->data[c][tau];
    110       yin->data[c][tau] *= tau / tmp;
    111       //AUBIO_DBG("%f\t",yin->data[c][tau]);
    112     }
    113     //AUBIO_DBG("\n");
     102  tmp = 0.;
     103  yin->data[0] = 1.;
     104  //AUBIO_DBG("%f\t",yin->data[0]);
     105  for (tau = 1; tau < yin->length; tau++) {
     106    tmp += yin->data[tau];
     107    yin->data[tau] *= tau / tmp;
     108    //AUBIO_DBG("%f\t",yin->data[tau]);
    114109  }
     110  //AUBIO_DBG("\n");
    115111}
    116112
     
    118114aubio_pitchyin_getpitch (fvec_t * yin)
    119115{
    120   uint_t c = 0, tau = 1;
     116  uint_t tau = 1;
    121117  do {
    122     if (yin->data[c][tau] < 0.1) {
    123       while (yin->data[c][tau + 1] < yin->data[c][tau]) {
     118    if (yin->data[tau] < 0.1) {
     119      while (yin->data[tau + 1] < yin->data[tau]) {
    124120        tau++;
    125121      }
     
    139135  smpl_t tol = o->tol;
    140136  fvec_t *yin = o->yin;
    141   uint_t c, j, tau = 0;
     137  uint_t j, tau = 0;
    142138  sint_t period;
    143139  smpl_t tmp = 0., tmp2 = 0.;
    144   for (c = 0; c < input->channels; c++) {
    145     yin->data[c][0] = 1.;
    146     for (tau = 1; tau < yin->length; tau++) {
    147       yin->data[c][tau] = 0.;
    148       for (j = 0; j < yin->length; j++) {
    149         tmp = input->data[c][j] - input->data[c][j + tau];
    150         yin->data[c][tau] += SQR (tmp);
    151       }
    152       tmp2 += yin->data[c][tau];
    153       yin->data[c][tau] *= tau / tmp2;
    154       period = tau - 3;
    155       if (tau > 4 && (yin->data[c][period] < tol) &&
    156           (yin->data[c][period] < yin->data[c][period + 1])) {
    157         out->data[c][0] = fvec_quadint (yin, period, c);
    158         goto beach;
    159       }
     140  yin->data[0] = 1.;
     141  for (tau = 1; tau < yin->length; tau++) {
     142    yin->data[tau] = 0.;
     143    for (j = 0; j < yin->length; j++) {
     144      tmp = input->data[j] - input->data[j + tau];
     145      yin->data[tau] += SQR (tmp);
    160146    }
    161     out->data[c][0] = fvec_quadint (yin, fvec_min_elem (yin), c);
    162   beach:
    163     continue;
     147    tmp2 += yin->data[tau];
     148    yin->data[tau] *= tau / tmp2;
     149    period = tau - 3;
     150    if (tau > 4 && (yin->data[period] < tol) &&
     151        (yin->data[period] < yin->data[period + 1])) {
     152      out->data[0] = fvec_quadint (yin, period);
     153      goto beach;
     154    }
    164155  }
    165   //return 0;
     156  out->data[0] = fvec_quadint (yin, fvec_min_elem (yin));
     157beach:
     158  return;
    166159}
    167160
  • src/pitch/pitchyinfft.c

    r0536612 rf658288  
    5656{
    5757  aubio_pitchyinfft_t *p = AUBIO_NEW (aubio_pitchyinfft_t);
    58   p->winput = new_fvec (bufsize, 1);
    59   p->fft = new_aubio_fft (bufsize, 1);
    60   p->fftout = new_cvec (bufsize, 1);
    61   p->sqrmag = new_fvec (bufsize, 1);
    62   p->res = new_cvec (bufsize, 1);
    63   p->yinfft = new_fvec (bufsize / 2 + 1, 1);
     58  p->winput = new_fvec (bufsize);
     59  p->fft = new_aubio_fft (bufsize);
     60  p->fftout = new_cvec (bufsize);
     61  p->sqrmag = new_fvec (bufsize);
     62  p->res = new_cvec (bufsize);
     63  p->yinfft = new_fvec (bufsize / 2 + 1);
    6464  p->tol = 0.85;
    6565  p->win = new_aubio_window ("hanningz", bufsize);
    66   p->weight = new_fvec (bufsize / 2 + 1, 1);
    67   {
    68     uint_t i = 0, j = 1;
    69     smpl_t freq = 0, a0 = 0, a1 = 0, f0 = 0, f1 = 0;
    70     for (i = 0; i < p->weight->length; i++) {
    71       freq = (smpl_t) i / (smpl_t) bufsize *(smpl_t) 44100.;
    72       while (freq > freqs[j]) {
    73         j += 1;
    74       }
    75       a0 = weight[j - 1];
    76       f0 = freqs[j - 1];
    77       a1 = weight[j];
    78       f1 = freqs[j];
    79       if (f0 == f1) {           // just in case
    80         p->weight->data[0][i] = a0;
    81       } else if (f0 == 0) {     // y = ax+b
    82         p->weight->data[0][i] = (a1 - a0) / f1 * freq + a0;
    83       } else {
    84         p->weight->data[0][i] = (a1 - a0) / (f1 - f0) * freq +
    85             (a0 - (a1 - a0) / (f1 / f0 - 1.));
    86       }
    87       while (freq > freqs[j]) {
    88         j += 1;
    89       }
    90       //AUBIO_DBG("%f\n",p->weight->data[0][i]);
    91       p->weight->data[0][i] = DB2LIN (p->weight->data[0][i]);
    92       //p->weight->data[0][i] = SQRT(DB2LIN(p->weight->data[0][i]));
     66  p->weight = new_fvec (bufsize / 2 + 1);
     67  uint_t i = 0, j = 1;
     68  smpl_t freq = 0, a0 = 0, a1 = 0, f0 = 0, f1 = 0;
     69  for (i = 0; i < p->weight->length; i++) {
     70    freq = (smpl_t) i / (smpl_t) bufsize *(smpl_t) 44100.;
     71    while (freq > freqs[j]) {
     72      j += 1;
    9373    }
     74    a0 = weight[j - 1];
     75    f0 = freqs[j - 1];
     76    a1 = weight[j];
     77    f1 = freqs[j];
     78    if (f0 == f1) {           // just in case
     79      p->weight->data[i] = a0;
     80    } else if (f0 == 0) {     // y = ax+b
     81      p->weight->data[i] = (a1 - a0) / f1 * freq + a0;
     82    } else {
     83      p->weight->data[i] = (a1 - a0) / (f1 - f0) * freq +
     84          (a0 - (a1 - a0) / (f1 / f0 - 1.));
     85    }
     86    while (freq > freqs[j]) {
     87      j += 1;
     88    }
     89    //AUBIO_DBG("%f\n",p->weight->data[i]);
     90    p->weight->data[i] = DB2LIN (p->weight->data[i]);
     91    //p->weight->data[i] = SQRT(DB2LIN(p->weight->data[i]));
    9492  }
    9593  return p;
     
    9997aubio_pitchyinfft_do (aubio_pitchyinfft_t * p, fvec_t * input, fvec_t * output)
    10098{
    101   uint_t i, tau, l;
     99  uint_t tau, l;
    102100  uint_t halfperiod;
    103101  smpl_t tmp, sum;
    104102  cvec_t *res = (cvec_t *) p->res;
    105103  fvec_t *yin = (fvec_t *) p->yinfft;
    106   for (i = 0; i < input->channels; i++) {
    107     l = 0;
    108     tmp = 0.;
    109     sum = 0.;
    110     for (l = 0; l < input->length; l++) {
    111       p->winput->data[0][l] = p->win->data[0][l] * input->data[i][l];
     104  l = 0;
     105  tmp = 0.;
     106  sum = 0.;
     107  for (l = 0; l < input->length; l++) {
     108    p->winput->data[l] = p->win->data[l] * input->data[l];
     109  }
     110  aubio_fft_do (p->fft, p->winput, p->fftout);
     111  for (l = 0; l < p->fftout->length; l++) {
     112    p->sqrmag->data[l] = SQR (p->fftout->norm[l]);
     113    p->sqrmag->data[l] *= p->weight->data[l];
     114  }
     115  for (l = 1; l < p->fftout->length; l++) {
     116    p->sqrmag->data[(p->fftout->length - 1) * 2 - l] =
     117        SQR (p->fftout->norm[l]);
     118    p->sqrmag->data[(p->fftout->length - 1) * 2 - l] *=
     119        p->weight->data[l];
     120  }
     121  for (l = 0; l < p->sqrmag->length / 2 + 1; l++) {
     122    sum += p->sqrmag->data[l];
     123  }
     124  sum *= 2.;
     125  aubio_fft_do (p->fft, p->sqrmag, res);
     126  yin->data[0] = 1.;
     127  for (tau = 1; tau < yin->length; tau++) {
     128    yin->data[tau] = sum - res->norm[tau] * COS (res->phas[tau]);
     129    tmp += yin->data[tau];
     130    yin->data[tau] *= tau / tmp;
     131  }
     132  tau = fvec_min_elem (yin);
     133  if (yin->data[tau] < p->tol) {
     134    /* no interpolation */
     135    //return tau;
     136    /* 3 point quadratic interpolation */
     137    //return fvec_quadint_min(yin,tau,1);
     138    /* additional check for (unlikely) octave doubling in higher frequencies */
     139    if (tau > 35) {
     140      output->data[0] = fvec_quadint (yin, tau);
     141    } else {
     142      /* should compare the minimum value of each interpolated peaks */
     143      halfperiod = FLOOR (tau / 2 + .5);
     144      if (yin->data[halfperiod] < p->tol)
     145        output->data[0] = fvec_quadint (yin, halfperiod);
     146      else
     147        output->data[0] = fvec_quadint (yin, tau);
    112148    }
    113     aubio_fft_do (p->fft, p->winput, p->fftout);
    114     for (l = 0; l < p->fftout->length; l++) {
    115       p->sqrmag->data[0][l] = SQR (p->fftout->norm[0][l]);
    116       p->sqrmag->data[0][l] *= p->weight->data[0][l];
    117     }
    118     for (l = 1; l < p->fftout->length; l++) {
    119       p->sqrmag->data[0][(p->fftout->length - 1) * 2 - l] =
    120           SQR (p->fftout->norm[0][l]);
    121       p->sqrmag->data[0][(p->fftout->length - 1) * 2 - l] *=
    122           p->weight->data[0][l];
    123     }
    124     for (l = 0; l < p->sqrmag->length / 2 + 1; l++) {
    125       sum += p->sqrmag->data[0][l];
    126     }
    127     sum *= 2.;
    128     aubio_fft_do (p->fft, p->sqrmag, res);
    129     yin->data[0][0] = 1.;
    130     for (tau = 1; tau < yin->length; tau++) {
    131       yin->data[0][tau] = sum - res->norm[0][tau] * COS (res->phas[0][tau]);
    132       tmp += yin->data[0][tau];
    133       yin->data[0][tau] *= tau / tmp;
    134     }
    135     tau = fvec_min_elem (yin);
    136     if (yin->data[0][tau] < p->tol) {
    137       /* no interpolation */
    138       //return tau;
    139       /* 3 point quadratic interpolation */
    140       //return fvec_quadint_min(yin,tau,1);
    141       /* additional check for (unlikely) octave doubling in higher frequencies */
    142       if (tau > 35) {
    143         output->data[i][0] = fvec_quadint (yin, tau, i);
    144       } else {
    145         /* should compare the minimum value of each interpolated peaks */
    146         halfperiod = FLOOR (tau / 2 + .5);
    147         if (yin->data[0][halfperiod] < p->tol)
    148           output->data[i][0] = fvec_quadint (yin, halfperiod, i);
    149         else
    150           output->data[i][0] = fvec_quadint (yin, tau, i);
    151       }
    152     } else {
    153       output->data[i][0] = 0.;
    154     }
     149  } else {
     150    output->data[0] = 0.;
    155151  }
    156152}
  • src/spectral/fft.c

    r0536612 rf658288  
    7575struct _aubio_fft_t {
    7676  uint_t winsize;
    77   uint_t channels;
    7877  uint_t fft_size;
    7978  real_t *in, *out;
     
    8382};
    8483
    85 aubio_fft_t * new_aubio_fft(uint_t winsize, uint_t channels) {
     84aubio_fft_t * new_aubio_fft(uint_t winsize) {
    8685  aubio_fft_t * s = AUBIO_NEW(aubio_fft_t);
    8786  uint_t i;
    8887  s->winsize  = winsize;
    89   s->channels = channels;
    9088  /* allocate memory */
    9189  s->in       = AUBIO_ARRAY(real_t,winsize);
    9290  s->out      = AUBIO_ARRAY(real_t,winsize);
    93   s->compspec = new_fvec(winsize,channels);
     91  s->compspec = new_fvec(winsize);
    9492  /* create plans */
    9593#ifdef HAVE_COMPLEX_H
     
    136134
    137135void aubio_fft_do_complex(aubio_fft_t * s, fvec_t * input, fvec_t * compspec) {
    138   uint_t i, j;
    139   for (i = 0; i < s->channels; i++) {
    140     for (j=0; j < s->winsize; j++) {
    141       s->in[j] = input->data[i][j];
    142     }
    143     fftw_execute(s->pfw);
    144 #ifdef HAVE_COMPLEX_H
    145     compspec->data[i][0] = REAL(s->specdata[0]);
    146     for (j = 1; j < s->fft_size -1 ; j++) {
    147       compspec->data[i][j] = REAL(s->specdata[j]);
    148       compspec->data[i][compspec->length - j] = IMAG(s->specdata[j]);
    149     }
    150     compspec->data[i][s->fft_size-1] = REAL(s->specdata[s->fft_size-1]);
    151 #else
    152     for (j = 0; j < s->fft_size; j++) {
    153       compspec->data[i][j] = s->specdata[j];
    154     }
    155 #endif
    156   }
     136  uint_t j;
     137  for (j=0; j < s->winsize; j++) {
     138    s->in[j] = input->data[j];
     139  }
     140  fftw_execute(s->pfw);
     141#ifdef HAVE_COMPLEX_H
     142  compspec->data[0] = REAL(s->specdata[0]);
     143  for (j = 1; j < s->fft_size -1 ; j++) {
     144    compspec->data[j] = REAL(s->specdata[j]);
     145    compspec->data[compspec->length - j] = IMAG(s->specdata[j]);
     146  }
     147  compspec->data[s->fft_size-1] = REAL(s->specdata[s->fft_size-1]);
     148#else
     149  for (j = 0; j < s->fft_size; j++) {
     150    compspec->data[j] = s->specdata[j];
     151  }
     152#endif
    157153}
    158154
    159155void aubio_fft_rdo_complex(aubio_fft_t * s, fvec_t * compspec, fvec_t * output) {
    160   uint_t i, j;
     156  uint_t j;
    161157  const smpl_t renorm = 1./(smpl_t)s->winsize;
    162   for (i = 0; i < compspec->channels; i++) {
    163 #ifdef HAVE_COMPLEX_H
    164     s->specdata[0] = compspec->data[i][0];
    165     for (j=1; j < s->fft_size - 1; j++) {
    166       s->specdata[j] = compspec->data[i][j] +
    167         I * compspec->data[i][compspec->length - j];
    168     }
    169     s->specdata[s->fft_size - 1] = compspec->data[i][s->fft_size - 1];
    170 #else
    171     for (j=0; j < s->fft_size; j++) {
    172       s->specdata[j] = compspec->data[i][j];
    173     }
    174 #endif
    175     fftw_execute(s->pbw);
    176     for (j = 0; j < output->length; j++) {
    177       output->data[i][j] = s->out[j]*renorm;
    178     }
     158#ifdef HAVE_COMPLEX_H
     159  s->specdata[0] = compspec->data[0];
     160  for (j=1; j < s->fft_size - 1; j++) {
     161    s->specdata[j] = compspec->data[j] +
     162      I * compspec->data[compspec->length - j];
     163  }
     164  s->specdata[s->fft_size - 1] = compspec->data[s->fft_size - 1];
     165#else
     166  for (j=0; j < s->fft_size; j++) {
     167    s->specdata[j] = compspec->data[j];
     168  }
     169#endif
     170  fftw_execute(s->pbw);
     171  for (j = 0; j < output->length; j++) {
     172    output->data[j] = s->out[j]*renorm;
    179173  }
    180174}
     
    191185
    192186void aubio_fft_get_phas(fvec_t * compspec, cvec_t * spectrum) {
    193   uint_t i, j;
    194   for (i = 0; i < spectrum->channels; i++) {
    195     if (compspec->data[i][0] < 0) {
    196       spectrum->phas[i][0] = PI;
    197     } else {
    198       spectrum->phas[i][0] = 0.;
    199     }
    200     for (j=1; j < spectrum->length - 1; j++) {
    201       spectrum->phas[i][j] = ATAN2(compspec->data[i][compspec->length-j],
    202           compspec->data[i][j]);
    203     }
    204     if (compspec->data[i][compspec->length/2] < 0) {
    205       spectrum->phas[i][spectrum->length - 1] = PI;
    206     } else {
    207       spectrum->phas[i][spectrum->length - 1] = 0.;
    208     }
     187  uint_t j;
     188  if (compspec->data[0] < 0) {
     189    spectrum->phas[0] = PI;
     190  } else {
     191    spectrum->phas[0] = 0.;
     192  }
     193  for (j=1; j < spectrum->length - 1; j++) {
     194    spectrum->phas[j] = ATAN2(compspec->data[compspec->length-j],
     195        compspec->data[j]);
     196  }
     197  if (compspec->data[compspec->length/2] < 0) {
     198    spectrum->phas[spectrum->length - 1] = PI;
     199  } else {
     200    spectrum->phas[spectrum->length - 1] = 0.;
    209201  }
    210202}
    211203
    212204void aubio_fft_get_norm(fvec_t * compspec, cvec_t * spectrum) {
    213   uint_t i, j = 0;
    214   for (i = 0; i < spectrum->channels; i++) {
    215     spectrum->norm[i][0] = ABS(compspec->data[i][0]);
    216     for (j=1; j < spectrum->length - 1; j++) {
    217       spectrum->norm[i][j] = SQRT(SQR(compspec->data[i][j])
    218           + SQR(compspec->data[i][compspec->length - j]) );
    219     }
    220     spectrum->norm[i][spectrum->length-1] =
    221       ABS(compspec->data[i][compspec->length/2]);
    222   }
     205  uint_t j = 0;
     206  spectrum->norm[0] = ABS(compspec->data[0]);
     207  for (j=1; j < spectrum->length - 1; j++) {
     208    spectrum->norm[j] = SQRT(SQR(compspec->data[j])
     209        + SQR(compspec->data[compspec->length - j]) );
     210  }
     211  spectrum->norm[spectrum->length-1] =
     212    ABS(compspec->data[compspec->length/2]);
    223213}
    224214
    225215void aubio_fft_get_imag(cvec_t * spectrum, fvec_t * compspec) {
    226   uint_t i, j;
    227   for (i = 0; i < compspec->channels; i++) {
    228     for (j = 1; j < ( compspec->length + 1 ) / 2 /*- 1 + 1*/; j++) {
    229       compspec->data[i][compspec->length - j] =
    230         spectrum->norm[i][j]*SIN(spectrum->phas[i][j]);
    231     }
     216  uint_t j;
     217  for (j = 1; j < ( compspec->length + 1 ) / 2 /*- 1 + 1*/; j++) {
     218    compspec->data[compspec->length - j] =
     219      spectrum->norm[j]*SIN(spectrum->phas[j]);
    232220  }
    233221}
    234222
    235223void aubio_fft_get_real(cvec_t * spectrum, fvec_t * compspec) {
    236   uint_t i, j;
    237   for (i = 0; i < compspec->channels; i++) {
    238     for (j = 0; j < compspec->length / 2 + 1; j++) {
    239       compspec->data[i][j] =
    240         spectrum->norm[i][j]*COS(spectrum->phas[i][j]);
    241     }
    242   }
    243 }
     224  uint_t j;
     225  for (j = 0; j < compspec->length / 2 + 1; j++) {
     226    compspec->data[j] =
     227      spectrum->norm[j]*COS(spectrum->phas[j]);
     228  }
     229}
  • src/spectral/fft.h

    r0536612 rf658288  
    4545
    4646  \param size length of the FFT
    47   \param channels number of channels
    4847
    4948*/
    50 aubio_fft_t * new_aubio_fft(uint_t size, uint_t channels);
     49aubio_fft_t * new_aubio_fft (uint_t size);
    5150/** delete FFT object
    5251
  • src/spectral/filterbank.c

    r0536612 rf658288  
    2222#include "aubio_priv.h"
    2323#include "fvec.h"
     24#include "fmat.h"
    2425#include "cvec.h"
    2526#include "spectral/filterbank.h"
     
    3132  uint_t win_s;
    3233  uint_t n_filters;
    33   fvec_t *filters;
     34  fmat_t *filters;
    3435};
    3536
     
    4243  fb->n_filters = n_filters;
    4344
    44   /* allocate filter tables, an fvec of length win_s and of filter_cnt channel */
    45   fb->filters = new_fvec (win_s / 2 + 1, n_filters);
     45  /* allocate filter tables, a matrix of length win_s and of height n_filters */
     46  fb->filters = new_fmat (win_s / 2 + 1, n_filters);
    4647
    4748  return fb;
     
    5152del_aubio_filterbank (aubio_filterbank_t * fb)
    5253{
    53   del_fvec (fb->filters);
     54  del_fmat (fb->filters);
    5455  AUBIO_FREE (fb);
    5556}
     
    5859aubio_filterbank_do (aubio_filterbank_t * f, cvec_t * in, fvec_t * out)
    5960{
    60   uint_t i, j, fn;
     61  uint_t j, fn;
    6162
    6263  /* apply filter to all input channel, provided out has enough channels */
    63   uint_t max_channels = MIN (in->channels, out->channels);
    6464  uint_t max_filters = MIN (f->n_filters, out->length);
    6565  uint_t max_length = MIN (in->length, f->filters->length);
     
    6868  fvec_zeros (out);
    6969
    70   /* apply filters on all channels */
    71   for (i = 0; i < max_channels; i++) {
     70  /* for each filter */
     71  for (fn = 0; fn < max_filters; fn++) {
    7272
    73     /* for each filter */
    74     for (fn = 0; fn < max_filters; fn++) {
    75 
    76       /* for each sample */
    77       for (j = 0; j < max_length; j++) {
    78         out->data[i][fn] += in->norm[i][j] * f->filters->data[fn][j];
    79       }
     73    /* for each sample */
     74    for (j = 0; j < max_length; j++) {
     75      out->data[fn] += in->norm[j] * f->filters->data[fn][j];
    8076    }
    8177  }
     
    8480}
    8581
    86 fvec_t *
     82fmat_t *
    8783aubio_filterbank_get_coeffs (aubio_filterbank_t * f)
    8884{
     
    9187
    9288uint_t
    93 aubio_filterbank_set_coeffs (aubio_filterbank_t * f, fvec_t * filters)
     89aubio_filterbank_set_coeffs (aubio_filterbank_t * f, fmat_t * filter_coeffs)
    9490{
    95   fvec_copy(filters, f->filters);
     91  fmat_copy(filter_coeffs, f->filters);
    9692  return 0;
    9793}
  • src/spectral/filterbank.h

    r0536612 rf658288  
    6363void aubio_filterbank_do (aubio_filterbank_t * fb, cvec_t * in, fvec_t * out);
    6464
    65 /** return a pointer to the fvec object containing all filter coefficients
     65/** return a pointer to the matrix object containing all filter coefficients
    6666
    6767  \param f filterbank object to get coefficients from
    6868
    6969 */
    70 fvec_t *aubio_filterbank_get_coeffs (aubio_filterbank_t * f);
     70fmat_t *aubio_filterbank_get_coeffs (aubio_filterbank_t * f);
    7171
    7272/** copy filter coefficients to the filterbank
     
    7676
    7777 */
    78 uint_t aubio_filterbank_set_coeffs (aubio_filterbank_t * f, fvec_t * filters);
     78uint_t aubio_filterbank_set_coeffs (aubio_filterbank_t * f, fmat_t * filters);
    7979
    8080#ifdef __cplusplus
  • src/spectral/filterbank_mel.c

    r0536612 rf658288  
    2121
    2222#include "aubio_priv.h"
     23#include "fmat.h"
    2324#include "fvec.h"
    2425#include "cvec.h"
     
    3132{
    3233
    33   fvec_t *filters = aubio_filterbank_get_coeffs (fb);
    34   uint_t n_filters = filters->channels, win_s = filters->length;
     34  fmat_t *filters = aubio_filterbank_get_coeffs (fb);
     35  uint_t n_filters = filters->height, win_s = filters->length;
    3536
    3637  uint_t fn;                    /* filter counter */
     
    4950  }
    5051
    51   if (freqs->data[0][freqs->length - 1] > samplerate / 2) {
     52  if (freqs->data[freqs->length - 1] > samplerate / 2) {
    5253    AUBIO_WRN ("Nyquist frequency is %fHz, but highest frequency band ends at \
    53 %fHz\n", samplerate / 2, freqs->data[0][freqs->length - 1]);
     54%fHz\n", samplerate / 2, freqs->data[freqs->length - 1]);
    5455  }
    5556
    5657  /* convenience reference to lower/center/upper frequency for each triangle */
    57   fvec_t *lower_freqs = new_fvec (n_filters, 1);
    58   fvec_t *upper_freqs = new_fvec (n_filters, 1);
    59   fvec_t *center_freqs = new_fvec (n_filters, 1);
     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);
    6061
    6162  /* height of each triangle */
    62   fvec_t *triangle_heights = new_fvec (n_filters, 1);
     63  fvec_t *triangle_heights = new_fvec (n_filters);
    6364
    6465  /* lookup table of each bin frequency in hz */
    65   fvec_t *fft_freqs = new_fvec (win_s, 1);
     66  fvec_t *fft_freqs = new_fvec (win_s);
    6667
    6768  /* fill up the lower/center/upper */
    6869  for (fn = 0; fn < n_filters; fn++) {
    69     lower_freqs->data[0][fn] = freqs->data[0][fn];
    70     center_freqs->data[0][fn] = freqs->data[0][fn + 1];
    71     upper_freqs->data[0][fn] = freqs->data[0][fn + 2];
     70    lower_freqs->data[fn] = freqs->data[fn];
     71    center_freqs->data[fn] = freqs->data[fn + 1];
     72    upper_freqs->data[fn] = freqs->data[fn + 2];
    7273  }
    7374
    7475  /* compute triangle heights so that each triangle has unit area */
    7576  for (fn = 0; fn < n_filters; fn++) {
    76     triangle_heights->data[0][fn] =
    77         2. / (upper_freqs->data[0][fn] - lower_freqs->data[0][fn]);
     77    triangle_heights->data[fn] =
     78        2. / (upper_freqs->data[fn] - lower_freqs->data[fn]);
    7879  }
    7980
    8081  /* fill fft_freqs lookup table, which assigns the frequency in hz to each bin */
    8182  for (bin = 0; bin < win_s; bin++) {
    82     fft_freqs->data[0][bin] =
     83    fft_freqs->data[bin] =
    8384        aubio_bintofreq (bin, samplerate, (win_s - 1) * 2);
    8485  }
    8586
    8687  /* zeroing of all filters */
    87   fvec_zeros (filters);
    88 
    89   if (fft_freqs->data[0][1] >= lower_freqs->data[0][0]) {
     88  fmat_zeros (filters);
     89
     90  if (fft_freqs->data[1] >= lower_freqs->data[0]) {
    9091    /* - 1 to make sure we don't miss the smallest power of two */
    9192    uint_t min_win_s =
    92         (uint_t) FLOOR (samplerate / lower_freqs->data[0][0]) - 1;
     93        (uint_t) FLOOR (samplerate / lower_freqs->data[0]) - 1;
    9394    AUBIO_WRN ("Lowest frequency bin (%.2fHz) is higher than lowest frequency \
    9495band (%.2f-%.2fHz). Consider increasing the window size from %d to %d.\n",
    95         fft_freqs->data[0][1], lower_freqs->data[0][0],
    96         upper_freqs->data[0][0], (win_s - 1) * 2,
     96        fft_freqs->data[1], lower_freqs->data[0],
     97        upper_freqs->data[0], (win_s - 1) * 2,
    9798        aubio_next_power_of_two (min_win_s));
    9899  }
     
    103104    /* skip first elements */
    104105    for (bin = 0; bin < win_s - 1; bin++) {
    105       if (fft_freqs->data[0][bin] <= lower_freqs->data[0][fn] &&
    106           fft_freqs->data[0][bin + 1] > lower_freqs->data[0][fn]) {
     106      if (fft_freqs->data[bin] <= lower_freqs->data[fn] &&
     107          fft_freqs->data[bin + 1] > lower_freqs->data[fn]) {
    107108        bin++;
    108109        break;
     
    112113    /* compute positive slope step size */
    113114    smpl_t riseInc =
    114         triangle_heights->data[0][fn] /
    115         (center_freqs->data[0][fn] - lower_freqs->data[0][fn]);
     115        triangle_heights->data[fn] /
     116        (center_freqs->data[fn] - lower_freqs->data[fn]);
    116117
    117118    /* compute coefficients in positive slope */
    118119    for (; bin < win_s - 1; bin++) {
    119120      filters->data[fn][bin] =
    120           (fft_freqs->data[0][bin] - lower_freqs->data[0][fn]) * riseInc;
    121 
    122       if (fft_freqs->data[0][bin + 1] >= center_freqs->data[0][fn]) {
     121          (fft_freqs->data[bin] - lower_freqs->data[fn]) * riseInc;
     122
     123      if (fft_freqs->data[bin + 1] >= center_freqs->data[fn]) {
    123124        bin++;
    124125        break;
     
    128129    /* compute negative slope step size */
    129130    smpl_t downInc =
    130         triangle_heights->data[0][fn] /
    131         (upper_freqs->data[0][fn] - center_freqs->data[0][fn]);
     131        triangle_heights->data[fn] /
     132        (upper_freqs->data[fn] - center_freqs->data[fn]);
    132133
    133134    /* compute coefficents in negative slope */
    134135    for (; bin < win_s - 1; bin++) {
    135136      filters->data[fn][bin] +=
    136           (upper_freqs->data[0][fn] - fft_freqs->data[0][bin]) * downInc;
     137          (upper_freqs->data[fn] - fft_freqs->data[bin]) * downInc;
    137138
    138139      if (filters->data[fn][bin] < 0.) {
     
    140141      }
    141142
    142       if (fft_freqs->data[0][bin + 1] >= upper_freqs->data[0][fn])
     143      if (fft_freqs->data[bin + 1] >= upper_freqs->data[fn])
    143144        break;
    144145    }
     
    176177
    177178  /* buffers to compute filter frequencies */
    178   fvec_t *freqs = new_fvec (n_filters + 2, 1);
     179  fvec_t *freqs = new_fvec (n_filters + 2);
    179180
    180181  /* first step: fill all the linear filter frequencies */
    181182  for (fn = 0; fn < linearFilters; fn++) {
    182     freqs->data[0][fn] = lowestFrequency + fn * linearSpacing;
    183   }
    184   smpl_t lastlinearCF = freqs->data[0][fn - 1];
     183    freqs->data[fn] = lowestFrequency + fn * linearSpacing;
     184  }
     185  smpl_t lastlinearCF = freqs->data[fn - 1];
    185186
    186187  /* second step: fill all the log filter frequencies */
    187188  for (fn = 0; fn < logFilters + 2; fn++) {
    188     freqs->data[0][fn + linearFilters] =
     189    freqs->data[fn + linearFilters] =
    189190        lastlinearCF * (POW (logSpacing, fn + 1));
    190191  }
  • src/spectral/mfcc.c

    r0536612 rf658288  
    2222#include "aubio_priv.h"
    2323#include "fvec.h"
     24#include "fmat.h"
    2425#include "cvec.h"
    2526#include "mathutils.h"
     
    4041  aubio_filterbank_t *fb;   /** filter bank */
    4142  fvec_t *in_dct;           /** input buffer for dct * [fb->n_filters] */
    42   fvec_t *dct_coeffs;       /** DCT transform n_filters * n_coeffs */
     43  fmat_t *dct_coeffs;       /** DCT transform n_filters * n_coeffs */
    4344};
    4445
     
    6465
    6566  /* allocating buffers */
    66   mfcc->in_dct = new_fvec (n_filters, 1);
     67  mfcc->in_dct = new_fvec (n_filters);
    6768
    68   mfcc->dct_coeffs = new_fvec (n_coefs, n_filters);
     69  mfcc->dct_coeffs = new_fmat (n_coefs, n_filters);
    6970
    7071  /* compute DCT transform dct_coeffs[i][j] as
     
    100101aubio_mfcc_do (aubio_mfcc_t * mf, cvec_t * in, fvec_t * out)
    101102{
    102   uint_t i, j, k;
     103  uint_t j, k;
    103104
    104105  /* compute filterbank */
     
    115116
    116117  /* compute discrete cosine transform */
    117   for (i = 0; i < out->channels; i++) {
    118     for (j = 0; j < mf->n_filters; j++) {
    119       for (k = 0; k < mf->n_coefs; k++) {
    120         out->data[i][k] += mf->in_dct->data[i][j]
    121             * mf->dct_coeffs->data[j][k];
    122       }
     118  for (j = 0; j < mf->n_filters; j++) {
     119    for (k = 0; k < mf->n_coefs; k++) {
     120      out->data[k] += mf->in_dct->data[j]
     121          * mf->dct_coeffs->data[j][k];
    123122    }
    124123  }
  • src/spectral/phasevoc.c

    r0536612 rf658288  
    3030  uint_t win_s;       /** grain length */
    3131  uint_t hop_s;       /** overlap step */
    32   uint_t channels;    /** number of channels */
    3332  aubio_fft_t * fft;  /** fft object */
    3433  fvec_t * synth;     /** cur output grain [win_s] */
     
    4948
    5049void aubio_pvoc_do(aubio_pvoc_t *pv, fvec_t * datanew, cvec_t *fftgrain) {
    51   uint_t i;
    52   for (i=0; i<pv->channels; i++) {
    53     /* slide  */
    54     aubio_pvoc_swapbuffers(pv->data->data[i],pv->dataold->data[i],
    55         datanew->data[i],pv->win_s,pv->hop_s);
    56   }
     50  /* slide  */
     51  aubio_pvoc_swapbuffers(pv->data->data,pv->dataold->data,
     52      datanew->data,pv->win_s,pv->hop_s);
    5753  /* windowing */
    5854  fvec_weight(pv->data, pv->w);
     
    6460
    6561void aubio_pvoc_rdo(aubio_pvoc_t *pv,cvec_t * fftgrain, fvec_t * synthnew) {
    66   uint_t i;
    6762  /* calculate rfft */
    6863  aubio_fft_rdo(pv->fft,fftgrain,pv->synth);
    6964  /* unshift */
    7065  fvec_shift(pv->synth);
    71   for (i=0; i<pv->channels; i++) {
    72     aubio_pvoc_addsynth(pv->synth->data[i],pv->synthold->data[i],
    73         synthnew->data[i],pv->win_s,pv->hop_s);
    74   }
     66  aubio_pvoc_addsynth(pv->synth->data,pv->synthold->data,
     67      synthnew->data,pv->win_s,pv->hop_s);
    7568}
    7669
    77 aubio_pvoc_t * new_aubio_pvoc (uint_t win_s, uint_t hop_s, uint_t channels) {
     70aubio_pvoc_t * new_aubio_pvoc (uint_t win_s, uint_t hop_s) {
    7871  aubio_pvoc_t * pv = AUBIO_NEW(aubio_pvoc_t);
    7972
     
    8881  }
    8982
    90   pv->fft      = new_aubio_fft(win_s,channels);
     83  pv->fft      = new_aubio_fft (win_s);
    9184
    9285  /* remember old */
    93   pv->data     = new_fvec (win_s, channels);
    94   pv->synth    = new_fvec (win_s, channels);
     86  pv->data     = new_fvec (win_s);
     87  pv->synth    = new_fvec (win_s);
    9588
    9689  /* new input output */
    97   pv->dataold  = new_fvec  (win_s-hop_s, channels);
    98   pv->synthold = new_fvec (win_s-hop_s, channels);
     90  pv->dataold  = new_fvec  (win_s-hop_s);
     91  pv->synthold = new_fvec (win_s-hop_s);
    9992  pv->w        = new_aubio_window ("hanningz", win_s);
    10093
    101   pv->channels = channels;
    10294  pv->hop_s    = hop_s;
    10395  pv->win_s    = win_s;
  • src/spectral/phasevoc.h

    r0536612 rf658288  
    2626  using a HanningZ window and a swapped version of the signal to simplify the
    2727  phase relationships across frames. The window sizes and overlap are specified
    28   at creation time. Multiple channels are fully supported.
     28  at creation time.
    2929
    3030*/
     
    4444  \param win_s size of analysis buffer (and length the FFT transform)
    4545  \param hop_s step size between two consecutive analysis
    46   \param channels number of channels
    4746
    4847*/
    49 aubio_pvoc_t * new_aubio_pvoc (uint_t win_s, uint_t hop_s, uint_t channels);
     48aubio_pvoc_t * new_aubio_pvoc (uint_t win_s, uint_t hop_s);
    5049/** delete phase vocoder object
    5150
     
    5756/** compute spectral frame
    5857 
    59   This function accepts an input vector of size [channels]x[hop_s]. The
     58  This function accepts an input vector of size [hop_s]. The
    6059  analysis buffer is rotated and filled with the new data. After windowing of
    6160  this signal window, the Fourier transform is computed and returned in
     
    7170
    7271  This function takes an input spectral frame fftgrain of size
    73   [channels]x[buf_s] and computes its inverse Fourier transform. Overlap-add
     72  [buf_s] and computes its inverse Fourier transform. Overlap-add
    7473  synthesis is then computed using the previously synthetised frames, and the
    7574  output stored in out.
     
    9493*/
    9594uint_t aubio_pvoc_get_hop(aubio_pvoc_t* pv);
    96 /** get channel number
    97  
    98   \param pv phase vocoder to get the number of channels from
    99 
    100 */
    101 uint_t aubio_pvoc_get_channels(aubio_pvoc_t* pv);
    10295
    10396#ifdef __cplusplus
  • src/spectral/specdesc.c

    r0536612 rf658288  
    8989void aubio_specdesc_energy  (aubio_specdesc_t *o UNUSED,
    9090    cvec_t * fftgrain, fvec_t * onset) {
    91   uint_t i,j;
    92   for (i=0;i<fftgrain->channels;i++) {
    93     onset->data[i][0] = 0.;
    94     for (j=0;j<fftgrain->length;j++) {
    95       onset->data[i][0] += SQR(fftgrain->norm[i][j]);
    96     }
     91  uint_t j;
     92  onset->data[0] = 0.;
     93  for (j=0;j<fftgrain->length;j++) {
     94    onset->data[0] += SQR(fftgrain->norm[j]);
    9795  }
    9896}
     
    10199void aubio_specdesc_hfc(aubio_specdesc_t *o UNUSED,
    102100    cvec_t * fftgrain, fvec_t * onset){
    103   uint_t i,j;
    104   for (i=0;i<fftgrain->channels;i++) {
    105     onset->data[i][0] = 0.;
    106     for (j=0;j<fftgrain->length;j++) {
    107       onset->data[i][0] += (j+1)*fftgrain->norm[i][j];
    108     }
     101  uint_t j;
     102  onset->data[0] = 0.;
     103  for (j=0;j<fftgrain->length;j++) {
     104    onset->data[0] += (j+1)*fftgrain->norm[j];
    109105  }
    110106}
     
    113109/* Complex Domain Method onset detection function */
    114110void aubio_specdesc_complex (aubio_specdesc_t *o, cvec_t * fftgrain, fvec_t * onset) {
    115   uint_t i, j;
     111  uint_t j;
    116112  uint_t nbins = fftgrain->length;
    117   for (i=0;i<fftgrain->channels; i++)  {
    118     onset->data[i][0] = 0.;
    119     for (j=0;j<nbins; j++)  {
    120       // compute the predicted phase
    121       o->dev1->data[i][j] = 2. * o->theta1->data[i][j] - o->theta2->data[i][j];
    122       // compute the euclidean distance in the complex domain
    123       // sqrt ( r_1^2 + r_2^2 - 2 * r_1 * r_2 * \cos ( \phi_1 - \phi_2 ) )
    124       onset->data[i][0] +=
    125         SQRT (ABS (SQR (o->oldmag->data[i][j]) + SQR (fftgrain->norm[i][j])
    126               - 2. * o->oldmag->data[i][j] * fftgrain->norm[i][j]
    127               * COS (o->dev1->data[i][j] - fftgrain->phas[i][j])));
    128       /* swap old phase data (need to remember 2 frames behind)*/
    129       o->theta2->data[i][j] = o->theta1->data[i][j];
    130       o->theta1->data[i][j] = fftgrain->phas[i][j];
    131       /* swap old magnitude data (1 frame is enough) */
    132       o->oldmag->data[i][j] = fftgrain->norm[i][j];
    133     }
     113  onset->data[0] = 0.;
     114  for (j=0;j<nbins; j++)  {
     115    // compute the predicted phase
     116    o->dev1->data[j] = 2. * o->theta1->data[j] - o->theta2->data[j];
     117    // compute the euclidean distance in the complex domain
     118    // sqrt ( r_1^2 + r_2^2 - 2 * r_1 * r_2 * \cos ( \phi_1 - \phi_2 ) )
     119    onset->data[0] +=
     120      SQRT (ABS (SQR (o->oldmag->data[j]) + SQR (fftgrain->norm[j])
     121            - 2. * o->oldmag->data[j] * fftgrain->norm[j]
     122            * COS (o->dev1->data[j] - fftgrain->phas[j])));
     123    /* swap old phase data (need to remember 2 frames behind)*/
     124    o->theta2->data[j] = o->theta1->data[j];
     125    o->theta1->data[j] = fftgrain->phas[j];
     126    /* swap old magnitude data (1 frame is enough) */
     127    o->oldmag->data[j] = fftgrain->norm[j];
    134128  }
    135129}
     
    139133void aubio_specdesc_phase(aubio_specdesc_t *o,
    140134    cvec_t * fftgrain, fvec_t * onset){
    141   uint_t i, j;
     135  uint_t j;
    142136  uint_t nbins = fftgrain->length;
    143   for (i=0;i<fftgrain->channels; i++)  {
    144     onset->data[i][0] = 0.0;
    145     o->dev1->data[i][0]=0.;
    146     for ( j=0;j<nbins; j++ )  {
    147       o->dev1->data[i][j] =
    148         aubio_unwrap2pi(
    149             fftgrain->phas[i][j]
    150             -2.0*o->theta1->data[i][j]
    151             +o->theta2->data[i][j]);
    152       if ( o->threshold < fftgrain->norm[i][j] )
    153         o->dev1->data[i][j] = ABS(o->dev1->data[i][j]);
    154       else
    155         o->dev1->data[i][j] = 0.0;
    156       /* keep a track of the past frames */
    157       o->theta2->data[i][j] = o->theta1->data[i][j];
    158       o->theta1->data[i][j] = fftgrain->phas[i][j];
    159     }
    160     /* apply o->histogram */
    161     aubio_hist_dyn_notnull(o->histog,o->dev1);
    162     /* weight it */
    163     aubio_hist_weight(o->histog);
    164     /* its mean is the result */
    165     onset->data[i][0] = aubio_hist_mean(o->histog); 
    166     //onset->data[i][0] = fvec_mean(o->dev1);
    167   }
     137  onset->data[0] = 0.0;
     138  o->dev1->data[0]=0.;
     139  for ( j=0;j<nbins; j++ )  {
     140    o->dev1->data[j] =
     141      aubio_unwrap2pi(
     142          fftgrain->phas[j]
     143          -2.0*o->theta1->data[j]
     144          +o->theta2->data[j]);
     145    if ( o->threshold < fftgrain->norm[j] )
     146      o->dev1->data[j] = ABS(o->dev1->data[j]);
     147    else
     148      o->dev1->data[j] = 0.0;
     149    /* keep a track of the past frames */
     150    o->theta2->data[j] = o->theta1->data[j];
     151    o->theta1->data[j] = fftgrain->phas[j];
     152  }
     153  /* apply o->histogram */
     154  aubio_hist_dyn_notnull(o->histog,o->dev1);
     155  /* weight it */
     156  aubio_hist_weight(o->histog);
     157  /* its mean is the result */
     158  onset->data[0] = aubio_hist_mean(o->histog); 
     159  //onset->data[0] = fvec_mean(o->dev1);
    168160}
    169161
     
    171163void aubio_specdesc_specdiff(aubio_specdesc_t *o,
    172164    cvec_t * fftgrain, fvec_t * onset){
    173   uint_t i, j;
     165  uint_t j;
    174166  uint_t nbins = fftgrain->length;
    175   for (i=0;i<fftgrain->channels; i++)  {
    176     onset->data[i][0] = 0.0;
     167    onset->data[0] = 0.0;
    177168    for (j=0;j<nbins; j++)  {
    178       o->dev1->data[i][j] = SQRT(
    179           ABS(SQR( fftgrain->norm[i][j])
    180             - SQR(o->oldmag->data[i][j])));
    181       if (o->threshold < fftgrain->norm[i][j] )
    182         o->dev1->data[i][j] = ABS(o->dev1->data[i][j]);
     169      o->dev1->data[j] = SQRT(
     170          ABS(SQR( fftgrain->norm[j])
     171            - SQR(o->oldmag->data[j])));
     172      if (o->threshold < fftgrain->norm[j] )
     173        o->dev1->data[j] = ABS(o->dev1->data[j]);
    183174      else
    184         o->dev1->data[i][j] = 0.0;
    185       o->oldmag->data[i][j] = fftgrain->norm[i][j];
     175        o->dev1->data[j] = 0.0;
     176      o->oldmag->data[j] = fftgrain->norm[j];
    186177    }
    187178
     
    192183    aubio_hist_weight(o->histog);
    193184    /* its mean is the result */
    194     onset->data[i][0] = aubio_hist_mean(o->histog); 
    195 
    196   }
     185    onset->data[0] = aubio_hist_mean(o->histog); 
    197186}
    198187
     
    201190 * negative (1.+) and infinite values (+1.e-10) */
    202191void aubio_specdesc_kl(aubio_specdesc_t *o, cvec_t * fftgrain, fvec_t * onset){
    203   uint_t i,j;
    204   for (i=0;i<fftgrain->channels;i++) {
    205     onset->data[i][0] = 0.;
     192  uint_t j;
     193    onset->data[0] = 0.;
    206194    for (j=0;j<fftgrain->length;j++) {
    207       onset->data[i][0] += fftgrain->norm[i][j]
    208         *LOG(1.+fftgrain->norm[i][j]/(o->oldmag->data[i][j]+1.e-10));
    209       o->oldmag->data[i][j] = fftgrain->norm[i][j];
     195      onset->data[0] += fftgrain->norm[j]
     196        *LOG(1.+fftgrain->norm[j]/(o->oldmag->data[j]+1.e-10));
     197      o->oldmag->data[j] = fftgrain->norm[j];
    210198    }
    211     if (isnan(onset->data[i][0])) onset->data[i][0] = 0.;
    212   }
     199    if (isnan(onset->data[0])) onset->data[0] = 0.;
    213200}
    214201
     
    217204 * negative (1.+) and infinite values (+1.e-10) */
    218205void aubio_specdesc_mkl(aubio_specdesc_t *o, cvec_t * fftgrain, fvec_t * onset){
    219   uint_t i,j;
    220   for (i=0;i<fftgrain->channels;i++) {
    221     onset->data[i][0] = 0.;
     206  uint_t j;
     207    onset->data[0] = 0.;
    222208    for (j=0;j<fftgrain->length;j++) {
    223       onset->data[i][0] += LOG(1.+fftgrain->norm[i][j]/(o->oldmag->data[i][j]+1.e-10));
    224       o->oldmag->data[i][j] = fftgrain->norm[i][j];
     209      onset->data[0] += LOG(1.+fftgrain->norm[j]/(o->oldmag->data[j]+1.e-10));
     210      o->oldmag->data[j] = fftgrain->norm[j];
    225211    }
    226     if (isnan(onset->data[i][0])) onset->data[i][0] = 0.;
    227   }
     212    if (isnan(onset->data[0])) onset->data[0] = 0.;
    228213}
    229214
    230215/* Spectral flux */
    231216void aubio_specdesc_specflux(aubio_specdesc_t *o, cvec_t * fftgrain, fvec_t * onset){
    232   uint_t i, j;
    233   for (i=0;i<fftgrain->channels;i++) {
    234     onset->data[i][0] = 0.;
    235     for (j=0;j<fftgrain->length;j++) {
    236       if (fftgrain->norm[i][j] > o->oldmag->data[i][j])
    237         onset->data[i][0] += fftgrain->norm[i][j] - o->oldmag->data[i][j];
    238       o->oldmag->data[i][j] = fftgrain->norm[i][j];
    239     }
     217  uint_t j;
     218  onset->data[0] = 0.;
     219  for (j=0;j<fftgrain->length;j++) {
     220    if (fftgrain->norm[j] > o->oldmag->data[j])
     221      onset->data[0] += fftgrain->norm[j] - o->oldmag->data[j];
     222    o->oldmag->data[j] = fftgrain->norm[j];
    240223  }
    241224}
     
    252235 */
    253236aubio_specdesc_t *
    254 new_aubio_specdesc (char_t * onset_mode,
    255     uint_t size, uint_t channels){
     237new_aubio_specdesc (char_t * onset_mode, uint_t size){
    256238  aubio_specdesc_t * o = AUBIO_NEW(aubio_specdesc_t);
    257239  uint_t rsize = size/2+1;
     
    303285      /* the other approaches will need some more memory spaces */
    304286    case aubio_onset_complex:
    305       o->oldmag = new_fvec(rsize,channels);
    306       o->dev1   = new_fvec(rsize,channels);
    307       o->theta1 = new_fvec(rsize,channels);
    308       o->theta2 = new_fvec(rsize,channels);
     287      o->oldmag = new_fvec(rsize);
     288      o->dev1   = new_fvec(rsize);
     289      o->theta1 = new_fvec(rsize);
     290      o->theta2 = new_fvec(rsize);
    309291      break;
    310292    case aubio_onset_phase:
    311       o->dev1   = new_fvec(rsize,channels);
    312       o->theta1 = new_fvec(rsize,channels);
    313       o->theta2 = new_fvec(rsize,channels);
    314       o->histog = new_aubio_hist(0.0, PI, 10, channels);
     293      o->dev1   = new_fvec(rsize);
     294      o->theta1 = new_fvec(rsize);
     295      o->theta2 = new_fvec(rsize);
     296      o->histog = new_aubio_hist(0.0, PI, 10);
    315297      o->threshold = 0.1;
    316298      break;
    317299    case aubio_onset_specdiff:
    318       o->oldmag = new_fvec(rsize,channels);
    319       o->dev1   = new_fvec(rsize,channels);
    320       o->histog = new_aubio_hist(0.0, PI, 10, channels);
     300      o->oldmag = new_fvec(rsize);
     301      o->dev1   = new_fvec(rsize);
     302      o->histog = new_aubio_hist(0.0, PI, 10);
    321303      o->threshold = 0.1;
    322304      break;
     
    324306    case aubio_onset_mkl:
    325307    case aubio_onset_specflux:
    326       o->oldmag = new_fvec(rsize,channels);
     308      o->oldmag = new_fvec(rsize);
    327309      break;
    328310    default:
  • src/spectral/specdesc.h

    r0536612 rf658288  
    2525  All of the following spectral description functions take as arguments the FFT
    2626  of a windowed signal (as created with aubio_pvoc). They output one smpl_t per
    27   buffer and per channel (stored in a vector of size [channels]x[1]).
     27  buffer (stored in a vector of size [1]).
    2828 
    2929  A list of the spectral description methods currently available follows.
     
    168168  \param method spectral description method
    169169  \param buf_size length of the input spectrum frame
    170   \param channels number of input channels
    171170
    172171*/
    173 aubio_specdesc_t *new_aubio_specdesc (char_t * method, uint_t buf_size,
    174     uint_t channels);
     172aubio_specdesc_t *new_aubio_specdesc (char_t * method, uint_t buf_size);
    175173
    176174/** deletion of a spectral descriptor
  • src/spectral/statistics.c

    r0536612 rf658288  
    2424
    2525smpl_t
    26 cvec_sum_channel (cvec_t * s, uint_t i)
     26cvec_sum (cvec_t * s)
    2727{
    2828  uint_t j;
    2929  smpl_t tmp = 0.0;
    30   for (j = 0; j < s->length; j++)
    31       tmp += s->norm[i][j];
     30  for (j = 0; j < s->length; j++) {
     31    tmp += s->norm[j];
     32  }
    3233  return tmp;
    3334}
    3435
    3536smpl_t
    36 cvec_mean_channel (cvec_t * s, uint_t i)
     37cvec_mean (cvec_t * s)
    3738{
    38   return cvec_sum_channel(s, i) / (smpl_t) (s->length);
     39  return cvec_sum (s) / (smpl_t) (s->length);
    3940}
    4041
    4142smpl_t
    42 cvec_centroid_channel (cvec_t * spec, uint_t i)
     43cvec_centroid (cvec_t * spec)
    4344{
    4445  smpl_t sum = 0., sc = 0.;
    4546  uint_t j;
    46   sum = cvec_sum_channel (spec, i);
     47  sum = cvec_sum (spec);
    4748  if (sum == 0.) {
    4849    return 0.;
    4950  } else {
    5051    for (j = 0; j < spec->length; j++) {
    51       sc += (smpl_t) j *spec->norm[i][j];
     52      sc += (smpl_t) j *spec->norm[j];
    5253    }
    5354    return sc / sum;
     
    5657
    5758smpl_t
    58 cvec_moment_channel (cvec_t * spec, uint_t i, uint_t order)
     59cvec_moment (cvec_t * spec, uint_t order)
    5960{
    6061  smpl_t sum = 0., centroid = 0., sc = 0.;
    6162  uint_t j;
    62   sum = cvec_sum_channel (spec, i);
     63  sum = cvec_sum (spec);
    6364  if (sum == 0.) {
    6465    return 0.;
    6566  } else {
    66     centroid = cvec_centroid_channel (spec, i);
     67    centroid = cvec_centroid (spec);
    6768    for (j = 0; j < spec->length; j++) {
    68       sc += (smpl_t) POW(j - centroid, order) * spec->norm[i][j];
     69      sc += (smpl_t) POW(j - centroid, order) * spec->norm[j];
    6970    }
    7071    return sc / sum;
     
    7677    fvec_t * desc)
    7778{
    78   uint_t i;
    79   for (i = 0; i < spec->channels; i++) {
    80     desc->data[i][0] = cvec_centroid_channel (spec, i);
    81   }
     79  desc->data[0] = cvec_centroid (spec);
    8280}
    8381
     
    8684    fvec_t * desc)
    8785{
    88   uint_t i;
    89   for (i = 0; i < spec->channels; i++) {
    90     desc->data[i][0] = cvec_moment_channel (spec, i, 2);
    91   }
     86  desc->data[0] = cvec_moment (spec, 2);
    9287}
    9388
     
    9691    fvec_t * desc)
    9792{
    98   uint_t i; smpl_t spread;
    99   for (i = 0; i < spec->channels; i++) {
    100     spread = cvec_moment_channel (spec, i, 2);
    101     if (spread == 0) {
    102       desc->data[i][0] = 0.;
    103     } else {
    104       desc->data[i][0] = cvec_moment_channel (spec, i, 3);
    105       desc->data[i][0] /= POW ( SQRT (spread), 3);
    106     }
     93  smpl_t spread;
     94  spread = cvec_moment (spec, 2);
     95  if (spread == 0) {
     96    desc->data[0] = 0.;
     97  } else {
     98    desc->data[0] = cvec_moment (spec, 3);
     99    desc->data[0] /= POW ( SQRT (spread), 3);
    107100  }
    108101}
     
    112105    fvec_t * desc)
    113106{
    114   uint_t i; smpl_t spread;
    115   for (i = 0; i < spec->channels; i++) {
    116     spread = cvec_moment_channel (spec, i, 2);
    117     if (spread == 0) {
    118       desc->data[i][0] = 0.;
    119     } else {
    120       desc->data[i][0] = cvec_moment_channel (spec, i, 4);
    121       desc->data[i][0] /= SQR (spread);
    122     }
     107  smpl_t spread;
     108  spread = cvec_moment (spec, 2);
     109  if (spread == 0) {
     110    desc->data[0] = 0.;
     111  } else {
     112    desc->data[0] = cvec_moment (spec, 4);
     113    desc->data[0] /= SQR (spread);
    123114  }
    124115}
     
    128119    fvec_t * desc)
    129120{
    130   uint_t i, j;
     121  uint_t j;
    131122  smpl_t norm = 0, sum = 0.;
    132123  // compute N * sum(j**2) - sum(j)**2
     
    137128  // sum_0^N(j) = length * (length + 1) / 2
    138129  norm -= SQR( (spec->length) * (spec->length - 1.) / 2. );
    139   for (i = 0; i < spec->channels; i++) {
    140     sum = cvec_sum_channel (spec, i);
    141     desc->data[i][0] = 0.;
    142     if (sum == 0.) {
    143       break;
    144     } else {
    145       for (j = 0; j < spec->length; j++) {
    146         desc->data[i][0] += j * spec->norm[i][j];
    147       }
    148       desc->data[i][0] *= spec->length;
    149       desc->data[i][0] -= sum * spec->length * (spec->length - 1) / 2.;
    150       desc->data[i][0] /= norm;
    151       desc->data[i][0] /= sum;
     130  sum = cvec_sum (spec);
     131  desc->data[0] = 0.;
     132  if (sum == 0.) {
     133    return;
     134  } else {
     135    for (j = 0; j < spec->length; j++) {
     136      desc->data[0] += j * spec->norm[j];
    152137    }
     138    desc->data[0] *= spec->length;
     139    desc->data[0] -= sum * spec->length * (spec->length - 1) / 2.;
     140    desc->data[0] /= norm;
     141    desc->data[0] /= sum;
    153142  }
    154143}
     
    158147    fvec_t * desc)
    159148{
    160   uint_t i, j; smpl_t sum;
    161   for (i = 0; i < spec->channels; i++) {
    162     sum = cvec_sum_channel (spec, i);
    163     desc->data[i][0] = 0;
    164     if (sum == 0.) {
    165       break;
    166     } else {
    167       sum -= spec->norm[i][0];
    168       for (j = 1; j < spec->length; j++) {
    169         desc->data[i][0] += (spec->norm[i][j] - spec->norm[i][0]) / j;
    170       }
    171       desc->data[i][0] /= sum;
     149  uint_t j; smpl_t sum;
     150  sum = cvec_sum (spec);
     151  desc->data[0] = 0;
     152  if (sum == 0.) {
     153    return;
     154  } else {
     155    sum -= spec->norm[0];
     156    for (j = 1; j < spec->length; j++) {
     157      desc->data[0] += (spec->norm[j] - spec->norm[0]) / j;
    172158    }
     159    desc->data[0] /= sum;
    173160  }
    174161}
     
    178165    fvec_t *desc)
    179166{
    180   uint_t i, j; smpl_t cumsum, rollsum;
    181   for (i = 0; i < spec->channels; i++) {
    182     cumsum = 0.; rollsum = 0.;
    183     for (j = 0; j < spec->length; j++) {
    184       cumsum += SQR (spec->norm[i][j]);
     167  uint_t j; smpl_t cumsum, rollsum;
     168  cumsum = 0.; rollsum = 0.;
     169  for (j = 0; j < spec->length; j++) {
     170    cumsum += SQR (spec->norm[j]);
     171  }
     172  if (cumsum == 0) {
     173    desc->data[0] = 0.;
     174  } else {
     175    cumsum *= 0.95;
     176    j = 0;
     177    while (rollsum < cumsum) {
     178      rollsum += SQR (spec->norm[j]);
     179      j++;
    185180    }
    186     if (cumsum == 0) {
    187       desc->data[i][0] = 0.;
    188     } else {
    189       cumsum *= 0.95;
    190       j = 0;
    191       while (rollsum < cumsum) {
    192         rollsum += SQR (spec->norm[i][j]);
    193         j++;
    194       }
    195       desc->data[i][0] = j;
    196     }
     181    desc->data[0] = j;
    197182  }
    198183}
  • src/spectral/tss.c

    r0536612 rf658288  
    4444    cvec_t * trans, cvec_t * stead)
    4545{
    46   uint_t i,j;
     46  uint_t j;
    4747  uint_t test;
    4848  uint_t nbins     = input->length;
    49   uint_t channels  = input->channels;
    5049  smpl_t alpha     = o->alpha;
    5150  smpl_t beta      = o->beta;
    5251  smpl_t parm      = o->parm;
    53   smpl_t ** dev    = (smpl_t **)o->dev->data;
    54   smpl_t ** oft1   = (smpl_t **)o->oft1->data;
    55   smpl_t ** oft2   = (smpl_t **)o->oft2->data;
    56   smpl_t ** theta1 = (smpl_t **)o->theta1->data;
    57   smpl_t ** theta2 = (smpl_t **)o->theta2->data;
     52  smpl_t * dev    = (smpl_t *)o->dev->data;
     53  smpl_t * oft1   = (smpl_t *)o->oft1->data;
     54  smpl_t * oft2   = (smpl_t *)o->oft2->data;
     55  smpl_t * theta1 = (smpl_t *)o->theta1->data;
     56  smpl_t * theta2 = (smpl_t *)o->theta2->data;
    5857  /* second phase derivative */
    59   for (i=0;i<channels; i++){
    60     for (j=0;j<nbins; j++){
    61       dev[i][j] = aubio_unwrap2pi(input->phas[i][j]
    62           -2.0*theta1[i][j]+theta2[i][j]);
    63       theta2[i][j] = theta1[i][j];
    64       theta1[i][j] = input->phas[i][j];
    65     }
     58  for (j=0;j<nbins; j++){
     59    dev[j] = aubio_unwrap2pi(input->phas[j]
     60        -2.0*theta1[j]+theta2[j]);
     61    theta2[j] = theta1[j];
     62    theta1[j] = input->phas[j];
     63  }
    6664
    67     for (j=0;j<nbins; j++){
    68       /* transient analysis */
    69       test = (ABS(dev[i][j]) > parm*oft1[i][j]);
    70       trans->norm[i][j] = input->norm[i][j] * test;
    71       trans->phas[i][j] = input->phas[i][j] * test;
    72     }
     65  for (j=0;j<nbins; j++){
     66    /* transient analysis */
     67    test = (ABS(dev[j]) > parm*oft1[j]);
     68    trans->norm[j] = input->norm[j] * test;
     69    trans->phas[j] = input->phas[j] * test;
     70  }
    7371
    74     for (j=0;j<nbins; j++){
    75       /* steady state analysis */
    76       test = (ABS(dev[i][j]) < parm*oft2[i][j]);
    77       stead->norm[i][j] = input->norm[i][j] * test;
    78       stead->phas[i][j] = input->phas[i][j] * test;
     72  for (j=0;j<nbins; j++){
     73    /* steady state analysis */
     74    test = (ABS(dev[j]) < parm*oft2[j]);
     75    stead->norm[j] = input->norm[j] * test;
     76    stead->phas[j] = input->phas[j] * test;
    7977
    80       /*increase sstate probability for sines */
    81       test = (trans->norm[i][j]==0.);
    82       oft1[i][j]  = test;
    83       test = (stead->norm[i][j]==0.);
    84       oft2[i][j]  = test;
    85       test = (trans->norm[i][j]>0.);
    86       oft1[i][j] += alpha*test;
    87       test = (stead->norm[i][j]>0.);
    88       oft2[i][j] += alpha*test;
    89       test = (oft1[i][j]>1. && trans->norm[i][j]>0.);
    90       oft1[i][j] += beta*test;
    91       test = (oft2[i][j]>1. && stead->norm[i][j]>0.);
    92       oft2[i][j] += beta*test;
    93     }
     78    /*increase sstate probability for sines */
     79    test = (trans->norm[j]==0.);
     80    oft1[j]  = test;
     81    test = (stead->norm[j]==0.);
     82    oft2[j]  = test;
     83    test = (trans->norm[j]>0.);
     84    oft1[j] += alpha*test;
     85    test = (stead->norm[j]>0.);
     86    oft2[j] += alpha*test;
     87    test = (oft1[j]>1. && trans->norm[j]>0.);
     88    oft1[j] += beta*test;
     89    test = (oft2[j]>1. && stead->norm[j]>0.);
     90    oft2[j] += beta*test;
    9491  }
    9592}
     
    10198}
    10299
    103 aubio_tss_t * new_aubio_tss(uint_t buf_size, uint_t hop_size, uint_t channels)
     100aubio_tss_t * new_aubio_tss(uint_t buf_size, uint_t hop_size)
    104101{
    105102  aubio_tss_t * o = AUBIO_NEW(aubio_tss_t);
     
    110107  o->beta = 4.;
    111108  o->parm = o->threshold*o->thrsfact;
    112   o->theta1 = new_fvec(rsize,channels);
    113   o->theta2 = new_fvec(rsize,channels);
    114   o->oft1 = new_fvec(rsize,channels);
    115   o->oft2 = new_fvec(rsize,channels);
    116   o->dev = new_fvec(rsize,channels);
     109  o->theta1 = new_fvec(rsize);
     110  o->theta2 = new_fvec(rsize);
     111  o->oft1 = new_fvec(rsize);
     112  o->oft2 = new_fvec(rsize);
     113  o->dev = new_fvec(rsize);
    117114  return o;
    118115}
  • src/spectral/tss.h

    r0536612 rf658288  
    4949  \param buf_size buffer size
    5050  \param hop_size step size
    51   \param channels number of input channels
    5251
    5352*/
    54 aubio_tss_t *new_aubio_tss (uint_t buf_size, uint_t hop_size, uint_t channels);
     53aubio_tss_t *new_aubio_tss (uint_t buf_size, uint_t hop_size);
    5554
    5655/** delete tss object
  • src/tempo/beattracking.c

    r0536612 rf658288  
    5555
    5656aubio_beattracking_t *
    57 new_aubio_beattracking (uint_t winlen, uint_t channels)
     57new_aubio_beattracking (uint_t winlen)
    5858{
    5959
     
    7979  p->rayparam = rayparam;
    8080  p->step = step;
    81   p->rwv = new_fvec (laglen, 1);
    82   p->gwv = new_fvec (laglen, 1);
    83   p->dfwv = new_fvec (winlen, 1);
    84   p->dfrev = new_fvec (winlen, channels);
    85   p->acf = new_fvec (winlen, channels);
    86   p->acfout = new_fvec (laglen, channels);
    87   p->phwv = new_fvec (2 * laglen, 1);
    88   p->phout = new_fvec (winlen, channels);
     81  p->rwv = new_fvec (laglen);
     82  p->gwv = new_fvec (laglen);
     83  p->dfwv = new_fvec (winlen);
     84  p->dfrev = new_fvec (winlen);
     85  p->acf = new_fvec (winlen);
     86  p->acfout = new_fvec (laglen);
     87  p->phwv = new_fvec (2 * laglen);
     88  p->phout = new_fvec (winlen);
    8989
    9090  p->timesig = 0;
     
    9292  /* exponential weighting, dfwv = 0.5 when i =  43 */
    9393  for (i = 0; i < winlen; i++) {
    94     p->dfwv->data[0][i] = (EXP ((LOG (2.0) / rayparam) * (i + 1)))
     94    p->dfwv->data[i] = (EXP ((LOG (2.0) / rayparam) * (i + 1)))
    9595        / dfwvnorm;
    9696  }
    9797
    9898  for (i = 0; i < (laglen); i++) {
    99     p->rwv->data[0][i] = ((smpl_t) (i + 1.) / SQR ((smpl_t) rayparam)) *
     99    p->rwv->data[i] = ((smpl_t) (i + 1.) / SQR ((smpl_t) rayparam)) *
    100100        EXP ((-SQR ((smpl_t) (i + 1.)) / (2. * SQR ((smpl_t) rayparam))));
    101101  }
     
    161161    for (a = 1; a <= numelem; a++) {
    162162      for (b = (1 - a); b < a; b++) {
    163         bt->acfout->data[0][i] += bt->acf->data[0][a * (i + 1) + b - 1]
     163        bt->acfout->data[i] += bt->acf->data[a * (i + 1) + b - 1]
    164164            * 1. / (2. * a - 1.);
    165165      }
     
    171171  /* find non-zero Rayleigh period */
    172172  maxindex = fvec_max_elem (bt->acfout);
    173   bt->rp = maxindex ? fvec_quadint (bt->acfout, maxindex, 0) : 1;
     173  bt->rp = maxindex ? fvec_quadint (bt->acfout, maxindex) : 1;
    174174  //rp = (maxindex==127) ? 43 : maxindex; //rayparam
    175175  bt->rp = (maxindex == bt->acfout->length - 1) ? bt->rayparam : maxindex;      //rayparam
     
    191191  for (i = 0; i < bp; i++) {
    192192    for (k = 0; k < kmax; k++) {
    193       bt->phout->data[0][i] += bt->dfrev->data[0][i + (uint_t) ROUND (bp * k)];
     193      bt->phout->data[i] += bt->dfrev->data[i + (uint_t) ROUND (bp * k)];
    194194    }
    195195  }
     
    204204    phase = step - bt->lastbeat;
    205205  } else {
    206     phase = fvec_quadint (bt->phout, maxindex, 0);
     206    phase = fvec_quadint (bt->phout, maxindex);
    207207  }
    208208  /* take back one frame delay */
     
    237237  if (beat >= 0) {
    238238    //AUBIO_DBG ("beat: %d, %f, %f\n", i, bp, beat);
    239     output->data[0][i] = beat;
     239    output->data[i] = beat;
    240240    i++;
    241241  }
     
    244244    beat += bp;
    245245    //AUBIO_DBG ("beat: %d, %f, %f\n", i, bp, beat);
    246     output->data[0][i] = beat;
     246    output->data[i] = beat;
    247247    i++;
    248248  }
     
    250250  bt->lastbeat = beat;
    251251  /* store the number of beats in this frame as the first element */
    252   output->data[0][0] = i;
     252  output->data[0] = i;
    253253}
    254254
     
    260260  if (acflen > 6 * gp + 2) {
    261261    for (k = -2; k < 2; k++) {
    262       three_energy += acf->data[0][3 * gp + k];
    263       four_energy += acf->data[0][4 * gp + k];
     262      three_energy += acf->data[3 * gp + k];
     263      four_energy += acf->data[4 * gp + k];
    264264    }
    265265  } else {
    266266    /*Expanded to be more accurate in time sig estimation */
    267267    for (k = -2; k < 2; k++) {
    268       three_energy += acf->data[0][3 * gp + k] + acf->data[0][6 * gp + k];
    269       four_energy += acf->data[0][4 * gp + k] + acf->data[0][2 * gp + k];
     268      three_energy += acf->data[3 * gp + k] + acf->data[6 * gp + k];
     269      four_energy += acf->data[4 * gp + k] + acf->data[2 * gp + k];
    270270    }
    271271  }
     
    301301      for (a = 1; a <= bt->timesig; a++) {
    302302        for (b = (1 - a); b < a; b++) {
    303           acfout->data[0][i] += acf->data[0][a * (i + 1) + b - 1];
     303          acfout->data[i] += acf->data[a * (i + 1) + b - 1];
    304304        }
    305305      }
    306306    }
    307307    fvec_weight (acfout, bt->gwv);
    308     gp = fvec_quadint (acfout, fvec_max_elem (acfout), 0);
     308    gp = fvec_quadint (acfout, fvec_max_elem (acfout));
    309309    /*
    310310       while(gp<32) gp =gp*2;
     
    351351    bt->timesig = fvec_gettimesig (acf, acflen, gp);
    352352    for (j = 0; j < laglen; j++)
    353       bt->gwv->data[0][j] =
     353      bt->gwv->data[j] =
    354354          EXP (-.5 * SQR ((smpl_t) (j + 1. - gp)) / SQR (bt->g_var));
    355355    flagconst = 0;
     
    363363    if (step > bt->lastbeat) {
    364364      for (j = 0; j < 2 * laglen; j++) {
    365         bt->phwv->data[0][j] =
     365        bt->phwv->data[j] =
    366366            EXP (-.5 * SQR ((smpl_t) (1. + j - step +
    367367                    bt->lastbeat)) / (bp / 8.));
     
    410410{
    411411  if (bt->timesig != 0 && bt->counter == 0 && bt->flagstep == 0) {
    412     return 5168. / fvec_quadint (bt->acfout, bt->bp, 0);
     412    return 5168. / fvec_quadint (bt->acfout, bt->bp);
    413413  } else {
    414414    return 0.;
  • src/tempo/beattracking.h

    r0536612 rf658288  
    4848
    4949  \param hop_size number of onset detection samples [512]
    50   \param channels number (not functionnal) [1]
    5150
    5251*/
    53 aubio_beattracking_t * new_aubio_beattracking(uint_t hop_size, uint_t channels);
     52aubio_beattracking_t * new_aubio_beattracking(uint_t hop_size);
    5453
    5554/** track the beat
  • src/tempo/tempo.c

    r0536612 rf658288  
    5959  /*if (usedoubled) {
    6060    aubio_specdesc_do(o2,fftgrain, onset2);
    61     onset->data[0][0] *= onset2->data[0][0];
     61    onset->data[0] *= onset2->data[0];
    6262  }*/
    6363  /* execute every overlap_size*step */
     
    6767    /* rotate dfframe */
    6868    for (i = 0 ; i < winlen - step; i++ )
    69       o->dfframe->data[0][i] = o->dfframe->data[0][i+step];
     69      o->dfframe->data[i] = o->dfframe->data[i+step];
    7070    for (i = winlen - step ; i < winlen; i++ )
    71       o->dfframe->data[0][i] = 0.;
     71      o->dfframe->data[i] = 0.;
    7272    o->blockpos = -1;
    7373  }
    7474  o->blockpos++;
    7575  aubio_peakpicker_do (o->pp, o->of, o->onset);
    76   tempo->data[0][1] = o->onset->data[0][0];
     76  tempo->data[1] = o->onset->data[0];
    7777  thresholded = aubio_peakpicker_get_thresholded_input(o->pp);
    78   o->dfframe->data[0][winlen - step + o->blockpos] = thresholded->data[0][0];
     78  o->dfframe->data[winlen - step + o->blockpos] = thresholded->data[0];
    7979  /* end of second level loop */
    80   tempo->data[0][0] = 0; /* reset tactus */
     80  tempo->data[0] = 0; /* reset tactus */
    8181  i=0;
    82   for (i = 1; i < o->out->data[0][0]; i++ ) {
     82  for (i = 1; i < o->out->data[0]; i++ ) {
    8383    /* if current frame is a predicted tactus */
    84     if (o->blockpos == FLOOR(o->out->data[0][i])) {
    85       tempo->data[0][0] = o->out->data[0][i] - FLOOR(o->out->data[0][i]); /* set tactus */
     84    if (o->blockpos == FLOOR(o->out->data[i])) {
     85      tempo->data[0] = o->out->data[i] - FLOOR(o->out->data[i]); /* set tactus */
    8686      /* test for silence */
    8787      if (aubio_silence_detection(input, o->silence)==1) {
    88         tempo->data[0][1] = 0; /* unset onset */
     88        tempo->data[1] = 0; /* unset onset */
    8989      }
    9090    }
     
    105105/* Allocate memory for an tempo detection */
    106106aubio_tempo_t * new_aubio_tempo (char_t * onset_mode,
    107     uint_t buf_size, uint_t hop_size, uint_t channels, uint_t samplerate)
     107    uint_t buf_size, uint_t hop_size, uint_t samplerate)
    108108{
    109109  aubio_tempo_t * o = AUBIO_NEW(aubio_tempo_t);
     
    115115  o->silence = -90.;
    116116  o->blockpos = 0;
    117   o->dfframe  = new_fvec(o->winlen,channels);
    118   o->fftgrain = new_cvec(buf_size, channels);
    119   o->out      = new_fvec(o->step,channels);
    120   o->pv       = new_aubio_pvoc(buf_size, hop_size, channels);
    121   o->pp       = new_aubio_peakpicker(channels);
     117  o->dfframe  = new_fvec(o->winlen);
     118  o->fftgrain = new_cvec(buf_size);
     119  o->out      = new_fvec(o->step);
     120  o->pv       = new_aubio_pvoc(buf_size, hop_size);
     121  o->pp       = new_aubio_peakpicker();
    122122  aubio_peakpicker_set_threshold (o->pp, o->threshold);
    123   o->od       = new_aubio_specdesc(onset_mode,buf_size,channels);
    124   o->of       = new_fvec(1, channels);
    125   o->bt       = new_aubio_beattracking(o->winlen,channels);
    126   o->onset    = new_fvec(1, channels);
     123  o->od       = new_aubio_specdesc(onset_mode,buf_size);
     124  o->of       = new_fvec(1);
     125  o->bt       = new_aubio_beattracking(o->winlen);
     126  o->onset    = new_fvec(1);
    127127  /*if (usedoubled)    {
    128     o2 = new_aubio_specdesc(type_onset2,buffer_size,channels);
    129     onset2 = new_fvec(1 , channels);
     128    o2 = new_aubio_specdesc(type_onset2,buffer_size);
     129    onset2 = new_fvec(1);
    130130  }*/
    131131  return o;
  • src/tempo/tempo.h

    r0536612 rf658288  
    4040/** create tempo detection object */
    4141aubio_tempo_t * new_aubio_tempo (char_t * method,
    42     uint_t buf_size, uint_t hop_size, uint_t channels, uint_t samplerate);
     42    uint_t buf_size, uint_t hop_size, uint_t samplerate);
    4343
    4444/** execute tempo detection */
  • src/temporal/a_weighting.c

    r0536612 rf658288  
    3232  lvec_t *bs = aubio_filter_get_feedforward (f);
    3333  lvec_t *as = aubio_filter_get_feedback (f);
    34   lsmp_t *b = bs->data[0], *a = as->data[0];
     34  lsmp_t *b = bs->data, *a = as->data;
    3535  uint_t order = aubio_filter_get_order (f);
    3636
     
    241241
    242242aubio_filter_t *
    243 new_aubio_filter_a_weighting (uint_t channels, uint_t samplerate)
     243new_aubio_filter_a_weighting (uint_t samplerate)
    244244{
    245   aubio_filter_t *f = new_aubio_filter (7, channels);
     245  aubio_filter_t *f = new_aubio_filter (7);
    246246  aubio_filter_set_a_weighting (f, samplerate);
    247247  return f;
  • src/temporal/a_weighting.h

    r0536612 rf658288  
    6161/** create new A-design filter
    6262
    63   \param channels number of channels to allocate
    6463  \param samplerate sampling frequency of the signal to filter. Should be one of
    6564  8000, 11025, 16000, 22050, 24000, 32000, 44100, 48000, 88200, 96000, and
     
    6968
    7069*/
    71 aubio_filter_t *new_aubio_filter_a_weighting (uint_t channels,
    72     uint_t samplerate);
     70aubio_filter_t *new_aubio_filter_a_weighting (uint_t samplerate);
    7371
    7472/** set feedback and feedforward coefficients of a A-weighting filter
  • src/temporal/biquad.c

    r0536612 rf658288  
    3636    return AUBIO_FAIL;
    3737  }
    38   bs->data[0][0] = b0;
    39   bs->data[0][1] = b1;
    40   bs->data[0][2] = b2;
    41   as->data[0][0] = 1.;
    42   as->data[0][1] = a1;
    43   as->data[0][1] = a2;
     38  bs->data[0] = b0;
     39  bs->data[1] = b1;
     40  bs->data[2] = b2;
     41  as->data[0] = 1.;
     42  as->data[1] = a1;
     43  as->data[1] = a2;
    4444  return AUBIO_OK;
    4545}
    4646
    4747aubio_filter_t *
    48 new_aubio_filter_biquad (lsmp_t b0, lsmp_t b1, lsmp_t b2, lsmp_t a1, lsmp_t a2,
    49     uint_t channels)
     48new_aubio_filter_biquad (lsmp_t b0, lsmp_t b1, lsmp_t b2, lsmp_t a1, lsmp_t a2)
    5049{
    51   aubio_filter_t *f = new_aubio_filter (3, channels);
     50  aubio_filter_t *f = new_aubio_filter (3);
    5251  aubio_filter_set_biquad (f, b0, b1, b2, a1, a2);
    5352  return f;
  • src/temporal/biquad.h

    r0536612 rf658288  
    6262  \param a1 feedback filter coefficient
    6363  \param a2 feedback filter coefficient
    64   \param channels number of channels to allocate
    6564
    6665*/
    6766aubio_filter_t *new_aubio_filter_biquad (lsmp_t b0, lsmp_t b1, lsmp_t b2,
    68     lsmp_t a1, lsmp_t a2, uint_t channels);
     67    lsmp_t a1, lsmp_t a2);
    6968
    7069#ifdef __cplusplus
  • src/temporal/c_weighting.c

    r0536612 rf658288  
    3232  lvec_t *bs = aubio_filter_get_feedforward (f);
    3333  lvec_t *as = aubio_filter_get_feedback (f);
    34   lsmp_t *b = bs->data[0], *a = as->data[0];
     34  lsmp_t *b = bs->data, *a = as->data;
    3535  uint_t order = aubio_filter_get_order (f);
    3636
     
    197197}
    198198
    199 aubio_filter_t * new_aubio_filter_c_weighting (uint_t channels, uint_t samplerate) {
    200   aubio_filter_t * f = new_aubio_filter(5, channels);
     199aubio_filter_t * new_aubio_filter_c_weighting (uint_t samplerate) {
     200  aubio_filter_t * f = new_aubio_filter(5);
    201201  aubio_filter_set_c_weighting (f, samplerate);
    202202  return f;
  • src/temporal/c_weighting.h

    r0536612 rf658288  
    6161/** create new C-design filter
    6262
    63   \param channels number of channels to allocate
    6463  \param samplerate sampling frequency of the signal to filter. Should be one of
    6564  8000, 11025, 16000, 22050, 24000, 32000, 44100, 48000, 88200, 96000, and
     
    6968
    7069*/
    71 aubio_filter_t *new_aubio_filter_c_weighting (uint_t channels,
    72     uint_t samplerate);
     70aubio_filter_t *new_aubio_filter_c_weighting (uint_t samplerate);
    7371
    7472/** set feedback and feedforward coefficients of a C-weighting filter
  • src/temporal/filter.c

    r0536612 rf658288  
    4949aubio_filter_do (aubio_filter_t * f, fvec_t * in)
    5050{
    51   uint_t i, j, l, order = f->order;
    52   lsmp_t *x;
    53   lsmp_t *y;
    54   lsmp_t *a = f->a->data[0];
    55   lsmp_t *b = f->b->data[0];
     51  uint_t j, l, order = f->order;
     52  lsmp_t *x = f->x->data;
     53  lsmp_t *y = f->y->data;
     54  lsmp_t *a = f->a->data;
     55  lsmp_t *b = f->b->data;
    5656
    57   for (i = 0; i < in->channels; i++) {
    58     x = f->x->data[i];
    59     y = f->y->data[i];
    60     for (j = 0; j < in->length; j++) {
    61       /* new input */
    62       x[0] = KILL_DENORMAL (in->data[i][j]);
    63       y[0] = b[0] * x[0];
    64       for (l = 1; l < order; l++) {
    65         y[0] += b[l] * x[l];
    66         y[0] -= a[l] * y[l];
    67       }
    68       /* new output */
    69       in->data[i][j] = y[0];
    70       /* store for next sample */
    71       for (l = order - 1; l > 0; l--) {
    72         x[l] = x[l - 1];
    73         y[l] = y[l - 1];
    74       }
     57  for (j = 0; j < in->length; j++) {
     58    /* new input */
     59    x[0] = KILL_DENORMAL (in->data[j]);
     60    y[0] = b[0] * x[0];
     61    for (l = 1; l < order; l++) {
     62      y[0] += b[l] * x[l];
     63      y[0] -= a[l] * y[l];
    7564    }
    76     /* store for next run */
    77     f->x->data[i] = x;
    78     f->y->data[i] = y;
     65    /* new output */
     66    in->data[j] = y[0];
     67    /* store for next sample */
     68    for (l = order - 1; l > 0; l--) {
     69      x[l] = x[l - 1];
     70      y[l] = y[l - 1];
     71    }
    7972  }
    8073}
     
    8477aubio_filter_do_filtfilt (aubio_filter_t * f, fvec_t * in, fvec_t * tmp)
    8578{
    86   uint_t j, i = 0;
     79  uint_t j;
    8780  uint_t length = in->length;
    8881  /* apply filtering */
     
    9184  /* mirror */
    9285  for (j = 0; j < length; j++)
    93     tmp->data[i][length - j - 1] = in->data[i][j];
     86    tmp->data[length - j - 1] = in->data[j];
    9487  /* apply filtering on mirrored */
    9588  aubio_filter_do (f, tmp);
     
    9790  /* invert back */
    9891  for (j = 0; j < length; j++)
    99     in->data[i][j] = tmp->data[i][length - j - 1];
     92    in->data[j] = tmp->data[length - j - 1];
    10093}
    10194
     
    139132
    140133aubio_filter_t *
    141 new_aubio_filter (uint_t order, uint_t channels)
     134new_aubio_filter (uint_t order)
    142135{
    143136  aubio_filter_t *f = AUBIO_NEW (aubio_filter_t);
    144   f->x = new_lvec (order, channels);
    145   f->y = new_lvec (order, channels);
    146   f->a = new_lvec (order, 1);
    147   f->b = new_lvec (order, 1);
     137  f->x = new_lvec (order);
     138  f->y = new_lvec (order);
     139  f->a = new_lvec (order);
     140  f->b = new_lvec (order);
    148141  /* by default, samplerate is not set */
    149142  f->samplerate = 0;
    150143  f->order = order;
    151144  /* set default to identity */
    152   f->a->data[0][1] = 1.;
     145  f->a->data[1] = 1.;
    153146  return f;
    154147}
  • src/temporal/filter.h

    r0536612 rf658288  
    2626  Digital filter
    2727
    28   This object stores a digital filter of order \f$n\f$ for \f$c\f$ channels.
     28  This object stores a digital filter of order \f$n\f$.
    2929  It contains the following data:
    3030    - \f$ n*1 b_i \f$ feedforward coefficients
     
    151151/** create new filter object
    152152
    153   This function creates a new ::aubio_filter_t object, given an order
    154   and a specific number of channels.
     153  This function creates a new ::aubio_filter_t object, given the order of the
     154  filter.
    155155
    156156  \param order order of the filter (number of coefficients)
    157   \param channels number of channels to allocate
    158157
    159158  \return the newly created filter object
    160159
    161160*/
    162 aubio_filter_t *new_aubio_filter (uint_t order, uint_t channels);
     161aubio_filter_t *new_aubio_filter (uint_t order);
    163162
    164163/** delete a filter object
  • src/temporal/resampler.c

    r0536612 rf658288  
    6161aubio_resampler_do (aubio_resampler_t * s, fvec_t * input, fvec_t * output)
    6262{
    63   uint_t i;
    6463  s->proc->input_frames = input->length;
    6564  s->proc->output_frames = output->length;
    6665  s->proc->src_ratio = (double) s->ratio;
    67   for (i = 0; i < input->channels; i++) {
    68     /* make SRC_PROC data point to input outputs */
    69     s->proc->data_in = (float *) input->data[i];
    70     s->proc->data_out = (float *) output->data[i];
    71     /* do resampling */
    72     src_process (s->stat, s->proc);
    73   }
     66  /* make SRC_PROC data point to input outputs */
     67  s->proc->data_in = (float *) input->data;
     68  s->proc->data_out = (float *) output->data;
     69  /* do resampling */
     70  src_process (s->stat, s->proc);
    7471}
    7572
     
    8784
    8885void
    89 del_aubio_resampler (aubio_resampler_t * s)
     86del_aubio_resampler (aubio_resampler_t * s UNUSED)
    9087{
    9188}
    9289
    9390void
    94 aubio_resampler_do (aubio_resampler_t * s, fvec_t * input, fvec_t * output)
     91aubio_resampler_do (aubio_resampler_t * s UNUSED, fvec_t * input UNUSED, fvec_t * output UNUSED)
    9592{
    9693}
  • src/utils/hist.c

    r0536612 rf658288  
    3232  fvec_t * hist;
    3333  uint_t nelems;
    34   uint_t channels;
    3534  fvec_t * cent;
    3635  aubio_scale_t *scaler;
     
    4039 * Object creation/deletion calls
    4140 */
    42 aubio_hist_t * new_aubio_hist (smpl_t ilow, smpl_t ihig, uint_t nelems, uint_t channels){
     41aubio_hist_t * new_aubio_hist (smpl_t ilow, smpl_t ihig, uint_t nelems){
    4342  aubio_hist_t * s = AUBIO_NEW(aubio_hist_t);
    4443  smpl_t step = (ihig-ilow)/(smpl_t)(nelems);
    4544  smpl_t accum = step;
    4645  uint_t i;
    47   s->channels = channels;
    4846  s->nelems = nelems;
    49   s->hist = new_fvec(nelems, channels);
    50   s->cent = new_fvec(nelems, 1);
     47  s->hist = new_fvec(nelems);
     48  s->cent = new_fvec(nelems);
    5149
    5250  /* use scale to map ilow/ihig -> 0/nelems */
    5351  s->scaler = new_aubio_scale(ilow,ihig,0,nelems);
    5452  /* calculate centers now once */
    55   s->cent->data[0][0] = ilow + 0.5 * step;
     53  s->cent->data[0] = ilow + 0.5 * step;
    5654  for (i=1; i < s->nelems; i++, accum+=step )
    57     s->cent->data[0][i] = s->cent->data[0][0] + accum;
     55    s->cent->data[i] = s->cent->data[0] + accum;
    5856
    5957  return s;
     
    7169 */
    7270void aubio_hist_do (aubio_hist_t *s, fvec_t *input) {
    73   uint_t i,j;
     71  uint_t j;
    7472  sint_t tmp = 0;
    7573  aubio_scale_do(s->scaler, input);
    7674  /* reset data */
    77   for (i=0; i < s->channels; i++)
    78     for (j=0; j < s->nelems; j++)
    79       s->hist->data[i][j] = 0;
     75  fvec_zeros(s->hist);
    8076  /* run accum */
    81   for (i=0; i < input->channels; i++)
    82     for (j=0;  j < input->length; j++)
    83     {
    84       tmp = (sint_t)FLOOR(input->data[i][j]);
    85       if ((tmp >= 0) && (tmp < (sint_t)s->nelems))
    86         s->hist->data[i][tmp] += 1;
     77  for (j=0;  j < input->length; j++)
     78  {
     79    tmp = (sint_t)FLOOR(input->data[j]);
     80    if ((tmp >= 0) && (tmp < (sint_t)s->nelems)) {
     81      s->hist->data[tmp] += 1;
    8782    }
     83  }
    8884}
    8985
    9086void aubio_hist_do_notnull (aubio_hist_t *s, fvec_t *input) {
    91   uint_t i,j;
     87  uint_t j;
    9288  sint_t tmp = 0;
    9389  aubio_scale_do(s->scaler, input);
    9490  /* reset data */
    95   for (i=0; i < s->channels; i++)
    96     for (j=0; j < s->nelems; j++)
    97       s->hist->data[i][j] = 0;
     91  fvec_zeros(s->hist);
    9892  /* run accum */
    99   for (i=0; i < input->channels; i++)
    100     for (j=0;  j < input->length; j++) {
    101       if (input->data[i][j] != 0) {
    102         tmp = (sint_t)FLOOR(input->data[i][j]);
    103         if ((tmp >= 0) && (tmp < (sint_t)s->nelems))
    104           s->hist->data[i][tmp] += 1;
    105       }
     93  for (j=0;  j < input->length; j++) {
     94    if (input->data[j] != 0) {
     95      tmp = (sint_t)FLOOR(input->data[j]);
     96      if ((tmp >= 0) && (tmp < (sint_t)s->nelems))
     97        s->hist->data[tmp] += 1;
    10698    }
     99  }
    107100}
    108101
    109102
    110103void aubio_hist_dyn_notnull (aubio_hist_t *s, fvec_t *input) {
    111   uint_t i,j;
     104  uint_t i;
    112105  sint_t tmp = 0;
    113106  smpl_t ilow = fvec_min(input);
     
    119112
    120113  /* recalculate centers */
    121   s->cent->data[0][0] = ilow + 0.5f * step;
     114  s->cent->data[0] = ilow + 0.5f * step;
    122115  for (i=1; i < s->nelems; i++)
    123     s->cent->data[0][i] = s->cent->data[0][0] + i * step;
     116    s->cent->data[i] = s->cent->data[0] + i * step;
    124117
    125118  /* scale */
     
    127120
    128121  /* reset data */
    129   for (i=0; i < s->channels; i++)
    130     for (j=0; j < s->nelems; j++)
    131       s->hist->data[i][j] = 0;
     122  fvec_zeros(s->hist);
    132123  /* run accum */
    133   for (i=0; i < input->channels; i++)
    134     for (j=0;  j < input->length; j++) {
    135       if (input->data[i][j] != 0) {
    136         tmp = (sint_t)FLOOR(input->data[i][j]);
    137         if ((tmp >= 0) && (tmp < (sint_t)s->nelems))
    138           s->hist->data[i][tmp] += 1;
    139       }
     124  for (i=0;  i < input->length; i++) {
     125    if (input->data[i] != 0) {
     126      tmp = (sint_t)FLOOR(input->data[i]);
     127      if ((tmp >= 0) && (tmp < (sint_t)s->nelems))
     128        s->hist->data[tmp] += 1;
    140129    }
     130  }
    141131}
    142132
    143133void aubio_hist_weight (aubio_hist_t *s) {
    144   uint_t i,j;
    145   for (i=0; i < s->channels; i++)
    146     for (j=0; j < s->nelems; j++) {
    147       s->hist->data[i][j] *= s->cent->data[0][j];
    148     }
     134  uint_t j;
     135  for (j=0; j < s->nelems; j++) {
     136    s->hist->data[j] *= s->cent->data[j];
     137  }
    149138}
    150139
    151140smpl_t aubio_hist_mean (aubio_hist_t *s) {
    152   uint_t i,j;
     141  uint_t j;
    153142  smpl_t tmp = 0.0;
    154   for (i=0; i < s->channels; i++)
    155     for (j=0; j < s->nelems; j++)
    156       tmp += s->hist->data[i][j];
     143  for (j=0; j < s->nelems; j++)
     144    tmp += s->hist->data[j];
    157145  return tmp/(smpl_t)(s->nelems);
    158146}
  • src/utils/hist.h

    r0536612 rf658288  
    4040 * \param fhig maximum input
    4141 * \param nelems number of histogram columns
    42  * \param channels number of channels
    4342 */
    44 aubio_hist_t * new_aubio_hist(smpl_t flow, smpl_t fhig, uint_t nelems, uint_t channels);
     43aubio_hist_t * new_aubio_hist(smpl_t flow, smpl_t fhig, uint_t nelems);
    4544/** histogram deletion */
    4645void del_aubio_hist(aubio_hist_t *s);
  • src/utils/scale.c

    r0536612 rf658288  
    7070void aubio_scale_do (aubio_scale_t *s, fvec_t *input)
    7171{
    72   uint_t i, j;
    73   for (i=0; i < input->channels; i++){
    74     for (j=0;  j < input->length; j++){
    75       input->data[i][j] -= s->ilow;
    76       input->data[i][j] *= s->scaler;
    77       input->data[i][j] += s->olow;
    78     }
     72  uint_t j;
     73  for (j=0;  j < input->length; j++){
     74    input->data[j] -= s->ilow;
     75    input->data[j] *= s->scaler;
     76    input->data[j] += s->olow;
    7977  }
    8078}
  • src/vecutils.c

    r0536612 rf658288  
    99void TYPE ## _ ## OPNAME (TYPE ## _t *o) \
    1010{ \
    11   uint_t i,j; \
    12   for (i = 0; i < o->channels; i++) { \
    13     for (j = 0; j < o->length; j++) { \
    14       o->OBJ[i][j] = OP (o->OBJ[i][j]); \
    15     } \
     11  uint_t j; \
     12  for (j = 0; j < o->length; j++) { \
     13    o->OBJ[j] = OP (o->OBJ[j]); \
    1614  } \
    1715}
     
    3533void fvec_pow (fvec_t *s, smpl_t power)
    3634{
    37   uint_t i,j;
    38   for (i = 0; i < s->channels; i++) {
    39     for (j = 0; j < s->length; j++) {
    40       s->data[i][j] = POW(s->data[i][j], power);
    41     }
     35  uint_t j;
     36  for (j = 0; j < s->length; j++) {
     37    s->data[j] = POW(s->data[j], power);
    4238  }
    4339}
     
    4541void cvec_pow (cvec_t *s, smpl_t power)
    4642{
    47   uint_t i,j;
    48   for (i = 0; i < s->channels; i++) {
    49     for (j = 0; j < s->length; j++) {
    50       s->norm[i][j] = POW(s->norm[i][j], power);
    51     }
     43  uint_t j;
     44  for (j = 0; j < s->length; j++) {
     45    s->norm[j] = POW(s->norm[j], power);
    5246  }
    5347}
  • swig/aubio.i

    r0536612 rf658288  
    1212
    1313/* fvec */
    14 fvec_t * new_fvec(uint_t length, uint_t channels);
     14fvec_t * new_fvec(uint_t length);
    1515void del_fvec(fvec_t *s);
    16 smpl_t fvec_read_sample(fvec_t *s, uint_t channel, uint_t position);
    17 void fvec_write_sample(fvec_t *s, smpl_t data, uint_t channel, uint_t position);
    18 smpl_t * fvec_get_channel(fvec_t *s, uint_t channel);
    19 void fvec_put_channel(fvec_t *s, smpl_t * data, uint_t channel);
    20 smpl_t ** fvec_get_data(fvec_t *s);
     16smpl_t fvec_read_sample(fvec_t *s, uint_t position);
     17void fvec_write_sample(fvec_t *s, smpl_t data, uint_t position);
     18smpl_t * fvec_get_data(fvec_t *s);
    2119
    2220/* cvec */
    23 cvec_t * new_cvec(uint_t length, uint_t channels);
     21cvec_t * new_cvec(uint_t length);
    2422void del_cvec(cvec_t *s);
    25 void cvec_write_norm(cvec_t *s, smpl_t data, uint_t channel, uint_t position);
    26 void cvec_write_phas(cvec_t *s, smpl_t data, uint_t channel, uint_t position);
    27 smpl_t cvec_read_norm(cvec_t *s, uint_t channel, uint_t position);
    28 smpl_t cvec_read_phas(cvec_t *s, uint_t channel, uint_t position);
    29 void cvec_put_norm_channel(cvec_t *s, smpl_t * data, uint_t channel);
    30 void cvec_put_phas_channel(cvec_t *s, smpl_t * data, uint_t channel);
    31 smpl_t * cvec_get_norm_channel(cvec_t *s, uint_t channel);
    32 smpl_t * cvec_get_phas_channel(cvec_t *s, uint_t channel);
    33 smpl_t ** cvec_get_norm(cvec_t *s);
    34 smpl_t ** cvec_get_phas(cvec_t *s);
     23void cvec_write_norm(cvec_t *s, smpl_t data, uint_t position);
     24void cvec_write_phas(cvec_t *s, smpl_t data, uint_t position);
     25smpl_t cvec_read_norm(cvec_t *s, uint_t position);
     26smpl_t cvec_read_phas(cvec_t *s, uint_t position);
     27smpl_t * cvec_get_norm(cvec_t *s);
     28smpl_t * cvec_get_phas(cvec_t *s);
    3529
    3630
    3731/* fft */
    38 aubio_fft_t * new_aubio_fft(uint_t size, uint_t channels);
     32aubio_fft_t * new_aubio_fft(uint_t size);
    3933void del_aubio_fft(aubio_fft_t * s);
    4034void aubio_fft_do (aubio_fft_t *s, fvec_t * input, cvec_t * spectrum);
     
    5044
    5145/* filter */
    52 aubio_filter_t * new_aubio_filter(uint_t order, uint_t channels);
     46aubio_filter_t * new_aubio_filter(uint_t order);
    5347void aubio_filter_do(aubio_filter_t * b, fvec_t * in);
    5448void aubio_filter_do_outplace(aubio_filter_t * b, fvec_t * in, fvec_t * out);
     
    5751
    5852/* a_weighting */
    59 aubio_filter_t * new_aubio_filter_a_weighting (uint_t channels, uint_t samplerate);
     53aubio_filter_t * new_aubio_filter_a_weighting (uint_t samplerate);
    6054uint_t aubio_filter_set_a_weighting (aubio_filter_t * b, uint_t samplerate);
    6155
    6256/* c_weighting */
    63 aubio_filter_t * new_aubio_filter_c_weighting (uint_t channels, uint_t samplerate);
     57aubio_filter_t * new_aubio_filter_c_weighting (uint_t samplerate);
    6458uint_t aubio_filter_set_c_weighting (aubio_filter_t * b, uint_t samplerate);
    6559
    6660/* biquad */
    67 aubio_filter_t * new_aubio_filter_biquad(lsmp_t b1, lsmp_t b2, lsmp_t b3, lsmp_t a2, lsmp_t a3, uint_t channels);
     61aubio_filter_t * new_aubio_filter_biquad(lsmp_t b1, lsmp_t b2, lsmp_t b3, lsmp_t a2, lsmp_t a3);
    6862uint_t aubio_filter_set_biquad (aubio_filter_t * b, lsmp_t b1, lsmp_t b2, lsmp_t b3, lsmp_t a2, lsmp_t a3);
    6963
     
    9488
    9589/* pvoc */
    96 aubio_pvoc_t * new_aubio_pvoc (uint_t win_s, uint_t hop_s, uint_t channels);
     90aubio_pvoc_t * new_aubio_pvoc (uint_t win_s, uint_t hop_s);
    9791void del_aubio_pvoc(aubio_pvoc_t *pv);
    9892void aubio_pvoc_do(aubio_pvoc_t *pv, fvec_t *in, cvec_t * fftgrain);
     
    10195/* pitch detection */
    10296aubio_pitch_t *new_aubio_pitch (char *pitch_mode,
    103     uint_t bufsize, uint_t hopsize, uint_t channels, uint_t samplerate);
     97    uint_t bufsize, uint_t hopsize, uint_t samplerate);
    10498void aubio_pitch_do (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf);
    10599uint_t aubio_pitch_set_tolerance(aubio_pitch_t *p, smpl_t thres);
     
    109103/* tempo */
    110104aubio_tempo_t * new_aubio_tempo (char_t * mode,
    111     uint_t buf_size, uint_t hop_size, uint_t channels, uint_t samplerate);
     105    uint_t buf_size, uint_t hop_size, uint_t samplerate);
    112106void aubio_tempo_do (aubio_tempo_t *o, fvec_t * input, fvec_t * tempo);
    113107uint_t aubio_tempo_set_silence(aubio_tempo_t * o, smpl_t silence);
     
    120114void aubio_specdesc_do (aubio_specdesc_t * o, cvec_t * fftgrain,
    121115  fvec_t * desc);
    122 aubio_specdesc_t *new_aubio_specdesc (char_t * method, uint_t buf_size,
    123   uint_t channels);
     116aubio_specdesc_t *new_aubio_specdesc (char_t * method, uint_t buf_size);
    124117void del_aubio_specdesc (aubio_specdesc_t * o);
    125118
    126119/* peak picker */
    127 aubio_peakpicker_t * new_aubio_peakpicker(uint_t channels);
     120aubio_peakpicker_t * new_aubio_peakpicker();
    128121void aubio_peakpicker_do(aubio_peakpicker_t * p, fvec_t * in, fvec_t * out);
    129122fvec_t * aubio_peakpicker_get_thresholded_input(aubio_peakpicker_t * p);
     
    140133aubio_sndfile_t * new_aubio_sndfile_wo(aubio_sndfile_t * existingfile, const char * outputname);
    141134void aubio_sndfile_info(aubio_sndfile_t * file);
    142 int aubio_sndfile_write(aubio_sndfile_t * file, int frames, fvec_t * write);
    143 int aubio_sndfile_read(aubio_sndfile_t * file, int frames, fvec_t * read);
     135int aubio_sndfile_write(aubio_sndfile_t * file, int frames, fvec_t ** write);
     136int aubio_sndfile_read(aubio_sndfile_t * file, int frames, fvec_t ** read);
    144137int del_aubio_sndfile(aubio_sndfile_t * file);
    145138uint_t aubio_sndfile_channels(aubio_sndfile_t * file);
  • tests/src/temporal/test-aweighting.c

    r0536612 rf658288  
    88  uint_t nrates = 6;
    99  uint_t samplerate, i = 0;
    10   uint_t channels = 2;
    1110
    1211  for ( samplerate = rates[i]; i < nrates ; i++ ) {
    13     f = new_aubio_filter_a_weighting (channels, samplerate);
     12    f = new_aubio_filter_a_weighting (samplerate);
    1413    del_aubio_filter (f);
    1514
    16     f = new_aubio_filter (7, channels*2);
     15    f = new_aubio_filter (7);
    1716    aubio_filter_set_a_weighting (f, samplerate);
    1817    del_aubio_filter (f);
     
    2019
    2120  // samplerate unknown
    22   f = new_aubio_filter_a_weighting (channels, 4200);
     21  f = new_aubio_filter_a_weighting (4200);
    2322  del_aubio_filter (f);
    2423
    2524  // order to small
    26   f = new_aubio_filter (2, channels*2);
     25  f = new_aubio_filter (2);
    2726  aubio_filter_set_a_weighting (f, samplerate);
    2827  del_aubio_filter (f);
    2928
    3029  // order to big
    31   f = new_aubio_filter (12, channels*2);
     30  f = new_aubio_filter (12);
    3231  aubio_filter_set_a_weighting (f, samplerate);
    3332  del_aubio_filter (f);
  • tests/src/temporal/test-cweighting.c

    r0536612 rf658288  
    88  uint_t nrates = 6;
    99  uint_t samplerate, i = 0;
    10   uint_t channels = 2;
    1110
    1211  for ( samplerate = rates[i]; i < nrates ; i++ ) {
    13     f = new_aubio_filter_c_weighting (channels, samplerate);
     12    f = new_aubio_filter_c_weighting (samplerate);
    1413    del_aubio_filter (f);
    1514
    16     f = new_aubio_filter (5, channels*2);
     15    f = new_aubio_filter (5);
    1716    aubio_filter_set_c_weighting (f, samplerate);
    1817    del_aubio_filter (f);
     
    2019
    2120  // samplerate unknown
    22   f = new_aubio_filter_c_weighting (channels, 4200);
     21  f = new_aubio_filter_c_weighting (4200);
    2322  del_aubio_filter (f);
    2423
    2524  // order to small
    26   f = new_aubio_filter (2, channels*2);
     25  f = new_aubio_filter (2);
    2726  aubio_filter_set_c_weighting (f, samplerate);
    2827  del_aubio_filter (f);
    2928
    3029  // order to big
    31   f = new_aubio_filter (12, channels*2);
     30  f = new_aubio_filter (12);
    3231  aubio_filter_set_c_weighting (f, samplerate);
    3332  del_aubio_filter (f);
  • tests/src/test-beattracking.c

    r0536612 rf658288  
    77        /* allocate some memory */
    88        uint_t win_s      = 1024;                       /* window size */
    9         uint_t channels   = 1;                          /* number of channel */
    10         fvec_t * in       = new_fvec (win_s, channels); /* input buffer */
    11         fvec_t * out      = new_fvec (win_s/4, channels);     /* input buffer */
     9        fvec_t * in       = new_fvec (win_s); /* input buffer */
     10        fvec_t * out      = new_fvec (win_s/4);     /* input buffer */
    1211 
    1312        /* allocate fft and other memory space */
    14         aubio_beattracking_t * tempo  = new_aubio_beattracking(win_s, channels);
     13        aubio_beattracking_t * tempo  = new_aubio_beattracking(win_s);
    1514
    1615        uint_t i = 0;
  • tests/src/test-biquad.c

    r0536612 rf658288  
    44        /* allocate some memory */
    55        uint_t win_s      = 1024;                       /* window size */
    6         uint_t channels   = 1;                          /* number of channel */
    7         fvec_t * in       = new_fvec (win_s, channels); /* input buffer */
    8         aubio_filter_t * o = new_aubio_filter_biquad(0.3,0.2,0.1,0.2,0.3, channels);
     6        fvec_t * in       = new_fvec (win_s); /* input buffer */
     7        aubio_filter_t * o = new_aubio_filter_biquad(0.3,0.2,0.1,0.2,0.3);
    98
    109        aubio_filter_do_filtfilt(o,in,in);
  • tests/src/test-cvec.c

    r0536612 rf658288  
    44        /* allocate some memory */
    55        uint_t win_s      = 1024;                       /* window size */
    6         uint_t channels   = 1;                          /* number of channel */
    7         cvec_t * sp       = new_cvec (win_s, channels); /* input buffer */
     6        cvec_t * sp       = new_cvec (win_s); /* input buffer */
    87        del_cvec(sp);
    98
  • tests/src/test-fft.c

    r0536612 rf658288  
    55        /* allocate some memory */
    66        uint_t win_s      = 8;                       /* window size        */
    7         uint_t channels   = 1;                        /* number of channels */
    8         fvec_t * in       = new_fvec (win_s, channels); /* input buffer       */
    9         cvec_t * fftgrain = new_cvec (win_s, channels); /* fft norm and phase */
    10         fvec_t * out      = new_fvec (win_s, channels); /* output buffer      */
    11         in->data[0][0] = 1;
    12         in->data[0][1] = 2;
    13         in->data[0][2] = 3;
    14         in->data[0][3] = 4;
    15         in->data[0][4] = 5;
    16         in->data[0][5] = 6;
    17         in->data[0][6] = 5;
    18         in->data[0][7] = 6;
     7        fvec_t * in       = new_fvec (win_s); /* input buffer       */
     8        cvec_t * fftgrain = new_cvec (win_s); /* fft norm and phase */
     9        fvec_t * out      = new_fvec (win_s); /* output buffer      */
     10        in->data[0] = 1;
     11        in->data[1] = 2;
     12        in->data[2] = 3;
     13        in->data[3] = 4;
     14        in->data[4] = 5;
     15        in->data[5] = 6;
     16        in->data[6] = 5;
     17        in->data[7] = 6;
    1918        /* allocate fft and other memory space */
    20         aubio_fft_t * fft = new_aubio_fft(win_s,channels);
     19        aubio_fft_t * fft = new_aubio_fft(win_s);
    2120        /* fill input with some data */
    2221        fvec_print(in);
  • tests/src/test-filter.c

    r0536612 rf658288  
    66  /* allocate some memory */
    77  uint_t win_s = 32;            /* window size */
    8   uint_t channels = 1;          /* number of channel */
    9   fvec_t *in = new_fvec (win_s, channels);      /* input buffer */
    10   fvec_t *out = new_fvec (win_s, channels);     /* input buffer */
     8  fvec_t *in = new_fvec (win_s);      /* input buffer */
     9  fvec_t *out = new_fvec (win_s);     /* input buffer */
    1110
    1211
    13   aubio_filter_t *o = new_aubio_filter_c_weighting (channels, 44100);
    14   in->data[0][12] = 0.5;
     12  aubio_filter_t *o = new_aubio_filter_c_weighting (44100);
     13  in->data[12] = 0.5;
    1514  fvec_print (in);
    1615  aubio_filter_do (o, in);
     
    1817  del_aubio_filter (o);
    1918
    20   o = new_aubio_filter_c_weighting (channels, 44100);
    21   in->data[0][12] = 0.5;
     19  o = new_aubio_filter_c_weighting (44100);
     20  in->data[12] = 0.5;
    2221  fvec_print (in);
    2322  aubio_filter_do_outplace (o, in, out);
     
    2524  del_aubio_filter (o);
    2625
    27   o = new_aubio_filter_c_weighting (channels, 44100);
    28   in->data[0][12] = 0.5;
     26  o = new_aubio_filter_c_weighting (44100);
     27  in->data[12] = 0.5;
    2928  fvec_print (in);
    3029  aubio_filter_do_filtfilt (o, in, out);
  • tests/src/test-filterbank.c

    r0536612 rf658288  
    99  /* allocate some memory */
    1010  uint_t win_s = 1024;          /* window size */
    11   uint_t channels = 2;          /* number of channel */
    1211  uint_t n_filters = 13;        /* number of filters */
    13   cvec_t *in = new_cvec (win_s, channels);      /* input buffer */
    14   fvec_t *out = new_fvec (win_s, channels);     /* input buffer */
    15   fvec_t *coeffs = NULL;
     12  cvec_t *in = new_cvec (win_s);      /* input buffer */
     13  fvec_t *out = new_fvec (win_s);     /* input buffer */
     14  fmat_t *coeffs = NULL;
    1615
    1716  /* allocate fft and other memory space */
     
    2322  }
    2423
     24  /*
    2525  if (fvec_max (coeffs) != 0.) {
    2626    return -1;
     
    3030    return -1;
    3131  }
     32  */
    3233
    33   fvec_print (coeffs);
     34  fmat_print (coeffs);
    3435
    3536  aubio_filterbank_do (o, in, out);
  • tests/src/test-filterbank_mel.c

    r0536612 rf658288  
    99  /* allocate some memory */
    1010  uint_t win_s = 512;           /* fft size */
    11   uint_t channels = 2;          /* number of channel */
    1211  uint_t n_filters = 40;        /* number of filters */
    13   cvec_t *in = new_cvec (win_s, channels);      /* input buffer */
    14   fvec_t *out = new_fvec (win_s, channels);     /* input buffer */
    15   fvec_t *coeffs = NULL;
     12  cvec_t *in = new_cvec (win_s);      /* input buffer */
     13  fvec_t *out = new_fvec (win_s);     /* input buffer */
     14  fmat_t *coeffs = NULL;
    1615  smpl_t samplerate = 16000.;
    1716
     
    2726  }
    2827
    29   //fvec_print (coeffs);
     28  //fmat_print (coeffs);
    3029
    3130  //fprintf(stderr, "%f\n", fvec_sum(coeffs));
  • tests/src/test-fvec.c

    r0536612 rf658288  
    44        /* allocate some memory */
    55        uint_t win_s      = 1024;                       /* window size */
    6         uint_t channels   = 1;                          /* number of channel */
    7         fvec_t * in       = new_fvec (win_s, channels); /* input buffer */
     6        fvec_t * in       = new_fvec (win_s); /* input buffer */
    87        del_fvec(in);
    98
  • tests/src/test-hist.c

    r0536612 rf658288  
    88  uint_t length;
    99  for (length = 1; length < 10; length ++ ) {
    10     aubio_hist_t *o = new_aubio_hist(0, 1, length, 5);
     10    aubio_hist_t *o = new_aubio_hist(0, 1, length);
    1111    fvec_t *t = new_aubio_window("hanning", length);
    1212    aubio_hist_do(o,t);
  • tests/src/test-mfcc.c

    r0536612 rf658288  
    66  /* allocate some memory */
    77  uint_t win_s = 512;           /* fft size */
    8   uint_t channels = 1;          /* number of channel */
    98  uint_t n_filters = 40;        /* number of filters */
    109  uint_t n_coefs = 13;          /* number of coefficients */
    11   cvec_t *in = new_cvec (win_s, channels);      /* input buffer */
    12   fvec_t *out = new_fvec (n_coefs, channels);     /* input buffer */
     10  cvec_t *in = new_cvec (win_s);      /* input buffer */
     11  fvec_t *out = new_fvec (n_coefs);     /* input buffer */
    1312  smpl_t samplerate = 16000.;
    1413
  • tests/src/test-onset.c

    r0536612 rf658288  
    44        /* allocate some memory */
    55        uint_t win_s      = 1024;                       /* window size */
    6         uint_t channels   = 1;                          /* number of channel */
    7         fvec_t * in       = new_fvec (win_s/4, channels); /* input buffer */
    8         fvec_t * out      = new_fvec (2, channels);     /* input buffer */
    9         aubio_onset_t * onset  = new_aubio_onset("complex", win_s, win_s/4, channels, 44100.);
     6        fvec_t * in       = new_fvec (win_s/4); /* input buffer */
     7        fvec_t * out      = new_fvec (2);     /* input buffer */
     8        aubio_onset_t * onset  = new_aubio_onset("complex", win_s, win_s/4, 44100.);
    109        uint_t i = 0;
    1110
  • tests/src/test-onsetdetection.c

    r0536612 rf658288  
    88{
    99  uint_t win_s = 1024;          /* window size */
    10   uint_t channels = 1;          /* number of channel */
    11   cvec_t *in = new_cvec (win_s, channels);      /* input buffer */
    12   fvec_t *out = new_fvec (1, channels); /* input buffer */
     10  cvec_t *in = new_cvec (win_s);      /* input buffer */
     11  fvec_t *out = new_fvec (1); /* input buffer */
    1312
    1413  aubio_specdesc_t *o;
    1514 
    16   o = new_aubio_specdesc ("energy", win_s, channels);
     15  o = new_aubio_specdesc ("energy", win_s);
    1716  aubio_specdesc_do (o, in, out);
    1817  del_aubio_specdesc (o);
    1918
    20   o = new_aubio_specdesc ("energy", win_s, channels);
     19  o = new_aubio_specdesc ("energy", win_s);
    2120  aubio_specdesc_do (o, in, out);
    2221  del_aubio_specdesc (o);
    2322
    24   o = new_aubio_specdesc ("hfc", win_s, channels);
     23  o = new_aubio_specdesc ("hfc", win_s);
    2524  aubio_specdesc_do (o, in, out);
    2625  del_aubio_specdesc (o);
    2726
    28   o = new_aubio_specdesc ("complex", win_s, channels);
     27  o = new_aubio_specdesc ("complex", win_s);
    2928  aubio_specdesc_do (o, in, out);
    3029  del_aubio_specdesc (o);
    3130
    32   o = new_aubio_specdesc ("phase", win_s, channels);
     31  o = new_aubio_specdesc ("phase", win_s);
    3332  aubio_specdesc_do (o, in, out);
    3433  del_aubio_specdesc (o);
    3534
    36   o = new_aubio_specdesc ("kl", win_s, channels);
     35  o = new_aubio_specdesc ("kl", win_s);
    3736  aubio_specdesc_do (o, in, out);
    3837  del_aubio_specdesc (o);
    3938
    40   o = new_aubio_specdesc ("mkl", win_s, channels);
     39  o = new_aubio_specdesc ("mkl", win_s);
    4140  aubio_specdesc_do (o, in, out);
    4241  del_aubio_specdesc (o);
  • tests/src/test-peakpick.c

    r0536612 rf658288  
    66        /* allocate some memory */
    77        uint_t win_s      = 1024;                       /* window size */
    8         uint_t channels   = 1;                          /* number of channel */
    9         fvec_t * in       = new_fvec (win_s, channels); /* input buffer */
    10         fvec_t * out      = new_fvec (1, channels); /* input buffer */
     8        fvec_t * in       = new_fvec (win_s); /* input buffer */
     9        fvec_t * out      = new_fvec (1); /* input buffer */
    1110        aubio_peakpicker_t * o = new_aubio_peakpicker(1);
    1211        aubio_peakpicker_set_threshold (o, 0.3);
  • tests/src/test-phasevoc-jack.c

    r0536612 rf658288  
    2222uint_t pos      = 0;  /* frames%dspblocksize for jack loop */
    2323
    24 fvec_t * in;
    25 cvec_t * fftgrain;
    26 fvec_t * out;
     24fvec_t * in[2];
     25cvec_t * fftgrain[2];
     26fvec_t * out[2];
    2727
    28 aubio_pvoc_t * pv;
     28aubio_pvoc_t * pv[2];
    2929
    3030int aubio_process(float **input, float **output, int nframes);
     
    3232int main(){
    3333        /* allocate some memory */
    34         in       = new_fvec (hop_s, channels); /* input buffer       */
    35         fftgrain = new_cvec (win_s, channels); /* fft norm and phase */
    36         out      = new_fvec (hop_s, channels); /* output buffer      */
     34  uint_t i;
     35    for (i=0;i<channels;i++) {
     36        in[i]       = new_fvec (hop_s); /* input buffer       */
     37        fftgrain[i] = new_cvec (win_s); /* fft norm and phase */
     38        out[i]      = new_fvec (hop_s); /* output buffer      */
    3739        /* allocate fft and other memory space */
    38         pv = new_aubio_pvoc(win_s,hop_s,channels);
     40        pv[i] = new_aubio_pvoc(win_s,hop_s);
     41    }
    3942
    4043#ifdef HAVE_JACK
     
    5356#endif
    5457       
    55         del_aubio_pvoc(pv);
    56         del_cvec(fftgrain);
    57         del_fvec(in);
    58         del_fvec(out);
     58    for (i=0;i<channels;i++) {
     59        del_aubio_pvoc(pv[i]);
     60        del_cvec(fftgrain[i]);
     61        del_fvec(in[i]);
     62        del_fvec(out[i]);
     63    }
    5964        aubio_cleanup();
    6065        return 0;
     
    6772    for (i=0;i<channels;i++) {
    6873      /* write input to datanew */
    69       fvec_write_sample(in, input[i][j], i, pos);
     74      fvec_write_sample(in[i], input[i][j], pos);
    7075      /* put synthnew in output */
    71       output[i][j] = fvec_read_sample(out, i, pos);
     76      output[i][j] = fvec_read_sample(out[i], pos);
    7277    }
    7378    /*time for fft*/
    7479    if (pos == hop_s-1) {
    7580      /* block loop */
    76       aubio_pvoc_do (pv,in, fftgrain);
     81    for (i=0;i<channels;i++) {
     82      aubio_pvoc_do (pv[i], in[i], fftgrain[i]);
    7783      // zero phases of first channel
    78       for (i=0;i<fftgrain->length;i++) fftgrain->phas[0][i] = 0.;
     84      for (i=0;i<fftgrain[i]->length;i++) fftgrain[0]->phas[i] = 0.;
    7985      // double phases of second channel
    80       for (i=0;i<fftgrain->length;i++) {
    81         fftgrain->phas[1][i] =
    82           aubio_unwrap2pi (fftgrain->phas[1][i] * 2.);
     86      for (i=0;i<fftgrain[i]->length;i++) {
     87        fftgrain[1]->phas[i] =
     88          aubio_unwrap2pi (fftgrain[1]->phas[i] * 2.);
    8389      }
    8490      // copy second channel to third one
    85       aubio_pvoc_rdo(pv,fftgrain,out);
     91      aubio_pvoc_rdo(pv[i], fftgrain[i], out[i]);
    8692      pos = -1;
     93    }
    8794    }
    8895    pos++;
  • tests/src/test-phasevoc.c

    r0536612 rf658288  
    77        uint_t win_s    = 1024; /* window size                       */
    88        uint_t hop_s    = 256;  /* hop size                          */
    9         uint_t channels = 4;  /* number of channels                */
    109        /* allocate some memory */
    11         fvec_t * in       = new_fvec (hop_s, channels); /* input buffer       */
    12         cvec_t * fftgrain = new_cvec (win_s, channels); /* fft norm and phase */
    13         fvec_t * out      = new_fvec (hop_s, channels); /* output buffer      */
     10        fvec_t * in       = new_fvec (hop_s); /* input buffer       */
     11        cvec_t * fftgrain = new_cvec (win_s); /* fft norm and phase */
     12        fvec_t * out      = new_fvec (hop_s); /* output buffer      */
    1413        /* allocate fft and other memory space */
    15         aubio_pvoc_t * pv = new_aubio_pvoc(win_s,hop_s,channels);
     14        aubio_pvoc_t * pv = new_aubio_pvoc(win_s,hop_s);
    1615        /* fill input with some data */
    1716        printf("initialised\n");
  • tests/src/test-pitchdetection.c

    r0536612 rf658288  
    88  uint_t hop_s = win_s / 4;     /* hop size */
    99  uint_t samplerate = 44100;    /* samplerate */
    10   uint_t channels = 1;          /* number of channel */
    11   fvec_t *in = new_fvec (hop_s, channels);      /* input buffer */
    12   fvec_t *out = new_fvec (1, channels); /* input buffer */
     10  fvec_t *in = new_fvec (hop_s);      /* input buffer */
     11  fvec_t *out = new_fvec (1); /* input buffer */
    1312  aubio_pitch_t *o =
    14       new_aubio_pitch ("default", win_s, hop_s, channels, samplerate);
     13      new_aubio_pitch ("default", win_s, hop_s, samplerate);
    1514  uint_t i = 0;
    1615
  • tests/src/test-pitchfcomb.c

    r0536612 rf658288  
    77        uint_t win_s      = 1024;                       /* window size */
    88        uint_t hop_s      = win_s/4;                    /* hop size */
    9         uint_t channels   = 3;                          /* number of channel */
    10         fvec_t * in       = new_fvec (hop_s, channels); /* input buffer */
    11         fvec_t * out      = new_fvec (1, channels);
     9        fvec_t * in       = new_fvec (hop_s); /* input buffer */
     10        fvec_t * out      = new_fvec (1);
    1211        aubio_pitchfcomb_t * o  = new_aubio_pitchfcomb (
    13           win_s, hop_s, channels);
     12          win_s, hop_s);
    1413        uint_t i = 0;
    1514
  • tests/src/test-pitchmcomb.c

    r0536612 rf658288  
    77        uint_t win_s      = 1024;                       /* window size */
    88        uint_t hop_s      = win_s/4;                    /* hop size */
    9         uint_t channels   = 1;                          /* number of channel */
    10         cvec_t * in       = new_cvec (win_s, channels); /* input buffer */
    11         fvec_t * out      = new_fvec (1, channels); /* input buffer */
     9        cvec_t * in       = new_cvec (win_s); /* input buffer */
     10        fvec_t * out      = new_fvec (1); /* input buffer */
    1211
    13         aubio_pitchmcomb_t * o  = new_aubio_pitchmcomb(win_s, hop_s, channels);
     12        aubio_pitchmcomb_t * o  = new_aubio_pitchmcomb(win_s, hop_s);
    1413        uint_t i = 0;
    1514
  • tests/src/test-pitchschmitt.c

    r0536612 rf658288  
    66        /* allocate some memory */
    77        uint_t win_s      = 1024;                       /* window size */
    8         fvec_t * in       = new_fvec (win_s, 1); /* input buffer */
    9         fvec_t * out = new_fvec (1, 1); /* input buffer */
     8        fvec_t * in       = new_fvec (win_s); /* input buffer */
     9        fvec_t * out = new_fvec (1); /* input buffer */
    1010        aubio_pitchschmitt_t * o  = new_aubio_pitchschmitt(win_s);
    1111        uint_t i = 0;
  • tests/src/test-pitchyin.c

    r0536612 rf658288  
    66        /* allocate some memory */
    77        uint_t win_s      = 1024;                       /* window size */
    8         uint_t channels   = 1;                          /* number of channel */
    9         fvec_t * in       = new_fvec (win_s, channels); /* input buffer */
    10         fvec_t * out      = new_fvec (win_s/2, channels); /* input buffer */
     8        fvec_t * in       = new_fvec (win_s); /* input buffer */
     9        fvec_t * out      = new_fvec (win_s/2); /* input buffer */
    1110        aubio_pitchyin_t *p = new_aubio_pitchyin (win_s);
    1211        uint_t i = 0;
  • tests/src/test-pitchyinfft.c

    r0536612 rf658288  
    66        /* allocate some memory */
    77        uint_t win_s      = 1024;                       /* window size */
    8         uint_t channels   = 1;                          /* number of channel */
    9         fvec_t * in       = new_fvec (win_s, channels); /* input buffer */
    10         fvec_t * out      = new_fvec (1, channels); /* output pitch periods */
     8        fvec_t * in       = new_fvec (win_s); /* input buffer */
     9        fvec_t * out      = new_fvec (1); /* output pitch periods */
    1110        aubio_pitchyinfft_t * o  = new_aubio_pitchyinfft(win_s);
    1211        aubio_pitchyinfft_set_tolerance (o, 0.2);
  • tests/src/test-resample.c

    r0536612 rf658288  
    77  /* allocate some memory */
    88  uint_t win_s = 1024;          /* window size */
    9   uint_t channels = 1;          /* number of channel */
    109  smpl_t ratio = 0.5;
    11   fvec_t *in = new_fvec (win_s, channels);      /* input buffer */
    12   fvec_t *out = new_fvec ((uint_t) (win_s * ratio), channels);  /* input buffer */
     10  fvec_t *in = new_fvec (win_s);      /* input buffer */
     11  fvec_t *out = new_fvec ((uint_t) (win_s * ratio));  /* input buffer */
    1312  aubio_resampler_t *o = new_aubio_resampler (0.5, 0);
    1413  uint_t i = 0;
  • tests/src/test-scale.c

    r0536612 rf658288  
    66        /* allocate some memory */
    77        uint_t win_s      = 1024;                       /* window size */
    8         uint_t channels   = 1;                          /* number of channel */
    9         fvec_t * in       = new_fvec (win_s, channels); /* input buffer */
     8        fvec_t * in       = new_fvec (win_s); /* input buffer */
    109        aubio_scale_t * o = new_aubio_scale(0,1,2,3);
    1110        aubio_scale_set_limits (o,0,1,2,3);
  • tests/src/test-tempo.c

    r0536612 rf658288  
    55        /* allocate some memory */
    66        uint_t win_s      = 1024;                       /* window size */
    7         uint_t channels   = 1;                          /* number of channel */
    8         fvec_t * in       = new_fvec (win_s, channels); /* input buffer */
    9         fvec_t * out      = new_fvec (2, channels);     /* input buffer */
    10         aubio_tempo_t * o  = new_aubio_tempo("complex", win_s, win_s/4, channels, 44100.);
     7        fvec_t * in       = new_fvec (win_s); /* input buffer */
     8        fvec_t * out      = new_fvec (2);     /* input buffer */
     9        aubio_tempo_t * o  = new_aubio_tempo("complex", win_s, win_s/4, 44100.);
    1110        uint_t i = 0;
    1211
  • tests/src/test-tss.c

    r0536612 rf658288  
    1414        uint_t win_s    = 1024; /* window size                       */
    1515        uint_t hop_s    = 256;  /* hop size                          */
    16         uint_t channels = 4;  /* number of channels                */
    1716        /* allocate some memory */
    18         fvec_t * in       = new_fvec (hop_s, channels); /* input buffer       */
    19         cvec_t * fftgrain = new_cvec (win_s, channels); /* fft norm and phase */
    20         cvec_t * cstead   = new_cvec (win_s, channels); /* fft norm and phase */
    21         cvec_t * ctrans   = new_cvec (win_s, channels); /* fft norm and phase */
    22         fvec_t * stead    = new_fvec (hop_s, channels); /* output buffer      */
    23         fvec_t * trans    = new_fvec (hop_s, channels); /* output buffer      */
     17        fvec_t * in       = new_fvec (hop_s); /* input buffer       */
     18        cvec_t * fftgrain = new_cvec (win_s); /* fft norm and phase */
     19        cvec_t * cstead   = new_cvec (win_s); /* fft norm and phase */
     20        cvec_t * ctrans   = new_cvec (win_s); /* fft norm and phase */
     21        fvec_t * stead    = new_fvec (hop_s); /* output buffer      */
     22        fvec_t * trans    = new_fvec (hop_s); /* output buffer      */
    2423        /* allocate fft and other memory space */
    25         aubio_pvoc_t * pv = new_aubio_pvoc (win_s,hop_s,channels);
    26         aubio_pvoc_t * pvt = new_aubio_pvoc(win_s,hop_s,channels);
    27         aubio_pvoc_t * pvs = new_aubio_pvoc(win_s,hop_s,channels);
     24        aubio_pvoc_t * pv = new_aubio_pvoc (win_s,hop_s);
     25        aubio_pvoc_t * pvt = new_aubio_pvoc(win_s,hop_s);
     26        aubio_pvoc_t * pvs = new_aubio_pvoc(win_s,hop_s);
    2827
    29         aubio_tss_t *  tss = new_aubio_tss(win_s,hop_s,channels);
     28        aubio_tss_t *  tss = new_aubio_tss(win_s,hop_s);
    3029        /* fill input with some data */
    3130        printf("initialised\n");
Note: See TracChangeset for help on using the changeset viewer.