shithub: leaf

Download patch

ref: 17938cf32356239d02625a3aa9b33321605aaf25
parent: f3bfe55e7d09ae5b44221279f481575fe74b5a2a
author: Matthew Wang <Matthew@nat-oitwireless-inside-vapornet100-10-9-79-190.princeton.edu>
date: Fri Sep 27 13:17:46 EDT 2019

WDF changes and added to JUCE project

binary files a/LEAF/Inc/.DS_Store b/LEAF/Inc/.DS_Store differ
--- a/LEAF/Inc/leaf-WDF.h
+++ b/LEAF/Inc/leaf-WDF.h
@@ -143,18 +143,26 @@
 	float value;
 	tWDF* child_left;
 	tWDF* child_right;
+    tWDF* outpoint;
 	float (*get_port_resistance)(tWDF* const);
 	float (*get_reflected_wave)(tWDF* const);
 	void (*set_incident_wave)(tWDF* const, float);
 };
 
-void tWDF_init(tWDF* const r, WDFComponentType type, float value, tWDF* const rL, tWDF* const rR, float sample_rate);
+void tWDF_init(tWDF* const r, WDFComponentType type, float value, tWDF* const rL, tWDF* const rR);
 float tWDF_tick(tWDF* const r, float sample, uint8_t paramsChanged);
+    
 void tWDF_setValue(tWDF* const r, float value);
+void tWDF_setSampleRate(tWDF* const r, float sample_rate);
+void tWDF_setOutputPoint(tWDF* const r, tWDF* const outpoint);
+uint8_t tWDF_isLeaf(tWDF* const r);
+    
+tWDF* tWDF_findOutputPoint(tWDF* const r);
+    
 float tWDF_getPortResistance(tWDF* const r);
-void tWDF_setPortResistances(tWDF* const r);
 float tWDF_getReflectedWave(tWDF* const r);
 void tWDF_setIncidentWave(tWDF* const r, float incident_wave);
+    
 float tWDF_getVoltage(tWDF* const r);
 float tWDF_getCurrent(tWDF* const r);
 
@@ -172,6 +180,10 @@
 static float get_reflected_wave_for_series(tWDF* const r);
 static float get_reflected_wave_for_parallel(tWDF* const r);
 
-
+//==============================================================================
+    
+#ifdef __cplusplus
+}
+#endif
 
 #endif /* LEAF_INC_LEAF_WDF_H_ */
--- a/LEAF/Src/leaf-WDF.c
+++ b/LEAF/Src/leaf-WDF.c
@@ -8,183 +8,14 @@
 
 #include "../Inc/leaf-WDF.h"
 
