Changeset 276032d


Ignore:
Timestamp:
Dec 16, 2018, 7:19:58 PM (5 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/timestretch, fix/ffmpeg5, master
Children:
4ca4a4a
Parents:
dea8506
Message:

[tests] add more sink tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/src/io/base-sink_custom.h

    rdea8506 r276032d  
    6464int test_wrong_params(void)
    6565{
     66  fvec_t *vec;
     67  fmat_t *mat;
    6668  aubio_sink_custom_t *s;
    6769  char_t sink_path[PATH_MAX] = "tmp_aubio_XXXXXX";
    6870  uint_t samplerate = 44100;
     71  uint_t hop_size = 256;
     72  uint_t oversized_hop_size = 4097;
     73  uint_t oversized_samplerate = 192000 * 8 + 1;
     74  uint_t channels = 3;
     75  uint_t oversized_channels = 1025;
    6976  // create temp file
    7077  int fd = create_temp_sink(sink_path);
     
    7885  s = new_aubio_sink_custom(sink_path, 0);
    7986
     87  // check setting wrong parameters fails
     88  if (!aubio_sink_custom_preset_samplerate(s, oversized_samplerate)) return 1;
     89  if (!aubio_sink_custom_preset_channels(s, oversized_channels)) return 1;
     90  if (!aubio_sink_custom_preset_channels(s, -1)) return 1;
     91
     92  // check setting valid parameters passes
    8093  if (aubio_sink_custom_preset_samplerate(s, samplerate)) return 1;
    8194  if (aubio_sink_custom_preset_channels(s, 1)) return 1;
     95
     96  // check writing a vector with valid length
     97  vec = new_fvec(hop_size);
     98  aubio_sink_custom_do(s, vec, hop_size);
     99  // check writing more than in the input
     100  aubio_sink_custom_do(s, vec, hop_size+1);
     101  // check write 0 frames
     102  aubio_sink_custom_do(s, vec, 0);
     103  del_fvec(vec);
     104
     105  // check writing an oversized vector
     106  vec = new_fvec(oversized_hop_size);
     107  aubio_sink_custom_do(s, vec, oversized_hop_size);
     108  del_fvec(vec);
    82109
    83110  // test delete without closing
     
    86113  s = new_aubio_sink_custom(sink_path, 0);
    87114
     115  // preset channels first
     116  if (aubio_sink_custom_preset_channels(s, channels)) return 1;
    88117  if (aubio_sink_custom_preset_samplerate(s, samplerate)) return 1;
    89   if (aubio_sink_custom_preset_channels(s, 3)) return 1;
     118
     119  mat = new_fmat(channels, hop_size);
     120  // check writing a vector with valid length
     121  aubio_sink_custom_do_multi(s, mat, hop_size);
     122  // check writing more than in the input
     123  aubio_sink_custom_do_multi(s, mat, hop_size+1);
     124  del_fmat(mat);
     125
     126  // check writing oversized input
     127  mat = new_fmat(channels, oversized_hop_size);
     128  aubio_sink_custom_do_multi(s, mat, oversized_hop_size);
     129  del_fmat(mat);
     130
     131  // check writing undersized input
     132  mat = new_fmat(channels - 1, hop_size);
     133  aubio_sink_custom_do_multi(s, mat, hop_size);
     134  del_fmat(mat);
    90135
    91136  aubio_sink_custom_close(s);
Note: See TracChangeset for help on using the changeset viewer.