Changeset 46a1e34


Ignore:
Timestamp:
Dec 16, 2018, 3:46:53 AM (6 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:
633a408
Parents:
5c849af
Message:

[tests] factorise sink tests

Location:
tests/src/io
Files:
1 added
3 edited

Legend:

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

    r5c849af r46a1e34  
    22#include <aubio.h>
    33#include "utils_tests.h"
     4
     5#define aubio_sink_custom "apple_audio"
     6
     7#ifdef HAVE_SINK_APPLE_AUDIO
     8#define HAVE_AUBIO_SINK_CUSTOM
     9#define aubio_sink_custom_t aubio_sink_apple_audio_t
     10#define new_aubio_sink_custom new_aubio_sink_apple_audio
     11#define del_aubio_sink_custom del_aubio_sink_apple_audio
     12#define aubio_sink_custom_do aubio_sink_apple_audio_do
     13#define aubio_sink_custom_do_multi aubio_sink_apple_audio_do_multi
     14#define aubio_sink_custom_close aubio_sink_apple_audio_close
     15#define aubio_sink_custom_preset_samplerate aubio_sink_apple_audio_preset_samplerate
     16#define aubio_sink_custom_preset_channels aubio_sink_apple_audio_preset_channels
     17#endif /* HAVE_SINK_APPLE_AUDIO */
     18
     19#include "base-sink_custom.h"
    420
    521// this file uses the unstable aubio api, please use aubio_sink instead
     
    824int main (int argc, char **argv)
    925{
    10   sint_t err = 0;
    11 
    12   if (argc < 3) {
    13     PRINT_ERR("not enough arguments, running tests\n");
    14     err = run_on_default_source_and_sink(main);
    15     PRINT_MSG("usage: %s <input_path> <output_path> [samplerate] [hop_size]\n", argv[0]);
    16     return err;
    17   }
    18 
    19 #ifdef HAVE_SINK_APPLE_AUDIO
    20   uint_t samplerate = 0;
    21   uint_t hop_size = 512;
    22   uint_t n_frames = 0, read = 0;
    23 
    24   char_t *source_path = argv[1];
    25   char_t *sink_path = argv[2];
    26 
    27   if ( argc >= 4 ) samplerate = atoi(argv[3]);
    28   if ( argc >= 5 ) hop_size = atoi(argv[4]);
    29   if ( argc >= 6 ) {
    30     err = 2;
    31     PRINT_ERR("too many arguments\n");
    32     return err;
    33   }
    34 
    35   fvec_t *vec = new_fvec(hop_size);
    36   if (!vec) { err = 1; goto beach_fvec; }
    37 
    38   aubio_source_t *i = new_aubio_source(source_path, samplerate, hop_size);
    39   if (!i) { err = 1; goto beach_source; }
    40 
    41   if (samplerate == 0 ) samplerate = aubio_source_get_samplerate(i);
    42 
    43   aubio_sink_apple_audio_t *o = new_aubio_sink_apple_audio(sink_path, samplerate);
    44   if (!o) { err = 1; goto beach_sink; }
    45 
    46   do {
    47     aubio_source_do(i, vec, &read);
    48     aubio_sink_apple_audio_do(o, vec, read);
    49     n_frames += read;
    50   } while ( read == hop_size );
    51 
    52   PRINT_MSG("read %d frames at %dHz (%d blocks) from %s written to %s\n",
    53       n_frames, samplerate, n_frames / hop_size,
    54       source_path, sink_path);
    55 
    56   del_aubio_sink_apple_audio(o);
    57 beach_sink:
    58   del_aubio_source(i);
    59 beach_source:
    60   del_fvec(vec);
    61 beach_fvec:
    62 #else /* HAVE_SINK_APPLE_AUDIO */
    63   err = 0;
    64   PRINT_ERR("aubio was not compiled with aubio_source_apple_audio\n");
    65 #endif /* HAVE_SINK_APPLE_AUDIO */
    66   return err;
     26  return base_main(argc, argv);
    6727}
  • tests/src/io/test-sink_sndfile.c

    r5c849af r46a1e34  
    22#include <aubio.h>
    33#include "utils_tests.h"
     4
     5#define aubio_sink_custom "sndfile"
     6
     7#ifdef HAVE_SNDFILE
     8#define HAVE_AUBIO_SINK_CUSTOM
     9#define aubio_sink_custom_t aubio_sink_sndfile_t
     10#define new_aubio_sink_custom new_aubio_sink_sndfile
     11#define del_aubio_sink_custom del_aubio_sink_sndfile
     12#define aubio_sink_custom_do aubio_sink_sndfile_do
     13#define aubio_sink_custom_do_multi aubio_sink_sndfile_do_multi
     14#define aubio_sink_custom_close aubio_sink_sndfile_close
     15#define aubio_sink_custom_preset_samplerate aubio_sink_sndfile_preset_samplerate
     16#define aubio_sink_custom_preset_channels aubio_sink_sndfile_preset_channels
     17#endif /* HAVE_SNDFILE */
     18
     19#include "base-sink_custom.h"
    420
    521// this file uses the unstable aubio api, please use aubio_sink instead
     
    824int main (int argc, char **argv)
    925{
    10   sint_t err = 0;
    11 
    12   if (argc < 3) {
    13     PRINT_ERR("not enough arguments, running tests\n");
    14     err = run_on_default_source_and_sink(main);
    15     PRINT_MSG("usage: %s <input_path> <output_path> [samplerate] [hop_size]\n", argv[0]);
    16     return err;
    17   }
    18 
    19 #ifdef HAVE_SNDFILE
    20   uint_t samplerate = 0;
    21   uint_t hop_size = 512;
    22   uint_t n_frames = 0, read = 0;
    23 
    24   char_t *source_path = argv[1];
    25   char_t *sink_path = argv[2];
    26 
    27   if ( argc >= 4 ) samplerate = atoi(argv[3]);
    28   if ( argc >= 5 ) hop_size = atoi(argv[4]);
    29   if ( argc >= 6 ) {
    30     err = 2;
    31     PRINT_ERR("too many arguments\n");
    32     return err;
    33   }
    34 
    35   fvec_t *vec = new_fvec(hop_size);
    36   if (!vec) { err = 1; goto beach_fvec; }
    37 
    38   aubio_source_t *i = new_aubio_source(source_path, samplerate, hop_size);
    39   if (!i) { err = 1; goto beach_source; }
    40 
    41   if (samplerate == 0 ) samplerate = aubio_source_get_samplerate(i);
    42 
    43   aubio_sink_sndfile_t *o = new_aubio_sink_sndfile(sink_path, samplerate);
    44   if (!o) { err = 1; goto beach_sink; }
    45 
    46   do {
    47     aubio_source_do(i, vec, &read);
    48     aubio_sink_sndfile_do(o, vec, read);
    49     n_frames += read;
    50   } while ( read == hop_size );
    51 
    52   PRINT_MSG("read %d frames at %dHz (%d blocks) from %s written to %s\n",
    53       n_frames, samplerate, n_frames / hop_size,
    54       source_path, sink_path);
    55 
    56   del_aubio_sink_sndfile(o);
    57 beach_sink:
    58   del_aubio_source(i);
    59 beach_source:
    60   del_fvec(vec);
    61 beach_fvec:
    62 #else
    63   err = 0;
    64   PRINT_ERR("aubio was not compiled with aubio_source_sndfile\n");
    65 #endif /* HAVE_SNDFILE */
    66   return err;
     26  return base_main(argc, argv);
    6727}
  • tests/src/io/test-sink_wavwrite.c

    r5c849af r46a1e34  
    22#include <aubio.h>
    33#include "utils_tests.h"
     4
     5#define aubio_sink_custom "wavwrite"
     6
     7#ifdef HAVE_WAVWRITE
     8#define HAVE_AUBIO_SINK_CUSTOM
     9#define aubio_sink_custom_t aubio_sink_wavwrite_t
     10#define new_aubio_sink_custom new_aubio_sink_wavwrite
     11#define del_aubio_sink_custom del_aubio_sink_wavwrite
     12#define aubio_sink_custom_do aubio_sink_wavwrite_do
     13#define aubio_sink_custom_do_multi aubio_sink_wavwrite_do_multi
     14#define aubio_sink_custom_close aubio_sink_wavwrite_close
     15#define aubio_sink_custom_preset_samplerate aubio_sink_wavwrite_preset_samplerate
     16#define aubio_sink_custom_preset_channels aubio_sink_wavwrite_preset_channels
     17#endif /* HAVE_WAVWRITE */
     18
     19#include "base-sink_custom.h"
    420
    521// this file uses the unstable aubio api, please use aubio_sink instead
     
    824int main (int argc, char **argv)
    925{
    10   sint_t err = 0;
    11 
    12   if (argc < 3) {
    13     PRINT_ERR("not enough arguments, running tests\n");
    14     err = run_on_default_source_and_sink(main);
    15     PRINT_MSG("usage: %s <input_path> <output_path> [samplerate] [hop_size]\n", argv[0]);
    16     return err;
    17   }
    18 
    19 #ifdef HAVE_WAVWRITE
    20   uint_t samplerate = 0;
    21   uint_t hop_size = 512;
    22   uint_t n_frames = 0, read = 0;
    23 
    24   char_t *source_path = argv[1];
    25   char_t *sink_path = argv[2];
    26 
    27   if ( argc >= 4 ) samplerate = atoi(argv[3]);
    28   if ( argc >= 5 ) hop_size = atoi(argv[4]);
    29   if ( argc >= 6 ) {
    30     err = 2;
    31     PRINT_ERR("too many arguments\n");
    32     return err;
    33   }
    34 
    35   fvec_t *vec = new_fvec(hop_size);
    36   if (!vec) { err = 1; goto beach_fvec; }
    37 
    38   aubio_source_t *i = new_aubio_source(source_path, samplerate, hop_size);
    39   if (!i) { err = 1; goto beach_source; }
    40 
    41   if (samplerate == 0 ) samplerate = aubio_source_get_samplerate(i);
    42 
    43   aubio_sink_wavwrite_t *o = new_aubio_sink_wavwrite(sink_path, samplerate);
    44   if (!o) { err = 1; goto beach_sink; }
    45 
    46   do {
    47     aubio_source_do(i, vec, &read);
    48     aubio_sink_wavwrite_do(o, vec, read);
    49     n_frames += read;
    50   } while ( read == hop_size );
    51 
    52   PRINT_MSG("read %d frames at %dHz (%d blocks) from %s written to %s\n",
    53       n_frames, samplerate, n_frames / hop_size,
    54       source_path, sink_path);
    55 
    56   del_aubio_sink_wavwrite(o);
    57 beach_sink:
    58   del_aubio_source(i);
    59 beach_source:
    60   del_fvec(vec);
    61 beach_fvec:
    62 #else
    63   err = 0;
    64   PRINT_ERR("aubio was not compiled with aubio_sink_wavwrite\n");
    65 #endif /* HAVE_WAVWRITE */
    66   return err;
     26  return base_main(argc, argv);
    6727}
Note: See TracChangeset for help on using the changeset viewer.