-//WDF resistor
-void tWDFresistor_init(tWDFresistor* const r, float electrical_resistance)
-{
-	r->port_resistance = electrical_resistance;
-	r->port_conductance = 1.0f / electrical_resistance;
-	r->electrical_resistance = electrical_resistance;
-	r->incident_wave = 0.0f;
-	r->reflected_wave = 0.0f;
-}
-void tWDFresistor_setElectricalResistance(tWDFresistor* const r, float electrical_resistance)
-{
-	r->port_resistance = electrical_resistance;
-	r->port_conductance = 1.0f / electrical_resistance;
-	r->electrical_resistance = electrical_resistance;
-}
-float tWDFresistor_getPortResistance(tWDFresistor* const r)
-{
-	return r->port_resistance;
-}
-void tWDFresistor_setIncidentWave(tWDFresistor* const r, float incident_wave)
-{
-	r->incident_wave = incident_wave;
-}
-float tWDFresistor_getReflectedWave(tWDFresistor* const r)
-{
-	r->reflected_wave = 0.0f;
-	return r->reflected_wave;
-}
-float tWDFresistor_getVoltage(tWDFresistor* const r)
-{
-	return ((r->incident_wave * 0.5f) + (r->reflected_wave * 0.5f));
-}
-float tWDFresistor_getCurrent(tWDFresistor* const r)
-{
-	return (((r->incident_wave * 0.5f) - (r->reflected_wave * 0.5f)) * r->port_conductance);
-}
-
-
-
-///----WDF resistive source
-void tWDFresistiveSource_init(tWDFresistiveSource* const r, float electrical_resistance, float source_voltage)
-{
-	r->port_resistance = electrical_resistance;
-	r->port_conductance = 1.0f / electrical_resistance;
-	r->electrical_resistance = electrical_resistance;
-	r->incident_wave = 0.0f;
-	r->reflected_wave = 0.0f;
-	r->source_voltage = source_voltage;
-}
-float tWDFresistiveSource_getPortResistance(tWDFresistiveSource* const r)
-{
-	return r->port_resistance;
-}
-void tWDFresistiveSource_setIncidentWave(tWDFresistiveSource* const r, float incident_wave)
-{
-	r->incident_wave = incident_wave;
-}
-float tWDFresistiveSource_getReflectedWave(tWDFresistiveSource* const r)
-{
-	r->reflected_wave = r->source_voltage;
-	return r->reflected_wave;
-}
-float tWDFresistiveSource_getVoltage(tWDFresistiveSource* const r)
-{
-	return ((r->incident_wave * 0.5f) + (r->reflected_wave * 0.5f));
-}
-float tWDFresistiveSource_getCurrent(tWDFresistiveSource* const r)
-{
-	return (((r->incident_wave * 0.5f) - (r->reflected_wave * 0.5f)) * r->port_conductance);
-}
-void tWDFresistiveSource_setSourceVoltage(tWDFresistiveSource* const r, float source_voltage)
-{
-	r->source_voltage = source_voltage;
-}
-
-
-//WDF capacitor
-
-void tWDFcapacitor_init(tWDFcapacitor* const r, float electrical_capacitance, float sample_rate)
-{
-	r->port_resistance = 1.0f / (sample_rate * 2.0f * electrical_capacitance); //based on trapezoidal discretization
-	r->port_conductance = (1.0f / r->port_resistance);
-	r->electrical_capacitance = electrical_capacitance;
-	r->incident_wave = 0.0f;
-	r->reflected_wave = 0.0f;
-	r->sample_rate = sample_rate;
-	r->memory = 0.0f;
-}
-
-float tWDFcapacitor_getPortResistance(tWDFcapacitor* const r)
-{
-	return r->port_resistance;
-}
-void tWDFcapacitor_setIncidentWave(tWDFcapacitor* const r, float incident_wave)
-{
-	r->incident_wave = incident_wave;
-	r->memory = r->incident_wave;
-}
-float tWDFcapacitor_getReflectedWave(tWDFcapacitor* const r)
-{
-	r->reflected_wave = r->memory;
-	return r->reflected_wave;
-}
-float tWDFcapacitor_getVoltage(tWDFcapacitor* const r)
-{
-	return ((r->incident_wave * 0.5f) + (r->reflected_wave * 0.5f));
-}
-float tWDFcapacitor_getCurrent(tWDFcapacitor* const r)
-{
-	return (((r->incident_wave * 0.5f) - (r->reflected_wave * 0.5f)) * r->port_conductance);
-}
-
-
-// WDF series
-void tWDFseriesAdaptor_init(tWDFseriesAdaptor* const r, tWDFresistor* const rL, tWDFcapacitor* const rR)
-{
-	r->rL = rL;
-	r->rR = rR;
-	r->port_resistance_left = tWDFresistor_getPortResistance(rL);
-	r->port_resistance_right = tWDFcapacitor_getPortResistance(rR);
-	r->port_resistance_up = r->port_resistance_left + r->port_resistance_right;
-	r->port_conductance_up  = 1.0f / r->port_resistance_up;
-	r->port_conductance_left = 1.0f / r->port_resistance_left;
-	r->port_conductance_right = 1.0f / r->port_resistance_right;
-	r->incident_wave_up = 0.0f;
-	r->incident_wave_left = 0.0f;
-	r->incident_wave_right = 0.0f;
-	r->reflected_wave_up = 0.0f;
-	r->reflected_wave_left = 0.0f;
-	r->reflected_wave_right = 0.0f;
-
-	r->gamma_zero = 1.0f / (r->port_resistance_right + r->port_resistance_left);
-}
-
-void tWDFseriesAdaptor_setPortResistances(tWDFseriesAdaptor* const r)
-{
-	r->port_resistance_left = tWDFresistor_getPortResistance(r->rL);
-	r->port_resistance_right = tWDFcapacitor_getPortResistance(r->rR);
-	r->port_resistance_up = r->port_resistance_left + r->port_resistance_right;
-	r->port_conductance_up  = 1.0f / r->port_resistance_up;
-	r->port_conductance_left = 1.0f / r->port_resistance_left;
-	r->port_conductance_right = 1.0f / r->port_resistance_right;
-	r->gamma_zero = 1.0f / (r->port_resistance_right + r->port_resistance_left);
-}
-
-float tWDFseriesAdaptor_getPortResistance(tWDFseriesAdaptor* const r)
-{
-	return r->port_resistance_up;
-}
-void tWDFseriesAdaptor_setIncidentWave(tWDFseriesAdaptor* const r, float incident_wave)
-{
-	float gamma_left = r->port_resistance_left * r->gamma_zero;
-	float gamma_right = r->port_resistance_right * r->gamma_zero;
-	float left_wave = tWDFresistor_getReflectedWave(r->rL);
-	float right_wave = tWDFcapacitor_getReflectedWave(r->rR);
-	tWDFresistor_setIncidentWave(r->rL, (-1.0f * gamma_left * incident_wave) + ((1.0f - gamma_left) * left_wave) - (gamma_left * right_wave));
-	tWDFcapacitor_setIncidentWave(r->rR, (-1.0f * gamma_right * incident_wave) + ((-1.0f * gamma_right) * left_wave) + ((1.0f - gamma_right) * right_wave));
-}
-
-float tWDFseriesAdaptor_getReflectedWave(tWDFseriesAdaptor* const r)
-{
-	 return (-1.0f * (tWDFresistor_getReflectedWave(r->rL) + tWDFcapacitor_getReflectedWave(r->rR)));
-}
-float tWDFseriesAdaptor_getVoltage(tWDFseriesAdaptor* const r)
-{
-	return ((r->incident_wave_up * 0.5f) + (r->reflected_wave_up * 0.5f));
-}
-float tWDFseriesAdaptor_getCurrent(tWDFseriesAdaptor* const r)
-{
-	return (((r->incident_wave_up * 0.5f) - (r->reflected_wave_up * 0.5f)) * r->port_conductance_up);
-}
-
 //WDF
 
