Changeset adc6e02


Ignore:
Timestamp:
Dec 1, 2018, 10:57:07 AM (10 months ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/constantq, feature/pitchshift, feature/timestretch, master
Children:
c1ba75b
Parents:
bbfa9a4 (diff), bde4f641 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into feature/pytest

Files:
2 added
34 edited

Legend:

Unmodified
Added
Removed
  • Makefile

    rbbfa9a4 radc6e02  
    260260                --output-file build/coverage.info
    261261        # remove tests
    262         lcov $(LCOVOPTS) --remove build/coverage.info '*/tests/*' '*/ooura_fft8g*' \
     262        lcov $(LCOVOPTS) --remove build/coverage.info '*/ooura_fft8g*' \
    263263                --output-file build/coverage_lib.info
    264264
     
    266266coverage_report: export WAFOPTS += --disable-docs
    267267coverage_report: coverage
    268         # create coverage report dir
    269         mkdir -p build/coverage/
    270268        # generate report with lcov's genhtml
    271         genhtml build/coverage_lib.info --output-directory build/coverage/lcov \
     269        genhtml build/coverage_lib.info --output-directory build/coverage_c \
    272270                --branch-coverage --highlight --legend
    273271        # generate python report with coverage python package
    274272        coverage report
    275         coverage html -d build/coverage/coverage
     273        coverage html -d build/coverage_python
    276274        # show links to generated reports
    277         for i in $$(ls build/coverage/*/index.html); do echo file://$(PWD)/$$i; done
     275        for i in $$(ls build/coverage_*/index.html); do echo file://$(PWD)/$$i; done
    278276
    279277sphinx: configure
  • python/ext/py-phasevoc.c

    rbbfa9a4 radc6e02  
    9191  self->hop_s = Py_default_vector_length/2;
    9292
    93   if (self == NULL) {
    94     return NULL;
    95   }
    96 
    9793  if (win_s > 0) {
    9894    self->win_s = win_s;
  • src/notes/notes.c

    rbbfa9a4 radc6e02  
    8484
    8585  o->onset = new_aubio_onset (onset_method, o->onset_buf_size, o->hop_size, o->samplerate);
     86  if (o->onset == NULL) goto fail;
    8687  if (o->onset_threshold != 0.) aubio_onset_set_threshold (o->onset, o->onset_threshold);
    8788  o->onset_output = new_fvec (1);
     
    99100  o->note_buffer = new_fvec(o->median);
    100101  o->note_buffer2 = new_fvec(o->median);
     102
     103  if (!o->onset_output || !o->pitch_output ||
     104      !o->note_buffer || !o->note_buffer2) goto fail;
    101105
    102106  o->curnote = -1.;
  • src/pitch/pitchmcomb.c

    rbbfa9a4 radc6e02  
    3838 * sort_pitchpeak(peaks, length);
    3939 */
     40#if 0
    4041/** spectral_peak comparison function (must return signed int) */
    4142static sint_t aubio_pitchmcomb_sort_peak_comp (const void *x, const void *y);
     
    4546uint_t aubio_pitch_cands (aubio_pitchmcomb_t * p, const cvec_t * fftgrain,
    4647    smpl_t * cands);
     48#endif
    4749
    4850/** sort spectral_candidate against their comb ene */
    4951void aubio_pitchmcomb_sort_cand_ene (aubio_spectralcandidate_t ** candidates,
    5052    uint_t nbins);
     53#if 0
    5154/** sort spectral_candidate against their frequency */
    5255void aubio_pitchmcomb_sort_cand_freq (aubio_spectralcandidate_t ** candidates,
    5356    uint_t nbins);
     57#endif
    5458
    5559struct _aubio_pitchmcomb_t
     
    134138}
    135139
     140#if 0
    136141uint_t
    137142aubio_pitch_cands (aubio_pitchmcomb_t * p, const cvec_t * fftgrain, smpl_t * cands)
     
    164169  }
    165170}
     171#endif
    166172
    167173void
     
    314320}
    315321
     322#if 0
    316323void
    317324aubio_pitchmcomb_sort_peak (aubio_spectralpeak_t * peaks, uint_t nbins)
     
    343350}
    344351
    345 
    346352void
    347353aubio_pitchmcomb_sort_cand_freq (aubio_spectralcandidate_t ** candidates,
     
    357363  }
    358364}
     365#endif
    359366
    360367aubio_pitchmcomb_t *
  • src/pitch/pitchyin.c

    rbbfa9a4 radc6e02  
    4040};
    4141
     42#if 0
    4243/** compute difference function
    4344
     
    6162*/
    6263uint_t aubio_pitchyin_getpitch (const fvec_t * yinbuf);
     64#endif
    6365
    6466aubio_pitchyin_t *
     
    7981}
    8082
     83#if 0
    8184/* outputs the difference function */
    8285void
     
    128131  return 0;
    129132}
     133#endif
    130134
    131135/* all the above in one */
  • src/pitch/pitchyinfast.c

    rbbfa9a4 radc6e02  
    5959  o->kernel_fft = new_fvec (bufsize);
    6060  o->fft = new_aubio_fft (bufsize);
     61  if (!o->yin || !o->tmpdata || !o->tmpdata || !o->sqdiff
     62      || !o->kernel || !o->samples_fft || !o->kernel || !o->fft)
     63  {
     64    del_aubio_pitchyinfast(o);
     65    return NULL;
     66  }
    6167  o->tol = 0.15;
    6268  o->peak_pos = 0;
     
    6773del_aubio_pitchyinfast (aubio_pitchyinfast_t * o)
    6874{
    69   del_fvec (o->yin);
    70   del_fvec (o->tmpdata);
    71   del_fvec (o->sqdiff);
    72   del_fvec (o->kernel);
    73   del_fvec (o->samples_fft);
    74   del_fvec (o->kernel_fft);
    75   del_aubio_fft (o->fft);
     75  if (o->yin)
     76    del_fvec (o->yin);
     77  if (o->tmpdata)
     78    del_fvec (o->tmpdata);
     79  if (o->sqdiff)
     80    del_fvec (o->sqdiff);
     81  if (o->kernel)
     82    del_fvec (o->kernel);
     83  if (o->samples_fft)
     84    del_fvec (o->samples_fft);
     85  if (o->kernel_fft)
     86    del_fvec (o->kernel_fft);
     87  if (o->fft)
     88    del_aubio_fft (o->fft);
    7689  AUBIO_FREE (o);
    7790}
  • src/utils/hist.c

    rbbfa9a4 radc6e02  
    4444  smpl_t accum = step;
    4545  uint_t i;
     46  if ((sint_t)nelems <= 0) {
     47    return NULL;
     48  }
    4649  s->nelems = nelems;
    4750  s->hist = new_fvec(nelems);
  • tests/src/io/test-sink-multi.c

    rbbfa9a4 radc6e02  
    1010
    1111  if (argc < 3) {
    12     err = 2;
    13     PRINT_ERR("not enough arguments\n");
     12    PRINT_ERR("not enough arguments, running tests\n");
     13    err = run_on_default_source_and_sink(main);
    1414    PRINT_MSG("usage: %s <input_path> <output_path> [samplerate] [channels] [hop_size]\n", argv[0]);
    1515    return err;
  • tests/src/io/test-sink.c

    rbbfa9a4 radc6e02  
    77
    88  if (argc < 3) {
    9     err = 2;
    10     PRINT_ERR("not enough arguments\n");
     9    PRINT_ERR("not enough arguments, running tests\n");
     10    err = run_on_default_source_and_sink(main);
    1111    PRINT_MSG("usage: %s <input_path> <output_path> [samplerate] [hop_size]\n", argv[0]);
    1212    return err;
  • tests/src/io/test-sink_apple_audio-multi.c

    rbbfa9a4 radc6e02  
    1111
    1212  if (argc < 3) {
    13     err = 2;
    14     PRINT_ERR("not enough arguments\n");
     13    PRINT_ERR("not enough arguments, running tests\n");
     14    err = run_on_default_source_and_sink(main);
    1515    PRINT_MSG("usage: %s <input_path> <output_path> [samplerate] [channels] [hop_size]\n", argv[0]);
    1616    return err;
     
    7272beach_source:
    7373#else /* HAVE_SINK_APPLE_AUDIO */
    74   err = 3;
     74  err = 0;
    7575  PRINT_ERR("aubio was not compiled with aubio_sink_apple_audio\n");
    7676#endif /* HAVE_SINK_APPLE_AUDIO */
  • tests/src/io/test-sink_apple_audio.c

    rbbfa9a4 radc6e02  
    1111
    1212  if (argc < 3) {
    13     err = 2;
    14     PRINT_ERR("not enough arguments\n");
     13    PRINT_ERR("not enough arguments, running tests\n");
     14    err = run_on_default_source_and_sink(main);
    1515    PRINT_MSG("usage: %s <input_path> <output_path> [samplerate] [hop_size]\n", argv[0]);
    1616    return err;
     
    6161beach_fvec:
    6262#else /* HAVE_SINK_APPLE_AUDIO */
    63   err = 3;
     63  err = 0;
    6464  PRINT_ERR("aubio was not compiled with aubio_source_apple_audio\n");
    6565#endif /* HAVE_SINK_APPLE_AUDIO */
  • tests/src/io/test-sink_sndfile-multi.c

    rbbfa9a4 radc6e02  
    1111
    1212  if (argc < 3) {
    13     err = 2;
    14     PRINT_ERR("not enough arguments\n");
     13    PRINT_ERR("not enough arguments, running tests\n");
     14    err = run_on_default_source_and_sink(main);
    1515    PRINT_MSG("usage: %s <input_path> <output_path> [samplerate] [channels] [hop_size]\n", argv[0]);
    1616    return err;
     
    7272beach_source:
    7373#else
    74   err = 3;
     74  err = 0;
    7575  PRINT_ERR("aubio was not compiled with aubio_sink_sndfile\n");
    7676#endif /* HAVE_SNDFILE */
  • tests/src/io/test-sink_sndfile.c

    rbbfa9a4 radc6e02  
    1111
    1212  if (argc < 3) {
    13     err = 2;
    14     PRINT_ERR("not enough arguments\n");
     13    PRINT_ERR("not enough arguments, running tests\n");
     14    err = run_on_default_source_and_sink(main);
    1515    PRINT_MSG("usage: %s <input_path> <output_path> [samplerate] [hop_size]\n", argv[0]);
    1616    return err;
     
    6161beach_fvec:
    6262#else
    63   err = 3;
     63  err = 0;
    6464  PRINT_ERR("aubio was not compiled with aubio_source_sndfile\n");
    6565#endif /* HAVE_SNDFILE */
  • tests/src/io/test-sink_wavwrite-multi.c

    rbbfa9a4 radc6e02  
    1111
    1212  if (argc < 3) {
    13     err = 2;
    14     PRINT_ERR("not enough arguments\n");
     13    PRINT_ERR("not enough arguments, running tests\n");
     14    err = run_on_default_source_and_sink(main);
    1515    PRINT_MSG("usage: %s <input_path> <output_path> [samplerate] [channels] [hop_size]\n", argv[0]);
    1616    return err;
     
    7272beach_source:
    7373#else
    74   err = 3;
     74  err = 0;
    7575  PRINT_ERR("aubio was not compiled with aubio_sink_wavwrite\n");
    7676#endif /* HAVE_WAVWRITE */
  • tests/src/io/test-sink_wavwrite.c

    rbbfa9a4 radc6e02  
    1111
    1212  if (argc < 3) {
    13     err = 2;
    14     PRINT_ERR("not enough arguments\n");
     13    PRINT_ERR("not enough arguments, running tests\n");
     14    err = run_on_default_source_and_sink(main);
    1515    PRINT_MSG("usage: %s <input_path> <output_path> [samplerate] [hop_size]\n", argv[0]);
    1616    return err;
     
    6161beach_fvec:
    6262#else
    63   err = 3;
     63  err = 0;
    6464  PRINT_ERR("aubio was not compiled with aubio_sink_wavwrite\n");
    6565#endif /* HAVE_WAVWRITE */
  • tests/src/io/test-source.c

    rbbfa9a4 radc6e02  
    66  uint_t err = 0;
    77  if (argc < 2) {
    8     err = 2;
    9     PRINT_ERR("not enough arguments\n");
     8    PRINT_ERR("not enough arguments, running tests\n");
     9    err = run_on_default_source(main);
    1010    PRINT_MSG("read a wave file as a mono vector\n");
    1111    PRINT_MSG("usage: %s <source_path> [samplerate] [hop_size]\n", argv[0]);
     
    2323  uint_t hop_size = 256;
    2424  uint_t n_frames = 0, read = 0;
    25   if ( argc == 3 ) samplerate = atoi(argv[2]);
    26   if ( argc == 4 ) hop_size = atoi(argv[3]);
     25  if ( argc >= 3 ) samplerate = atoi(argv[2]);
     26  if ( argc >= 4 ) hop_size = atoi(argv[3]);
    2727
    2828  char_t *source_path = argv[1];
  • tests/src/io/test-source_apple_audio.c

    rbbfa9a4 radc6e02  
    1010  uint_t err = 0;
    1111  if (argc < 2) {
    12     err = 2;
    13     PRINT_ERR("not enough arguments\n");
     12    PRINT_ERR("not enough arguments, running tests\n");
     13    err = run_on_default_source(main);
    1414    PRINT_MSG("read a wave file as a mono vector\n");
    1515    PRINT_MSG("usage: %s <source_path> [samplerate] [hop_size]\n", argv[0]);
     
    2828  uint_t hop_size = 256;
    2929  uint_t n_frames = 0, read = 0;
    30   if ( argc == 3 ) samplerate = atoi(argv[2]);
    31   if ( argc == 4 ) hop_size = atoi(argv[3]);
     30  if ( argc >= 3 ) samplerate = atoi(argv[2]);
     31  if ( argc >= 4 ) hop_size = atoi(argv[3]);
    3232
    3333  char_t *source_path = argv[1];
     
    5757beach:
    5858#else /* HAVE_SOURCE_APPLE_AUDIO */
    59   err = 3;
     59  err = 0;
    6060  PRINT_ERR("aubio was not compiled with aubio_source_apple_audio\n");
    6161#endif /* HAVE_SOURCE_APPLE_AUDIO */
  • tests/src/io/test-source_avcodec.c

    rbbfa9a4 radc6e02  
    1010  uint_t err = 0;
    1111  if (argc < 2) {
    12     err = 2;
    13     PRINT_ERR("not enough arguments\n");
     12    PRINT_ERR("not enough arguments, running tests\n");
     13    err = run_on_default_source(main);
    1414    PRINT_MSG("read a wave file as a mono vector\n");
    1515    PRINT_MSG("usage: %s <source_path> [samplerate] [hop_size]\n", argv[0]);
     
    2828  uint_t hop_size = 256;
    2929  uint_t n_frames = 0, read = 0;
    30   if ( argc == 3 ) samplerate = atoi(argv[2]);
    31   if ( argc == 4 ) hop_size = atoi(argv[3]);
     30  if ( argc >= 3 ) samplerate = atoi(argv[2]);
     31  if ( argc >= 4 ) hop_size = atoi(argv[3]);
    3232
    3333  char_t *source_path = argv[1];
     
    5757beach:
    5858#else /* HAVE_LIBAV */
    59   err = 3;
     59  err = 0;
    6060  PRINT_ERR("aubio was not compiled with aubio_source_avcodec\n");
    6161#endif /* HAVE_LIBAV */
  • tests/src/io/test-source_multi.c

    rbbfa9a4 radc6e02  
    66  sint_t err = 0;
    77  if (argc < 2) {
    8     err = -2;
    9     PRINT_ERR("not enough arguments\n");
     8    PRINT_ERR("not enough arguments, running tests\n");
     9    err = run_on_default_source(main);
    1010    PRINT_MSG("read a wave file as a mono vector\n");
    1111    PRINT_MSG("usage: %s <source_path> [samplerate] [hop_size]\n", argv[0]);
  • tests/src/io/test-source_seek.c

    rbbfa9a4 radc6e02  
    66  uint_t err = 0;
    77  if (argc < 2) {
    8     err = 2;
    9     PRINT_ERR("not enough arguments\n");
     8    PRINT_ERR("not enough arguments, running tests\n");
     9    err = run_on_default_source(main);
    1010    PRINT_MSG("read a wave file as a mono vector\n");
    1111    PRINT_MSG("usage: %s <source_path> [samplerate] [hop_size]\n", argv[0]);
     
    2424  uint_t n_frames = 0, read = 0;
    2525  uint_t old_n_frames_1 = 0, old_n_frames_2 = 0, old_n_frames_3 = 0;
    26   if ( argc == 3 ) samplerate = atoi(argv[2]);
    27   if ( argc == 4 ) hop_size = atoi(argv[3]);
     26  if ( argc >= 3 ) samplerate = atoi(argv[2]);
     27  if ( argc >= 4 ) hop_size = atoi(argv[3]);
    2828
    2929  char_t *source_path = argv[1];
  • tests/src/io/test-source_sndfile.c

    rbbfa9a4 radc6e02  
    1010  uint_t err = 0;
    1111  if (argc < 2) {
    12     err = 2;
    13     PRINT_ERR("not enough arguments\n");
     12    PRINT_ERR("not enough arguments, running tests\n");
     13    err = run_on_default_source(main);
    1414    PRINT_MSG("read a wave file as a mono vector\n");
    1515    PRINT_MSG("usage: %s <source_path> [samplerate] [hop_size]\n", argv[0]);
     
    2828  uint_t hop_size = 256;
    2929  uint_t n_frames = 0, read = 0;
    30   if ( argc == 3 ) samplerate = atoi(argv[2]);
    31   if ( argc == 4 ) hop_size = atoi(argv[3]);
     30  if ( argc >= 3 ) samplerate = atoi(argv[2]);
     31  if ( argc >= 4 ) hop_size = atoi(argv[3]);
    3232
    3333  char_t *source_path = argv[1];
     
    5757beach:
    5858#else
    59   err = 3;
     59  err = 0;
    6060  PRINT_ERR("aubio was not compiled with aubio_source_sndfile\n");
    6161#endif /* HAVE_SNDFILE */
  • tests/src/io/test-source_wavread.c

    rbbfa9a4 radc6e02  
    1010  uint_t err = 0;
    1111  if (argc < 2) {
    12     err = 2;
    13     PRINT_ERR("not enough arguments\n");
     12    PRINT_ERR("not enough arguments, running tests\n");
     13    err = run_on_default_source(main);
    1414    PRINT_MSG("read a wave file as a mono vector\n");
    1515    PRINT_MSG("usage: %s <source_path> [samplerate] [hop_size]\n", argv[0]);
     
    2828  uint_t hop_size = 256;
    2929  uint_t n_frames = 0, read = 0;
    30   if ( argc == 3 ) samplerate = atoi(argv[2]);
    31   if ( argc == 4 ) hop_size = atoi(argv[3]);
     30  if ( argc >= 3 ) samplerate = atoi(argv[2]);
     31  if ( argc >= 4 ) hop_size = atoi(argv[3]);
    3232
    3333  char_t *source_path = argv[1];
     
    3636  aubio_source_wavread_t * s =
    3737    new_aubio_source_wavread(source_path, samplerate, hop_size);
    38 
    3938  if (!s) { err = 1; goto beach; }
    4039  fvec_t *vec = new_fvec(hop_size);
     
    5857beach:
    5958#else
    60   err = 3;
     59  err = 0;
    6160  PRINT_ERR("aubio was not compiled with aubio_source_wavread\n");
    6261#endif /* HAVE_WAVREAD */
  • tests/src/onset/test-onset.c

    rbbfa9a4 radc6e02  
    1010    err = 2;
    1111    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     }
     12    err = test_wrong_params();
    1813    PRINT_MSG("usage: %s <source_path> [samplerate] [hop_size]\n", argv[0]);
    1914    return err;
     
    2318  uint_t hop_size = win_s / 4;
    2419  uint_t n_frames = 0, read = 0;
    25   if ( argc == 3 ) samplerate = atoi(argv[2]);
    26   if ( argc == 4 ) hop_size = atoi(argv[3]);
     20  if ( argc >= 3 ) samplerate = atoi(argv[2]);
     21  if ( argc >= 4 ) hop_size = atoi(argv[3]);
    2722
    2823  char_t *source_path = argv[1];
     
    9085  if (new_aubio_onset("abcd", win_size, win_size/2, samplerate))
    9186    return 1;
    92   // pv creation failed
    93   if (new_aubio_onset("default", 5, 2, samplerate))
    94     return 1;
    9587
    9688  aubio_onset_t *o;
     89
     90  // pv creation might fail
     91  o = new_aubio_onset("default", 5, 2, samplerate);
     92  if (o) del_aubio_onset(o);
     93
    9794  o = new_aubio_onset("default", win_size, hop_size, samplerate);
    9895  if (!aubio_onset_set_default_parameters(o, "wrong_type"))
     
    10097  del_aubio_onset(o);
    10198
    102   return 0;
     99  return run_on_default_source(main);
    103100}
  • tests/src/pitch/test-pitch.c

    rbbfa9a4 radc6e02  
    3131  aubio_cleanup ();
    3232
     33  if (new_aubio_pitch(0, win_s, hop_s, samplerate)) return 1;
     34  if (new_aubio_pitch("unknown", win_s, hop_s, samplerate)) return 1;
     35  if (new_aubio_pitch("default", win_s,     0, samplerate)) return 1;
     36  if (new_aubio_pitch("default",     0, hop_s, samplerate)) return 1;
     37  if (new_aubio_pitch("default", hop_s, win_s, samplerate)) return 1;
     38  if (new_aubio_pitch("default", win_s, hop_s,          0)) return 1;
     39
     40  o = new_aubio_pitch("default", win_s, hop_s, samplerate);
     41
     42  if (aubio_pitch_set_unit(o, "freq")) return 1;
     43  if (aubio_pitch_set_unit(o, "hertz")) return 1;
     44  if (aubio_pitch_set_unit(o, "Hertz")) return 1;
     45  if (aubio_pitch_set_unit(o, "Hz")) return 1;
     46  if (aubio_pitch_set_unit(o, "f0")) return 1;
     47  if (aubio_pitch_set_unit(o, "midi")) return 1;
     48  if (aubio_pitch_set_unit(o, "cent")) return 1;
     49  if (aubio_pitch_set_unit(o, "bin")) return 1;
     50  if (!aubio_pitch_set_unit(o, "unknown")) return 1;
     51
     52  if (aubio_pitch_set_tolerance(o, 0.3)) return 1;
     53  if (aubio_pitch_set_silence(o, 0)) return 1;
     54  if (aubio_pitch_set_silence(o, -200)) return 1;
     55  if (!aubio_pitch_set_silence(o, -300)) return 1;
     56  del_aubio_pitch(o);
     57
     58  // fft based might fail with non power of 2
     59  o = new_aubio_pitch("yinfft", win_s + 1, hop_s, samplerate);
     60  if (o) del_aubio_pitch(o);
     61  o = new_aubio_pitch("yinfast", win_s + 1, hop_s, samplerate);
     62  if (o) del_aubio_pitch(o);
     63  o = new_aubio_pitch("fcomb", win_s + 1, hop_s, samplerate);
     64  if (o) del_aubio_pitch(o);
     65  o = new_aubio_pitch("mcomb", win_s + 1, hop_s, samplerate);
     66  if (o) del_aubio_pitch(o);
     67  o = new_aubio_pitch("specacf", win_s + 1, hop_s, samplerate);
     68  if (o) del_aubio_pitch(o);
     69
    3370  return 0;
    3471}
  • tests/src/spectral/test-awhitening.c

    rbbfa9a4 radc6e02  
    1111    err = 2;
    1212    PRINT_WRN("no arguments, running tests\n");
    13     if (test_wrong_params() != 0) {
    14       PRINT_ERR("tests failed!\n");
    15       err = 1;
    16     } else {
    17       err = 0;
    18     }
     13    err = test_wrong_params();
    1914    PRINT_MSG("usage: %s <input_path> <output_path> [samplerate] [hop_size]\n", argv[0]);
    2015    return err;
     
    3126  if ( argc >= 4 ) samplerate = atoi(argv[3]);
    3227  if ( argc >= 5 ) hop_size = atoi(argv[4]);
    33   if ( argc >= 6 ) {
    34     err = 2;
    35     PRINT_ERR("too many arguments\n");
    36     return err;
    37   }
    3828
    3929  fvec_t *vec = new_fvec(hop_size);
     
    10999  del_aubio_spectral_whitening(o);
    110100
    111   return 0;
     101  return run_on_default_source_and_sink(main);
    112102}
  • tests/src/spectral/test-dct.c

    rbbfa9a4 radc6e02  
    3333    aubio_dct_rdo (dct, dctout, out);
    3434    for (j = 0; j < in->length; j++) {
    35       if (fabsf(in->data[j] - out->data[j]) > 10.e-4) {
    36         fprintf(stderr, "dct reconstruction failed\n");
    37       }
     35      return_code += (fabsf(in->data[j] - out->data[j]) > 10.e-4);
    3836    }
    3937  }
  • tests/src/synth/test-sampler.c

    rbbfa9a4 radc6e02  
     1#include <string.h> // strncpy
     2#include <limits.h> // PATH_MAX
    13#include <aubio.h>
    24#include "utils_tests.h"
     
    68  sint_t err = 0;
    79
    8   if (argc < 4) {
    9     err = 2;
    10     PRINT_ERR("not enough arguments\n");
     10  if (argc < 3) {
     11    PRINT_ERR("not enough arguments, running tests\n");
     12    err = run_on_default_source_and_sink(main);
    1113    PRINT_MSG("usage: %s <input_path> <output_path> <sample_path> [samplerate]\n", argv[0]);
    1214    return err;
     
    1921  char_t *source_path = argv[1];
    2022  char_t *sink_path = argv[2];
    21   char_t *sample_path = argv[3];
    22   if ( argc == 5 ) samplerate = atoi(argv[4]);
     23  char_t sample_path[PATH_MAX];
     24  if ( argc >= 4 ) {
     25    strncpy(sample_path, argv[3], PATH_MAX - 1);
     26  } else {
     27    // use input_path as sample
     28    strncpy(sample_path, source_path, PATH_MAX - 1);
     29  }
     30  sample_path[PATH_MAX - 1] = '\0';
     31  if ( argc >= 5 ) samplerate = atoi(argv[4]);
    2332
    2433  fvec_t *vec = new_fvec(hop_size);
  • tests/src/synth/test-wavetable.c

    rbbfa9a4 radc6e02  
    77
    88  if (argc < 2) {
    9     err = 2;
    10     PRINT_ERR("not enough arguments\n");
     9    PRINT_ERR("not enough arguments, running tests\n");
     10    err = run_on_default_sink(main);
    1111    PRINT_MSG("usage: %s <output_path> [freq] [samplerate]\n", argv[0]);
    1212    return err;
     
    1818
    1919  char_t *sink_path = argv[1];
    20   if ( argc == 4 ) samplerate = atoi(argv[3]);
    21   if ( argc == 3 ) freq = atof(argv[2]);
     20  if ( argc >= 4 ) samplerate = atoi(argv[3]);
     21  if ( argc >= 3 ) freq = atof(argv[2]);
    2222
    2323  fvec_t *vec = new_fvec(hop_size);
  • tests/src/tempo/test-tempo.c

    rbbfa9a4 radc6e02  
    88  uint_t err = 0;
    99  if (argc < 2) {
    10     err = 2;
    1110    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     }
     11    err = test_wrong_params();
    1812    PRINT_MSG("usage: %s <source_path> [samplerate] [win_size] [hop_size]\n",
    1913        argv[0]);
     
    136130  del_fvec(out);
    137131
    138   return 0;
     132  return run_on_default_source(main);
    139133}
  • tests/src/test-mathutils.c

    rbbfa9a4 radc6e02  
    103103
    104104  window_size /= 2.;
    105   window = new_aubio_window("triangle", window_size);
     105  window = new_aubio_window("parzen", window_size);
    106106  fvec_print(window);
    107107  del_fvec(window);
     
    117117  test_miditofreq();
    118118  test_freqtomidi();
     119  test_aubio_window();
    119120  return 0;
    120121}
  • tests/src/utils/test-hist.c

    rbbfa9a4 radc6e02  
    2626    del_fvec(t);
    2727  }
     28  if (new_aubio_hist(0, 1, 0)) return 1;
    2829  return 0;
    2930}
  • tests/utils_tests.h

    rbbfa9a4 radc6e02  
    55#include <assert.h>
    66#include "config.h"
     7
     8#ifdef HAVE_STRING_H
     9#include <string.h>
     10#endif
     11
     12#ifdef HAVE_UNISTD_H
     13#include <unistd.h> // unlink, close
     14#endif
     15
     16#ifdef HAVE_LIMITS_H
     17#include <limits.h> // PATH_MAX
     18#endif /* HAVE_LIMITS_H */
     19#ifndef PATH_MAX
     20#define PATH_MAX 1024
     21#endif
     22
     23#if defined(HAVE_WIN_HACKS) && !defined(__GNUC__)
     24#include <io.h> // _access
     25#endif
     26
     27// This macro is used to pass a string to msvc compiler: since msvc's -D flag
     28// strips the quotes, we define the string without quotes and re-add them with
     29// this macro.
     30
     31#define REDEFINESTRING(x) #x
     32#define DEFINEDSTRING(x) REDEFINESTRING(x)
     33
     34#ifndef AUBIO_TESTS_SOURCE
     35#error "AUBIO_TESTS_SOURCE is not defined"
     36#endif
    737
    838#ifdef HAVE_C99_VARARGS_MACROS
     
    4878  time_t now = time(0);
    4979  struct tm *tm_struct = localtime(&now);
    50   int seed = tm_struct->tm_sec;
     80  size_t **tm_address = (void*)&tm_struct;
     81  int seed = tm_struct->tm_sec + (size_t)tm_address;
    5182  //PRINT_WRN("current seed: %d\n", seed);
    52   srandom (seed);
     83  srandom ((unsigned int)seed);
    5384}
     85
     86// create_temp_sink / close_temp_sink
     87#if defined(__GNUC__) // mkstemp
     88
     89int check_source(char *source_path)
     90{
     91  return access(source_path, R_OK);
     92}
     93
     94int create_temp_sink(char *sink_path)
     95{
     96  return mkstemp(sink_path);
     97}
     98
     99int close_temp_sink(char *sink_path, int sink_fildes)
     100{
     101  int err;
     102  if ((err = close(sink_fildes)) != 0) return err;
     103  if ((err = unlink(sink_path)) != 0) return err;
     104  return err;
     105}
     106
     107#elif defined(HAVE_WIN_HACKS) //&& !defined(__GNUC__)
     108// windows workaround, where mkstemp does not exist...
     109
     110int check_source(char *source_path)
     111{
     112  return _access(source_path, 04);
     113}
     114
     115int create_temp_sink(char *templ)
     116{
     117  int i = 0;
     118  static const char letters[] = "abcdefg0123456789";
     119  int letters_len = strlen(letters);
     120  int templ_len = strlen(templ);
     121  if (templ_len == 0) return 0;
     122  utils_init_random();
     123  for (i = 0; i < 6; i++)
     124  {
     125    templ[templ_len - i] = letters[rand() % letters_len];
     126  }
     127  return 1;
     128}
     129
     130int close_temp_sink(char* sink_path, int sink_fildes) {
     131  // the file should be closed when not using mkstemp, no need to open it
     132  if (sink_fildes == 0) return 1;
     133  return _unlink(sink_path);
     134}
     135
     136#else // windows workaround
     137// otherwise, we don't really know what to do yet
     138#error "mkstemp undefined, but not on windows. additional workaround required."
     139#endif
     140
     141// pass progname / default
     142int run_on_default_source( int main(int, char**) )
     143{
     144  const int argc = 2;
     145  int err = 0;
     146  char** argv = (char**)calloc(argc, sizeof(char*));
     147  argv[0] = __FILE__;
     148  argv[1] = DEFINEDSTRING(AUBIO_TESTS_SOURCE);
     149  // check if the file can be read
     150  if ( check_source(argv[1]) ) return 1;
     151  err = main(argc, argv);
     152  if (argv) free(argv);
     153  return err;
     154}
     155
     156int run_on_default_sink( int main(int, char**) )
     157{
     158  const int argc = 2;
     159  int err = 0;
     160  char** argv = (char**)calloc(argc, sizeof(char*));
     161  char sink_path[PATH_MAX] = "tmp_aubio_XXXXXX";
     162  int fd = create_temp_sink(sink_path);
     163  if (!fd) return 1;
     164  argv[0] = __FILE__;
     165  argv[1] = sink_path;
     166  err = main(argc, argv);
     167  close_temp_sink(sink_path, fd);
     168  if (argv) free(argv);
     169  return err;
     170}
     171
     172int run_on_default_source_and_sink( int main(int, char**) )
     173{
     174  const int argc = 3;
     175  int err = 0;
     176  char** argv = (char**)calloc(argc, sizeof(char*));
     177  char sink_path[PATH_MAX] = "tmp_aubio_XXXXXX";
     178  int fd = create_temp_sink(sink_path);
     179  if (!fd) return 1;
     180  argv[0] = __FILE__;
     181  argv[1] = DEFINEDSTRING(AUBIO_TESTS_SOURCE);
     182  argv[2] = sink_path;
     183  // check if the file can be read
     184  if ( check_source(argv[1]) ) return 1;
     185  err = main(argc, argv);
     186  close_temp_sink(sink_path, fd);
     187  if (argv) free(argv);
     188  return err;
     189}
  • tests/wscript_build

    rbbfa9a4 radc6e02  
    88programs_sources = ctx.path.ant_glob('src/**/*.c')
    99
     10test_sound_target = '44100Hz_44100f_sine441_stereo.wav'
     11test_sound_abspath = bld.path.get_bld().make_node(test_sound_target)
     12# workaround to double escape backslash characters on windows
     13test_sound_abspath = str(test_sound_abspath).replace('\\', '\\\\')
     14
     15b = bld(name='create_tests_source',
     16    rule='python ${SRC} ${TGT}',
     17    source='create_tests_source.py',
     18    target=test_sound_target)
     19# use post() to create the task, keep a reference to it
     20b.post()
     21create_tests_source = b.tasks[0]
     22
    1023for source_file in programs_sources:
    1124    target = os.path.basename(os.path.splitext(str(source_file))[0])
    12     bld(features = 'c cprogram test',
     25    a = bld(features = 'c cprogram test',
    1326            source = source_file,
    1427            target = target,
     
    1629            use = uselib,
    1730            install_path = None,
    18             defines = 'AUBIO_UNSTABLE_API=1',
     31            defines = ['AUBIO_UNSTABLE_API=1',
     32                        'AUBIO_TESTS_SOURCE={}'.format(test_sound_abspath)]
    1933       )
     34    a.post()
     35    # make sure the unit_test task runs *after* the source is created
     36    a.tasks[-1].set_run_after(create_tests_source)
  • wscript

    rbbfa9a4 radc6e02  
    518518    sphinx(bld)
    519519
     520    from waflib.Tools import waf_unit_test
     521    bld.add_post_fun(waf_unit_test.summary)
     522    bld.add_post_fun(waf_unit_test.set_exit_code)
     523
    520524def txt2man(bld):
    521525    # build manpages from txt files using txt2man
Note: See TracChangeset for help on using the changeset viewer.