History

leaf version used in vocodec that was sent to beta testers

spiricom committed 6 years ago

Commit 5c365ac1 parent 99c38dd5 files · +123 −108Browse files

Unified · Split

5 files
  1. leaf/Inc/leaf-filters.h +0 −1
  2. leaf/Src/leaf-delay.c +88 −88
  3. leaf/Src/leaf-effects.c +3 −1
  4. leaf/Src/leaf-envelopes.c +6 −0
  5. leaf/Src/leaf-sampling.c +26 −18
leaf/Inc/leaf-filters.h+0−1
@@ -415,7 +415,6 @@ extern "C" { · 414 unmodified lines
415 float cL, cB, cH; // coefficients for low-, band-, and highpass signals415 float cL, cB, cH; // coefficients for low-, band-, and highpass signals
416 416
417 // parameters:417 // parameters:
418 float fs; // sample-rate
419 float fc; // characteristic frequency418 float fc; // characteristic frequency
420 float G; // gain419 float G; // gain
421 float invG; //1/gain420 float invG; //1/gain
leaf/Src/leaf-delay.c+88−88
@@ -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
72float tDelay_tick (tDelay* const dl, float input)72float tDelay_tick (tDelay* const dl, float input)
73{73{
74 _tDelay* d = *dl;74 _tDelay* d = *dl;
75 75
76 // Input76 // 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 // Output81 // 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
88int tDelay_setDelay (tDelay* const dl, uint32_t delay)88int 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 write94 // 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
101float tDelay_tapOut (tDelay* const dl, uint32_t tapDelay)101float 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
114void tDelay_tapIn (tDelay* const dl, float value, uint32_t tapDelay)114void 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
222float tLinearDelay_tick (tLinearDelay* const dl, float input)222float 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 length240 // 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
246void tLinearDelay_tickIn (tLinearDelay* const dl, float input)246void 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
256float tLinearDelay_tickOut (tLinearDelay* const dl)256float 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 interpolation261 // 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
275int tLinearDelay_setDelay (tLinearDelay* const dl, float delay)275int 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 length284 outPointer += d->maxDelay; // modulo maximum length
285 285
286 d->outPoint = (uint32_t) outPointer; // integer part286 d->outPoint = (uint32_t) outPointer; // integer part
287 287
288 d->alpha = outPointer - d->outPoint; // fractional part288 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
296float tLinearDelay_tapOut (tLinearDelay* const dl, uint32_t tapDelay)296float 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
307void tLinearDelay_tapIn (tLinearDelay* const dl, float value, uint32_t tapDelay)307void 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
319float tLinearDelay_addTo (tLinearDelay* const dl, float value, uint32_t tapDelay)319float 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
622float tAllpassDelay_tick (tAllpassDelay* const dl, float input)622float 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 input636 // 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
645int tAllpassDelay_setDelay (tAllpassDelay* const dl, float delay)645int 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 inPoint651 // 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 length654 while ( outPointer < 0 ) outPointer += d->maxDelay; // mod max length
655 655
656 d->outPoint = (uint32_t) outPointer; // integer part656 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 part660 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 to664 // 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 allpass674 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
679float tAllpassDelay_tapOut (tAllpassDelay* const dl, uint32_t tapDelay)679float 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
692void tAllpassDelay_tapIn (tAllpassDelay* const dl, float value, uint32_t tapDelay)692void 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
704float tAllpassDelay_addTo (tAllpassDelay* const dl, float value, uint32_t tapDelay)704float 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
799float tTapeDelay_tick (tTapeDelay* const dl, float input)799float 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
851float tTapeDelay_tapOut (tTapeDelay* const dl, float tapDelay)851float 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
874void tTapeDelay_tapIn (tTapeDelay* const dl, float value, uint32_t tapDelay)874void 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.
leaf/Src/leaf-effects.c+3−1
@@ -859,12 +859,14 @@ float tVocoder_tick (tVocoder* const voc, float synth, float voice) · 858 unmodified lines
859 859
860 v->kout = oo;860 v->kout = oo;
861 v->kval = k & 0x1;861 v->kval = k & 0x1;
862#ifdef NO_DENORMAL_CHECK
863#else
862 if(fabs(v->f[0][11])<1.0e-10) v->f[0][11] = 0.0f; //catch HF envelope denormal864 if(fabs(v->f[0][11])<1.0e-10) v->f[0][11] = 0.0f; //catch HF envelope denormal
863 865
864 for(i=1;i<nb;i++)866 for(i=1;i<nb;i++)
865 if(fabs(v->f[i][3])<1.0e-10 || fabs(v->f[i][7])<1.0e-10)867 if(fabs(v->f[i][3])<1.0e-10 || fabs(v->f[i][7])<1.0e-10)
866 for(k=3; k<12; k++) v->f[i][k] = 0.0f; //catch reson & envelope denormals868 for(k=3; k<12; k++) v->f[i][k] = 0.0f; //catch reson & envelope denormals
867 869#endif
868 if(fabs(o)>10.0f) tVocoder_suspend(voc); //catch instability870 if(fabs(o)>10.0f) tVocoder_suspend(voc); //catch instability
869 871
870 return o;872 return o;
leaf/Src/leaf-envelopes.c+6−0
@@ -1559,7 +1559,10 @@ float tSlide_tickNoInput(tSlide* const sl) · 1558 unmodified lines
1559 {1559 {
1560 s->currentOut = s->prevOut + ((in - s->prevOut) * s->invDownSlide);1560 s->currentOut = s->prevOut + ((in - s->prevOut) * s->invDownSlide);
1561 }1561 }
1562#ifdef NO_DENORMAL_CHECK
1563#else
1562 if (s->currentOut < VSF) s->currentOut = 0.0f;1564 if (s->currentOut < VSF) s->currentOut = 0.0f;
1565#endif
1563 s->prevIn = in;1566 s->prevIn = in;
1564 s->prevOut = s->currentOut;1567 s->prevOut = s->currentOut;
1565 return s->currentOut;1568 return s->currentOut;
@@ -1578,7 +1581,10 @@ float tSlide_tick(tSlide* const sl, float in) · 12 unmodified lines
1578 {1581 {
1579 s->currentOut = s->prevOut + ((in - s->prevOut) * s->invDownSlide);1582 s->currentOut = s->prevOut + ((in - s->prevOut) * s->invDownSlide);
1580 }1583 }
1584#ifdef NO_DENORMAL_CHECK
1585#else
1581 if (s->currentOut < VSF) s->currentOut = 0.0f;1586 if (s->currentOut < VSF) s->currentOut = 0.0f;
1587#endif
1582 s->prevIn = in;1588 s->prevIn = in;
1583 s->prevOut = s->currentOut;1589 s->prevOut = s->currentOut;
1584 return s->currentOut;1590 return s->currentOut;
leaf/Src/leaf-sampling.c+26−18
@@ -268,12 +268,12 @@ float tSampler_tick (tSampler* const sp) · 267 unmodified lines
268 float* buff = p->samp->buff;268 float* buff = p->samp->buff;
269 269
270 // Variables so start is also before end270 // Variables so start is also before end
271 int32_t start = p->start;271 int myStart = p->start;
272 int32_t end = p->end;272 int myEnd = p->end;
273 if (p->flip < 0)273 if (p->flip < 0)
274 {274 {
275 start = p->end;275 myStart = p->end;
276 end = p->start;276 myEnd = p->start;
277 }277 }
278 278
279 // Get the direction and a reverse flag for some calcs279 // Get the direction and a reverse flag for some calcs
@@ -306,17 +306,17 @@ float tSampler_tick (tSampler* const sp) · 26 unmodified lines
306 buff[i4],306 buff[i4],
307 alpha);307 alpha);
308 308
309 uint32_t cfxlen = p->cfxlen;309 int32_t cfxlen = p->cfxlen;
310 if (p->len * 0.25f < cfxlen) cfxlen = p->len * 0.25f;310 if (p->len * 0.25f < cfxlen) cfxlen = p->len * 0.25f;
311 311
312 // Determine crossfade points312 // Determine crossfade points
313 uint32_t fadeLeftStart = 0;313 int32_t fadeLeftStart = 0;
314 if (start >= cfxlen) fadeLeftStart = start - cfxlen;314 if (myStart >= cfxlen) fadeLeftStart = myStart - cfxlen;
315 uint32_t fadeLeftEnd = fadeLeftStart + cfxlen;315 int32_t fadeLeftEnd = fadeLeftStart + cfxlen;
316 316
317 uint32_t fadeRightEnd = end;// + (fadeLeftEnd - start);317 int32_t fadeRightEnd = myEnd;// + (fadeLeftEnd - start);
318 // if (fadeRightEnd >= length) fadeRightEnd = length - 1;318 // if (fadeRightEnd >= length) fadeRightEnd = length - 1;
319 uint32_t fadeRightStart = fadeRightEnd - cfxlen;319 int32_t fadeRightStart = fadeRightEnd - cfxlen;
320 320
321 321
322 322
@@ -401,7 +401,7 @@ float tSampler_tick (tSampler* const sp) · 78 unmodified lines
401 }401 }
402 }402 }
403 403
404 float inc = fmod(p->inc, p->len);404 float inc = fmodf(p->inc, (float)p->len);
405 p->idx += (dir * inc);405 p->idx += (dir * inc);
406 if (p->flipStart >= 0)406 if (p->flipStart >= 0)
407 {407 {
@@ -424,11 +424,11 @@ float tSampler_tick (tSampler* const sp) · 16 unmodified lines
424 424
425 if (p->mode == PlayLoop)425 if (p->mode == PlayLoop)
426 {426 {
427 if((int)p->idx < start)427 if((int)p->idx < myStart)
428 {428 {
429 p->idx += (float)(fadeRightEnd - fadeLeftEnd);429 p->idx += (float)(fadeRightEnd - fadeLeftEnd);
430 }430 }
431 if((int)p->idx > end)431 if((int)p->idx > myEnd)
432 {432 {
433 433
434 p->idx -= (float)(fadeRightEnd - fadeLeftEnd);434 p->idx -= (float)(fadeRightEnd - fadeLeftEnd);
@@ -436,22 +436,30 @@ float tSampler_tick (tSampler* const sp) · 1 unmodified line
436 }436 }
437 else if (p->mode == PlayBackAndForth)437 else if (p->mode == PlayBackAndForth)
438 {438 {
439 if (p->idx < start)439 if (p->idx < myStart)
440 {440 {
441 p->bnf = -p->bnf;441 p->bnf = -p->bnf;
442 p->idx = start + 1;442 p->idx = myStart + 1;
443 }443 }
444 else if (p->idx > end)444 else if (p->idx > myEnd)
445 {445 {
446 p->bnf = -p->bnf;446 p->bnf = -p->bnf;
447 p->idx = end - 1;447 p->idx = myEnd - 1;
448 }448 }
449 }449 }
450 450
451 451
452 if (p->mode == PlayNormal)452 if (p->mode == PlayNormal)
453 {453 {
454 float ticksToEnd = rev ? ((idx - start) * p->iinc) : ((end - idx) * p->iinc);454 if (p->idx < myStart)
455 {
456 p->idx = myStart;
457 }
458 else if (p->idx > myEnd)
459 {
460 p->idx = myEnd;
461 }
462 float ticksToEnd = rev ? ((idx - myStart) * p->iinc) : ((myEnd - idx) * p->iinc);
455 if (ticksToEnd < (0.007f * leaf.sampleRate))463 if (ticksToEnd < (0.007f * leaf.sampleRate))
456 {464 {
457 tRamp_setDest(&p->gain, 0.f);465 tRamp_setDest(&p->gain, 0.f);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t