History

jeff updates from working on vocodec over dec 22-26

spiricom committed 6 years ago

Commit 6e322e91 parent 61205ba16 files · +272 −91Browse files

Unified · Split

16 files
  1. .DS_Store +0 −0
  2. LEAF/.DS_Store +0 −0
  3. LEAF/Inc/.DS_Store +0 −0
  4. LEAF/Inc/leaf-distortion.h +16 −2
  5. LEAF/Inc/leaf-filters.h +3 −7
  6. LEAF/Inc/leaf-global.h +1 −1
  7. LEAF/Inc/leaf-math.h +16 −3
  8. LEAF/Inc/leaf-reverb.h +2 −1
  9. LEAF/Src/.DS_Store +0 −0
  10. LEAF/Src/leaf-distortion.c +21 −17
  11. LEAF/Src/leaf-effects.c +34 −20
  12. LEAF/Src/leaf-envelopes.c +6 −1
  13. LEAF/Src/leaf-filters.c +31 −42
  14. LEAF/Src/leaf-math.c +26 −0
  15. LEAF/Src/leaf-reverb.c +118 −1
  16. LEAF/Src/leaf.c +2 −0
.DS_Store+0−0

Binary file not shown.

LEAF/.DS_Store+0−0

Binary file not shown.

LEAF/Inc/.DS_Store+0−0

Binary file not shown.

