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.h299
1 files changed, 257 insertions, 42 deletions
diff --git a/plugins/ZamTube/wdfcircuits.h b/plugins/ZamTube/wdfcircuits.h
index a54517b..b2c402d 100644
--- a/plugins/ZamTube/wdfcircuits.h
+++ b/plugins/ZamTube/wdfcircuits.h
@@ -1,3 +1,5 @@
+//Autogenerated zamtube circuit
+//Damien Zammit
#ifndef WDFCIRCUITS_H
#define WDFCIRCUITS_H
#include "glue.h"
@@ -6,13 +8,16 @@
class TubeStageCircuit {
/*Tube Preamp*/
public:
- Triode t;
- bool on;
-
TubeStageCircuit() {
Cia = 0.0;
Cka = 0.0;
- Coa = 0.0;
+ Lpa = 0.0;
+ Lsa = 0.0;
+ Csa = 0.0;
+ Lea = 0.0;
+ Cma = 0.0;
+ Lma = 0.0;
+ Caa = 0.0;
Vk = 0.0;
Vg = 0.0;
on = false;
@@ -29,18 +34,36 @@ 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, Triode& tube) {
+ void updateRValues(Real C_Ca, Real C_Ci, Real C_Ck, Real C_Cm, Real C_Cs, Real E_E500, Real L_Le, Real L_Lm, Real L_Lp, Real L_Ls, Real Tee_pos, Real Tem_pos, Real Tma_pos, Real R_E500, Real R_Ra, Real R_Re, Real R_Rg, Real R_Ri, Real R_Rk, Real R_Rm, Real R_Rp1, Real R_Rp2, Real R_Rs1, Real R_Rs2, Real R_Vi, Real sampleRate, Triode &tube) {
t = tube;
Real ViR = R_Vi;
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 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 Rp1R = R_Rp1;
+ Real Rp2R = R_Rp2;
+ Real LpR = 2.0*L_Lp*sampleRate;
+ Teen = 1.0 / Tee_pos;
+ TeeOneOvern = Tee_pos;
+ Real Rs1R = R_Rs1;
+ Real Rs2R = R_Rs2;
+ Real LsR = 2.0*L_Ls*sampleRate;
+ Real CsR = 1.0 / (2.0*C_Cs*sampleRate);
+ Real ReR = R_Re;
+ Real LeR = 2.0*L_Le*sampleRate;
+ Temn = 1.0 / Tem_pos;
+ TemOneOvern = Tem_pos;
+ Real RmR = R_Rm;
+ Real CmR = 1.0 / (2.0*C_Cm*sampleRate);
+ Real LmR = 2.0*L_Lm*sampleRate;
+ Tman = 1.0 / Tma_pos;
+ TmaOneOvern = Tma_pos;
+ Real CaR = 1.0 / (2.0*C_Ca*sampleRate);
+ Real RaR = R_Ra;
Real S0_3R = (CiR + ViR);
S0_3Gamma1 = CiR/(CiR + ViR);
Assert(S0_3Gamma1 >= 0.0 && S0_3Gamma1 <= 1.0);
@@ -56,38 +79,155 @@ public:
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);
+ S7_3Gamma1 = CaR/(CaR + RaR);
+ Assert(S7_3Gamma1 >= 0.0 && S7_3Gamma1 <= 1.0);
+ Real TmaR = (CaR + RaR)/(Tman*Tman);
+ Real P9_1R = TmaR;
+ Real P9_2R = CmR;
+ Real P9_3R = 1.0 /(1.0 / P9_1R + 1.0 / P9_2R);
+ P9_3Gamma1 = 1.0 / P9_1R/(1.0 / P9_1R + 1.0 / P9_2R);
+ Assert(P9_3Gamma1 >= 0.0 && P9_3Gamma1 <= 1.0);
+ Real P8_1R = P9_3R;
+ Real P8_2R = LmR;
+ Real P8_3R = 1.0 /(1.0 / P8_1R + 1.0 / P8_2R);
+ P8_3Gamma1 = 1.0 / P8_1R/(1.0 / P8_1R + 1.0 / P8_2R);
+ Assert(P8_3Gamma1 >= 0.0 && P8_3Gamma1 <= 1.0);
+ Real P7_1R = P8_3R;
+ Real P7_2R = RmR;
+ P7_3Gamma1 = 1.0 / P7_1R/(1.0 / P7_1R + 1.0 / P7_2R);
+ Assert(P7_3Gamma1 >= 0.0 && P7_3Gamma1 <= 1.0);
+ Real TemR = 1.0 /(1.0 / P7_1R + 1.0 / P7_2R)/(Temn*Temn);
+ Real S6_3R = (ReR + LeR);
+ S6_3Gamma1 = ReR/(ReR + LeR);
+ Assert(S6_3Gamma1 >= 0.0 && S6_3Gamma1 <= 1.0);
+ Real S5_3R = (TemR + S6_3R);
+ S5_3Gamma1 = TemR/(TemR + S6_3R);
+ Assert(S5_3Gamma1 >= 0.0 && S5_3Gamma1 <= 1.0);
+ Real P6_1R = CsR;
+ Real P6_2R = LsR;
+ Real P6_3R = 1.0 /(1.0 / P6_1R + 1.0 / P6_2R);
+ P6_3Gamma1 = 1.0 / P6_1R/(1.0 / P6_1R + 1.0 / P6_2R);
+ Assert(P6_3Gamma1 >= 0.0 && P6_3Gamma1 <= 1.0);
+ Real P5_1R = P6_3R;
+ Real P5_2R = Rs2R;
+ Real P5_3R = 1.0 /(1.0 / P5_1R + 1.0 / P5_2R);
+ P5_3Gamma1 = 1.0 / P5_1R/(1.0 / P5_1R + 1.0 / P5_2R);
+ Assert(P5_3Gamma1 >= 0.0 && P5_3Gamma1 <= 1.0);
+ Real S4_3R = (P5_3R + Rs1R);
+ S4_3Gamma1 = P5_3R/(P5_3R + Rs1R);
+ Assert(S4_3Gamma1 >= 0.0 && S4_3Gamma1 <= 1.0);
+ Real P4_1R = S4_3R;
+ Real P4_2R = S5_3R;
+ P4_3Gamma1 = 1.0 / P4_1R/(1.0 / P4_1R + 1.0 / P4_2R);
+ Assert(P4_3Gamma1 >= 0.0 && P4_3Gamma1 <= 1.0);
+ Real TeeR = 1.0 /(1.0 / P4_1R + 1.0 / P4_2R)/(Teen*Teen);
+ Real P3_1R = LpR;
+ Real P3_2R = Rp2R;
+ Real P3_3R = 1.0 /(1.0 / P3_1R + 1.0 / P3_2R);
+ P3_3Gamma1 = 1.0 / P3_1R/(1.0 / P3_1R + 1.0 / P3_2R);
+ Assert(P3_3Gamma1 >= 0.0 && P3_3Gamma1 <= 1.0);
+ Real S3_3R = (P3_3R + Rp1R);
+ S3_3Gamma1 = P3_3R/(P3_3R + Rp1R);
Assert(S3_3Gamma1 >= 0.0 && S3_3Gamma1 <= 1.0);
Real P2_1R = S3_3R;
- Real P2_2R = E500R;
+ Real P2_2R = TeeR;
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);
+ Real S2_3R = (P2_3R + E500R);
+ S2_3Gamma1 = P2_3R/(P2_3R + E500R);
Assert(S2_3Gamma1 >= 0.0 && S2_3Gamma1 <= 1.0);
- }
+ S8_3Gamma1 = S2_3R/(S2_3R + P1_3R);
+ Assert(S8_3Gamma1 >= 0.0 && S8_3Gamma1 <= 1.0);
+ }
- Real advanc(Real ViE) {
- Real fudge = 0.997; // Critical to make Vk = ~2V when -15dbFS sine wave is input
+ Real advanc(Real ViE){
+ Real fudge = 0.997;
//Get Bs
+ //S8_3GetB
+ //S2_3GetB
+ //P2_3GetB
+ //S3_3GetB
+ //P3_3GetB
+ Real Lpb = -Lpa;
+ //P3_1SetA
+ //Rp2GetB
+ //P3_2SetA
+ Real P3_3b3 = -P3_3Gamma1*(-Lpb);
+ //S3_1SetA
+ //Rp1GetB
+ //S3_2SetA
+ Real S3_3b3 = -(P3_3b3);
+ //P2_1SetA
+ //TeeGetB
+ //P4_3GetB
+ //S4_3GetB
+ //P5_3GetB
+ //P6_3GetB
+ Real Csb = Csa;
+ //P6_1SetA
+ Real Lsb = -Lsa;
+ //P6_2SetA
+ Real P6_3b3 = Lsb - P6_3Gamma1*(Lsb - Csb);
+ //P5_1SetA
+ //Rs2GetB
+ //P5_2SetA
+ Real P5_3b3 = -P5_3Gamma1*(-P6_3b3);
+ //S4_1SetA
+ //Rs1GetB
+ //S4_2SetA
+ Real S4_3b3 = -(P5_3b3);
+ //P4_1SetA
+ //S5_3GetB
+ //TemGetB
+ //P7_3GetB
+ //P8_3GetB
+ //P9_3GetB
+ //TmaGetB
+ //S7_3GetB
+ Real Cab = Caa;
+ //S7_1SetA
+ //RaGetB
+ //S7_2SetA
+ Real S7_3b3 = -(Cab);
+ //P9_1SetA
+ Real Cmb = Cma;
+ //P9_2SetA
+ Real P9_3b3 = Cmb - P9_3Gamma1*(Cmb - S7_3b3*TmaOneOvern);
+ //P8_1SetA
+ Real Lmb = -Lma;
+ //P8_2SetA
+ Real P8_3b3 = Lmb - P8_3Gamma1*(Lmb - P9_3b3);
+ //P7_1SetA
+ //RmGetB
+ //P7_2SetA
+ Real P7_3b3 = -P7_3Gamma1*(-P8_3b3);
+ //S5_1SetA
+ //S6_3GetB
+ //ReGetB
+ //S6_1SetA
+ Real Leb = -Lea;
+ //S6_2SetA
+ Real S6_3b3 = -(Leb);
+ //S5_2SetA
+ Real S5_3b3 = -(P7_3b3*TemOneOvern + S6_3b3);
+ //P4_2SetA
+ Real P4_3b3 = S5_3b3 - P4_3Gamma1*(S5_3b3 - S4_3b3);
+ //P2_2SetA
+ Real P2_3b3 = P4_3b3*TeeOneOvern - P2_3Gamma1*(P4_3b3*TeeOneOvern - S3_3b3);
+ //S2_1SetA
+ //E500GetB
+ //S2_2SetA
+ Real S2_3b3 = -(P2_3b3 + E500E);
+ //S8_1SetA
//P1_3GetB
Real Ckb = Cka;
//P1_1SetA
//RkGetB
//P1_2SetA
Real P1_3b3 = -fudge*P1_3Gamma1*(-Ckb);
- Real Cob = Coa;
- //S3_1SetA
- //RoGetB
- //S3_2SetA
- Real S3_3b3 = -(Cob);
- //P2_1SetA
- //E500GetB
- //P2_2SetA
- Real P2_3b3 = E500E - fudge*P2_3Gamma1*(E500E - S3_3b3);
- //S2_2SetA
- Real S2_3b3 = -(P1_3b3 + P2_3b3);
+ //S8_2SetA
+ Real S8_3b3 = -(S2_3b3 + P1_3b3);
//S1_3GetB
//RgGetB
//S1_1SetA
@@ -104,49 +244,124 @@ public:
Real P0_3b3 = -P0_3Gamma1*(-S0_3b3);
//S1_2SetA
Real S1_3b3 = -(P0_3b3);
- //Call tube model
+ //P1_3GetB
Vg = -S1_3b3;
- Real b = t.compute(-S2_3b3, S2_3Gamma1, Vg-Vk, Vk);
+ //Call tube model
+ Real b = t.compute(S8_3b3, S8_3Gamma1, Vg-Vk, Vk);
//Set As
+ //S8_3SetA
+ Real S8_3b1 = S2_3b3 - S8_3Gamma1*(S2_3b3 + P1_3b3 + b);
//S2_3SetA
- Real S2_3b1 = P1_3b3 - S2_3Gamma1*(P1_3b3 + P2_3b3 + b);
+ Real S2_3b1 = P2_3b3 - S2_3Gamma1*(P2_3b3 + E500E + S8_3b1);
+ //P2_3SetA
+ Real P2_3b1 = S2_3b1 + P4_3b3*TeeOneOvern - S3_3b3 - P2_3Gamma1*(P4_3b3*TeeOneOvern - S3_3b3);
+ //S3_3SetA
+ Real S3_3b1 = P3_3b3 - S3_3Gamma1*(P3_3b3 + P2_3b1);
+ //P3_3SetA
+ Real P3_3b1 = S3_3b1 - Lpb - P3_3Gamma1*(-Lpb);
+ Lpa = P3_3b1;
+ //Rp2SetA
+ //Rp1SetA
+ Real P2_3b2 = S2_3b1 - P2_3Gamma1*(P4_3b3*TeeOneOvern - S3_3b3);
+ //TeeSetA
+ //P4_3SetA
+ Real P4_3b1 = P2_3b2*Teen + S5_3b3 - S4_3b3 - P4_3Gamma1*(S5_3b3 - S4_3b3);
+ //S4_3SetA
+ Real S4_3b1 = P5_3b3 - S4_3Gamma1*(P5_3b3 + P4_3b1);
+ //P5_3SetA
+ Real P5_3b1 = S4_3b1 - P6_3b3 - P5_3Gamma1*(-P6_3b3);
+ //P6_3SetA
+ Real P6_3b1 = P5_3b1 + Lsb - Csb - P6_3Gamma1*(Lsb - Csb);
+ Csa = P6_3b1;
+ Real P6_3b2 = P5_3b1 - P6_3Gamma1*(Lsb - Csb);
+ Lsa = P6_3b2;
+ //Rs2SetA
+ //Rs1SetA
+ Real P4_3b2 = P2_3b2*Teen - P4_3Gamma1*(S5_3b3 - S4_3b3);
+ //S5_3SetA
+ Real S5_3b1 = P7_3b3*TemOneOvern - S5_3Gamma1*(P7_3b3*TemOneOvern + S6_3b3 + P4_3b2);
+ //TemSetA
+ //P7_3SetA
+ Real P7_3b1 = S5_3b1*Temn - P8_3b3 - P7_3Gamma1*(-P8_3b3);
+ //P8_3SetA
+ Real P8_3b1 = P7_3b1 + Lmb - P9_3b3 - P8_3Gamma1*(Lmb - P9_3b3);
+ //P9_3SetA
+ Real P9_3b1 = P8_3b1 + Cmb - S7_3b3*TmaOneOvern - P9_3Gamma1*(Cmb - S7_3b3*TmaOneOvern);
+ //TmaSetA
+ //S7_3SetA
+ Real S7_3b1 = Cab - S7_3Gamma1*(Cab + P9_3b1*Tman);
+ Caa = S7_3b1;
+ Real S7_3b2 = Cab + P9_3b1*Tman - S7_3Gamma1*(Cab + P9_3b1*Tman);
+ //RaSetA
+ Real Raa = S7_3b2;
+ Real P9_3b2 = P8_3b1 - P9_3Gamma1*(Cmb - S7_3b3*TmaOneOvern);
+ Cma = P9_3b2;
+ Real P8_3b2 = P7_3b1 - P8_3Gamma1*(Lmb - P9_3b3);
+ Lma = P8_3b2;
+ //RmSetA
+ Real S5_3b2 = P7_3b3*TemOneOvern + P4_3b2 - S5_3Gamma1*(P7_3b3*TemOneOvern + S6_3b3 + P4_3b2);
+ //S6_3SetA
+ Real S6_3b1 = -S6_3Gamma1*(Leb + S5_3b2);
+ //ReSetA
+ Real Rea = S6_3b1;
+ Real S6_3b2 = S5_3b2 - S6_3Gamma1*(Leb + S5_3b2);
+ Lea = S6_3b2;
+ Real S8_3b2 = S2_3b3 + b - S8_3Gamma1*(S2_3b3 + P1_3b3 + b);
//P1_3SetA
- Real P1_3b1 = S2_3b1 - Ckb - P1_3Gamma1*(-Ckb);
+ Real P1_3b1 = S8_3b2 - 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("Vk=%f Vg=%f Vpk(b)=%f(%f) in=%f out=%f\n", Vk,Vg,P2_3b3,b, ViE,Roa);
- return (Roa);
+ return Raa;
}
+ Triode t;
+ bool on;
private:
//State variables
- Real Coa;
Real Cia;
Real Cka;
+ Real Lpa;
+ Real Lsa;
+ Real Csa;
+ Real Lea;
+ Real Cma;
+ Real Lma;
+ Real Caa;
Real Vk;
Real Vg;
//R values
+ Real S8_3Gamma1;
Real P3_3Gamma1;
Real P0_3Gamma1;
+ Real P9_3Gamma1;
+ Real P6_3Gamma1;
+ Real Teen;
+ Real TmaOneOvern;
+ Real P7_3Gamma1;
+ Real P4_3Gamma1;
+ Real TemOneOvern;
Real S1_3Gamma1;
Real S3_3Gamma1;
+ Real S4_3Gamma1;
+ Real S7_3Gamma1;
Real P1_3Gamma1;
- Real ViE;
+ Real TeeOneOvern;
Real S0_3Gamma1;
Real S2_3Gamma1;
+ Real S6_3Gamma1;
Real P2_3Gamma1;
+ Real P5_3Gamma1;
+ Real Temn;
+ Real Tman;
+ Real P8_3Gamma1;
+ Real S5_3Gamma1;
Real E500E;
};
+
+
+
#endif
+