summaryrefslogtreecommitdiff
path: root/plugins/ZamTube/wdfcircuits.h
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/ZamTube/wdfcircuits.h')
-rw-r--r--plugins/ZamTube/wdfcircuits.h167
1 files changed, 96 insertions, 71 deletions
diff --git a/plugins/ZamTube/wdfcircuits.h b/plugins/ZamTube/wdfcircuits.h
index f8d8a49..2f774f5 100644
--- a/plugins/ZamTube/wdfcircuits.h
+++ b/plugins/ZamTube/wdfcircuits.h
@@ -13,28 +13,34 @@ public:
Cia = 0.0;
Cka = 0.0;
Coa = 0.0;
+ Vk = 0.0;
+ Vg = 0.0;
on = false;
}
- TubeStageCircuit(Real C_Ci, Real C_Ck, Real C_Co, Real E_E250, Real R_E250, Real R_Rg, Real R_Ri, Real R_Rk, Real R_Ro, Real R_Vi, Real sampleRate, Triode& tube) {
- Cia = 0.0;
- Cka = 0.0;
- Coa = 0.0;
+
+ void warmup_tubes(void) {
+ int i;
on = false;
- updateRValues(C_Ci, C_Ck, C_Co, E_E250, R_E250, R_Rg, R_Ri, R_Rk, R_Ro, R_Vi, sampleRate, tube);
+ for (i = 0; i < 8000; i++) {
+ advanc(0.0);
+ }
+ on = true;
}
- void updateRValues(Real C_Ci, Real C_Ck, Real C_Co, Real E_E250, Real R_E250, Real R_Rg, Real R_Ri, Real R_Rk, Real R_Ro, Real R_Vi, Real sampleRate, Triode& tube) {
+
+
+ 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, Triode& tube) {
t = tube;
Real ViR = R_Vi;
- CiR = 1.0 / (2.0*C_Ci*sampleRate);
- CkR = 1.0 / (2.0*C_Ck*sampleRate);
- CoR = 1.0 / (2.0*C_Co*sampleRate);
- Real RoR = R_Ro;
- Real RgR = R_Rg;
+ Real CiR = 1.0 / (2.0*C_Ci*sampleRate);
Real RiR = R_Ri;
+ Real RgR = R_Rg;
+ Real RoR = R_Ro;
Real RkR = R_Rk;
- Real E250R = R_E250;
- E250E = E_E250;
+ Real CkR = 1.0 / (2.0*C_Ck*sampleRate);
+ Real E500R = R_E500;
+ E500E = E_E500;
+ Real CoR = 1.0 / (2.0*C_Co*sampleRate);
Real S0_3R = (CiR + ViR);
S0_3Gamma1 = CiR/(CiR + ViR);
Assert(S0_3Gamma1 >= 0.0 && S0_3Gamma1 <= 1.0);
@@ -45,82 +51,101 @@ public:
Assert(P0_3Gamma1 >= 0.0 && P0_3Gamma1 <= 1.0);
S1_3Gamma1 = RgR/(RgR + P0_3R);
Assert(S1_3Gamma1 >= 0.0 && S1_3Gamma1 <= 1.0);
- Real I3_1R = CkR;
- Real I3_2R = RkR;
- I3_3Gamma1 = 1.0 / I3_1R/(1.0 / I3_1R + 1.0 / I3_2R);
- Assert(I3_3Gamma1 >= 0.0 && I3_3Gamma1 <= 1.0);
- Real S2_3R = (CoR + RoR);
- S2_3Gamma1 = CoR/(CoR + RoR);
- Assert(S2_3Gamma1 >= 0.0 && S2_3Gamma1 <= 1.0);
- Real P2_1R = S2_3R;
- Real P2_2R = E250R;
+ Real P1_1R = CkR;
+ Real P1_2R = RkR;
+ Real P1_3R = 1.0 /(1.0 / P1_1R + 1.0 / P1_2R);
+ P1_3Gamma1 = 1.0 / P1_1R/(1.0 / P1_1R + 1.0 / P1_2R);
+ Assert(P1_3Gamma1 >= 0.0 && P1_3Gamma1 <= 1.0);
+ Real S3_3R = (CoR + RoR);
+ S3_3Gamma1 = CoR/(CoR + RoR);
+ Assert(S3_3Gamma1 >= 0.0 && S3_3Gamma1 <= 1.0);
+ Real P2_1R = S3_3R;
+ Real P2_2R = E500R;
+ 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);
- t.Kr = sanitize_denormal(I3_3Gamma1);
- t.Pr = sanitize_denormal(P2_3Gamma1);
- t.Gr = sanitize_denormal(S1_3Gamma1);
- //printf("Kr = %f Pr = %f Gr = %f\n", t.Kr, t.Pr, t.Gr);
- }
-
- void warmup_tubes(void) {
- int i;
- on = false;
- for (i = 0; i < 8000; i++) {
- advanc(0.0);
- }
- on = true;
- }
+ S2_3Gamma1 = P1_3R/(P1_3R + P2_3R);
+ Assert(S2_3Gamma1 >= 0.0 && S2_3Gamma1 <= 1.0);
+ }
- Real advanc(Real VE){
- ViE = VE;
+ Real advanc(Real ViE) {
+ //Get Bs
+ //P1_3GetB
Real Ckb = Cka;
- Real I3_3b3 = I3_3Gamma1 * Ckb / CkR;
- Real Cib = Cia;
- Real S0_3b3 = (ViE + S0_3Gamma1 * Cib / CiR);
- Real P0_3b3 = -P0_3Gamma1 * S0_3b3;
- Real S1_3b3 = (P0_3b3 + S1_3Gamma1*(P0_3b3));
+ //P1_1SetA
+ //RkGetB
+ //P1_2SetA
+ Real P1_3b3 = -P1_3Gamma1*(-Ckb);
Real Cob = Coa;
- Real S2_3b3 = Cob;
- Real P2_3b3 = (E250E - P2_3Gamma1 * S2_3b3);
- //Tube: K G P
- t.compute(I3_3b3,-S1_3b3,P2_3b3);
- Real b1 = t.getC();
- Real b2 = t.getG();
- Real b3 = t.getP();
+ //S3_1SetA
+ //RoGetB
+ //S3_2SetA
+ Real S3_3b3 = -(Cob);
+ //P2_1SetA
+ //E500GetB
+ //P2_2SetA
+ Real P2_3b3 = E500E - P2_3Gamma1*(E500E - S3_3b3);
+ //S2_2SetA
+ Real S2_3b3 = -(P1_3b3 + P2_3b3);
+ //S1_3GetB
+ //RgGetB
+ //S1_1SetA
+ //P0_3GetB
+ //S0_3GetB
+ Real Cib = Cia;
+ //S0_1SetA
+ //ViGetB
+ //S0_2SetA
+ Real S0_3b3 = -(Cib + ViE);
+ //P0_1SetA
+ //RiGetB
+ //P0_2SetA
+ Real P0_3b3 = -P0_3Gamma1*(-S0_3b3);
+ //S1_2SetA
+ Real S1_3b3 = -(P0_3b3);
+ //Call tube model
+ Vg = -S1_3b3;
+ Real b = t.compute(-S2_3b3, S2_3Gamma1, Vg, Vk);
//Set As
- Real I3_3b1 = (b1 - I3_3Gamma1*(b1 + Ckb));
- Cka = I3_3b1;
- Real S1_3b2 = (P0_3b3 - b2 - S1_3Gamma1*(P0_3b3 - b2));
- Real P0_3b1 = (S1_3b2 + (-S0_3b3) - P0_3Gamma1*(S1_3b2 - S0_3b3));
- Real S0_3b1 = (Cib - P0_3b1 - S0_3Gamma1*(Cib - P0_3b1));
- Cia = S0_3b1;
- Real P2_3b1 = (b3 - S2_3b3 - P2_3Gamma1*(b3 - S2_3b3));
- Real S2_3b2 = (Cob - S2_3Gamma1*(Cob - P2_3b1));
- Coa = S2_3b2;
- Real S2_3b1 = (Cob - P2_3b1 - S2_3Gamma1*(Cob - P2_3b1));
- Real Roa = S2_3b1;
- //printf("K=%f G=%f P=%f out=%f\n", I3_3b3,-S1_3b3,P2_3b3, Roa);
- return Roa;
+ //S2_3SetA
+ Real S2_3b1 = P1_3b3 - S2_3Gamma1*(P1_3b3 + P2_3b3 + b);
+ //P1_3SetA
+ Real P1_3b1 = S2_3b1 - Ckb - P1_3Gamma1*(-Ckb);
+ Cka = P1_3b1;
+ //RkSetA
+ Real S2_3b2 = P1_3b3 + b - S2_3Gamma1*(P1_3b3 + P2_3b3 + b);
+ //P2_3SetA
+ Real P2_3b1 = S2_3b2 + 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;
+ Vk = -P1_3b3;
+ //printf("K=%f G=%f P=%f b=%f in=%f out=%f\n", P1_3b3,S1_3b3,P2_3b3,b, ViE,-Roa);
+ return -(Roa);
}
private:
//State variables
+ Real Coa;
Real Cia;
Real Cka;
- Real Coa;
+ Real Vk;
+ Real Vg;
//R values
- Real CiR;
- Real CkR;
- Real CoR;
- Real I3_3Gamma1;
- Real E250E;
- Real ViE;
+ Real P3_3Gamma1;
Real P0_3Gamma1;
+ Real S1_3Gamma1;
+ Real S3_3Gamma1;
+ Real P1_3Gamma1;
+ Real ViE;
Real S0_3Gamma1;
Real S2_3Gamma1;
- Real S1_3Gamma1;
Real P2_3Gamma1;
+ Real E500E;
};
#endif