Changeset 1b0755d for src/io/source.c
- Timestamp:
- Dec 5, 2013, 4:00:43 AM (11 years ago)
- 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:
- d3b9fe4
- Parents:
- 2e50800
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/io/source.c
r2e50800 r1b0755d 24 24 #include "fmat.h" 25 25 #include "io/source.h" 26 #ifdef HAVE_AVCODEC 27 #include "io/source_avcodec.h" 28 #endif /* HAVE_AVCODEC */ 26 29 #ifdef __APPLE__ 27 30 #include "io/source_apple_audio.h" … … 29 32 #ifdef HAVE_SNDFILE 30 33 #include "io/source_sndfile.h" 31 #endif 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); 32 42 33 43 struct _aubio_source_t { 34 44 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; 35 51 }; 36 52 37 53 aubio_source_t * new_aubio_source(char_t * uri, uint_t samplerate, uint_t hop_size) { 38 54 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 */ 39 67 #ifdef __APPLE__ 40 68 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__ */ 43 79 #if HAVE_SNDFILE 44 80 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 } 46 90 #endif /* HAVE_SNDFILE */ 47 #endif /* __APPLE__ */48 91 AUBIO_ERROR("failed creating aubio source with %s\n", uri); 49 92 AUBIO_FREE(s); … … 52 95 53 96 void 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); 61 98 } 62 99 63 100 void 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); 71 102 } 72 103 73 104 void del_aubio_source(aubio_source_t * s) { 74 105 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); 82 107 AUBIO_FREE(s); 83 108 } 84 109 85 110 uint_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); 93 112 } 94 113 95 114 uint_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); 103 116 } 104 117 105 118 uint_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); 113 120 }
Note: See TracChangeset
for help on using the changeset viewer.