Changeset 155cc10 for src/io/source.c


Ignore:
Timestamp:
Mar 10, 2017, 2:26:32 PM (8 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/applefworks, fix/ffmpeg5, master, sampler
Children:
ee8a57c
Parents:
00d0275 (diff), 67b6618 (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 'master' into awhitening

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/io/source.c

    r00d0275 r155cc10  
    1919*/
    2020
    21 #include "config.h"
    2221#include "aubio_priv.h"
    2322#include "fvec.h"
     
    4140typedef uint_t (*aubio_source_get_samplerate_t)(aubio_source_t * s);
    4241typedef uint_t (*aubio_source_get_channels_t)(aubio_source_t * s);
     42typedef uint_t (*aubio_source_get_duration_t)(aubio_source_t * s);
    4343typedef uint_t (*aubio_source_seek_t)(aubio_source_t * s, uint_t seek);
    4444typedef uint_t (*aubio_source_close_t)(aubio_source_t * s);
     
    5151  aubio_source_get_samplerate_t s_get_samplerate;
    5252  aubio_source_get_channels_t s_get_channels;
     53  aubio_source_get_duration_t s_get_duration;
    5354  aubio_source_seek_t s_seek;
    5455  aubio_source_close_t s_close;
     
    5657};
    5758
    58 aubio_source_t * new_aubio_source(char_t * uri, uint_t samplerate, uint_t hop_size) {
     59aubio_source_t * new_aubio_source(const char_t * uri, uint_t samplerate, uint_t hop_size) {
    5960  aubio_source_t * s = AUBIO_NEW(aubio_source_t);
    60 #if HAVE_LIBAV
     61#ifdef HAVE_LIBAV
    6162  s->source = (void *)new_aubio_source_avcodec(uri, samplerate, hop_size);
    6263  if (s->source) {
     
    6566    s->s_get_channels = (aubio_source_get_channels_t)(aubio_source_avcodec_get_channels);
    6667    s->s_get_samplerate = (aubio_source_get_samplerate_t)(aubio_source_avcodec_get_samplerate);
     68    s->s_get_duration = (aubio_source_get_duration_t)(aubio_source_avcodec_get_duration);
    6769    s->s_seek = (aubio_source_seek_t)(aubio_source_avcodec_seek);
    6870    s->s_close = (aubio_source_close_t)(aubio_source_avcodec_close);
     
    7880    s->s_get_channels = (aubio_source_get_channels_t)(aubio_source_apple_audio_get_channels);
    7981    s->s_get_samplerate = (aubio_source_get_samplerate_t)(aubio_source_apple_audio_get_samplerate);
     82    s->s_get_duration = (aubio_source_get_duration_t)(aubio_source_apple_audio_get_duration);
    8083    s->s_seek = (aubio_source_seek_t)(aubio_source_apple_audio_seek);
    8184    s->s_close = (aubio_source_close_t)(aubio_source_apple_audio_close);
     
    8487  }
    8588#endif /* HAVE_SOURCE_APPLE_AUDIO */
    86 #if HAVE_SNDFILE
     89#ifdef HAVE_SNDFILE
    8790  s->source = (void *)new_aubio_source_sndfile(uri, samplerate, hop_size);
    8891  if (s->source) {
     
    9194    s->s_get_channels = (aubio_source_get_channels_t)(aubio_source_sndfile_get_channels);
    9295    s->s_get_samplerate = (aubio_source_get_samplerate_t)(aubio_source_sndfile_get_samplerate);
     96    s->s_get_duration = (aubio_source_get_duration_t)(aubio_source_sndfile_get_duration);
    9397    s->s_seek = (aubio_source_seek_t)(aubio_source_sndfile_seek);
    9498    s->s_close = (aubio_source_close_t)(aubio_source_sndfile_close);
     
    97101  }
    98102#endif /* HAVE_SNDFILE */
    99 #if HAVE_WAVREAD
     103#ifdef HAVE_WAVREAD
    100104  s->source = (void *)new_aubio_source_wavread(uri, samplerate, hop_size);
    101105  if (s->source) {
     
    104108    s->s_get_channels = (aubio_source_get_channels_t)(aubio_source_wavread_get_channels);
    105109    s->s_get_samplerate = (aubio_source_get_samplerate_t)(aubio_source_wavread_get_samplerate);
     110    s->s_get_duration = (aubio_source_get_duration_t)(aubio_source_wavread_get_duration);
    106111    s->s_seek = (aubio_source_seek_t)(aubio_source_wavread_seek);
    107112    s->s_close = (aubio_source_close_t)(aubio_source_wavread_close);
     
    110115  }
    111116#endif /* HAVE_WAVREAD */
    112   AUBIO_ERROR("source: failed creating aubio source with %s"
    113      " at samplerate %d with hop_size %d\n", uri, samplerate, hop_size);
     117#if !defined(HAVE_WAVREAD) && \
     118  !defined(HAVE_LIBAV) && \
     119  !defined(HAVE_SOURCE_APPLE_AUDIO) && \
     120  !defined(HAVE_SNDFILE)
     121  AUBIO_ERROR("source: failed creating with %s at %dHz with hop size %d"
     122     " (no source built-in)\n", uri, samplerate, hop_size);
     123#endif
    114124  AUBIO_FREE(s);
    115125  return NULL;
     
    142152}
    143153
     154uint_t aubio_source_get_duration(aubio_source_t *s) {
     155  return s->s_get_duration((void *)s->source);
     156}
     157
    144158uint_t aubio_source_seek (aubio_source_t * s, uint_t seek ) {
    145159  return s->s_seek((void *)s->source, seek);
Note: See TracChangeset for help on using the changeset viewer.