Unified · Split
| @@ -32,7 +32,7 @@ tNoise noise; · 31 unmodified lines | |||
| 32 | tButterworth bw; | 32 | tButterworth bw; |
| 33 | 33 | ||
| 34 | tWaveTable wt; | 34 | tWaveTable wt; |
| 35 | tCompactWaveTable cwt; | 35 | tWaveTableS cwt; |
| 36 | tWaveSynth ws; | 36 | tWaveSynth ws; |
| 37 | 37 | ||
| 38 | tBuffer samp; | 38 | tBuffer samp; |
| @@ -64,7 +64,7 @@ void LEAFTest_init (float sampleRate, int blockSize) · 25 unmodified lines | |||
| 64 | LEAF_init(&leaf, sampleRate, blockSize, memory, MSIZE, &getRandomFloat); | 64 | LEAF_init(&leaf, sampleRate, blockSize, memory, MSIZE, &getRandomFloat); |
| 65 | 65 | ||
| 66 | // tWaveTable_init(&wt, __leaf_table_sawtooth[0], 2048, 10000.f, &leaf); | 66 | // tWaveTable_init(&wt, __leaf_table_sawtooth[0], 2048, 10000.f, &leaf); |
| 67 | // tCompactWaveTable_init(&cwt, __leaf_table_sawtooth[0], 2048, 10000.f, &leaf); | 67 | // tWaveTableS_init(&cwt, __leaf_table_sawtooth[0], 2048, 10000.f, &leaf); |
| 68 | 68 | ||
| 69 | tMBTriangle_init(&btri, &leaf); | 69 | tMBTriangle_init(&btri, &leaf); |
| 70 | tMBPulse_init(&bpulse, &leaf); | 70 | tMBPulse_init(&bpulse, &leaf); |
| @@ -118,7 +118,7 @@ void LEAFTest_block (void) · 47 unmodified lines | |||
| 118 | tMBPulse_setFreq(&bpulse, val * 160000.f - 80000.0f); | 118 | tMBPulse_setFreq(&bpulse, val * 160000.f - 80000.0f); |
| 119 | tMBSaw_setFreq(&bsaw, val * 10000.f); | 119 | tMBSaw_setFreq(&bsaw, val * 10000.f); |
| 120 | // tWaveTable_setFreq(&wt, val * 160000.f - 80000.0f); | 120 | // tWaveTable_setFreq(&wt, val * 160000.f - 80000.0f); |
| 121 | // tCompactWaveTable_setFreq(&cwt, val * 10000.); | 121 | // tWaveTableS_setFreq(&cwt, val * 10000.); |
| 122 | tWaveSynth_setFreq(&ws, 0, val * 10000.f); | 122 | tWaveSynth_setFreq(&ws, 0, val * 10000.f); |
| 123 | // tRetune_tuneVoice(&retune, 0, val * 3.0f + 0.5f); | 123 | // tRetune_tuneVoice(&retune, 0, val * 3.0f + 0.5f); |
| 124 | // tSimpleRetune_tuneVoice(&sretune, 0, 300); | 124 | // tSimpleRetune_tuneVoice(&sretune, 0, 300); |
| @@ -281,152 +281,153 @@ extern "C" { · 280 unmodified lines | |||
| 281 | // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | 281 | // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ |
| 282 | 282 | ||
| 283 | /*! | 283 | /*! |
| 284 | @defgroup tasdr2 tADSR2 | 284 | @defgroup tadsrt tADSRT |
| 285 | @ingroup envelopes | 285 | @ingroup envelopes |
| 286 | @brief | 286 | @brief |
| 287 | @{ | 287 | @{ |
| 288 | 288 | ||
| 289 | @fn void tADSR2_init (tADSR2* const, float attack, float decay, float sustain, float release, LEAF* const leaf) | 289 | @fn void tADSRT_init (tADSRT* const, float attack, float decay, float sustain, float release, float* expBuffer, int bufferSize, LEAF* const leaf) |
| 290 | @brief Initialize a tADSR2 to the default mempool of a LEAF instance. | 290 | @brief Initialize a tADSRT to the default mempool of a LEAF instance. |
| 291 | @param adsr A pointer to the tADSR2 to initialize. | 291 | @param adsr A pointer to the tADSRT to initialize. |
| 292 | @param leaf A pointer to the leaf instance. | 292 | @param leaf A pointer to the leaf instance. |
| 293 | 293 | ||
| 294 | @fn void tADSR2_initToPool (tADSR2* const, float attack, float decay, float sustain, float release, tMempool* const) | 294 | @fn void tADSRT_initToPool (tADSRT* const, float attack, float decay, float sustain, float release, float* expBuffer, int bufferSize, tMempool* const) |
| 295 | @brief Initialize a tADSR2 to a specified mempool. | 295 | @brief Initialize a tADSRT to a specified mempool. |
| 296 | @param adsr A pointer to the tADSR2 to initialize. | 296 | @param adsr A pointer to the tADSRT to initialize. |
| 297 | @param mempool A pointer to the tMempool to use. | 297 | @param mempool A pointer to the tMempool to use. |
| 298 | 298 | ||
| 299 | @fn void tADSR2_free (tADSR2* const) | 299 | @fn void tADSRT_free (tADSRT* const) |
| 300 | @brief Free a tADSR2 from its mempool. | 300 | @brief Free a tADSRT from its mempool. |
| 301 | @param adsr A pointer to the tADSR2 to free. | 301 | @param adsr A pointer to the tADSRT to free. |
| 302 | 302 | ||
| 303 | @fn float tADSR2_tick (tADSR2* const) | 303 | @fn float tADSRT_tick (tADSRT* const) |
| 304 | @brief | 304 | @brief |
| 305 | @param adsr A pointer to the relevant tADSR2. | 305 | @param adsr A pointer to the relevant tADSRT. |
| 306 | 306 | ||
| 307 | @fn void tADSR2_setAttack (tADSR2* const, float attack) | 307 | @fn float tADSRT_tickNoInterp (tADSRT* const adsrenv) |
| 308 | @brief | ||
| 309 | @param adsr A pointer to the relevant tADSRT. | ||
| 310 | |||
| 311 | @fn void tADSRT_setAttack (tADSRT* const, float attack) | ||
| 308 | @brief | 312 | @brief |
| 309 | @param adsr A pointer to the relevant tADSR2. | 313 | @param adsr A pointer to the relevant tADSRT. |
| 310 | 314 | ||
| 311 | @fn void tADSR2_setDecay (tADSR2* const, float decay) | 315 | @fn void tADSRT_setDecay (tADSRT* const, float decay) |
| 312 | @brief | 316 | @brief |
| 313 | @param adsr A pointer to the relevant tADSR2. | 317 | @param adsr A pointer to the relevant tADSRT. |
| 314 | 318 | ||
| 315 | @fn void tADSR2_setSustain (tADSR2* const, float sustain) | 319 | @fn void tADSRT_setSustain (tADSRT* const, float sustain) |
| 316 | @brief | 320 | @brief |
| 317 | @param adsr A pointer to the relevant tADSR2. | 321 | @param adsr A pointer to the relevant tADSRT. |
| 318 | 322 | ||
| 319 | @fn void tADSR2_setRelease (tADSR2* const, float release) | 323 | @fn void tADSRT_setRelease (tADSRT* const, float release) |
| 320 | @brief | 324 | @brief |
| 321 | @param adsr A pointer to the relevant tADSR2. | 325 | @param adsr A pointer to the relevant tADSRT. |
| 322 | 326 | ||
| 323 | @fn void tADSR2_setLeakFactor (tADSR2* const, float leakFactor) | 327 | @fn void tADSRT_setLeakFactor (tADSRT* const, float leakFactor) |
| 324 | @brief | 328 | @brief |
| 325 | @param adsr A pointer to the relevant tADSR2. | 329 | @param adsr A pointer to the relevant tADSRT. |
| 326 | 330 | ||
| 327 | @fn void tADSR2_on (tADSR2* const, float velocity) | 331 | @fn void tADSRT_on (tADSRT* const, float velocity) |
| 328 | @brief | 332 | @brief |
| 329 | @param adsr A pointer to the relevant tADSR2. | 333 | @param adsr A pointer to the relevant tADSRT. |
| 330 | 334 | ||
| 331 | @fn void tADSR2_off (tADSR2* const) | 335 | @fn void tADSRT_off (tADSRT* const) |
| 332 | @brief | 336 | @brief |
| 333 | @param adsr A pointer to the relevant tADSR2. | 337 | @param adsr A pointer to the relevant tADSRT. |
| 334 | 338 | ||
| 335 | @} */ | 339 | @} */ |
| 336 | 340 | ||
| 337 | typedef struct _tADSR2 | 341 | typedef struct _tADSRT |
| 338 | { | 342 | { |
| 339 | 343 | ||
| 340 | tMempool mempool; | 344 | tMempool mempool; |
| 341 | float sampleRateInMs; | 345 | const float *exp_buff; |
| 342 | float attack; | 346 | uint32_t buff_size; |
| 343 | float decay; | 347 | uint32_t buff_sizeMinusOne; |
| 344 | float release; | 348 | float bufferSizeDividedBySampleRateInMs; |
| 345 | float attackLambda; | 349 | float next; |
| 346 | float decayLambda; | 350 | |
| 347 | float releaseLambda; | 351 | float attackInc, decayInc, releaseInc, rampInc; |
| 348 | float sustain; | 352 | |
| 349 | float leakGain; | 353 | uint32_t whichStage; |
| 354 | |||
| 355 | float sustain, gain, rampPeak, releasePeak; | ||
| 356 | |||
| 357 | float attackPhase, decayPhase, releasePhase, rampPhase; | ||
| 358 | |||
| 350 | float leakFactor; | 359 | float leakFactor; |
| 351 | float targetGainSquared; | 360 | } _tADSRT; |
| 352 | float factor; | ||
| 353 | float oneMinusFactor; | ||
| 354 | float gain; | ||
| 355 | uint8_t attacking; | ||
| 356 | uint8_t gate; | ||
| 357 | float env; | ||
| 358 | float envTarget; | ||
| 359 | } _tADSR2; | ||
| 360 | |||
| 361 | typedef _tADSR2* tADSR2; | ||
| 362 | 361 | ||
| 363 | void tADSR2_init (tADSR2* const, float attack, float decay, float sustain, float release, LEAF* const leaf); | 362 | typedef _tADSRT* tADSRT; |
| 364 | void tADSR2_initToPool (tADSR2* const, float attack, float decay, float sustain, float release, tMempool* const); | ||
| 365 | void tADSR2_free (tADSR2* const); | ||
| 366 | 363 | ||
| 367 | float tADSR2_tick (tADSR2* const); | 364 | void tADSRT_init (tADSRT* const, float attack, float decay, float sustain, float release, float* expBuffer, int bufferSize, LEAF* const leaf); |
| 368 | void tADSR2_setAttack (tADSR2* const, float attack); | 365 | void tADSRT_initToPool (tADSRT* const, float attack, float decay, float sustain, float release, float* expBuffer, int bufferSize, tMempool* const); |
| 369 | void tADSR2_setDecay (tADSR2* const, float decay); | 366 | void tADSRT_free (tADSRT* const); |
| 370 | void tADSR2_setSustain (tADSR2* const, float sustain); | ||
| 371 | void tADSR2_setRelease (tADSR2* const, float release); | ||
| 372 | void tADSR2_setLeakFactor (tADSR2* const, float leakFactor); | ||
| 373 | void tADSR2_on (tADSR2* const, float velocity); | ||
| 374 | void tADSR2_off (tADSR2* const); | ||
| 375 | 367 | ||
| 368 | float tADSRT_tick (tADSRT* const); | ||
| 369 | float tADSRT_tickNoInterp (tADSRT* const adsrenv); | ||
| 370 | void tADSRT_setAttack (tADSRT* const, float attack); | ||
| 371 | void tADSRT_setDecay (tADSRT* const, float decay); | ||
| 372 | void tADSRT_setSustain (tADSRT* const, float sustain); | ||
| 373 | void tADSRT_setRelease (tADSRT* const, float release); | ||
| 374 | void tADSRT_setLeakFactor (tADSRT* const, float leakFactor); | ||
| 375 | void tADSRT_on (tADSRT* const, float velocity); | ||
| 376 | void tADSRT_off (tADSRT* const); | ||
| 376 | 377 | ||
| 377 | // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | 378 | // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ |
| 378 | 379 | ||
| 379 | /*! | 380 | /*! |
| 380 | @defgroup tadsr3 tADSR3 | 381 | @defgroup tadsrs tADSRS |
| 381 | @ingroup envelopes | 382 | @ingroup envelopes |
| 382 | @brief | 383 | @brief |
| 383 | @{ | 384 | @{ |
| 384 | 385 | ||
| 385 | @fn void tADSR3_init (tADSR3* const, float attack, float decay, float sustain, float release, LEAF* const leaf) | 386 | @fn void tADSRS_init (tADSRS* const, float attack, float decay, float sustain, float release, LEAF* const leaf) |
| 386 | @brief Initialize a tADSR3 to the default mempool of a LEAF instance. | 387 | @brief Initialize a tADSRS to the default mempool of a LEAF instance. |
| 387 | @param adsr A pointer to the tADSR3 to initialize. | 388 | @param adsr A pointer to the tADSRS to initialize. |
| 388 | @param leaf A pointer to the leaf instance. | 389 | @param leaf A pointer to the leaf instance. |
| 389 | 390 | ||
| 390 | @fn void tADSR3_initToPool (tADSR3* const, float attack, float decay, float sustain, float release, tMempool* const) | 391 | @fn void tADSRS_initToPool (tADSRS* const, float attack, float decay, float sustain, float release, tMempool* const) |
| 391 | @brief Initialize a tADSR3 to a specified mempool. | 392 | @brief Initialize a tADSRS to a specified mempool. |
| 392 | @param adsr A pointer to the tADSR3 to initialize. | 393 | @param adsr A pointer to the tADSRS to initialize. |
| 393 | @param mempool A pointer to the tMempool to use. | 394 | @param mempool A pointer to the tMempool to use. |
| 394 | 395 | ||
| 395 | @fn void tADSR3_free (tADSR3* const) | 396 | @fn void tADSRS_free (tADSRS* const) |
| 396 | @brief Free a tADSR3 from its mempool. | 397 | @brief Free a tADSRS from its mempool. |
| 397 | @param adsr A pointer to the tADSR3 to free. | 398 | @param adsr A pointer to the tADSRS to free. |
| 398 | 399 | ||
| 399 | @fn float tADSR3_tick (tADSR3* const) | 400 | @fn float tADSRS_tick (tADSRS* const) |
| 400 | @brief | 401 | @brief |
| 401 | @param adsr A pointer to the relevant tADSR3. | 402 | @param adsr A pointer to the relevant tADSRS. |
| 402 | 403 | ||
| 403 | @fn void tADSR3_setAttack (tADSR3* const, float attack) | 404 | @fn void tADSRS_setAttack (tADSRS* const, float attack) |
| 404 | @brief | 405 | @brief |
| 405 | @param adsr A pointer to the relevant tADSR3. | 406 | @param adsr A pointer to the relevant tADSRS. |
| 406 | 407 | ||
| 407 | @fn void tADSR3_setDecay (tADSR3* const, float decay) | 408 | @fn void tADSRS_setDecay (tADSRS* const, float decay) |
| 408 | @brief | 409 | @brief |
| 409 | @param adsr A pointer to the relevant tADSR3. | 410 | @param adsr A pointer to the relevant tADSRS. |
| 410 | 411 | ||
| 411 | @fn void tADSR3_setSustain (tADSR3* const, float sustain) | 412 | @fn void tADSRS_setSustain (tADSRS* const, float sustain) |
| 412 | @brief | 413 | @brief |
| 413 | @param adsr A pointer to the relevant tADSR3. | 414 | @param adsr A pointer to the relevant tADSRS. |
| 414 | 415 | ||
| 415 | @fn void tADSR3_setRelease (tADSR3* const, float release) | 416 | @fn void tADSRS_setRelease (tADSRS* const, float release) |
| 416 | @brief | 417 | @brief |
| 417 | @param adsr A pointer to the relevant tADSR3. | 418 | @param adsr A pointer to the relevant tADSRS. |
| 418 | 419 | ||
| 419 | @fn void tADSR3_setLeakFactor (tADSR3* const, float leakFactor) | 420 | @fn void tADSRS_setLeakFactor (tADSRS* const, float leakFactor) |
| 420 | @brief | 421 | @brief |
| 421 | @param adsr A pointer to the relevant tADSR3. | 422 | @param adsr A pointer to the relevant tADSRS. |
| 422 | 423 | ||
| 423 | @fn void tADSR3_on (tADSR3* const, float velocity) | 424 | @fn void tADSRS_on (tADSRS* const, float velocity) |
| 424 | @brief | 425 | @brief |
| 425 | @param adsr A pointer to the relevant tADSR3. | 426 | @param adsr A pointer to the relevant tADSRS. |
| 426 | 427 | ||
| 427 | @fn void tADSR3_off (tADSR3* const) | 428 | @fn void tADSRS_off (tADSRS* const) |
| 428 | @brief | 429 | @brief |
| 429 | @param adsr A pointer to the relevant tADSR3. | 430 | @param adsr A pointer to the relevant tADSRS. |
| 430 | 431 | ||
| 431 | @} */ | 432 | @} */ |
| 432 | 433 | ||
| @@ -439,7 +440,7 @@ extern "C" { · 6 unmodified lines | |||
| 439 | env_ramp | 440 | env_ramp |
| 440 | }; | 441 | }; |
| 441 | 442 | ||
| 442 | typedef struct _tADSR3 | 443 | typedef struct _tADSRS |
| 443 | { | 444 | { |
| 444 | 445 | ||
| 445 | tMempool mempool; | 446 | tMempool mempool; |
| @@ -464,119 +465,22 @@ extern "C" { · 18 unmodified lines | |||
| 464 | float oneMinusFactor; | 465 | float oneMinusFactor; |
| 465 | float gain; | 466 | float gain; |
| 466 | 467 | ||
| 467 | } _tADSR3; | 468 | } _tADSRS; |
| 468 | 469 | ||
| 469 | typedef _tADSR3* tADSR3; | 470 | typedef _tADSRS* tADSRS; |
| 470 | 471 | ||
| 471 | void tADSR3_init (tADSR3* const, float attack, float decay, float sustain, float release, LEAF* const leaf); | 472 | void tADSRS_init (tADSRS* const, float attack, float decay, float sustain, float release, LEAF* const leaf); |
| 472 | void tADSR3_initToPool (tADSR3* const, float attack, float decay, float sustain, float release, tMempool* const); | 473 | void tADSRS_initToPool (tADSRS* const, float attack, float decay, float sustain, float release, tMempool* const); |
| 473 | void tADSR3_free (tADSR3* const); | 474 | void tADSRS_free (tADSRS* const); |
| 474 | 475 | ||
| 475 | float tADSR3_tick (tADSR3* const); | 476 | float tADSRS_tick (tADSRS* const); |
| 476 | void tADSR3_setAttack (tADSR3* const, float attack); | 477 | void tADSRS_setAttack (tADSRS* const, float attack); |
| 477 | void tADSR3_setDecay (tADSR3* const, float decay); | 478 | void tADSRS_setDecay (tADSRS* const, float decay); |
| 478 | void tADSR3_setSustain (tADSR3* const, float sustain); | 479 | void tADSRS_setSustain (tADSRS* const, float sustain); |
| 479 | void tADSR3_setRelease (tADSR3* const, float release); | 480 | void tADSRS_setRelease (tADSRS* const, float release); |
| 480 | void tADSR3_setLeakFactor (tADSR3* const, float leakFactor); | 481 | void tADSRS_setLeakFactor (tADSRS* const, float leakFactor); |
| 481 | void tADSR3_on (tADSR3* const, float velocity); | 482 | void tADSRS_on (tADSRS* const, float velocity); |
| 482 | void tADSR3_off (tADSR3* const); | 483 | void tADSRS_off (tADSRS* const); |
| 483 | |||
| 484 | // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | ||
| 485 | |||
| 486 | /*! | ||
| 487 | @defgroup tadsr4 tADSR4 | ||
| 488 | @ingroup envelopes | ||
| 489 | @brief | ||
| 490 | @{ | ||
| 491 | |||
| 492 | @fn void tADSR4_init (tADSR4* const, float attack, float decay, float sustain, float release, float* expBuffer, int bufferSize, LEAF* const leaf) | ||
| 493 | @brief Initialize a tADSR4 to the default mempool of a LEAF instance. | ||
| 494 | @param adsr A pointer to the tADSR4 to initialize. | ||
| 495 | @param leaf A pointer to the leaf instance. | ||
| 496 | |||
| 497 | @fn void tADSR4_initToPool (tADSR4* const, float attack, float decay, float sustain, float release, float* expBuffer, int bufferSize, tMempool* const) | ||
| 498 | @brief Initialize a tADSR4 to a specified mempool. | ||
| 499 | @param adsr A pointer to the tADSR4 to initialize. | ||
| 500 | @param mempool A pointer to the tMempool to use. | ||
| 501 | |||
| 502 | @fn void tADSR4_free (tADSR4* const) | ||
| 503 | @brief Free a tADSR4 from its mempool. | ||
| 504 | @param adsr A pointer to the tADSR4 to free. | ||
| 505 | |||
| 506 | @fn float tADSR4_tick (tADSR4* const) | ||
| 507 | @brief | ||
| 508 | @param adsr A pointer to the relevant tADSR4. | ||
| 509 | |||
| 510 | @fn float tADSR4_tickNoInterp (tADSR4* const adsrenv) | ||
| 511 | @brief | ||
| 512 | @param adsr A pointer to the relevant tADSR4. | ||
| 513 | |||
| 514 | @fn void tADSR4_setAttack (tADSR4* const, float attack) | ||
| 515 | @brief | ||
| 516 | @param adsr A pointer to the relevant tADSR4. | ||
| 517 | |||
| 518 | @fn void tADSR4_setDecay (tADSR4* const, float decay) | ||
| 519 | @brief | ||
| 520 | @param adsr A pointer to the relevant tADSR4. | ||
| 521 | |||
| 522 | @fn void tADSR4_setSustain (tADSR4* const, float sustain) | ||
| 523 | @brief | ||
| 524 | @param adsr A pointer to the relevant tADSR4. | ||
| 525 | |||
| 526 | @fn void tADSR4_setRelease (tADSR4* const, float release) | ||
| 527 | @brief | ||
| 528 | @param adsr A pointer to the relevant tADSR4. | ||
| 529 | |||
| 530 | @fn void tADSR4_setLeakFactor (tADSR4* const, float leakFactor) | ||
| 531 | @brief | ||
| 532 | @param adsr A pointer to the relevant tADSR4. | ||
| 533 | |||
| 534 | @fn void tADSR4_on (tADSR4* const, float velocity) | ||
| 535 | @brief | ||
| 536 | @param adsr A pointer to the relevant tADSR4. | ||
| 537 | |||
| 538 | @fn void tADSR4_off (tADSR4* const) | ||
| 539 | @brief | ||
| 540 | @param adsr A pointer to the relevant tADSR4. | ||
| 541 | |||
| 542 | @} */ | ||
| 543 | |||
| 544 | typedef struct _tADSR4 | ||
| 545 | { | ||
| 546 | |||
| 547 | tMempool mempool; | ||
| 548 | const float *exp_buff; | ||
| 549 | uint32_t buff_size; | ||
| 550 | uint32_t buff_sizeMinusOne; | ||
| 551 | float bufferSizeDividedBySampleRateInMs; | ||
| 552 | float next; | ||
| 553 | |||
| 554 | float attackInc, decayInc, releaseInc, rampInc; | ||
| 555 | |||
| 556 | uint32_t whichStage; | ||
| 557 | |||
| 558 | float sustain, gain, rampPeak, releasePeak; | ||
| 559 | |||
| 560 | float attackPhase, decayPhase, releasePhase, rampPhase; | ||
| 561 | |||
| 562 | float leakFactor; | ||
| 563 | } _tADSR4; | ||
| 564 | |||
| 565 | typedef _tADSR4* tADSR4; | ||
| 566 | |||
| 567 | void tADSR4_init (tADSR4* const, float attack, float decay, float sustain, float release, float* expBuffer, int bufferSize, LEAF* const leaf); | ||
| 568 | void tADSR4_initToPool (tADSR4* const, float attack, float decay, float sustain, float release, float* expBuffer, int bufferSize, tMempool* const); | ||
| 569 | void tADSR4_free (tADSR4* const); | ||
| 570 | |||
| 571 | float tADSR4_tick (tADSR4* const); | ||
| 572 | float tADSR4_tickNoInterp (tADSR4* const adsrenv); | ||
| 573 | void tADSR4_setAttack (tADSR4* const, float attack); | ||
| 574 | void tADSR4_setDecay (tADSR4* const, float decay); | ||
| 575 | void tADSR4_setSustain (tADSR4* const, float sustain); | ||
| 576 | void tADSR4_setRelease (tADSR4* const, float release); | ||
| 577 | void tADSR4_setLeakFactor (tADSR4* const, float leakFactor); | ||
| 578 | void tADSR4_on (tADSR4* const, float velocity); | ||
| 579 | void tADSR4_off (tADSR4* const); | ||
| 580 | 484 | ||
| 581 | // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | 485 | // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ |
| 582 | 486 | ||
| @@ -1015,7 +1015,7 @@ extern "C" { · 1014 unmodified lines | |||
| 1015 | //============================================================================== | 1015 | //============================================================================== |
| 1016 | 1016 | ||
| 1017 | /*! | 1017 | /*! |
| 1018 | @defgroup twaveset tWaveSynth | 1018 | @defgroup twavesynth tWaveSynth |
| 1019 | @ingroup oscillators | 1019 | @ingroup oscillators |
| 1020 | @brief Set of anti-aliased wavetable oscillators that can be faded between. | 1020 | @brief Set of anti-aliased wavetable oscillators that can be faded between. |
| 1021 | @{ | 1021 | @{ |
| @@ -1091,34 +1091,34 @@ extern "C" { · 69 unmodified lines | |||
| 1091 | //============================================================================== | 1091 | //============================================================================== |
| 1092 | 1092 | ||
| 1093 | /*! | 1093 | /*! |
| 1094 | @defgroup tcompactwavetable tCompactWaveTable | 1094 | @defgroup ttwavetables tWaveTableS |
| 1095 | @ingroup oscillators | 1095 | @ingroup oscillators |
| 1096 | @brief A more space-efficient anti-aliased wavetable generator than tWaveTable but with slightly worse fidelity. | 1096 | @brief A more space-efficient anti-aliased wavetable generator than tWaveTable but with slightly worse fidelity. |
| 1097 | @{ | 1097 | @{ |
| 1098 | 1098 | ||
| 1099 | @fn void tCompactWaveTable_init (tCompactWaveTable* const osc, float* table, int size, float maxFreq, LEAF* const leaf) | 1099 | @fn void tWaveTableS_init (tWaveTableS* const osc, float* table, int size, float maxFreq, LEAF* const leaf) |
| 1100 | @brief Initialize a tCompactWaveTable to the default mempool of a LEAF instance. | 1100 | @brief Initialize a tWaveTableS to the default mempool of a LEAF instance. |
| 1101 | @param osc A pointer to the tCompactWaveTable to initialize. | 1101 | @param osc A pointer to the tWaveTableS to initialize. |
| 1102 | @param table A pointer to the wavetable data. | 1102 | @param table A pointer to the wavetable data. |
| 1103 | @param size The number of samples in the wavetable. | 1103 | @param size The number of samples in the wavetable. |
| 1104 | @param maxFreq The maximum expected frequency of the oscillator. The higher this is, the more memory will be needed. | 1104 | @param maxFreq The maximum expected frequency of the oscillator. The higher this is, the more memory will be needed. |
| 1105 | @param leaf A pointer to the leaf instance. | 1105 | @param leaf A pointer to the leaf instance. |
| 1106 | 1106 | ||
| 1107 | @fn void tCompactWaveTable_initToPool (tCompactWaveTable* const osc, float* table, int size, float maxFreq, tMempool* const mempool) | 1107 | @fn void tWaveTableS_initToPool (tWaveTableS* const osc, float* table, int size, float maxFreq, tMempool* const mempool) |
| 1108 | @brief Initialize a tCompactWaveTable to a specified mempool. | 1108 | @brief Initialize a tWaveTableS to a specified mempool. |
| 1109 | @param osc A pointer to the tCompactWaveTable to initialize. | 1109 | @param osc A pointer to the tWaveTableS to initialize. |
| 1110 | @param table A pointer to the wavetable data. | 1110 | @param table A pointer to the wavetable data. |
| 1111 | @param size The number of samples in the wave table. | 1111 | @param size The number of samples in the wave table. |
| 1112 | @param maxFreq The maximum expected frequency of the oscillator. The higher this is, the more memory will be needed. | 1112 | @param maxFreq The maximum expected frequency of the oscillator. The higher this is, the more memory will be needed. |
| 1113 | @param mempool A pointer to the tMempool to use. | 1113 | @param mempool A pointer to the tMempool to use. |
| 1114 | 1114 | ||
| 1115 | @fn void tCompactWaveTable_free (tCompactWaveTable* const osc) | 1115 | @fn void tWaveTableS_free (tWaveTableS* const osc) |
| 1116 | @brief Free a tCompactWaveTable from its mempool. | 1116 | @brief Free a tWaveTableS from its mempool. |
| 1117 | @param osc A pointer to the tCompactWaveTable to free. | 1117 | @param osc A pointer to the tWaveTableS to free. |
| 1118 | 1118 | ||
| 1119 | @} */ | 1119 | @} */ |
| 1120 | 1120 | ||
| 1121 | typedef struct _tCompactWaveTable | 1121 | typedef struct _tWaveTableS |
| 1122 | { | 1122 | { |
| 1123 | tMempool mempool; | 1123 | tMempool mempool; |
| 1124 | 1124 | ||
| @@ -1129,150 +1129,150 @@ extern "C" { · 4 unmodified lines | |||
| 1129 | tButterworth bl; | 1129 | tButterworth bl; |
| 1130 | float dsBuffer[2]; | 1130 | float dsBuffer[2]; |
| 1131 | tOversampler ds; | 1131 | tOversampler ds; |
| 1132 | } _tCompactWaveTable; | 1132 | } _tWaveTableS; |
| 1133 | 1133 | ||
| 1134 | typedef _tCompactWaveTable* tCompactWaveTable; | 1134 | typedef _tWaveTableS* tWaveTableS; |
| 1135 | 1135 | ||
| 1136 | void tCompactWaveTable_init(tCompactWaveTable* const osc, float* table, int size, float maxFreq, LEAF* const leaf); | 1136 | void tWaveTableS_init(tWaveTableS* const osc, float* table, int size, float maxFreq, LEAF* const leaf); |
| 1137 | void tCompactWaveTable_initToPool(tCompactWaveTable* const osc, float* table, int size, float maxFreq, tMempool* const mempool); | 1137 | void tWaveTableS_initToPool(tWaveTableS* const osc, float* table, int size, float maxFreq, tMempool* const mempool); |
| 1138 | void tCompactWaveTable_free(tCompactWaveTable* const osc); | 1138 | void tWaveTableS_free(tWaveTableS* const osc); |
| 1139 | 1139 | ||
| 1140 | /*! | 1140 | /*! |
| 1141 | @defgroup tcompactwaveosc tCompactWaveOsc | 1141 | @defgroup twaveoscs tWaveOscS |
| 1142 | @ingroup oscillators | 1142 | @ingroup oscillators |
| 1143 | @brief A more space-efficient anti-aliased wavetable oscillator than tWaveOsc but with slightly worse fidelity. | 1143 | @brief A more space-efficient anti-aliased wavetable oscillator than tWaveOsc but with slightly worse fidelity. |
| 1144 | @{ | 1144 | @{ |
| 1145 | 1145 | ||
| 1146 | @fn void tCompactWaveOsc_init (tCompactWaveOsc* const osc, float* table, int size, float maxFreq, LEAF* const leaf) | 1146 | @fn void tWaveOscS_init (tWaveOscS* const osc, float* table, int size, float maxFreq, LEAF* const leaf) |
| 1147 | @brief Initialize a tCompactWaveOsc to the default mempool of a LEAF instance. | 1147 | @brief Initialize a tWaveOscS to the default mempool of a LEAF instance. |
| 1148 | @param osc A pointer to the tCompactWaveOsc to initialize. | 1148 | @param osc A pointer to the tWaveOscS to initialize. |
| 1149 | @param table A pointer to the wavetable data. | 1149 | @param table A pointer to the wavetable data. |
| 1150 | @param size The number of samples in the wavetable. | 1150 | @param size The number of samples in the wavetable. |
| 1151 | @param maxFreq The maximum expected frequency of the oscillator. The higher this is, the more memory will be needed. | 1151 | @param maxFreq The maximum expected frequency of the oscillator. The higher this is, the more memory will be needed. |
| 1152 | @param leaf A pointer to the leaf instance. | 1152 | @param leaf A pointer to the leaf instance. |
| 1153 | 1153 | ||
| 1154 | @fn void tCompactWaveOsc_initToPool (tCompactWaveOsc* const osc, float* table, int size, float maxFreq, tMempool* const mempool) | 1154 | @fn void tWaveOscS_initToPool (tWaveOscS* const osc, float* table, int size, float maxFreq, tMempool* const mempool) |
| 1155 | @brief Initialize a tCompactWaveOsc to a specified mempool. | 1155 | @brief Initialize a tWaveOscS to a specified mempool. |
| 1156 | @param osc A pointer to the tCompactWaveOsc to initialize. | 1156 | @param osc A pointer to the tWaveOscS to initialize. |
| 1157 | @param table A pointer to the wavetable data. | 1157 | @param table A pointer to the wavetable data. |
| 1158 | @param size The number of samples in the wave table. | 1158 | @param size The number of samples in the wave table. |
| 1159 | @param maxFreq The maximum expected frequency of the oscillator. The higher this is, the more memory will be needed. | 1159 | @param maxFreq The maximum expected frequency of the oscillator. The higher this is, the more memory will be needed. |
| 1160 | @param mempool A pointer to the tMempool to use. | 1160 | @param mempool A pointer to the tMempool to use. |
| 1161 | 1161 | ||
| 1162 | @fn void tCompactWaveOsc_free (tCompactWaveOsc* const osc) | 1162 | @fn void tWaveOscS_free (tWaveOscS* const osc) |
| 1163 | @brief Free a tCompactWaveOsc from its mempool. | 1163 | @brief Free a tWaveOscS from its mempool. |
| 1164 | @param osc A pointer to the tCompactWaveOsc to free. | 1164 | @param osc A pointer to the tWaveOscS to free. |
| 1165 | 1165 | ||
| 1166 | @fn float tCompactWaveOsc_tick (tCompactWaveOsc* const osc) | 1166 | @fn float tWaveOscS_tick (tWaveOscS* const osc) |
| 1167 | @brief Tick a tCompactWaveOsc oscillator. | 1167 | @brief Tick a tWaveOscS oscillator. |
| 1168 | @param osc A pointer to the relevant tCompactWaveOsc. | 1168 | @param osc A pointer to the relevant tWaveOscS. |
| 1169 | @return The ticked sample as a float from -1 to 1. | 1169 | @return The ticked sample as a float from -1 to 1. |
| 1170 | 1170 | ||
| 1171 | @fn void tCompactWaveOsc_setFreq (tCompactWaveOsc* const osc, float freq) | 1171 | @fn void tWaveOscS_setFreq (tWaveOscS* const osc, float freq) |
| 1172 | @brief Set the frequency of a tCompactWaveOsc oscillator. | 1172 | @brief Set the frequency of a tWaveOscS oscillator. |
| 1173 | @param osc A pointer to the relevant tCompactWaveOsc. | 1173 | @param osc A pointer to the relevant tWaveOscS. |
| 1174 | @param freq The frequency to set the oscillator to. | 1174 | @param freq The frequency to set the oscillator to. |
| 1175 | 1175 | ||
| 1176 | @} */ | 1176 | @} */ |
| 1177 | 1177 | ||
| 1178 | typedef struct _tCompactWaveOsc | 1178 | typedef struct _tWaveOscS |
| 1179 | { | 1179 | { |
| 1180 | tMempool mempool; | 1180 | tMempool mempool; |
| 1181 | tCompactWaveTable table; | 1181 | tWaveTableS table; |
| 1182 | float inc, freq; | 1182 | float inc, freq; |
| 1183 | float phase; | 1183 | float phase; |
| 1184 | float phaseOffset; | 1184 | float phaseOffset; |
| 1185 | int oct; | 1185 | int oct; |
| 1186 | float w; | 1186 | float w; |
| 1187 | float aa; | 1187 | float aa; |
| 1188 | } _tCompactWaveOsc; | 1188 | } _tWaveOscS; |
| 1189 | 1189 | ||
| 1190 | typedef _tCompactWaveOsc* tCompactWaveOsc; | 1190 | typedef _tWaveOscS* tWaveOscS; |
| 1191 | 1191 | ||
| 1192 | void tCompactWaveOsc_init(tCompactWaveOsc* const osc, tCompactWaveTable* const table, LEAF* const leaf); | 1192 | void tWaveOscS_init(tWaveOscS* const osc, tWaveTableS* const table, LEAF* const leaf); |
| 1193 | void tCompactWaveOsc_initToPool(tCompactWaveOsc* const osc, tCompactWaveTable* const table, tMempool* const mempool); | 1193 | void tWaveOscS_initToPool(tWaveOscS* const osc, tWaveTableS* const table, tMempool* const mempool); |
| 1194 | void tCompactWaveOsc_free(tCompactWaveOsc* const osc); | 1194 | void tWaveOscS_free(tWaveOscS* const osc); |
| 1195 | 1195 | ||
| 1196 | float tCompactWaveOsc_tick(tCompactWaveOsc* const osc); | 1196 | float tWaveOscS_tick(tWaveOscS* const osc); |
| 1197 | void tCompactWaveOsc_setFreq(tCompactWaveOsc* const osc, float freq); | 1197 | void tWaveOscS_setFreq(tWaveOscS* const osc, float freq); |
| 1198 | void tCompactWaveOsc_setAntiAliasing(tCompactWaveOsc* const osc, float aa); | 1198 | void tWaveOscS_setAntiAliasing(tWaveOscS* const osc, float aa); |
| 1199 | void tCompactWaveOsc_setPhaseOffset(tCompactWaveOsc* const osc, float phase); | 1199 | void tWaveOscS_setPhaseOffset(tWaveOscS* const osc, float phase); |
| 1200 | 1200 | ||
| 1201 | //============================================================================== | 1201 | //============================================================================== |
| 1202 | 1202 | ||
| 1203 | /*! | 1203 | /*! |
| 1204 | @defgroup tCompactWaveset tCompactWaveSynth | 1204 | @defgroup twavesynths tWaveSynthS |
| 1205 | @ingroup oscillators | 1205 | @ingroup oscillators |
| 1206 | @brief Set of anti-aliased wavetable oscillators that can be faded between. | 1206 | @brief Set of anti-aliased wavetable oscillators that can be faded between. |
| 1207 | @{ | 1207 | @{ |
| 1208 | 1208 | ||
| 1209 | @fn void tCompactWaveSynth_init(tWaveSynth* const osc, const float** tables, int n, int size, float maxFreq, LEAF* const leaf) | 1209 | @fn void tWaveSynthS_init(tWaveSynth* const osc, const float** tables, int n, int size, float maxFreq, LEAF* const leaf) |
| 1210 | @brief Initialize a tCompactWaveSynth to the default mempool of a LEAF instance. | 1210 | @brief Initialize a tWaveSynthS to the default mempool of a LEAF instance. |
| 1211 | @param osc A pointer to the tCompactWaveSynth to initialize. | 1211 | @param osc A pointer to the tWaveSynthS to initialize. |
| 1212 | @param tables An array of pointers to wavetable data. | 1212 | @param tables An array of pointers to wavetable data. |
| 1213 | @param n The number of wavetables. | 1213 | @param n The number of wavetables. |
| 1214 | @param size The number of samples in each of the wavetables. | 1214 | @param size The number of samples in each of the wavetables. |
| 1215 | @param maxFreq The maximum expected frequency of the oscillator. The higher this is, the more memory will be needed. | 1215 | @param maxFreq The maximum expected frequency of the oscillator. The higher this is, the more memory will be needed. |
| 1216 | @param leaf A pointer to the leaf instance. | 1216 | @param leaf A pointer to the leaf instance. |
| 1217 | 1217 | ||
| 1218 | @fn void tCompactWaveSynth_initToPool(tWaveSynth* const osc, const float** tables, int n, int size, float maxFreq, tMempool* const mempool) | 1218 | @fn void tWaveSynthS_initToPool(tWaveSynth* const osc, const float** tables, int n, int size, float maxFreq, tMempool* const mempool) |
| 1219 | @brief Initialize a tCompactWaveSynth to a specified mempool. | 1219 | @brief Initialize a tWaveSynthS to a specified mempool. |
| 1220 | @param osc A pointer to the tCompactWaveTable to initialize. | 1220 | @param osc A pointer to the tWaveTableS to initialize. |
| 1221 | @param tables An array of pointers to wavetable data. | 1221 | @param tables An array of pointers to wavetable data. |
| 1222 | @param n The number of wavetables. | 1222 | @param n The number of wavetables. |
| 1223 | @param size The number of samples in each of the wavetables. | 1223 | @param size The number of samples in each of the wavetables. |
| 1224 | @param maxFreq The maximum expected frequency of the oscillator. The higher this is, the more memory will be needed. | 1224 | @param maxFreq The maximum expected frequency of the oscillator. The higher this is, the more memory will be needed. |
| 1225 | @param mempool A pointer to the tMempool to use. | 1225 | @param mempool A pointer to the tMempool to use. |
| 1226 | 1226 | ||
| 1227 | @fn void tCompactWaveSynth_free (tWaveSynth* const osc) | 1227 | @fn void tWaveSynthS_free (tWaveSynth* const osc) |
| 1228 | @brief Free a tCompactWaveSynth from its mempool. | 1228 | @brief Free a tWaveSynthS from its mempool. |
| 1229 | @param osc A pointer to the tCompactWaveSynth to free. | 1229 | @param osc A pointer to the tWaveSynthS to free. |
| 1230 | 1230 | ||
| 1231 | @fn float tCompactWaveSynth_tick (tWaveSynth* const osc) | 1231 | @fn float tWaveSynthS_tick (tWaveSynth* const osc) |
| 1232 | @brief Tick a tCompactWaveSynth oscillator. | 1232 | @brief Tick a tWaveSynthS oscillator. |
| 1233 | @param osc A pointer to the relevant tCompactWaveSynth. | 1233 | @param osc A pointer to the relevant tWaveSynthS. |
| 1234 | @return The ticked sample as a float from -1 to 1. | 1234 | @return The ticked sample as a float from -1 to 1. |
| 1235 | 1235 | ||
| 1236 | @fn void tCompactWaveSynth_setFreq (tWaveSynth* const osc, float freq) | 1236 | @fn void tWaveSynthS_setFreq (tWaveSynth* const osc, float freq) |
| 1237 | @brief Set the frequency of a tCompactWaveSynth oscillator. | 1237 | @brief Set the frequency of a tWaveSynthS oscillator. |
| 1238 | @param osc A pointer to the relevant tCompactWaveSynth. | 1238 | @param osc A pointer to the relevant tWaveSynthS. |
| 1239 | @param freq The frequency to set the oscillator to. | 1239 | @param freq The frequency to set the oscillator to. |
| 1240 | 1240 | ||
| 1241 | @fn void tCompactWaveSynth_setIndex(tWaveSynth* const osc, float index) | 1241 | @fn void tWaveSynthS_setIndex(tWaveSynth* const osc, float index) |
| 1242 | @brief Set the output index of the wavetable set. | 1242 | @brief Set the output index of the wavetable set. |
| 1243 | @param index The new index from 0.0 to 1.0 as a smooth fade from the first wavetable in the set to the last. | 1243 | @param index The new index from 0.0 to 1.0 as a smooth fade from the first wavetable in the set to the last. |
| 1244 | 1244 | ||
| 1245 | @} */ | 1245 | @} */ |
| 1246 | 1246 | ||
| 1247 | typedef struct _tCompactWaveSynth | 1247 | typedef struct _tWaveSynthS |
| 1248 | { | 1248 | { |
| 1249 | tMempool mempool; | 1249 | tMempool mempool; |
| 1250 | 1250 | ||
| 1251 | tCompactWaveTable* tables; | 1251 | tWaveTableS* tables; |
| 1252 | tCompactWaveOsc** oscs; | 1252 | tWaveOscS** oscs; |
| 1253 | int numTables; | 1253 | int numTables; |
| 1254 | int numVoices; | 1254 | int numVoices; |
| 1255 | float* g; | 1255 | float* g; |
| 1256 | float index; | 1256 | float index; |
| 1257 | float maxFreq; | 1257 | float maxFreq; |
| 1258 | } _tCompactWaveSynth; | 1258 | } _tWaveSynthS; |
| 1259 | 1259 | ||
| 1260 | typedef _tCompactWaveSynth* tCompactWaveSynth; | 1260 | typedef _tWaveSynthS* tWaveSynthS; |
| 1261 | 1261 | ||
| 1262 | void tCompactWaveSynth_init(tCompactWaveSynth* const osc, int numVoices, float** tables, int* sizes, | 1262 | void tWaveSynthS_init(tWaveSynthS* const osc, int numVoices, float** tables, int* sizes, |
| 1263 | int numTables, float maxFreq, LEAF* const leaf); | 1263 | int numTables, float maxFreq, LEAF* const leaf); |
| 1264 | void tCompactWaveSynth_initToPool(tCompactWaveSynth* const osc, int numVoices, float** tables, int* sizes, | 1264 | void tWaveSynthS_initToPool(tWaveSynthS* const osc, int numVoices, float** tables, int* sizes, |
| 1265 | int numTables, float maxFreq, tMempool* const mempool); | 1265 | int numTables, float maxFreq, tMempool* const mempool); |
| 1266 | void tCompactWaveSynth_free(tCompactWaveSynth* const osc); | 1266 | void tWaveSynthS_free(tWaveSynthS* const osc); |
| 1267 | 1267 | ||
| 1268 | float tCompactWaveSynth_tick(tCompactWaveSynth* const osc); | 1268 | float tWaveSynthS_tick(tWaveSynthS* const osc); |
| 1269 | float tCompactWaveSynth_tickVoice(tCompactWaveSynth* const cy, int voice); | 1269 | float tWaveSynthS_tickVoice(tWaveSynthS* const cy, int voice); |
| 1270 | void tCompactWaveSynth_setFreq(tCompactWaveSynth* const osc, int voice, float freq); | 1270 | void tWaveSynthS_setFreq(tWaveSynthS* const osc, int voice, float freq); |
| 1271 | void tCompactWaveSynth_setAntiAliasing(tCompactWaveSynth* const osc, float aa); | 1271 | void tWaveSynthS_setAntiAliasing(tWaveSynthS* const osc, float aa); |
| 1272 | void tCompactWaveSynth_setIndex(tCompactWaveSynth* const osc, float index); | 1272 | void tWaveSynthS_setIndex(tWaveSynthS* const osc, float index); |
| 1273 | void tCompactWaveSynth_setIndexGain(tCompactWaveSynth* const osc, int i, float gain); | 1273 | void tWaveSynthS_setIndexGain(tWaveSynthS* const osc, int i, float gain); |
| 1274 | void tCompactWaveSynth_setIndexPhase(tCompactWaveSynth* const osc, int i, float phase); | 1274 | void tWaveSynthS_setIndexPhase(tWaveSynthS* const osc, int i, float phase); |
| 1275 | // void tCompactWaveSynth_setIndexTable(tCompactWaveSynth* const osc, int i, float* table, int size); | 1275 | // void tWaveSynthS_setIndexTable(tWaveSynthS* const osc, int i, float* table, int size); |
| 1276 | 1276 | ||
| 1277 | #ifdef __cplusplus | 1277 | #ifdef __cplusplus |
| 1278 | } | 1278 | } |
| @@ -391,7 +391,7 @@ extern "C" { · 390 unmodified lines | |||
| 391 | 391 | ||
| 392 | 392 | ||
| 393 | /*! | 393 | /*! |
| 394 | @defgroup tMBSampler tMBSampler | 394 | @defgroup tmbsampler tMBSampler |
| 395 | @ingroup sampling | 395 | @ingroup sampling |
| 396 | @brief Loopable input sampler using minBLEP to remove discontinuities. | 396 | @brief Loopable input sampler using minBLEP to remove discontinuities. |
| 397 | @{ | 397 | @{ |
| @@ -486,165 +486,6 @@ float tADSR_tick(tADSR* const adsrenv) · 485 unmodified lines | |||
| 486 | #endif // LEAF_INCLUDE_ADSR_TABLES | 486 | #endif // LEAF_INCLUDE_ADSR_TABLES |
| 487 | 487 | ||
| 488 | 488 | ||
| 489 | |||
| 490 | /* ADSR 2*/ | ||
| 491 | //This one is adapted from the VCV Rack code | ||
| 492 | //-JS | ||
| 493 | |||
| 494 | |||
| 495 | |||
| 496 | const float ADSR2_MIN_TIME = 1e-3f; | ||
| 497 | const float ADSR2_INV_MIN_TIME = 1000.0f; | ||
| 498 | const float ADSR2_MAX_TIME = 10.f; | ||
| 499 | const float ADSR2_LAMBDA_BASE = 10000.0f; | ||
| 500 | |||
| 501 | |||
| 502 | void tADSR2_init(tADSR2* const adsrenv, float attack, float decay, float sustain, float release, LEAF* const leaf) | ||
| 503 | { | ||
| 504 | tADSR2_initToPool(adsrenv, attack, decay, sustain, release, &leaf->mempool); | ||
| 505 | } | ||
| 506 | |||
| 507 | void tADSR2_initToPool (tADSR2* const adsrenv, float attack, float decay, float sustain, float release, tMempool* const mp) | ||
| 508 | { | ||
| 509 | _tMempool* m = *mp; | ||
| 510 | _tADSR2* adsr = *adsrenv = (_tADSR2*) mpool_alloc(sizeof(_tADSR2), m); | ||
| 511 | adsr->mempool = m; | ||
| 512 | |||
| 513 | LEAF* leaf = adsr->mempool->leaf; | ||
| 514 | |||
| 515 | adsr->sampleRateInMs = leaf->sampleRate * 0.001f; | ||
| 516 | adsr->attack = LEAF_clip(0.0f, attack * 0.001f, 1.0f); | ||
| 517 | adsr->attackLambda = powf(ADSR2_LAMBDA_BASE, -adsr->attack) * ADSR2_INV_MIN_TIME; | ||
| 518 | |||
| 519 | |||
| 520 | adsr->decay = LEAF_clip(0.0f, decay * 0.001f, 1.0f); | ||
| 521 | adsr->decayLambda = powf(ADSR2_LAMBDA_BASE, -adsr->decay) * ADSR2_INV_MIN_TIME; | ||
| 522 | |||
| 523 | |||
| 524 | adsr->sustain= sustain; | ||
| 525 | |||
| 526 | |||
| 527 | adsr->release = LEAF_clip(0.0f, release * 0.001f, 1.0f); | ||
| 528 | adsr->releaseLambda = powf(ADSR2_LAMBDA_BASE, -adsr->release) * ADSR2_INV_MIN_TIME; | ||
| 529 | |||
| 530 | adsr->attacking = 0; | ||
| 531 | adsr->gate = 0; | ||
| 532 | adsr->gain = 1.0f; | ||
| 533 | adsr->targetGainSquared = 1.0f; | ||
| 534 | adsr->factor = 0.01f; | ||
| 535 | adsr->oneMinusFactor = 0.99f; | ||
| 536 | adsr->env = 0.0f; | ||
| 537 | adsr->leakFactor = 1.0f; | ||
| 538 | } | ||
| 539 | |||
| 540 | void tADSR2_free (tADSR2* const adsrenv) | ||
| 541 | { | ||
| 542 | _tADSR2* adsr = *adsrenv; | ||
| 543 | mpool_free((char*)adsr, adsr->mempool); | ||
| 544 | } | ||
| 545 | |||
| 546 | void tADSR2_setAttack(tADSR2* const adsrenv, float attack) | ||
| 547 | { | ||
| 548 | _tADSR2* adsr = *adsrenv; | ||
| 549 | adsr->attack = LEAF_clip(0.0f, attack * 0.001f, 1.0f); | ||
| 550 | adsr->attackLambda = fastPowf(ADSR2_LAMBDA_BASE, -adsr->attack) * ADSR2_INV_MIN_TIME; | ||
| 551 | |||
| 552 | } | ||
| 553 | |||
| 554 | void tADSR2_setDecay(tADSR2* const adsrenv, float decay) | ||
| 555 | { | ||
| 556 | _tADSR2* adsr = *adsrenv; | ||
| 557 | adsr->decay = LEAF_clip(0.0f, decay * 0.001f, 1.0f); | ||
| 558 | adsr->decayLambda = fastPowf(ADSR2_LAMBDA_BASE, -adsr->decay) * ADSR2_INV_MIN_TIME; | ||
| 559 | |||
| 560 | } | ||
| 561 | |||
| 562 | void tADSR2_setSustain(tADSR2* const adsrenv, float sustain) | ||
| 563 | { | ||
| 564 | _tADSR2* adsr = *adsrenv; | ||
| 565 | adsr->sustain = sustain; | ||
| 566 | |||
| 567 | if (adsr->gate) | ||
| 568 | { | ||
| 569 | if (adsr->attacking == 0) | ||
| 570 | { | ||
| 571 | adsr->envTarget = sustain; | ||
| 572 | } | ||
| 573 | } | ||
| 574 | } | ||
| 575 | |||
| 576 | void tADSR2_setRelease(tADSR2* const adsrenv, float release) | ||
| 577 | { | ||
| 578 | _tADSR2* adsr = *adsrenv; | ||
| 579 | adsr->release = LEAF_clip(0.0f, release * 0.001f, 1.0f); | ||
| 580 | adsr->releaseLambda = fastPowf(ADSR2_LAMBDA_BASE, -adsr->release) * ADSR2_INV_MIN_TIME; | ||
| 581 | } | ||
| 582 | |||
| 583 | // 0.999999 is slow leak, 0.9 is fast leak | ||
| 584 | void tADSR2_setLeakFactor(tADSR2* const adsrenv, float leakFactor) | ||
| 585 | { | ||
| 586 | _tADSR2* adsr = *adsrenv; | ||
| 587 | |||
| 588 | adsr->leakFactor = leakFactor; | ||
| 589 | } | ||
| 590 | |||
| 591 | void tADSR2_on(tADSR2* const adsrenv, float velocity) | ||
| 592 | { | ||
| 593 | _tADSR2* adsr = *adsrenv; | ||
| 594 | adsr->targetGainSquared = velocity * velocity; | ||
| 595 | adsr->envTarget = 1.2f; | ||
| 596 | adsr->leakGain = 1.0f; | ||
| 597 | adsr->gate = 1; | ||
| 598 | adsr->attacking = 1; | ||
| 599 | } | ||
| 600 | |||
| 601 | void tADSR2_off(tADSR2* const adsrenv) | ||
| 602 | { | ||
| 603 | _tADSR2* adsr = *adsrenv; | ||
| 604 | adsr->gate = 0; | ||
| 605 | adsr->envTarget = 0.0f; | ||
| 606 | } | ||
| 607 | |||
| 608 | float tADSR2_tick(tADSR2* const adsrenv) | ||
| 609 | { | ||
| 610 | _tADSR2* adsr = *adsrenv; | ||
| 611 | LEAF* leaf = adsr->mempool->leaf; | ||
| 612 | |||
| 613 | float lambda; | ||
| 614 | |||
| 615 | if (adsr->gate) | ||
| 616 | { | ||
| 617 | if (adsr->attacking) | ||
| 618 | { | ||
| 619 | lambda = adsr->attackLambda; | ||
| 620 | } | ||
| 621 | else | ||
| 622 | { | ||
| 623 | lambda = adsr->decayLambda; | ||
| 624 | } | ||
| 625 | } | ||
| 626 | else | ||
| 627 | { | ||
| 628 | lambda = adsr->releaseLambda; | ||
| 629 | } | ||
| 630 | |||
| 631 | |||
| 632 | // Adjust env | ||
| 633 | adsr->env += (adsr->envTarget - adsr->env) * lambda * leaf->invSampleRate; | ||
| 634 | |||
| 635 | // Turn off attacking state if envelope is HIGH | ||
| 636 | if (adsr->env >= 1.0f) | ||
| 637 | { | ||
| 638 | adsr->attacking = 0; | ||
| 639 | adsr->envTarget = adsr->sustain; | ||
| 640 | } | ||
| 641 | |||
| 642 | //smooth the gain value -- this is not ideal, a retrigger while the envelope is still going with a new gain will cause a jump, although it will be smoothed quickly. Maybe doing the math so the range is computed based on the gain rather than 0.->1. is preferable? But that's harder to get the exponential curve right without a lookup. | ||
| 643 | adsr->gain = ((adsr->factor*adsr->targetGainSquared)+(adsr->oneMinusFactor*adsr->gain)); | ||
| 644 | adsr->leakGain *= adsr->leakFactor; | ||
| 645 | return adsr->env * adsr->gain * adsr->leakGain; | ||
| 646 | } | ||
| 647 | |||
| 648 | /* ADSR 3*/ | 489 | /* ADSR 3*/ |
| 649 | //This one doesn't use any lookup table - by Nigel Redmon from his blog. Thanks, Nigel! | 490 | //This one doesn't use any lookup table - by Nigel Redmon from his blog. Thanks, Nigel! |
| 650 | //-JS | 491 | //-JS |
| @@ -655,15 +496,15 @@ float calcADSR3Coef(float rate, float targetRatio) · 4 unmodified lines | |||
| 655 | } | 496 | } |
| 656 | 497 | ||
| 657 | 498 | ||
| 658 | void tADSR3_init(tADSR3* const adsrenv, float attack, float decay, float sustain, float release, LEAF* const leaf) | 499 | void tADSRS_init(tADSRS* const adsrenv, float attack, float decay, float sustain, float release, LEAF* const leaf) |
| 659 | { | 500 | { |
| 660 | tADSR3_initToPool(adsrenv, attack, decay, sustain, release, &leaf->mempool); | 501 | tADSRS_initToPool(adsrenv, attack, decay, sustain, release, &leaf->mempool); |
| 661 | } | 502 | } |
| 662 | 503 | ||
| 663 | void tADSR3_initToPool (tADSR3* const adsrenv, float attack, float decay, float sustain, float release, tMempool* const mp) | 504 | void tADSRS_initToPool (tADSRS* const adsrenv, float attack, float decay, float sustain, float release, tMempool* const mp) |
| 664 | { | 505 | { |
| 665 | _tMempool* m = *mp; | 506 | _tMempool* m = *mp; |
| 666 | _tADSR3* adsr = *adsrenv = (_tADSR3*) mpool_alloc(sizeof(_tADSR3), m); | 507 | _tADSRS* adsr = *adsrenv = (_tADSRS*) mpool_alloc(sizeof(_tADSRS), m); |
| 667 | adsr->mempool = m; | 508 | adsr->mempool = m; |
| 668 | 509 | ||
| 669 | LEAF* leaf = adsr->mempool->leaf; | 510 | LEAF* leaf = adsr->mempool->leaf; |
| @@ -695,41 +536,41 @@ void tADSR3_initToPool (tADSR3* const adsrenv, float attack, float decay, · 25 unmodified lines | |||
| 695 | adsr->leakFactor = 1.0f; | 536 | adsr->leakFactor = 1.0f; |
| 696 | } | 537 | } |
| 697 | 538 | ||
| 698 | void tADSR3_free (tADSR3* const adsrenv) | 539 | void tADSRS_free (tADSRS* const adsrenv) |
| 699 | { | 540 | { |
| 700 | _tADSR3* adsr = *adsrenv; | 541 | _tADSRS* adsr = *adsrenv; |
| 701 | mpool_free((char*)adsr, adsr->mempool); | 542 | mpool_free((char*)adsr, adsr->mempool); |
| 702 | } | 543 | } |
| 703 | 544 | ||
| 704 | void tADSR3_setAttack(tADSR3* const adsrenv, float attack) | 545 | void tADSRS_setAttack(tADSRS* const adsrenv, float attack) |
| 705 | { | 546 | { |
| 706 | _tADSR3* adsr = *adsrenv; | 547 | _tADSRS* adsr = *adsrenv; |
| 707 | 548 | ||
| 708 | adsr->attackRate = attack * adsr->sampleRateInMs; | 549 | adsr->attackRate = attack * adsr->sampleRateInMs; |
| 709 | adsr->attackCoef = calcADSR3Coef(adsr->attackRate, adsr->targetRatioA); | 550 | adsr->attackCoef = calcADSR3Coef(adsr->attackRate, adsr->targetRatioA); |
| 710 | adsr->attackBase = (1.0f + adsr->targetRatioA) * (1.0f - adsr->attackCoef); | 551 | adsr->attackBase = (1.0f + adsr->targetRatioA) * (1.0f - adsr->attackCoef); |
| 711 | } | 552 | } |
| 712 | 553 | ||
| 713 | void tADSR3_setDecay(tADSR3* const adsrenv, float decay) | 554 | void tADSRS_setDecay(tADSRS* const adsrenv, float decay) |
| 714 | { | 555 | { |
| 715 | _tADSR3* adsr = *adsrenv; | 556 | _tADSRS* adsr = *adsrenv; |
| 716 | 557 | ||
| 717 | adsr->decayRate = decay * adsr->sampleRateInMs; | 558 | adsr->decayRate = decay * adsr->sampleRateInMs; |
| 718 | adsr->decayCoef = calcADSR3Coef(adsr->decayRate,adsr-> targetRatioDR); | 559 | adsr->decayCoef = calcADSR3Coef(adsr->decayRate,adsr-> targetRatioDR); |
| 719 | adsr->decayBase = (adsr->sustainLevel - adsr->targetRatioDR) * (1.0f - adsr->decayCoef); | 560 | adsr->decayBase = (adsr->sustainLevel - adsr->targetRatioDR) * (1.0f - adsr->decayCoef); |
| 720 | } | 561 | } |
| 721 | 562 | ||
| 722 | void tADSR3_setSustain(tADSR3* const adsrenv, float sustain) | 563 | void tADSRS_setSustain(tADSRS* const adsrenv, float sustain) |
| 723 | { | 564 | { |
| 724 | _tADSR3* adsr = *adsrenv; | 565 | _tADSRS* adsr = *adsrenv; |
| 725 | 566 | ||
| 726 | adsr->sustainLevel = sustain; | 567 | adsr->sustainLevel = sustain; |
| 727 | adsr->decayBase = (adsr->sustainLevel - adsr->targetRatioDR) * (1.0f - adsr->decayCoef); | 568 | adsr->decayBase = (adsr->sustainLevel - adsr->targetRatioDR) * (1.0f - adsr->decayCoef); |
| 728 | } | 569 | } |
| 729 | 570 | ||
| 730 | void tADSR3_setRelease(tADSR3* const adsrenv, float release) | 571 | void tADSRS_setRelease(tADSRS* const adsrenv, float release) |
| 731 | { | 572 | { |
| 732 | _tADSR3* adsr = *adsrenv; | 573 | _tADSRS* adsr = *adsrenv; |
| 733 | 574 | ||
| 734 | adsr->releaseRate = release * adsr->sampleRateInMs; | 575 | adsr->releaseRate = release * adsr->sampleRateInMs; |
| 735 | adsr->releaseCoef = calcADSR3Coef(adsr->releaseRate, (float)adsr->targetRatioDR); | 576 | adsr->releaseCoef = calcADSR3Coef(adsr->releaseRate, (float)adsr->targetRatioDR); |
| @@ -737,23 +578,23 @@ void tADSR3_setRelease(tADSR3* const adsrenv, float release) · 1 unmodified line | |||
| 737 | } | 578 | } |
| 738 | 579 | ||
| 739 | // 0.999999 is slow leak, 0.9 is fast leak | 580 | // 0.999999 is slow leak, 0.9 is fast leak |
| 740 | void tADSR3_setLeakFactor(tADSR3* const adsrenv, float leakFactor) | 581 | void tADSRS_setLeakFactor(tADSRS* const adsrenv, float leakFactor) |
| 741 | { | 582 | { |
| 742 | _tADSR3* adsr = *adsrenv; | 583 | _tADSRS* adsr = *adsrenv; |
| 743 | 584 | ||
| 744 | adsr->leakFactor = leakFactor; | 585 | adsr->leakFactor = leakFactor; |
| 745 | } | 586 | } |
| 746 | 587 | ||
| 747 | void tADSR3_on(tADSR3* const adsrenv, float velocity) | 588 | void tADSRS_on(tADSRS* const adsrenv, float velocity) |
| 748 | { | 589 | { |
| 749 | _tADSR3* adsr = *adsrenv; | 590 | _tADSRS* adsr = *adsrenv; |
| 750 | adsr->state = env_attack; | 591 | adsr->state = env_attack; |
| 751 | adsr->targetGainSquared = velocity * velocity; | 592 | adsr->targetGainSquared = velocity * velocity; |
| 752 | } | 593 | } |
| 753 | 594 | ||
| 754 | void tADSR3_off(tADSR3* const adsrenv) | 595 | void tADSRS_off(tADSRS* const adsrenv) |
| 755 | { | 596 | { |
| 756 | _tADSR3* adsr = *adsrenv; | 597 | _tADSRS* adsr = *adsrenv; |
| 757 | 598 | ||
| 758 | if (adsr->state != env_idle) | 599 | if (adsr->state != env_idle) |
| 759 | { | 600 | { |
| @@ -761,9 +602,9 @@ void tADSR3_off(tADSR3* const adsrenv) · 1 unmodified line | |||
| 761 | } | 602 | } |
| 762 | } | 603 | } |
| 763 | 604 | ||
| 764 | float tADSR3_tick(tADSR3* const adsrenv) | 605 | float tADSRS_tick(tADSRS* const adsrenv) |
| 765 | { | 606 | { |
| 766 | _tADSR3* adsr = *adsrenv; | 607 | _tADSRS* adsr = *adsrenv; |
| 767 | 608 | ||
| 768 | 609 | ||
| 769 | switch (adsr->state) { | 610 | switch (adsr->state) { |
| @@ -803,17 +644,17 @@ float tADSR3_tick(tADSR3* const adsrenv) · 33 unmodified lines | |||
| 803 | 644 | ||
| 804 | /* ADSR 4 */ // new version of our original table-based ADSR but with the table passed in by the user | 645 | /* ADSR 4 */ // new version of our original table-based ADSR but with the table passed in by the user |
| 805 | // use this if the size of the big ADSR tables is too much. | 646 | // use this if the size of the big ADSR tables is too much. |
| 806 | void tADSR4_init (tADSR4* const adsrenv, float attack, float decay, float sustain, float release, float* expBuffer, int bufferSize, LEAF* const leaf) | 647 | void tADSRT_init (tADSRT* const adsrenv, float attack, float decay, float sustain, float release, float* expBuffer, int bufferSize, LEAF* const leaf) |
| 807 | { | 648 | { |
| 808 | tADSR4_initToPool (adsrenv, attack, decay, sustain, release, expBuffer, bufferSize, &leaf->mempool); | 649 | tADSRT_initToPool (adsrenv, attack, decay, sustain, release, expBuffer, bufferSize, &leaf->mempool); |
| 809 | } | 650 | } |
| 810 | 651 | ||
| 811 | //initialize with an exponential function that decays -- i.e. a call to LEAF_generate_exp(expBuffer, 0.001f, 0.0f, 1.0f, -0.0008f, EXP_BUFFER_SIZE); | 652 | //initialize with an exponential function that decays -- i.e. a call to LEAF_generate_exp(expBuffer, 0.001f, 0.0f, 1.0f, -0.0008f, EXP_BUFFER_SIZE); |
| 812 | //times are in ms | 653 | //times are in ms |
| 813 | void tADSR4_initToPool (tADSR4* const adsrenv, float attack, float decay, float sustain, float release, float* expBuffer, int bufferSize, tMempool* const mp) | 654 | void tADSRT_initToPool (tADSRT* const adsrenv, float attack, float decay, float sustain, float release, float* expBuffer, int bufferSize, tMempool* const mp) |
| 814 | { | 655 | { |
| 815 | _tMempool* m = *mp; | 656 | _tMempool* m = *mp; |
| 816 | _tADSR4* adsr = *adsrenv = (_tADSR4*) mpool_alloc(sizeof(_tADSR4), m); | 657 | _tADSRT* adsr = *adsrenv = (_tADSRT*) mpool_alloc(sizeof(_tADSRT), m); |
| 817 | adsr->mempool = m; | 658 | adsr->mempool = m; |
| 818 | 659 | ||
| 819 | LEAF* leaf = adsr->mempool->leaf; | 660 | LEAF* leaf = adsr->mempool->leaf; |
| @@ -852,15 +693,15 @@ void tADSR4_initToPool (tADSR4* const adsrenv, float attack, float decay, · 32 unmodified lines | |||
| 852 | adsr->leakFactor = 1.0f; | 693 | adsr->leakFactor = 1.0f; |
| 853 | } | 694 | } |
| 854 | 695 | ||
| 855 | void tADSR4_free (tADSR4* const adsrenv) | 696 | void tADSRT_free (tADSRT* const adsrenv) |
| 856 | { | 697 | { |
| 857 | _tADSR4* adsr = *adsrenv; | 698 | _tADSRT* adsr = *adsrenv; |
| 858 | mpool_free((char*)adsr, adsr->mempool); | 699 | mpool_free((char*)adsr, adsr->mempool); |
| 859 | } | 700 | } |
| 860 | 701 | ||
| 861 | void tADSR4_setAttack(tADSR4* const adsrenv, float attack) | 702 | void tADSRT_setAttack(tADSRT* const adsrenv, float attack) |
| 862 | { | 703 | { |
| 863 | _tADSR4* adsr = *adsrenv; | 704 | _tADSRT* adsr = *adsrenv; |
| 864 | 705 | ||
| 865 | if (attack < 0.0f) | 706 | if (attack < 0.0f) |
| 866 | { | 707 | { |
| @@ -870,9 +711,9 @@ void tADSR4_setAttack(tADSR4* const adsrenv, float attack) · 3 unmodified lines | |||
| 870 | adsr->attackInc = adsr->bufferSizeDividedBySampleRateInMs / attack; | 711 | adsr->attackInc = adsr->bufferSizeDividedBySampleRateInMs / attack; |
| 871 | } | 712 | } |
| 872 | 713 | ||
| 873 | void tADSR4_setDecay(tADSR4* const adsrenv, float decay) | 714 | void tADSRT_setDecay(tADSRT* const adsrenv, float decay) |
| 874 | { | 715 | { |
| 875 | _tADSR4* adsr = *adsrenv; | 716 | _tADSRT* adsr = *adsrenv; |
| 876 | 717 | ||
| 877 | if (decay < 0.0f) | 718 | if (decay < 0.0f) |
| 878 | { | 719 | { |
| @@ -881,18 +722,18 @@ void tADSR4_setDecay(tADSR4* const adsrenv, float decay) · 2 unmodified lines | |||
| 881 | adsr->decayInc = adsr->bufferSizeDividedBySampleRateInMs / decay; | 722 | adsr->decayInc = adsr->bufferSizeDividedBySampleRateInMs / decay; |
| 882 | } | 723 | } |
| 883 | 724 | ||
| 884 | void tADSR4_setSustain(tADSR4* const adsrenv, float sustain) | 725 | void tADSRT_setSustain(tADSRT* const adsrenv, float sustain) |
| 885 | { | 726 | { |
| 886 | _tADSR4* adsr = *adsrenv; | 727 | _tADSRT* adsr = *adsrenv; |
| 887 | 728 | ||
| 888 | if (sustain > 1.0f) adsr->sustain = 1.0f; | 729 | if (sustain > 1.0f) adsr->sustain = 1.0f; |
| 889 | else if (sustain < 0.0f) adsr->sustain = 0.0f; | 730 | else if (sustain < 0.0f) adsr->sustain = 0.0f; |
| 890 | else adsr->sustain = sustain; | 731 | else adsr->sustain = sustain; |
| 891 | } | 732 | } |
| 892 | 733 | ||
| 893 | void tADSR4_setRelease(tADSR4* const adsrenv, float release) | 734 | void tADSRT_setRelease(tADSRT* const adsrenv, float release) |
| 894 | { | 735 | { |
| 895 | _tADSR4* adsr = *adsrenv; | 736 | _tADSRT* adsr = *adsrenv; |
| 896 | 737 | ||
| 897 | if (release < 0.0f) | 738 | if (release < 0.0f) |
| 898 | { | 739 | { |
| @@ -902,17 +743,17 @@ void tADSR4_setRelease(tADSR4* const adsrenv, float release) · 3 unmodified lines | |||
| 902 | } | 743 | } |
| 903 | 744 | ||
| 904 | // 0.999999 is slow leak, 0.9 is fast leak | 745 | // 0.999999 is slow leak, 0.9 is fast leak |
| 905 | void tADSR4_setLeakFactor(tADSR4* const adsrenv, float leakFactor) | 746 | void tADSRT_setLeakFactor(tADSRT* const adsrenv, float leakFactor) |
| 906 | { | 747 | { |
| 907 | _tADSR4* adsr = *adsrenv; | 748 | _tADSRT* adsr = *adsrenv; |
| 908 | 749 | ||
| 909 | 750 | ||
| 910 | adsr->leakFactor = leakFactor; | 751 | adsr->leakFactor = leakFactor; |
| 911 | } | 752 | } |
| 912 | 753 | ||
| 913 | void tADSR4_on(tADSR4* const adsrenv, float velocity) | 754 | void tADSRT_on(tADSRT* const adsrenv, float velocity) |
| 914 | { | 755 | { |
| 915 | _tADSR4* adsr = *adsrenv; | 756 | _tADSRT* adsr = *adsrenv; |
| 916 | 757 | ||
| 917 | if (adsr->whichStage != env_idle) // In case ADSR retriggered while it is still happening. | 758 | if (adsr->whichStage != env_idle) // In case ADSR retriggered while it is still happening. |
| 918 | { | 759 | { |
| @@ -931,9 +772,9 @@ void tADSR4_on(tADSR4* const adsrenv, float velocity) · 12 unmodified lines | |||
| 931 | adsr->gain = velocity; | 772 | adsr->gain = velocity; |
| 932 | } | 773 | } |
| 933 | 774 | ||
| 934 | void tADSR4_off(tADSR4* const adsrenv) | 775 | void tADSRT_off(tADSRT* const adsrenv) |
| 935 | { | 776 | { |
| 936 | _tADSR4* adsr = *adsrenv; | 777 | _tADSRT* adsr = *adsrenv; |
| 937 | 778 | ||
| 938 | if (adsr->whichStage == env_idle) | 779 | if (adsr->whichStage == env_idle) |
| 939 | { | 780 | { |
| @@ -946,9 +787,9 @@ void tADSR4_off(tADSR4* const adsrenv) · 6 unmodified lines | |||
| 946 | } | 787 | } |
| 947 | } | 788 | } |
| 948 | 789 | ||
| 949 | float tADSR4_tick(tADSR4* const adsrenv) | 790 | float tADSRT_tick(tADSRT* const adsrenv) |
| 950 | { | 791 | { |
| 951 | _tADSR4* adsr = *adsrenv; | 792 | _tADSRT* adsr = *adsrenv; |
| 952 | 793 | ||
| 953 | switch (adsr->whichStage) | 794 | switch (adsr->whichStage) |
| 954 | { | 795 | { |
| @@ -1071,9 +912,9 @@ float tADSR4_tick(tADSR4* const adsrenv) · 116 unmodified lines | |||
| 1071 | return adsr->next; | 912 | return adsr->next; |
| 1072 | } | 913 | } |
| 1073 | 914 | ||
| 1074 | float tADSR4_tickNoInterp(tADSR4* const adsrenv) | 915 | float tADSRT_tickNoInterp(tADSRT* const adsrenv) |
| 1075 | { | 916 | { |
| 1076 | _tADSR4* adsr = *adsrenv; | 917 | _tADSRT* adsr = *adsrenv; |
| 1077 | 918 | ||
| 1078 | switch (adsr->whichStage) | 919 | switch (adsr->whichStage) |
| 1079 | { | 920 | { |
| @@ -2055,15 +2055,15 @@ void tWaveSynth_setIndexPhase(tWaveSynth* const cy, int i, float phase) · 2054 unmodified lines | |||
| 2055 | //======================================================================================= | 2055 | //======================================================================================= |
| 2056 | //======================================================================================= | 2056 | //======================================================================================= |
| 2057 | 2057 | ||
| 2058 | void tCompactWaveTable_init(tCompactWaveTable* const cy, float* table, int size, float maxFreq, LEAF* const leaf) | 2058 | void tWaveTableS_init(tWaveTableS* const cy, float* table, int size, float maxFreq, LEAF* const leaf) |
| 2059 | { | 2059 | { |
| 2060 | tCompactWaveTable_initToPool(cy, table, size, maxFreq, &leaf->mempool); | 2060 | tWaveTableS_initToPool(cy, table, size, maxFreq, &leaf->mempool); |
| 2061 | } | 2061 | } |
| 2062 | 2062 | ||
| 2063 | void tCompactWaveTable_initToPool(tCompactWaveTable* const cy, float* table, int size, float maxFreq, tMempool* const mp) | 2063 | void tWaveTableS_initToPool(tWaveTableS* const cy, float* table, int size, float maxFreq, tMempool* const mp) |
| 2064 | { | 2064 | { |
| 2065 | _tMempool* m = *mp; | 2065 | _tMempool* m = *mp; |
| 2066 | _tCompactWaveTable* c = *cy = (_tCompactWaveTable*) mpool_alloc(sizeof(_tCompactWaveTable), m); | 2066 | _tWaveTableS* c = *cy = (_tWaveTableS*) mpool_alloc(sizeof(_tWaveTableS), m); |
| 2067 | c->mempool = m; | 2067 | c->mempool = m; |
| 2068 | 2068 | ||
| 2069 | // Determine base frequency | 2069 | // Determine base frequency |
| @@ -2117,9 +2117,9 @@ void tCompactWaveTable_initToPool(tCompactWaveTable* const cy, float* table, int · 47 unmodified lines | |||
| 2117 | tButterworth_free(&c->bl); | 2117 | tButterworth_free(&c->bl); |
| 2118 | } | 2118 | } |
| 2119 | 2119 | ||
| 2120 | void tCompactWaveTable_free(tCompactWaveTable* const cy) | 2120 | void tWaveTableS_free(tWaveTableS* const cy) |
| 2121 | { | 2121 | { |
| 2122 | _tCompactWaveTable* c = *cy; | 2122 | _tWaveTableS* c = *cy; |
| 2123 | 2123 | ||
| 2124 | for (int t = 0; t < c->numTables; ++t) | 2124 | for (int t = 0; t < c->numTables; ++t) |
| 2125 | { | 2125 | { |
| @@ -2133,15 +2133,15 @@ void tCompactWaveTable_free(tCompactWaveTable* const cy) · 7 unmodified lines | |||
| 2133 | //================================================================================================ | 2133 | //================================================================================================ |
| 2134 | //================================================================================================ | 2134 | //================================================================================================ |
| 2135 | 2135 | ||
| 2136 | void tCompactWaveOsc_init(tCompactWaveOsc* const cy, tCompactWaveTable* const table, LEAF* const leaf) | 2136 | void tWaveOscS_init(tWaveOscS* const cy, tWaveTableS* const table, LEAF* const leaf) |
| 2137 | { | 2137 | { |
| 2138 | tCompactWaveOsc_initToPool(cy, table, &leaf->mempool); | 2138 | tWaveOscS_initToPool(cy, table, &leaf->mempool); |
| 2139 | } | 2139 | } |
| 2140 | 2140 | ||
| 2141 | void tCompactWaveOsc_initToPool(tCompactWaveOsc* const cy, tCompactWaveTable* const table, tMempool* const mp) | 2141 | void tWaveOscS_initToPool(tWaveOscS* const cy, tWaveTableS* const table, tMempool* const mp) |
| 2142 | { | 2142 | { |
| 2143 | _tMempool* m = *mp; | 2143 | _tMempool* m = *mp; |
| 2144 | _tCompactWaveOsc* c = *cy = (_tCompactWaveOsc*) mpool_alloc(sizeof(_tCompactWaveOsc), m); | 2144 | _tWaveOscS* c = *cy = (_tWaveOscS*) mpool_alloc(sizeof(_tWaveOscS), m); |
| 2145 | c->mempool = m; | 2145 | c->mempool = m; |
| 2146 | 2146 | ||
| 2147 | c->inc = 0.0f; | 2147 | c->inc = 0.0f; |
| @@ -2149,18 +2149,18 @@ void tCompactWaveOsc_initToPool(tCompactWaveOsc* const cy, tCompactWaveTable* co · 1 unmodified line | |||
| 2149 | c->phaseOffset = 0.0f; | 2149 | c->phaseOffset = 0.0f; |
| 2150 | c->aa = 0.5f; | 2150 | c->aa = 0.5f; |
| 2151 | 2151 | ||
| 2152 | tCompactWaveOsc_setFreq(cy, 220); | 2152 | tWaveOscS_setFreq(cy, 220); |
| 2153 | } | 2153 | } |
| 2154 | 2154 | ||
| 2155 | void tCompactWaveOsc_free(tCompactWaveOsc* const cy) | 2155 | void tWaveOscS_free(tWaveOscS* const cy) |
| 2156 | { | 2156 | { |
| 2157 | _tCompactWaveOsc* c = *cy; | 2157 | _tWaveOscS* c = *cy; |
| 2158 | mpool_free((char*)c, c->mempool); | 2158 | mpool_free((char*)c, c->mempool); |
| 2159 | } | 2159 | } |
| 2160 | 2160 | ||
| 2161 | float tCompactWaveOsc_tick(tCompactWaveOsc* const cy) | 2161 | float tWaveOscS_tick(tWaveOscS* const cy) |
| 2162 | { | 2162 | { |
| 2163 | _tCompactWaveOsc* c = *cy; | 2163 | _tWaveOscS* c = *cy; |
| 2164 | 2164 | ||
| 2165 | float temp; | 2165 | float temp; |
| 2166 | int idx; | 2166 | int idx; |
| @@ -2198,9 +2198,9 @@ float tCompactWaveOsc_tick(tCompactWaveOsc* const cy) · 31 unmodified lines | |||
| 2198 | return oct0 + (oct1 - oct0) * c->w; | 2198 | return oct0 + (oct1 - oct0) * c->w; |
| 2199 | } | 2199 | } |
| 2200 | 2200 | ||
| 2201 | void tCompactWaveOsc_setFreq(tCompactWaveOsc* const cy, float freq) | 2201 | void tWaveOscS_setFreq(tWaveOscS* const cy, float freq) |
| 2202 | { | 2202 | { |
| 2203 | _tCompactWaveOsc* c = *cy; | 2203 | _tWaveOscS* c = *cy; |
| 2204 | 2204 | ||
| 2205 | LEAF* leaf = c->mempool->leaf; | 2205 | LEAF* leaf = c->mempool->leaf; |
| 2206 | 2206 | ||
| @@ -2220,33 +2220,33 @@ void tCompactWaveOsc_setFreq(tCompactWaveOsc* const cy, float freq) · 13 unmodified lines | |||
| 2220 | if (c->oct >= c->table->numTables - 1) c->oct = c->table->numTables - 2; | 2220 | if (c->oct >= c->table->numTables - 1) c->oct = c->table->numTables - 2; |
| 2221 | } | 2221 | } |
| 2222 | 2222 | ||
| 2223 | void tCompactWaveOsc_setAntiAliasing(tCompactWaveOsc* const cy, float aa) | 2223 | void tWaveOscS_setAntiAliasing(tWaveOscS* const cy, float aa) |
| 2224 | { | 2224 | { |
| 2225 | _tCompactWaveOsc* c = *cy; | 2225 | _tWaveOscS* c = *cy; |
| 2226 | c->aa = aa; | 2226 | c->aa = aa; |
| 2227 | tCompactWaveOsc_setFreq(cy, c->freq); | 2227 | tWaveOscS_setFreq(cy, c->freq); |
| 2228 | } | 2228 | } |
| 2229 | 2229 | ||
| 2230 | void tCompactWaveOsc_setPhaseOffset(tCompactWaveOsc* const cy, float phase) | 2230 | void tWaveOscS_setPhaseOffset(tWaveOscS* const cy, float phase) |
| 2231 | { | 2231 | { |
| 2232 | _tCompactWaveOsc* c = *cy; | 2232 | _tWaveOscS* c = *cy; |
| 2233 | c->phaseOffset = phase - (int)phase; | 2233 | c->phaseOffset = phase - (int)phase; |
| 2234 | } | 2234 | } |
| 2235 | 2235 | ||
| 2236 | //================================================================================================ | 2236 | //================================================================================================ |
| 2237 | //================================================================================================ | 2237 | //================================================================================================ |
| 2238 | 2238 | ||
| 2239 | void tCompactWaveSynth_init(tCompactWaveSynth* const cy, int numVoices, float** tables, int* sizes, | 2239 | void tWaveSynthS_init(tWaveSynthS* const cy, int numVoices, float** tables, int* sizes, |
| 2240 | int numTables, float maxFreq, LEAF* const leaf) | 2240 | int numTables, float maxFreq, LEAF* const leaf) |
| 2241 | { | 2241 | { |
| 2242 | tCompactWaveSynth_initToPool(cy, numVoices, tables, sizes, numTables, maxFreq, &leaf->mempool); | 2242 | tWaveSynthS_initToPool(cy, numVoices, tables, sizes, numTables, maxFreq, &leaf->mempool); |
| 2243 | } | 2243 | } |
| 2244 | 2244 | ||
| 2245 | void tCompactWaveSynth_initToPool(tCompactWaveSynth* const cy, int numVoices, float** tables, int* sizes, | 2245 | void tWaveSynthS_initToPool(tWaveSynthS* const cy, int numVoices, float** tables, int* sizes, |
| 2246 | int numTables, float maxFreq, tMempool* const mp) | 2246 | int numTables, float maxFreq, tMempool* const mp) |
| 2247 | { | 2247 | { |
| 2248 | _tMempool* m = *mp; | 2248 | _tMempool* m = *mp; |
| 2249 | _tCompactWaveSynth* c = *cy = (_tCompactWaveSynth*) mpool_alloc(sizeof(_tCompactWaveSynth), m); | 2249 | _tWaveSynthS* c = *cy = (_tWaveSynthS*) mpool_alloc(sizeof(_tWaveSynthS), m); |
| 2250 | c->mempool = m; | 2250 | c->mempool = m; |
| 2251 | 2251 | ||
| 2252 | c->numTables = 0; | 2252 | c->numTables = 0; |
| @@ -2255,8 +2255,8 @@ void tCompactWaveSynth_initToPool(tCompactWaveSynth* const cy, int numVoices, fl · 2 unmodified lines | |||
| 2255 | if (sizes[t] > 0) c->numTables++; | 2255 | if (sizes[t] > 0) c->numTables++; |
| 2256 | } | 2256 | } |
| 2257 | 2257 | ||
| 2258 | c->tables = (tCompactWaveTable*) mpool_alloc(sizeof(tCompactWaveTable) * c->numTables, m); | 2258 | c->tables = (tWaveTableS*) mpool_alloc(sizeof(tWaveTableS) * c->numTables, m); |
| 2259 | c->oscs = (tCompactWaveOsc**) mpool_alloc(sizeof(tCompactWaveOsc*) * c->numTables, m); | 2259 | c->oscs = (tWaveOscS**) mpool_alloc(sizeof(tWaveOscS*) * c->numTables, m); |
| 2260 | 2260 | ||
| 2261 | c->numVoices = numVoices; | 2261 | c->numVoices = numVoices; |
| 2262 | 2262 | ||
| @@ -2265,9 +2265,9 @@ void tCompactWaveSynth_initToPool(tCompactWaveSynth* const cy, int numVoices, fl · 2 unmodified lines | |||
| 2265 | { | 2265 | { |
| 2266 | if (sizes[t] > 0) | 2266 | if (sizes[t] > 0) |
| 2267 | { | 2267 | { |
| 2268 | tCompactWaveTable_initToPool(&c->tables[i], tables[t], sizes[t], maxFreq, mp); | 2268 | tWaveTableS_initToPool(&c->tables[i], tables[t], sizes[t], maxFreq, mp); |
| 2269 | c->oscs[i] = (tCompactWaveOsc*) mpool_alloc(sizeof(tCompactWaveOsc) * c->numVoices, m); | 2269 | c->oscs[i] = (tWaveOscS*) mpool_alloc(sizeof(tWaveOscS) * c->numVoices, m); |
| 2270 | for (int v = 0; v < c->numVoices; ++v) tCompactWaveOsc_initToPool(&c->oscs[i][v], &c->tables[i], mp); | 2270 | for (int v = 0; v < c->numVoices; ++v) tWaveOscS_initToPool(&c->oscs[i][v], &c->tables[i], mp); |
| 2271 | i++; | 2271 | i++; |
| 2272 | } | 2272 | } |
| 2273 | } | 2273 | } |
| @@ -2279,14 +2279,14 @@ void tCompactWaveSynth_initToPool(tCompactWaveSynth* const cy, int numVoices, fl · 5 unmodified lines | |||
| 2279 | c->maxFreq = maxFreq; | 2279 | c->maxFreq = maxFreq; |
| 2280 | } | 2280 | } |
| 2281 | 2281 | ||
| 2282 | void tCompactWaveSynth_free(tCompactWaveSynth* const cy) | 2282 | void tWaveSynthS_free(tWaveSynthS* const cy) |
| 2283 | { | 2283 | { |
| 2284 | _tCompactWaveSynth* c = *cy; | 2284 | _tWaveSynthS* c = *cy; |
| 2285 | 2285 | ||
| 2286 | for (int i = 0; i < c->numTables; ++i) | 2286 | for (int i = 0; i < c->numTables; ++i) |
| 2287 | { | 2287 | { |
| 2288 | tCompactWaveTable_free(&c->tables[i]); | 2288 | tWaveTableS_free(&c->tables[i]); |
| 2289 | for (int v = 0; v < c->numVoices; ++v) tCompactWaveOsc_free(&c->oscs[i][v]); | 2289 | for (int v = 0; v < c->numVoices; ++v) tWaveOscS_free(&c->oscs[i][v]); |
| 2290 | mpool_free((char*)c->oscs[i], c->mempool); | 2290 | mpool_free((char*)c->oscs[i], c->mempool); |
| 2291 | } | 2291 | } |
| 2292 | mpool_free((char*)c->g, c->mempool); | 2292 | mpool_free((char*)c->g, c->mempool); |
| @@ -2295,9 +2295,9 @@ void tCompactWaveSynth_free(tCompactWaveSynth* const cy) · 2 unmodified lines | |||
| 2295 | mpool_free((char*)c, c->mempool); | 2295 | mpool_free((char*)c, c->mempool); |
| 2296 | } | 2296 | } |
| 2297 | 2297 | ||
| 2298 | float tCompactWaveSynth_tick(tCompactWaveSynth* const cy) | 2298 | float tWaveSynthS_tick(tWaveSynthS* const cy) |
| 2299 | { | 2299 | { |
| 2300 | _tCompactWaveSynth* c = *cy; | 2300 | _tWaveSynthS* c = *cy; |
| 2301 | 2301 | ||
| 2302 | float f = c->index * (c->numTables - 1); | 2302 | float f = c->index * (c->numTables - 1); |
| 2303 | 2303 | ||
| @@ -2310,7 +2310,7 @@ float tCompactWaveSynth_tick(tCompactWaveSynth* const cy) · 6 unmodified lines | |||
| 2310 | for (int t = 0; t < c->numTables; ++t) | 2310 | for (int t = 0; t < c->numTables; ++t) |
| 2311 | { | 2311 | { |
| 2312 | float s0 = 0.f; | 2312 | float s0 = 0.f; |
| 2313 | for (int v = 0; v < c->numVoices; ++v) s0 += tCompactWaveOsc_tick(&c->oscs[t][v]); | 2313 | for (int v = 0; v < c->numVoices; ++v) s0 += tWaveOscS_tick(&c->oscs[t][v]); |
| 2314 | if (t == o1) s1 = s0 * c->g[t]; | 2314 | if (t == o1) s1 = s0 * c->g[t]; |
| 2315 | if (t == o2) s2 = s0 * c->g[t]; | 2315 | if (t == o2) s2 = s0 * c->g[t]; |
| 2316 | } | 2316 | } |
| @@ -2319,9 +2319,9 @@ float tCompactWaveSynth_tick(tCompactWaveSynth* const cy) · 2 unmodified lines | |||
| 2319 | return s1 + (s2 - s1) * mix; | 2319 | return s1 + (s2 - s1) * mix; |
| 2320 | } | 2320 | } |
| 2321 | 2321 | ||
| 2322 | float tCompactWaveSynth_tickVoice(tCompactWaveSynth* const cy, int voice) | 2322 | float tWaveSynthS_tickVoice(tWaveSynthS* const cy, int voice) |
| 2323 | { | 2323 | { |
| 2324 | _tCompactWaveSynth* c = *cy; | 2324 | _tWaveSynthS* c = *cy; |
| 2325 | 2325 | ||
| 2326 | float f = c->index * (c->numTables - 1); | 2326 | float f = c->index * (c->numTables - 1); |
| 2327 | 2327 | ||
| @@ -2334,7 +2334,7 @@ float tCompactWaveSynth_tickVoice(tCompactWaveSynth* const cy, int voice) · 6 unmodified lines | |||
| 2334 | for (int t = 0; t < c->numTables; ++t) | 2334 | for (int t = 0; t < c->numTables; ++t) |
| 2335 | { | 2335 | { |
| 2336 | // Should we tick every voice anyway to preserve relative phases? | 2336 | // Should we tick every voice anyway to preserve relative phases? |
| 2337 | float s0 = tCompactWaveOsc_tick(&c->oscs[t][voice]); | 2337 | float s0 = tWaveOscS_tick(&c->oscs[t][voice]); |
| 2338 | if (t == o1) s1 = s0 * c->g[t]; | 2338 | if (t == o1) s1 = s0 * c->g[t]; |
| 2339 | if (t == o2) s2 = s0 * c->g[t]; | 2339 | if (t == o2) s2 = s0 * c->g[t]; |
| 2340 | } | 2340 | } |
| @@ -2343,58 +2343,58 @@ float tCompactWaveSynth_tickVoice(tCompactWaveSynth* const cy, int voice) · 2 unmodified lines | |||
| 2343 | return s1 + (s2 - s1) * mix; | 2343 | return s1 + (s2 - s1) * mix; |
| 2344 | } | 2344 | } |
| 2345 | 2345 | ||
| 2346 | void tCompactWaveSynth_setFreq(tCompactWaveSynth* const cy, int voice, float freq) | 2346 | void tWaveSynthS_setFreq(tWaveSynthS* const cy, int voice, float freq) |
| 2347 | { | 2347 | { |
| 2348 | _tCompactWaveSynth* c = *cy; | 2348 | _tWaveSynthS* c = *cy; |
| 2349 | for (int t = 0; t < c->numTables; ++t) | 2349 | for (int t = 0; t < c->numTables; ++t) |
| 2350 | { | 2350 | { |
| 2351 | tCompactWaveOsc_setFreq(&c->oscs[t][voice], freq); | 2351 | tWaveOscS_setFreq(&c->oscs[t][voice], freq); |
| 2352 | } | 2352 | } |
| 2353 | } | 2353 | } |
| 2354 | 2354 | ||
| 2355 | void tCompactWaveSynth_setAntiAliasing(tCompactWaveSynth* const cy, float aa) | 2355 | void tWaveSynthS_setAntiAliasing(tWaveSynthS* const cy, float aa) |
| 2356 | { | 2356 | { |
| 2357 | _tCompactWaveSynth* c = *cy; | 2357 | _tWaveSynthS* c = *cy; |
| 2358 | for (int t = 0; t < c->numTables; ++t) | 2358 | for (int t = 0; t < c->numTables; ++t) |
| 2359 | { | 2359 | { |
| 2360 | for (int v = 0; v < c->numVoices; ++v) | 2360 | for (int v = 0; v < c->numVoices; ++v) |
| 2361 | { | 2361 | { |
| 2362 | tCompactWaveOsc_setAntiAliasing(&c->oscs[t][v], aa); | 2362 | tWaveOscS_setAntiAliasing(&c->oscs[t][v], aa); |
| 2363 | } | 2363 | } |
| 2364 | } | 2364 | } |
| 2365 | } | 2365 | } |
| 2366 | 2366 | ||
| 2367 | void tCompactWaveSynth_setIndex(tCompactWaveSynth* const cy, float index) | 2367 | void tWaveSynthS_setIndex(tWaveSynthS* const cy, float index) |
| 2368 | { | 2368 | { |
| 2369 | _tCompactWaveSynth* c = *cy; | 2369 | _tWaveSynthS* c = *cy; |
| 2370 | c->index = index; | 2370 | c->index = index; |
| 2371 | } | 2371 | } |
| 2372 | 2372 | ||
| 2373 | void tCompactWaveSynth_setIndexGain(tCompactWaveSynth* const cy, int i, float gain) | 2373 | void tWaveSynthS_setIndexGain(tWaveSynthS* const cy, int i, float gain) |
| 2374 | { | 2374 | { |
| 2375 | _tCompactWaveSynth* c = *cy; | 2375 | _tWaveSynthS* c = *cy; |
| 2376 | if (i >= c->numTables) return; | 2376 | if (i >= c->numTables) return; |
| 2377 | c->g[i] = gain; | 2377 | c->g[i] = gain; |
| 2378 | } | 2378 | } |
| 2379 | 2379 | ||
| 2380 | void tCompactWaveSynth_setIndexPhase(tCompactWaveSynth* const cy, int i, float phase) | 2380 | void tWaveSynthS_setIndexPhase(tWaveSynthS* const cy, int i, float phase) |
| 2381 | { | 2381 | { |
| 2382 | _tCompactWaveSynth* c = *cy; | 2382 | _tWaveSynthS* c = *cy; |
| 2383 | if (i >= c->numTables) return; | 2383 | if (i >= c->numTables) return; |
| 2384 | for (int v = 0; v < c->numVoices; ++v) | 2384 | for (int v = 0; v < c->numVoices; ++v) |
| 2385 | { | 2385 | { |
| 2386 | tCompactWaveOsc_setPhaseOffset(&c->oscs[i][v], phase); | 2386 | tWaveOscS_setPhaseOffset(&c->oscs[i][v], phase); |
| 2387 | } | 2387 | } |
| 2388 | } | 2388 | } |
| 2389 | // | 2389 | // |
| 2390 | //void tCompactWaveSynth_setIndexTable(tCompactWaveSynth* const cy, int i, float* table, int size) | 2390 | //void tWaveSynthS_setIndexTable(tWaveSynthS* const cy, int i, float* table, int size) |
| 2391 | //{ | 2391 | //{ |
| 2392 | // _tCompactWaveSynth* c = *cy; | 2392 | // _tWaveSynthS* c = *cy; |
| 2393 | // if (i >= c->numTables) return; | 2393 | // if (i >= c->numTables) return; |
| 2394 | // tCompactWaveTable_free(&c->tables[i]); | 2394 | // tWaveTableS_free(&c->tables[i]); |
| 2395 | // tCompactWaveTable_initToPool(&c->tables[i], table, size, c->maxFreq, &c->mempool); | 2395 | // tWaveTableS_initToPool(&c->tables[i], table, size, c->maxFreq, &c->mempool); |
| 2396 | // for (int v = 0; v < c->numVoices; ++v) | 2396 | // for (int v = 0; v < c->numVoices; ++v) |
| 2397 | // { | 2397 | // { |
| 2398 | // tCompactWaveOsc_setFreq(&c->oscs[i][v], c->oscs[i][v]->freq); | 2398 | // tWaveOscS_setFreq(&c->oscs[i][v], c->oscs[i][v]->freq); |
| 2399 | // } | 2399 | // } |
| 2400 | //} | 2400 | //} |
| @@ -18,7 +18,7 @@ · 17 unmodified lines | |||
| 18 | 18 | ||
| 19 | //============================================================================== | 19 | //============================================================================== |
| 20 | 20 | ||
| 21 | //! Include FIR tables required to use tOversampler and tCompactWaveTable which uses tOversampler. | 21 | //! Include FIR tables required to use tOversampler and tWaveTableS which uses tOversampler. |
| 22 | #define LEAF_INCLUDE_OVERSAMPLER_TABLES 1 | 22 | #define LEAF_INCLUDE_OVERSAMPLER_TABLES 1 |
| 23 | 23 | ||
| 24 | // Unused | 24 | // Unused |
| @@ -36,7 +36,7 @@ · 11 unmodified lines | |||
| 36 | // Unused | 36 | // Unused |
| 37 | #define LEAF_INCLUDE_ADC_TABLE 0 | 37 | #define LEAF_INCLUDE_ADC_TABLE 0 |
| 38 | 38 | ||
| 39 | //! Include tables required to use tEnvelope and tADSR (but not tADSR2, tADSR3, and tADSR4). | 39 | //! Include tables required to use tEnvelope and tADSR (but not tADSRT and tADSRS). |
| 40 | #define LEAF_INCLUDE_ADSR_TABLES 1 | 40 | #define LEAF_INCLUDE_ADSR_TABLES 1 |
| 41 | 41 | ||
| 42 | //! Include wave table required to use tCycle. | 42 | //! Include wave table required to use tCycle. |