source: src/io/sink.c @ 3388e1a

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5sampleryinfft+
Last change on this file since 3388e1a was 33d0242, checked in by Paul Brossier <piem@piem.org>, 8 years ago

src/aubio_priv.h: move include config.h here

  • Property mode set to 100644
File size: 5.4 KB
RevLine 
[9316173]1/*
[4ed4b1f]2  Copyright (C) 2012-2014 Paul Brossier <piem@aubio.org>
[9316173]3
4  This file is part of aubio.
5
6  aubio is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10
11  aubio is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  GNU General Public License for more details.
15
16  You should have received a copy of the GNU General Public License
17  along with aubio.  If not, see <http://www.gnu.org/licenses/>.
18
19*/
20
21#include "aubio_priv.h"
22#include "fvec.h"
[4ed4b1f]23#include "fmat.h"
[9316173]24#include "io/sink.h"
[9209c79]25#ifdef HAVE_SINK_APPLE_AUDIO
[8aed26d]26#include "io/sink_apple_audio.h"
[9209c79]27#endif /* HAVE_SINK_APPLE_AUDIO */
[8aed26d]28#ifdef HAVE_SNDFILE
29#include "io/sink_sndfile.h"
30#endif
[52ca8a3]31#ifdef HAVE_WAVWRITE
32#include "io/sink_wavwrite.h"
33#endif
[9316173]34
[4b7747d]35typedef void (*aubio_sink_do_t)(aubio_sink_t * s, fvec_t * data, uint_t write);
[4ed4b1f]36typedef void (*aubio_sink_do_multi_t)(aubio_sink_t * s, fmat_t * data, uint_t write);
37typedef uint_t (*aubio_sink_preset_samplerate_t)(aubio_sink_t * s, uint_t samplerate);
38typedef uint_t (*aubio_sink_preset_channels_t)(aubio_sink_t * s, uint_t channels);
[4b7747d]39typedef uint_t (*aubio_sink_get_samplerate_t)(aubio_sink_t * s);
40typedef uint_t (*aubio_sink_get_channels_t)(aubio_sink_t * s);
[a9fd272]41typedef uint_t (*aubio_sink_close_t)(aubio_sink_t * s);
[082c88b]42typedef void (*del_aubio_sink_t)(aubio_sink_t * s);
[4b7747d]43
[9316173]44struct _aubio_sink_t { 
[8aed26d]45  void *sink;
[4b7747d]46  aubio_sink_do_t s_do;
47  aubio_sink_do_multi_t s_do_multi;
[4ed4b1f]48  aubio_sink_preset_samplerate_t s_preset_samplerate;
49  aubio_sink_preset_channels_t s_preset_channels;
[4b7747d]50  aubio_sink_get_samplerate_t s_get_samplerate;
51  aubio_sink_get_channels_t s_get_channels;
[a9fd272]52  aubio_sink_close_t s_close;
[4b7747d]53  del_aubio_sink_t s_del;
[9316173]54};
55
[ae5d58a]56aubio_sink_t * new_aubio_sink(const char_t * uri, uint_t samplerate) {
[4d75b46]57  aubio_sink_t * s = AUBIO_NEW(aubio_sink_t);
[9209c79]58#ifdef HAVE_SINK_APPLE_AUDIO
[8aed26d]59  s->sink = (void *)new_aubio_sink_apple_audio(uri, samplerate);
[4b7747d]60  if (s->sink) {
61    s->s_do = (aubio_sink_do_t)(aubio_sink_apple_audio_do);
[4ed4b1f]62    s->s_do_multi = (aubio_sink_do_multi_t)(aubio_sink_apple_audio_do_multi);
63    s->s_preset_samplerate = (aubio_sink_preset_samplerate_t)(aubio_sink_apple_audio_preset_samplerate);
64    s->s_preset_channels = (aubio_sink_preset_channels_t)(aubio_sink_apple_audio_preset_channels);
65    s->s_get_samplerate = (aubio_sink_get_samplerate_t)(aubio_sink_apple_audio_get_samplerate);
66    s->s_get_channels = (aubio_sink_get_channels_t)(aubio_sink_apple_audio_get_channels);
[a9fd272]67    s->s_close = (aubio_sink_close_t)(aubio_sink_apple_audio_close);
[4b7747d]68    s->s_del = (del_aubio_sink_t)(del_aubio_sink_apple_audio);
69    return s;
70  }
[9209c79]71#endif /* HAVE_SINK_APPLE_AUDIO */
[de66709]72#ifdef HAVE_SNDFILE
[8aed26d]73  s->sink = (void *)new_aubio_sink_sndfile(uri, samplerate);
[4b7747d]74  if (s->sink) {
75    s->s_do = (aubio_sink_do_t)(aubio_sink_sndfile_do);
[4ed4b1f]76    s->s_do_multi = (aubio_sink_do_multi_t)(aubio_sink_sndfile_do_multi);
77    s->s_preset_samplerate = (aubio_sink_preset_samplerate_t)(aubio_sink_sndfile_preset_samplerate);
78    s->s_preset_channels = (aubio_sink_preset_channels_t)(aubio_sink_sndfile_preset_channels);
79    s->s_get_samplerate = (aubio_sink_get_samplerate_t)(aubio_sink_sndfile_get_samplerate);
80    s->s_get_channels = (aubio_sink_get_channels_t)(aubio_sink_sndfile_get_channels);
[a9fd272]81    s->s_close = (aubio_sink_close_t)(aubio_sink_sndfile_close);
[4b7747d]82    s->s_del = (del_aubio_sink_t)(del_aubio_sink_sndfile);
83    return s;
84  }
[8aed26d]85#endif /* HAVE_SNDFILE */
[de66709]86#ifdef HAVE_WAVWRITE
[52ca8a3]87  s->sink = (void *)new_aubio_sink_wavwrite(uri, samplerate);
88  if (s->sink) {
89    s->s_do = (aubio_sink_do_t)(aubio_sink_wavwrite_do);
[4ed4b1f]90    s->s_do_multi = (aubio_sink_do_multi_t)(aubio_sink_wavwrite_do_multi);
91    s->s_preset_samplerate = (aubio_sink_preset_samplerate_t)(aubio_sink_wavwrite_preset_samplerate);
92    s->s_preset_channels = (aubio_sink_preset_channels_t)(aubio_sink_wavwrite_preset_channels);
93    s->s_get_samplerate = (aubio_sink_get_samplerate_t)(aubio_sink_wavwrite_get_samplerate);
94    s->s_get_channels = (aubio_sink_get_channels_t)(aubio_sink_wavwrite_get_channels);
[a9fd272]95    s->s_close = (aubio_sink_close_t)(aubio_sink_wavwrite_close);
[52ca8a3]96    s->s_del = (del_aubio_sink_t)(del_aubio_sink_wavwrite);
97    return s;
98  }
99#endif /* HAVE_WAVWRITE */
[b8503f8]100  //AUBIO_ERROR("sink: failed creating '%s' with samplerate %dHz\n",
101  //    uri, samplerate);
[779966b]102  AUBIO_FREE(s);
103  return NULL;
[9316173]104}
105
[8aed26d]106void aubio_sink_do(aubio_sink_t * s, fvec_t * write_data, uint_t write) {
[4b7747d]107  s->s_do((void *)s->sink, write_data, write);
[9316173]108}
109
[4ed4b1f]110void aubio_sink_do_multi(aubio_sink_t * s, fmat_t * write_data, uint_t write) {
111  s->s_do_multi((void *)s->sink, write_data, write);
112}
113
114uint_t aubio_sink_preset_samplerate(aubio_sink_t * s, uint_t samplerate) {
115  return s->s_preset_samplerate((void *)s->sink, samplerate);
116}
117
118uint_t aubio_sink_preset_channels(aubio_sink_t * s, uint_t channels) {
119  return s->s_preset_channels((void *)s->sink, channels);
120}
121
[ae5d58a]122uint_t aubio_sink_get_samplerate(const aubio_sink_t * s) {
[4ed4b1f]123  return s->s_get_samplerate((void *)s->sink);
124}
125
[ae5d58a]126uint_t aubio_sink_get_channels(const aubio_sink_t * s) {
[4ed4b1f]127  return s->s_get_channels((void *)s->sink);
128}
129
[a9fd272]130uint_t aubio_sink_close(aubio_sink_t *s) {
131  return s->s_close((void *)s->sink);
132}
133
[9316173]134void del_aubio_sink(aubio_sink_t * s) {
[779966b]135  if (!s) return;
[4b7747d]136  s->s_del((void *)s->sink);
[4d75b46]137  AUBIO_FREE(s);
[9316173]138  return;
139}
Note: See TracBrowser for help on using the repository browser.