| @@ -33,11 +33,11 @@ void tDelay_initToPool (tDelay* const dl, uint32_t delay, uint32_t maxDelay · 32 unmodified lines |
| 33 | { | 33 | { |
| 34 | _tMempool* m = *mp; | 34 | _tMempool* m = *mp; |
| 35 | _tDelay* d = *dl = (_tDelay*) mpool_alloc(sizeof(_tDelay), m); | 35 | _tDelay* d = *dl = (_tDelay*) mpool_alloc(sizeof(_tDelay), m); |
| 36 | | 36 | |
| 37 | d->maxDelay = maxDelay; | 37 | d->maxDelay = maxDelay; |
| 38 | | 38 | |
| 39 | d->delay = delay; | 39 | d->delay = delay; |
| 40 | | 40 | |
| 41 | d->buff = (float*) mpool_alloc(sizeof(float) * maxDelay, m); | 41 | d->buff = (float*) mpool_alloc(sizeof(float) * maxDelay, m); |
| 42 | | 42 | |
| 43 | d->inPoint = 0; | 43 | d->inPoint = 0; |
| @@ -72,49 +72,49 @@ void tDelay_clear(tDelay* const dl) · 28 unmodified lines |
| 72 | float tDelay_tick (tDelay* const dl, float input) | 72 | float tDelay_tick (tDelay* const dl, float input) |
| 73 | { | 73 | { |
| 74 | _tDelay* d = *dl; | 74 | _tDelay* d = *dl; |
| 75 | | 75 | |
| 76 | // Input | 76 | // Input |
| 77 | d->lastIn = input; | 77 | d->lastIn = input; |
| 78 | d->buff[d->inPoint] = input * d->gain; | 78 | d->buff[d->inPoint] = input * d->gain; |
| 79 | if (++(d->inPoint) == d->maxDelay) d->inPoint = 0; | 79 | if (++(d->inPoint) == d->maxDelay) d->inPoint = 0; |
| 80 | | 80 | |
| 81 | // Output | 81 | // Output |
| 82 | d->lastOut = d->buff[d->outPoint]; | 82 | d->lastOut = d->buff[d->outPoint]; |
| 83 | if (++(d->outPoint) == d->maxDelay) d->outPoint = 0; | 83 | if (++(d->outPoint) == d->maxDelay) d->outPoint = 0; |
| 84 | | 84 | |
| 85 | return d->lastOut; | 85 | return d->lastOut; |
| 86 | } | 86 | } |
| 87 | | 87 | |
| 88 | int tDelay_setDelay (tDelay* const dl, uint32_t delay) | 88 | int tDelay_setDelay (tDelay* const dl, uint32_t delay) |
| 89 | { | 89 | { |
| 90 | _tDelay* d = *dl; | 90 | _tDelay* d = *dl; |
| 91 | | 91 | |
| 92 | d->delay = LEAF_clip(0.0f, delay, d->maxDelay); | 92 | d->delay = LEAF_clip(0.0f, delay, d->maxDelay); |
| 93 | | 93 | |
| 94 | // read chases write | 94 | // read chases write |
| 95 | if ( d->inPoint >= delay ) d->outPoint = d->inPoint - d->delay; | 95 | if ( d->inPoint >= delay ) d->outPoint = d->inPoint - d->delay; |
| 96 | else d->outPoint = d->maxDelay + d->inPoint - d->delay; | 96 | else d->outPoint = d->maxDelay + d->inPoint - d->delay; |
| 97 | | 97 | |
| 98 | return 0; | 98 | return 0; |
| 99 | } | 99 | } |
| 100 | | 100 | |
| 101 | float tDelay_tapOut (tDelay* const dl, uint32_t tapDelay) | 101 | float tDelay_tapOut (tDelay* const dl, uint32_t tapDelay) |
| 102 | { | 102 | { |
| 103 | _tDelay* d = *dl; | 103 | _tDelay* d = *dl; |
| 104 | | 104 | |
| 105 | int32_t tap = d->inPoint - tapDelay - 1; | 105 | int32_t tap = d->inPoint - tapDelay - 1; |
| 106 | | 106 | |
| 107 | // Check for wraparound. | 107 | // Check for wraparound. |
| 108 | while ( tap < 0 ) tap += d->maxDelay; | 108 | while ( tap < 0 ) tap += d->maxDelay; |
| 109 | | 109 | |
| 110 | return d->buff[tap]; | 110 | return d->buff[tap]; |
| 111 | | 111 | |
| 112 | } | 112 | } |
| 113 | | 113 | |
| 114 | void tDelay_tapIn (tDelay* const dl, float value, uint32_t tapDelay) | 114 | void tDelay_tapIn (tDelay* const dl, float value, uint32_t tapDelay) |
| 115 | { | 115 | { |
| 116 | _tDelay* d = *dl; | 116 | _tDelay* d = *dl; |
| 117 | | 117 | |
| 118 | int32_t tap = d->inPoint - tapDelay - 1; | 118 | int32_t tap = d->inPoint - tapDelay - 1; |
| 119 | | 119 | |
| 120 | // Check for wraparound. | 120 | // Check for wraparound. |
| @@ -181,17 +181,17 @@ void tLinearDelay_initToPool (tLinearDelay* const dl, float delay, uint32_t · 60 unmodified lines |
| 181 | { | 181 | { |
| 182 | _tMempool* m = *mp; | 182 | _tMempool* m = *mp; |
| 183 | _tLinearDelay* d = *dl = (_tLinearDelay*) mpool_alloc(sizeof(_tLinearDelay), m); | 183 | _tLinearDelay* d = *dl = (_tLinearDelay*) mpool_alloc(sizeof(_tLinearDelay), m); |
| 184 | | 184 | |
| 185 | d->maxDelay = maxDelay; | 185 | d->maxDelay = maxDelay; |
| 186 | | 186 | |
| 187 | if (delay > maxDelay) d->delay = maxDelay; | 187 | if (delay > maxDelay) d->delay = maxDelay; |
| 188 | else if (delay < 0.0f) d->delay = 0.0f; | 188 | else if (delay < 0.0f) d->delay = 0.0f; |
| 189 | else d->delay = delay; | 189 | else d->delay = delay; |
| 190 | | 190 | |
| 191 | d->buff = (float*) mpool_alloc(sizeof(float) * maxDelay, m); | 191 | d->buff = (float*) mpool_alloc(sizeof(float) * maxDelay, m); |
| 192 | | 192 | |
| 193 | d->gain = 1.0f; | 193 | d->gain = 1.0f; |
| 194 | | 194 | |
| 195 | d->lastIn = 0.0f; | 195 | d->lastIn = 0.0f; |
| 196 | d->lastOut = 0.0f; | 196 | d->lastOut = 0.0f; |
| 197 | | 197 | |
| @@ -222,9 +222,9 @@ void tLinearDelay_clear(tLinearDelay* const dl) · 24 unmodified lines |
| 222 | float tLinearDelay_tick (tLinearDelay* const dl, float input) | 222 | float tLinearDelay_tick (tLinearDelay* const dl, float input) |
| 223 | { | 223 | { |
| 224 | _tLinearDelay* d = *dl; | 224 | _tLinearDelay* d = *dl; |
| 225 | | 225 | |
| 226 | d->buff[d->inPoint] = input * d->gain; | 226 | d->buff[d->inPoint] = input * d->gain; |
| 227 | | 227 | |
| 228 | // Increment input pointer modulo length. | 228 | // Increment input pointer modulo length. |
| 229 | if (++(d->inPoint) == d->maxDelay ) d->inPoint = 0; | 229 | if (++(d->inPoint) == d->maxDelay ) d->inPoint = 0; |
| 230 | | 230 | |
| @@ -239,14 +239,14 @@ float tLinearDelay_tick (tLinearDelay* const dl, float input) · 8 unmodified lines |
| 239 | | 239 | |
| 240 | // Increment output pointer modulo length | 240 | // Increment output pointer modulo length |
| 241 | if ( (++d->outPoint) >= d->maxDelay ) d->outPoint = 0; | 241 | if ( (++d->outPoint) >= d->maxDelay ) d->outPoint = 0; |
| 242 | | 242 | |
| 243 | return d->lastOut; | 243 | return d->lastOut; |
| 244 | } | 244 | } |
| 245 | | 245 | |
| 246 | void tLinearDelay_tickIn (tLinearDelay* const dl, float input) | 246 | void tLinearDelay_tickIn (tLinearDelay* const dl, float input) |
| 247 | { | 247 | { |
| 248 | _tLinearDelay* d = *dl; | 248 | _tLinearDelay* d = *dl; |
| 249 | | 249 | |
| 250 | d->buff[d->inPoint] = input * d->gain; | 250 | d->buff[d->inPoint] = input * d->gain; |
| 251 | | 251 | |
| 252 | // Increment input pointer modulo length. | 252 | // Increment input pointer modulo length. |
| @@ -256,7 +256,7 @@ void tLinearDelay_tickIn (tLinearDelay* const dl, float input) · 3 unmodified lines |
| 256 | float tLinearDelay_tickOut (tLinearDelay* const dl) | 256 | float tLinearDelay_tickOut (tLinearDelay* const dl) |
| 257 | { | 257 | { |
| 258 | _tLinearDelay* d = *dl; | 258 | _tLinearDelay* d = *dl; |
| 259 | | 259 | |
| 260 | uint32_t idx = (uint32_t) d->outPoint; | 260 | uint32_t idx = (uint32_t) d->outPoint; |
| 261 | // First 1/2 of interpolation | 261 | // First 1/2 of interpolation |
| 262 | d->lastOut = d->buff[idx] * d->omAlpha; | 262 | d->lastOut = d->buff[idx] * d->omAlpha; |
| @@ -275,53 +275,53 @@ float tLinearDelay_tickOut (tLinearDelay* const dl) · 12 unmodified lines |
| 275 | int tLinearDelay_setDelay (tLinearDelay* const dl, float delay) | 275 | int tLinearDelay_setDelay (tLinearDelay* const dl, float delay) |
| 276 | { | 276 | { |
| 277 | _tLinearDelay* d = *dl; | 277 | _tLinearDelay* d = *dl; |
| 278 | | 278 | |
| 279 | d->delay = LEAF_clip(0.0f, delay, d->maxDelay); | 279 | d->delay = LEAF_clip(0.0f, delay, d->maxDelay); |
| 280 | | 280 | |
| 281 | float outPointer = d->inPoint - d->delay; | 281 | float outPointer = d->inPoint - d->delay; |
| 282 | | 282 | |
| 283 | while ( outPointer < 0 ) | 283 | while ( outPointer < 0 ) |
| 284 | outPointer += d->maxDelay; // modulo maximum length | 284 | outPointer += d->maxDelay; // modulo maximum length |
| 285 | | 285 | |
| 286 | d->outPoint = (uint32_t) outPointer; // integer part | 286 | d->outPoint = (uint32_t) outPointer; // integer part |
| 287 | | 287 | |
| 288 | d->alpha = outPointer - d->outPoint; // fractional part | 288 | d->alpha = outPointer - d->outPoint; // fractional part |
| 289 | d->omAlpha = 1.0f - d->alpha; | 289 | d->omAlpha = 1.0f - d->alpha; |
| 290 | | 290 | |
| 291 | if ( d->outPoint == d->maxDelay ) d->outPoint = 0; | 291 | if ( d->outPoint == d->maxDelay ) d->outPoint = 0; |
| 292 | | 292 | |
| 293 | return 0; | 293 | return 0; |
| 294 | } | 294 | } |
| 295 | | 295 | |
| 296 | float tLinearDelay_tapOut (tLinearDelay* const dl, uint32_t tapDelay) | 296 | float tLinearDelay_tapOut (tLinearDelay* const dl, uint32_t tapDelay) |
| 297 | { | 297 | { |
| 298 | _tLinearDelay* d = *dl; | 298 | _tLinearDelay* d = *dl; |
| 299 | | 299 | |
| 300 | uint32_t tap = d->inPoint - tapDelay - 1; | 300 | uint32_t tap = d->inPoint - tapDelay - 1; |
| 301 | // Check for wraparound. | 301 | // Check for wraparound. |
| 302 | while ( tap < 0 ) tap += d->maxDelay; | 302 | while ( tap < 0 ) tap += d->maxDelay; |
| 303 | | 303 | |
| 304 | return d->buff[tap]; | 304 | return d->buff[tap]; |
| 305 | } | 305 | } |
| 306 | | 306 | |
| 307 | void tLinearDelay_tapIn (tLinearDelay* const dl, float value, uint32_t tapDelay) | 307 | void tLinearDelay_tapIn (tLinearDelay* const dl, float value, uint32_t tapDelay) |
| 308 | { | 308 | { |
| 309 | _tLinearDelay* d = *dl; | 309 | _tLinearDelay* d = *dl; |
| 310 | | 310 | |
| 311 | uint32_t tap = d->inPoint - tapDelay - 1; | 311 | uint32_t tap = d->inPoint - tapDelay - 1; |
| 312 | | 312 | |
| 313 | // Check for wraparound. | 313 | // Check for wraparound. |
| 314 | while ( tap < 0 ) tap += d->maxDelay; | 314 | while ( tap < 0 ) tap += d->maxDelay; |
| 315 | | 315 | |
| 316 | d->buff[tap] = value; | 316 | d->buff[tap] = value; |
| 317 | } | 317 | } |
| 318 | | 318 | |
| 319 | float tLinearDelay_addTo (tLinearDelay* const dl, float value, uint32_t tapDelay) | 319 | float tLinearDelay_addTo (tLinearDelay* const dl, float value, uint32_t tapDelay) |
| 320 | { | 320 | { |
| 321 | _tLinearDelay* d = *dl; | 321 | _tLinearDelay* d = *dl; |
| 322 | | 322 | |
| 323 | int32_t tap = d->inPoint - tapDelay - 1; | 323 | int32_t tap = d->inPoint - tapDelay - 1; |
| 324 | | 324 | |
| 325 | // Check for wraparound. | 325 | // Check for wraparound. |
| 326 | while ( tap < 0 ) tap += d->maxDelay; | 326 | while ( tap < 0 ) tap += d->maxDelay; |
| 327 | | 327 | |
| @@ -579,15 +579,15 @@ void tAllpassDelay_initToPool (tAllpassDelay* const dl, float delay, uint32_ · 251 unmodified lines |
| 579 | { | 579 | { |
| 580 | _tMempool* m = *mp; | 580 | _tMempool* m = *mp; |
| 581 | _tAllpassDelay* d = *dl = (_tAllpassDelay*) mpool_alloc(sizeof(_tAllpassDelay), m); | 581 | _tAllpassDelay* d = *dl = (_tAllpassDelay*) mpool_alloc(sizeof(_tAllpassDelay), m); |
| 582 | | 582 | |
| 583 | d->maxDelay = maxDelay; | 583 | d->maxDelay = maxDelay; |
| 584 | | 584 | |
| 585 | if (delay > maxDelay) d->delay = maxDelay; | 585 | if (delay > maxDelay) d->delay = maxDelay; |
| 586 | else if (delay < 0.0f) d->delay = 0.0f; | 586 | else if (delay < 0.0f) d->delay = 0.0f; |
| 587 | else d->delay = delay; | 587 | else d->delay = delay; |
| 588 | | 588 | |
| 589 | d->buff = (float*) mpool_alloc(sizeof(float) * maxDelay, m); | 589 | d->buff = (float*) mpool_alloc(sizeof(float) * maxDelay, m); |
| 590 | | 590 | |
| 591 | d->gain = 1.0f; | 591 | d->gain = 1.0f; |
| 592 | | 592 | |
| 593 | d->lastIn = 0.0f; | 593 | d->lastIn = 0.0f; |
| @@ -622,43 +622,43 @@ void tAllpassDelay_clear(tAllpassDelay* const dl) · 28 unmodified lines |
| 622 | float tAllpassDelay_tick (tAllpassDelay* const dl, float input) | 622 | float tAllpassDelay_tick (tAllpassDelay* const dl, float input) |
| 623 | { | 623 | { |
| 624 | _tAllpassDelay* d = *dl; | 624 | _tAllpassDelay* d = *dl; |
| 625 | | 625 | |
| 626 | d->buff[d->inPoint] = input * d->gain; | 626 | d->buff[d->inPoint] = input * d->gain; |
| 627 | | 627 | |
| 628 | // Increment input pointer modulo length. | 628 | // Increment input pointer modulo length. |
| 629 | if ( ++(d->inPoint) >= d->maxDelay ) d->inPoint = 0; | 629 | if ( ++(d->inPoint) >= d->maxDelay ) d->inPoint = 0; |
| 630 | | 630 | |
| 631 | // Do allpass interpolation delay. | 631 | // Do allpass interpolation delay. |
| 632 | float out = d->lastOut * -d->coeff; | 632 | float out = d->lastOut * -d->coeff; |
| 633 | out += d->apInput + ( d->coeff * d->buff[d->outPoint] ); | 633 | out += d->apInput + ( d->coeff * d->buff[d->outPoint] ); |
| 634 | d->lastOut = out; | 634 | d->lastOut = out; |
| 635 | | 635 | |
| 636 | // Save allpass input | 636 | // Save allpass input |
| 637 | d->apInput = d->buff[d->outPoint]; | 637 | d->apInput = d->buff[d->outPoint]; |
| 638 | | 638 | |
| 639 | // Increment output pointer modulo length. | 639 | // Increment output pointer modulo length. |
| 640 | if (++(d->outPoint) >= d->maxDelay ) d->outPoint = 0; | 640 | if (++(d->outPoint) >= d->maxDelay ) d->outPoint = 0; |
| 641 | | 641 | |
| 642 | return d->lastOut; | 642 | return d->lastOut; |
| 643 | } | 643 | } |
| 644 | | 644 | |
| 645 | int tAllpassDelay_setDelay (tAllpassDelay* const dl, float delay) | 645 | int tAllpassDelay_setDelay (tAllpassDelay* const dl, float delay) |
| 646 | { | 646 | { |
| 647 | _tAllpassDelay* d = *dl; | 647 | _tAllpassDelay* d = *dl; |
| 648 | | 648 | |
| 649 | d->delay = LEAF_clip(0.5f, delay, d->maxDelay); | 649 | d->delay = LEAF_clip(0.5f, delay, d->maxDelay); |
| 650 | | 650 | |
| 651 | // outPoint chases inPoint | 651 | // outPoint chases inPoint |
| 652 | float outPointer = (float)d->inPoint - d->delay + 1.0f; | 652 | float outPointer = (float)d->inPoint - d->delay + 1.0f; |
| 653 | | 653 | |
| 654 | while ( outPointer < 0 ) outPointer += d->maxDelay; // mod max length | 654 | while ( outPointer < 0 ) outPointer += d->maxDelay; // mod max length |
| 655 | | 655 | |
| 656 | d->outPoint = (uint32_t) outPointer; // integer part | 656 | d->outPoint = (uint32_t) outPointer; // integer part |
| 657 | | 657 | |
| 658 | if ( d->outPoint >= d->maxDelay ) d->outPoint = 0; | 658 | if ( d->outPoint >= d->maxDelay ) d->outPoint = 0; |
| 659 | | 659 | |
| 660 | d->alpha = 1.0f + (float)d->outPoint - outPointer; // fractional part | 660 | d->alpha = 1.0f + (float)d->outPoint - outPointer; // fractional part |
| 661 | | 661 | |
| 662 | if ( d->alpha < 0.5f ) | 662 | if ( d->alpha < 0.5f ) |
| 663 | { | 663 | { |
| 664 | // The optimal range for alpha is about 0.5 - 1.5 in order to | 664 | // The optimal range for alpha is about 0.5 - 1.5 in order to |
| @@ -670,46 +670,46 @@ int tAllpassDelay_setDelay (tAllpassDelay* const dl, float delay) · 5 unmodified lines |
| 670 | | 670 | |
| 671 | d->alpha += 1.0f; | 671 | d->alpha += 1.0f; |
| 672 | } | 672 | } |
| 673 | | 673 | |
| 674 | d->coeff = (1.0f - d->alpha) / (1.0f + d->alpha); // coefficient for allpass | 674 | d->coeff = (1.0f - d->alpha) / (1.0f + d->alpha); // coefficient for allpass |
| 675 | | 675 | |
| 676 | return 0; | 676 | return 0; |
| 677 | } | 677 | } |
| 678 | | 678 | |
| 679 | float tAllpassDelay_tapOut (tAllpassDelay* const dl, uint32_t tapDelay) | 679 | float tAllpassDelay_tapOut (tAllpassDelay* const dl, uint32_t tapDelay) |
| 680 | { | 680 | { |
| 681 | _tAllpassDelay* d = *dl; | 681 | _tAllpassDelay* d = *dl; |
| 682 | | 682 | |
| 683 | int32_t tap = d->inPoint - tapDelay - 1; | 683 | int32_t tap = d->inPoint - tapDelay - 1; |
| 684 | | 684 | |
| 685 | // Check for wraparound. | 685 | // Check for wraparound. |
| 686 | while ( tap < 0 ) tap += d->maxDelay; | 686 | while ( tap < 0 ) tap += d->maxDelay; |
| 687 | | 687 | |
| 688 | return d->buff[tap]; | 688 | return d->buff[tap]; |
| 689 | | 689 | |
| 690 | } | 690 | } |
| 691 | | 691 | |
| 692 | void tAllpassDelay_tapIn (tAllpassDelay* const dl, float value, uint32_t tapDelay) | 692 | void tAllpassDelay_tapIn (tAllpassDelay* const dl, float value, uint32_t tapDelay) |
| 693 | { | 693 | { |
| 694 | _tAllpassDelay* d = *dl; | 694 | _tAllpassDelay* d = *dl; |
| 695 | | 695 | |
| 696 | int32_t tap = d->inPoint - tapDelay - 1; | 696 | int32_t tap = d->inPoint - tapDelay - 1; |
| 697 | | 697 | |
| 698 | // Check for wraparound. | 698 | // Check for wraparound. |
| 699 | while ( tap < 0 ) tap += d->maxDelay; | 699 | while ( tap < 0 ) tap += d->maxDelay; |
| 700 | | 700 | |
| 701 | d->buff[tap] = value; | 701 | d->buff[tap] = value; |
| 702 | } | 702 | } |
| 703 | | 703 | |
| 704 | float tAllpassDelay_addTo (tAllpassDelay* const dl, float value, uint32_t tapDelay) | 704 | float tAllpassDelay_addTo (tAllpassDelay* const dl, float value, uint32_t tapDelay) |
| 705 | { | 705 | { |
| 706 | _tAllpassDelay* d = *dl; | 706 | _tAllpassDelay* d = *dl; |
| 707 | | 707 | |
| 708 | int32_t tap = d->inPoint - tapDelay - 1; | 708 | int32_t tap = d->inPoint - tapDelay - 1; |
| 709 | | 709 | |
| 710 | // Check for wraparound. | 710 | // Check for wraparound. |
| 711 | while ( tap < 0 ) tap += d->maxDelay; | 711 | while ( tap < 0 ) tap += d->maxDelay; |
| 712 | | 712 | |
| 713 | return (d->buff[tap] += value); | 713 | return (d->buff[tap] += value); |
| 714 | } | 714 | } |
| 715 | | 715 | |
| @@ -759,20 +759,20 @@ void tTapeDelay_initToPool (tTapeDelay* const dl, float delay, uint32_t maxD · 43 unmodified lines |
| 759 | { | 759 | { |
| 760 | _tMempool* m = *mp; | 760 | _tMempool* m = *mp; |
| 761 | _tTapeDelay* d = *dl = (_tTapeDelay*) mpool_alloc(sizeof(_tTapeDelay), m); | 761 | _tTapeDelay* d = *dl = (_tTapeDelay*) mpool_alloc(sizeof(_tTapeDelay), m); |
| 762 | | 762 | |
| 763 | d->maxDelay = maxDelay; | 763 | d->maxDelay = maxDelay; |
| 764 | | 764 | |
| 765 | d->buff = (float*) mpool_alloc(sizeof(float) * maxDelay, m); | 765 | d->buff = (float*) mpool_alloc(sizeof(float) * maxDelay, m); |
| 766 | | 766 | |
| 767 | d->gain = 1.0f; | 767 | d->gain = 1.0f; |
| 768 | | 768 | |
| 769 | d->lastIn = 0.0f; | 769 | d->lastIn = 0.0f; |
| 770 | d->lastOut = 0.0f; | 770 | d->lastOut = 0.0f; |
| 771 | | 771 | |
| 772 | d->idx = 0.0f; | 772 | d->idx = 0.0f; |
| 773 | d->inc = 1.0f; | 773 | d->inc = 1.0f; |
| 774 | d->inPoint = 0; | 774 | d->inPoint = 0; |
| 775 | | 775 | |
| 776 | tTapeDelay_setDelay(dl, delay); | 776 | tTapeDelay_setDelay(dl, delay); |
| 777 | } | 777 | } |
| 778 | | 778 | |
| @@ -780,7 +780,7 @@ void tTapeDelay_freeFromPool(tTapeDelay* const dl, tMempool* const mp) · 1 unmodified line |
| 780 | { | 780 | { |
| 781 | _tMempool* m = *mp; | 781 | _tMempool* m = *mp; |
| 782 | _tTapeDelay* d = *dl; | 782 | _tTapeDelay* d = *dl; |
| 783 | | 783 | |
| 784 | mpool_free((char*)d->buff, m); | 784 | mpool_free((char*)d->buff, m); |
| 785 | mpool_free((char*)d, m); | 785 | mpool_free((char*)d, m); |
| 786 | } | 786 | } |
| @@ -799,28 +799,28 @@ void tTapeDelay_clear(tTapeDelay* const dl) · 12 unmodified lines |
| 799 | float tTapeDelay_tick (tTapeDelay* const dl, float input) | 799 | float tTapeDelay_tick (tTapeDelay* const dl, float input) |
| 800 | { | 800 | { |
| 801 | _tTapeDelay* d = *dl; | 801 | _tTapeDelay* d = *dl; |
| 802 | | 802 | |
| 803 | d->buff[d->inPoint] = input * d->gain; | 803 | d->buff[d->inPoint] = input * d->gain; |
| 804 | | 804 | |
| 805 | // Increment input pointer modulo length. | 805 | // Increment input pointer modulo length. |
| 806 | if (++(d->inPoint) == d->maxDelay ) d->inPoint = 0; | 806 | if (++(d->inPoint) == d->maxDelay ) d->inPoint = 0; |
| 807 | | 807 | |
| 808 | int idx = (int) d->idx; | 808 | int idx = (int) d->idx; |
| 809 | float alpha = d->idx - idx; | 809 | float alpha = d->idx - idx; |
| 810 | | 810 | |
| 811 | d->lastOut = LEAF_interpolate_hermite_x (d->buff[((idx - 1) + d->maxDelay) % d->maxDelay], | 811 | d->lastOut = LEAF_interpolate_hermite_x (d->buff[((idx - 1) + d->maxDelay) % d->maxDelay], |
| 812 | d->buff[idx], | 812 | d->buff[idx], |
| 813 | d->buff[(idx + 1) % d->maxDelay], | 813 | d->buff[(idx + 1) % d->maxDelay], |
| 814 | d->buff[(idx + 2) % d->maxDelay], | 814 | d->buff[(idx + 2) % d->maxDelay], |
| 815 | alpha); | 815 | alpha); |
| 816 | | 816 | |
| 817 | float diff = (d->inPoint - d->idx); | 817 | float diff = (d->inPoint - d->idx); |
| 818 | while (diff < 0.f) diff += d->maxDelay; | 818 | while (diff < 0.f) diff += d->maxDelay; |
| 819 | | 819 | |
| 820 | d->inc = 1.0f + (diff - d->delay) / d->delay; //* SMOOTH_FACTOR; | 820 | d->inc = 1.0f + (diff - d->delay) / d->delay; //* SMOOTH_FACTOR; |
| 821 | | 821 | |
| 822 | d->idx += d->inc; | 822 | d->idx += d->inc; |
| 823 | | 823 | |
| 824 | if (d->idx >= d->maxDelay) d->idx = 0.0f; | 824 | if (d->idx >= d->maxDelay) d->idx = 0.0f; |
| 825 | | 825 | |
| 826 | if (d->lastOut) | 826 | if (d->lastOut) |
| @@ -851,30 +851,30 @@ void tTapeDelay_setDelay (tTapeDelay* const dl, float delay) · 24 unmodified lines |
| 851 | float tTapeDelay_tapOut (tTapeDelay* const dl, float tapDelay) | 851 | float tTapeDelay_tapOut (tTapeDelay* const dl, float tapDelay) |
| 852 | { | 852 | { |
| 853 | _tTapeDelay* d = *dl; | 853 | _tTapeDelay* d = *dl; |
| 854 | | 854 | |
| 855 | float tap = (float) d->inPoint - tapDelay - 1.f; | 855 | float tap = (float) d->inPoint - tapDelay - 1.f; |
| 856 | | 856 | |
| 857 | // Check for wraparound. | 857 | // Check for wraparound. |
| 858 | while ( tap < 0.f ) tap += (float)d->maxDelay; | 858 | while ( tap < 0.f ) tap += (float)d->maxDelay; |
| 859 | | 859 | |
| 860 | int idx = (int) tap; | 860 | int idx = (int) tap; |
| 861 | | 861 | |
| 862 | float alpha = tap - idx; | 862 | float alpha = tap - idx; |
| 863 | | 863 | |
| 864 | float samp = LEAF_interpolate_hermite_x (d->buff[((idx - 1) + d->maxDelay) % d->maxDelay], | 864 | float samp = LEAF_interpolate_hermite_x (d->buff[((idx - 1) + d->maxDelay) % d->maxDelay], |
| 865 | d->buff[idx], | 865 | d->buff[idx], |
| 866 | d->buff[(idx + 1) % d->maxDelay], | 866 | d->buff[(idx + 1) % d->maxDelay], |
| 867 | d->buff[(idx + 2) % d->maxDelay], | 867 | d->buff[(idx + 2) % d->maxDelay], |
| 868 | alpha); | 868 | alpha); |
| 869 | | 869 | |
| 870 | return samp; | 870 | return samp; |
| 871 | | 871 | |
| 872 | } | 872 | } |
| 873 | | 873 | |
| 874 | void tTapeDelay_tapIn (tTapeDelay* const dl, float value, uint32_t tapDelay) | 874 | void tTapeDelay_tapIn (tTapeDelay* const dl, float value, uint32_t tapDelay) |
| 875 | { | 875 | { |
| 876 | _tTapeDelay* d = *dl; | 876 | _tTapeDelay* d = *dl; |
| 877 | | 877 | |
| 878 | int32_t tap = d->inPoint - tapDelay - 1; | 878 | int32_t tap = d->inPoint - tapDelay - 1; |
| 879 | | 879 | |
| 880 | // Check for wraparound. | 880 | // Check for wraparound. |