LEAF/Inc/leaf-distortion.h+16−2
@@ -25,10 +25,24 @@ extern "C" { · 24 unmodified lines
2525
2626 typedef struct _tLockhartWavefolder
2727 {
28− double Ln1;
29− double Fn1;
28+ float Ln1;
29+ float Fn1;
3030 float xn1;
3131
32+ float RL;
33+ float R;
34+ float VT;
35+ float Is;
36+
37+ float a;
38+ float b;
39+ float d;
40+
41+ // Antialiasing error threshold
42+ float thresh;
43+ float half_a;
44+ float longthing;
45+
3246 } _tLockhartWavefolder;
3347
3448 typedef _tLockhartWavefolder* tLockhartWavefolder;
LEAF/Inc/leaf-filters.h+3−7
@@ -50,12 +50,8 @@ extern "C" { · 49 unmodified lines
5050 float gain;
5151 float a0,a1;
5252 float b0,b1;
53−
54− float coef;
55−
56− float freq;
57−
5853 float lastIn, lastOut;
54+
5955
6056 } _tOnePole;
6157
@@ -83,7 +79,7 @@ extern "C" { · 21 unmodified lines
8379
8480 float radius, frequency;
8581 oBool normalize;
86−
82+
8783 float lastOut[2];
8884
8985 } _tTwoPole;
@@ -288,7 +284,7 @@ extern "C" { · 198 unmodified lines
288284 {
289285 float gain;
290286
291− float N;
287+ int N;
292288
293289 tSVF low[NUM_SVF_BW];
294290 tSVF high[NUM_SVF_BW];
LEAF/Inc/leaf-global.h+1−1
@@ -20,7 +20,7 @@ typedef struct _LEAF · 19 unmodified lines
2020 float sampleRate;
2121 float invSampleRate;
2222 int blockSize;
23−
23+ float twoPiTimesInvSampleRate;
2424 float (*random)(void);
2525 } LEAF;
2626
LEAF/Inc/leaf-math.h+16−3
@@ -64,13 +64,16 @@ extern "C" { · 63 unmodified lines
6464 #define INV_LOG2 3.321928095f
6565
6666 #define SOS_M 343.0f
67−
67+#define TWO_TO_5 32.0f
68+#define INV_TWO_TO_5 0.03125f
6869 #define TWO_TO_7 128.f
6970 #define INV_TWO_TO_7 0.0078125f
7071 #define TWO_TO_8 256.f
7172 #define INV_TWO_TO_8 0.00390625f
72−#define TWO_TO_5 32.0f
73−#define INV_TWO_TO_5 0.03125f
73+#define TWO_TO_10 1024.f
74+#define INV_TWO_TO_10 0.0009765625f
75+#define TWO_TO_11 2048.f
76+#define INV_TWO_TO_11 0.00048828125f
7477 #define TWO_TO_12 4096.f
7578 #define INV_TWO_TO_12 0.00024414062f
7679 #define TWO_TO_15 32768.f
@@ -133,8 +136,18 @@ extern "C" { · 56 unmodified lines
133136
134137 #define LOGTEN 2.302585092994
135138
139+ float fast_mtof(float f);
140+
141+ float fastexpf(float x);
142+
143+ float fasterexpf(float x);
144+
136145 float mtof(float f);
137146
147+ float fast_mtof(float f);
148+
149+ float faster_mtof(float f);
150+
138151 float ftom(float f);
139152
140153 float powtodb(float f);
LEAF/Inc/leaf-reverb.h+2−1
@@ -136,8 +136,9 @@ extern "C" { · 135 unmodified lines
136136 void tDattorroReverb_free (tDattorroReverb* const);
137137
138138 float tDattorroReverb_tick (tDattorroReverb* const, float input);
139−
139+ void tDattorroReverb_tickStereo (tDattorroReverb* const rev, float input, float* output);
140140 void tDattorroReverb_setMix (tDattorroReverb* const, float mix);
141+ void tDattorroReverb_setHP (tDattorroReverb* const, float freq);
141142 void tDattorroReverb_setSize (tDattorroReverb* const, float size);
142143 void tDattorroReverb_setInputDelay (tDattorroReverb* const, float preDelay);
143144 void tDattorroReverb_setInputFilter (tDattorroReverb* const, float freq);
LEAF/Src/.DS_Store+0−0

Binary file not shown.

LEAF/Src/leaf-distortion.c+21−17
@@ -28,6 +28,20 @@ void tLockhartWavefolder_init(tLockhartWavefolder* const wf) · 27 unmodified lines
2828 w->Ln1 = 0.0;
2929 w->Fn1 = 0.0;
3030 w->xn1 = 0.0f;
31+
32+ w->RL = 7.5e3;
33+ w->R = 15e3;
34+ w->VT = 26e-3;
35+ w->Is = 10e-16;
36+
37+ w->a = 2.0*w->RL/w->R;
38+ w->b = (w->R+2.0*w->RL)/(w->VT*w->R);
39+ w->d = (w->RL*w->Is)/w->VT;
40+ w->half_a = 0.5f * w->a;
41+ w->longthing = (0.5*w->VT/w->b);
42+
43+ // Antialiasing error threshold
44+ w->thresh = 10e-10;
3145 }
3246
3347 void tLockhartWavefolder_free(tLockhartWavefolder* const wf)
@@ -73,37 +87,27 @@ float tLockhartWavefolder_tick(tLockhartWavefolder* const wf, float samp) · 39 unmodified lines
7387
7488 float out = 0.0f;
7589 // Constants
76− double RL = 7.5e3;
77− double R = 15e3;
78− double VT = 26e-3;
79− double Is = 10e-16;
80−
81− double a = 2.0*RL/R;
82− double b = (R+2.0*RL)/(VT*R);
83− double d = (RL*Is)/VT;
84−
85− // Antialiasing error threshold
86− double thresh = 10e-10;
90+
8791
8892 // Compute Antiderivative
8993 int l = (samp > 0) - (samp < 0);
90− double u = d*exp(l*b*samp);
94+ double u = w->d*exp(l*w->b*samp);
9195 double Ln = tLockhartWavefolderLambert(u,w->Ln1);
92− double Fn = (0.5*VT/b)*(Ln*(Ln + 2.0)) - 0.5*a*samp*samp;
96+ double Fn = w->longthing*(Ln*(Ln + 2.0)) - w->half_a*samp*samp;
9397
9498 // Check for ill-conditioning
95− if (fabs(samp-w->xn1)<thresh) {
99+ if (fabs(samp-w->xn1)<w->thresh) {
96100
97101 // Compute Averaged Wavefolder Output
98102 double xn = 0.5*(samp+w->xn1);
99− u = d*exp(l*b*xn);
103+ u = w->d*exp(l*w->b*xn);
100104 Ln = tLockhartWavefolderLambert(u,w->Ln1);
101− out = (float) (l*VT*Ln - a*xn);
105+ out = (float) (l*w->VT*Ln - w->a*xn);
102106 if (isnan(out))
103107 {
104108 ;
105109 }
106−
110+
107111 }
108112 else {
109113
LEAF/Src/leaf-effects.c+34−20
@@ -644,13 +644,17 @@ float* tAutotune_tick(tAutotune* const rt, float sample) · 643 unmodified lines
644644 {
645645 _tAutotune* r = *rt;
646646
647− r->inputPeriod = tPeriodDetection_findPeriod(&r->pd, sample);
648−
649− for (int v = 0; v < r->numVoices; ++v)
650− {
651− r->tickOutput[v] = tPitchShift_shiftToFreq(&r->ps[v], r->freq[v]);
652− }
653−
647+ float tempPeriod = tPeriodDetection_findPeriod(&r->pd, sample);
648+ if (tempPeriod < 1000.0f) //to avoid trying to follow consonants
649+ {
650+ r->inputPeriod = tempPeriod;
651+ }
652+
653+ for (int v = 0; v < r->numVoices; ++v)
654+ {
655+ r->tickOutput[v] = tPitchShift_shiftToFreq(&r->ps[v], r->freq[v]);
656+ }
657+
654658 return r->tickOutput;
655659 }
656660
@@ -1273,13 +1277,15 @@ void tFormantShifter_init(tFormantShifter* const fsr, int bufsize, int order) · 616 unmodified lines
12731277
12741278
12751279 fs->falph = powf(0.001f, 80.0f / (leaf.sampleRate));
1276− fs->flamb = -(0.8517f*sqrt(atanf(0.06583f*leaf.sampleRate))-0.1916f);
1280+ fs->flamb = -(0.8517f*sqrtf(atanf(0.06583f*leaf.sampleRate))-0.1916f);
12771281 fs->fhp = 0.0f;
12781282 fs->flp = 0.0f;
12791283 fs->flpa = powf(0.001f, 10.0f / (leaf.sampleRate));
12801284 fs->fmute = 1.0f;
12811285 fs->fmutealph = powf(0.001f, 1.0f / (leaf.sampleRate));
12821286 fs->cbi = 0;
1287+ fs->intensity = 1.0f;
1288+ fs->invIntensity = 1.0f;
12831289 }
12841290
12851291 void tFormantShifter_free(tFormantShifter* const fsr)
@@ -1314,12 +1320,11 @@ float tFormantShifter_remove(tFormantShifter* const fsr, float in) · 28 unmodified lines
13141320
13151321 in *= fs->intensity;
13161322
1317− float fa, fb, fc, foma, falph, ford, flpa, flamb, tf, fk;
1323+ float fa, fb, fc, foma, falph, ford, flamb, tf, fk;
13181324 int ti4;
13191325 ford = fs->ford;
13201326 falph = fs->falph;
13211327 foma = (1.0f - falph);
1322− flpa = fs->flpa;
13231328 flamb = fs->flamb;
13241329
13251330 tf = in;
@@ -1356,11 +1361,11 @@ float tFormantShifter_add(tFormantShifter* const fsr, float in) · 30 unmodified lines
13561361 {
13571362 _tFormantShifter* fs = *fsr;
13581363
1359− float fa, fb, fc, foma, falph, ford, flpa, flamb, tf, tf2, f0resp, f1resp, frlamb;
1364+ float fa, fb, fc, falph, ford, flpa, flamb, tf, tf2, f0resp, f1resp, frlamb;
13601365 int ti4;
13611366 ford = fs->ford;
13621367 falph = fs->falph;
1363− foma = (1.0f - falph);
1368+
13641369 flpa = fs->flpa;
13651370 flamb = fs->flamb;
13661371 tf = fs->shiftFactor * (1+flamb)/(1-flamb);
@@ -1368,7 +1373,7 @@ float tFormantShifter_add(tFormantShifter* const fsr, float in) · 1 unmodified line
13681373 ti4 = fs->cbi;
13691374
13701375 tf2 = in;
1371− fa = 0;
1376+ fa = 0.0f;
13721377 fb = fa;
13731378 for (int i=0; i<ford; i++)
13741379 {
@@ -1407,13 +1412,13 @@ float tFormantShifter_add(tFormantShifter* const fsr, float in) · 32 unmodified lines
14071412 tf = 2.0f*tf2;
14081413 tf2 = tf;
14091414 tf = (1.0f - f1resp + f0resp);
1410− if (tf!=0)
1415+ if (tf!=0.0f)
14111416 {
14121417 tf2 = (tf2 + f0resp) / tf;
14131418 }
14141419 else
14151420 {
1416− tf2 = 0;
1421+ tf2 = 0.0f;
14171422 }
14181423
14191424 // third time: update delay registers
@@ -1434,16 +1439,16 @@ float tFormantShifter_add(tFormantShifter* const fsr, float in) · 14 unmodified lines
14341439
14351440 // Bring up the gain slowly when formant correction goes from disabled
14361441 // to enabled, while things stabilize.
1437− if (fs->fmute>0.5)
1442+ if (fs->fmute>0.5f)
14381443 {
1439− tf = tf*(fs->fmute - 0.5)*2;
1444+ tf = tf*(fs->fmute - 0.5f)*2.0f;
14401445 }
14411446 else
14421447 {
1443− tf = 0;
1448+ tf = 0.0f;
14441449 }
14451450 tf2 = fs->fmutealph;
1446− fs->fmute = (1-tf2) + tf2*fs->fmute;
1451+ fs->fmute = (1.0f-tf2) + tf2*fs->fmute;
14471452 // now tf is signal output
14481453 // ...and we're done messing with formants
14491454
@@ -1461,5 +1466,14 @@ void tFormantShifter_setIntensity(tFormantShifter* const fsr, float intensity) · 11 unmodified lines
14611466 {
14621467 _tFormantShifter* fs = *fsr;
14631468 fs->intensity = intensity;
1464− fs->invIntensity = 1.0f/fs->intensity;
1469+ //make sure you don't divide by zero, doofies
1470+ if (fs->intensity != 0.0f)
1471+ {
1472+ fs->invIntensity = 1.0f/fs->intensity;
1473+ }
1474+ else
1475+ {
1476+ fs->invIntensity = 1.0f;
1477+ }
1478+
14651479 }
LEAF/Src/leaf-envelopes.c+6−1
@@ -514,7 +514,12 @@ float tRamp_tick(tRamp* const ramp) · 513 unmodified lines
514514
515515 r->curr += r->inc;
516516
517− if (((r->curr >= r->dest) && (r->inc > 0.0f)) || ((r->curr <= r->dest) && (r->inc < 0.0f))) r->inc = 0.0f;
517+ if (((r->curr >= r->dest) && (r->inc > 0.0f)) || ((r->curr <= r->dest) && (r->inc < 0.0f)))
518+ {
519+ r->inc = 0.0f;
520+ r->curr=r->dest;
521+ }
522+
518523 // Palle: There is a slight risk that you overshoot here and stay on dest+inc, which with a large inc value could be a real problem
519524 // I suggest you add: r->curr=r->dest in the true if case
520525
LEAF/Src/leaf-filters.c+31−42
@@ -279,7 +279,7 @@ void tTwoZero_setNotch(tTwoZero* const ft, float freq, float radius) · 278 unmodified lines
279279 f->radius = radius;
280280
281281 f->b2 = radius * radius;
282− f->b1 = -2.0f * radius * cosf(TWO_PI * freq * leaf.invSampleRate); // OPTIMIZE with LOOKUP or APPROXIMATION
282+ f->b1 = -2.0f * radius * cosf(freq * leaf.twoPiTimesInvSampleRate); // OPTIMIZE with LOOKUP or APPROXIMATION
283283
284284 // Normalize the filter gain. From STK.
285285 if ( f->b1 > 0.0f ) // Maximum at z = 0.
@@ -331,7 +331,7 @@ void tOnePole_init(tOnePole* const ft, float freq) · 45 unmodified lines
331331
332332 f->gain = 1.0f;
333333 f->a0 = 1.0;
334−
334+
335335 tOnePole_setFreq(ft, freq);
336336
337337 f->lastIn = 0.0f;
@@ -374,7 +374,7 @@ void tOnePole_setPole(tOnePole* const ft, float thePole) · 36 unmodified lines
374374 void tOnePole_setFreq (tOnePole* const ft, float freq)
375375 {
376376 _tOnePole* f = *ft;
377− f->b0 = freq * TWO_PI * leaf.invSampleRate;
377+ f->b0 = freq * leaf.twoPiTimesInvSampleRate;
378378 f->b0 = LEAF_clip(0.0f, f->b0, 1.0f);
379379 f->a1 = 1.0f - f->b0;
380380 }
@@ -462,7 +462,8 @@ void tTwoPole_setResonance(tTwoPole* const ft, float frequency, float radius, · 81 unmodified lines
462462 {
463463 _tTwoPole* f = *ft;
464464
465− if (frequency < 0.0f) frequency = 0.0f; // need to also handle when frequency > nyquist
465+ if (frequency < 0.0f) frequency = 0.0f;
466+ if (frequency > (leaf.sampleRate * 0.49f)) frequency = leaf.sampleRate * 0.49f;
466467 if (radius < 0.0f) radius = 0.0f;
467468 if (radius >= 1.0f) radius = 0.999999f;
468469
@@ -471,14 +472,14 @@ void tTwoPole_setResonance(tTwoPole* const ft, float frequency, float radius, · 2 unmodified lines
471472 f->normalize = normalize;
472473
473474 f->a2 = radius * radius;
474− f->a1 = -2.0f * radius * cos(TWO_PI * frequency * leaf.invSampleRate);
475+ f->a1 = -2.0f * radius * cosf(frequency * leaf.twoPiTimesInvSampleRate);
475476
476477 if ( normalize )
477478 {
478479 // Normalize the filter gain ... not terribly efficient.
479− float real = 1 - radius + (f->a2 - radius) * cos(TWO_PI * 2 * frequency * leaf.invSampleRate);
480− float imag = (f->a2 - radius) * sin(TWO_PI * 2 * frequency * leaf.invSampleRate);
481− f->b0 = sqrt( pow(real, 2) + pow(imag, 2) );
480+ float real = 1 - radius + (f->a2 - radius) * cosf(2 * frequency * leaf.twoPiTimesInvSampleRate);
481+ float imag = (f->a2 - radius) * sinf(2 * frequency * leaf.twoPiTimesInvSampleRate);
482+ f->b0 = sqrtf( powf(real, 2) + powf(imag, 2) );
482483 }
483484 }
484485
@@ -501,14 +502,14 @@ void tTwoPoleSampleRateChanged (tTwoPole* const ft) · 16 unmodified lines
501502 _tTwoPole* f = *ft;
502503
503504 f->a2 = f->radius * f->radius;
504− f->a1 = -2.0f * f->radius * cos(TWO_PI * f->frequency * leaf.invSampleRate);
505+ f->a1 = -2.0f * f->radius * cosf(f->frequency * leaf.twoPiTimesInvSampleRate);
505506
506507 if ( f->normalize )
507508 {
508509 // Normalize the filter gain ... not terribly efficient.
509− float real = 1 - f->radius + (f->a2 - f->radius) * cos(TWO_PI * 2 * f->frequency * leaf.invSampleRate);
510− float imag = (f->a2 - f->radius) * sin(TWO_PI * 2 * f->frequency * leaf.invSampleRate);
511− f->b0 = sqrt( pow(real, 2) + pow(imag, 2) );
510+ float real = 1 - f->radius + (f->a2 - f->radius) * cosf(2 * f->frequency * leaf.twoPiTimesInvSampleRate);
511+ float imag = (f->a2 - f->radius) * sinf(2 * f->frequency * leaf.twoPiTimesInvSampleRate);
512+ f->b0 = sqrtf( powf(real, 2) + powf(imag, 2) );
512513 }
513514 }
514515
@@ -663,8 +664,8 @@ void tBiQuad_setResonance(tBiQuad* const ft, float freq, float radius, oBool · 148 unmodified lines
663664 {
664665 _tBiQuad* f = *ft;
665666
666− // Should also deal with frequency being > half sample rate / nyquist. See STK
667667 if (freq < 0.0f) freq = 0.0f;
668+ if (freq > (leaf.sampleRate * 0.49f)) freq = leaf.sampleRate * 0.49f;
668669 if (radius < 0.0f) radius = 0.0f;
669670 if (radius >= 1.0f) radius = 1.0f;
670671
@@ -673,7 +674,7 @@ void tBiQuad_setResonance(tBiQuad* const ft, float freq, float radius, oBool · 2 unmodified lines
673674 f->normalize = normalize;
674675
675676 f->a2 = radius * radius;
676− f->a1 = -2.0f * radius * cosf(TWO_PI * freq * leaf.invSampleRate);
677+ f->a1 = -2.0f * radius * cosf(freq * leaf.twoPiTimesInvSampleRate);
677678
678679 if (normalize)
679680 {
@@ -687,12 +688,12 @@ void tBiQuad_setNotch(tBiQuad* const ft, float freq, float radius) · 7 unmodified lines
687688 {
688689 _tBiQuad* f = *ft;
689690
690− // Should also deal with frequency being > half sample rate / nyquist. See STK
691691 if (freq < 0.0f) freq = 0.0f;
692+ if (freq > (leaf.sampleRate * 0.49f)) freq = leaf.sampleRate * 0.49f;
692693 if (radius < 0.0f) radius = 0.0f;
693694
694695 f->b2 = radius * radius;
695− f->b1 = -2.0f * radius * cosf(TWO_PI * freq * leaf.invSampleRate); // OPTIMIZE with LOOKUP or APPROXIMATION
696+ f->b1 = -2.0f * radius * cosf(freq * leaf.twoPiTimesInvSampleRate); // OPTIMIZE with LOOKUP or APPROXIMATION
696697
697698 // Does not attempt to normalize filter gain.
698699 }
@@ -755,7 +756,7 @@ void tBiQuadSampleRateChanged(tBiQuad* const ft) · 56 unmodified lines
755756 {
756757 _tBiQuad* f = *ft;
757758 f->a2 = f->radius * f->radius;
758− f->a1 = -2.0f * f->radius * cosf(TWO_PI * f->frequency * leaf.invSampleRate);
759+ f->a1 = -2.0f * f->radius * cosf(f->frequency * leaf.twoPiTimesInvSampleRate);
759760
760761 if (f->normalize)
761762 {
@@ -770,7 +771,7 @@ void tHighpass_init(tHighpass* const ft, float freq) · 8 unmodified lines
770771 {
771772 _tHighpass* f = *ft = (_tHighpass*) leaf_alloc(sizeof(_tHighpass));
772773
773− f->R = (1.0f-((freq * 2.0f * 3.14f)* leaf.invSampleRate));
774+ f->R = (1.0f - (freq * leaf.twoPiTimesInvSampleRate));
774775 f->ys = 0.0f;
775776 f->xs = 0.0f;
776777
@@ -788,7 +789,7 @@ void tHighpass_setFreq(tHighpass* const ft, float freq) · 11 unmodified lines
788789 {
789790 _tHighpass* f = *ft;
790791 f->frequency = freq;
791− f->R = (1.0f-((freq * 2.0f * 3.14f) * leaf.invSampleRate));
792+ f->R = (1.0f - (freq * leaf.twoPiTimesInvSampleRate));
792793
793794 }
794795
@@ -813,7 +814,7 @@ void tHighpassSampleRateChanged(tHighpass* const ft) · 18 unmodified lines
813814 f->R = (1.0f-((f->frequency * 2.0f * 3.14f) * leaf.invSampleRate));
814815 }
815816
816−// Less efficient, more accurate version of SVF, in which cutoff frequency is taken as floating point Hz value and tanh
817+// Less efficient, more accurate version of SVF, in which cutoff frequency is taken as floating point Hz value and tanf
817818 // is calculated when frequency changes.
818819 void tSVF_init(tSVF* const svff, SVFType type, float freq, float Q)
819820 {
@@ -825,17 +826,11 @@ void tSVF_init(tSVF* const svff, SVFType type, float freq, float Q) · 5 unmodified lines
825826 svf->ic2eq = 0;
826827
827828 float a1,a2,a3,g,k;
828− g = tanf(PI * freq * leaf.invSampleRate);
829− k = 1.0f/Q;
830− a1 = 1.0f/(1.0f+g*(g+k));
831− a2 = g*a1;
832− a3 = g*a2;
833−
834− svf->g = g;
835− svf->k = k;
836− svf->a1 = a1;
837− svf->a2 = a2;
838− svf->a3 = a3;
829+ svf->g = tanf(PI * freq * leaf.invSampleRate);
830+ svf->k = 1.0f/Q;
831+ svf->a1 = 1.0f/(1.0f + svf->g * (svf->g + svf->k));
832+ svf->a2 = g*a1;
833+ svf->a3 = g*a2;
839834 }
840835
841836 void tSVF_free(tSVF* const svff)
@@ -896,17 +891,11 @@ void tEfficientSVF_init(tEfficientSVF* const svff, SVFType type, uint16_t inpu · 54 unmodified lines
896891 svf->ic2eq = 0;
897892
898893 float a1,a2,a3,g,k;
899− g = filtertan[input];
900− k = 1.0f/Q;
901− a1 = 1.0f/(1.0f+g*(g+k));
902− a2 = g*a1;
903− a3 = g*a2;
904−
905− svf->g = g;
906− svf->k = k;
907− svf->a1 = a1;
908− svf->a2 = a2;
909− svf->a3 = a3;
894+ svf->g = filtertan[input];
895+ svf->k = 1.0f/Q;
896+ svf->a1 = 1.0f/(1.0f+g*(g+k));
897+ svf->a2 = g*a1;
898+ svf->a3 = g*a2;
910899 }
911900
912901 void tEfficientSVF_free(tEfficientSVF* const svff)
LEAF/Src/leaf-math.c+26−0
@@ -73,6 +73,22 @@ float fastabsf(float f) · 72 unmodified lines
7373 return alias.f;
7474 }
7575
76+
77+float fastexpf(float x) {
78+ x = 1.0f + (x * 0.0009765625f);
79+ x *= x; x *= x; x *= x; x *= x;
80+ x *= x; x *= x; x *= x; x *= x;
81+ x *= x; x *= x;
82+ return x;
83+}
84+
85+float fasterexpf(float x) {
86+ x = 1.0 + (x * 0.00390625f);
87+ x *= x; x *= x; x *= x; x *= x;
88+ x *= x; x *= x; x *= x; x *= x;
89+ return x;
90+}
91+
7692 // fast floating-point exp2 function taken from Robert Bristow Johnson's
7793 // post in the music-dsp list on Date: Tue, 02 Sep 2014 16:50:11 -0400
7894 float fastexp2f(float x)
@@ -396,6 +412,16 @@ float mtof(float f) · 317 unmodified lines
396412 else return (8.17579891564f * expf(0.0577622650f * f));
397413 }
398414
415+float fast_mtof(float f)
416+{
417+ return (8.17579891564f * fastexpf(0.0577622650f * f));
418+}
419+
420+float faster_mtof(float f)
421+{
422+ return (8.17579891564f * fastexpf(0.0577622650f * f));
423+}
424+
399425 float ftom(float f)
400426 {
401427 return (f > 0 ? 17.3123405046f * logf(.12231220585f * f) : -1500.0f);
LEAF/Src/leaf-reverb.c+118−1
@@ -357,7 +357,7 @@ void tDattorroReverb_free (tDattorroReverb* const rev) · 356 unmodified lines
357357
358358 tOnePole_free(&r->f1_filter);
359359
360− tHighpass_free(&r->f2_hp);
360+ tHighpass_free(&r->f1_hp);
361361
362362 tCycle_free(&r->f1_lfo);
363363
@@ -479,12 +479,128 @@ float tDattorroReverb_tick (tDattorroReverb* const rev, float inp · 115 unmodified lines
479479 return (input * (1.0f - r->mix) + sample * r->mix);
480480 }
481481
482+void tDattorroReverb_tickStereo (tDattorroReverb* const rev, float input, float* output)
483+{
484+ _tDattorroReverb* r = *rev;
485+
486+ // INPUT
487+ float in_sample = tTapeDelay_tick(&r->in_delay, input);
488+
489+ in_sample = tOnePole_tick(&r->in_filter, in_sample);
490+
491+ for (int i = 0; i < 4; i++)
492+ {
493+ in_sample = tAllpass_tick(&r->in_allpass[i], in_sample);
494+ }
495+
496+ // FEEDBACK 1
497+ float f1_sample = in_sample + r->f2_last; // + f2_last_out;
498+
499+ tAllpass_setDelay(&r->f1_allpass, SAMP(30.51f) + tCycle_tick(&r->f1_lfo) * SAMP(4.0f));
500+
501+ f1_sample = tAllpass_tick(&r->f1_allpass, f1_sample);
502+
503+ f1_sample = tTapeDelay_tick(&r->f1_delay_1, f1_sample);
504+
505+ f1_sample = tOnePole_tick(&r->f1_filter, f1_sample);
506+
507+ f1_sample = f1_sample + r->f1_delay_2_last * 0.5f;
508+
509+ float f1_delay_2_sample = tTapeDelay_tick(&r->f1_delay_2, f1_sample * 0.5f);
510+
511+ r->f1_delay_2_last = f1_delay_2_sample;
512+
513+ f1_sample = r->f1_delay_2_last + f1_sample;
514+
515+ f1_sample = tHighpass_tick(&r->f1_hp, f1_sample);
516+
517+ f1_sample *= r->feedback_gain;
518+
519+ f1_sample = tanhf(f1_sample);
520+
521+ r->f1_last = tTapeDelay_tick(&r->f1_delay_3, f1_sample);
522+
523+ // FEEDBACK 2
524+ float f2_sample = in_sample + r->f1_last;
525+
526+ tAllpass_setDelay(&r->f2_allpass, SAMP(22.58f) + tCycle_tick(&r->f2_lfo) * SAMP(4.0f));
527+
528+ f2_sample = tAllpass_tick(&r->f2_allpass, f2_sample);
529+
530+ f2_sample = tTapeDelay_tick(&r->f2_delay_1, f2_sample);
531+
532+ f2_sample = tOnePole_tick(&r->f2_filter, f2_sample);
533+
534+ f2_sample = f2_sample + r->f2_delay_2_last * 0.5f;
535+
536+ float f2_delay_2_sample = tTapeDelay_tick(&r->f2_delay_2, f2_sample * 0.5f);
537+
538+ r->f2_delay_2_last = f2_delay_2_sample;
539+
540+ f2_sample = r->f2_delay_2_last + f2_sample;
541+
542+ f2_sample = tHighpass_tick(&r->f2_hp, f2_sample);
543+
544+ f2_sample *= r->feedback_gain;
545+
546+ f2_sample = tanhf(f2_sample);
547+
548+ r->f2_last = tTapeDelay_tick(&r->f2_delay_3, f2_sample);
549+
550+
551+ // TAP OUT 1
552+ f1_sample = tTapeDelay_tapOut(&r->f1_delay_1, SAMP(8.9f)) +
553+ tTapeDelay_tapOut(&r->f1_delay_1, SAMP(99.8f));
554+
555+ f1_sample -= tTapeDelay_tapOut(&r->f1_delay_2, SAMP(64.2f));
556+
557+ f1_sample += tTapeDelay_tapOut(&r->f1_delay_3, SAMP(67.f));
558+
559+ f1_sample -= tTapeDelay_tapOut(&r->f2_delay_1, SAMP(66.8f));
560+
561+ f1_sample -= tTapeDelay_tapOut(&r->f2_delay_2, SAMP(6.3f));
562+
563+ f1_sample -= tTapeDelay_tapOut(&r->f2_delay_3, SAMP(35.8f));
564+
565+ f1_sample *= 0.14f;
566+
567+ // TAP OUT 2
568+ f2_sample = tTapeDelay_tapOut(&r->f2_delay_1, SAMP(11.8f)) +
569+ tTapeDelay_tapOut(&r->f2_delay_1, SAMP(121.7f));
570+
571+ f2_sample -= tTapeDelay_tapOut(&r->f2_delay_2, SAMP(6.3f));
572+
573+ f2_sample += tTapeDelay_tapOut(&r->f2_delay_3, SAMP(89.7f));
574+
575+ f2_sample -= tTapeDelay_tapOut(&r->f1_delay_1, SAMP(70.8f));
576+
577+ f2_sample -= tTapeDelay_tapOut(&r->f1_delay_2, SAMP(11.2f));
578+
579+ f2_sample -= tTapeDelay_tapOut(&r->f1_delay_3, SAMP(4.1f));
580+
581+ f2_sample *= 0.14f;
582+
583+ output[0] = input * (1.0f - r->mix) + f1_sample * r->mix;
584+ output[1] = input * (1.0f - r->mix) + f2_sample * r->mix;
585+
586+}
587+
482588 void tDattorroReverb_setMix (tDattorroReverb* const rev, float mix)
483589 {
484590 _tDattorroReverb* r = *rev;
485591 r->mix = LEAF_clip(0.0f, mix, 1.0f);
486592 }
487593
594+
595+void tDattorroReverb_setHP (tDattorroReverb* const rev, float freq)
596+{
597+ _tDattorroReverb* r = *rev;
598+ float newFreq = LEAF_clip(20.0f, freq, 20000.0f);
599+ tHighpass_setFreq(&r->f1_hp, newFreq);
600+ tHighpass_setFreq(&r->f2_hp, newFreq);
601+}
602+
603+
488604 void tDattorroReverb_setSize (tDattorroReverb* const rev, float size)
489605 {
490606 _tDattorroReverb* r = *rev;
@@ -507,6 +623,7 @@ void tDattorroReverb_setSize (tDattorroReverb* const rev, float siz · 16 unmodified lines
507623 tTapeDelay_setDelay(&r->f1_delay_3, SAMP(125.f));
508624
509625 // maybe change rate of SINE LFO's when size changes?
626+ //tCycle_setFreq(&r->f2_lfo, 0.07f * size * r->size_max);
510627
511628 // FEEDBACK 2
512629 //tAllpass_setDelay(&r->f2_allpass, SAMP(22.58f));
LEAF/Src/leaf.c+2−0
@@ -30,6 +30,8 @@ void LEAF_init(float sr, int blocksize, char* memory, size_t memorysize, float(* · 29 unmodified lines
3030
3131 leaf.invSampleRate = 1.0f/sr;
3232
33+ leaf.twoPiTimesInvSampleRate = leaf.invSampleRate * TWO_PI;
34+
3335 leaf.random = random;
3436 }
3537

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