From 3e6be85fe6eea0c304c77ada82eab8c07435fede Mon Sep 17 00:00:00 2001 From: Iscle Date: Sun, 25 Sep 2022 01:28:56 +0200 Subject: [PATCH] Update --- src/cpp/viper/effects/SoftwareLimiter.cpp | 24 ++++++++++----- src/cpp/viper/effects/SoftwareLimiter.h | 12 +++++++- src/cpp/viper/utils/NoiseSharpening.cpp | 6 ++-- src/cpp/viper/utils/PolesFilter.cpp | 10 +++---- src/cpp/viper/utils/Stereo3DSurround.cpp | 36 ++++++++++++++++++----- src/cpp/viper/utils/Stereo3DSurround.h | 4 ++- 6 files changed, 66 insertions(+), 26 deletions(-) diff --git a/src/cpp/viper/effects/SoftwareLimiter.cpp b/src/cpp/viper/effects/SoftwareLimiter.cpp index 85d7c7e..9cc6d59 100644 --- a/src/cpp/viper/effects/SoftwareLimiter.cpp +++ b/src/cpp/viper/effects/SoftwareLimiter.cpp @@ -1,11 +1,14 @@ +#include #include "SoftwareLimiter.h" SoftwareLimiter::SoftwareLimiter() { - -} - -SoftwareLimiter::~SoftwareLimiter() { - + this->ready = false; + this->unknown4 = 0; + this->unknown2 = 1.0; + this->gate = 0.999999; + this->unknown3 = 1.0; + this->unknown1 = 1.0; + this->ResetLimiter(); } void SoftwareLimiter::Process(float *samples, uint32_t size) { @@ -13,9 +16,14 @@ void SoftwareLimiter::Process(float *samples, uint32_t size) { } void SoftwareLimiter::ResetLimiter() { - + memset(this->arr256, 0, 256); + memset(this->arr512, 0, 512); + this->ready = false; + this->unknown4 = 0; + this->unknown2 = 1.0; + this->unknown3 = 1.0; } -void SoftwareLimiter::SetGate() { - +void SoftwareLimiter::SetGate(float gate) { + this->gate = gate; } diff --git a/src/cpp/viper/effects/SoftwareLimiter.h b/src/cpp/viper/effects/SoftwareLimiter.h index 23bfc12..60b7e7f 100644 --- a/src/cpp/viper/effects/SoftwareLimiter.h +++ b/src/cpp/viper/effects/SoftwareLimiter.h @@ -9,7 +9,17 @@ public: void Process(float *samples, uint32_t size); void ResetLimiter(); - void SetGate(); + void SetGate(float gate); + +private: + float gate; + float unknown1; + float unknown2; + float unknown3; + float arr256[256]; + float arr512[512]; + uint32_t unknown4; + bool ready; }; diff --git a/src/cpp/viper/utils/NoiseSharpening.cpp b/src/cpp/viper/utils/NoiseSharpening.cpp index be44dba..232e80f 100644 --- a/src/cpp/viper/utils/NoiseSharpening.cpp +++ b/src/cpp/viper/utils/NoiseSharpening.cpp @@ -3,7 +3,7 @@ NoiseSharpening::NoiseSharpening() { this->samplingRate = DEFAULT_SAMPLERATE; - this->gain = 0.f; + this->gain = 0.0; Reset(); } @@ -36,9 +36,9 @@ void NoiseSharpening::Process(float *buffer, uint32_t size) { void NoiseSharpening::Reset() { for (int i = 0; i < 2; i++) { - this->filters[i].setLPF_BW(this->samplingRate / 2.f - 1000.f, this->samplingRate); + this->filters[i].setLPF_BW((float) ((double) this->samplingRate / 2.0 - 1000.0), this->samplingRate); this->filters[i].Mute(); - this->in[i] = 0.f; + this->in[i] = 0.0; } } diff --git a/src/cpp/viper/utils/PolesFilter.cpp b/src/cpp/viper/utils/PolesFilter.cpp index 9da2d68..f034c32 100644 --- a/src/cpp/viper/utils/PolesFilter.cpp +++ b/src/cpp/viper/utils/PolesFilter.cpp @@ -18,13 +18,13 @@ void PolesFilter::UpdateCoeff() { memset(&this->channels[0], 0, sizeof(channel)); memset(&this->channels[1], 0, sizeof(channel)); - this->channels[0].lower_angle = ((float) this->lower_freq * M_PI / (float) this->samplingRate); - this->channels[1].lower_angle = ((float) this->lower_freq * M_PI / (float) this->samplingRate); - this->channels[0].upper_angle = ((float) this->upper_freq * M_PI / (float) this->samplingRate); - this->channels[1].upper_angle = ((float) this->upper_freq * M_PI / (float) this->samplingRate); + this->channels[0].lower_angle = (float) this->lower_freq * (float) M_PI / (float) this->samplingRate; + this->channels[1].lower_angle = (float) this->lower_freq * (float) M_PI / (float) this->samplingRate; + this->channels[0].upper_angle = (float) this->upper_freq * (float) M_PI / (float) this->samplingRate; + this->channels[1].upper_angle = (float) this->upper_freq * (float) M_PI / (float) this->samplingRate; } -inline void DoFilterSide(channel *side, float sample, float *out1, float *out2, float *out3) { +static inline void DoFilterSide(channel *side, float sample, float *out1, float *out2, float *out3) { float oldestSampleIn = side->in[2]; side->in[2] = side->in[1]; side->in[1] = side->in[0]; diff --git a/src/cpp/viper/utils/Stereo3DSurround.cpp b/src/cpp/viper/utils/Stereo3DSurround.cpp index f4f183e..f71df3d 100644 --- a/src/cpp/viper/utils/Stereo3DSurround.cpp +++ b/src/cpp/viper/utils/Stereo3DSurround.cpp @@ -1,22 +1,42 @@ #include "Stereo3DSurround.h" Stereo3DSurround::Stereo3DSurround() { - this->midImage = 1.0f; - this->stereoWiden = 0.0f; - this->unknown1 = 1.0f; - this->unknown2 = 0.5f; - this->coeffLeft = 0.5f; - this->coeffRight = 0.5f; + this->middleImage = 1.0; + this->stereoWiden = 0.0; + this->unknown1 = 1.0; + this->unknown2 = 0.5; + this->coeffLeft = 0.5; + this->coeffRight = 0.5; } void Stereo3DSurround::Process(float *samples, uint32_t size) { + if (size >= 2) { + } +} + +inline void Stereo3DSurround::ConfigureVariables() { + this->unknown1 = this->stereoWiden + 1.0f; + + float x = this->unknown1 + 1.0f; + float y; + if (x < 2.0) { + y = 0.5; + } else { + y = 1.0f / x; + } + + this->unknown2 = y; + this->coeffLeft = this->middleImage * y; + this->coeffRight = this->unknown1 * y; } void Stereo3DSurround::SetMiddleImage(float middleImage) { - + this->middleImage = middleImage; + this->ConfigureVariables(); } void Stereo3DSurround::SetStereoWiden(float stereoWiden) { - + this->stereoWiden = stereoWiden; + this->ConfigureVariables(); } diff --git a/src/cpp/viper/utils/Stereo3DSurround.h b/src/cpp/viper/utils/Stereo3DSurround.h index 7d3822b..e252900 100644 --- a/src/cpp/viper/utils/Stereo3DSurround.h +++ b/src/cpp/viper/utils/Stereo3DSurround.h @@ -11,8 +11,10 @@ public: void SetStereoWiden(float stereoWiden); private: + void ConfigureVariables(); + float stereoWiden; - float midImage; + float middleImage; float unknown1; float unknown2; float coeffLeft;