ProcessUnit_FX: Implement constructor, destructor and ResetAllEffects()

This commit is contained in:
Iscle 2022-08-24 01:08:20 +02:00
parent 3fd428155e
commit 2f2211821a
12 changed files with 355 additions and 17 deletions

View File

@ -33,7 +33,8 @@ Effect::Effect() {
Effect::~Effect() {
if (this->buffer != nullptr) {
free(this->buffer);
delete this->buffer;
this->buffer = nullptr;
}
}

View File

@ -9,10 +9,193 @@
ProcessUnit_FX::ProcessUnit_FX() {
v4a_print(ANDROID_LOG_INFO, "Welcome to ViPER4Android Reworked driver[SQ]");
v4a_printf(ANDROID_LOG_INFO, "Current version is %s %s", VERSION_STRING, VERSION_CODENAME);
this->adaptiveBuffer = new AdaptiveBuffer_F32(2, 4096);
this->waveBuffer = new WaveBuffer_I32(2, 4096);
this->convolver = new Convolver();
// this->convolver->SetEnable(false);
// this->convolver->SetSamplingRate(this->sampleRate);
// this->convolver->Reset();
this->vhe = new VHE();
this->vhe->SetEnable(false);
this->vhe->SetSamplingRate(this->sampleRate);
this->vhe->Reset();
this->viperDdc = new ViPERDDC();
// this->viperDdc->SetEnable(false);
// this->viperDdc->SetSamplingRate(this->sampleRate);
// this->viperDdc->Reset();
this->spectrumExtend = new SpectrumExtend();
this->spectrumExtend->SetEnable(false);
this->spectrumExtend->SetSamplingRate(this->sampleRate);
this->spectrumExtend->SetReferenceFrequency(7600);
this->spectrumExtend->SetExciter(0);
this->spectrumExtend->Reset();
this->iirFilter = new IIRFilter();
// this->iirFilter->SetEnable(false);
// this->iirFilter->SetSamplingRate(this->sampleRate);
// this->iirFilter->Reset();
this->colorfulMusic = new ColorfulMusic();
// this->colorfulMusic->SetEnable(false);
// this->colorfulMusic->SetSamplingRate(this->sampleRate);
// this->colorfulMusic->Reset();
this->reverberation = new Reverberation();
this->reverberation->SetEnable(false);
this->reverberation->SetSamplingRate(this->sampleRate);
this->reverberation->Reset();
this->playbackGain = new PlaybackGain();
// this->playbackGain->SetEnable(false);
// this->playbackGain->SetSamplingRate(this->sampleRate);
// this->playbackGain->Reset();
this->fetCompressor = new FETCompressor();
// this->fetCompressor->SetEnable(false);
// this->fetCompressor->SetSamplingRate(this->sampleRate);
// this->fetCompressor->Reset();
this->dynamicSystem = new DynamicSystem();
this->dynamicSystem->SetEnable(false);
this->dynamicSystem->SetSamplingRate(this->sampleRate);
this->dynamicSystem->Reset();
this->viperBass = new ViPERBass();
// this->viperBass->SetEnable(false);
// this->viperBass->SetSamplingRate(this->sampleRate);
// this->viperBass->Reset();
this->viperClarity = new ViPERClarity();
this->viperClarity->SetEnable(false);
this->viperClarity->SetSamplingRate(this->sampleRate);
this->viperClarity->Reset();
this->diffSurround = new DiffSurround();
this->diffSurround->SetEnable(false);
this->diffSurround->SetSamplingRate(this->sampleRate);
this->diffSurround->Reset();
this->cure = new Cure();
this->cure->SetEnable(false);
this->cure->SetSamplingRate(this->sampleRate);
this->cure->Reset();
this->tubeSimulator = new TubeSimulator();
// this->tubeSimulator->SetEnable(false);
// this->tubeSimulator->SetSamplingRate(this->sampleRate);
this->tubeSimulator->Reset();
this->analogX = new AnalogX();
// this->analogX->SetEnable(false);
this->analogX->SetSamplingRate(this->sampleRate);
this->analogX->SetProcessingModel(0);
this->analogX->Reset();
this->speakerCorrection = new SpeakerCorrection();
this->speakerCorrection->SetEnable(false);
this->speakerCorrection->SetSamplingRate(this->sampleRate);
this->speakerCorrection->Reset();
for (int i = 0; i < sizeof(softwareLimiters); i++) {
this->softwareLimiters[i] = new SoftwareLimiter();
// this->softwareLimiters[i]->ResetLimiter();
}
this->init_ok = true;
this->enabled = false;
this->force_enabled = false;
this->mode = ViPER_FX_TYPE_NONE; // 0
}
ProcessUnit_FX::~ProcessUnit_FX() {
if (this->adaptiveBuffer != nullptr) {
delete this->adaptiveBuffer;
this->adaptiveBuffer = nullptr;
}
if (this->waveBuffer != nullptr) {
delete this->waveBuffer;
this->waveBuffer = nullptr;
}
if (this->convolver != nullptr) {
delete this->convolver;
this->convolver = nullptr;
}
if (this->vhe != nullptr) {
delete this->vhe;
this->vhe = nullptr;
}
if (this->viperDdc != nullptr) {
delete this->viperDdc;
this->viperDdc = nullptr;
}
if (this->spectrumExtend != nullptr) {
delete this->spectrumExtend;
this->spectrumExtend = nullptr;
}
if (this->iirFilter != nullptr) {
delete this->iirFilter;
this->iirFilter = nullptr;
}
if (this->colorfulMusic != nullptr) {
delete this->colorfulMusic;
this->colorfulMusic = nullptr;
}
if (this->reverberation != nullptr) {
delete this->reverberation;
this->reverberation = nullptr;
}
if (this->playbackGain != nullptr) {
delete this->playbackGain;
this->playbackGain = nullptr;
}
if (this->fetCompressor != nullptr) {
delete this->fetCompressor;
this->fetCompressor = nullptr;
}
if (this->dynamicSystem != nullptr) {
delete this->dynamicSystem;
this->dynamicSystem = nullptr;
}
if (this->viperBass != nullptr) {
delete this->viperBass;
this->viperBass = nullptr;
}
if (this->viperClarity != nullptr) {
delete this->viperClarity;
this->viperClarity = nullptr;
}
if (this->diffSurround != nullptr) {
delete this->diffSurround;
this->diffSurround = nullptr;
}
if (this->cure != nullptr) {
delete this->cure;
this->cure = nullptr;
}
if (this->tubeSimulator != nullptr) {
delete this->tubeSimulator;
this->tubeSimulator = nullptr;
}
if (this->analogX != nullptr) {
delete this->analogX;
this->analogX = nullptr;
}
if (this->speakerCorrection != nullptr) {
delete this->speakerCorrection;
this->speakerCorrection = nullptr;
}
for (int i = 0; i < sizeof(softwareLimiters); i++) {
if (softwareLimiters[i] != nullptr) {
delete softwareLimiters[i];
softwareLimiters[i] = nullptr;
}
}
}
int32_t
@ -31,5 +214,82 @@ void ProcessUnit_FX::DispatchCommand(int param_1, int param_2, int param_3, int
}
void ProcessUnit_FX::ResetAllEffects() {
// TODO
if (this->adaptiveBuffer != nullptr) {
// this->adaptiveBuffer->FlushBuffer();
}
if (this->waveBuffer != nullptr) {
this->waveBuffer->Reset();
}
if (this->convolver != nullptr) {
// this->convolver->SetSamplingRate(this->sampleRate);
// this->convolver->Reset();
}
if (this->vhe != nullptr) {
this->vhe->SetSamplingRate(this->sampleRate);
this->vhe->Reset();
}
if (this->viperDdc != nullptr) {
// this->viperDdc->SetSamplingRate(this->sampleRate);
// this->viperDdc->Reset();
}
if (this->spectrumExtend != nullptr) {
this->spectrumExtend->SetSamplingRate(this->sampleRate);
this->spectrumExtend->Reset();
}
if (this->iirFilter != nullptr) {
// this->iirFilter->SetSamplingRate(this->sampleRate);
// this->iirFilter->Reset();
}
if (this->colorfulMusic != nullptr) {
// this->colorfulMusic->SetSamplingRate(this->sampleRate);
// this->colorfulMusic->Reset();
}
if (this->reverberation != nullptr) {
this->reverberation->SetSamplingRate(this->sampleRate);
this->reverberation->Reset();
}
if (this->playbackGain != nullptr) {
// this->playbackGain->SetSamplingRate(this->sampleRate);
// this->playbackGain->Reset();
}
if (this->fetCompressor != nullptr) {
// this->fetCompressor->SetSamplingRate(this->sampleRate);
// this->fetCompressor->Reset();
}
if (this->dynamicSystem != nullptr) {
this->dynamicSystem->SetSamplingRate(this->sampleRate);
this->dynamicSystem->Reset();
}
if (this->viperBass != nullptr) {
// this->viperBass->SetSamplingRate(this->sampleRate);
// this->viperBass->Reset();
}
if (this->viperClarity != nullptr) {
this->viperClarity->SetSamplingRate(this->sampleRate);
this->viperClarity->Reset();
}
if (this->diffSurround != nullptr) {
this->diffSurround->SetSamplingRate(this->sampleRate);
this->diffSurround->Reset();
}
if (this->cure != nullptr) {
this->cure->SetSamplingRate(this->sampleRate);
this->cure->Reset();
}
if (this->tubeSimulator != nullptr) {
// this->tubeSimulator->Reset();
}
if (this->analogX != nullptr) {
this->analogX->SetSamplingRate(this->sampleRate);
this->analogX->Reset();
}
if (this->speakerCorrection != nullptr) {
this->speakerCorrection->SetSamplingRate(this->sampleRate);
this->speakerCorrection->Reset();
}
for (int i = 0; i < sizeof(softwareLimiters); i++) {
if (softwareLimiters[i] != nullptr) {
// softwareLimiters[i]->Reset();
}
}
}

View File

@ -16,6 +16,15 @@
#include "effects/Cure.h"
#include "effects/DiffSurround.h"
#include "effects/VHE.h"
#include "effects/AdaptiveBuffer_F32.h"
#include "effects/Convolver.h"
#include "effects/ViPERDDC.h"
#include "effects/IIRFilter.h"
#include "effects/ColorfulMusic.h"
#include "effects/FETCompressor.h"
#include "effects/ViPERBass.h"
#include "effects/SoftwareLimiter.h"
#include "effects/PlaybackGain.h"
class ProcessUnit_FX : public Effect {
public:
@ -35,26 +44,27 @@ public:
bool init_ok, enabled, force_enabled, fetcomp_enabled;
FxMode mode;
// AdaptiveBuffer_F32* adaptiveBuffer;
// Effects
AdaptiveBuffer_F32 *adaptiveBuffer;
WaveBuffer_I32 *waveBuffer;
// Convolver* convolver;
Convolver *convolver;
VHE *vhe;
// ViPERDDC* vddc;
ViPERDDC *viperDdc;
SpectrumExtend *spectrumExtend;
// IIRFilter* iirfilter;
// ColorfulMusic* colm;
Reverberation *reverb;
// PlaybackGain* playbackGain;
// FETCompressor* fetcomp;
DynamicSystem *dynsys;
// ViPERBass* bass;
ViPERClarity *clarity;
IIRFilter *iirFilter;
ColorfulMusic *colorfulMusic;
Reverberation *reverberation;
PlaybackGain *playbackGain;
FETCompressor *fetCompressor;
DynamicSystem *dynamicSystem;
ViPERBass *viperBass;
ViPERClarity *viperClarity;
DiffSurround *diffSurround;
Cure *cure;
TubeSimulator *tube;
AnalogX *analogx;
TubeSimulator *tubeSimulator;
AnalogX *analogX;
SpeakerCorrection *speakerCorrection;
// SoftwareLimiter* limiter[2];
SoftwareLimiter *softwareLimiters[2];
int unk[3];
};

View File

@ -0,0 +1,11 @@
#pragma once
#include <cstdint>
class AdaptiveBuffer_F32 {
public:
AdaptiveBuffer_F32(int channels, uint32_t size);
// TODO
};

View File

@ -0,0 +1,7 @@
#pragma once
class ColorfulMusic {
// TODO
};

View File

@ -0,0 +1,7 @@
#pragma once
class Convolver {
// TODO
};

View File

@ -0,0 +1,7 @@
#pragma once
class FETCompressor {
// TODO
};

View File

@ -0,0 +1,7 @@
#pragma once
class IIRFilter {
// TODO
};

View File

@ -0,0 +1,7 @@
#pragma once
class PlaybackGain {
// TODO
};

View File

@ -0,0 +1,7 @@
#pragma once
class SoftwareLimiter {
// TODO
};

View File

@ -0,0 +1,7 @@
#pragma once
class ViPERBass {
// TODO
};

View File

@ -0,0 +1,7 @@
#pragma once
class ViPERDDC {
// TODO
};