summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Zammit <damien@zamaudio.com>2020-12-05 19:14:47 +1100
committerDamien Zammit <damien@zamaudio.com>2020-12-05 19:14:47 +1100
commit70798be14640dd6df18767c35545191ed7addaa0 (patch)
tree5ab25dd666caa6e8c19e8b3a5b0e9346839a08bf
parentfb75630022fc2991fdb1f11c53f6af888816bda0 (diff)
ZamTube: Remove capacitor Ci on sixties model to be consistent with best model
-rw-r--r--plugins/ZamTube/ZamTubePlugin.cpp5
-rw-r--r--plugins/ZamTube/wdfcircuits.h45
2 files changed, 46 insertions, 4 deletions
diff --git a/plugins/ZamTube/ZamTubePlugin.cpp b/plugins/ZamTube/ZamTubePlugin.cpp
index 40349c4..cdf62aa 100644
--- a/plugins/ZamTube/ZamTubePlugin.cpp
+++ b/plugins/ZamTube/ZamTubePlugin.cpp
@@ -330,9 +330,7 @@ void ZamTubePlugin::activate()
ro[0] = 100e+3;
*/
- int pre = 0;
- float volumepot = 800e+3; // 100 good at low gain, 1000 good at high gain
- ckt.updateRValues(ci[pre], ck[pre], co[pre], e[pre], er[pre], rg[pre], volumepot, rk[pre], 1e+3, ro[pre], Fs);
+ ckt.updateRValues(ci[0], ck[0], co[0], e[0], er[0], rg[0], 800e+3, rk[0], 1e+3, ro[0], Fs);
fSamplingFreq = Fs;
@@ -414,6 +412,7 @@ void ZamTubePlugin::run(const float** inputs, float** outputs, uint32_t frames)
if (insaneold != (int)insane) {
insaneold = (int)insane;
ckt.set_mode(insane > 0.5 ? ckt.TUBE_MODE_GRIDLEAK : ckt.TUBE_MODE_SIXTIES);
+ ckt.updateRValues(ci[0], ck[0], co[0], e[0], er[0], rg[0], 800e+3, rk[0], 1e+3, ro[0], getSampleRate());
ZamTubePlugin::deactivate();
}
diff --git a/plugins/ZamTube/wdfcircuits.h b/plugins/ZamTube/wdfcircuits.h
index 286fdbe..ca0804e 100644
--- a/plugins/ZamTube/wdfcircuits.h
+++ b/plugins/ZamTube/wdfcircuits.h
@@ -45,7 +45,7 @@ public:
Vk = 0.0;
}
- 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) {
+ void updateRValues_gridleak(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) {
warmup_tubes();
Real ViR = R_Vi;
Real CiR = 1.0 / (2.0*C_Ci*sampleRate);
@@ -84,6 +84,49 @@ public:
Assert(S2_3Gamma1 >= 0.0 && S2_3Gamma1 <= 1.0);
}
+ void updateRValues_sixties(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) {
+ warmup_tubes();
+ Real ViR = R_Vi;
+ 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 P0_1R = ViR;
+ Real P0_2R = RiR;
+ Real P0_3R = 1.0 /(1.0 / P0_1R + 1.0 / P0_2R);
+ P0_3Gamma1 = 1.0 / P0_1R/(1.0 / P0_1R + 1.0 / P0_2R);
+ 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 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);
+ S2_3Gamma1 = P2_3R/(P2_3R + P1_3R);
+ Assert(S2_3Gamma1 >= 0.0 && S2_3Gamma1 <= 1.0);
+ }
+
+ 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) {
+ if (mode == TUBE_MODE_SIXTIES) {
+ updateRValues_sixties(C_Ck, C_Co, E_E500, R_E500, R_Rg, R_Ri, R_Rk, R_Vi, R_Ro, sampleRate);
+ } else {
+ updateRValues_gridleak(C_Ci, C_Ck, C_Co, E_E500, R_E500, R_Rg, R_Ri, R_Rk, R_Vi, R_Ro, sampleRate);
+ }
+ }
+
Real advanc_gridleak(Real ViE) {
//Get Bs
//S2_3GetB