-void tWDF_init(tWDF* const r, WDFComponentType type, float value, tWDF* const rL, tWDF* const rR, float sample_rate)
+void tWDF_init(tWDF* const r, WDFComponentType type, float value, tWDF* const rL, tWDF* const rR)
 {
 	r->type = type;
+    r->child_left = rL;
+    r->child_right = rR;
+    r->outpoint = tWDF_findOutputPoint(r);
 	r->incident_wave_up = 0.0f;
 	r->incident_wave_left = 0.0f;
 	r->incident_wave_right = 0.0f;
@@ -191,12 +22,10 @@
 	r->reflected_wave_up = 0.0f;
 	r->reflected_wave_left = 0.0f;
 	r->reflected_wave_right = 0.0f;
-	r->sample_rate = sample_rate;
+	r->sample_rate = leaf.sampleRate;
 	r->value = value;
 	if (r->type == SeriesAdaptor)
 	{
-		r->child_left = rL;
-		r->child_right = rR;
 		r->port_resistance_left = tWDF_getPortResistance(rL);
 		r->port_resistance_right = tWDF_getPortResistance(rR);
 		r->port_resistance_up = r->port_resistance_left + r->port_resistance_right;
@@ -211,8 +40,6 @@
 	}
 	else if (r->type == ParallelAdaptor)
 	{
-		r->child_left = rL;
-		r->child_right = rR;
 		r->port_resistance_left = tWDF_getPortResistance(rL);
 		r->port_resistance_right = tWDF_getPortResistance(rR);
 		r->port_resistance_up = (r->port_resistance_left * r->port_resistance_right) / (r->port_resistance_left + r->port_resistance_right);
@@ -236,7 +63,7 @@
 	}
 	else if (r->type == Capacitor)
 	{
-		r->port_resistance_up = 1.0f / (sample_rate * 2.0f * r->value); //based on trapezoidal discretization
+		r->port_resistance_up = 1.0f / (r->sample_rate * 2.0f * r->value); //based on trapezoidal discretization
 		r->port_conductance_up = (1.0f / r->port_resistance_up);
 
 		r->get_port_resistance = &get_port_resistance_for_capacitor;
@@ -267,7 +94,7 @@
 	tWDF_setIncidentWave(r, reflected_wave);
 
 	//step 5 : grab whatever voltages or currents we want as outputs
-	return -1.0f * tWDF_getVoltage(r->child_right->child_right);
+	return -1.0f * tWDF_getVoltage(r->outpoint);
 }
 
 void tWDF_setValue(tWDF* const r, float value)
@@ -275,6 +102,28 @@
 	r->value = value;
 }
 
