Changeset e8c4de2 for src


Ignore:
Timestamp:
Dec 6, 2013, 8:39:41 PM (11 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, pitchshift, sampler, timestretch, yinfft+
Children:
cc6b221
Parents:
9ec63a0 (diff), 7816f2b (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'avcodec' into develop

Location:
src
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • src/aubio.h

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

    r9ec63a0 re8c4de2  
    2424#include "fmat.h"
    2525#include "io/source.h"
     26#ifdef HAVE_AVCODEC
     27#include "io/source_avcodec.h"
     28#endif /* HAVE_AVCODEC */
    2629#ifdef __APPLE__
    2730#include "io/source_apple_audio.h"
     
    2932#ifdef HAVE_SNDFILE
    3033#include "io/source_sndfile.h"
    31 #endif
     34#endif /* HAVE_SNDFILE */
     35
     36typedef void (*aubio_source_do_t)(aubio_source_t * s, fvec_t * data, uint_t * read);
     37typedef void (*aubio_source_do_multi_t)(aubio_source_t * s, fmat_t * data, uint_t * read);
     38typedef uint_t (*aubio_source_get_samplerate_t)(aubio_source_t * s);
     39typedef uint_t (*aubio_source_get_channels_t)(aubio_source_t * s);
     40typedef uint_t (*aubio_source_seek_t)(aubio_source_t * s, uint_t seek);
     41typedef uint_t (*del_aubio_source_t)(aubio_source_t * s);
    3242
    3343struct _aubio_source_t {
    3444  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;
    3551};
    3652
    3753aubio_source_t * new_aubio_source(char_t * uri, uint_t samplerate, uint_t hop_size) {
    3854  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 */
    3967#ifdef __APPLE__
    4068  s->source = (void *)new_aubio_source_apple_audio(uri, samplerate, hop_size);
    41   if (s->source) return s;
    42 #else /* __APPLE__ */
     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__ */
    4379#if HAVE_SNDFILE
    4480  s->source = (void *)new_aubio_source_sndfile(uri, samplerate, hop_size);
    45   if (s->source) return s;
     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  }
    4690#endif /* HAVE_SNDFILE */
    47 #endif /* __APPLE__ */
    4891  AUBIO_ERROR("failed creating aubio source with %s\n", uri);
    4992  AUBIO_FREE(s);
     
    5295
    5396void aubio_source_do(aubio_source_t * s, fvec_t * data, uint_t * 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__ */
     97  s->s_do((void *)s->source, data, read);
    6198}
    6299
    63100void aubio_source_do_multi(aubio_source_t * s, fmat_t * data, uint_t * 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__ */
     101  s->s_do_multi((void *)s->source, data, read);
    71102}
    72103
    73104void del_aubio_source(aubio_source_t * s) {
    74105  if (!s) return;
    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__ */
     106  s->s_del((void *)s->source);
    82107  AUBIO_FREE(s);
    83108}
    84109
    85110uint_t aubio_source_get_samplerate(aubio_source_t * s) {
    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__ */
     111  return s->s_get_samplerate((void *)s->source);
    93112}
    94113
    95114uint_t aubio_source_get_channels(aubio_source_t * s) {
    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__ */
     115  return s->s_get_channels((void *)s->source);
    103116}
    104117
    105118uint_t aubio_source_seek (aubio_source_t * s, uint_t 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__ */
     119  return s->s_seek((void *)s->source, seek);
    113120}
  • src/io/source.h

    r9ec63a0 re8c4de2  
    7777  \param s source object, created with ::new_aubio_source
    7878  \param read_to ::fmat_t of data to read to
    79   \param read upon returns, equals to number of frames actually read
     79  \param[out] 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

    r9ec63a0 re8c4de2  
    6767  if (path == NULL) {
    6868    AUBIO_ERR("Aborted opening null path\n");
    69     return NULL;
     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;
    7078  }
    7179
     
    7482  s->path = path;
    7583
    76   // try opening the file, geting the info in sfinfo
     84  // try opening the file, getting the info in sfinfo
    7785  SF_INFO sfinfo;
    7886  AUBIO_MEMSET(&sfinfo, 0, sizeof (sfinfo));
     
    134142
    135143beach:
    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);
     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);
    138146  del_aubio_source_sndfile(s);
    139147  return NULL;
  • src/wscript_build

    r9ec63a0 re8c4de2  
    66uselib += ['SAMPLERATE']
    77uselib += ['SNDFILE']
     8uselib += ['AVCODEC']
     9uselib += ['AVFORMAT']
     10uselib += ['AVRESAMPLE']
     11uselib += ['AVUTIL']
    812uselib += ['JACK']
    913uselib += ['LASH']
Note: See TracChangeset for help on using the changeset viewer.