aubio  0.4.1
synth/wavetable.h
Go to the documentation of this file.
00001 /*
00002   Copyright (C) 2003-2013 Paul Brossier <piem@aubio.org>
00003 
00004   This file is part of aubio.
00005 
00006   aubio is free software: you can redistribute it and/or modify
00007   it under the terms of the GNU General Public License as published by
00008   the Free Software Foundation, either version 3 of the License, or
00009   (at your option) any later version.
00010 
00011   aubio is distributed in the hope that it will be useful,
00012   but WITHOUT ANY WARRANTY; without even the implied warranty of
00013   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014   GNU General Public License for more details.
00015 
00016   You should have received a copy of the GNU General Public License
00017   along with aubio.  If not, see <http://www.gnu.org/licenses/>.
00018 
00019 */
00020 
00021 #ifndef _AUBIO_WAVETABLE_H
00022 #define _AUBIO_WAVETABLE_H
00023 
00024 /** \file
00025 
00026   Wavetable synthesis.
00027 
00028   This file creates a wavetable and plays it at different frequency.
00029 
00030   The `_do` function adds the new samples to the input, and write the result as
00031   the output.
00032 
00033   \example synth/test-wavetable.c
00034 
00035 */
00036 
00037 #ifdef __cplusplus
00038 extern "C" {
00039 #endif
00040 
00041 /** wavetable object */
00042 typedef struct _aubio_wavetable_t aubio_wavetable_t;
00043 
00044 /** create new wavetable object
00045 
00046   \param samplerate the sampling rate of the new wavetable
00047   \param hop_size the block size of the new wavetable
00048 
00049   \return the newly created aubio_wavetable_t
00050 
00051 */
00052 aubio_wavetable_t * new_aubio_wavetable(uint_t samplerate, uint_t hop_size);
00053 
00054 /** load source in wavetable
00055 
00056   \param o wavetable, created by new_aubio_wavetable()
00057   \param uri the uri of the source to load
00058 
00059   \return 0 if successful, non-zero otherwise
00060 
00061 */
00062 uint_t aubio_wavetable_load( aubio_wavetable_t * o, char_t * uri );
00063 
00064 /** process wavetable function
00065 
00066   \param o wavetable, created by new_aubio_wavetable()
00067   \param input input of the wavetable, to be added to the output
00068   \param output output of the wavetable
00069 
00070 This function adds the new samples from the playing wavetable to the output.
00071 
00072 If `input` is not NULL and different from `output`, then the samples from `input`
00073 are added to the output.
00074 
00075 */
00076 void aubio_wavetable_do ( aubio_wavetable_t * o, fvec_t * input, fvec_t * output);
00077 
00078 /** process wavetable function, multiple channels
00079 
00080   \param o wavetable, created by new_aubio_wavetable()
00081   \param input input of the wavetable, to be added to the output
00082   \param output output of the wavetable
00083 
00084 This function adds the new samples from the playing wavetable to the output.
00085 
00086 If `input` is not NULL and different from `output`, then the samples from `input`
00087 are added to the output.
00088 
00089 */
00090 void aubio_wavetable_do_multi ( aubio_wavetable_t * o, fmat_t * input, fmat_t * output);
00091 
00092 /** get current playing state
00093 
00094   \param o wavetable, created by new_aubio_wavetable()
00095 
00096   \return 0 if not playing, 1 if playing
00097 
00098 */
00099 uint_t aubio_wavetable_get_playing ( aubio_wavetable_t * o );
00100 
00101 /** set current playing state
00102 
00103   \param o wavetable, created by new_aubio_wavetable()
00104   \param playing 0 for not playing, 1 for playing
00105 
00106   \return 0 if successful, 1 otherwise
00107 
00108 */
00109 uint_t aubio_wavetable_set_playing ( aubio_wavetable_t * o, uint_t playing );
00110 
00111 /** play sample from start
00112 
00113   \param o wavetable, created by new_aubio_wavetable()
00114 
00115   \return 0 if successful, 1 otherwise
00116 
00117 */
00118 uint_t aubio_wavetable_play ( aubio_wavetable_t * o );
00119 
00120 /** stop wavetable
00121 
00122   \param o wavetable, created by new_aubio_wavetable()
00123 
00124   \return 0 if successful, 1 otherwise
00125 
00126 */
00127 uint_t aubio_wavetable_stop ( aubio_wavetable_t * o );
00128 
00129 /** set wavetable frequency
00130 
00131   \param o wavetable, created by new_aubio_wavetable()
00132   \param freq new frequency value for the wavetable
00133 
00134   \return 0 if successful, 1 otherwise
00135 
00136 */
00137 uint_t aubio_wavetable_set_freq ( aubio_wavetable_t * o, smpl_t freq );
00138 
00139 /** get wavetable frequency
00140 
00141   \param o wavetable, created by new_aubio_wavetable()
00142 
00143   \return current frequency, in Hz
00144 
00145 */
00146 smpl_t aubio_wavetable_get_freq ( aubio_wavetable_t * o);
00147 
00148 /** set wavetable amplitude
00149 
00150   \param o wavetable, created by new_aubio_wavetable()
00151   \param amp new amplitude value for the wavetable
00152 
00153   \return 0 if successful, 1 otherwise
00154 
00155 */
00156 uint_t aubio_wavetable_set_amp ( aubio_wavetable_t * o, smpl_t amp );
00157 
00158 /** get wavetable amplitude
00159 
00160   \param o wavetable, created by new_aubio_wavetable()
00161 
00162   \return current amplitude
00163 
00164 */
00165 smpl_t aubio_wavetable_get_amp ( aubio_wavetable_t * o);
00166 
00167 /** destroy aubio_wavetable_t object
00168 
00169   \param o wavetable, created by new_aubio_wavetable()
00170 
00171 */
00172 void del_aubio_wavetable( aubio_wavetable_t * o );
00173 
00174 #ifdef __cplusplus
00175 }
00176 #endif
00177 
00178 #endif /* _AUBIO_WAVETABLE_H */
 All Data Structures Files Functions Variables Typedefs Defines