+void tWDF_setSampleRate(tWDF* const r, float sample_rate)
+{
+    r->sample_rate = sample_rate;
+}
+
+void tWDF_setOutputPoint(tWDF* const r, tWDF* const outpoint)
+{
+    r->outpoint = outpoint;
+}
+
+uint8_t tWDF_isLeaf(tWDF* const r)
+{
+    if (r->child_left == NULL && r->child_right == NULL) return 1;
+    return 0;
+}
+
+tWDF* tWDF_findOutputPoint(tWDF* const r)
+{
+    if (tWDF_isLeaf(r)) return r;
+    return tWDF_findOutputPoint(r->child_left);
+}
+
 float tWDF_getPortResistance(tWDF* const r)
 {
 	return r->get_port_resistance(r);
@@ -400,4 +249,181 @@
 	float gamma_right = r->port_conductance_right * r->gamma_zero;
 	//return ( dl * downPorts[0]->a + dr * downPorts[1]->a );
 	return (gamma_left * tWDF_getReflectedWave(r->child_left) + gamma_right * tWDF_getReflectedWave(r->child_right));
+}
+
+
+
+
+
+
+//WDF resistor
+void tWDFresistor_init(tWDFresistor* const r, float electrical_resistance)
+{
+    r->port_resistance = electrical_resistance;
+    r->port_conductance = 1.0f / electrical_resistance;
+    r->electrical_resistance = electrical_resistance;
+    r->incident_wave = 0.0f;
+    r->reflected_wave = 0.0f;
+}
+void tWDFresistor_setElectricalResistance(tWDFresistor* const r, float electrical_resistance)
+{
+    r->port_resistance = electrical_resistance;
+    r->port_conductance = 1.0f / electrical_resistance;
+    r->electrical_resistance = electrical_resistance;
+}
+float tWDFresistor_getPortResistance(tWDFresistor* const r)
+{
+    return r->port_resistance;
+}
+void tWDFresistor_setIncidentWave(tWDFresistor* const r, float incident_wave)
+{
+    r->incident_wave = incident_wave;
+}
+float tWDFresistor_getReflectedWave(tWDFresistor* const r)
+{
+    r->reflected_wave = 0.0f;
+    return r->reflected_wave;
+}
+float tWDFresistor_getVoltage(tWDFresistor* const r)
+{
+    return ((r->incident_wave * 0.5f) + (r->reflected_wave * 0.5f));
+}
+float tWDFresistor_getCurrent(tWDFresistor* const r)
+{
+    return (((r->incident_wave * 0.5f) - (r->reflected_wave * 0.5f)) * r->port_conductance);
+}
+
+
+
+///----WDF resistive source
+void tWDFresistiveSource_init(tWDFresistiveSource* const r, float electrical_resistance, float source_voltage)
+{
+    r->port_resistance = electrical_resistance;
+    r->port_conductance = 1.0f / electrical_resistance;
+    r->electrical_resistance = electrical_resistance;
+    r->incident_wave = 0.0f;
+    r->reflected_wave = 0.0f;
+    r->source_voltage = source_voltage;
+}
+float tWDFresistiveSource_getPortResistance(tWDFresistiveSource* const r)
+{
+    return r->port_resistance;
+}
+void tWDFresistiveSource_setIncidentWave(tWDFresistiveSource* const r, float incident_wave)
+{
+    r->incident_wave = incident_wave;
+}
+float tWDFresistiveSource_getReflectedWave(tWDFresistiveSource* const r)
+{
+    r->reflected_wave = r->source_voltage;
+    return r->reflected_wave;
+}
+float tWDFresistiveSource_getVoltage(tWDFresistiveSource* const r)
+{
+    return ((r->incident_wave * 0.5f) + (r->reflected_wave * 0.5f));
+}
+float tWDFresistiveSource_getCurrent(tWDFresistiveSource* const r)
+{
+    return (((r->incident_wave * 0.5f) - (r->reflected_wave * 0.5f)) * r->port_conductance);
+}
+void tWDFresistiveSource_setSourceVoltage(tWDFresistiveSource* const r, float source_voltage)
+{
+    r->source_voltage = source_voltage;
+}
+
+
+//WDF capacitor
+
+void tWDFcapacitor_init(tWDFcapacitor* const r, float electrical_capacitance, float sample_rate)
+{
+    r->port_resistance = 1.0f / (sample_rate * 2.0f * electrical_capacitance); //based on trapezoidal discretization
+    r->port_conductance = (1.0f / r->port_resistance);
+    r->electrical_capacitance = electrical_capacitance;
+    r->incident_wave = 0.0f;
+    r->reflected_wave = 0.0f;
+    r->sample_rate = sample_rate;
+    r->memory = 0.0f;
+}
+
+float tWDFcapacitor_getPortResistance(tWDFcapacitor* const r)
+{
+    return r->port_resistance;
+}
+void tWDFcapacitor_setIncidentWave(tWDFcapacitor* const r, float incident_wave)
+{
+    r->incident_wave = incident_wave;
+    r->memory = r->incident_wave;
+}
+float tWDFcapacitor_getReflectedWave(tWDFcapacitor* const r)
+{
+    r->reflected_wave = r->memory;
+    return r->reflected_wave;
+}
+float tWDFcapacitor_getVoltage(tWDFcapacitor* const r)
+{
+    return ((r->incident_wave * 0.5f) + (r->reflected_wave * 0.5f));
+}
+float tWDFcapacitor_getCurrent(tWDFcapacitor* const r)
+{
+    return (((r->incident_wave * 0.5f) - (r->reflected_wave * 0.5f)) * r->port_conductance);
+}
+
+
+// WDF series
+void tWDFseriesAdaptor_init(tWDFseriesAdaptor* const r, tWDFresistor* const rL, tWDFcapacitor* const rR)
+{
+    r->rL = rL;
+    r->rR = rR;
+    r->port_resistance_left = tWDFresistor_getPortResistance(rL);
+    r->port_resistance_right = tWDFcapacitor_getPortResistance(rR);
+    r->port_resistance_up = r->port_resistance_left + r->port_resistance_right;
+    r->port_conductance_up  = 1.0f / r->port_resistance_up;
+    r->port_conductance_left = 1.0f / r->port_resistance_left;
+    r->port_conductance_right = 1.0f / r->port_resistance_right;
+    r->incident_wave_up = 0.0f;
+    r->incident_wave_left = 0.0f;
+    r->incident_wave_right = 0.0f;
+    r->reflected_wave_up = 0.0f;
+    r->reflected_wave_left = 0.0f;
+    r->reflected_wave_right = 0.0f;
+    
+    r->gamma_zero = 1.0f / (r->port_resistance_right + r->port_resistance_left);
+}
+
+void tWDFseriesAdaptor_setPortResistances(tWDFseriesAdaptor* const r)
+{
+    r->port_resistance_left = tWDFresistor_getPortResistance(r->rL);
+    r->port_resistance_right = tWDFcapacitor_getPortResistance(r->rR);
+    r->port_resistance_up = r->port_resistance_left + r->port_resistance_right;
+    r->port_conductance_up  = 1.0f / r->port_resistance_up;
+    r->port_conductance_left = 1.0f / r->port_resistance_left;
+    r->port_conductance_right = 1.0f / r->port_resistance_right;
+    r->gamma_zero = 1.0f / (r->port_resistance_right + r->port_resistance_left);
+}
+
+float tWDFseriesAdaptor_getPortResistance(tWDFseriesAdaptor* const r)
+{
+    return r->port_resistance_up;
+}
+void tWDFseriesAdaptor_setIncidentWave(tWDFseriesAdaptor* const r, float incident_wave)
+{
+    float gamma_left = r->port_resistance_left * r->gamma_zero;
+    float gamma_right = r->port_resistance_right * r->gamma_zero;
+    float left_wave = tWDFresistor_getReflectedWave(r->rL);
+    float right_wave = tWDFcapacitor_getReflectedWave(r->rR);
+    tWDFresistor_setIncidentWave(r->rL, (-1.0f * gamma_left * incident_wave) + ((1.0f - gamma_left) * left_wave) - (gamma_left * right_wave));
+    tWDFcapacitor_setIncidentWave(r->rR, (-1.0f * gamma_right * incident_wave) + ((-1.0f * gamma_right) * left_wave) + ((1.0f - gamma_right) * right_wave));
+}
+
+float tWDFseriesAdaptor_getReflectedWave(tWDFseriesAdaptor* const r)
+{
+    return (-1.0f * (tWDFresistor_getReflectedWave(r->rL) + tWDFcapacitor_getReflectedWave(r->rR)));
+}
+float tWDFseriesAdaptor_getVoltage(tWDFseriesAdaptor* const r)
+{
+    return ((r->incident_wave_up * 0.5f) + (r->reflected_wave_up * 0.5f));
+}
+float tWDFseriesAdaptor_getCurrent(tWDFseriesAdaptor* const r)
+{
+    return (((r->incident_wave_up * 0.5f) - (r->reflected_wave_up * 0.5f)) * r->port_conductance_up);
 }
