2 Copyright (C) 2012-2014 Paul Brossier <piem@aubio.org>
4 This file is part of aubio.
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.
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.
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/>.
26 Media sink to write blocks of consecutive audio samples to file.
28 To read from file, use ::aubio_source_t.
30 Depending on how aubio was compiled, the following sinks will be available.
32 When creating a new sink using ::new_aubio_sink, the new function of each of
33 the compiled-in sinks will be attempted, in the following order, until one of
34 them gets successfully created. If all sinks returned NULL, ::new_aubio_sink
37 \b \p sink_apple_audio : ExtAudioFileRef
39 This sink uses CoreAudio [Extended Audio File Services]
40 (https://developer.apple.com/library/mac/documentation/MusicAudio/Reference/ExtendedAudioFileServicesReference/Reference/reference.html)
41 to write 16-bits encoded WAV files.
43 \b \p sink_sndfile : libsndfile
45 This sink uses [libsndfile](http://www.mega-nerd.com/libsndfile/) to write
46 16-bits encoded WAV files.
48 \b \p sink_wavwrite : native WAV write
50 A simple sink to write 16-bits PCM RIFF encoded WAV files.
52 \example io/test-sink.c
60 /** media sink object */
61 typedef struct _aubio_sink_t aubio_sink_t;
65 create new ::aubio_sink_t
67 \param uri the file path or uri to write to
68 \param samplerate sample rate to write the file at
70 \return newly created ::aubio_sink_t
72 Creates a new sink object.
74 If samplerate is set to 0, the creation of the file will be delayed until
75 both ::aubio_sink_preset_samplerate and ::aubio_sink_preset_channels have
79 aubio_sink_t * new_aubio_sink(char_t * uri, uint_t samplerate);
83 preset sink samplerate
85 \param s sink, created with ::new_aubio_sink
86 \param samplerate samplerate to preset the sink to, in Hz
88 \return 0 on success, 1 on error
90 Preset the samplerate of the sink. The file should have been created using a
93 The file will be opened only when both samplerate and channels have been set.
96 uint_t aubio_sink_preset_samplerate(aubio_sink_t *s, uint_t samplerate);
102 \param s sink, created with ::new_aubio_sink
103 \param channels number of channels to preset the sink to
105 \return 0 on success, 1 on error
107 Preset the samplerate of the sink. The file should have been created using a
110 The file will be opened only when both samplerate and channels have been set.
113 uint_t aubio_sink_preset_channels(aubio_sink_t *s, uint_t channels);
117 get samplerate of sink object
119 \param s sink object, created with ::new_aubio_sink
120 \return samplerate, in Hz
123 uint_t aubio_sink_get_samplerate(aubio_sink_t *s);
127 get channels of sink object
129 \param s sink object, created with ::new_aubio_sink
130 \return number of channels
133 uint_t aubio_sink_get_channels(aubio_sink_t *s);
137 write monophonic vector of length hop_size to sink
139 \param s sink, created with ::new_aubio_sink
140 \param write_data ::fvec_t samples to write to sink
141 \param write number of frames to write
144 void aubio_sink_do(aubio_sink_t * s, fvec_t * write_data, uint_t write);
148 write polyphonic vector of length hop_size to sink
150 \param s sink, created with ::new_aubio_sink
151 \param write_data ::fmat_t samples to write to sink
152 \param write number of frames to write
155 void aubio_sink_do_multi(aubio_sink_t * s, fmat_t * write_data, uint_t write);
161 \param s sink object, created with ::new_aubio_sink
163 \return 0 on success, non-zero on failure
166 uint_t aubio_sink_close(aubio_sink_t * s);
170 close sink and cleanup memory
172 \param s sink object, created with ::new_aubio_sink
175 void del_aubio_sink(aubio_sink_t * s);
181 #endif /* _AUBIO_SINK_H */