diff options
author | Damien Zammit <damien@zamaudio.com> | 2020-11-24 22:03:42 +1100 |
---|---|---|
committer | Damien Zammit <damien@zamaudio.com> | 2020-12-01 14:08:10 +1100 |
commit | 2f55cb574840d2c050e48f6ebf595b5cd3ef308b (patch) | |
tree | 192cf6c0db8bc1c4ccaf1f9e2c75a4f01fd997aa | |
parent | e25f001825f04d96419a0306be80aa4c21463e31 (diff) |
Revert "ZamTube: Simplify circuit with no Ci capacitor - no sound quality loss"
This reverts commit 77da69c220dbb7cdccf3b316e567e6ae69a0579d.
-rw-r--r-- | plugins/ZamTube/ZamTubePlugin.cpp | 5 | ||||
-rw-r--r-- | plugins/ZamTube/wdfcircuits.h | 26 |
2 files changed, 21 insertions, 10 deletions
diff --git a/plugins/ZamTube/ZamTubePlugin.cpp b/plugins/ZamTube/ZamTubePlugin.cpp index b47186b..b13fb4d 100644 --- a/plugins/ZamTube/ZamTubePlugin.cpp +++ b/plugins/ZamTube/ZamTubePlugin.cpp @@ -299,6 +299,7 @@ void ZamTubePlugin::activate() // Passive components /* Original WDF preamp + ci[0] = 100e-9; rg[0] = 20e+3; rk[0] = 1e+3; ck[0] = 10e-6; @@ -309,6 +310,7 @@ void ZamTubePlugin::activate() */ /* Matt's preamp */ + ci[0] = 100e-9; rg[0] = 1e-3; rk[0] = 1200.; // 820 originally ck[0] = 50e-6; @@ -318,6 +320,7 @@ void ZamTubePlugin::activate() ro[0] = 470e+3; /* CLA's preamp + ci[0] = 1.0e-7; rg[0] = 5.6e+3; rk[0] = 1.5e+3; ck[0] = 4.7e-6; @@ -330,7 +333,7 @@ void ZamTubePlugin::activate() int pre = 0; float volumepot = 800e+3; // 100 good at low gain, 1000 good at high gain ckt.on = false; - ckt.updateRValues(ck[pre], co[pre], e[pre], er[pre], rg[pre], volumepot, rk[pre], 1e+3, ro[pre], Fs); + ckt.updateRValues(ci[pre], ck[pre], co[pre], e[pre], er[pre], rg[pre], volumepot, rk[pre], 1e+3, ro[pre], Fs); ckt.warmup_tubes(); fSamplingFreq = Fs; diff --git a/plugins/ZamTube/wdfcircuits.h b/plugins/ZamTube/wdfcircuits.h index 99c5eb7..3d1eb01 100644 --- a/plugins/ZamTube/wdfcircuits.h +++ b/plugins/ZamTube/wdfcircuits.h @@ -40,9 +40,10 @@ public: E500E = 0.; } - void updateRValues(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(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; Real RgR = R_Rg; Real RoR = R_Ro; @@ -51,7 +52,10 @@ public: Real E500R = R_E500; E500E = E_E500; Real CoR = 1.0 / (2.0*C_Co*sampleRate); - Real P0_1R = ViR; + Real S0_3R = (CiR + ViR); + S0_3Gamma1 = CiR/(CiR + ViR); + Assert(S0_3Gamma1 >= 0.0 && S0_3Gamma1 <= 1.0); + Real P0_1R = S0_3R; 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); @@ -103,14 +107,15 @@ public: //S1_1SetA //P0_3GetB //S0_3GetB - //Real Cib = Cia; + Real Cib = Cia; //S0_1SetA //ViGetB //S0_2SetA + Real S0_3b3 = -(Cib + ViE); //P0_1SetA //RiGetB //P0_2SetA - Real P0_3b3 = -P0_3Gamma1*ViE; + Real P0_3b3 = -P0_3Gamma1*(-S0_3b3); //S1_2SetA Real S1_3b3 = -(P0_3b3); //P1_3GetB @@ -118,9 +123,9 @@ public: //RkGetB //P1_2SetA //Call tube model - Real Vd = Vg-Vk; - Real Rd = (Vd > 0.) ? 2e+3 : 100e+9; - Vg = (S1_3b3); + Vg = -(S1_3b3); + Real Vd = Vk-Vg; + Real Rd = (Vd > 0.) ? 2e+2 : 10e+6; Vk = -(P1_3b3 - Vg * S1_3Gamma1 / Rd); Real b = t.compute(S2_3b3, S2_3Gamma1, Vg, Vk); //Set As @@ -141,11 +146,14 @@ public: //RkSetA //S1_3SetA //RgSetA + Real S1_3b2 = Vg - S1_3Gamma1*(P0_3b3 + Vg); //P0_3SetA + Real P0_3b1 = S1_3b2 - S0_3b3 - P0_3Gamma1*(-S0_3b3); //S0_3SetA - //Cia = S0_3b1; + Real S0_3b1 = Cib - S0_3Gamma1*(Cib + ViE + P0_3b1); + Cia = S0_3b1; //RiSetA - //printf("Vk=%f Vg=%f Vd=%f in=%f out=%f\n", Vk,Vg,Vd, ViE,Roa); + printf("Vk=%f Vg=%f Vd=%f in=%f out=%f\n", Vk,Vg,Vd, ViE,Roa); return Roa; } |