adjustments to timing
This commit is contained in:
parent
e452e282f4
commit
d2e8e6126d
|
|
@ -29,8 +29,8 @@ Chorus::Chorus() {
|
||||||
lfoPhase = 1;
|
lfoPhase = 1;
|
||||||
lfoSpeed = 6.283 * 10.7 / sampleRate; // plainly silly value to show if it hasn't been set
|
lfoSpeed = 6.283 * 10.7 / sampleRate; // plainly silly value to show if it hasn't been set
|
||||||
|
|
||||||
gainTC = 1 - exp(-6.283 * 10 / sampleRate); // 1/10th of a second declick
|
gainTC = 1 - exp(-M_PI * 10 / sampleRate); // 1/10th of a second declick
|
||||||
bbdTC = 1 - exp(-6.283 * 30 / sampleRate); // hpf into BBD at 159Hz
|
bbdTC = 1 - exp(-M_PI * 60 / sampleRate); // hpf into BBD
|
||||||
|
|
||||||
// not quite Butterworth but you'd never hear the difference
|
// not quite Butterworth but you'd never hear the difference
|
||||||
// these are calculated from the real-world component values
|
// these are calculated from the real-world component values
|
||||||
|
|
@ -127,11 +127,11 @@ void Chorus::setHpf(uint8_t mode) {
|
||||||
// k = 1-exp(-2pi * Fc * sampleRate)
|
// k = 1-exp(-2pi * Fc * sampleRate)
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case 0x00:
|
case 0x00:
|
||||||
hpCut = 1 - exp(-6.283 * 720 / sampleRate);
|
hpCut = 1 - exp(-M_PI * 720 / sampleRate);
|
||||||
hpGain = -1;
|
hpGain = -1;
|
||||||
break;
|
break;
|
||||||
case 0x08:
|
case 0x08:
|
||||||
hpCut = 1 - exp(-6.283 * 225 / sampleRate);
|
hpCut = 1 - exp(-M_PI * 225 / sampleRate);
|
||||||
hpGain = -1;
|
hpGain = -1;
|
||||||
break;
|
break;
|
||||||
case 0x10:
|
case 0x10:
|
||||||
|
|
@ -139,7 +139,7 @@ void Chorus::setHpf(uint8_t mode) {
|
||||||
hpGain = 0;
|
hpGain = 0;
|
||||||
break;
|
break;
|
||||||
case 0x18:
|
case 0x18:
|
||||||
hpCut = 1 - exp(-6.283 * 85 / sampleRate);
|
hpCut = 1 - exp(-M_PI * 85 / sampleRate);
|
||||||
hpGain = 1.707;
|
hpGain = 1.707;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -154,11 +154,11 @@ void Chorus::setChorus(uint8_t mode) {
|
||||||
break;
|
break;
|
||||||
case 0x40:
|
case 0x40:
|
||||||
gain = 1.2;
|
gain = 1.2;
|
||||||
lfoSpeed = 6.283 * 0.525 / sampleRate / 2;
|
lfoSpeed = M_PI * 0.525 / sampleRate;
|
||||||
break;
|
break;
|
||||||
case 0x00:
|
case 0x00:
|
||||||
gain = 1.2;
|
gain = 1.2;
|
||||||
lfoSpeed = 6.283 * 0.85 / sampleRate / 2;
|
lfoSpeed = M_PI * 0.85 / sampleRate;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,9 +25,9 @@
|
||||||
|
|
||||||
Module::Module() {
|
Module::Module() {
|
||||||
// cutoff frequencies for various RC networks
|
// cutoff frequencies for various RC networks
|
||||||
vcaTC = 1 - exp(-6.283 * 159 / sampleRate); // VCA and VCF 10k/0.1u time constant
|
vcaTC = 1 - exp(-M_PI * 159 / sampleRate); // VCA and VCF 10k/0.1u time constant
|
||||||
subTC = 1 - exp(-6.283 * 15 / sampleRate); // Main VCA and Sub Level 1k + 10u time constant
|
subTC = 1 - exp(-M_PI * 15 / sampleRate); // Main VCA and Sub Level 1k + 10u time constant
|
||||||
pwmTC = 1 - exp(-6.283 * 40 / sampleRate); // integrator with 100k/0.047u time constant
|
pwmTC = 1 - exp(-M_PI * 40 / sampleRate); // integrator with 100k/0.047u time constant
|
||||||
|
|
||||||
vcaBuf = new float[bufferSize];
|
vcaBuf = new float[bufferSize];
|
||||||
subBuf = new float[bufferSize];
|
subBuf = new float[bufferSize];
|
||||||
|
|
@ -104,12 +104,12 @@ void Module::run(Voice* voices, uint32_t blockSize) {
|
||||||
// originally I had 0.28, 0.36, 0.4
|
// originally I had 0.28, 0.36, 0.4
|
||||||
// measurement suggests that saw and square are around 100mV each with sub 160mV
|
// measurement suggests that saw and square are around 100mV each with sub 160mV
|
||||||
|
|
||||||
square = (patchRam.switch1 & 0x08) ? 0.3 : 0;
|
square = (patchRam.switch1 & 0x08) ? 1 : 0;
|
||||||
saw = (patchRam.switch1 & 0x10) ? .3 : 0;
|
saw = (patchRam.switch1 & 0x10) ? 1 : 0;
|
||||||
sub = (patchRam.sub / 127.0f) * 0.48;
|
sub = (patchRam.sub / 127.0f) * 1.6;
|
||||||
|
|
||||||
res = patchRam.vcfReso / 127.0;
|
res = patchRam.vcfReso / 127.0;
|
||||||
noise = (patchRam.noise / 127.0) * 0.4;
|
noise = (patchRam.noise / 127.0);
|
||||||
|
|
||||||
// FIXME the exp in these is expensive, don't call it all the time
|
// FIXME the exp in these is expensive, don't call it all the time
|
||||||
chorus->setChorus(patchRam.switch1 & 0x60);
|
chorus->setChorus(patchRam.switch1 & 0x60);
|
||||||
|
|
@ -183,7 +183,7 @@ void Module::run(Voice* voices, uint32_t blockSize) {
|
||||||
v->omega = px / (sampleRate * 8.0f); // FIXME recalculate table using proper scaler
|
v->omega = px / (sampleRate * 8.0f); // FIXME recalculate table using proper scaler
|
||||||
|
|
||||||
// per voice we need to calculate the key follow amount and envelope amount
|
// per voice we need to calculate the key follow amount and envelope amount
|
||||||
v->vcfCut = vcfBase + (((v->env * patchRam.vcfEnv)>>7) * ((patchRam.switch1 & 0x02) ? -1 : 1));
|
v->vcfCut = vcfBase + (((v->env * patchRam.vcfEnv)>>7) * ((patchRam.switch2 & 0x02) ? -1 : 1));
|
||||||
|
|
||||||
v->vcfCut += (int)((v->note - 36) * (patchRam.vcfKey << 1) * 0.375);
|
v->vcfCut += (int)((v->note - 36) * (patchRam.vcfKey << 1) * 0.375);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ void Voice::run(Module* m, float* buffer, uint32_t framePos, uint32_t samples) {
|
||||||
|
|
||||||
float r = 5 * m->res;
|
float r = 5 * m->res;
|
||||||
|
|
||||||
float amp = vcaEnv / 4096.0f;
|
float amp = vcaEnv / 16384.0f;
|
||||||
|
|
||||||
for (uint32_t i = 0; i < samples; i++) {
|
for (uint32_t i = 0; i < samples; i++) {
|
||||||
out = delay;
|
out = delay;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue