summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Zammit <damien@zamaudio.com>2020-11-21 13:59:53 +1100
committerDamien Zammit <damien@zamaudio.com>2020-11-22 11:15:56 +1100
commit285af5438bd9538edccbcf2f93592de86397a515 (patch)
tree941962021f7acc270b6ba8c7a0695ea30cd23a4e
parent71e9201fa6622c87d755f76dc4d3319ac9854ba9 (diff)
ZamTube: Better circuit
-rw-r--r--plugins/ZamTube/wdfcircuits.h37
1 files changed, 26 insertions, 11 deletions
diff --git a/plugins/ZamTube/wdfcircuits.h b/plugins/ZamTube/wdfcircuits.h
index bb4adf6..df959a9 100644
--- a/plugins/ZamTube/wdfcircuits.h
+++ b/plugins/ZamTube/wdfcircuits.h
@@ -41,6 +41,7 @@ public:
}
void updateRValues(Real C_Ci, Real C_Ck, Real C_Co, Real E_E500, Real R_E500, Real R_Rg, Real R_Ri, Real R_Rk, Real R_Vi, Real R_Ro, Real sampleRate) {
+
Real ViR = R_Vi;
Real CiR = 1.0 / (2.0*C_Ci*sampleRate);
Real RiR = R_Ri;
@@ -74,11 +75,13 @@ public:
Real P2_3R = 1.0 /(1.0 / P2_1R + 1.0 / P2_2R);
P2_3Gamma1 = 1.0 / P2_1R/(1.0 / P2_1R + 1.0 / P2_2R);
Assert(P2_3Gamma1 >= 0.0 && P2_3Gamma1 <= 1.0);
- S2_3Gamma1 = P1_3R/(P1_3R + P2_3R);
+ S2_3Gamma1 = P2_3R/(P2_3R + P1_3R);
+ Assert(S2_3Gamma1 >= 0.0 && S2_3Gamma1 <= 1.0);
}
Real advanc(Real ViE) {
//Get Bs
+ //S2_3GetB
//P2_3GetB
//S3_3GetB
Real Cob = Coa;
@@ -90,6 +93,15 @@ public:
//E500GetB
//P2_2SetA
Real P2_3b3 = E500E - P2_3Gamma1*(E500E - S3_3b3);
+ //S2_1SetA
+ //P1_3GetB
+ Real Ckb = Cka;
+ //P1_1SetA
+ //RkGetB
+ //P1_2SetA
+ Real P1_3b3 = /*-*/P1_3Gamma1*(-Ckb);
+ //S2_2SetA
+ Real S2_3b3 = (P2_3b3 + P1_3b3);
//S1_3GetB
//RgGetB
//S1_1SetA
@@ -107,24 +119,31 @@ public:
//S1_2SetA
Real S1_3b3 = -(P0_3b3);
//P1_3GetB
- Real Ckb = Cka;
+ //Real Ckb = Cka;
//P1_1SetA
//RkGetB
//P1_2SetA
- Real P1_3b3 = -P1_3Gamma1*(-Ckb);
+ //Real P1_3b3 = -P1_3Gamma1*(-Ckb);
//Call tube model
Vg = -S1_3b3;
- Real b = t.compute(P2_3b3, P2_3Gamma1, Vg, Vk);
- Vk = P1_3b3 + Vg * S2_3Gamma1;
+ Vk = -P1_3b3;
+ Real b = -t.compute(S2_3b3, S2_3Gamma1, Vg, Vk);
//Set As
+ //S2_3SetA
+ Real S2_3b1 = P2_3b3 - S2_3Gamma1*(P2_3b3 + P1_3b3 + b);
//P2_3SetA
- Real P2_3b1 = b + E500E - S3_3b3 - P2_3Gamma1*(E500E - S3_3b3);
+ Real P2_3b1 = S2_3b1 + E500E - S3_3b3 - P2_3Gamma1*(E500E - S3_3b3);
//S3_3SetA
Real S3_3b1 = Cob - S3_3Gamma1*(Cob + P2_3b1);
Coa = S3_3b1;
Real S3_3b2 = Cob + P2_3b1 - S3_3Gamma1*(Cob + P2_3b1);
//RoSetA
Real Roa = S3_3b2;
+ Real S2_3b2 = P2_3b3 + b - S2_3Gamma1*(P2_3b3 + P1_3b3 + b);
+ //P1_3SetA
+ Real P1_3b1 = S2_3b2 - Ckb - P1_3Gamma1*(-Ckb);
+ Cka = P1_3b1;
+ //RkSetA
//S1_3SetA
//RgSetA
Real S1_3b2 = Vg - S1_3Gamma1*(P0_3b3 + Vg);
@@ -134,11 +153,7 @@ public:
Real S0_3b1 = Cib - S0_3Gamma1*(Cib + ViE + P0_3b1);
Cia = S0_3b1;
//RiSetA
- //P1_3SetA
- Real P1_3b1 = Vk - Ckb - P1_3Gamma1*(-Ckb);
- Cka = P1_3b1;
- //RkSetA
- //printf("Vk=%f Vg=%f Vpk=%f in=%f out=%f\n", Vk,Vg,b, ViE,Roa);
+ //printf("Vk=%f Vg=%f Vpk=%f in=%f out=%f\n", Vk,Vg,S2_3b3, ViE,Roa);
return -(Roa);
}