Multiple updates

This commit is contained in:
Iscle 2023-03-01 19:49:26 +01:00
parent 2c4e153120
commit aaa0ac2634
8 changed files with 71 additions and 38 deletions

View File

@ -98,7 +98,7 @@ ViPER::ViPER() {
for (auto &softwareLimiter: this->softwareLimiters) {
softwareLimiter = new SoftwareLimiter();
softwareLimiter->ResetLimiter();
softwareLimiter->Reset();
}
this->frameScale = 1.0;
@ -417,15 +417,33 @@ void ViPER::DispatchCommand(int param, int val1, int val2, int val3, int val4, u
} // 0x1002D
case PARAM_CURE_CROSS_FEED_STRENGTH: {
switch (val1) {
case 0:
case 0: {
// Cure_R::SetPreset(pCVar17,0x5f028a);
struct Crossfeed::Preset preset = {
.cutoff = 650,
.feedback = 95,
};
this->cure->SetPreset(preset);
break;
case 1:
}
case 1: {
// Cure_R::SetPreset(pCVar17,0x3c02bc);
struct Crossfeed::Preset preset = {
.cutoff = 700,
.feedback = 60,
};
this->cure->SetPreset(preset);
break;
case 2:
}
case 2: {
// Cure_R::SetPreset(pCVar17,0x2d02bc);
struct Crossfeed::Preset preset = {
.cutoff = 700,
.feedback = 45,
};
this->cure->SetPreset(preset);
break;
}
}
break;
} // 0x1002E
@ -598,7 +616,7 @@ void ViPER::ResetAllEffects() {
}
for (auto &softwareLimiter: softwareLimiters) {
if (softwareLimiter != nullptr) {
softwareLimiter->ResetLimiter();
softwareLimiter->Reset();
}
}
}

View File

