History

Dattorro reverb ugen working great.

mulshine committed 7 years ago

Commit 1af17391 parent 32bb7b98 files · +415 −219Browse files

Showing the changes to LEAF/Src_cpp/leaf-filter.cpp (1 of 8 files). Show all

Unified · Split

LEAF/Src_cpp/leaf-filter.cpp+46−6
@@ -20,7 +20,44 @@ · 19 unmodified lines
2020 #include "../Inc/leaf-wavetables.h"
2121 #include "../leaf.h"
2222
23−#endif
23+#endif
24+
25+// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ OnePole Filter ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ //
26+void tAllpass_init(tAllpass* const f, float initDelay, uint32_t maxDelay)
27+{
28+ f->gain = 0.7f;
29+
30+ f->lastOut = 0.0f;
31+
32+ tDelayL_init(&f->delay, initDelay, maxDelay);
33+}
34+
35+void tAllpass_setDelay(tAllpass* const f, float delay)
36+{
37+ tDelayL_setDelay(&f->delay, delay);
38+}
39+
40+void tAllpass_free(tAllpass* const f)
41+{
42+ leaf_free(&f->delay);
43+ leaf_free(f);
44+}
45+
46+void tAllpass_setGain(tAllpass* const f, float gain)
47+{
48+ f->gain = gain;
49+}
50+
51+float tAllpass_tick(tAllpass* const f, float input)
52+{
53+ float s1 = (-f->gain) * f->lastOut + input;
54+
55+ float s2 = tDelayL_tick(&f->delay, s1) + (f->gain) * input;
56+
57+ f->lastOut = s2;
58+
59+ return f->lastOut;
60+}
2461
2562 void tButterworth_init(tButterworth* const f, int N, float f1, float f2)
2663 {
@@ -239,12 +276,12 @@ void tTwoZeroSampleRateChanged(tTwoZero* const f) · 212 unmodified lines
239276 }
240277
241278 // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ OnePole Filter ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ //
242−void tOnePole_init(tOnePole* const f, float thePole)
279+void tOnePole_init(tOnePole* const f, float freq)
243280 {
244281 f->gain = 1.0f;
245282 f->a0 = 1.0;
246283
247− tOnePole_setPole(f, thePole);
284+ tOnePole_setFreq(f, freq);
248285
249286 f->lastIn = 0.0f;
250287 f->lastOut = 0.0f;
@@ -280,8 +317,11 @@ void tOnePole_setPole(tOnePole* const f, float thePole) · 29 unmodified lines
280317
281318 void tOnePole_setFreq (tOnePole* const f, float freq)
282319 {
283− f->a1 = expf(-2.0 * PI * freq);
284− f->b0 = 1.0f - f->a1;
320+ f->b0 = freq * TWO_PI * leaf.invSampleRate;
321+
322+ f->b0 = LEAF_clip(0.0f, f->b0, 1.0f);
323+
324+ f->a1 = 1.0f - f->b0;
285325 }
286326
287327 void tOnePole_setCoefficients(tOnePole* const f, float b0, float a1)
@@ -300,7 +340,7 @@ void tOnePole_setGain(tOnePole* const f, float gain) · 12 unmodified lines
300340 float tOnePole_tick(tOnePole* const f, float input)
301341 {
302342 float in = input * f->gain;
303− float out = (f->b0 * in) - (f->a1 * f->lastOut);
343+ float out = (f->b0 * in) + (f->a1 * f->lastOut);
304344
305345 f->lastIn = in;
306346 f->lastOut = out;

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