2 Copyright (C) 2003-2013 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/>.
21 #ifndef _AUBIO_SYNTH_WAVETABLE_H
22 #define _AUBIO_SYNTH_WAVETABLE_H
26 Load and play sound files.
28 This file loads a sample and gets ready to play it.
30 The `_do` function adds the new samples to the input, and write the result as
33 \example synth/test-wavetable.c
41 /** wavetable object */
42 typedef struct _aubio_wavetable_t aubio_wavetable_t;
44 /** create new wavetable object
46 \param samplerate the sampling rate of the new wavetable
48 \return the newly created ::aubio_wavetable_t
51 aubio_wavetable_t * new_aubio_wavetable(uint_t samplerate, uint_t hop_size);
53 /** load source in wavetable
55 \param o wavetable, created by ::new_aubio_wavetable
56 \param uri the uri of the source to load
58 \return 0 if successful, non-zero otherwise
61 uint_t aubio_wavetable_load( aubio_wavetable_t * o, char_t * uri );
63 /** process wavetable function
65 \param o wavetable, created by ::new_aubio_wavetable
66 \param input input of the wavetable, to be added to the output
67 \param output output of the wavetable
69 This function adds the new samples from the playing sample to the output.
71 If `input` is not NULL and different from `output`, then the samples from `input`
72 are added to the output.
75 void aubio_wavetable_do ( aubio_wavetable_t * o, fvec_t * input, fvec_t * output);
77 /** process wavetable function, multiple channels
79 \param o wavetable, created by ::new_aubio_wavetable
80 \param input input of the wavetable, to be added to the output
81 \param output output of the wavetable
83 This function adds the new samples from the playing sample to the output.
85 If `input` is not NULL and different from `output`, then the samples from `input`
86 are added to the output.
89 void aubio_wavetable_do_multi ( aubio_wavetable_t * o, fmat_t * input, fmat_t * output);
91 /** get current playing state
93 \param o wavetable, created by ::new_aubio_wavetable
95 \return 0 if not playing, 1 if playing
98 uint_t aubio_wavetable_get_playing ( aubio_wavetable_t * o );
100 /** set current playing state
102 \param o wavetable, created by ::new_aubio_wavetable
103 \param playing 0 for not playing, 1 for playing
105 \return 0 if successful, 1 otherwise
108 uint_t aubio_wavetable_set_playing ( aubio_wavetable_t * o, uint_t playing );
110 /** play sample from start
112 \param o wavetable, created by ::new_aubio_wavetable
113 \param playing 0 for not playing, 1 for playing
115 \return 0 if successful, 1 otherwise
118 uint_t aubio_wavetable_play ( aubio_wavetable_t * o );
120 /** stop sample from start
122 \param o wavetable, created by ::new_aubio_wavetable
123 \param playing 0 for not playing, 1 for playing
125 \return 0 if successful, 1 otherwise
128 uint_t aubio_wavetable_stop ( aubio_wavetable_t * o );
130 /** set wavetable frequency
132 \param o wavetable, created by ::new_aubio_wavetable
133 \param playing 0 for not playing, 1 for playing
135 \return 0 if successful, 1 otherwise
138 uint_t aubio_wavetable_set_freq ( aubio_wavetable_t * o, smpl_t freq );
140 /** get wavetable frequency
142 \param o wavetable, created by ::new_aubio_wavetable
144 \return current frequency, in Hz
147 smpl_t aubio_wavetable_get_freq ( aubio_wavetable_t * o);
149 /** set wavetable amplitude
151 \param o wavetable, created by ::new_aubio_wavetable
152 \param playing 0 for not playing, 1 for playing
154 \return 0 if successful, 1 otherwise
157 uint_t aubio_wavetable_set_amp ( aubio_wavetable_t * o, smpl_t amp );
159 /** get wavetable amplitude
161 \param o wavetable, created by ::new_aubio_wavetable
163 \return current amplitude
166 smpl_t aubio_wavetable_get_amp ( aubio_wavetable_t * o);
168 /** destroy ::aubio_wavetable_t object
170 \param o wavetable, created by ::new_aubio_wavetable
173 void del_aubio_wavetable( aubio_wavetable_t * o );
179 #endif /* _AUBIO_SYNTH_WAVETABLE_H */