Changeset 9d8cedf5


Ignore:
Timestamp:
Dec 7, 2018, 12:17:55 PM (6 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/cnn, feature/crepe, feature/timestretch, fix/ffmpeg5, master
Children:
97a5ac08
Parents:
4bb2e74
Message:

[tests] add test_wrong_params to test-timestretch

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/src/effects/test-timestretch.c

    r4bb2e74 r9d8cedf5  
    22#include <aubio.h>
    33#include "utils_tests.h"
     4
     5int test_wrong_params(void);
    46
    57int main (int argc, char **argv)
     
    79  sint_t err = 0;
    810
    9   if (argc < 4) {
    10     err = 2;
    11     PRINT_ERR("not enough arguments\n");
     11  if (argc < 3 || argc >= 9) {
     12    PRINT_ERR("wrong number of arguments, running tests\n");
     13    err = test_wrong_params();
    1214    PRINT_MSG("usage: %s <input_path> <output_path> <stretch> [transpose] [mode] [hop_size] [samplerate]\n", argv[0]);
    1315    PRINT_MSG(" with <stretch> a time stretching ratio in the range [0.025, 10.]\n");
     
    1719  }
    1820
    19   uint_t samplerate = 0;
     21#ifdef HAVE_RUBBERBAND
     22  uint_t samplerate = 0; // using source samplerate
    2023  uint_t hop_size = 64;
    2124  smpl_t transpose = 0.;
     
    2831  char_t *mode = "default";
    2932
    30   stretch = atof(argv[3]);
    31 
     33  if ( argc >= 4 ) stretch = atof(argv[3]);
    3234  if ( argc >= 5 ) transpose = atof(argv[4]);
    3335  if ( argc >= 6 ) mode = argv[5];
    3436  if ( argc >= 7 ) hop_size = atoi(argv[6]);
    3537  if ( argc >= 8 ) samplerate = atoi(argv[7]);
    36   if ( argc >= 9 ) {
    37     err = 2;
    38     PRINT_ERR("too many arguments\n");
    39     return err;
    40   }
    4138
    4239  uint_t source_hopsize = 2048;
     
    9794  del_aubio_source(s);
    9895beach_source:
     96#else
     97  err = 0;
     98  PRINT_ERR("aubio was not compiled with rubberband\n");
     99#endif
    99100  return err;
    100101}
     102
     103int test_wrong_params(void)
     104{
     105  const char_t *mode = "default";
     106  smpl_t stretch = 1.;
     107  uint_t hop_size = 256;
     108  uint_t samplerate = 44100;
     109
     110  if (new_aubio_timestretch("??", stretch, hop_size, samplerate)) return 1;
     111  if (new_aubio_timestretch(mode,     41., hop_size, samplerate)) return 1;
     112  if (new_aubio_timestretch(mode, stretch,        0, samplerate)) return 1;
     113  if (new_aubio_timestretch(mode, stretch, hop_size,          0)) return 1;
     114
     115  aubio_timestretch_t *p = new_aubio_timestretch(mode, stretch, hop_size,
     116      samplerate);
     117#ifdef HAVE_RUBBERBAND
     118  if (!p) return 1;
     119
     120  if (aubio_timestretch_get_latency(p) == 0) return 1;
     121
     122  aubio_timestretch_reset(p);
     123
     124  if (aubio_timestretch_get_transpose(p) != 0) return 1;
     125  if (aubio_timestretch_set_transpose(p, 2.)) return 1;
     126  if (fabsf(aubio_timestretch_get_transpose(p) - 2.) >= 1e-6) return 1;
     127  if (!aubio_timestretch_set_transpose(p, 200.)) return 1;
     128  if (!aubio_timestretch_set_transpose(p, -200.)) return 1;
     129  if (aubio_timestretch_set_transpose(p, 0.)) return 1;
     130
     131  if (aubio_timestretch_get_pitchscale(p) != 1) return 1;
     132  if (aubio_timestretch_set_pitchscale(p, 2.)) return 1;
     133  if (fabsf(aubio_timestretch_get_pitchscale(p) - 2.) >= 1e-6) return 1;
     134  if (!aubio_timestretch_set_pitchscale(p, 0.)) return 1;
     135  if (!aubio_timestretch_set_pitchscale(p, 6.)) return 1;
     136
     137  if (aubio_timestretch_get_stretch(p) != stretch) return 1;
     138  if (aubio_timestretch_set_stretch(p, 2.)) return 1;
     139  if (fabsf(aubio_timestretch_get_stretch(p) - 2.) >= 1e-6) return 1;
     140  if (!aubio_timestretch_set_stretch(p, 0.)) return 1;
     141  if (!aubio_timestretch_set_stretch(p, 41.)) return 1;
     142
     143  del_aubio_timestretch(p);
     144#else
     145  if (p) return 1;
     146#endif
     147
     148  return run_on_default_source_and_sink(main);
     149}
Note: See TracChangeset for help on using the changeset viewer.