History

added inductor, inverted (both untested) and nonlinear components; single diode seems to work; should maybe not have separate WDF nonlinear class

Matthew Wang committed 7 years ago

Commit 4a5f1861 parent 17938cf3 files · +340 −128Browse files

Unified · Split

3 files
  1. LEAF/Inc/leaf-WDF.h +112 −71
  2. LEAF/Src/leaf-WDF.c +198 −43
  3. LEAF_JUCEPlugin/Source/MyTest.cpp +30 −14
LEAF/Inc/leaf-WDF.h+112−71
@@ -19,9 +19,119 @@ extern "C" { · 18 unmodified lines
1919
2020 //==============================================================================
2121
22−//---
23−//WDF resistor
22+typedef enum WDFComponentType
23+{
24+ SeriesAdaptor = 0,
25+ ParallelAdaptor,
26+ Resistor,
27+ Capacitor,
28+ Inductor,
29+ Inverter,
30+ ResistiveSource,
31+ ComponentNil
32+} WDFComponentType;
33+
34+typedef enum WDFRootType
35+{
36+ IdealSource = 0,
37+ Diode,
38+ DiodePair,
39+ RootNil
40+} WDFRootType;
41+
42+typedef struct _tWDF tWDF; // needed to allow tWDF pointers in struct
43+struct _tWDF
44+{
45+ WDFComponentType type;
46+ float port_resistance_up;
47+ float port_resistance_left;
48+ float port_resistance_right;
49+ float port_conductance_up;
50+ float port_conductance_left;
51+ float port_conductance_right;
52+ float incident_wave_up;
53+ float incident_wave_left;
54+ float incident_wave_right;
55+ float reflected_wave_up;
56+ float reflected_wave_left;
57+ float reflected_wave_right;
58+ float gamma_zero;
59+ float sample_rate;
60+ float value;
61+ tWDF* child_left;
62+ tWDF* child_right;
63+ tWDF* outpoint;
64+ float (*get_port_resistance)(tWDF* const);
65+ float (*get_reflected_wave)(tWDF* const);
66+ void (*set_incident_wave)(tWDF* const, float);
67+};
68+
69+typedef struct _tWDFNonlinear tWDFNonlinear;
70+struct _tWDFNonlinear
71+{
72+ WDFRootType type;
73+ tWDF* child;
74+ float (*calculate_reflected_wave)(tWDFNonlinear* const, float, float);
75+};
76+
77+//WDF Linear Components
78+void tWDF_init(tWDF* const r, WDFComponentType type, float value, tWDF* const rL, tWDF* const rR);
79+float tWDF_tick(tWDF* const r, tWDFNonlinear* const n, float sample, uint8_t paramsChanged);
80+
81+void tWDF_setValue(tWDF* const r, float value);
82+void tWDF_setSampleRate(tWDF* const r, float sample_rate);
83+void tWDF_setOutputPoint(tWDF* const r, tWDF* const outpoint);
84+uint8_t tWDF_isLeaf(tWDF* const r);
85+
86+tWDF* tWDF_findOutputPoint(tWDF* const r);
87+
88+float tWDF_getPortResistance(tWDF* const r);
89+float tWDF_getReflectedWave(tWDF* const r);
90+void tWDF_setIncidentWave(tWDF* const r, float incident_wave);
2491
92+float tWDF_getVoltage(tWDF* const r);
93+float tWDF_getCurrent(tWDF* const r);
94+
95+static float get_port_resistance_for_resistor(tWDF* const r);
96+static float get_port_resistance_for_capacitor(tWDF* const r);
97+static float get_port_resistance_for_inductor(tWDF* const r);
98+static float get_port_resistance_for_resistive(tWDF* const r);
99+static float get_port_resistance_for_inverter(tWDF* const r);
100+static float get_port_resistance_for_series(tWDF* const r);
101+static float get_port_resistance_for_parallel(tWDF* const r);
102+
103+static void set_incident_wave_for_leaf(tWDF* const r, float incident_wave);
104+static void set_incident_wave_for_leaf_inverted(tWDF* const r, float incident_wave);
105+static void set_incident_wave_for_inverter(tWDF* const r, float incident_wave);
106+static void set_incident_wave_for_series(tWDF* const r, float incident_wave);
107+static void set_incident_wave_for_parallel(tWDF* const r, float incident_wave);
108+
109+static float get_reflected_wave_for_resistor(tWDF* const r);
110+static float get_reflected_wave_for_capacitor(tWDF* const r);
111+static float get_reflected_wave_for_resistive(tWDF* const r);
112+static float get_reflected_wave_for_inverter(tWDF* const r);
113+static float get_reflected_wave_for_series(tWDF* const r);
114+static float get_reflected_wave_for_parallel(tWDF* const r);
115+
116+//WDF Nonlinear Roots
117+void tWDFNonlinear_init(tWDFNonlinear* const n, WDFRootType type, tWDF* const child);
118+float tWDFNonlinear_calculateReflectedWave(tWDFNonlinear* const n, float input, float incident_wave);
119+
120+static float calculate_reflected_wave_for_ideal(tWDFNonlinear* const n, float input, float incident_wave);
121+static float calculate_reflected_wave_for_diode(tWDFNonlinear* const n, float input, float incident_wave);
122+
123+
124+
125+
126+
127+
128+
129+
130+
131+
132+
133+
134+//WDF resistor
25135 typedef struct _tWDFresistor
26136 {
27137 float port_resistance;
@@ -111,75 +221,6 @@ float tWDFseriesAdaptor_getReflectedWave(tWDFseriesAdaptor* const r); · 83 unmodified lines
111221 float tWDFseriesAdaptor_getVoltage(tWDFseriesAdaptor* const r);
112222 float tWDFseriesAdaptor_getCurrent(tWDFseriesAdaptor* const r);
113223
114−//WDF component
115−typedef enum WDFComponentType
116−{
117− SeriesAdaptor = 0,
118− ParallelAdaptor,
119− Resistor,
120− Capacitor,
121− ResistiveSource,
122− ComponentNil
123−} WDFComponentType;
124−
125−typedef struct _tWDF tWDF; // needed to allow tWDF pointers in struct
126−struct _tWDF
127−{
128− WDFComponentType type;
129− float port_resistance_up;
130− float port_resistance_left;
131− float port_resistance_right;
132− float port_conductance_up;
133− float port_conductance_left;
134− float port_conductance_right;
135− float incident_wave_up;
136− float incident_wave_left;
137− float incident_wave_right;
138− float reflected_wave_up;
139− float reflected_wave_left;
140− float reflected_wave_right;
141− float gamma_zero;
142− float sample_rate;
143− float value;
144− tWDF* child_left;
145− tWDF* child_right;
146− tWDF* outpoint;
147− float (*get_port_resistance)(tWDF* const);
148− float (*get_reflected_wave)(tWDF* const);
149− void (*set_incident_wave)(tWDF* const, float);
150−};
151−
152−void tWDF_init(tWDF* const r, WDFComponentType type, float value, tWDF* const rL, tWDF* const rR);
153−float tWDF_tick(tWDF* const r, float sample, uint8_t paramsChanged);
154−
155−void tWDF_setValue(tWDF* const r, float value);
156−void tWDF_setSampleRate(tWDF* const r, float sample_rate);
157−void tWDF_setOutputPoint(tWDF* const r, tWDF* const outpoint);
158−uint8_t tWDF_isLeaf(tWDF* const r);
159−
160−tWDF* tWDF_findOutputPoint(tWDF* const r);
161−
162−float tWDF_getPortResistance(tWDF* const r);
163−float tWDF_getReflectedWave(tWDF* const r);
164−void tWDF_setIncidentWave(tWDF* const r, float incident_wave);
165−
166−float tWDF_getVoltage(tWDF* const r);
167−float tWDF_getCurrent(tWDF* const r);
168−
169−static float get_port_resistance_for_resistor(tWDF* const r);
170−static float get_port_resistance_for_capacitor(tWDF* const r);
171−static float get_port_resistance_for_series(tWDF* const r);
172−static float get_port_resistance_for_parallel(tWDF* const r);
173−
174−static void set_incident_wave_for_leaf(tWDF* const r, float incident_wave);
175−static void set_incident_wave_for_series(tWDF* const r, float incident_wave);
176−static void set_incident_wave_for_parallel(tWDF* const r, float incident_wave);
177−
178−static float get_reflected_wave_for_resistor(tWDF* const r);
179−static float get_reflected_wave_for_capacitor(tWDF* const r);
180−static float get_reflected_wave_for_series(tWDF* const r);
181−static float get_reflected_wave_for_parallel(tWDF* const r);
182−
183224 //==============================================================================
184225
185226 #ifdef __cplusplus
LEAF/Src/leaf-WDF.c+198−43
@@ -9,7 +9,6 @@ · 8 unmodified lines
99 #include "../Inc/leaf-WDF.h"
1010
1111 //WDF
12−
1312 void tWDF_init(tWDF* const r, WDFComponentType type, float value, tWDF* const rL, tWDF* const rR)
1413 {
1514 r->type = type;
@@ -24,35 +23,7 @@ void tWDF_init(tWDF* const r, WDFComponentType type, float value, tWDF* const rL · 8 unmodified lines
2423 r->reflected_wave_right = 0.0f;
2524 r->sample_rate = leaf.sampleRate;
2625 r->value = value;
27− if (r->type == SeriesAdaptor)
28− {
29− r->port_resistance_left = tWDF_getPortResistance(rL);
30− r->port_resistance_right = tWDF_getPortResistance(rR);
31− r->port_resistance_up = r->port_resistance_left + r->port_resistance_right;
32− r->port_conductance_up = 1.0f / r->port_resistance_up;
33− r->port_conductance_left = 1.0f / r->port_resistance_left;
34− r->port_conductance_right = 1.0f / r->port_resistance_right;
35− r->gamma_zero = 1.0f / (r->port_resistance_right + r->port_resistance_left);
36−
37− r->get_port_resistance = &get_port_resistance_for_series;
38− r->get_reflected_wave = &get_reflected_wave_for_series;
39− r->set_incident_wave = &set_incident_wave_for_series;
40− }
41− else if (r->type == ParallelAdaptor)
42− {
43− r->port_resistance_left = tWDF_getPortResistance(rL);
44− r->port_resistance_right = tWDF_getPortResistance(rR);
45− r->port_resistance_up = (r->port_resistance_left * r->port_resistance_right) / (r->port_resistance_left + r->port_resistance_right);
46− r->port_conductance_up = 1.0f / r->port_resistance_up;
47− r->port_conductance_left = 1.0f / r->port_resistance_left;
48− r->port_conductance_right = 1.0f / r->port_resistance_right;
49− r->gamma_zero = 1.0f / (r->port_resistance_right + r->port_resistance_left);
50−
51− r->get_port_resistance = &get_port_resistance_for_parallel;
52− r->get_reflected_wave = &get_reflected_wave_for_parallel;
53− r->set_incident_wave = &set_incident_wave_for_parallel;
54− }
55− else if (r->type == Resistor)
26+ if (r->type == Resistor)
5627 {
5728 r->port_resistance_up = r->value;
5829 r->port_conductance_up = 1.0f / r->value;
@@ -63,20 +34,71 @@ void tWDF_init(tWDF* const r, WDFComponentType type, float value, tWDF* const rL · 4 unmodified lines
6334 }
6435 else if (r->type == Capacitor)
6536 {
66− r->port_resistance_up = 1.0f / (r->sample_rate * 2.0f * r->value); //based on trapezoidal discretization
67− r->port_conductance_up = (1.0f / r->port_resistance_up);
68−
37+ r->port_conductance_up = r->sample_rate * 2.0f * r->value;
38+ r->port_resistance_up = 1.0f / r->port_conductance_up; //based on trapezoidal discretization
39+
6940 r->get_port_resistance = &get_port_resistance_for_capacitor;
7041 r->get_reflected_wave = &get_reflected_wave_for_capacitor;
7142 r->set_incident_wave = &set_incident_wave_for_leaf;
7243 }
44+ else if (r->type == Inductor)
45+ {
46+ r->port_resistance_up = r->sample_rate * 2.0f * r->value; //based on trapezoidal discretization
47+ r->port_conductance_up = 1.0f / r->port_resistance_up;
48+
49+ r->get_port_resistance = &get_port_resistance_for_inductor;
50+ r->get_reflected_wave = &get_reflected_wave_for_capacitor; // same as capacitor
51+ r->set_incident_wave = &set_incident_wave_for_leaf_inverted;
52+ }
7353 else if (r->type == ResistiveSource)
7454 {
75−
55+ r->port_resistance_up = 1.0f; // always use 1.0f for resistance
56+ r->port_conductance_up = 1.0f / 1.0f;
57+ // value is source voltage
58+ r->get_port_resistance = &get_port_resistance_for_resistive;
59+ r->get_reflected_wave = &get_reflected_wave_for_resistive;
60+ r->set_incident_wave = &set_incident_wave_for_leaf;
7661 }
77−}
78−
79−float tWDF_tick(tWDF* const r, float sample, uint8_t paramsChanged)
62+ else if (r->type == Inverter)
63+ {
64+ r->port_resistance_up = tWDF_getPortResistance(r->child_left);
65+ r->port_conductance_up = 1.0f / r->port_resistance_up;
66+
67+ r->get_port_resistance = &get_port_resistance_for_inverter;
68+ r->get_reflected_wave = &get_reflected_wave_for_inverter;
69+ r->set_incident_wave = &set_incident_wave_for_inverter;
70+ }
71+ else if (r->type == SeriesAdaptor)
72+ {
73+ r->port_resistance_left = tWDF_getPortResistance(r->child_left);
74+ r->port_resistance_right = tWDF_getPortResistance(r->child_right);
75+ r->port_resistance_up = r->port_resistance_left + r->port_resistance_right;
76+ r->port_conductance_up = 1.0f / r->port_resistance_up;
77+ r->port_conductance_left = 1.0f / r->port_resistance_left;
78+ r->port_conductance_right = 1.0f / r->port_resistance_right;
79+ r->gamma_zero = 1.0f / (r->port_resistance_right + r->port_resistance_left);
80+
81+ r->get_port_resistance = &get_port_resistance_for_series;
82+ r->get_reflected_wave = &get_reflected_wave_for_series;
83+ r->set_incident_wave = &set_incident_wave_for_series;
84+ }
85+ else if (r->type == ParallelAdaptor)
86+ {
87+ r->port_resistance_left = tWDF_getPortResistance(r->child_left);
88+ r->port_resistance_right = tWDF_getPortResistance(r->child_right);
89+ r->port_resistance_up = (r->port_resistance_left * r->port_resistance_right) / (r->port_resistance_left + r->port_resistance_right);
90+ r->port_conductance_up = 1.0f / r->port_resistance_up;
91+ r->port_conductance_left = 1.0f / r->port_resistance_left;
92+ r->port_conductance_right = 1.0f / r->port_resistance_right;
93+ r->gamma_zero = 1.0f / (r->port_resistance_right + r->port_resistance_left);
94+
95+ r->get_port_resistance = &get_port_resistance_for_parallel;
96+ r->get_reflected_wave = &get_reflected_wave_for_parallel;
97+ r->set_incident_wave = &set_incident_wave_for_parallel;
98+ }
99+}
100+
101+float tWDF_tick(tWDF* const r, tWDFNonlinear* const n, float sample, uint8_t paramsChanged)
80102 {
81103 //step 0 : update port resistances if something changed
82104 if (paramsChanged) tWDF_getPortResistance(r);
@@ -88,13 +110,13 @@ float tWDF_tick(tWDF* const r, float sample, uint8_t paramsChanged) · 5 unmodified lines
88110 float incident_wave = tWDF_getReflectedWave(r);
89111
90112 //step 3 : do root scattering computation
91− float reflected_wave = (2.0f * input) - incident_wave;
113+ float reflected_wave = tWDFNonlinear_calculateReflectedWave(n, input, incident_wave);
92114
93− //step 4 : propigate waves down the tree
115+ //step 4 : propogate waves down the tree
94116 tWDF_setIncidentWave(r, reflected_wave);
95117
96118 //step 5 : grab whatever voltages or currents we want as outputs
97− return -1.0f * tWDF_getVoltage(r->outpoint);
119+ return reflected_wave*0.5f + incident_wave*0.5f;//tWDF_getVoltage(r->outpoint);
98120 }
99121
100122 void tWDF_setValue(tWDF* const r, float value)
@@ -149,7 +171,10 @@ float tWDF_getCurrent(tWDF* const r) · 48 unmodified lines
149171 return (((r->incident_wave_up * 0.5f) - (r->reflected_wave_up * 0.5f)) * r->port_conductance_up);
150172 }
151173
152−// static functions to be pointed to
174+//============ Static Functions to be Pointed To ====================
175+//===================================================================
176+//============ Get and Calculate Port Resistances ===================
177+
153178 static float get_port_resistance_for_resistor(tWDF* const r)
154179 {
155180 r->port_resistance_up = r->value;
@@ -160,12 +185,33 @@ static float get_port_resistance_for_resistor(tWDF* const r) · 4 unmodified lines
160185
161186 static float get_port_resistance_for_capacitor(tWDF* const r)
162187 {
163− r->port_resistance_up = 1.0f / (r->sample_rate * 2.0f * r->value); //based on trapezoidal discretization
164− r->port_conductance_up = (1.0f / r->port_resistance_up);
188+ r->port_conductance_up = r->sample_rate * 2.0f * r->value; //based on trapezoidal discretization
189+ r->port_resistance_up = (1.0f / r->port_conductance_up);
165190
166191 return r->port_resistance_up;
167192 }
168193
194+static float get_port_resistance_for_inductor(tWDF* const r)
195+{
196+ r->port_resistance_up = r->sample_rate * 2.0f * r->value; //based on trapezoidal discretization
197+ r->port_conductance_up = (1.0f / r->port_resistance_up);
198+
199+ return r->port_resistance_up;
200+}
201+
202+static float get_port_resistance_for_resistive(tWDF* const r)
203+{
204+ return r->port_resistance_up;
205+}
206+
207+static float get_port_resistance_for_inverter(tWDF* const r)
208+{
209+ r->port_resistance_up = tWDF_getPortResistance(r->child_left);
210+ r->port_conductance_up = 1.0f / r->port_resistance_up;
211+
212+ return r->port_resistance_up;
213+}
214+
169215 static float get_port_resistance_for_series(tWDF* const r)
170216 {
171217 r->port_resistance_left = tWDF_getPortResistance(r->child_left);
@@ -192,11 +238,24 @@ static float get_port_resistance_for_parallel(tWDF* const r) · 20 unmodified lines
192238 return r->port_resistance_up;
193239 }
194240
241+//===================================================================
242+//================ Set Incident Waves ===============================
243+
195244 static void set_incident_wave_for_leaf(tWDF* const r, float incident_wave)
196245 {
197246 r->incident_wave_up = incident_wave;
198247 }
199248
249+static void set_incident_wave_for_leaf_inverted(tWDF* const r, float incident_wave)
250+{
251+ r->incident_wave_up = -1.0f * incident_wave;
252+}
253+
254+static void set_incident_wave_for_inverter(tWDF* const r, float incident_wave)
255+{
256+ tWDF_setIncidentWave(r->child_left, -1.0f * incident_wave);
257+}
258+
200259 static void set_incident_wave_for_series(tWDF* const r, float incident_wave)
201260 {
202261 float gamma_left = r->port_resistance_left * r->gamma_zero;
@@ -225,6 +284,9 @@ static void set_incident_wave_for_parallel(tWDF* const r, float incident_wave) · 22 unmodified lines
225284 tWDF_setIncidentWave(r->child_right, gamma_left * left_wave + (gamma_right - 1.0f) * right_wave + incident_wave);
226285 }
227286
287+//===================================================================
288+//================ Get Reflected Waves ==============================
289+
228290 static float get_reflected_wave_for_resistor(tWDF* const r)
229291 {
230292 r->reflected_wave_up = 0.0f;
@@ -237,6 +299,18 @@ static float get_reflected_wave_for_capacitor(tWDF* const r) · 6 unmodified lines
237299 return r->reflected_wave_up;
238300 }
239301
302+static float get_reflected_wave_for_resistive(tWDF* const r)
303+{
304+ r->reflected_wave_up = r->value;
305+ return r->reflected_wave_up;
306+}
307+
308+static float get_reflected_wave_for_inverter(tWDF* const r)
309+{
310+ r->reflected_wave_up = -1.0f * tWDF_getReflectedWave(r->child_left);
311+ return r->reflected_wave_up;
312+}
313+
240314 static float get_reflected_wave_for_series(tWDF* const r)
241315 {
242316 //-( downPorts[0]->a + downPorts[1]->a );
@@ -251,6 +325,87 @@ static float get_reflected_wave_for_parallel(tWDF* const r) · 8 unmodified lines
251325 return (gamma_left * tWDF_getReflectedWave(r->child_left) + gamma_right * tWDF_getReflectedWave(r->child_right));
252326 }
253327
328+// WDF Nonlinear
329+void tWDFNonlinear_init(tWDFNonlinear* const n, WDFRootType type, tWDF* const child)
330+{
331+ n->type = type;
332+ n->child = child;
333+ if (n->type == IdealSource)
334+ {
335+ n->calculate_reflected_wave = &calculate_reflected_wave_for_ideal;
336+ }
337+ else if (n->type == Diode)
338+ {
339+ n->calculate_reflected_wave = &calculate_reflected_wave_for_diode;
340+ }
341+ else if (n->type == DiodePair)
342+ {
343+ //n->calculate_reflected_wave = &calculate_reflected_wave_for_ideal;
344+ }
345+}
346+
347+float tWDFNonlinear_calculateReflectedWave(tWDFNonlinear* const n, float input, float incident_wave)
348+{
349+ return n->calculate_reflected_wave(n, input, incident_wave);
350+}
351+
352+static float calculate_reflected_wave_for_ideal(tWDFNonlinear* const n, float input, float incident_wave)
353+{
354+ return (2.0f * input) - incident_wave;
355+}
356+
357+static const float l2A = 0.1640425613334452f;
358+static const float l2B = -1.098865286222744f;
359+static const float l2Y = 3.148297929334117f;
360+static const float l2K = -2.213475204444817f;
361+static float log2Approximation(float x)
362+{
363+ return (l2A * x*x*x) + (l2B * x*x) + (l2Y * x) + l2K;
364+}
365+
366+static const float wX1 = -3.684303659906469f;
367+static const float wX2 = 1.972967391708859f;
368+static const float wA = 0.009451797158780131f;
369+static const float wB = 0.1126446405111627f;
370+static const float wY = 0.4451353886588814f;
371+static const float wK = 0.5836596684310648f;
372+
373+static float wrightOmega3(float x)
374+{
375+ if (x <= wX1)
376+ {
377+ return 0;
378+ }
379+ else if (x < wX2)
380+ {
381+ return (wA * x*x*x) + (wB * x*x) + (wY * x) + wK;
382+ }
383+ else
384+ {
385+ return x - logf(x);
386+ }
387+}
388+
389+static float wrightOmegaApproximation(float x)
390+{
391+ float w3 = wrightOmega3(x);
392+ return w3 - ((w3 - expf(x - w3)) / (w3 + 1.0f));
393+}
394+
395+static float lambertW(float a, float r, float I, float iVT)
396+{
397+ return wrightOmegaApproximation(((a + r*I) * iVT) + log((r * I) * iVT));
398+}
399+
400+#define Is_DIODE 2.52e-9
401+#define VT_DIODE 0.02585
402+static float calculate_reflected_wave_for_diode(tWDFNonlinear* const n, float input, float incident_wave)
403+{
404+ float a = incident_wave;
405+ float r = n->child->port_resistance_up;
406+ return a + 2.0f*r*Is_DIODE - 2.0f*VT_DIODE*lambertW(a, r, Is_DIODE, 1.0f/VT_DIODE);
407+}
408+
254409
255410
256411
LEAF_JUCEPlugin/Source/MyTest.cpp+30−14
@@ -20,11 +20,14 @@ tWDF r1; · 19 unmodified lines
2020 tWDF r2;
2121 tWDF c1;
2222 tWDF c2;
23+tWDF rs1;
2324 tWDF p1;
2425 tWDF s1;
2526 tWDF s2;
26−
27+tWDFNonlinear i;
28+tWDFNonlinear d;
2729 tNoise noise;
30+tCycle sine;
2831
2932 float gain;
3033 bool buttonState;
@@ -35,8 +38,11 @@ void LEAFTest_init (float sampleRate, int blockSize) · 4 unmodified lines
3538 LEAF_init(sampleRate, blockSize, &getRandomFloat);
3639
3740 tNoise_init(&noise, WhiteNoise);
41+ tCycle_init(&sine);
42+ tCycle_setFreq(&sine, 200);
3843
3944 //Bandpass circuit 1
45+ //use c1 for output voltage
4046 // tWDF_init(&r1, Resistor, 10000.0f, NULL, NULL);
4147 // tWDF_init(&r2, Resistor, 10000.0f, NULL, NULL);
4248 // tWDF_init(&c1, Capacitor, 0.000000159154943f, NULL, NULL);
@@ -46,25 +52,35 @@ void LEAFTest_init (float sampleRate, int blockSize) · 3 unmodified lines
4652 // tWDF_init(&s2, SeriesAdaptor, 0.0f, &s1, &p1);
4753
4854 //Bandpass circuit 2
55+// tWDF_init(&r1, Resistor, 10000.0f, NULL, NULL);
56+// tWDF_init(&c1, Capacitor, 0.000000159154943f, NULL, NULL);
57+// tWDF_init(&s1, SeriesAdaptor, 0.0f, &c1, &r1);
58+// tWDF_init(&r2, Resistor, 10000.0f, NULL, NULL);
59+// tWDF_init(&p1, ParallelAdaptor, 10000.0f, &s1, &r2);
60+// tWDF_init(&c2, Capacitor, 0.000000159154943f, NULL, NULL);
61+// tWDF_init(&s2, SeriesAdaptor, 0.0f, &c2, &p1);
62+
63+// tWDF_setOutputPoint(&s2, &c1);
64+
65+// tWDFNonlinear_init(&i, IdealSource, &s2);
66+
4967 tWDF_init(&r1, Resistor, 10000.0f, NULL, NULL);
50− tWDF_init(&c1, Capacitor, 0.000000159154943f, NULL, NULL);
51− tWDF_init(&s1, SeriesAdaptor, 0.0f, &c1, &r1);
52− tWDF_init(&r2, Resistor, 10000.0f, NULL, NULL);
53− tWDF_init(&p1, ParallelAdaptor, 10000.0f, &s1, &r2);
54− tWDF_init(&c2, Capacitor, 0.000000159154943f, NULL, NULL);
55− tWDF_init(&s2, SeriesAdaptor, 0.0f, &c2, &p1);
56−
68+ tWDF_init(&rs1, ResistiveSource, 0.0f, NULL, NULL);
69+ tWDF_init(&s1, SeriesAdaptor, 0.0f, &r1, &rs1);
5770
58− tWDF_setOutputPoint(&s2, &c1);
71+ tWDF_setOutputPoint(&s1, &r1);
72+
73+ tWDFNonlinear_init(&d, Diode, &r1);
5974
6075 leaf_pool_report();
6176 }
6277
6378 float LEAFTest_tick (float input)
6479 {
65− float sample = tNoise_tick(&noise);
80+ float sample = tCycle_tick(&sine);
6681
67− sample = tWDF_tick(&s2, sample, 1);
82+ tWDF_setValue(&rs1, sample*gain);
83+ sample = tWDF_tick(&s1, &d, sample, 1);
6884
6985 return sample;
7086 }
@@ -80,9 +96,9 @@ void LEAFTest_block (void) · 9 unmodified lines
8096 tWDF_setValue(&r1, val);
8197
8298 val = getSliderValue("mod depth");
83− val = 1.0f + 10000.0f * val;
84−
85− tWDF_setValue(&r2, val);
99+ val = 10.0f * val;
100+ gain = val;
101+ //tWDF_setValue(&r2, val);
86102 }
87103
88104 void LEAFTest_controllerInput (int cnum, float cval)

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