1 | /* |
---|
2 | Copyright (C) 2003-2013 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_SAMPLER_H |
---|
22 | #define AUBIO_SAMPLER_H |
---|
23 | |
---|
24 | /** \file |
---|
25 | |
---|
26 | Load and play a sound file. |
---|
27 | |
---|
28 | This file loads a sample and gets ready to play it. |
---|
29 | |
---|
30 | The `_do` function adds the new samples to the input, and write the result as |
---|
31 | the output. |
---|
32 | |
---|
33 | TODO: |
---|
34 | - add _preset_threaded(level) |
---|
35 | - add _set_stretch |
---|
36 | - add _set_pitch |
---|
37 | |
---|
38 | \example synth/test-sampler.c |
---|
39 | |
---|
40 | */ |
---|
41 | |
---|
42 | #ifdef __cplusplus |
---|
43 | extern "C" { |
---|
44 | #endif |
---|
45 | |
---|
46 | /** sampler object */ |
---|
47 | typedef struct _aubio_sampler_t aubio_sampler_t; |
---|
48 | |
---|
49 | /** create new sampler object |
---|
50 | |
---|
51 | \param samplerate the sampling rate of the new sampler |
---|
52 | \param hop_size the block size of the new sampler |
---|
53 | |
---|
54 | \return the newly created ::aubio_sampler_t |
---|
55 | |
---|
56 | */ |
---|
57 | aubio_sampler_t * new_aubio_sampler(uint_t hop_size, uint_t samplerate); |
---|
58 | |
---|
59 | /** load source in sampler |
---|
60 | |
---|
61 | \param o sampler, created by new_aubio_sampler() |
---|
62 | \param uri the uri of the source to load |
---|
63 | |
---|
64 | \return 0 if successful, non-zero otherwise |
---|
65 | |
---|
66 | */ |
---|
67 | uint_t aubio_sampler_load( aubio_sampler_t * o, const char_t * uri ); |
---|
68 | |
---|
69 | /** queue source in sampler |
---|
70 | |
---|
71 | \param o sampler, created by new_aubio_sampler() |
---|
72 | \param uri the uri of the source to load |
---|
73 | |
---|
74 | \return 0 if successfully queued, non-zero otherwise |
---|
75 | |
---|
76 | */ |
---|
77 | uint_t aubio_sampler_queue(aubio_sampler_t * o, const char_t * uri ); |
---|
78 | |
---|
79 | /** process sampler function |
---|
80 | |
---|
81 | \param o sampler, created by new_aubio_sampler() |
---|
82 | \param output output of the sampler |
---|
83 | |
---|
84 | This function get new samples from the playing source into output. |
---|
85 | |
---|
86 | */ |
---|
87 | void aubio_sampler_do ( aubio_sampler_t * o, fvec_t * output, uint_t *read); |
---|
88 | |
---|
89 | /** process sampler function, multiple channels |
---|
90 | |
---|
91 | \param o sampler, created by new_aubio_sampler() |
---|
92 | \param output output of the sampler |
---|
93 | |
---|
94 | This function gets new samples from the playing source into output. |
---|
95 | |
---|
96 | */ |
---|
97 | void aubio_sampler_do_multi ( aubio_sampler_t * o, fmat_t * output, uint_t *read); |
---|
98 | |
---|
99 | /** get current playing state |
---|
100 | |
---|
101 | \param o sampler, created by new_aubio_sampler() |
---|
102 | |
---|
103 | \return 0 if not playing, 1 if playing |
---|
104 | |
---|
105 | */ |
---|
106 | uint_t aubio_sampler_get_playing ( const aubio_sampler_t * o ); |
---|
107 | |
---|
108 | /** set current playing state |
---|
109 | |
---|
110 | \param o sampler, created by new_aubio_sampler() |
---|
111 | \param playing 0 for not playing, 1 for playing |
---|
112 | |
---|
113 | \return 0 if successful, 1 otherwise |
---|
114 | |
---|
115 | */ |
---|
116 | uint_t aubio_sampler_set_playing ( aubio_sampler_t * o, uint_t playing ); |
---|
117 | |
---|
118 | uint_t aubio_sampler_get_loop(aubio_sampler_t * o); |
---|
119 | |
---|
120 | /** set current looping state |
---|
121 | |
---|
122 | \param o sampler, created by new_aubio_sampler() |
---|
123 | \param looping 0 for not looping, 1 for looping |
---|
124 | |
---|
125 | \return 0 if successful, 1 otherwise |
---|
126 | |
---|
127 | */ |
---|
128 | uint_t aubio_sampler_set_loop(aubio_sampler_t * o, uint_t loop); |
---|
129 | |
---|
130 | /** play sample from start |
---|
131 | |
---|
132 | \param o sampler, created by new_aubio_sampler() |
---|
133 | |
---|
134 | \return 0 if successful, 1 otherwise |
---|
135 | |
---|
136 | */ |
---|
137 | uint_t aubio_sampler_play ( aubio_sampler_t * o ); |
---|
138 | |
---|
139 | /** play sample from start, looping it |
---|
140 | |
---|
141 | \param o sampler, created by new_aubio_sampler() |
---|
142 | |
---|
143 | \return 0 if successful, 1 otherwise |
---|
144 | |
---|
145 | */ |
---|
146 | uint_t aubio_sampler_loop ( aubio_sampler_t * o ); |
---|
147 | |
---|
148 | /** play sample from start, once |
---|
149 | |
---|
150 | \param o sampler, created by new_aubio_sampler() |
---|
151 | |
---|
152 | \return 0 if successful, 1 otherwise |
---|
153 | |
---|
154 | */ |
---|
155 | uint_t aubio_sampler_trigger ( aubio_sampler_t * o ); |
---|
156 | |
---|
157 | /** stop sample |
---|
158 | |
---|
159 | \param o sampler, created by new_aubio_sampler() |
---|
160 | |
---|
161 | \return 0 if successful, 1 otherwise |
---|
162 | |
---|
163 | */ |
---|
164 | uint_t aubio_sampler_stop ( aubio_sampler_t * o ); |
---|
165 | |
---|
166 | /** get end-of-file status |
---|
167 | |
---|
168 | \param o sampler, created by new_aubio_sampler() |
---|
169 | |
---|
170 | \return 1 when the eof is being reached, 0 otherwise |
---|
171 | |
---|
172 | */ |
---|
173 | uint_t aubio_sampler_get_eof(aubio_sampler_t * o); |
---|
174 | |
---|
175 | /** get end-of-file status |
---|
176 | |
---|
177 | \param o sampler, created by new_aubio_sampler() |
---|
178 | |
---|
179 | \return 1 when the eof is being reached, 0 otherwise |
---|
180 | |
---|
181 | */ |
---|
182 | uint_t aubio_sampler_get_finished (aubio_sampler_t * o); |
---|
183 | |
---|
184 | /** get samplerate |
---|
185 | |
---|
186 | \param o sampler, created by new_aubio_sampler() |
---|
187 | |
---|
188 | \return samplerate of the sampler |
---|
189 | |
---|
190 | */ |
---|
191 | uint_t aubio_sampler_get_samplerate(aubio_sampler_t * o); |
---|
192 | |
---|
193 | /** get the number of samples that were set to zero while opening a file |
---|
194 | |
---|
195 | \param o sampler, created by new_aubio_sampler() |
---|
196 | \param waited the number of frames processed during this block |
---|
197 | |
---|
198 | \return the total delay in samples when the file was successfuly opened, 0 |
---|
199 | otherwise |
---|
200 | |
---|
201 | */ |
---|
202 | uint_t aubio_sampler_get_waited_opening(aubio_sampler_t * o, uint_t waited); |
---|
203 | |
---|
204 | /** seek to position |
---|
205 | |
---|
206 | \param o sampler, created by new_aubio_sampler() |
---|
207 | \param pos position to seek to, in samples |
---|
208 | |
---|
209 | \return 0 if successful, 1 otherwise |
---|
210 | |
---|
211 | */ |
---|
212 | uint_t aubio_sampler_seek(aubio_sampler_t * o, uint_t pos); |
---|
213 | |
---|
214 | /** destroy ::aubio_sampler_t object |
---|
215 | |
---|
216 | \param o sampler, created by new_aubio_sampler() |
---|
217 | |
---|
218 | */ |
---|
219 | void del_aubio_sampler( aubio_sampler_t * o ); |
---|
220 | |
---|
221 | #ifdef __cplusplus |
---|
222 | } |
---|
223 | #endif |
---|
224 | |
---|
225 | #endif /* AUBIO_SAMPLER_H */ |
---|