Unified · Split
| @@ -18,136 +18,121 @@ extern "C" { · 17 unmodified lines | ||
| 18 | 18 | #include "leaf-tables.h" |
| 19 | 19 | #include "leaf-filters.h" |
| 20 | 20 | |
| 21 | + | |
| 21 | 22 | /*! |
| 22 | − * Header. | |
| 23 | − * @include basic-oscillators.h | |
| 24 | − * @example basic-oscillators.c | |
| 25 | − * An example. | |
| 23 | + Header. | |
| 24 | + @include basic-oscillators.h | |
| 25 | + @example basic-oscillators.c | |
| 26 | + An example. | |
| 26 | 27 | */ |
| 28 | + | |
| 27 | 29 | |
| 28 | 30 | //============================================================================== |
| 29 | 31 | |
| 30 | − typedef struct _tCycle | |
| 31 | − { | |
| 32 | − tMempool mempool; | |
| 33 | − // Underlying phasor | |
| 34 | − float phase; | |
| 35 | − float inc,freq; | |
| 36 | − } _tCycle; | |
| 37 | − | |
| 38 | − typedef _tCycle* tCycle; | |
| 39 | − | |
| 40 | 32 | /*! |
| 41 | − * @defgroup tcycle tCycle | |
| 42 | − * @ingroup oscillators | |
| 43 | − * @brief A cycle/sine waveform oscillator. Uses wavetable synthesis. | |
| 44 | − * @{ | |
| 33 | + @defgroup tcycle tCycle | |
| 34 | + @ingroup oscillators | |
| 35 | + @brief A cycle/sine waveform oscillator. Uses wavetable synthesis. | |
| 36 | + @{ | |
| 45 | 37 | */ |
| 46 | 38 | |
| 47 | − //! Initialize a tCycle to the default LEAF mempool. | |
| 48 | 39 | /*! |
| 40 | + @fn void tCycle_init (tCycle* const osc) | |
| 41 | + @brief Initialize a tCycle to the default LEAF mempool. | |
| 49 | 42 | @param osc A pointer to the tCycle to be initialized. |
| 50 | 43 | */ |
| 51 | − void tCycle_init (tCycle* const osc); | |
| 52 | 44 | |
| 53 | − | |
| 54 | − //! Initialize a tCycle to a specified mempool. | |
| 55 | 45 | /*! |
| 46 | + @fn void tCycle_initToPool (tCycle* const osc, tMempool* const pool) | |
| 47 | + @brief Initialize a tCycle to a specified mempool. | |
| 56 | 48 | @param osc A pointer to the tCycle to be initialized. |
| 57 | 49 | @param pool A pointer to the tMempool to which the tCycle should be initialized. |
| 58 | 50 | */ |
| 59 | − void tCycle_initToPool (tCycle* const osc, tMempool* const pool); | |
| 60 | − | |
| 61 | 51 | |
| 62 | − //! Free a tCycle from the default LEAF mempool. | |
| 63 | 52 | /*! |
| 53 | + @fn void tCycle_free (tCycle* const osc) | |
| 54 | + @brief Free a tCycle from the default LEAF mempool. | |
| 64 | 55 | @param osc A pointer to the tCycle to be freed. |
| 65 | 56 | */ |
| 66 | − void tCycle_free (tCycle* const osc); | |
| 67 | − | |
| 68 | 57 | |
| 69 | − //! Tick a tCycle oscillator. | |
| 70 | 58 | /*! |
| 59 | + @fn float tCycle_tick (tCycle* const osc) | |
| 60 | + @brief Tick a tCycle oscillator. | |
| 71 | 61 | @param osc A pointer to the relevant tCycle. |
| 72 | 62 | @return The ticked sample as a float from -1 to 1. |
| 73 | 63 | */ |
| 74 | − float tCycle_tick (tCycle* const osc); | |
| 75 | 64 | |
| 76 | − | |
| 77 | − //! Set the frequency of a tCycle oscillator. | |
| 78 | 65 | /*! |
| 66 | + @fn void tCycle_setFreq (tCycle* const osc, float freq) | |
| 67 | + @brief Set the frequency of a tCycle oscillator. | |
| 79 | 68 | @param osc A pointer to the relevant tCycle. |
| 80 | 69 | @param freq The frequency to set the oscillator to. |
| 81 | 70 | */ |
| 82 | − void tCycle_setFreq (tCycle* const osc, float freq); | |
| 83 | 71 | |
| 84 | 72 | /*! @} */ |
| 85 | 73 | |
| 86 | − //============================================================================== | |
| 87 | − | |
| 88 | − /* tTriangle: Anti-aliased Triangle waveform using wavetable interpolation. Wavetables constructed from sine components. */ | |
| 89 | − typedef struct _tTriangle | |
| 74 | + typedef struct _tCycle | |
| 90 | 75 | { |
| 91 | 76 | tMempool mempool; |
| 92 | 77 | // Underlying phasor |
| 93 | 78 | float phase; |
| 94 | 79 | float inc,freq; |
| 95 | − int oct; | |
| 96 | − float w; | |
| 97 | − } _tTriangle; | |
| 80 | + } _tCycle; | |
| 98 | 81 | |
| 99 | − typedef _tTriangle* tTriangle; | |
| 82 | + typedef _tCycle* tCycle; | |
| 83 | + | |
| 84 | + void tCycle_init (tCycle* const osc); | |
| 85 | + void tCycle_initToPool (tCycle* const osc, tMempool* const pool); | |
| 86 | + void tCycle_free (tCycle* const osc); | |
| 87 | + | |
| 88 | + float tCycle_tick (tCycle* const osc); | |
| 89 | + void tCycle_setFreq (tCycle* const osc, float freq); | |
| 90 | + | |
| 91 | + //============================================================================== | |
| 100 | 92 | |
| 101 | 93 | /*! |
| 102 | − * @defgroup ttriangle tTriangle | |
| 103 | − * @ingroup oscillators | |
| 104 | − * @brief An anti-aliased triangle waveform oscillator. Uses wavetable synthesis. | |
| 105 | − * @{ | |
| 94 | + @defgroup ttriangle tTriangle | |
| 95 | + @ingroup oscillators | |
| 96 | + @brief Anti-aliased Triangle waveform using wavetable interpolation. Wavetables constructed from sine components. | |
| 97 | + @{ | |
| 106 | 98 | */ |
| 107 | 99 | |
| 108 | − //! Initialize a tTriangle to the default LEAF mempool. | |
| 109 | 100 | /*! |
| 101 | + @fn void tTriangle_init (tTriangle* const osc) | |
| 102 | + @brief Initialize a tTriangle to the default LEAF mempool. | |
| 110 | 103 | @param osc A pointer to the tTriangle to be initialized. |
| 111 | 104 | */ |
| 112 | − void tTriangle_init (tTriangle* const osc); | |
| 113 | − | |
| 114 | 105 | |
| 115 | − //! Initialize a tTriangle to a specified mempool. | |
| 116 | 106 | /*! |
| 107 | + @fn void tTriangle_initToPool (tTriangle* const osc, tMempool* const pool) | |
| 108 | + @brief Initialize a tTriangle to a specified mempool. | |
| 117 | 109 | @param osc A pointer to the tTriangle to be initialized. |
| 118 | 110 | @param pool A pointer to the tMempool to which the tTriangle should be initialized. |
| 119 | 111 | */ |
| 120 | − void tTriangle_initToPool (tTriangle* const osc, tMempool* const pool); | |
| 121 | 112 | |
| 122 | − | |
| 123 | − //! Free a tTriangle from the default LEAF mempool. | |
| 124 | 113 | /*! |
| 114 | + @fn void tTriangle_free (tTriangle* const osc) | |
| 115 | + @brief Free a tTriangle from the default LEAF mempool. | |
| 125 | 116 | @param osc A pointer to the tTriangle to be freed. |
| 126 | 117 | */ |
| 127 | − void tTriangle_free (tTriangle* const osc); | |
| 128 | − | |
| 129 | 118 | |
| 130 | − //! Tick a tTriangle oscillator. | |
| 131 | 119 | /*! |
| 120 | + @fn float tTriangle_tick (tTriangle* const osc) | |
| 121 | + @brief Tick a tTriangle oscillator. | |
| 132 | 122 | @param osc A pointer to the relevant tTriangle. |
| 133 | 123 | @return The ticked sample as a float from -1 to 1. |
| 134 | 124 | */ |
| 135 | − float tTriangle_tick (tTriangle* const osc); | |
| 136 | − | |
| 137 | 125 | |
| 138 | − //! Set the frequency of a tTriangle oscillator. | |
| 139 | 126 | /*! |
| 127 | + @fn void tTriangle_setFreq (tTriangle* const osc, float freq) | |
| 128 | + @brief Set the frequency of a tTriangle oscillator. | |
| 140 | 129 | @param osc A pointer to the relevant tTriangle. |
| 141 | 130 | @param freq The frequency to set the oscillator to. |
| 142 | 131 | */ |
| 143 | − void tTriangle_setFreq (tTriangle* const osc, float freq); | |
| 144 | 132 | |
| 145 | 133 | /*! @} */ |
| 146 | − | |
| 147 | − //============================================================================== | |
| 148 | − | |
| 149 | − /* tSquare: Anti-aliased Square waveform using wavetable interpolation. Wavetables constructed from sine components. */ | |
| 150 | − typedef struct _tSquare | |
| 134 | + | |
| 135 | + typedef struct _tTriangle | |
| 151 | 136 | { |
| 152 | 137 | tMempool mempool; |
| 153 | 138 | // Underlying phasor |
| @@ -155,60 +140,63 @@ extern "C" { · 1 unmodified line | ||
| 155 | 140 | float inc,freq; |
| 156 | 141 | int oct; |
| 157 | 142 | float w; |
| 158 | − } _tSquare; | |
| 143 | + } _tTriangle; | |
| 159 | 144 | |
| 160 | − typedef _tSquare* tSquare; | |
| 145 | + typedef _tTriangle* tTriangle; | |
| 146 | + | |
| 147 | + void tTriangle_init (tTriangle* const osc); | |
| 148 | + void tTriangle_initToPool (tTriangle* const osc, tMempool* const pool); | |
| 149 | + void tTriangle_free (tTriangle* const osc); | |
| 150 | + | |
| 151 | + float tTriangle_tick (tTriangle* const osc); | |
| 152 | + void tTriangle_setFreq (tTriangle* const osc, float freq); | |
| 153 | + | |
| 154 | + | |
| 155 | + //============================================================================== | |
| 161 | 156 | |
| 162 | 157 | /*! |
| 163 | − * @defgroup tsquare tSquare | |
| 164 | − * @ingroup oscillators | |
| 165 | − * @brief An anti-aliased square waveform oscillator. Uses wavetable synthesis. | |
| 166 | − * @{ | |
| 158 | + @defgroup tsquare tSquare | |
| 159 | + @ingroup oscillators | |
| 160 | + @brief Anti-aliased Square waveform using wavetable interpolation. Wavetables constructed from sine components. | |
| 161 | + @{ | |
| 167 | 162 | */ |
| 168 | 163 | |
| 169 | − //! Initialize a tSquare to the default LEAF mempool. | |
| 170 | 164 | /*! |
| 165 | + @fn void tSquare_init (tSquare* const osc) | |
| 166 | + @brief Initialize a tSquare to the default LEAF mempool. | |
| 171 | 167 | @param osc A pointer to the tSquare to be initialized. |
| 172 | 168 | */ |
| 173 | − void tSquare_init (tSquare* const osc); | |
| 174 | − | |
| 175 | 169 | |
| 176 | − //! Initialize a tSquare to a specified mempool. | |
| 177 | 170 | /*! |
| 171 | + @fn void tSquare_initToPool (tSquare* const osc, tMempool* const pool) | |
| 172 | + @brief Initialize a tSquare to a specified mempool. | |
| 178 | 173 | @param osc A pointer to the tSquare to be initialized. |
| 179 | 174 | @param pool A pointer to the tMempool to which the tSquare should be initialized. |
| 180 | 175 | */ |
| 181 | − void tSquare_initToPool (tSquare* const osc, tMempool* const); | |
| 182 | − | |
| 183 | 176 | |
| 184 | − //! Free a tSquare from the default LEAF mempool. | |
| 185 | 177 | /*! |
| 178 | + @fn void tSquare_free (tSquare* const osc) | |
| 179 | + @brief Free a tSquare from the default LEAF mempool. | |
| 186 | 180 | @param osc A pointer to the tSquare to be freed. |
| 187 | 181 | */ |
| 188 | − void tSquare_free (tSquare* const osc); | |
| 189 | 182 | |
| 190 | − | |
| 191 | − //! Tick a tSquare oscillator. | |
| 192 | 183 | /*! |
| 184 | + @fn float tSquare_tick (tSquare* const osc) | |
| 185 | + @brief Tick a tSquare oscillator. | |
| 193 | 186 | @param osc A pointer to the relevant tSquare. |
| 194 | 187 | @return The ticked sample as a float from -1 to 1. |
| 195 | 188 | */ |
| 196 | − float tSquare_tick (tSquare* const osc); | |
| 197 | − | |
| 198 | 189 | |
| 199 | − //! Set the frequency of a tSquare oscillator. | |
| 200 | 190 | /*! |
| 191 | + @fn void tSquare_setFreq (tSquare* const osc, float freq) | |
| 192 | + @brief Set the frequency of a tSquare oscillator. | |
| 201 | 193 | @param osc A pointer to the relevant tSquare. |
| 202 | 194 | @param freq The frequency to set the oscillator to. |
| 203 | 195 | */ |
| 204 | − void tSquare_setFreq (tSquare* const osc, float freq); | |
| 205 | 196 | |
| 206 | 197 | /*! @} */ |
| 207 | 198 | |
| 208 | − //============================================================================== | |
| 209 | − | |
| 210 | − /* tSawtooth: Anti-aliased Sawtooth waveform using wavetable interpolation. Wavetables constructed from sine components. */ | |
| 211 | − typedef struct _tSawtooth | |
| 199 | + typedef struct _tSquare | |
| 212 | 200 | { |
| 213 | 201 | tMempool mempool; |
| 214 | 202 | // Underlying phasor |
| @@ -216,58 +204,86 @@ extern "C" { · 1 unmodified line | ||
| 216 | 204 | float inc,freq; |
| 217 | 205 | int oct; |
| 218 | 206 | float w; |
| 219 | − } _tSawtooth; | |
| 207 | + } _tSquare; | |
| 220 | 208 | |
| 221 | − typedef _tSawtooth* tSawtooth; | |
| 209 | + typedef _tSquare* tSquare; | |
| 210 | + | |
| 211 | + void tSquare_init (tSquare* const osc); | |
| 212 | + void tSquare_initToPool (tSquare* const osc, tMempool* const); | |
| 213 | + void tSquare_free (tSquare* const osc); | |
| 214 | + | |
| 215 | + float tSquare_tick (tSquare* const osc); | |
| 216 | + void tSquare_setFreq (tSquare* const osc, float freq); | |
| 217 | + | |
| 218 | + /*! @} */ | |
| 219 | + | |
| 220 | + //============================================================================== | |
| 222 | 221 | |
| 223 | 222 | /*! |
| 224 | − * @defgroup tsawtooth tSawtooth | |
| 225 | − * @ingroup oscillators | |
| 226 | − * @brief An anti-aliased sawtooth waveform oscillator. Uses wavetable synthesis. | |
| 227 | − * @{ | |
| 223 | + @defgroup tsawtooth tSawtooth | |
| 224 | + @ingroup oscillators | |
| 225 | + @brief Anti-aliased Square waveform using wavetable interpolation. Wavetables constructed from sine components. | |
| 226 | + @{ | |
| 228 | 227 | */ |
| 229 | 228 | |
| 230 | − //! Initialize a tSawtooth to the default LEAF mempool. | |
| 231 | 229 | /*! |
| 230 | + @fn void tSawtooth_init (tSawtooth* const osc) | |
| 231 | + @brief Initialize a tSawtooth to the default LEAF mempool. | |
| 232 | 232 | @param osc A pointer to the tSawtooth to be initialized. |
| 233 | 233 | */ |
| 234 | − void tSawtooth_init (tSawtooth* const osc); | |
| 235 | 234 | |
| 236 | − | |
| 237 | − //! Initialize a tSawtooth to a specified mempool. | |
| 238 | 235 | /*! |
| 236 | + @fn void tSawtooth_initToPool (tSawtooth* const osc, tMempool* const pool) | |
| 237 | + @brief Initialize a tSawtooth to a specified mempool. | |
| 239 | 238 | @param osc A pointer to the tSawtooth to be initialized. |
| 240 | 239 | @param pool A pointer to the tMempool to which the tSawtooth should be initialized. |
| 241 | 240 | */ |
| 242 | − void tSawtooth_initToPool (tSawtooth* const osc, tMempool* const pool); | |
| 243 | 241 | |
| 244 | − | |
| 245 | − //! Free a tSawtooth from the default LEAF mempool. | |
| 246 | 242 | /*! |
| 243 | + @fn void tSawtooth_free (tSawtooth* const osc) | |
| 244 | + @brief Free a tSawtooth from the default LEAF mempool. | |
| 247 | 245 | @param osc A pointer to the tSawtooth to be freed. |
| 248 | 246 | */ |
| 249 | − void tSawtooth_free (tSawtooth* const osc); | |
| 250 | 247 | |
| 251 | − | |
| 252 | − //! Tick a tSawtooth oscillator. | |
| 253 | 248 | /*! |
| 249 | + @fn float tSawtooth_tick (tSawtooth* const osc) | |
| 250 | + @brief Tick a tSawtooth oscillator. | |
| 254 | 251 | @param osc A pointer to the relevant tSawtooth. |
| 255 | 252 | @return The ticked sample as a float from -1 to 1. |
| 256 | 253 | */ |
| 257 | − float tSawtooth_tick (tSawtooth* const osc); | |
| 258 | − | |
| 259 | 254 | |
| 260 | − //! Set the frequency of a tSawtooth oscillator. | |
| 261 | 255 | /*! |
| 256 | + @fn void tSawtooth_setFreq (tSawtooth* const osc, float freq) | |
| 257 | + @brief Set the frequency of a tSawtooth oscillator. | |
| 262 | 258 | @param osc A pointer to the relevant tSawtooth. |
| 263 | 259 | @param freq The frequency to set the oscillator to. |
| 264 | 260 | */ |
| 265 | − void tSawtooth_setFreq (tSawtooth* const osc, float freq); | |
| 266 | 261 | |
| 267 | 262 | /*! @} */ |
| 268 | 263 | |
| 264 | + typedef struct _tSawtooth | |
| 265 | + { | |
| 266 | + tMempool mempool; | |
| 267 | + // Underlying phasor | |
| 268 | + float phase; | |
| 269 | + float inc,freq; | |
| 270 | + int oct; | |
| 271 | + float w; | |
| 272 | + } _tSawtooth; | |
| 273 | + | |
| 274 | + typedef _tSawtooth* tSawtooth; | |
| 275 | + | |
| 276 | + void tSawtooth_init (tSawtooth* const osc); | |
| 277 | + void tSawtooth_initToPool (tSawtooth* const osc, tMempool* const pool); | |
| 278 | + void tSawtooth_free (tSawtooth* const osc); | |
| 279 | + | |
| 280 | + float tSawtooth_tick (tSawtooth* const osc); | |
| 281 | + void tSawtooth_setFreq (tSawtooth* const osc, float freq); | |
| 282 | + | |
| 269 | 283 | //============================================================================== |
| 270 | 284 | |
| 285 | + | |
| 286 | + // TO BE REMOVED | |
| 271 | 287 | typedef struct _tSine |
| 272 | 288 | { |
| 273 | 289 | tMempool mempool; |
| @@ -279,55 +295,15 @@ extern "C" { · 5 unmodified lines | ||
| 279 | 295 | |
| 280 | 296 | typedef _tSine* tSine; |
| 281 | 297 | |
| 282 | − /*! | |
| 283 | − * @defgroup tsine tSine | |
| 284 | − * @ingroup oscillators | |
| 285 | − * @brief A cycle/sine waveform oscillator. | |
| 286 | − * @{ | |
| 287 | − */ | |
| 288 | − | |
| 289 | − //! Initialize a tSine to the default LEAF mempool. | |
| 290 | − /*! | |
| 291 | − @param osc A pointer to the tSine to be initialized. | |
| 292 | − */ | |
| 293 | 298 | void tSine_init (tSine* const osc, int size); |
| 294 | − | |
| 295 | − | |
| 296 | − //! Initialize a tSine to a specified mempool. | |
| 297 | − /*! | |
| 298 | − @param osc A pointer to the tSine to be initialized. | |
| 299 | − @param pool A pointer to the tMempool to which the tSine should be initialized. | |
| 300 | − */ | |
| 301 | 299 | void tSine_initToPool (tSine* const osc, int size, tMempool* const pool); |
| 302 | − | |
| 303 | − | |
| 304 | − //! Free a tSine from the default LEAF mempool. | |
| 305 | − /*! | |
| 306 | − @param osc A pointer to the tSine to be freed. | |
| 307 | − */ | |
| 300 | + | |
| 308 | 301 | void tSine_free (tSine* const osc); |
| 309 | − | |
| 310 | − | |
| 311 | − //! Tick a tSine oscillator. | |
| 312 | − /*! | |
| 313 | − @param osc A pointer to the relevant tSine. | |
| 314 | − @return The ticked sample as a float from -1 to 1. | |
| 315 | − */ | |
| 316 | 302 | float tSine_tick (tSine* const osc); |
| 317 | − | |
| 318 | − | |
| 319 | − //! Set the frequency of a tSine oscillator. | |
| 320 | − /*! | |
| 321 | − @param osc A pointer to the relevant tSine. | |
| 322 | − @param freq The frequency to set the oscillator to. | |
| 323 | − */ | |
| 324 | 303 | void tSine_setFreq (tSine* const osc, float freq); |
| 325 | 304 | |
| 326 | − /*! @} */ | |
| 327 | − | |
| 328 | 305 | //============================================================================== |
| 329 | − | |
| 330 | − /* tTri: Anti-aliased Triangle waveform using wavetable interpolation. */ | |
| 306 | + | |
| 331 | 307 | typedef struct _tTri |
| 332 | 308 | { |
| 333 | 309 | tMempool mempool; |
| @@ -339,57 +315,18 @@ extern "C" { · 5 unmodified lines | ||
| 339 | 315 | |
| 340 | 316 | typedef _tTri* tTri; |
| 341 | 317 | |
| 342 | − /*! | |
| 343 | − * @defgroup tTri tTri | |
| 344 | − * @ingroup oscillators | |
| 345 | − * @brief An anti-aliased triangle waveform oscillator. | |
| 346 | − * @{ | |
| 347 | − */ | |
| 348 | − | |
| 349 | − //! Initialize a tTri to the default LEAF mempool. | |
| 350 | − /*! | |
| 351 | − @param osc A pointer to the tTri to be initialized. | |
| 352 | − */ | |
| 353 | 318 | void tTri_init (tTri* const osc); |
| 354 | − | |
| 355 | − | |
| 356 | − //! Initialize a tTri to a specified mempool. | |
| 357 | − /*! | |
| 358 | − @param osc A pointer to the tTri to be initialized. | |
| 359 | − @param pool A pointer to the tMempool to which the tTri should be initialized. | |
| 360 | − */ | |
| 361 | 319 | void tTri_initToPool (tTri* const osc, tMempool* const pool); |
| 362 | − | |
| 363 | − | |
| 364 | − //! Free a tTri from the default LEAF mempool. | |
| 365 | − /*! | |
| 366 | − @param osc A pointer to the tTri to be freed. | |
| 367 | − */ | |
| 368 | 320 | void tTri_free (tTri* const osc); |
| 369 | 321 | |
| 370 | − | |
| 371 | − //! Tick a tTri oscillator. | |
| 372 | − /*! | |
| 373 | − @param osc A pointer to the relevant tTri. | |
| 374 | − @return The ticked sample as a float from -1 to 1. | |
| 375 | − */ | |
| 376 | 322 | float tTri_tick (tTri* const osc); |
| 377 | − | |
| 378 | − | |
| 379 | − //! Set the frequency of a tTri oscillator. | |
| 380 | − /*! | |
| 381 | − @param osc A pointer to the relevant tTriangle. | |
| 382 | − @param freq The frequency to set the oscillator to. | |
| 383 | − */ | |
| 384 | 323 | void tTri_setFreq (tTri* const osc, float freq); |
| 385 | − | |
| 386 | 324 | void tTri_setSkew (tTri* const osc, float skew); |
| 387 | 325 | |
| 388 | 326 | /*! @} */ |
| 389 | 327 | |
| 390 | 328 | //============================================================================== |
| 391 | 329 | |
| 392 | − /* tPulse: Anti-aliased Square waveform. */ | |
| 393 | 330 | typedef struct _tPulse |
| 394 | 331 | { |
| 395 | 332 | tMempool mempool; |
| @@ -400,57 +337,16 @@ extern "C" { · 4 unmodified lines | ||
| 400 | 337 | |
| 401 | 338 | typedef _tPulse* tPulse; |
| 402 | 339 | |
| 403 | − /*! | |
| 404 | − * @defgroup tPulse tPulse | |
| 405 | − * @ingroup oscillators | |
| 406 | − * @brief An anti-aliased pulse waveform oscillator with changeable pulse width. | |
| 407 | − * @{ | |
| 408 | − */ | |
| 409 | − | |
| 410 | − //! Initialize a tPulse to the default LEAF mempool. | |
| 411 | − /*! | |
| 412 | − @param osc A pointer to the tPulse to be initialized. | |
| 413 | − */ | |
| 414 | 340 | void tPulse_init (tPulse* const osc); |
| 415 | − | |
| 416 | − | |
| 417 | − //! Initialize a tPulse to a specified mempool. | |
| 418 | − /*! | |
| 419 | − @param osc A pointer to the tPulse to be initialized. | |
| 420 | − @param pool A pointer to the tMempool to which the tPulse should be initialized. | |
| 421 | − */ | |
| 422 | 341 | void tPulse_initToPool (tPulse* const osc, tMempool* const); |
| 423 | − | |
| 424 | − | |
| 425 | − //! Free a tPulse from the default LEAF mempool. | |
| 426 | − /*! | |
| 427 | − @param osc A pointer to the tPulse to be freed. | |
| 428 | − */ | |
| 429 | 342 | void tPulse_free (tPulse* const osc); |
| 430 | 343 | |
| 431 | − | |
| 432 | − //! Tick a tPulse oscillator. | |
| 433 | − /*! | |
| 434 | − @param osc A pointer to the relevant tPulse. | |
| 435 | − @return The ticked sample as a float from -1 to 1. | |
| 436 | − */ | |
| 437 | 344 | float tPulse_tick (tPulse* const osc); |
| 438 | − | |
| 439 | − | |
| 440 | − //! Set the frequency of a tPulse oscillator. | |
| 441 | − /*! | |
| 442 | − @param osc A pointer to the relevant tPulse. | |
| 443 | − @param freq The frequency to set the oscillator to. | |
| 444 | − */ | |
| 445 | 345 | void tPulse_setFreq (tPulse* const osc, float freq); |
| 446 | − | |
| 447 | 346 | void tPulse_setWidth (tPulse* const osc, float width); |
| 448 | 347 | |
| 449 | − /*! @} */ | |
| 450 | − | |
| 451 | 348 | //============================================================================== |
| 452 | 349 | |
| 453 | − /* tSawtooth: Anti-aliased Sawtooth waveform. */ | |
| 454 | 350 | typedef struct _tSaw |
| 455 | 351 | { |
| 456 | 352 | tMempool mempool; |
| @@ -460,55 +356,15 @@ extern "C" { · 3 unmodified lines | ||
| 460 | 356 | |
| 461 | 357 | typedef _tSaw* tSaw; |
| 462 | 358 | |
| 463 | − /*! | |
| 464 | − * @defgroup tsaw tSaw | |
| 465 | − * @ingroup oscillators | |
| 466 | − * @brief An anti-aliased sawtooth waveform oscillator. Uses wavetable synthesis. | |
| 467 | − * @{ | |
| 468 | − */ | |
| 469 | − | |
| 470 | − //! Initialize a tSaw to the default LEAF mempool. | |
| 471 | − /*! | |
| 472 | − @param osc A pointer to the tSaw to be initialized. | |
| 473 | − */ | |
| 474 | 359 | void tSaw_init (tSaw* const osc); |
| 475 | − | |
| 476 | − | |
| 477 | − //! Initialize a tSaw to a specified mempool. | |
| 478 | − /*! | |
| 479 | − @param osc A pointer to the tSaw to be initialized. | |
| 480 | − @param pool A pointer to the tMempool to which the tSaw should be initialized. | |
| 481 | − */ | |
| 482 | 360 | void tSaw_initToPool (tSaw* const osc, tMempool* const pool); |
| 483 | − | |
| 484 | − | |
| 485 | − //! Free a tSaw from the default LEAF mempool. | |
| 486 | − /*! | |
| 487 | − @param osc A pointer to the tSaw to be freed. | |
| 488 | − */ | |
| 489 | 361 | void tSaw_free (tSaw* const osc); |
| 490 | 362 | |
| 491 | − | |
| 492 | − //! Tick a tSaw oscillator. | |
| 493 | − /*! | |
| 494 | − @param osc A pointer to the relevant tSaw. | |
| 495 | − @return The ticked sample as a float from -1 to 1. | |
| 496 | − */ | |
| 497 | 363 | float tSaw_tick (tSaw* const osc); |
| 498 | − | |
| 499 | − | |
| 500 | − //! Set the frequency of a tSaw oscillator. | |
| 501 | − /*! | |
| 502 | − @param osc A pointer to the relevant tSaw. | |
| 503 | − @param freq The frequency to set the oscillator to. | |
| 504 | − */ | |
| 505 | 364 | void tSaw_setFreq (tSaw* const osc, float freq); |
| 506 | 365 | |
| 507 | − /*! @} */ | |
| 508 | − | |
| 509 | 366 | //============================================================================== |
| 510 | 367 | |
| 511 | − /* tPhasor: Aliasing phasor [0.0, 1.0) */ | |
| 512 | 368 | typedef struct _tPhasor |
| 513 | 369 | { |
| 514 | 370 | tMempool mempool; |
| @@ -519,61 +375,15 @@ extern "C" { · 4 unmodified lines | ||
| 519 | 375 | |
| 520 | 376 | typedef _tPhasor* tPhasor; |
| 521 | 377 | |
| 522 | − /*! | |
| 523 | − * @defgroup tphasor Phasor | |
| 524 | − * @ingroup oscillators | |
| 525 | − * @brief An aliasing phasor. | |
| 526 | − * @{ | |
| 527 | − */ | |
| 528 | − | |
| 529 | − //! Initialize a tPhasor to the default LEAF mempool. | |
| 530 | − /*! | |
| 531 | − @param osc A pointer to the tPhasor to be initialized. | |
| 532 | − */ | |
| 533 | 378 | void tPhasor_init (tPhasor* const osc); |
| 534 | − | |
| 535 | − | |
| 536 | − //! Initialize a tPhasor to a specified mempool. | |
| 537 | − /*! | |
| 538 | − @param osc A pointer to the tPhasor to be initialized. | |
| 539 | − @param pool A pointer to the tMempool to which the tPhasor should be initialized. | |
| 540 | − */ | |
| 541 | 379 | void tPhasor_initToPool (tPhasor* const osc, tMempool* const); |
| 542 | − | |
| 543 | − | |
| 544 | − //! Free a tPhasor from the default LEAF mempool. | |
| 545 | − /*! | |
| 546 | − @param osc A pointer to the tPhasor to be freed. | |
| 547 | − */ | |
| 548 | 380 | void tPhasor_free (tPhasor* const osc); |
| 549 | 381 | |
| 550 | − | |
| 551 | − //! Tick a tPhasor oscillator. | |
| 552 | − /*! | |
| 553 | − @param osc A pointer to the relevant tPhasor. | |
| 554 | − @return The ticked sample as a float from 0 to 1. | |
| 555 | − */ | |
| 556 | 382 | float tPhasor_tick (tPhasor* const osc); |
| 557 | − | |
| 558 | − | |
| 559 | − //! Set the frequency of a tPhasor oscillator. | |
| 560 | − /*! | |
| 561 | − @param osc A pointer to the relevant tPhasor. | |
| 562 | − @param freq The frequency to set the oscillator to. | |
| 563 | − */ | |
| 564 | 383 | void tPhasor_setFreq (tPhasor* const osc, float freq); |
| 565 | 384 | |
| 566 | − /*! @} */ | |
| 567 | − | |
| 568 | 385 | //============================================================================== |
| 569 | 386 | |
| 570 | − /*! | |
| 571 | − * @defgroup tnoise tNoise | |
| 572 | − * @ingroup oscillators | |
| 573 | − * @brief A noise generator. | |
| 574 | − * @{ | |
| 575 | − */ | |
| 576 | − | |
| 577 | 387 | /* tNoise. WhiteNoise, PinkNoise. */ |
| 578 | 388 | /*! |
| 579 | 389 | * Noise types |
| @@ -596,198 +406,179 @@ extern "C" { · 16 unmodified lines | ||
| 596 | 406 | } _tNoise; |
| 597 | 407 | |
| 598 | 408 | typedef _tNoise* tNoise; |
| 599 | − | |
| 600 | − //! Initialize a tNoise to the default LEAF mempool. | |
| 601 | − /*! | |
| 602 | − @param osc A pointer to the tNoise to be initialized. | |
| 603 | − */ | |
| 409 | + | |
| 604 | 410 | void tNoise_init (tNoise* const noise, NoiseType type); |
| 605 | − | |
| 606 | − | |
| 607 | − //! Initialize a tNoise to a specified mempool. | |
| 608 | − /*! | |
| 609 | − @param osc A pointer to the tNoise to be initialized. | |
| 610 | − @param pool A pointer to the tMempool to which the tNoise should be initialized. | |
| 611 | − */ | |
| 612 | 411 | void tNoise_initToPool (tNoise* const noise, NoiseType type, tMempool* const); |
| 613 | − | |
| 614 | − | |
| 615 | − //! Free a tNoise from the default LEAF mempool. | |
| 616 | − /*! | |
| 617 | − @param osc A pointer to the tNoise to be freed. | |
| 618 | − */ | |
| 619 | 412 | void tNoise_free (tNoise* const noise); |
| 620 | 413 | |
| 621 | − | |
| 622 | − //! Tick a tNoise oscillator. | |
| 623 | − /*! | |
| 624 | − @param osc A pointer to the relevant tNoise. | |
| 625 | − @return The ticked sample as a float from -1 to 1. | |
| 626 | − */ | |
| 627 | 414 | float tNoise_tick (tNoise* const noise); |
| 628 | 415 | |
| 629 | − /*! @} */ | |
| 630 | − | |
| 631 | 416 | //============================================================================== |
| 632 | 417 | |
| 633 | 418 | /*! |
| 634 | − * @defgroup tneuron tNeuron | |
| 635 | − * @ingroup oscillators | |
| 636 | − * @brief A model of a neuron, adapted to act as an oscillator. | |
| 637 | − * @{ | |
| 419 | + @defgroup tneuron tNeuron | |
| 420 | + @ingroup oscillators | |
| 421 | + @brief A model of a neuron, adapted to act as an oscillator. | |
| 422 | + @{ | |
| 638 | 423 | */ |
| 639 | 424 | |
| 640 | 425 | /*! |
| 641 | − * Neuron modes | |
| 642 | − */ | |
| 643 | − enum NeuronMode | |
| 644 | − { | |
| 645 | − NeuronNormal, //!< Normal operation | |
| 646 | − NeuronTanh, //!< Tanh voltage shaping | |
| 647 | − NeuronAaltoShaper, //!< Aalto voltage shaping | |
| 648 | − NeuronModeNil | |
| 649 | − }; | |
| 650 | − typedef enum NeuronMode NeuronMode; | |
| 651 | − | |
| 652 | − typedef struct _tNeuron | |
| 653 | − { | |
| 654 | − tMempool mempool; | |
| 655 | − | |
| 656 | − tPoleZero f; | |
| 657 | − | |
| 658 | − NeuronMode mode; | |
| 659 | − | |
| 660 | − float voltage, current; | |
| 661 | − float timeStep; | |
| 662 | − | |
| 663 | − float alpha[3]; | |
| 664 | − float beta[3]; | |
| 665 | − float rate[3]; | |
| 666 | − float V[3]; | |
| 667 | − float P[3]; | |
| 668 | − float gK, gN, gL, C; | |
| 669 | − } _tNeuron; | |
| 670 | − | |
| 671 | − typedef _tNeuron* tNeuron; | |
| 672 | − | |
| 673 | − //! Initialize a tNeuron to the default LEAF mempool. | |
| 674 | − /*! | |
| 426 | + @fn void tNeuron_init (tNeuron* const neuron) | |
| 427 | + @brief Initialize a tNeuron to the default LEAF mempool. | |
| 675 | 428 | @param neuron A pointer to the tNeuron to be initialized. |
| 676 | 429 | */ |
| 677 | − void tNeuron_init (tNeuron* const neuron); | |
| 678 | − | |
| 679 | 430 | |
| 680 | − //! Initialize a tNeuron to a specified mempool. | |
| 681 | 431 | /*! |
| 432 | + @fn void tNeuron_initToPool (tNeuron* const neuron, tMempool* const pool) | |
| 433 | + @brief Initialize a tNeuron to a specified mempool. | |
| 682 | 434 | @param neuron A pointer to the tNeuron to be initialized. |
| 683 | 435 | @param pool A pointer to the tMempool to which the tNeuron should be initialized. |
| 684 | 436 | */ |
| 685 | − void tNeuron_initToPool (tNeuron* const neuron, tMempool* const pool); | |
| 686 | 437 | |
| 687 | − | |
| 688 | − //! Free a tNeuron from the default LEAF mempool. | |
| 689 | 438 | /*! |
| 439 | + @fn void tNeuron_free (tNeuron* const neuron) | |
| 440 | + @brief Free a tNeuron from the default LEAF mempool. | |
| 690 | 441 | @param neuron A pointer to the tNeuron to be freed. |
| 691 | 442 | */ |
| 692 | − void tNeuron_free (tNeuron* const neuron); | |
| 693 | − | |
| 694 | 443 | |
| 695 | − //! Reset the neuron model. | |
| 696 | 444 | /*! |
| 445 | + @fn void tNeuron_reset (tNeuron* const neuron) | |
| 446 | + @brief Reset the neuron model. | |
| 697 | 447 | @param neuron A pointer to the relevant tNeuron. |
| 698 | 448 | */ |
| 699 | − void tNeuron_reset (tNeuron* const neuron); | |
| 700 | − | |
| 701 | 449 | |
| 702 | − //! Tick a tNeuron oscillator. | |
| 703 | 450 | /*! |
| 451 | + @fn float tNeuron_tick (tNeuron* const neuron) | |
| 452 | + @brief Tick a tNeuron oscillator. | |
| 704 | 453 | @param neuron A pointer to the relevant tNeuron. |
| 705 | 454 | @return The ticked sample as a float from -1 to 1. |
| 706 | 455 | */ |
| 707 | − float tNeuron_tick (tNeuron* const neuron); | |
| 708 | − | |
| 709 | − | |
| 710 | − //! Set the tNeuron shaping mode. | |
| 456 | + | |
| 711 | 457 | /*! |
| 458 | + @fn void tNeuron_setMode (tNeuron* const neuron, NeuronMode mode) | |
| 459 | + @brief Set the tNeuron shaping mode. | |
| 712 | 460 | @param neuron A pointer to the relevant tNeuron. |
| 713 | 461 | @param mode The mode to set the tNeuron to. |
| 714 | 462 | */ |
| 715 | − void tNeuron_setMode (tNeuron* const neuron, NeuronMode mode); | |
| 716 | − | |
| 717 | − | |
| 718 | − //! Set the current. | |
| 463 | + | |
| 719 | 464 | /*! |
| 465 | + @fn void tNeuron_setCurrent (tNeuron* const neuron, float current) | |
| 466 | + @brief Set the current. | |
| 720 | 467 | @param neuron A pointer to the relevant tNeuron. |
| 721 | 468 | @param current The new current. |
| 722 | 469 | */ |
| 723 | − void tNeuron_setCurrent (tNeuron* const neuron, float current); | |
| 724 | − | |
| 725 | 470 | |
| 726 | − //! Set the potassium value. | |
| 727 | 471 | /*! |
| 472 | + @fn void tNeuron_setK (tNeuron* const neuron, float K) | |
| 473 | + @brief Set the potassium value. | |
| 728 | 474 | @param neuron A pointer to the relevant tNeuron. |
| 729 | 475 | @param K The new potassium. |
| 730 | 476 | */ |
| 731 | − void tNeuron_setK (tNeuron* const neuron, float K); | |
| 732 | − | |
| 733 | 477 | |
| 734 | − //! Set the chloride value. | |
| 735 | 478 | /*! |
| 479 | + @fn void tNeuron_setL (tNeuron* const neuron, float L) | |
| 480 | + @brief Set the chloride value. | |
| 736 | 481 | @param neuron A pointer to the relevant tNeuron. |
| 737 | 482 | @param L The new chloride value. |
| 738 | 483 | */ |
| 739 | − void tNeuron_setL (tNeuron* const neuron, float L); | |
| 740 | 484 | |
| 741 | − | |
| 742 | − //! Set the sodium value. | |
| 743 | 485 | /*! |
| 486 | + @fn void tNeuron_setN (tNeuron* const neuron, float N) | |
| 487 | + @brief Set the sodium value. | |
| 744 | 488 | @param neuron A pointer to the relevant tNeuron. |
| 745 | 489 | @param N The new sodium value. |
| 746 | 490 | */ |
| 747 | − void tNeuron_setN (tNeuron* const neuron, float N); | |
| 748 | − | |
| 749 | 491 | |
| 750 | − //! Set the calcium value. | |
| 751 | 492 | /*! |
| 493 | + @fn void tNeuron_setC (tNeuron* const neuron, float C) | |
| 494 | + @brief Set the calcium value. | |
| 752 | 495 | @param neuron A pointer to the relevant tNeuron. |
| 753 | 496 | @param C The new calcium. |
| 754 | 497 | */ |
| 755 | − void tNeuron_setC (tNeuron* const neuron, float C); | |
| 756 | − | |
| 757 | 498 | |
| 758 | − //! Set the V1 value. | |
| 759 | 499 | /*! |
| 500 | + @fn void tNeuron_setV1 (tNeuron* const neuron, float V1) | |
| 501 | + @brief Set the V1 value. | |
| 760 | 502 | @param neuron A pointer to the relevant tNeuron. |
| 761 | 503 | @param V1 The new V1. |
| 762 | 504 | */ |
| 763 | − void tNeuron_setV1 (tNeuron* const neuron, float V1); | |
| 764 | 505 | |
| 765 | − | |
| 766 | − //! Set the V2 value. | |
| 767 | 506 | /*! |
| 507 | + @fn void tNeuron_setV2 (tNeuron* const neuron, float V2) | |
| 508 | + @brief Set the V2 value. | |
| 768 | 509 | @param neuron A pointer to the relevant tNeuron. |
| 769 | 510 | @param V2 The new V2. |
| 770 | 511 | */ |
| 771 | − void tNeuron_setV2 (tNeuron* const neuron, float V2); | |
| 772 | − | |
| 773 | 512 | |
| 774 | − //! Set the V3 value. | |
| 775 | 513 | /*! |
| 514 | + @fn void tNeuron_setV3 (tNeuron* const neuron, float V3) | |
| 515 | + @brief Set the V3 value. | |
| 776 | 516 | @param neuron A pointer to the relevant tNeuron. |
| 777 | 517 | @param V3 The new V3. |
| 778 | 518 | */ |
| 779 | − void tNeuron_setV3 (tNeuron* const neuron, float V3); | |
| 780 | − | |
| 781 | 519 | |
| 782 | − //! Set the time step. | |
| 783 | 520 | /*! |
| 521 | + @fn void tNeuron_setTimeStep (tNeuron* const neuron, float timestep) | |
| 522 | + @brief Set the time step of the model. | |
| 784 | 523 | @param neuron A pointer to the relevant tNeuron. |
| 785 | − @param timestep The new time step | |
| 524 | + @param timestep The new time step. | |
| 786 | 525 | */ |
| 787 | − void tNeuron_setTimeStep (tNeuron* const neuron, float timestep); | |
| 526 | + | |
| 527 | + /*! | |
| 528 | + @brief Shaping modes for tNeuron output. | |
| 529 | + */ | |
| 530 | + enum NeuronMode | |
| 531 | + { | |
| 532 | + NeuronNormal, //!< Normal operation | |
| 533 | + NeuronTanh, //!< Tanh voltage shaping | |
| 534 | + NeuronAaltoShaper, //!< Aalto voltage shaping | |
| 535 | + NeuronModeNil | |
| 536 | + }; | |
| 788 | 537 | |
| 789 | 538 | /*! @} */ |
| 790 | 539 | |
| 540 | + typedef enum NeuronMode NeuronMode; | |
| 541 | + | |
| 542 | + typedef struct _tNeuron | |
| 543 | + { | |
| 544 | + tMempool mempool; | |
| 545 | + | |
| 546 | + tPoleZero f; | |
| 547 | + | |
| 548 | + NeuronMode mode; | |
| 549 | + | |
| 550 | + float voltage, current; | |
| 551 | + float timeStep; | |
| 552 | + | |
| 553 | + float alpha[3]; | |
| 554 | + float beta[3]; | |
| 555 | + float rate[3]; | |
| 556 | + float V[3]; | |
| 557 | + float P[3]; | |
| 558 | + float gK, gN, gL, C; | |
| 559 | + } _tNeuron; | |
| 560 | + | |
| 561 | + typedef _tNeuron* tNeuron; | |
| 562 | + | |
| 563 | + void tNeuron_init (tNeuron* const neuron); | |
| 564 | + void tNeuron_initToPool (tNeuron* const neuron, tMempool* const pool); | |
| 565 | + void tNeuron_free (tNeuron* const neuron); | |
| 566 | + | |
| 567 | + void tNeuron_reset (tNeuron* const neuron); | |
| 568 | + float tNeuron_tick (tNeuron* const neuron); | |
| 569 | + void tNeuron_setMode (tNeuron* const neuron, NeuronMode mode); | |
| 570 | + void tNeuron_setCurrent (tNeuron* const neuron, float current); | |
| 571 | + void tNeuron_setK (tNeuron* const neuron, float K); | |
| 572 | + void tNeuron_setL (tNeuron* const neuron, float L); | |
| 573 | + void tNeuron_setN (tNeuron* const neuron, float N); | |
| 574 | + void tNeuron_setC (tNeuron* const neuron, float C); | |
| 575 | + void tNeuron_setV1 (tNeuron* const neuron, float V1); | |
| 576 | + void tNeuron_setV2 (tNeuron* const neuron, float V2); | |
| 577 | + void tNeuron_setV3 (tNeuron* const neuron, float V3); | |
| 578 | + void tNeuron_setTimeStep (tNeuron* const neuron, float timestep); | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 791 | 582 | //============================================================================== |
| 792 | 583 | |
| 793 | 584 | #define FILLEN 256 |
| @@ -888,3 +679,5 @@ extern "C" { · 94 unmodified lines | ||
| 888 | 679 | |
| 889 | 680 | //============================================================================== |
| 890 | 681 | |
| 682 | + | |
| 683 | + | |