Unified · Split
| @@ -111,6 +111,39 @@ float tDelayA_tick (tDelayA* const, float sample); · 110 unmodified lines | |||
| 111 | float tDelayA_getLastOut (tDelayA* const); | 111 | float tDelayA_getLastOut (tDelayA* const); |
| 112 | float tDelayA_getLastIn (tDelayA* const); | 112 | float tDelayA_getLastIn (tDelayA* const); |
| 113 | 113 | ||
| 114 | // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | 114 | // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ |
| 115 | |||
| 116 | /* Linear interpolating delay with fixed read and write pointers, variable rate. */ | ||
| 117 | typedef struct _tTapeDelay | ||
| 118 | { | ||
| 119 | float gain; | ||
| 120 | float* buff; | ||
| 121 | |||
| 122 | float lastOut, lastIn; | ||
| 123 | |||
| 124 | uint32_t inPoint; | ||
| 125 | uint32_t outPoint; | ||
| 126 | |||
| 127 | uint32_t maxDelay; | ||
| 128 | |||
| 129 | float delay, inc, idx; | ||
| 130 | |||
| 131 | float alpha, omAlpha, coeff; | ||
| 132 | |||
| 133 | float apInput; | ||
| 134 | |||
| 135 | } tTapeDelay; | ||
| 136 | |||
| 137 | void tTapeDelay_init (tTapeDelay* const, float delay, uint32_t maxDelay); | ||
| 138 | void tTapeDelay_free (tTapeDelay* const); | ||
| 139 | |||
| 140 | int tTapeDelay_setDelay (tTapeDelay* const, float delay); | ||
| 141 | float tTapeDelay_getDelay (tTapeDelay* const); | ||
| 142 | void tTapeDelay_tapIn (tTapeDelay* const, float in, uint32_t tapDelay); | ||
| 143 | float tTapeDelay_tapOut (tTapeDelay* const, uint32_t tapDelay); | ||
| 144 | float tTapeDelay_addTo (tTapeDelay* const, float value, uint32_t tapDelay); | ||
| 145 | float tTapeDelay_tick (tTapeDelay* const, float sample); | ||
| 146 | float tTapeDelay_getLastOut (tTapeDelay* const); | ||
| 147 | float tTapeDelay_getLastIn (tTapeDelay* const); | ||
| 115 | 148 | ||
| 116 | #endif // LEAFDELAY_H_INCLUDED | 149 | #endif // LEAFDELAY_H_INCLUDED |
| @@ -89,6 +89,11 @@ void LEAF_generate_square (float* buffer, float basefreq, int size); · 88 unmodified lines | |||
| 89 | // dope af | 89 | // dope af |
| 90 | float LEAF_chebyshevT(float in, int n); | 90 | float LEAF_chebyshevT(float in, int n); |
| 91 | float LEAF_CompoundChebyshevT(float in, int n, float* amps); | 91 | float LEAF_CompoundChebyshevT(float in, int n, float* amps); |
| 92 | |||
| 93 | |||
| 94 | // Hermite interpolation | ||
| 95 | float LEAF_interpolate_hermite (float A, float B, float C, float D, float t); | ||
| 96 | float LEAF_interpolation_linear (float A, float B, float t); | ||
| 92 | 97 | ||
| 93 | static inline float interpolate3max(float *buf, const int peakindex) | 98 | static inline float interpolate3max(float *buf, const int peakindex) |
| 94 | { | 99 | { |
| @@ -81,7 +81,6 @@ void tNRev_setMix (tNRev* const, float mix); · 80 unmodified lines | |||
| 81 | 81 | ||
| 82 | // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | 82 | // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ |
| 83 | 83 | ||
| 84 | |||
| 85 | typedef struct _tDattorro | 84 | typedef struct _tDattorro |
| 86 | { | 85 | { |
| 87 | float predelay; | 86 | float predelay; |
| @@ -90,13 +89,14 @@ typedef struct _tDattorro · 2 unmodified lines | |||
| 90 | float feedback_gain; | 89 | float feedback_gain; |
| 91 | float mix; | 90 | float mix; |
| 92 | 91 | ||
| 93 | float size, t; | 92 | |
| 93 | float size, size_max, t; | ||
| 94 | 94 | ||
| 95 | float f1_delay_2_last, | 95 | float f1_delay_2_last, |
| 96 | f2_delay_2_last; | 96 | f2_delay_2_last; |
| 97 | 97 | ||
| 98 | float f1_last, | 98 | float f1_last, |
| 99 | f2_last; | 99 | f2_last; |
| 100 | 100 | ||
| 101 | // INPUT | 101 | // INPUT |
| 102 | tDelayL in_delay; | 102 | tDelayL in_delay; |
| @@ -109,6 +109,7 @@ typedef struct _tDattorro · 6 unmodified lines | |||
| 109 | tOnePole f1_filter; | 109 | tOnePole f1_filter; |
| 110 | tDelayL f1_delay_2; | 110 | tDelayL f1_delay_2; |
| 111 | tDelayL f1_delay_3; | 111 | tDelayL f1_delay_3; |
| 112 | tHighpass f1_hp; | ||
| 112 | 113 | ||
| 113 | tCycle f1_lfo; | 114 | tCycle f1_lfo; |
| 114 | 115 | ||
| @@ -118,9 +119,10 @@ typedef struct _tDattorro · 3 unmodified lines | |||
| 118 | tOnePole f2_filter; | 119 | tOnePole f2_filter; |
| 119 | tDelayL f2_delay_2; | 120 | tDelayL f2_delay_2; |
| 120 | tDelayL f2_delay_3; | 121 | tDelayL f2_delay_3; |
| 122 | tHighpass f2_hp; | ||
| 121 | 123 | ||
| 122 | tCycle f2_lfo; | 124 | tCycle f2_lfo; |
| 123 | 125 | ||
| 124 | } tDattorro; | 126 | } tDattorro; |
| 125 | 127 | ||
| 126 | void tDattorro_init (tDattorro* const); | 128 | void tDattorro_init (tDattorro* const); |
| @@ -133,7 +135,6 @@ void tDattorro_setSize (tDattorro* const, float size); · 6 unmodified lines | |||
| 133 | void tDattorro_setInputDelay (tDattorro* const, float preDelay); | 135 | void tDattorro_setInputDelay (tDattorro* const, float preDelay); |
| 134 | void tDattorro_setInputFilter (tDattorro* const, float freq); | 136 | void tDattorro_setInputFilter (tDattorro* const, float freq); |
| 135 | void tDattorro_setFeedbackFilter (tDattorro* const, float freq); | 137 | void tDattorro_setFeedbackFilter (tDattorro* const, float freq); |
| 136 | void tDattorro_setFeedbackGain (tDattorro* const, float gain); | 138 | void tDattorro_setFeedbackGain (tDattorro* const, float gain); |
| 137 | |||
| 138 | 139 | ||
| 139 | #endif // LEAFREVERB_H_INCLUDED | 140 | #endif // LEAFREVERB_H_INCLUDED |
| @@ -63,8 +63,8 @@ float tDelay_tick (tDelay* const d, float input) · 62 unmodified lines | |||
| 63 | 63 | ||
| 64 | int tDelay_setDelay (tDelay* const d, uint32_t delay) | 64 | int tDelay_setDelay (tDelay* const d, uint32_t delay) |
| 65 | { | 65 | { |
| 66 | if (delay >= d->maxDelay) d->delay = d->maxDelay; | 66 | d->delay = LEAF_clip(0.0f, delay, d->maxDelay); |
| 67 | else d->delay = delay; | 67 | |
| 68 | 68 | ||
| 69 | // read chases write | 69 | // read chases write |
| 70 | if ( d->inPoint >= delay ) d->outPoint = d->inPoint - d->delay; | 70 | if ( d->inPoint >= delay ) d->outPoint = d->inPoint - d->delay; |
| @@ -163,29 +163,26 @@ float tDelayL_tick (tDelayL* const d, float input) · 92 unmodified lines | |||
| 163 | d->buff[d->inPoint] = input * d->gain; | 163 | d->buff[d->inPoint] = input * d->gain; |
| 164 | 164 | ||
| 165 | // Increment input pointer modulo length. | 165 | // Increment input pointer modulo length. |
| 166 | if (++(d->inPoint) == d->maxDelay ) d->inPoint = 0; | 166 | if (++(d->inPoint) == d->maxDelay ) d->inPoint = 0; |
| 167 | 167 | ||
| 168 | 168 | ||
| 169 | // First 1/2 of interpolation | 169 | uint32_t idx = (uint32_t) d->outPoint; |
| 170 | d->lastOut = d->buff[d->outPoint] * d->omAlpha; | 170 | |
| 171 | 171 | d->lastOut = LEAF_interpolate_hermite (d->buff[((idx - 1) + d->maxDelay) % d->maxDelay], | |
| 172 | // Second 1/2 of interpolation | 172 | d->buff[idx], |
| 173 | if (d->outPoint + 1 < d->maxDelay) | 173 | d->buff[(idx + 1) % d->maxDelay], |
| 174 | d->lastOut += d->buff[d->outPoint+1] * d->alpha; | 174 | d->buff[(idx + 2) % d->maxDelay], |
| 175 | else | 175 | d->alpha); |
| 176 | d->lastOut += d->buff[0] * d->alpha; | ||
| 177 | 176 | ||
| 178 | // Increment output pointer modulo length. | 177 | // Increment output pointer modulo length |
| 179 | if ( ++(d->outPoint) == d->maxDelay ) d->outPoint = 0; | 178 | if ( (++d->outPoint) >= d->maxDelay ) d->outPoint = 0; |
| 180 | 179 | ||
| 181 | return d->lastOut; | 180 | return d->lastOut; |
| 182 | } | 181 | } |
| 183 | 182 | ||
| 184 | int tDelayL_setDelay (tDelayL* const d, float delay) | 183 | int tDelayL_setDelay (tDelayL* const d, float delay) |
| 185 | { | 184 | { |
| 186 | if (delay < 0.0f) d->delay = 0.0f; | 185 | d->delay = LEAF_clip(0.0f, delay, d->maxDelay); |
| 187 | else if (delay <= d->maxDelay) d->delay = delay; | ||
| 188 | else d->delay = d->maxDelay; | ||
| 189 | 186 | ||
| 190 | float outPointer = d->inPoint - d->delay; | 187 | float outPointer = d->inPoint - d->delay; |
| 191 | 188 | ||
| @@ -326,9 +323,8 @@ float tDelayA_tick (tDelayA* const d, float input) · 134 unmodified lines | |||
| 326 | 323 | ||
| 327 | int tDelayA_setDelay (tDelayA* const d, float delay) | 324 | int tDelayA_setDelay (tDelayA* const d, float delay) |
| 328 | { | 325 | { |
| 329 | if (delay < 0.5f) d->delay = 0.5f; | 326 | d->delay = LEAF_clip(0.5f, delay, d->maxDelay); |
| 330 | else if (delay <= d->maxDelay) d->delay = delay; | 327 | |
| 331 | else d->delay = d->maxDelay; | ||
| 332 | 328 | ||
| 333 | // outPoint chases inPoint | 329 | // outPoint chases inPoint |
| 334 | float outPointer = (float)d->inPoint - d->delay + 1.0f; | 330 | float outPointer = (float)d->inPoint - d->delay + 1.0f; |
| @@ -413,5 +409,156 @@ void tDelayA_setGain (tDelayA* const d, float gain) · 78 unmodified lines | |||
| 413 | float tDelayA_getGain (tDelayA* const d) | 409 | float tDelayA_getGain (tDelayA* const d) |
| 414 | { | 410 | { |
| 415 | return d->gain; | 411 | return d->gain; |
| 412 | } | ||
| 413 | |||
| 414 | // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ TapeDelay ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ // | ||
| 415 | void tTapeDelay_init (tTapeDelay* const d, float delay, uint32_t maxDelay) | ||
| 416 | { | ||
| 417 | d->maxDelay = maxDelay; | ||
| 418 | |||
| 419 | d->delay = LEAF_clip(0.0f, delay, d->maxDelay); | ||
| 420 | |||
| 421 | d->buff = (float*) leaf_alloc(sizeof(float) * maxDelay); | ||
| 422 | |||
| 423 | d->gain = 1.0f; | ||
| 424 | |||
| 425 | d->lastIn = 0.0f; | ||
| 426 | d->lastOut = 0.0f; | ||
| 427 | |||
| 428 | d->idx = 0.0f; | ||
| 429 | d->inc = 1.0f; | ||
| 430 | d->inPoint = 0; | ||
| 431 | d->outPoint = 0; | ||
| 432 | |||
| 433 | tTapeDelay_setDelay(d, 1); | ||
| 434 | } | ||
| 435 | |||
| 436 | void tTapeDelay_free(tTapeDelay* const d) | ||
| 437 | { | ||
| 438 | leaf_free(d->buff); | ||
| 439 | leaf_free(d); | ||
| 440 | } | ||
| 441 | |||
| 442 | int count = 0; | ||
| 443 | |||
| 444 | #define SMOOTH_FACTOR 10.f | ||
| 445 | |||
| 446 | float tTapeDelay_tick (tTapeDelay* const d, float input) | ||
| 447 | { | ||
| 448 | d->buff[d->inPoint] = input * d->gain; | ||
| 449 | |||
| 450 | // Increment input pointer modulo length. | ||
| 451 | if (++(d->inPoint) == d->maxDelay ) d->inPoint = 0; | ||
| 452 | |||
| 453 | int idx = (int) d->idx; | ||
| 454 | d->alpha = d->idx - idx; | ||
| 455 | |||
| 456 | d->lastOut = LEAF_interpolate_hermite (d->buff[((idx - 1) + d->maxDelay) % d->maxDelay], | ||
| 457 | d->buff[idx], | ||
| 458 | d->buff[(idx + 1) % d->maxDelay], | ||
| 459 | d->buff[(idx + 2) % d->maxDelay], | ||
| 460 | d->alpha); | ||
| 461 | |||
| 462 | float diff = (d->inPoint - d->idx); | ||
| 463 | while (diff < 0.f) diff += d->maxDelay; | ||
| 464 | |||
| 465 | d->inc = 1.0f + (diff - d->delay) / d->delay * SMOOTH_FACTOR; | ||
| 466 | |||
| 467 | d->idx += d->inc; | ||
| 468 | |||
| 469 | if (d->idx >= d->maxDelay) d->idx = 0.f; | ||
| 470 | |||
| 471 | if ( ++(d->outPoint) >= d->maxDelay ) d->outPoint -= d->maxDelay; | ||
| 472 | |||
| 473 | return d->lastOut; | ||
| 474 | } | ||
| 475 | |||
| 476 | |||
| 477 | void tTapeDelay_setRate(tTapeDelay* const d, float rate) | ||
| 478 | { | ||
| 479 | d->inc = rate; | ||
| 480 | } | ||
| 481 | |||
| 482 | int tTapeDelay_setDelay (tTapeDelay* const d, float delay) | ||
| 483 | { | ||
| 484 | d->delay = LEAF_clip(0.0f, delay, d->maxDelay); | ||
| 485 | |||
| 486 | |||
| 487 | float outPointer = d->inPoint - d->delay; | ||
| 488 | |||
| 489 | while ( outPointer < 0 ) | ||
| 490 | outPointer += d->maxDelay; // modulo maximum length | ||
| 491 | |||
| 492 | d->outPoint = (uint32_t) outPointer; // integer part | ||
| 493 | |||
| 494 | |||
| 495 | return 0; | ||
| 496 | } | ||
| 497 | |||
| 498 | float tTapeDelay_tapOut (tTapeDelay* const d, float tapDelay) | ||
| 499 | { | ||
| 500 | float tap = (float) d->inPoint - tapDelay - 1.f; | ||
| 501 | |||
| 502 | // Check for wraparound. | ||
| 503 | while ( tap < 0.f ) tap += (float)d->maxDelay; | ||
| 504 | |||
| 505 | int idx = (int) tap; | ||
| 506 | |||
| 507 | float alpha = tap - idx; | ||
| 508 | |||
| 509 | float samp = LEAF_interpolate_hermite (d->buff[((idx - 1) + d->maxDelay) % d->maxDelay], | ||
| 510 | d->buff[idx], | ||
| 511 | d->buff[(idx + 1) % d->maxDelay], | ||
| 512 | d->buff[(idx + 2) % d->maxDelay], | ||
| 513 | d->alpha); | ||
| 514 | |||
| 515 | return samp; | ||
| 516 | |||
| 517 | } | ||
| 518 | |||
| 519 | void tTapeDelay_tapIn (tTapeDelay* const d, float value, uint32_t tapDelay) | ||
| 520 | { | ||
| 521 | int32_t tap = d->inPoint - tapDelay - 1; | ||
| 522 | |||
| 523 | // Check for wraparound. | ||
| 524 | while ( tap < 0 ) tap += d->maxDelay; | ||
| 525 | |||
| 526 | d->buff[tap] = value; | ||
| 527 | } | ||
| 528 | |||
| 529 | float tTapeDelay_addTo (tTapeDelay* const d, float value, uint32_t tapDelay) | ||
| 530 | { | ||
| 531 | int32_t tap = d->inPoint - tapDelay - 1; | ||
| 532 | |||
| 533 | // Check for wraparound. | ||
| 534 | while ( tap < 0 ) tap += d->maxDelay; | ||
| 535 | |||
| 536 | return (d->buff[tap] += value); | ||
| 537 | } | ||
| 538 | |||
| 539 | float tTapeDelay_getDelay (tTapeDelay *d) | ||
| 540 | { | ||
| 541 | return d->delay; | ||
| 542 | } | ||
| 543 | |||
| 544 | float tTapeDelay_getLastOut (tTapeDelay* const d) | ||
| 545 | { | ||
| 546 | return d->lastOut; | ||
| 547 | } | ||
| 548 | |||
| 549 | float tTapeDelay_getLastIn (tTapeDelay* const d) | ||
| 550 | { | ||
| 551 | return d->lastIn; | ||
| 552 | } | ||
| 553 | |||
| 554 | void tTapeDelay_setGain (tTapeDelay* const d, float gain) | ||
| 555 | { | ||
| 556 | if (gain < 0.0f) d->gain = 0.0f; | ||
| 557 | else d->gain = gain; | ||
| 558 | } | ||
| 559 | |||
| 560 | float tTapeDelay_getGain (tTapeDelay* const d) | ||
| 561 | { | ||
| 562 | return d->gain; | ||
| 416 | } | 563 | } |
| 417 | 564 | ||
| @@ -231,4 +231,34 @@ float LEAF_midiToFrequency(float f) · 230 unmodified lines | |||
| 231 | if( f <= -1500.0f ) return (0); | 231 | if( f <= -1500.0f ) return (0); |
| 232 | else if( f > 1499.0f ) return (LEAF_midiToFrequency(1499.0f)); | 232 | else if( f > 1499.0f ) return (LEAF_midiToFrequency(1499.0f)); |
| 233 | else return ( powf(2.0f, (f - 69.0f) / 12.0f) * 440.0f ); | 233 | else return ( powf(2.0f, (f - 69.0f) / 12.0f) * 440.0f ); |
| 234 | } | 234 | } |
| 235 | |||
| 236 | |||
| 237 | // alpha, [0.0, 1.0] | ||
| 238 | float LEAF_interpolate_hermite (float A, float B, float C, float D, float alpha) | ||
| 239 | { | ||
| 240 | alpha = LEAF_clip(0.0f, alpha, 1.0f); | ||
| 241 | |||
| 242 | float a = -A/2.0f + (3.0f*B)/2.0f - (3.0f*C)/2.0f + D/2.0f; | ||
| 243 | float b = A - (5.0f*B)/2.0f + 2.0f*C - D / 2.0f; | ||
| 244 | float c = -A/2.0f + C/2.0f; | ||
| 245 | float d = B; | ||
| 246 | |||
| 247 | return a*alpha*alpha*alpha + b*alpha*alpha + c*alpha + d; | ||
| 248 | } | ||
| 249 | |||
| 250 | // alpha, [0.0, 1.0] | ||
| 251 | float LEAF_interpolation_linear (float A, float B, float alpha) | ||
| 252 | { | ||
| 253 | alpha = LEAF_clip(0.0f, alpha, 1.0f); | ||
| 254 | |||
| 255 | float omAlpha = 1.0f - alpha; | ||
| 256 | |||
| 257 | // First 1/2 of interpolation | ||
| 258 | float out = A * omAlpha; | ||
| 259 | |||
| 260 | out += B * alpha; | ||
| 261 | |||
| 262 | return out; | ||
| 263 | } | ||
| 264 | |||
| @@ -262,9 +262,12 @@ void tNRevSampleRateChanged (tNRev* const r) · 261 unmodified lines | |||
| 262 | float in_allpass_delays[4] = { 4.771f, 3.595f, 12.73f, 9.307f }; | 262 | float in_allpass_delays[4] = { 4.771f, 3.595f, 12.73f, 9.307f }; |
| 263 | float in_allpass_gains[4] = { 0.75f, 0.75f, 0.625f, 0.625f }; | 263 | float in_allpass_gains[4] = { 0.75f, 0.75f, 0.625f, 0.625f }; |
| 264 | 264 | ||
| 265 | |||
| 265 | void tDattorro_init (tDattorro* const r) | 266 | void tDattorro_init (tDattorro* const r) |
| 266 | { | 267 | { |
| 267 | tDattorro_setSize(r, 1.0f); | 268 | r->size_max = 2.0f; |
| 269 | r->size = 1.f; | ||
| 270 | r->t = r->size * leaf.sampleRate * 0.001f; | ||
| 268 | 271 | ||
| 269 | // INPUT | 272 | // INPUT |
| 270 | tDelayL_init(&r->in_delay, 0.f, SAMP(200.f)); | 273 | tDelayL_init(&r->in_delay, 0.f, SAMP(200.f)); |
| @@ -272,33 +275,37 @@ void tDattorro_init (tDattorro* const r) · 1 unmodified line | |||
| 272 | 275 | ||
| 273 | for (int i = 0; i < 4; i++) | 276 | for (int i = 0; i < 4; i++) |
| 274 | { | 277 | { |
| 275 | tAllpass_init(&r->in_allpass[i], in_allpass_delays[i], SAMP(20.f)); | 278 | tAllpass_init(&r->in_allpass[i], SAMP(in_allpass_delays[i]), SAMP(20.f)); // * r->size_max |
| 276 | tAllpass_setGain(&r->in_allpass[i], in_allpass_gains[i]); | 279 | tAllpass_setGain(&r->in_allpass[i], in_allpass_gains[i]); |
| 277 | } | 280 | } |
| 278 | 281 | ||
| 279 | // FEEDBACK 1 | 282 | // FEEDBACK 1 |
| 280 | tAllpass_init(&r->f1_allpass, SAMP(30.51f), SAMP(100.f)); | 283 | tAllpass_init(&r->f1_allpass, SAMP(30.51f), SAMP(100.f)); // * r->size_max |
| 281 | tAllpass_setGain(&r->f1_allpass, 0.7f); | 284 | tAllpass_setGain(&r->f1_allpass, 0.7f); |
| 282 | 285 | ||
| 283 | tDelayL_init(&r->f1_delay_1, SAMP(141.69f), SAMP(200.0f)); | 286 | tDelayL_init(&r->f1_delay_1, SAMP(141.69f), SAMP(200.0f) * r->size_max + 1); |
| 284 | tDelayL_init(&r->f1_delay_2, SAMP(89.24f), SAMP(100.0f)); | 287 | tDelayL_init(&r->f1_delay_2, SAMP(89.24f), SAMP(100.0f) * r->size_max + 1); |
| 285 | tDelayL_init(&r->f1_delay_3, SAMP(125.f), SAMP(200.0f)); | 288 | tDelayL_init(&r->f1_delay_3, SAMP(125.f), SAMP(200.0f) * r->size_max + 1); |
| 286 | 289 | ||
| 287 | tOnePole_init(&r->f1_filter, 1.f); | 290 | tOnePole_init(&r->f1_filter, 1.f); |
| 288 | 291 | ||
| 292 | tHighpass_init(&r->f1_hp, 20.f); | ||
| 293 | |||
| 289 | tCycle_init(&r->f1_lfo); | 294 | tCycle_init(&r->f1_lfo); |
| 290 | tCycle_setFreq(&r->f1_lfo, 0.1f); | 295 | tCycle_setFreq(&r->f1_lfo, 0.1f); |
| 291 | 296 | ||
| 292 | // FEEDBACK 2 | 297 | // FEEDBACK 2 |
| 293 | tAllpass_init(&r->f2_allpass, SAMP(22.58f), SAMP(100.f)); | 298 | tAllpass_init(&r->f2_allpass, SAMP(22.58f), SAMP(100.f)); // * r->size_max |
| 294 | tAllpass_setGain(&r->f2_allpass, 0.7f); | 299 | tAllpass_setGain(&r->f2_allpass, 0.7f); |
| 295 | 300 | ||
| 296 | tDelayL_init(&r->f2_delay_1, SAMP(149.62f), SAMP(200.0f)); | 301 | tDelayL_init(&r->f2_delay_1, SAMP(149.62f), SAMP(200.f) * r->size_max + 1); |
| 297 | tDelayL_init(&r->f2_delay_2, SAMP(60.48f), SAMP(100.0f)); | 302 | tDelayL_init(&r->f2_delay_2, SAMP(60.48f), SAMP(100.f) * r->size_max + 1); |
| 298 | tDelayL_init(&r->f2_delay_3, SAMP(106.28f), SAMP(200.0f)); | 303 | tDelayL_init(&r->f2_delay_3, SAMP(106.28f), SAMP(200.f) * r->size_max + 1); |
| 299 | 304 | ||
| 300 | tOnePole_init(&r->f2_filter, 1.f); | 305 | tOnePole_init(&r->f2_filter, 1.f); |
| 301 | 306 | ||
| 307 | tHighpass_init(&r->f2_hp, 20.f); | ||
| 308 | |||
| 302 | tCycle_init(&r->f2_lfo); | 309 | tCycle_init(&r->f2_lfo); |
| 303 | tCycle_setFreq(&r->f2_lfo, 0.07f); | 310 | tCycle_setFreq(&r->f2_lfo, 0.07f); |
| 304 | 311 | ||
| @@ -313,6 +320,8 @@ void tDattorro_init (tDattorro* const r) · 8 unmodified lines | |||
| 313 | tDattorro_setFeedbackFilter(r, 5000.f); | 320 | tDattorro_setFeedbackFilter(r, 5000.f); |
| 314 | 321 | ||
| 315 | tDattorro_setFeedbackGain(r, 0.4f); | 322 | tDattorro_setFeedbackGain(r, 0.4f); |
| 323 | |||
| 324 | |||
| 316 | } | 325 | } |
| 317 | 326 | ||
| 318 | void tDattorro_free (tDattorro* const r) | 327 | void tDattorro_free (tDattorro* const r) |
| @@ -382,6 +391,8 @@ float tDattorro_tick (tDattorro* const r, float input) · 63 unmodified lines | |||
| 382 | 391 | ||
| 383 | f1_sample = r->f1_delay_2_last + f1_sample; | 392 | f1_sample = r->f1_delay_2_last + f1_sample; |
| 384 | 393 | ||
| 394 | f1_sample = tHighpass_tick(&r->f1_hp, f1_sample); | ||
| 395 | |||
| 385 | f1_sample *= r->feedback_gain; | 396 | f1_sample *= r->feedback_gain; |
| 386 | 397 | ||
| 387 | r->f1_last = tDelayL_tick(&r->f1_delay_3, f1_sample); | 398 | r->f1_last = tDelayL_tick(&r->f1_delay_3, f1_sample); |
| @@ -405,6 +416,8 @@ float tDattorro_tick (tDattorro* const r, float input) · 17 unmodified lines | |||
| 405 | 416 | ||
| 406 | f2_sample = r->f2_delay_2_last + f2_sample; | 417 | f2_sample = r->f2_delay_2_last + f2_sample; |
| 407 | 418 | ||
| 419 | f2_sample = tHighpass_tick(&r->f2_hp, f2_sample); | ||
| 420 | |||
| 408 | f2_sample *= r->feedback_gain; | 421 | f2_sample *= r->feedback_gain; |
| 409 | 422 | ||
| 410 | r->f2_last = tDelayL_tick(&r->f2_delay_3, f2_sample); | 423 | r->f2_last = tDelayL_tick(&r->f2_delay_3, f2_sample); |
| @@ -412,7 +425,7 @@ float tDattorro_tick (tDattorro* const r, float input) · 1 unmodified line | |||
| 412 | 425 | ||
| 413 | // TAP OUT 1 | 426 | // TAP OUT 1 |
| 414 | f1_sample = tDelayL_tapOut(&r->f1_delay_1, SAMP(8.9f)) + | 427 | f1_sample = tDelayL_tapOut(&r->f1_delay_1, SAMP(8.9f)) + |
| 415 | tDelayL_tapOut(&r->f1_delay_1, SAMP(99.8f)); | 428 | tDelayL_tapOut(&r->f1_delay_1, SAMP(99.8f)); |
| 416 | 429 | ||
| 417 | f1_sample -= tDelayL_tapOut(&r->f1_delay_2, SAMP(64.2f)); | 430 | f1_sample -= tDelayL_tapOut(&r->f1_delay_2, SAMP(64.2f)); |
| 418 | 431 | ||
| @@ -428,7 +441,7 @@ float tDattorro_tick (tDattorro* const r, float input) · 9 unmodified lines | |||
| 428 | 441 | ||
| 429 | // TAP OUT 2 | 442 | // TAP OUT 2 |
| 430 | f2_sample = tDelayL_tapOut(&r->f2_delay_1, SAMP(11.8f)) + | 443 | f2_sample = tDelayL_tapOut(&r->f2_delay_1, SAMP(11.8f)) + |
| 431 | tDelayL_tapOut(&r->f2_delay_1, SAMP(121.7f)); | 444 | tDelayL_tapOut(&r->f2_delay_1, SAMP(121.7f)); |
| 432 | 445 | ||
| 433 | f2_sample -= tDelayL_tapOut(&r->f2_delay_2, SAMP(6.3f)); | 446 | f2_sample -= tDelayL_tapOut(&r->f2_delay_2, SAMP(6.3f)); |
| 434 | 447 | ||
| @@ -454,8 +467,31 @@ void tDattorro_setMix (tDattorro* const r, float mix) · 19 unmodified lines | |||
| 454 | 467 | ||
| 455 | void tDattorro_setSize (tDattorro* const r, float size) | 468 | void tDattorro_setSize (tDattorro* const r, float size) |
| 456 | { | 469 | { |
| 457 | r->size = LEAF_clip(0.001f, size, 100.0f); | 470 | r->size = LEAF_clip(0.01f, size*r->size_max, r->size_max); |
| 458 | r->t = r->size * leaf.sampleRate * 0.001f; | 471 | r->t = r->size * leaf.sampleRate * 0.001f; |
| 472 | |||
| 473 | /* | ||
| 474 | for (int i = 0; i < 4; i++) | ||
| 475 | { | ||
| 476 | tAllpass_setDelay(&r->in_allpass[i], SAMP(in_allpass_delays[i])); | ||
| 477 | } | ||
| 478 | */ | ||
| 479 | |||
| 480 | // FEEDBACK 1 | ||
| 481 | //tAllpass_setDelay(&r->f1_allpass, SAMP(30.51f)); | ||
| 482 | |||
| 483 | tDelayL_setDelay(&r->f1_delay_1, SAMP(141.69f)); | ||
| 484 | tDelayL_setDelay(&r->f1_delay_2, SAMP(89.24f)); | ||
| 485 | tDelayL_setDelay(&r->f1_delay_3, SAMP(125.f)); | ||
| 486 | |||
| 487 | // maybe change rate of SINE LFO's when size changes? | ||
| 488 | |||
| 489 | // FEEDBACK 2 | ||
| 490 | //tAllpass_setDelay(&r->f2_allpass, SAMP(22.58f)); | ||
| 491 | |||
| 492 | tDelayL_setDelay(&r->f2_delay_1, SAMP(149.62f)); | ||
| 493 | tDelayL_setDelay(&r->f2_delay_2, SAMP(60.48f)); | ||
| 494 | tDelayL_setDelay(&r->f2_delay_3, SAMP(106.28f)); | ||
| 459 | } | 495 | } |
| 460 | 496 | ||
| 461 | void tDattorro_setInputDelay (tDattorro* const r, float preDelay) | 497 | void tDattorro_setInputDelay (tDattorro* const r, float preDelay) |
| @@ -483,5 +519,4 @@ void tDattorro_setFeedbackFilter (tDattorro* const r, float freq) · 21 unmodified lines | |||
| 483 | void tDattorro_setFeedbackGain (tDattorro* const r, float gain) | 519 | void tDattorro_setFeedbackGain (tDattorro* const r, float gain) |
| 484 | { | 520 | { |
| 485 | r->feedback_gain = gain; | 521 | r->feedback_gain = gain; |
| 486 | } | 522 | } |
| 487 | |||
| @@ -9,7 +9,13 @@ · 8 unmodified lines | |||
| 9 | */ | 9 | */ |
| 10 | 10 | ||
| 11 | #ifndef LEAF_H_INCLUDED | 11 | #ifndef LEAF_H_INCLUDED |
| 12 | #define LEAF_H_INCLUDED | 12 | #define LEAF_H_INCLUDED |
| 13 | |||
| 14 | #define DEBUG 1 | ||
| 15 | |||
| 16 | #if DEBUG | ||
| 17 | #include "../JuceLibraryCode/JuceHeader.h" | ||
| 18 | #endif | ||
| 13 | 19 | ||
| 14 | #if _WIN32 || _WIN64 | 20 | #if _WIN32 || _WIN64 |
| 15 | 21 | ||
| @@ -18,19 +18,31 @@ static void run_pool_test(void); · 17 unmodified lines | |||
| 18 | 18 | ||
| 19 | tDattorro reverb; | 19 | tDattorro reverb; |
| 20 | 20 | ||
| 21 | |||
| 22 | tTapeDelay delay; | ||
| 23 | |||
| 24 | float size; | ||
| 25 | tRamp dtime; | ||
| 26 | |||
| 21 | 27 | ||
| 22 | void LEAFTest_init (float sampleRate, int blockSize) | 28 | void LEAFTest_init (float sampleRate, int blockSize) |
| 23 | { | 29 | { |
| 24 | LEAF_init(sampleRate, blockSize, &randomNumberGenerator); | 30 | LEAF_init(sampleRate, blockSize, &randomNumberGenerator); |
| 25 | 31 | ||
| 26 | tDattorro_init(&reverb); | 32 | tDattorro_init(&reverb); |
| 33 | |||
| 34 | //tTapeDelay_init(&delay, 0.5f * leaf.sampleRate, leaf.sampleRate); | ||
| 27 | 35 | ||
| 36 | tRamp_init(&dtime, 500.0f, 1); | ||
| 37 | |||
| 38 | |||
| 28 | setSliderValue("mix", reverb.mix); | 39 | setSliderValue("mix", reverb.mix); |
| 29 | setSliderValue("predelay", reverb.predelay / 200.0f); | 40 | setSliderValue("predelay", reverb.predelay / 200.0f); |
| 30 | setSliderValue("input filter", reverb.input_filter / 20000.0f); | 41 | setSliderValue("input filter", reverb.input_filter / 20000.0f); |
| 31 | setSliderValue("feedback filter", reverb.feedback_filter / 20000.0f); | 42 | setSliderValue("feedback filter", reverb.feedback_filter / 20000.0f); |
| 32 | setSliderValue("feedback gain", reverb.feedback_gain); | 43 | setSliderValue("feedback gain", reverb.feedback_gain); |
| 33 | //setSliderValue("size", reverb.size / 4.0f); | 44 | setSliderValue("size", reverb.size / 4.0f); |
| 45 | |||
| 34 | 46 | ||
| 35 | leaf_pool_report(); | 47 | leaf_pool_report(); |
| 36 | } | 48 | } |
| @@ -53,12 +65,20 @@ float LEAFTest_tick (float input) · 16 unmodified lines | |||
| 53 | input = 1.0f; | 65 | input = 1.0f; |
| 54 | } | 66 | } |
| 55 | #endif | 67 | #endif |
| 68 | //tTapeDelay_setDelay(&delay, tRamp_tick(&dtime)); | ||
| 69 | |||
| 70 | //return tTapeDelay_tick(&delay, input); | ||
| 71 | |||
| 72 | |||
| 73 | tDattorro_setSize(&reverb, tRamp_tick(&dtime)); | ||
| 56 | 74 | ||
| 57 | return tDattorro_tick(&reverb, input); | 75 | return tDattorro_tick(&reverb, input); |
| 76 | |||
| 58 | } | 77 | } |
| 59 | 78 | ||
| 60 | void LEAFTest_block (void) | 79 | void LEAFTest_block (void) |
| 61 | { | 80 | { |
| 81 | |||
| 62 | float val = getSliderValue("mix"); | 82 | float val = getSliderValue("mix"); |
| 63 | tDattorro_setMix(&reverb, val); | 83 | tDattorro_setMix(&reverb, val); |
| 64 | 84 | ||
| @@ -74,8 +94,13 @@ void LEAFTest_block (void) · 9 unmodified lines | |||
| 74 | val = getSliderValue("feedback gain"); | 94 | val = getSliderValue("feedback gain"); |
| 75 | tDattorro_setFeedbackGain(&reverb, val); | 95 | tDattorro_setFeedbackGain(&reverb, val); |
| 76 | 96 | ||
| 77 | //val = getSliderValue("size"); | 97 | val = getSliderValue("size"); |
| 78 | //tDattorro_setSize(&reverb, val * 4.0f); | 98 | tRamp_setDest(&dtime, val * reverb.size_max); |
| 99 | |||
| 100 | |||
| 101 | //float val = getSliderValue("size"); | ||
| 102 | //tRamp_setDest(&dtime, val * leaf.sampleRate + 1); | ||
| 103 | |||
| 79 | } | 104 | } |
| 80 | 105 | ||
| 81 | void LEAFTest_controllerInput (int cnum, float cval) | 106 | void LEAFTest_controllerInput (int cnum, float cval) |