From 2f2211821a0eec5e092aedf21372931db4107896 Mon Sep 17 00:00:00 2001 From: Iscle Date: Wed, 24 Aug 2022 01:08:20 +0200 Subject: [PATCH] ProcessUnit_FX: Implement constructor, destructor and ResetAllEffects() --- src/cpp/Effect.cpp | 3 +- src/cpp/ProcessUnit_FX.cpp | 264 ++++++++++++++++++++++++++- src/cpp/ProcessUnit_FX.h | 38 ++-- src/cpp/effects/AdaptiveBuffer_F32.h | 11 ++ src/cpp/effects/ColorfulMusic.h | 7 + src/cpp/effects/Convolver.h | 7 + src/cpp/effects/FETCompressor.h | 7 + src/cpp/effects/IIRFilter.h | 7 + src/cpp/effects/PlaybackGain.h | 7 + src/cpp/effects/SoftwareLimiter.h | 7 + src/cpp/effects/ViPERBass.h | 7 + src/cpp/effects/ViPERDDC.h | 7 + 12 files changed, 355 insertions(+), 17 deletions(-) create mode 100644 src/cpp/effects/AdaptiveBuffer_F32.h create mode 100644 src/cpp/effects/ColorfulMusic.h create mode 100644 src/cpp/effects/Convolver.h create mode 100644 src/cpp/effects/FETCompressor.h create mode 100644 src/cpp/effects/IIRFilter.h create mode 100644 src/cpp/effects/PlaybackGain.h create mode 100644 src/cpp/effects/SoftwareLimiter.h create mode 100644 src/cpp/effects/ViPERBass.h create mode 100644 src/cpp/effects/ViPERDDC.h diff --git a/src/cpp/Effect.cpp b/src/cpp/Effect.cpp index 8e01ca5..c985235 100644 --- a/src/cpp/Effect.cpp +++ b/src/cpp/Effect.cpp @@ -33,7 +33,8 @@ Effect::Effect() { Effect::~Effect() { if (this->buffer != nullptr) { - free(this->buffer); + delete this->buffer; + this->buffer = nullptr; } } diff --git a/src/cpp/ProcessUnit_FX.cpp b/src/cpp/ProcessUnit_FX.cpp index c67d400..672c4ae 100644 --- a/src/cpp/ProcessUnit_FX.cpp +++ b/src/cpp/ProcessUnit_FX.cpp @@ -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(); + } + } } diff --git a/src/cpp/ProcessUnit_FX.h b/src/cpp/ProcessUnit_FX.h index effecf3..e92fc0d 100644 --- a/src/cpp/ProcessUnit_FX.h +++ b/src/cpp/ProcessUnit_FX.h @@ -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]; }; diff --git a/src/cpp/effects/AdaptiveBuffer_F32.h b/src/cpp/effects/AdaptiveBuffer_F32.h new file mode 100644 index 0000000..3b9c42a --- /dev/null +++ b/src/cpp/effects/AdaptiveBuffer_F32.h @@ -0,0 +1,11 @@ +#pragma once + +#include + +class AdaptiveBuffer_F32 { +public: + AdaptiveBuffer_F32(int channels, uint32_t size); + // TODO +}; + + diff --git a/src/cpp/effects/ColorfulMusic.h b/src/cpp/effects/ColorfulMusic.h new file mode 100644 index 0000000..c631545 --- /dev/null +++ b/src/cpp/effects/ColorfulMusic.h @@ -0,0 +1,7 @@ +#pragma once + +class ColorfulMusic { + // TODO +}; + + diff --git a/src/cpp/effects/Convolver.h b/src/cpp/effects/Convolver.h new file mode 100644 index 0000000..52f6e00 --- /dev/null +++ b/src/cpp/effects/Convolver.h @@ -0,0 +1,7 @@ +#pragma once + +class Convolver { + // TODO +}; + + diff --git a/src/cpp/effects/FETCompressor.h b/src/cpp/effects/FETCompressor.h new file mode 100644 index 0000000..f215ecd --- /dev/null +++ b/src/cpp/effects/FETCompressor.h @@ -0,0 +1,7 @@ +#pragma once + +class FETCompressor { + // TODO +}; + + diff --git a/src/cpp/effects/IIRFilter.h b/src/cpp/effects/IIRFilter.h new file mode 100644 index 0000000..1a46e42 --- /dev/null +++ b/src/cpp/effects/IIRFilter.h @@ -0,0 +1,7 @@ +#pragma once + +class IIRFilter { + // TODO +}; + + diff --git a/src/cpp/effects/PlaybackGain.h b/src/cpp/effects/PlaybackGain.h new file mode 100644 index 0000000..db1e4b7 --- /dev/null +++ b/src/cpp/effects/PlaybackGain.h @@ -0,0 +1,7 @@ +#pragma once + +class PlaybackGain { + // TODO +}; + + diff --git a/src/cpp/effects/SoftwareLimiter.h b/src/cpp/effects/SoftwareLimiter.h new file mode 100644 index 0000000..e610d8a --- /dev/null +++ b/src/cpp/effects/SoftwareLimiter.h @@ -0,0 +1,7 @@ +#pragma once + +class SoftwareLimiter { + // TODO +}; + + diff --git a/src/cpp/effects/ViPERBass.h b/src/cpp/effects/ViPERBass.h new file mode 100644 index 0000000..1b590ab --- /dev/null +++ b/src/cpp/effects/ViPERBass.h @@ -0,0 +1,7 @@ +#pragma once + +class ViPERBass { + // TODO +}; + + diff --git a/src/cpp/effects/ViPERDDC.h b/src/cpp/effects/ViPERDDC.h new file mode 100644 index 0000000..2f2a1cb --- /dev/null +++ b/src/cpp/effects/ViPERDDC.h @@ -0,0 +1,7 @@ +#pragma once + +class ViPERDDC { + // TODO +}; + +