Changes in / [e8c4de2:9ec63a0]


Ignore:
Files:
3 deleted
11 edited

Legend:

Unmodified
Added
Removed
  • doc/web.cfg

    re8c4de2 r9ec63a0  
    703703EXCLUDE                = ../src/aubio_priv.h \
    704704                         ../src/mathutils .h \
    705                          ../src/io/audio_unit.h \
    706705                         ../src/io/source_sndfile.h \
    707706                         ../src/io/source_apple_audio.h \
    708                          ../src/io/source_avcodec.h \
    709707                         ../src/io/sink_sndfile.h \
    710708                         ../src/io/sink_apple_audio.h \
  • python/lib/generator.py

    re8c4de2 r9ec63a0  
    5858      'source_apple_audio',
    5959      'source_sndfile',
    60       'source_avcodec',
    6160      #'sampler',
    6261      'audio_unit',
  • src/aubio.h

    re8c4de2 r9ec63a0  
    194194#include "io/source_sndfile.h"
    195195#include "io/source_apple_audio.h"
    196 #include "io/source_avcodec.h"
    197196#include "io/sink_sndfile.h"
    198197#include "io/sink_apple_audio.h"
  • src/io/source.c

    re8c4de2 r9ec63a0  
    2424#include "fmat.h"
    2525#include "io/source.h"
    26 #ifdef HAVE_AVCODEC
    27 #include "io/source_avcodec.h"
    28 #endif /* HAVE_AVCODEC */
    2926#ifdef __APPLE__
    3027#include "io/source_apple_audio.h"
     
    3229#ifdef HAVE_SNDFILE
    3330#include "io/source_sndfile.h"
    34 #endif /* HAVE_SNDFILE */
    35 
    36 typedef void (*aubio_source_do_t)(aubio_source_t * s, fvec_t * data, uint_t * read);
    37 typedef void (*aubio_source_do_multi_t)(aubio_source_t * s, fmat_t * data, uint_t * read);
    38 typedef uint_t (*aubio_source_get_samplerate_t)(aubio_source_t * s);
    39 typedef uint_t (*aubio_source_get_channels_t)(aubio_source_t * s);
    40 typedef uint_t (*aubio_source_seek_t)(aubio_source_t * s, uint_t seek);
    41 typedef uint_t (*del_aubio_source_t)(aubio_source_t * s);
     31#endif
    4232
    4333struct _aubio_source_t {
    4434  void *source;
    45   aubio_source_do_t s_do;
    46   aubio_source_do_multi_t s_do_multi;
    47   aubio_source_get_samplerate_t s_get_samplerate;
    48   aubio_source_get_channels_t s_get_channels;
    49   aubio_source_seek_t s_seek;
    50   del_aubio_source_t s_del;
    5135};
    5236
    5337aubio_source_t * new_aubio_source(char_t * uri, uint_t samplerate, uint_t hop_size) {
    5438  aubio_source_t * s = AUBIO_NEW(aubio_source_t);
    55 #if HAVE_AVCODEC
    56   s->source = (void *)new_aubio_source_avcodec(uri, samplerate, hop_size);
    57   if (s->source) {
    58     s->s_do = (aubio_source_do_t)(aubio_source_avcodec_do);
    59     s->s_do_multi = (aubio_source_do_multi_t)(aubio_source_avcodec_do_multi);
    60     s->s_get_channels = (aubio_source_get_channels_t)(aubio_source_avcodec_get_channels);
    61     s->s_get_samplerate = (aubio_source_get_samplerate_t)(aubio_source_avcodec_get_samplerate);
    62     s->s_seek = (aubio_source_seek_t)(aubio_source_avcodec_seek);
    63     s->s_del = (del_aubio_source_t)(del_aubio_source_avcodec);
    64     return s;
    65   }
    66 #endif /* HAVE_AVCODEC */
    6739#ifdef __APPLE__
    6840  s->source = (void *)new_aubio_source_apple_audio(uri, samplerate, hop_size);
    69   if (s->source) {
    70     s->s_do = (aubio_source_do_t)(aubio_source_apple_audio_do);
    71     s->s_do_multi = (aubio_source_do_multi_t)(aubio_source_apple_audio_do_multi);
    72     s->s_get_channels = (aubio_source_get_channels_t)(aubio_source_apple_audio_get_channels);
    73     s->s_get_samplerate = (aubio_source_get_samplerate_t)(aubio_source_apple_audio_get_samplerate);
    74     s->s_seek = (aubio_source_seek_t)(aubio_source_apple_audio_seek);
    75     s->s_del = (del_aubio_source_t)(del_aubio_source_apple_audio);
    76     return s;
    77   }
    78 #endif /* __APPLE__ */
     41  if (s->source) return s;
     42#else /* __APPLE__ */
    7943#if HAVE_SNDFILE
    8044  s->source = (void *)new_aubio_source_sndfile(uri, samplerate, hop_size);
    81   if (s->source) {
    82     s->s_do = (aubio_source_do_t)(aubio_source_sndfile_do);
    83     s->s_do_multi = (aubio_source_do_multi_t)(aubio_source_sndfile_do_multi);
    84     s->s_get_channels = (aubio_source_get_channels_t)(aubio_source_sndfile_get_channels);
    85     s->s_get_samplerate = (aubio_source_get_samplerate_t)(aubio_source_sndfile_get_samplerate);
    86     s->s_seek = (aubio_source_seek_t)(aubio_source_sndfile_seek);
    87     s->s_del = (del_aubio_source_t)(del_aubio_source_sndfile);
    88     return s;
    89   }
     45  if (s->source) return s;
    9046#endif /* HAVE_SNDFILE */
     47#endif /* __APPLE__ */
    9148  AUBIO_ERROR("failed creating aubio source with %s\n", uri);
    9249  AUBIO_FREE(s);
     
    9552
    9653void aubio_source_do(aubio_source_t * s, fvec_t * data, uint_t * read) {
    97   s->s_do((void *)s->source, data, read);
     54#ifdef __APPLE__
     55  aubio_source_apple_audio_do((aubio_source_apple_audio_t *)s->source, data, read);
     56#else /* __APPLE__ */
     57#if HAVE_SNDFILE
     58  aubio_source_sndfile_do((aubio_source_sndfile_t *)s->source, data, read);
     59#endif /* HAVE_SNDFILE */
     60#endif /* __APPLE__ */
    9861}
    9962
    10063void aubio_source_do_multi(aubio_source_t * s, fmat_t * data, uint_t * read) {
    101   s->s_do_multi((void *)s->source, data, read);
     64#ifdef __APPLE__
     65  aubio_source_apple_audio_do_multi((aubio_source_apple_audio_t *)s->source, data, read);
     66#else /* __APPLE__ */
     67#if HAVE_SNDFILE
     68  aubio_source_sndfile_do_multi((aubio_source_sndfile_t *)s->source, data, read);
     69#endif /* HAVE_SNDFILE */
     70#endif /* __APPLE__ */
    10271}
    10372
    10473void del_aubio_source(aubio_source_t * s) {
    10574  if (!s) return;
    106   s->s_del((void *)s->source);
     75#ifdef __APPLE__
     76  del_aubio_source_apple_audio((aubio_source_apple_audio_t *)s->source);
     77#else /* __APPLE__ */
     78#if HAVE_SNDFILE
     79  del_aubio_source_sndfile((aubio_source_sndfile_t *)s->source);
     80#endif /* HAVE_SNDFILE */
     81#endif /* __APPLE__ */
    10782  AUBIO_FREE(s);
    10883}
    10984
    11085uint_t aubio_source_get_samplerate(aubio_source_t * s) {
    111   return s->s_get_samplerate((void *)s->source);
     86#ifdef __APPLE__
     87  return aubio_source_apple_audio_get_samplerate((aubio_source_apple_audio_t *)s->source);
     88#else /* __APPLE__ */
     89#if HAVE_SNDFILE
     90  return aubio_source_sndfile_get_samplerate((aubio_source_sndfile_t *)s->source);
     91#endif /* HAVE_SNDFILE */
     92#endif /* __APPLE__ */
    11293}
    11394
    11495uint_t aubio_source_get_channels(aubio_source_t * s) {
    115   return s->s_get_channels((void *)s->source);
     96#ifdef __APPLE__
     97  return aubio_source_apple_audio_get_channels((aubio_source_apple_audio_t *)s->source);
     98#else /* __APPLE__ */
     99#if HAVE_SNDFILE
     100  return aubio_source_sndfile_get_channels((aubio_source_sndfile_t *)s->source);
     101#endif /* HAVE_SNDFILE */
     102#endif /* __APPLE__ */
    116103}
    117104
    118105uint_t aubio_source_seek (aubio_source_t * s, uint_t seek ) {
    119   return s->s_seek((void *)s->source, seek);
     106#ifdef __APPLE__
     107  return aubio_source_apple_audio_seek ((aubio_source_apple_audio_t *)s->source, seek);
     108#else /* __APPLE__ */
     109#if HAVE_SNDFILE
     110  return aubio_source_sndfile_seek ((aubio_source_sndfile_t *)s->source, seek);
     111#endif /* HAVE_SNDFILE */
     112#endif /* __APPLE__ */
    120113}
  • src/io/source.h

    re8c4de2 r9ec63a0  
    7777  \param s source object, created with ::new_aubio_source
    7878  \param read_to ::fmat_t of data to read to
    79   \param[out] read upon returns, equals to number of frames actually read
     79  \param read upon returns, equals to number of frames actually read
    8080
    8181  Upon returns, `read` contains the number of frames actually read from the
  • src/io/source_sndfile.c

    re8c4de2 r9ec63a0  
    6767  if (path == NULL) {
    6868    AUBIO_ERR("Aborted opening null path\n");
    69     goto beach;
    70   }
    71   if ((sint_t)samplerate < 0) {
    72     AUBIO_ERR("Can not open %s with samplerate %d\n", path, samplerate);
    73     goto beach;
    74   }
    75   if ((sint_t)hop_size <= 0) {
    76     AUBIO_ERR("Can not open %s with hop_size %d\n", path, hop_size);
    77     goto beach;
     69    return NULL;
    7870  }
    7971
     
    8274  s->path = path;
    8375
    84   // try opening the file, getting the info in sfinfo
     76  // try opening the file, geting the info in sfinfo
    8577  SF_INFO sfinfo;
    8678  AUBIO_MEMSET(&sfinfo, 0, sizeof (sfinfo));
     
    142134
    143135beach:
    144   //AUBIO_ERR("can not read %s at samplerate %dHz with a hop_size of %d\n",
    145   //    s->path, s->samplerate, s->hop_size);
     136  AUBIO_ERR("can not read %s at samplerate %dHz with a hop_size of %d\n",
     137      s->path, s->samplerate, s->hop_size);
    146138  del_aubio_source_sndfile(s);
    147139  return NULL;
  • src/wscript_build

    re8c4de2 r9ec63a0  
    66uselib += ['SAMPLERATE']
    77uselib += ['SNDFILE']
    8 uselib += ['AVCODEC']
    9 uselib += ['AVFORMAT']
    10 uselib += ['AVRESAMPLE']
    11 uselib += ['AVUTIL']
    128uselib += ['JACK']
    139uselib += ['LASH']
  • tests/src/io/test-source.c

    re8c4de2 r9ec63a0  
    2828  char_t *source_path = argv[1];
    2929
     30  fvec_t *vec = new_fvec(hop_size);
    3031
    31   aubio_source_t* s =
    32     new_aubio_source(source_path, samplerate, hop_size);
     32  aubio_source_t* s = new_aubio_source(source_path, samplerate, hop_size);
    3333  if (!s) { err = 1; goto beach; }
    34   fvec_t *vec = new_fvec(hop_size);
    3534
    3635  if (samplerate == 0 ) samplerate = aubio_source_get_samplerate(s);
     
    4544    n_frames / hop_size, source_path);
    4645
    47   del_fvec (vec);
    4846  del_aubio_source (s);
    4947beach:
     48  del_fvec (vec);
     49
    5050  return err;
    5151}
  • tests/src/io/test-source_apple_audio.c

    re8c4de2 r9ec63a0  
    1212    err = 2;
    1313    PRINT_ERR("not enough arguments\n");
    14     PRINT_MSG("read a wave file as a mono vector\n");
    15     PRINT_MSG("usage: %s <source_path> [samplerate] [hop_size]\n", argv[0]);
    16     PRINT_MSG("examples:\n");
    17     PRINT_MSG(" - read file.wav at original samplerate\n");
    18     PRINT_MSG("       %s file.wav\n", argv[0]);
    19     PRINT_MSG(" - read file.wav at 32000Hz\n");
    20     PRINT_MSG("       %s file.aif 32000\n", argv[0]);
    21     PRINT_MSG(" - read file.wav at original samplerate with 4096 blocks\n");
    22     PRINT_MSG("       %s file.wav 0 4096 \n", argv[0]);
     14    PRINT_MSG("usage: %s <source_path> [samplerate]\n", argv[0]);
    2315    return err;
    2416  }
    2517
    2618#if __APPLE__
    27   uint_t samplerate = 0;
     19  uint_t samplerate = 32000;
    2820  uint_t hop_size = 256;
    2921  uint_t n_frames = 0, read = 0;
    3022  if ( argc == 3 ) samplerate = atoi(argv[2]);
    31   if ( argc == 4 ) hop_size = atoi(argv[3]);
    3223
    3324  char_t *source_path = argv[1];
    3425
     26  fvec_t *vec = new_fvec(hop_size);
     27  aubio_source_apple_audio_t * s = new_aubio_source_apple_audio(source_path, samplerate, hop_size);
     28  if (samplerate == 0 ) samplerate = aubio_source_apple_audio_get_samplerate(s);
    3529
    36   aubio_source_apple_audio_t * s =
    37     new_aubio_source_apple_audio(source_path, samplerate, hop_size);
    3830  if (!s) { err = 1; goto beach; }
    39   fvec_t *vec = new_fvec(hop_size);
    40 
    41   if (samplerate == 0 ) samplerate = aubio_source_apple_audio_get_samplerate(s);
    4231
    4332  do {
    4433    aubio_source_apple_audio_do(s, vec, &read);
    45     fvec_print (vec);
     34    // fvec_print (vec);
    4635    n_frames += read;
    4736  } while ( read == hop_size );
    4837
    49   PRINT_MSG("read %d frames at %dHz (%d blocks) from %s\n", n_frames, samplerate,
    50     n_frames / hop_size, source_path);
    51 
     38beach:
     39  del_aubio_source_apple_audio (s);
    5240  del_fvec (vec);
    53   del_aubio_source_apple_audio (s);
    54 beach:
    5541#else
    5642  err = 3;
  • tests/src/io/test-source_sndfile.c

    re8c4de2 r9ec63a0  
    1313    err = 2;
    1414    PRINT_ERR("not enough arguments\n");
    15     PRINT_MSG("read a wave file as a mono vector\n");
    16     PRINT_MSG("usage: %s <source_path> [samplerate] [hop_size]\n", argv[0]);
    17     PRINT_MSG("examples:\n");
    18     PRINT_MSG(" - read file.wav at original samplerate\n");
    19     PRINT_MSG("       %s file.wav\n", argv[0]);
    20     PRINT_MSG(" - read file.wav at 32000Hz\n");
    21     PRINT_MSG("       %s file.aif 32000\n", argv[0]);
    22     PRINT_MSG(" - read file.wav at original samplerate with 4096 blocks\n");
    23     PRINT_MSG("       %s file.wav 0 4096 \n", argv[0]);
     15    PRINT_MSG("usage: %s <source_path> [samplerate]\n", argv[0]);
    2416    return err;
    2517  }
    2618
    2719#ifdef HAVE_SNDFILE
    28   uint_t samplerate = 0;
     20  uint_t samplerate = 32000;
    2921  uint_t hop_size = 256;
    3022  uint_t n_frames = 0, read = 0;
    3123  if ( argc == 3 ) samplerate = atoi(argv[2]);
    32   if ( argc == 4 ) hop_size = atoi(argv[3]);
    3324
    3425  char_t *source_path = argv[1];
    3526
    36 
    37   aubio_source_sndfile_t * s =
    38     new_aubio_source_sndfile(source_path, samplerate, hop_size);
     27  fvec_t *vec = new_fvec(hop_size);
     28  aubio_source_sndfile_t * s = new_aubio_source_sndfile(source_path, samplerate, hop_size);
    3929  if (!s) { err = 1; goto beach; }
    40   fvec_t *vec = new_fvec(hop_size);
    41 
    4230  if (samplerate == 0 ) samplerate = aubio_source_sndfile_get_samplerate(s);
    4331
    4432  do {
    4533    aubio_source_sndfile_do(s, vec, &read);
    46     fvec_print (vec);
     34    // fvec_print (vec);
    4735    n_frames += read;
    4836  } while ( read == hop_size );
    4937
    50   PRINT_MSG("read %d frames at %dHz (%d blocks) from %s\n", n_frames, samplerate,
    51     n_frames / hop_size, source_path);
    52 
    53   del_fvec (vec);
    5438  del_aubio_source_sndfile (s);
    5539beach:
     40  del_fvec (vec);
    5641#else
    5742  err = 3;
  • wscript

    re8c4de2 r9ec63a0  
    5757  add_option_enable_disable(ctx, 'sndfile', default = None,
    5858          help_str = 'compile with sndfile (auto)', help_disable_str = 'disable sndfile')
    59   add_option_enable_disable(ctx, 'avcodec', default = None,
    60           help_str = 'compile with libavcodec (auto)', help_disable_str = 'disable libavcodec')
    6159  add_option_enable_disable(ctx, 'samplerate', default = None,
    6260          help_str = 'compile with samplerate (auto)', help_disable_str = 'disable samplerate')
     
    202200    args = '--cflags --libs', uselib_store = 'LASH', mandatory = False)
    203201
    204   if (ctx.options.enable_avcodec != False):
    205     ctx.check_cfg(package = 'libavcodec', atleast_version = '54.35.0',
    206     args = '--cflags --libs', uselib_store = 'AVCODEC', mandatory = False)
    207     ctx.check_cfg(package = 'libavformat', atleast_version = '52.3.0',
    208     args = '--cflags --libs', uselib_store = 'AVFORMAT', mandatory = False)
    209     ctx.check_cfg(package = 'libavutil', atleast_version = '52.3.0',
    210     args = '--cflags --libs', uselib_store = 'AVUTIL', mandatory = False)
    211     ctx.check_cfg(package = 'libavresample', atleast_version = '1.0.1',
    212     args = '--cflags --libs', uselib_store = 'AVRESAMPLE', mandatory = False)
    213 
    214202  # write configuration header
    215203  ctx.write_config_header('src/config.h')
Note: See TracChangeset for help on using the changeset viewer.