Changeset 88d3d31 for tests


Ignore:
Timestamp:
Nov 24, 2018, 6:03:43 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/pydocstrings, feature/timestretch, fix/ffmpeg5, master
Children:
b5a0479
Parents:
63bc67b
Message:

[tests] run some tests in tempo if no arguments passed

File:
1 edited

Legend:

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

    r63bc67b r88d3d31  
    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] [win_size] [hop_size]\n", argv[0]);
    1219    return err;
     
    6572  return err;
    6673}
     74
     75int test_wrong_params(void)
     76{
     77  uint_t win_size = 1024;
     78  uint_t hop_size = 256;
     79  uint_t samplerate = 44100;
     80  aubio_tempo_t *t;
     81  fvec_t* in, *out;
     82  uint_t i;
     83
     84  // test wrong method fails
     85  if (new_aubio_tempo("unexisting_method", win_size, hop_size, samplerate))
     86    return 1;
     87
     88  // test hop > win fails
     89  if (new_aubio_tempo("default", hop_size, win_size, samplerate))
     90    return 1;
     91
     92  // test null hop_size fails
     93  if (new_aubio_tempo("default", win_size, 0, samplerate))
     94    return 1;
     95
     96  // test 1 buf_size fails
     97  if (new_aubio_tempo("default", 1, 1, samplerate))
     98    return 1;
     99
     100  // test null samplerate fails
     101  if (new_aubio_tempo("default", win_size, hop_size, 0))
     102    return 1;
     103
     104  // test short sizes workaround
     105  t = new_aubio_tempo("default", 2048, 2048, 500);
     106  if (!t)
     107    return 1;
     108
     109  del_aubio_tempo(t);
     110
     111  t = new_aubio_tempo("default", win_size, hop_size, samplerate);
     112  if (!t)
     113    return 1;
     114
     115  in = new_fvec(hop_size);
     116  out = new_fvec(1);
     117
     118  for (i = 0; i < 4; i++)
     119  {
     120    aubio_tempo_do(t,in,out);
     121    PRINT_MSG("beat at %.3fms, %.3fs, frame %d, %.2f bpm "
     122        "with confidence %.2f, was tatum %d\n",
     123        aubio_tempo_get_last_ms(t), aubio_tempo_get_last_s(t),
     124        aubio_tempo_get_last(t), aubio_tempo_get_bpm(t),
     125        aubio_tempo_get_confidence(t), aubio_tempo_was_tatum(t));
     126  }
     127
     128  del_aubio_tempo(t);
     129  del_fvec(in);
     130  del_fvec(out);
     131
     132  return 0;
     133}
Note: See TracChangeset for help on using the changeset viewer.