aubio: io/sink.h Source File

aubio 0.4.9

Loading...
Searching...
No Matches
sink.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2012-2014 Paul Brossier <piem@aubio.org>
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#ifndef AUBIO_SINK_H
22#define AUBIO_SINK_H
23
24/** \file
25
26 Media sink to write blocks of consecutive audio samples to file.
27
28 To read from file, use ::aubio_source_t.
29
30 Depending on how aubio was compiled, the following sinks will be available.
31
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
35 will return NULL.
36
37 \b \p sink_apple_audio : ExtAudioFileRef
38
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.
42
43 \b \p sink_sndfile : libsndfile
44
45 This sink uses [libsndfile](http://www.mega-nerd.com/libsndfile/) to write
46 16-bits encoded WAV files.
47
48 \b \p sink_wavwrite : native WAV write
49
50 A simple sink to write 16-bits PCM RIFF encoded WAV files.
51
52 \example io/test-sink.c
53
54*/
55
56#ifdef __cplusplus
57extern "C" {
58#endif
59
60/** media sink object */
61 typedef struct _aubio_sink_t aubio_sink_t;
62
63/**
64
65 create new ::aubio_sink_t
66
67 \param uri the file path or uri to write to
68 \param samplerate sample rate to write the file at
69
70 \return newly created ::aubio_sink_t
71
72 Creates a new sink object.
73
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
76 been called.
77
78*/
79 aubio_sink_t * new_aubio_sink(const char_t * uri, uint_t samplerate);
80
81/**
82
83 preset sink samplerate
84
85 \param s sink, created with ::new_aubio_sink
86 \param samplerate samplerate to preset the sink to, in Hz
87
88 \return 0 on success, 1 on error
89
90 Preset the samplerate of the sink. The file should have been created using a
91 samplerate of 0.
92
93 The file will be opened only when both samplerate and channels have been set.
94
95*/
96 uint_t aubio_sink_preset_samplerate(aubio_sink_t *s, uint_t samplerate);
97
98/**
99
100 preset sink channels
101
102 \param s sink, created with ::new_aubio_sink
103 \param channels number of channels to preset the sink to
104
105 \return 0 on success, 1 on error
106
107 Preset the samplerate of the sink. The file should have been created using a
108 samplerate of 0.
109
110 The file will be opened only when both samplerate and channels have been set.
111
112*/
113 uint_t aubio_sink_preset_channels(aubio_sink_t *s, uint_t channels);
114
115/**
116
117 get samplerate of sink object
118
119 \param s sink object, created with ::new_aubio_sink
120 \return samplerate, in Hz
121
122*/
123 uint_t aubio_sink_get_samplerate(const aubio_sink_t *s);
124
125/**
126
127 get channels of sink object
128
129 \param s sink object, created with ::new_aubio_sink
130 \return number of channels
131
132*/
133 uint_t aubio_sink_get_channels(const aubio_sink_t *s);
134
135/**
136
137 write monophonic vector of length hop_size to sink
138
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
142
143*/
144 void aubio_sink_do(aubio_sink_t * s, fvec_t * write_data, uint_t write);
145
146/**
147
148 write polyphonic vector of length hop_size to sink
149
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
153
154*/
155 void aubio_sink_do_multi(aubio_sink_t * s, fmat_t * write_data, uint_t write);
156
157/**
158
159 close sink
160
161 \param s sink object, created with ::new_aubio_sink
162
163 \return 0 on success, non-zero on failure
164
165*/
166 uint_t aubio_sink_close(aubio_sink_t * s);
167
168/**
169
170 close sink and cleanup memory
171
172 \param s sink object, created with ::new_aubio_sink
173
174*/
175 void del_aubio_sink(aubio_sink_t * s);
176
177#ifdef __cplusplus
178}
179#endif
180
181#endif /* AUBIO_SINK_H */
aubio_sink_close
uint_t aubio_sink_close(aubio_sink_t *s)
close sink
aubio_sink_preset_samplerate
uint_t aubio_sink_preset_samplerate(aubio_sink_t *s, uint_t samplerate)
preset sink samplerate
aubio_sink_do_multi
void aubio_sink_do_multi(aubio_sink_t *s, fmat_t *write_data, uint_t write)
write polyphonic vector of length hop_size to sink
aubio_sink_do
void aubio_sink_do(aubio_sink_t *s, fvec_t *write_data, uint_t write)
write monophonic vector of length hop_size to sink
del_aubio_sink
void del_aubio_sink(aubio_sink_t *s)
close sink and cleanup memory
aubio_sink_get_channels
uint_t aubio_sink_get_channels(const aubio_sink_t *s)
get channels of sink object
aubio_sink_t
struct _aubio_sink_t aubio_sink_t
media sink object
Definition: sink.h:61
new_aubio_sink
aubio_sink_t * new_aubio_sink(const char_t *uri, uint_t samplerate)
create new aubio_sink_t
aubio_sink_preset_channels
uint_t aubio_sink_preset_channels(aubio_sink_t *s, uint_t channels)
preset sink channels
aubio_sink_get_samplerate
uint_t aubio_sink_get_samplerate(const aubio_sink_t *s)
get samplerate of sink object
fmat_t
Buffer for real data.
Definition: fmat.h:40
fvec_t
Buffer for real data.
Definition: fvec.h:67
uint_t
unsigned int uint_t
unsigned integer
Definition: types.h:60
char_t
char char_t
character
Definition: types.h:64