Ignore:
Timestamp:
Dec 17, 2018, 2:34:15 AM (6 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/crepe, fix/ffmpeg5, master
Children:
4c37e87
Parents:
0850e54 (diff), 0512fca (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/sink_vorbis

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/src/io/test-source.c

    r0850e54 r40bdc14  
    22#include "utils_tests.h"
    33
    4 int main (int argc, char **argv)
     4int test_wrong_params(void);
     5
     6int main(int argc, char **argv)
    57{
    68  uint_t err = 0;
    79  if (argc < 2) {
    810    PRINT_ERR("not enough arguments, running tests\n");
    9     err = run_on_default_source(main);
     11    err = test_wrong_params();
    1012    PRINT_MSG("read a wave file as a mono vector\n");
    1113    PRINT_MSG("usage: %s <source_path> [samplerate] [hop_size]\n", argv[0]);
     
    2830  char_t *source_path = argv[1];
    2931
    30 
    3132  aubio_source_t* s =
    3233    new_aubio_source(source_path, samplerate, hop_size);
    33   if (!s) { err = 1; goto beach; }
    3434  fvec_t *vec = new_fvec(hop_size);
     35  if (!s || !vec) { err = 1; goto beach; }
    3536
    3637  uint_t n_frames_expected = aubio_source_get_duration(s);
     
    5051  // close the file (optional)
    5152  aubio_source_close(s);
     53
     54beach:
     55  if (vec)
     56    del_fvec(vec);
     57  if (s)
     58    del_aubio_source(s);
     59  return err;
     60}
     61
     62int test_wrong_params(void)
     63{
     64  char_t *uri = DEFINEDSTRING(AUBIO_TESTS_SOURCE);
     65  uint_t samplerate = 44100;
     66  uint_t hop_size = 512;
     67  uint_t channels, read = 0;
     68  fvec_t *vec;
     69  fmat_t *mat;
     70  aubio_source_t *s;
     71
     72  if (new_aubio_source(0,    samplerate, hop_size)) return 1;
     73  if (new_aubio_source("\0", samplerate, hop_size)) return 1;
     74  if (new_aubio_source(uri,          -1, hop_size)) return 1;
     75  if (new_aubio_source(uri,           0,        0)) return 1;
     76
     77  s = new_aubio_source(uri, samplerate, hop_size);
     78  if (!s) return 1;
     79  channels = aubio_source_get_channels(s);
     80
     81  // vector to read downmixed samples
     82  vec = new_fvec(hop_size);
     83  // matrix to read individual channels
     84  mat = new_fmat(channels, hop_size);
     85
     86  if (aubio_source_get_samplerate(s) != samplerate) return 1;
     87
     88  // read first hop_size frames
     89  aubio_source_do(s, vec, &read);
     90  if (read != hop_size) return 1;
     91
     92  // seek to 0
     93  if(aubio_source_seek(s, 0)) return 1;
     94
     95  // read again as multiple channels
     96  aubio_source_do_multi(s, mat, &read);
     97  if (read != hop_size) return 1;
     98
     99  // close the file (optional)
     100  aubio_source_close(s);
    52101  // test closing the file a second time
    53102  aubio_source_close(s);
    54103
    55   del_fvec (vec);
    56   del_aubio_source (s);
    57 beach:
    58   return err;
     104  del_aubio_source(s);
     105  del_fmat(mat);
     106  del_fvec(vec);
     107
     108  return run_on_default_source(main);
    59109}
Note: See TracChangeset for help on using the changeset viewer.