[dd15573] | 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_WAVETABLE_H |
---|
| 22 | #define AUBIO_WAVETABLE_H |
---|
[dd15573] | 23 | |
---|
| 24 | /** \file |
---|
| 25 | |
---|
[2b6139e7] | 26 | Wavetable synthesis. |
---|
[dd15573] | 27 | |
---|
[2b6139e7] | 28 | This file creates a wavetable and plays it at different frequency. |
---|
[dd15573] | 29 | |
---|
| 30 | The `_do` function adds the new samples to the input, and write the result as |
---|
| 31 | the output. |
---|
| 32 | |
---|
| 33 | \example synth/test-wavetable.c |
---|
| 34 | |
---|
| 35 | */ |
---|
| 36 | |
---|
| 37 | #ifdef __cplusplus |
---|
| 38 | extern "C" { |
---|
| 39 | #endif |
---|
| 40 | |
---|
| 41 | /** wavetable object */ |
---|
| 42 | typedef struct _aubio_wavetable_t aubio_wavetable_t; |
---|
| 43 | |
---|
| 44 | /** create new wavetable object |
---|
| 45 | |
---|
| 46 | \param samplerate the sampling rate of the new wavetable |
---|
[2b6139e7] | 47 | \param hop_size the block size of the new wavetable |
---|
[dd15573] | 48 | |
---|
[2b6139e7] | 49 | \return the newly created aubio_wavetable_t |
---|
[dd15573] | 50 | |
---|
| 51 | */ |
---|
| 52 | aubio_wavetable_t * new_aubio_wavetable(uint_t samplerate, uint_t hop_size); |
---|
| 53 | |
---|
| 54 | /** process wavetable function |
---|
| 55 | |
---|
[2b6139e7] | 56 | \param o wavetable, created by new_aubio_wavetable() |
---|
[dd15573] | 57 | \param input input of the wavetable, to be added to the output |
---|
| 58 | \param output output of the wavetable |
---|
| 59 | |
---|
[2b6139e7] | 60 | This function adds the new samples from the playing wavetable to the output. |
---|
[dd15573] | 61 | |
---|
| 62 | If `input` is not NULL and different from `output`, then the samples from `input` |
---|
| 63 | are added to the output. |
---|
| 64 | |
---|
| 65 | */ |
---|
[ce3ff2b] | 66 | void aubio_wavetable_do ( aubio_wavetable_t * o, const fvec_t * input, fvec_t * output); |
---|
[dd15573] | 67 | |
---|
| 68 | /** process wavetable function, multiple channels |
---|
| 69 | |
---|
[2b6139e7] | 70 | \param o wavetable, created by new_aubio_wavetable() |
---|
[dd15573] | 71 | \param input input of the wavetable, to be added to the output |
---|
| 72 | \param output output of the wavetable |
---|
| 73 | |
---|
[2b6139e7] | 74 | This function adds the new samples from the playing wavetable to the output. |
---|
[dd15573] | 75 | |
---|
| 76 | If `input` is not NULL and different from `output`, then the samples from `input` |
---|
| 77 | are added to the output. |
---|
| 78 | |
---|
| 79 | */ |
---|
[ce3ff2b] | 80 | void aubio_wavetable_do_multi ( aubio_wavetable_t * o, const fmat_t * input, fmat_t * output); |
---|
[dd15573] | 81 | |
---|
| 82 | /** get current playing state |
---|
| 83 | |
---|
[2b6139e7] | 84 | \param o wavetable, created by new_aubio_wavetable() |
---|
[dd15573] | 85 | |
---|
| 86 | \return 0 if not playing, 1 if playing |
---|
| 87 | |
---|
| 88 | */ |
---|
[ce3ff2b] | 89 | uint_t aubio_wavetable_get_playing ( const aubio_wavetable_t * o ); |
---|
[dd15573] | 90 | |
---|
| 91 | /** set current playing state |
---|
| 92 | |
---|
[2b6139e7] | 93 | \param o wavetable, created by new_aubio_wavetable() |
---|
[dd15573] | 94 | \param playing 0 for not playing, 1 for playing |
---|
| 95 | |
---|
| 96 | \return 0 if successful, 1 otherwise |
---|
| 97 | |
---|
| 98 | */ |
---|
| 99 | uint_t aubio_wavetable_set_playing ( aubio_wavetable_t * o, uint_t playing ); |
---|
| 100 | |
---|
| 101 | /** play sample from start |
---|
| 102 | |
---|
[2b6139e7] | 103 | \param o wavetable, created by new_aubio_wavetable() |
---|
[dd15573] | 104 | |
---|
| 105 | \return 0 if successful, 1 otherwise |
---|
| 106 | |
---|
| 107 | */ |
---|
| 108 | uint_t aubio_wavetable_play ( aubio_wavetable_t * o ); |
---|
| 109 | |
---|
[2b6139e7] | 110 | /** stop wavetable |
---|
[dd15573] | 111 | |
---|
[2b6139e7] | 112 | \param o wavetable, created by new_aubio_wavetable() |
---|
[dd15573] | 113 | |
---|
| 114 | \return 0 if successful, 1 otherwise |
---|
| 115 | |
---|
| 116 | */ |
---|
| 117 | uint_t aubio_wavetable_stop ( aubio_wavetable_t * o ); |
---|
| 118 | |
---|
| 119 | /** set wavetable frequency |
---|
| 120 | |
---|
[2b6139e7] | 121 | \param o wavetable, created by new_aubio_wavetable() |
---|
[8750bbd] | 122 | \param freq new frequency value for the wavetable |
---|
[dd15573] | 123 | |
---|
| 124 | \return 0 if successful, 1 otherwise |
---|
| 125 | |
---|
| 126 | */ |
---|
| 127 | uint_t aubio_wavetable_set_freq ( aubio_wavetable_t * o, smpl_t freq ); |
---|
| 128 | |
---|
| 129 | /** get wavetable frequency |
---|
| 130 | |
---|
[2b6139e7] | 131 | \param o wavetable, created by new_aubio_wavetable() |
---|
[dd15573] | 132 | |
---|
| 133 | \return current frequency, in Hz |
---|
| 134 | |
---|
| 135 | */ |
---|
[ce3ff2b] | 136 | smpl_t aubio_wavetable_get_freq ( const aubio_wavetable_t * o); |
---|
[dd15573] | 137 | |
---|
| 138 | /** set wavetable amplitude |
---|
| 139 | |
---|
[2b6139e7] | 140 | \param o wavetable, created by new_aubio_wavetable() |
---|
[8750bbd] | 141 | \param amp new amplitude value for the wavetable |
---|
[dd15573] | 142 | |
---|
| 143 | \return 0 if successful, 1 otherwise |
---|
| 144 | |
---|
| 145 | */ |
---|
| 146 | uint_t aubio_wavetable_set_amp ( aubio_wavetable_t * o, smpl_t amp ); |
---|
| 147 | |
---|
| 148 | /** get wavetable amplitude |
---|
| 149 | |
---|
[2b6139e7] | 150 | \param o wavetable, created by new_aubio_wavetable() |
---|
[dd15573] | 151 | |
---|
| 152 | \return current amplitude |
---|
| 153 | |
---|
| 154 | */ |
---|
[ce3ff2b] | 155 | smpl_t aubio_wavetable_get_amp ( const aubio_wavetable_t * o); |
---|
[dd15573] | 156 | |
---|
[2b6139e7] | 157 | /** destroy aubio_wavetable_t object |
---|
[dd15573] | 158 | |
---|
[2b6139e7] | 159 | \param o wavetable, created by new_aubio_wavetable() |
---|
[dd15573] | 160 | |
---|
| 161 | */ |
---|
| 162 | void del_aubio_wavetable( aubio_wavetable_t * o ); |
---|
| 163 | |
---|
| 164 | #ifdef __cplusplus |
---|
| 165 | } |
---|
| 166 | #endif |
---|
| 167 | |
---|
[6f42c16] | 168 | #endif /* AUBIO_WAVETABLE_H */ |
---|