@ -18,8 +18,6 @@ PlaybackGain::PlaybackGain() {
}
double PlaybackGain::AnalyseWave(float *samples, uint32_t size) {
if (size == 0) return 0.0;
double tmpL = 0.0;
double tmpR = 0.0;

View File

@ -9,11 +9,13 @@ SoftwareLimiter::SoftwareLimiter() {
this->gate = 0.999999;
this->unknown3 = 1.0;
this->unknown1 = 1.0;
this->ResetLimiter();
Reset();
}
float SoftwareLimiter::Process(float sample) {
bool bVar1;
float *pfVar2;
uint uVar3;
uint uVar4;
int iVar5;
@ -22,16 +24,26 @@ float SoftwareLimiter::Process(float sample) {
uint uVar8;
float fVar9;
float fVar10;
float gate;
float abs_sample;
float abs_sample = std::abs(sample);
if (abs_sample < this->gate) {
gate = this->gate;
abs_sample = std::abs(sample);
if (abs_sample < gate) {
if (this->ready) goto LAB_0006d86c;
uVar8 = this->unknown4;
} else {
}
else {
if (!this->ready) {
memset(this->arr512, 0, sizeof(this->arr512));
this->ready = true;
iVar5 = 0x200;
pfVar2 = this->arr512;
do {
iVar5 = iVar5 + -1;
*pfVar2 = 0.0;
pfVar2 = pfVar2 + 1;
} while (iVar5 != 0);
}
this->ready = true;
LAB_0006d86c:
uVar3 = 8;
puVar7 = &this->unknown4;
@ -47,11 +59,16 @@ LAB_0006d86c:
}
uVar3 = uVar3 - 1;
} while (uVar3 != 0);
if (this->gate < abs_sample) {
gate = this->gate;
if (gate < abs_sample) {
bVar1 = this->ready;
fVar10 = this->unknown1;
uVar4 = uVar8 + 1 & 0xff;
this->arr256[uVar8] = sample;
this->unknown4 = uVar4;
fVar10 = this->gate / abs_sample;
if (bVar1) {
fVar10 = gate / abs_sample;
}
abs_sample = this->arr256[uVar4];
goto LAB_0006d8fc;
}
@ -77,17 +94,20 @@ LAB_0006d8fc:
this->unknown2 = fVar9;
}
fVar9 = abs_sample * fVar9;
if (this->gate <= std::abs(fVar9)) {
fVar9 = this->gate / std::abs(abs_sample);
fVar10 = std::abs(fVar9);
if (gate <= fVar10) {
fVar9 = gate / std::abs(abs_sample);
}
if (gate <= fVar10) {
this->unknown2 = fVar9;
fVar9 = abs_sample * fVar9;
}
return fVar9;
}
void SoftwareLimiter::ResetLimiter() {
memset(this->arr256, 0, 256);
memset(this->arr512, 0, 512);
void SoftwareLimiter::Reset() {
memset(this->arr256, 0, sizeof(this->arr256));
memset(this->arr512, 0, sizeof(this->arr512));
this->ready = false;
this->unknown4 = 0;
this->unknown2 = 1.0;

View File

@ -7,7 +7,7 @@ public:
SoftwareLimiter();
float Process(float sample);
void ResetLimiter();
void Reset();
void SetGate(float gate);
private:

View File

@ -40,15 +40,15 @@ void SpectrumExtend::Process(float *samples, uint32_t size) {
}
void SpectrumExtend::Reset() {
this->highpass[0].RefreshFilter(MultiBiquad::FilterType::HIGH_PASS, 0.0, (float) this->referenceFreq, (float) this->samplingRate,
this->highpass[0].RefreshFilter(MultiBiquad::FilterType::HIGH_PASS, 0.0, (float) this->referenceFreq, this->samplingRate,
0.717, false);
this->highpass[1].RefreshFilter(MultiBiquad::FilterType::HIGH_PASS, 0.0, (float) this->referenceFreq, (float) this->samplingRate,
this->highpass[1].RefreshFilter(MultiBiquad::FilterType::HIGH_PASS, 0.0, (float) this->referenceFreq, this->samplingRate,
0.717, false);
this->lowpass[0].RefreshFilter(MultiBiquad::FilterType::LOW_PASS, 0.0, (float) this->referenceFreq / 2.f - 2000.f,
(float) this->referenceFreq, 0.717, false);
this->referenceFreq, 0.717, false);
this->lowpass[1].RefreshFilter(MultiBiquad::FilterType::LOW_PASS, 0.0, (float) this->referenceFreq / 2.f - 2000.f,
(float) this->referenceFreq, 0.717, false);
this->referenceFreq, 0.717, false);
this->harmonics[0].Reset();
this->harmonics[1].Reset();

View File

@ -27,10 +27,7 @@ float CCombFilter::Process(float sample) {
float output = this->buffer[this->bufferIndex];
this->filterStore = output * this->damp2 + this->filterStore * this->damp;
this->buffer[this->bufferIndex] = sample + this->filterStore * this->feedback;
this->bufferIndex++;
if (this->bufferIndex >= this->bufferSize) {
this->bufferIndex = 0;
}
this->bufferIndex = (this->bufferIndex + 1) % this->bufferSize;
return output;
}

View File

@ -123,20 +123,20 @@ void CRevModel::ProcessReplace(float *bufL, float *bufR, uint32_t size) {
for (uint32_t idx = 0; idx < size; idx++) {
float outL = 0.0;
float outR = 0.0;
float input = (bufL[idx] + bufR[idx]) * gain;
float input = (bufL[idx] + bufR[idx]) * this->gain;
for (uint32_t i = 0; i < 8; i++) {
outL += combL[i].Process(input);
outR += combR[i].Process(input);
outL += this->combL[i].Process(input);
outR += this->combR[i].Process(input);
}
for (uint32_t i = 0; i < 4; i++) {
outL = allpassL[i].Process(outL);
outR = allpassR[i].Process(outR);
outL = this->allpassL[i].Process(outL);
outR = this->allpassR[i].Process(outR);
}
bufL[idx] = outL * unknown1 + outR * unknown2 + bufL[idx] * dry;
bufR[idx] = outR * unknown1 + outL * unknown2 + bufR[idx] * dry;
bufL[idx] = outL * this->unknown1 + outR * this->unknown2 + bufL[idx] * this->dry;
bufR[idx] = outR * this->unknown1 + outL * this->unknown2 + bufR[idx] * this->dry;
}
}

View File

@ -55,8 +55,8 @@ struct Crossfeed::Preset Crossfeed::GetPreset() {
}
void Crossfeed::ProcessFrames(float *buffer, uint32_t size) {
for (uint32_t i = 0; i < size; i += 2) {
FilterSample(&buffer[i]);
for (uint32_t i = 0; i < size * 2; i += 2) {
FilterSample(buffer + i);
}
}