Changeset 41d14b8 for tests


Ignore:
Timestamp:
Dec 17, 2018, 4:41:40 PM (6 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/crepe, fix/ffmpeg5, master
Children:
09b4be9
Parents:
68b991e
Message:

[tests] update test-sink_flac

File:
1 edited

Legend:

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

    r68b991e r41d14b8  
    33#include "utils_tests.h"
    44
    5 #if 1 // test without inclusion in headers
     5#define aubio_sink_custom "flac"
     6
     7#ifdef HAVE_FLAC
     8// functions not exposed in the headers, declared here
    69typedef struct _aubio_sink_flac_t aubio_sink_flac_t;
    710extern aubio_sink_flac_t * new_aubio_sink_flac(const char_t *uri,
     
    912extern void del_aubio_sink_flac (aubio_sink_flac_t *s);
    1013extern uint_t aubio_sink_flac_open(aubio_sink_flac_t *s);
     14extern uint_t aubio_sink_flac_close(aubio_sink_flac_t *s);
    1115extern uint_t aubio_sink_flac_preset_channels(aubio_sink_flac_t *s,
    1216    uint_t channels);
    1317extern uint_t aubio_sink_flac_preset_samplerate(aubio_sink_flac_t *s,
    1418    uint_t samplerate);
     19extern void aubio_sink_flac_do(aubio_sink_flac_t *s, fvec_t* write_data,
     20    uint_t write);
     21extern void aubio_sink_flac_do_multi(aubio_sink_flac_t *s,
     22    fmat_t *write_data, uint_t write);
    1523extern uint_t aubio_sink_flac_get_channels(aubio_sink_flac_t *s);
    1624extern uint_t aubio_sink_flac_get_samplerate(aubio_sink_flac_t *s);
    17 extern void aubio_sink_flac_do_multi(aubio_sink_flac_t *s, fmat_t*
    18     write_data, uint_t write);
    19 #endif
    2025
    21 // this file uses the unstable aubio api to test aubio_sink_flac, please
    22 // use aubio_sink instead see src/io/sink.h and tests/src/sink/test-sink.c
     26#define HAVE_AUBIO_SINK_CUSTOM
     27#define aubio_sink_custom_t aubio_sink_flac_t
     28#define new_aubio_sink_custom new_aubio_sink_flac
     29#define del_aubio_sink_custom del_aubio_sink_flac
     30#define aubio_sink_custom_do aubio_sink_flac_do
     31#define aubio_sink_custom_do_multi aubio_sink_flac_do_multi
     32#define aubio_sink_custom_close aubio_sink_flac_close
     33#define aubio_sink_custom_preset_samplerate aubio_sink_flac_preset_samplerate
     34#define aubio_sink_custom_preset_channels aubio_sink_flac_preset_channels
     35#define aubio_sink_custom_get_samplerate aubio_sink_flac_get_samplerate
     36#define aubio_sink_custom_get_channels aubio_sink_flac_get_channels
     37#endif /* HAVE_FLAC */
     38
     39#include "base-sink_custom.h"
     40
     41// this file uses the unstable aubio api, please use aubio_sink instead
     42// see src/io/sink.h and tests/src/sink/test-sink.c
    2343
    2444int main (int argc, char **argv)
    2545{
    26   sint_t err = 0;
    27 
    28   if (argc < 3) {
    29     PRINT_ERR("not enough arguments, running tests\n");
    30     err = run_on_default_source_and_sink(main);
    31     PRINT_MSG("usage: %s <input_path> <output_path> [samplerate] [channels] [hop_size]\n", argv[0]);
    32     return err;
    33   }
    34 
    35 #ifdef HAVE_FLAC
    36   uint_t samplerate = 0;
    37   uint_t channels = 0;
    38   uint_t hop_size = 512;
    39   uint_t n_frames = 0, read = 0;
    40 
    41   char_t *source_path = argv[1];
    42   char_t *sink_path = argv[2];
    43 
    44   if ( argc >= 4 ) samplerate = atoi(argv[3]);
    45   if ( argc >= 5 ) channels = atoi(argv[4]);
    46   if ( argc >= 6 ) hop_size = atoi(argv[5]);
    47   if ( argc >= 7 ) {
    48     err = 2;
    49     PRINT_ERR("too many arguments\n");
    50     return err;
    51   }
    52 
    53   aubio_source_t *i = new_aubio_source(source_path, samplerate, hop_size);
    54   if (!i) { err = 1; goto beach_source; }
    55 
    56   if (samplerate == 0 ) samplerate = aubio_source_get_samplerate(i);
    57   if (channels == 0 ) channels = aubio_source_get_channels(i);
    58 
    59   fmat_t *mat = new_fmat(channels, hop_size);
    60   if (!mat) { err = 1; goto beach_fmat; }
    61 
    62   aubio_sink_flac_t *o = new_aubio_sink_flac(sink_path, 0);
    63   if (!o) { err = 1; goto beach_sink; }
    64   err = aubio_sink_flac_preset_samplerate(o, samplerate);
    65   if (err) { goto beach; }
    66   err = aubio_sink_flac_preset_channels(o, channels);
    67   if (err) { goto beach; }
    68 
    69   do {
    70     aubio_source_do_multi(i, mat, &read);
    71     aubio_sink_flac_do_multi(o, mat, read);
    72     n_frames += read;
    73   } while ( read == hop_size );
    74 
    75   PRINT_MSG("read %d frames at %dHz in %d channels (%d blocks) from %s written to %s\n",
    76       n_frames, samplerate, channels, n_frames / hop_size,
    77       source_path, sink_path);
    78   PRINT_MSG("wrote %s with %dHz in %d channels\n", sink_path,
    79       aubio_sink_flac_get_samplerate(o),
    80       aubio_sink_flac_get_channels(o) );
    81 
    82 beach:
    83   del_aubio_sink_flac(o);
    84 beach_sink:
    85   del_fmat(mat);
    86 beach_fmat:
    87   del_aubio_source(i);
    88 beach_source:
    89 #else /* HAVE_FLAC */
    90   err = 0;
    91   PRINT_ERR("aubio was not compiled with aubio_sink_flac\n");
    92 #endif /* HAVE_FLAC */
    93   return err;
     46  return base_main(argc, argv);
    9447}
Note: See TracChangeset for help on using the changeset viewer.