Changeset f87e191 for tests/src


Ignore:
Timestamp:
Nov 26, 2018, 10:33:30 PM (6 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/constantq
Children:
868c6b8
Parents:
d1d4ad4 (diff), db3eb5c (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/constantq

Location:
tests/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • tests/src/onset/test-onset.c

    rd1d4ad4 rf87e191  
    11#include <aubio.h>
    22#include "utils_tests.h"
     3
     4int test_wrong_params(void);
    35
    46int main (int argc, char **argv)
     
    79  if (argc < 2) {
    810    err = 2;
    9     PRINT_ERR("not enough arguments\n");
    10     PRINT_MSG("read a wave file as a mono vector\n");
     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    }
    1118    PRINT_MSG("usage: %s <source_path> [samplerate] [hop_size]\n", argv[0]);
    1219    return err;
     
    6168  return err;
    6269}
     70
     71int 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}
  • tests/src/spectral/test-awhitening.c

    rd1d4ad4 rf87e191  
    11#include <aubio.h>
    22#include "utils_tests.h"
     3
     4int test_wrong_params(void);
    35
    46int main (int argc, char **argv)
     
    810  if (argc < 3) {
    911    err = 2;
    10     PRINT_ERR("not enough arguments\n");
     12    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    }
    1119    PRINT_MSG("usage: %s <input_path> <output_path> [samplerate] [hop_size]\n", argv[0]);
    1220    return err;
     
    8391}
    8492
     93int test_wrong_params(void)
     94{
     95  uint_t buf_size = 512;
     96  uint_t hop_size = 256;
     97  uint_t samplerate = 44100;
     98  aubio_spectral_whitening_t *o;
     99
     100  if (new_aubio_spectral_whitening(       0, hop_size, samplerate)) return 1;
     101  if (new_aubio_spectral_whitening(buf_size,        0, samplerate)) return 1;
     102  if (new_aubio_spectral_whitening(buf_size, hop_size,          0)) return 1;
     103
     104  o = new_aubio_spectral_whitening(buf_size, hop_size, samplerate);
     105
     106  aubio_spectral_whitening_get_relax_time(o);
     107  aubio_spectral_whitening_get_floor(o);
     108
     109  del_aubio_spectral_whitening(o);
     110
     111  return 0;
     112}
  • tests/src/spectral/test-dct.c

    rd1d4ad4 rf87e191  
    1010  // create dct object
    1111  aubio_dct_t * dct = new_aubio_dct(win_s);
     12  aubio_dct_t * tmp;
     13
     14  if (new_aubio_dct(0)) return 1;
    1215
    1316  fvec_t * in = new_fvec (win_s); // input buffer
    1417  fvec_t * dctout = new_fvec (win_s); // output buffer
    1518  fvec_t * out = new_fvec (win_s); // input buffer
     19
     20  if ((tmp = new_aubio_dct(1)) == 0) return 1;
     21  //aubio_dct_do(tmp, dctout, out);
     22  //aubio_dct_rdo(tmp, dctout, out);
     23  del_aubio_dct(tmp);
    1624
    1725  if (!dct || !in || !dctout) {
  • tests/src/spectral/test-filterbank.c

    rd1d4ad4 rf87e191  
    88  cvec_t *in_spec = new_cvec (win_s); // input vector of samples
    99  fvec_t *out_filters = new_fvec (n_filters); // per-band outputs
     10
     11  if (new_aubio_filterbank(0, win_s)) return 1;
     12  if (new_aubio_filterbank(n_filters, 0)) return 1;
    1013
    1114  // create filterbank object
  • tests/src/spectral/test-mfcc.c

    rd1d4ad4 rf87e191  
    55  uint_t win_s = 512; // fft size
    66  uint_t n_filters = 40; // number of filters
    7   uint_t n_coefs = 13; // number of coefficients
     7  uint_t n_coeffs = 13; // number of coefficients
    88  smpl_t samplerate = 16000.; // samplerate
    99  cvec_t *in = new_cvec (win_s); // input buffer
    10   fvec_t *out = new_fvec (n_coefs); // output coefficients
     10  fvec_t *out = new_fvec (n_coeffs); // output coefficients
     11
     12  if (new_aubio_mfcc(    0, n_filters, n_coeffs, samplerate)) return 1;
     13  if (new_aubio_mfcc(win_s,         0, n_coeffs, samplerate)) return 1;
     14  if (new_aubio_mfcc(win_s, n_filters,        0, samplerate)) return 1;
     15  if (new_aubio_mfcc(win_s, n_filters, n_coeffs,          0)) return 1;
    1116
    1217  // create mfcc object
    13   aubio_mfcc_t *o = new_aubio_mfcc (win_s, n_filters, n_coefs, samplerate);
     18  aubio_mfcc_t *o = new_aubio_mfcc (win_s, n_filters, n_coeffs, samplerate);
    1419
    1520  cvec_norm_set_all (in, 1.);
  • tests/src/spectral/test-phasevoc.c

    rd1d4ad4 rf87e191  
    1313  // allocate fft and other memory space
    1414  aubio_pvoc_t * pv = new_aubio_pvoc(win_s,hop_s);
     15
     16  if (new_aubio_pvoc(win_s, 0)) return 1;
     17
     18  if (aubio_pvoc_get_win(pv) != win_s) return 1;
     19  if (aubio_pvoc_get_hop(pv) != hop_s) return 1;
     20
     21  if (aubio_pvoc_set_window(pv, "hanningz") != 0) return 1;
    1522
    1623  // fill input with some data
  • tests/src/spectral/test-tss.c

    rd1d4ad4 rf87e191  
    3535  }
    3636
     37  aubio_tss_set_alpha(tss, 4.);
     38  aubio_tss_set_beta(tss, 3.);
     39  aubio_tss_set_threshold(tss, 3.);
     40
    3741  del_aubio_pvoc(pv);
    3842  del_aubio_pvoc(pvt);
  • tests/src/tempo/test-tempo.c

    rd1d4ad4 rf87e191  
    11#include <aubio.h>
    22#include "utils_tests.h"
     3
     4int test_wrong_params(void);
    35
    46int main (int argc, char **argv)
     
    79  if (argc < 2) {
    810    err = 2;
    9     PRINT_ERR("not enough arguments\n");
    10     PRINT_MSG("read a wave file as a mono vector\n");
    11     PRINT_MSG("usage: %s <source_path> [samplerate] [win_size] [hop_size]\n", argv[0]);
     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    }
     18    PRINT_MSG("usage: %s <source_path> [samplerate] [win_size] [hop_size]\n",
     19        argv[0]);
    1220    return err;
    1321  }
     
    2129
    2230  char_t *source_path = argv[1];
    23   aubio_source_t * source = new_aubio_source(source_path, samplerate, hop_size);
     31  aubio_source_t * source = new_aubio_source(source_path, samplerate,
     32      hop_size);
    2433  if (!source) { err = 1; goto beach; }
    2534
     
    3140
    3241  // create tempo object
    33   aubio_tempo_t * o = new_aubio_tempo("default", win_size, hop_size, samplerate);
     42  aubio_tempo_t * o = new_aubio_tempo("default", win_size, hop_size,
     43      samplerate);
     44
     45  if (!o) { err = 1; goto beach_tempo; }
    3446
    3547  do {
     
    4052    // do something with the beats
    4153    if (out->data[0] != 0) {
    42       PRINT_MSG("beat at %.3fms, %.3fs, frame %d, %.2fbpm with confidence %.2f\n",
     54      PRINT_MSG("beat at %.3fms, %.3fs, frame %d, %.2f bpm "
     55          "with confidence %.2f\n",
    4356          aubio_tempo_get_last_ms(o), aubio_tempo_get_last_s(o),
    44           aubio_tempo_get_last(o), aubio_tempo_get_bpm(o), aubio_tempo_get_confidence(o));
     57          aubio_tempo_get_last(o), aubio_tempo_get_bpm(o),
     58          aubio_tempo_get_confidence(o));
    4559    }
    4660    n_frames += read;
     
    5468  // clean up memory
    5569  del_aubio_tempo(o);
     70beach_tempo:
    5671  del_fvec(in);
    5772  del_fvec(out);
     
    6277  return err;
    6378}
     79
     80int test_wrong_params(void)
     81{
     82  uint_t win_size = 1024;
     83  uint_t hop_size = 256;
     84  uint_t samplerate = 44100;
     85  aubio_tempo_t *t;
     86  fvec_t* in, *out;
     87  uint_t i;
     88
     89  // test wrong method fails
     90  if (new_aubio_tempo("unexisting_method", win_size, hop_size, samplerate))
     91    return 1;
     92
     93  // test hop > win fails
     94  if (new_aubio_tempo("default", hop_size, win_size, samplerate))
     95    return 1;
     96
     97  // test null hop_size fails
     98  if (new_aubio_tempo("default", win_size, 0, samplerate))
     99    return 1;
     100
     101  // test 1 buf_size fails
     102  if (new_aubio_tempo("default", 1, 1, samplerate))
     103    return 1;
     104
     105  // test null samplerate fails
     106  if (new_aubio_tempo("default", win_size, hop_size, 0))
     107    return 1;
     108
     109  // test short sizes workaround
     110  t = new_aubio_tempo("default", 2048, 2048, 500);
     111  if (!t)
     112    return 1;
     113
     114  del_aubio_tempo(t);
     115
     116  t = new_aubio_tempo("default", win_size, hop_size, samplerate);
     117  if (!t)
     118    return 1;
     119
     120  in = new_fvec(hop_size);
     121  out = new_fvec(1);
     122
     123  // up to step = (next_power_of_two(5.8 * samplerate / hop_size ) / 4 )
     124  for (i = 0; i < 256 + 1; i++)
     125  {
     126    aubio_tempo_do(t,in,out);
     127    PRINT_MSG("beat at %.3fms, %.3fs, frame %d, %.2f bpm "
     128        "with confidence %.2f, was tatum %d\n",
     129        aubio_tempo_get_last_ms(t), aubio_tempo_get_last_s(t),
     130        aubio_tempo_get_last(t), aubio_tempo_get_bpm(t),
     131        aubio_tempo_get_confidence(t), aubio_tempo_was_tatum(t));
     132  }
     133
     134  del_aubio_tempo(t);
     135  del_fvec(in);
     136  del_fvec(out);
     137
     138  return 0;
     139}
Note: See TracChangeset for help on using the changeset viewer.