Changes in / [ce323e4:1cf031a]


Ignore:
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/onset/onset.c

    rce323e4 r1cf031a  
    257257  o->pp = new_aubio_peakpicker();
    258258  o->od = new_aubio_specdesc(onset_mode,buf_size);
     259  if (o->od == NULL) goto beach_specdesc;
    259260  o->fftgrain = new_cvec(buf_size);
    260261  o->desc = new_fvec(1);
    261262  o->spectral_whitening = new_aubio_spectral_whitening(buf_size, hop_size, samplerate);
    262263
    263   if (!o->pv || !o->pp || !o->od || !o->fftgrain
    264       || !o->desc || !o->spectral_whitening)
    265     goto beach;
    266 
    267264  /* initialize internal variables */
    268265  aubio_onset_set_default_parameters (o, onset_mode);
     
    271268  return o;
    272269
     270beach_specdesc:
     271  del_aubio_peakpicker(o->pp);
     272  del_aubio_pvoc(o->pv);
    273273beach:
    274   del_aubio_onset(o);
     274  AUBIO_FREE(o);
    275275  return NULL;
    276276}
     
    340340void del_aubio_onset (aubio_onset_t *o)
    341341{
    342   if (o->spectral_whitening)
    343     del_aubio_spectral_whitening(o->spectral_whitening);
    344   if (o->od)
    345     del_aubio_specdesc(o->od);
    346   if (o->pp)
    347     del_aubio_peakpicker(o->pp);
    348   if (o->pv)
    349     del_aubio_pvoc(o->pv);
    350   if (o->desc)
    351     del_fvec(o->desc);
    352   if (o->fftgrain)
    353     del_cvec(o->fftgrain);
     342  del_aubio_spectral_whitening(o->spectral_whitening);
     343  del_aubio_specdesc(o->od);
     344  del_aubio_peakpicker(o->pp);
     345  del_aubio_pvoc(o->pv);
     346  del_fvec(o->desc);
     347  del_cvec(o->fftgrain);
    354348  AUBIO_FREE(o);
    355349}
  • tests/src/onset/test-onset.c

    rce323e4 r1cf031a  
    11#include <aubio.h>
    22#include "utils_tests.h"
    3 
    4 int test_wrong_params(void);
    53
    64int main (int argc, char **argv)
     
    97  if (argc < 2) {
    108    err = 2;
    11     PRINT_WRN("no arguments, running tests\n");
    12     if (test_wrong_params() != 0) {
    13       PRINT_ERR("tests failed!\n");
    14       err = 1;
    15     } else {
    16       err = 0;
    17     }
     9    PRINT_ERR("not enough arguments\n");
     10    PRINT_MSG("read a wave file as a mono vector\n");
    1811    PRINT_MSG("usage: %s <source_path> [samplerate] [hop_size]\n", argv[0]);
    1912    return err;
     
    6861  return err;
    6962}
    70 
    71 int test_wrong_params(void)
    72 {
    73   uint_t win_size = 1024;
    74   uint_t hop_size = win_size / 2;
    75   uint_t samplerate = 44100;
    76   // hop_size < 1
    77   if (new_aubio_onset("default", 5, 0, samplerate))
    78     return 1;
    79   // buf_size < 2
    80   if (new_aubio_onset("default", 1, 1, samplerate))
    81     return 1;
    82   // buf_size < hop_size
    83   if (new_aubio_onset("default", hop_size, win_size, samplerate))
    84     return 1;
    85   // samplerate < 1
    86   if (new_aubio_onset("default", 1024, 512, 0))
    87     return 1;
    88 
    89   // specdesc creation failed
    90   if (new_aubio_onset("abcd", win_size, win_size/2, samplerate))
    91     return 1;
    92   // pv creation failed
    93   if (new_aubio_onset("default", 5, 2, samplerate))
    94     return 1;
    95 
    96   aubio_onset_t *o;
    97   o = new_aubio_onset("default", win_size, hop_size, samplerate);
    98   if (!aubio_onset_set_default_parameters(o, "wrong_type"))
    99     return 1;
    100   del_aubio_onset(o);
    101 
    102   return 0;
    103 }
Note: See TracChangeset for help on using the changeset viewer.