--- a/LEAF_JUCEPlugin/LEAF.jucer
+++ b/LEAF_JUCEPlugin/LEAF.jucer
@@ -45,6 +45,7 @@
           <FILE id="bpUZCA" name="leaf-crusher.h" compile="0" resource="0" file="../LEAF/Inc/leaf-crusher.h"/>
           <FILE id="PRkOp2" name="leaf-wavefolder.h" compile="0" resource="0"
                 file="../LEAF/Inc/leaf-wavefolder.h"/>
+          <FILE id="lJdTFA" name="leaf-WDF.h" compile="0" resource="0" file="../LEAF/Inc/leaf-WDF.h"/>
           <FILE id="JvZKsP" name="leaf-tables.h" compile="0" resource="0" file="../LEAF/Inc/leaf-tables.h"/>
         </GROUP>
         <GROUP id="{A3AE8C8C-29BA-ADB3-DD7D-EEDC2F7B58F3}" name="Src">
@@ -69,6 +70,7 @@
           <FILE id="Oymcac" name="leaf-crusher.c" compile="1" resource="0" file="../LEAF/Src/leaf-crusher.c"/>
           <FILE id="LVoaGm" name="leaf-wavefolder.c" compile="1" resource="0"
                 file="../LEAF/Src/leaf-wavefolder.c"/>
