source: src/synth/sampler.h @ 82ad1ed

sampler
Last change on this file since 82ad1ed was 82ad1ed, checked in by Paul Brossier <piem@piem.org>, 7 years ago

src/synth/sampler.h: add timestretch (first draft)

  • Property mode set to 100644
File size: 7.3 KB
RevLine 
[04c8346]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
[6f42c16]21#ifndef AUBIO_SAMPLER_H
22#define AUBIO_SAMPLER_H
[04c8346]23
24/** \file
25
[88042ef]26  Load and play a sound file.
[04c8346]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
[88042ef]33TODO:
34  - add _preset_threaded(level)
35  - add _set_stretch
36  - add _set_pitch
37
[04c8346]38  \example synth/test-sampler.c
39
40*/
41
42#ifdef __cplusplus
43extern "C" {
44#endif
45
46/** sampler object */
47typedef struct _aubio_sampler_t aubio_sampler_t;
48
49/** create new sampler object
50
51  \param samplerate the sampling rate of the new sampler
[2b6139e7]52  \param hop_size the block size of the new sampler
[04c8346]53
54  \return the newly created ::aubio_sampler_t
55
56*/
[88042ef]57aubio_sampler_t * new_aubio_sampler(uint_t hop_size, uint_t samplerate);
[04c8346]58
59/** load source in sampler
60
[2b6139e7]61  \param o sampler, created by new_aubio_sampler()
[04c8346]62  \param uri the uri of the source to load
63
64  \return 0 if successful, non-zero otherwise
65
[6cc2d9d]66  This function attempts to load a new source, swaps the current one with the
67  newly loaded one (or NULL if loading failed), then delete the old one.
68
[04c8346]69*/
[ce3ff2b]70uint_t aubio_sampler_load( aubio_sampler_t * o, const char_t * uri );
[04c8346]71
[88042ef]72/** queue source in sampler
73
74  \param o sampler, created by new_aubio_sampler()
75  \param uri the uri of the source to load
76
77  \return 0 if successfully queued, non-zero otherwise
78
[6cc2d9d]79  This function is identical to aubio_sampler_load(), except it will be called
80  in its own thread to avoid blocking calls to aubio_sampler_do().
81
[88042ef]82*/
83uint_t aubio_sampler_queue(aubio_sampler_t * o, const char_t * uri );
84
[2ca4b59]85/** set array to read from
86
87  \param o sampler, created by new_aubio_sampler()
88  \param samples the vector to set the table to
89
90  \return 0 if successfully set, non-zero otherwise
91
92*/
93uint_t aubio_sampler_set_table(aubio_sampler_t *o, fvec_t *samples);
94
[04c8346]95/** process sampler function
96
[2b6139e7]97  \param o sampler, created by new_aubio_sampler()
[04c8346]98  \param output output of the sampler
[6cc2d9d]99  \param read number of samples actually read
100
101  This function get new samples from the sampler and store them into output.
[04c8346]102
[6cc2d9d]103  The output vector will be completed with 0 if too few samples are available.
[04c8346]104
105*/
[88042ef]106void aubio_sampler_do ( aubio_sampler_t * o, fvec_t * output, uint_t *read);
[04c8346]107
108/** process sampler function, multiple channels
109
[2b6139e7]110  \param o sampler, created by new_aubio_sampler()
[04c8346]111  \param output output of the sampler
112
[8b07fa9]113  This function is identical to aubio_sampler_do(), but for a multi-channel source.
[04c8346]114
115*/
[88042ef]116void aubio_sampler_do_multi ( aubio_sampler_t * o, fmat_t * output, uint_t *read);
[04c8346]117
118/** get current playing state
119
[2b6139e7]120  \param o sampler, created by new_aubio_sampler()
[04c8346]121
122  \return 0 if not playing, 1 if playing
123
124*/
[ce3ff2b]125uint_t aubio_sampler_get_playing ( const aubio_sampler_t * o );
[04c8346]126
127/** set current playing state
128
[2b6139e7]129  \param o sampler, created by new_aubio_sampler()
[04c8346]130  \param playing 0 for not playing, 1 for playing
131
132  \return 0 if successful, 1 otherwise
133
134*/
135uint_t aubio_sampler_set_playing ( aubio_sampler_t * o, uint_t playing );
136
[88042ef]137uint_t aubio_sampler_get_loop(aubio_sampler_t * o);
138
139/** set current looping state
140
141  \param o sampler, created by new_aubio_sampler()
142  \param looping 0 for not looping, 1 for looping
143
144  \return 0 if successful, 1 otherwise
145
146*/
147uint_t aubio_sampler_set_loop(aubio_sampler_t * o, uint_t loop);
148
[04c8346]149/** play sample from start
150
[2b6139e7]151  \param o sampler, created by new_aubio_sampler()
[04c8346]152
153  \return 0 if successful, 1 otherwise
154
155*/
156uint_t aubio_sampler_play ( aubio_sampler_t * o );
157
[88042ef]158/** play sample from start, looping it
159
160  \param o sampler, created by new_aubio_sampler()
161
162  \return 0 if successful, 1 otherwise
163
164*/
165uint_t aubio_sampler_loop ( aubio_sampler_t * o );
166
167/** play sample from start, once
168
169  \param o sampler, created by new_aubio_sampler()
170
171  \return 0 if successful, 1 otherwise
172
173*/
174uint_t aubio_sampler_trigger ( aubio_sampler_t * o );
175
[2b6139e7]176/** stop sample
[04c8346]177
[2b6139e7]178  \param o sampler, created by new_aubio_sampler()
[04c8346]179
180  \return 0 if successful, 1 otherwise
181
182*/
183uint_t aubio_sampler_stop ( aubio_sampler_t * o );
184
[88042ef]185/** get end-of-file status
186
187  \param o sampler, created by new_aubio_sampler()
188
189  \return 1 when the eof is being reached, 0 otherwise
190
191*/
192uint_t aubio_sampler_get_eof(aubio_sampler_t * o);
193
194/** get end-of-file status
195
196  \param o sampler, created by new_aubio_sampler()
197
198  \return 1 when the eof is being reached, 0 otherwise
199
200*/
201uint_t aubio_sampler_get_finished (aubio_sampler_t * o);
202
203/** get samplerate
204
205  \param o sampler, created by new_aubio_sampler()
206
207  \return samplerate of the sampler
208
209*/
210uint_t aubio_sampler_get_samplerate(aubio_sampler_t * o);
211
212/** get the number of samples that were set to zero while opening a file
213
214  \param o sampler, created by new_aubio_sampler()
[0a756ea]215  \param waited the number of frames processed during this block
[88042ef]216
[0a756ea]217  \return the total delay in samples when the file was successfuly opened, 0
218  otherwise
[88042ef]219
220*/
221uint_t aubio_sampler_get_waited_opening(aubio_sampler_t * o, uint_t waited);
222
[82ad1ed]223/** get current time stretching factor
224
225  \param o sampler, created by new_aubio_sampler()
226
227  \return the current time stretch factor
228
229 */
230smpl_t aubio_sampler_get_stretch (aubio_sampler_t *o);
231
232/** set current time stretching factor
233
234  \param o sampler, created by new_aubio_sampler()
235  \param stretch new time stretching factor
236
237  \return AUBIO_OK on success, AUBIO_FAIL otherwise
238
239 */
240uint_t aubio_sampler_set_stretch (aubio_sampler_t *o, smpl_t stretch);
241
242/** get current pitch shifting factor
243
244  \param o sampler, created by new_aubio_sampler()
245
246  \return the current pitch transposition factor
247
248 */
249smpl_t aubio_sampler_get_transpose (aubio_sampler_t *o);
250
251/** set current pitch shifting factor
252
253  \param o sampler, created by new_aubio_sampler()
254  \param transpose new pitch shifting (transposition) factor
255
256  \return AUBIO_OK on success, AUBIO_FAIL otherwise
257
258 */
259uint_t aubio_sampler_set_transpose (aubio_sampler_t *o, smpl_t transpose);
260
[943ef49]261/** get the current perfect loop mode
262
263  \param o sampler, created by new_aubio_sampler()
264
265  \return the total delay in samples when the file was successfuly opened, 0
266  otherwise
267
268*/
269uint_t aubio_sampler_get_perfectloop (aubio_sampler_t *o);
270
271/** set the perfect loop mode
272
273  \param o sampler, created by new_aubio_sampler()
274  \param perfectloop 1 to set perfect loop mode, 0 to turn it of
275
276  \return AUBIO_OK on success, AUBIO_FAIL otherwise
277
278 */
279uint_t aubio_sampler_set_perfectloop (aubio_sampler_t *o, uint_t perfectloop);
280
[88042ef]281/** seek to position
282
283  \param o sampler, created by new_aubio_sampler()
284  \param pos position to seek to, in samples
285
286  \return 0 if successful, 1 otherwise
287
288*/
289uint_t aubio_sampler_seek(aubio_sampler_t * o, uint_t pos);
290
[04c8346]291/** destroy ::aubio_sampler_t object
292
[2b6139e7]293  \param o sampler, created by new_aubio_sampler()
[04c8346]294
295*/
296void del_aubio_sampler( aubio_sampler_t * o );
297
298#ifdef __cplusplus
299}
300#endif
301
[6f42c16]302#endif /* AUBIO_SAMPLER_H */
Note: See TracBrowser for help on using the repository browser.