+          <FILE id="Oh72PT" name="leaf-WDF.c" compile="1" resource="0" file="../LEAF/Src/leaf-WDF.c"/>
           <FILE id="TxA1Gg" name="leaf-tables.c" compile="1" resource="0" file="../LEAF/Src/leaf-tables.c"/>
           <FILE id="BFkVGu" name="leaf.c" compile="1" resource="0" file="../LEAF/Src/leaf.c"/>
         </GROUP>
--- a/LEAF_JUCEPlugin/Source/MyTest.cpp
+++ b/LEAF_JUCEPlugin/Source/MyTest.cpp
@@ -16,11 +16,15 @@
 static void leaf_pool_dump(void);
 static void run_pool_test(void);
 
-tOversampler os;
+tWDF r1;
+tWDF r2;
+tWDF c1;
+tWDF c2;
+tWDF p1;
+tWDF s1;
+tWDF s2;
+
 tNoise noise;
-tCycle sine;
-tFIR filter;
-tLockhartWavefolder wf;
 
 float gain;
 bool buttonState;
@@ -30,33 +34,38 @@
 {
     LEAF_init(sampleRate, blockSize, &getRandomFloat);
     
-    tOversampler_init(&os, ratio, OTRUE);
     tNoise_init(&noise, WhiteNoise);
-    tCycle_init(&sine);
-    tCycle_setFreq(&sine, 220);
-    tLockhartWavefolder_init(&wf);
+    
+    //Bandpass circuit 1
+//    tWDF_init(&r1, Resistor, 10000.0f, NULL, NULL);
+//    tWDF_init(&r2, Resistor, 10000.0f, NULL, NULL);
+//    tWDF_init(&c1, Capacitor, 0.000000159154943f, NULL, NULL);
+//    tWDF_init(&c2, Capacitor, 0.000000159154943f, NULL, NULL);
+//    tWDF_init(&p1, ParallelAdaptor, 10000.0f, &r1, &c1);
+//    tWDF_init(&s1, SeriesAdaptor, 0.0f, &c2, &r2);
+//    tWDF_init(&s2, SeriesAdaptor, 0.0f, &s1, &p1);
+    
+    //Bandpass circuit 2
+    tWDF_init(&r1, Resistor, 10000.0f, NULL, NULL);
+    tWDF_init(&c1, Capacitor, 0.000000159154943f, NULL, NULL);
+    tWDF_init(&s1, SeriesAdaptor, 0.0f, &c1, &r1);
+    tWDF_init(&r2, Resistor, 10000.0f, NULL, NULL);
+    tWDF_init(&p1, ParallelAdaptor, 10000.0f, &s1, &r2);
+    tWDF_init(&c2, Capacitor, 0.000000159154943f, NULL, NULL);
+    tWDF_init(&s2, SeriesAdaptor, 0.0f, &c2, &p1);
+
+    
+    tWDF_setOutputPoint(&s2, &c1);
+    
     leaf_pool_report();
 }
 
 float   LEAFTest_tick            (float input)
 {
-    float sample = tCycle_tick(&sine);
-    float output[ratio];
+    float sample = tNoise_tick(&noise);
     
-    sample *= gain*10.0f;
-    sample = tLockhartWavefolder_tick(&wf, sample);
-//    if (buttonState) {
-//        tOversampler_upsample(&os, sample, output);
-//        for (int i = 0; i < ratio; ++i) {
-//            output[i] *= gain*10.0f;
-//            output[i] = tLockhartWavefolder_tick(&wf, output[i]);
-//        }
-//        sample = tOversampler_downsample(&os, output);
-//    }
-//    else {
-//        sample *= gain*10.0f;
-//        sample = tLockhartWavefolder_tick(&wf, sample);
-//    }
+    sample = tWDF_tick(&s2, sample, 1);
+    
     return sample;
 }
 
@@ -65,21 +74,15 @@
 bool lastState = false, lastPlayState = false;
 void    LEAFTest_block           (void)
 {
-    
-    buttonState = getSliderValue("on/off") > 0.5 ? true : false;
-    
     float val = getSliderValue("mod freq");
+    val = 1.0f + 10000.0f * val;
     
-    float freq = 200 + 20000 * val;
-    tCycle_setFreq(&sine, freq);
+    tWDF_setValue(&r1, val);
     
     val = getSliderValue("mod depth");
+    val = 1.0f + 10000.0f * val;
     
-    gain = val;
-    
-    
-    
-
+    tWDF_setValue(&r2, val);
 }
 
 void    LEAFTest_controllerInput (int cnum, float cval)
@@ -173,4 +176,3 @@
     
     leaf_pool_dump();
 }
-