This commit is contained in:
Iscle
2022-09-16 03:16:58 +02:00
parent fcd7da0f13
commit 40339a15cd
32 changed files with 363 additions and 162 deletions

View File

@ -50,6 +50,7 @@ set(FILES
src/cpp/viper/utils/Crossfeed.cpp src/cpp/viper/utils/Crossfeed.cpp
src/cpp/viper/utils/DepthSurround.cpp src/cpp/viper/utils/DepthSurround.cpp
src/cpp/viper/utils/DynamicBass.cpp src/cpp/viper/utils/DynamicBass.cpp
src/cpp/viper/utils/FIR.cpp
src/cpp/viper/utils/FixedBiquad.cpp src/cpp/viper/utils/FixedBiquad.cpp
src/cpp/viper/utils/Harmonic.cpp src/cpp/viper/utils/Harmonic.cpp
src/cpp/viper/utils/HiFi.cpp src/cpp/viper/utils/HiFi.cpp
@ -62,6 +63,8 @@ set(FILES
src/cpp/viper/utils/PassFilter.cpp src/cpp/viper/utils/PassFilter.cpp
src/cpp/viper/utils/PConvSingle_F32.cpp src/cpp/viper/utils/PConvSingle_F32.cpp
src/cpp/viper/utils/PolesFilter.cpp src/cpp/viper/utils/PolesFilter.cpp
src/cpp/viper/utils/Polyphase.cpp
src/cpp/viper/utils/Stereo3DSurround.cpp
src/cpp/viper/utils/Subwoofer.cpp src/cpp/viper/utils/Subwoofer.cpp
src/cpp/viper/utils/TimeConstDelay.cpp src/cpp/viper/utils/TimeConstDelay.cpp
src/cpp/viper/utils/WaveBuffer_I32.cpp) src/cpp/viper/utils/WaveBuffer_I32.cpp)

View File

@ -87,7 +87,7 @@ ViPER::ViPER() {
this->tubeSimulator->Reset(); this->tubeSimulator->Reset();
this->analogX = new AnalogX(); this->analogX = new AnalogX();
this->analogX->enabled = false; //SetEnable(false); // this->analogX->SetEnable(false);
this->analogX->SetSamplingRate(this->sampleRate); this->analogX->SetSamplingRate(this->sampleRate);
this->analogX->SetProcessingModel(0); this->analogX->SetProcessingModel(0);
this->analogX->Reset(); this->analogX->Reset();
@ -104,10 +104,10 @@ ViPER::ViPER() {
this->fetcomp_enabled = false; this->fetcomp_enabled = false;
this->init_ok = true; this->init_ok = true;
this->scale_frames_if_not_1point0 = 1.0; this->frame_scale = 1.0;
this->pan_frames_if_less_than_1point0 = 1.0; this->left_pan = 1.0;
this->process_time_ms = 0; this->process_time_ms = 0;
this->pan_frames_if_less_than_1point0_2 = 1.0; this->right_pan = 1.0;
this->enabled = false; this->enabled = false;
this->force_enabled = false; this->force_enabled = false;
this->update_status = false; this->update_status = false;
@ -171,7 +171,7 @@ ViPER::~ViPER() {
delete this->speakerCorrection; delete this->speakerCorrection;
this->speakerCorrection = nullptr; this->speakerCorrection = nullptr;
for (auto &softwareLimiter: softwareLimiters) { for (auto &softwareLimiter: this->softwareLimiters) {
delete softwareLimiter; delete softwareLimiter;
softwareLimiter = nullptr; softwareLimiter = nullptr;
} }
@ -322,7 +322,7 @@ void ViPER::processBuffer(float *buffer, int frameSize) {
this->process_time_ms = time.tv_sec * 1000 + time.tv_usec / 1000; this->process_time_ms = time.tv_sec * 1000 + time.tv_usec / 1000;
} }
int ret; uint32_t ret;
// if convolver is enabled // if convolver is enabled
ret = this->waveBuffer->PushSamples(buffer, frameSize); ret = this->waveBuffer->PushSamples(buffer, frameSize);
@ -366,11 +366,11 @@ void ViPER::processBuffer(float *buffer, int frameSize) {
this->analogX->Process(pAdaptiveBuffer, ret); this->analogX->Process(pAdaptiveBuffer, ret);
} }
if (this->scale_frames_if_not_1point0 != 1.0) { if (this->frame_scale != 1.0) {
this->adaptiveBuffer->ScaleFrames(this->scale_frames_if_not_1point0); this->adaptiveBuffer->ScaleFrames(this->frame_scale);
} }
if (this->pan_frames_if_less_than_1point0 < 1.0 || this->pan_frames_if_less_than_1point0_2 < 1.0) { if (this->left_pan < 1.0 || this->right_pan < 1.0) {
this->adaptiveBuffer->PanFrames(this->pan_frames_if_less_than_1point0, this->pan_frames_if_less_than_1point0_2); this->adaptiveBuffer->PanFrames(this->left_pan, this->right_pan);
} }
if (ret << 1 != 0) { if (ret << 1 != 0) {

View File

@ -73,7 +73,7 @@ public:
SpeakerCorrection *speakerCorrection; SpeakerCorrection *speakerCorrection;
SoftwareLimiter *softwareLimiters[2]; SoftwareLimiter *softwareLimiters[2];
float scale_frames_if_not_1point0; float frame_scale;
float pan_frames_if_less_than_1point0; float left_pan;
float pan_frames_if_less_than_1point0_2; float right_pan;
}; };

View File

@ -7,12 +7,12 @@ static float ANALOGX_HARMONICS[10] = {
0.02f, 0.02f,
0.0001f, 0.0001f,
0.001f, 0.001f,
0.f, 0.0f,
0.f, 0.0f,
0.f, 0.0f,
0.f, 0.0f,
0.f, 0.0f,
0.f 0.0f
}; };
AnalogX::AnalogX() { AnalogX::AnalogX() {

View File

@ -14,6 +14,7 @@ public:
void SetProcessingModel(int processingModel); void SetProcessingModel(int processingModel);
void SetSamplingRate(uint32_t samplingRate); void SetSamplingRate(uint32_t samplingRate);
private:
MultiBiquad highpass[2]; MultiBiquad highpass[2];
Harmonic harmonic[2]; Harmonic harmonic[2];
MultiBiquad lowpass[2]; MultiBiquad lowpass[2];

View File

@ -1,7 +1,12 @@
#include "ColorfulMusic.h" #include "ColorfulMusic.h"
#include "../constants.h"
ColorfulMusic::ColorfulMusic() { ColorfulMusic::ColorfulMusic() {
this->samplingRate = DEFAULT_SAMPLERATE;
this->enabled = false;
this->stereo3DSurround->SetStereoWiden(0.0f);
this->depthSurround->SetSamplingRate(this->samplingRate);
this->depthSurround->SetStrength(0);
} }
ColorfulMusic::~ColorfulMusic() { ColorfulMusic::~ColorfulMusic() {
@ -9,29 +14,42 @@ ColorfulMusic::~ColorfulMusic() {
} }
void ColorfulMusic::Process(float *samples, uint32_t size) { void ColorfulMusic::Process(float *samples, uint32_t size) {
if (!this->enabled) {
return;
}
this->depthSurround->Process(samples, size);
this->stereo3DSurround->Process(samples, size);
} }
void ColorfulMusic::Reset() { void ColorfulMusic::Reset() {
this->depthSurround->SetSamplingRate(this->samplingRate);
} }
void ColorfulMusic::SetDepthValue() { void ColorfulMusic::SetDepthValue(short depthValue) {
this->depthSurround->SetStrength(depthValue);
} }
void ColorfulMusic::SetEnable(bool enable) { void ColorfulMusic::SetEnable(bool enable) {
if (this->enabled != enable) {
this->enabled = enable;
if (enable) {
Reset();
}
}
} }
void ColorfulMusic::SetMidImageValue() { void ColorfulMusic::SetMidImageValue(float midImageValue) {
this->stereo3DSurround->SetMiddleImage(midImageValue);
} }
void ColorfulMusic::SetSamplingRate(uint32_t samplingRate) { void ColorfulMusic::SetSamplingRate(uint32_t samplingRate) {
if (this->samplingRate != samplingRate) {
this->samplingRate = samplingRate;
this->depthSurround->SetSamplingRate(this->samplingRate);
}
} }
void ColorfulMusic::SetWidenValue() { void ColorfulMusic::SetWidenValue(float widenValue) {
this->stereo3DSurround->SetStereoWiden(widenValue);
} }

View File

@ -1,6 +1,8 @@
#pragma once #pragma once
#include <cstdint> #include <cstdint>
#include "../utils/Stereo3DSurround.h"
#include "../utils/DepthSurround.h"
class ColorfulMusic { class ColorfulMusic {
public: public:
@ -9,11 +11,18 @@ public:
void Process(float *samples, uint32_t size); void Process(float *samples, uint32_t size);
void Reset(); void Reset();
void SetDepthValue(); void SetDepthValue(short depthValue);
void SetEnable(bool enable); void SetEnable(bool enable);
void SetMidImageValue(); void SetMidImageValue(float midImageValue);
void SetSamplingRate(uint32_t samplingRate); void SetSamplingRate(uint32_t samplingRate);
void SetWidenValue(); void SetWidenValue(float widenValue);
private:
Stereo3DSurround *stereo3DSurround;
DepthSurround *depthSurround;
uint32_t samplingRate;
bool enabled;
}; };

View File

@ -26,8 +26,12 @@ void Cure::Reset() {
} }
void Cure::SetEnable(bool enabled) { void Cure::SetEnable(bool enabled) {
Reset(); if (this->enabled != enabled) {
this->enabled = enabled; this->enabled = enabled;
if (enabled) {
Reset();
}
}
} }
void Cure::SetSamplingRate(uint32_t samplerate) { void Cure::SetSamplingRate(uint32_t samplerate) {
@ -53,7 +57,6 @@ preset_t Cure::GetPreset() {
void Cure::SetCutoff(uint16_t cutoff) { void Cure::SetCutoff(uint16_t cutoff) {
this->crossfeed.SetCutoff(cutoff); this->crossfeed.SetCutoff(cutoff);
} }
void Cure::SetFeedback(float feedback) { void Cure::SetFeedback(float feedback) {

View File

@ -1,22 +1,21 @@
//
// Created by mart on 7/31/21.
//
#include <cstring> #include <cstring>
#include "DiffSurround.h" #include "DiffSurround.h"
#include "../constants.h" #include "../constants.h"
DiffSurround::DiffSurround() { DiffSurround::DiffSurround() {
this->samplerate = DEFAULT_SAMPLERATE; this->samplerate = DEFAULT_SAMPLERATE;
this->delayTime = 0.f; this->delayTime = 0.0f;
this->enabled = false; this->enabled = false;
this->buffers[0] = new WaveBuffer_I32(1, 0x1000); for (auto &buffer : this->buffers) {
this->buffers[1] = new WaveBuffer_I32(1, 0x1000); buffer = new WaveBuffer_I32(1, 0x1000);
}
} }
DiffSurround::~DiffSurround() { DiffSurround::~DiffSurround() {
delete this->buffers[0]; for (auto &buffer : this->buffers) {
delete this->buffers[1]; delete buffer;
buffer = nullptr;
}
} }
void DiffSurround::Process(float *samples, uint32_t size) { void DiffSurround::Process(float *samples, uint32_t size) {
@ -44,25 +43,32 @@ void DiffSurround::Process(float *samples, uint32_t size) {
} }
void DiffSurround::Reset() { void DiffSurround::Reset() {
this->buffers[0]->Reset(); for (auto &buffer : this->buffers) {
this->buffers[1]->Reset(); buffer->Reset();
}
this->buffers[1]->PushZeros((uint32_t) (this->delayTime / 1000.f * (float) this->samplerate)); this->buffers[1]->PushZeros((uint32_t) (this->delayTime / 1000.0f * (float) this->samplerate));
} }
void DiffSurround::SetDelayTime(float value) { void DiffSurround::SetDelayTime(float delayTime) {
this->delayTime = value; if (this->delayTime != delayTime) {
Reset(); this->delayTime = delayTime;
this->Reset();
}
} }
void DiffSurround::SetEnable(bool enabled) { void DiffSurround::SetEnable(bool enabled) {
this->enabled = enabled; if (this->enabled != enabled) {
if (this->enabled) { this->enabled = enabled;
Reset(); if (enabled) {
Reset();
}
} }
} }
void DiffSurround::SetSamplingRate(uint32_t samplerate) { void DiffSurround::SetSamplingRate(uint32_t samplerate) {
this->samplerate = samplerate; if (this->samplerate != samplerate) {
Reset(); this->samplerate = samplerate;
this->Reset();
}
} }

View File

@ -10,7 +10,7 @@ public:
void Process(float *samples, uint32_t size); void Process(float *samples, uint32_t size);
void Reset(); void Reset();
void SetDelayTime(float value); void SetDelayTime(float delayTime);
void SetEnable(bool enabled); void SetEnable(bool enabled);
void SetSamplingRate(uint32_t samplerate); void SetSamplingRate(uint32_t samplerate);

View File

@ -28,7 +28,12 @@ void DynamicSystem::SetBassGain(float gain) {
} }
void DynamicSystem::SetEnable(bool enable) { void DynamicSystem::SetEnable(bool enable) {
this->enabled = enable; if (this->enabled != enable) {
this->enabled = enable;
if (enable) {
Reset();
}
}
} }
void DynamicSystem::SetSideGain(float gainX, float gainY) { void DynamicSystem::SetSideGain(float gainX, float gainY) {
@ -44,8 +49,10 @@ void DynamicSystem::SetYCoeffs(uint32_t low, uint32_t high) {
} }
void DynamicSystem::SetSamplingRate(uint32_t samplerate) { void DynamicSystem::SetSamplingRate(uint32_t samplerate) {
this->samplerate = samplerate; if (this->samplerate != samplerate) {
this->bass.SetSamplingRate(samplerate); this->samplerate = samplerate;
this->bass.SetSamplingRate(samplerate);
}
} }
DynamicSystem::~DynamicSystem() { DynamicSystem::~DynamicSystem() {

View File

@ -1,3 +1,4 @@
#include <cmath>
#include "ViPERBass.h" #include "ViPERBass.h"
ViPERBass::ViPERBass() { ViPERBass::ViPERBass() {
@ -13,18 +14,29 @@ void ViPERBass::Process(float *samples, uint32_t size) {
} }
void ViPERBass::Reset() { void ViPERBass::Reset() {
this->polyphase->SetSamplingRate(this->samplingRate);
this->polyphase->Reset();
this->waveBuffer->Reset();
this->waveBuffer->PushZeros(this->polyphase->GetLatency());
this->subwoofer->SetBassGain(this->samplingRate, this->bassFactor * 2.5f);
this->fixedBiquad->SetLowPassParameter(this->speaker, this->samplingRate, 0.53);
this->unknown1 = 0.0f;
} }
void ViPERBass::SetBassFactor() { void ViPERBass::SetBassFactor(float bassFactor) {
if (abs(this->bassFactor - bassFactor) <= 0.01) {
return;
}
this->bassFactor = bassFactor;
this->subwoofer->SetBassGain(this->samplingRate, bassFactor * 2.5f);
} }
void ViPERBass::SetEnable(bool enable) { void ViPERBass::SetEnable(bool enable) {
} }
void ViPERBass::SetProcessMode() { void ViPERBass::SetProcessMode(int processMode) {
} }
@ -32,6 +44,10 @@ void ViPERBass::SetSamplingRate(uint32_t samplingRate) {
} }
void ViPERBass::SetSpeaker() { void ViPERBass::SetSpeaker(float speaker) {
if (this->speaker != speaker) {
this->speaker = speaker;
Reset();
}
} }

View File

@ -1,6 +1,10 @@
#pragma once #pragma once
#include <cstdint> #include <cstdint>
#include "../utils/FixedBiquad.h"
#include "../utils/Subwoofer.h"
#include "../utils/WaveBuffer_I32.h"
#include "../utils/Polyphase.h"
class ViPERBass { class ViPERBass {
public: public:
@ -9,11 +13,24 @@ public:
void Process(float *samples, uint32_t size); void Process(float *samples, uint32_t size);
void Reset(); void Reset();
void SetBassFactor(); void SetBassFactor(float bassFactor);
void SetEnable(bool enable); void SetEnable(bool enable);
void SetProcessMode(); void SetProcessMode(int processMode);
void SetSamplingRate(uint32_t samplingRate); void SetSamplingRate(uint32_t samplingRate);
void SetSpeaker(); void SetSpeaker(float speaker);
private:
Polyphase *polyphase;
FixedBiquad *fixedBiquad;
Subwoofer *subwoofer;
WaveBuffer_I32 *waveBuffer;
bool enable;
bool initOk;
int processMode;
uint32_t samplingRate;
float unknown1;
float speaker;
float bassFactor;
}; };

View File

@ -1,7 +1,3 @@
//
// Created by mart on 7/31/21.
//
#include "ViPERClarity.h" #include "ViPERClarity.h"
#include "../constants.h" #include "../constants.h"

View File

@ -21,19 +21,19 @@ void AdaptiveBuffer::FlushBuffer() {
this->offset = 0; this->offset = 0;
} }
uint32_t AdaptiveBuffer::GetBufferLength() { uint32_t AdaptiveBuffer::GetBufferLength() const {
return this->length; return this->length;
} }
uint32_t AdaptiveBuffer::GetBufferOffset() { uint32_t AdaptiveBuffer::GetBufferOffset() const {
return this->offset; return this->offset;
} }
float *AdaptiveBuffer::GetBufferPointer() { float *AdaptiveBuffer::GetBufferPointer() const {
return this->buffer; return this->buffer;
} }
uint32_t AdaptiveBuffer::GetChannels() { uint32_t AdaptiveBuffer::GetChannels() const {
return this->channels; return this->channels;
} }
@ -58,14 +58,14 @@ int AdaptiveBuffer::PopFrames(float *frames, uint32_t length) {
memcpy(frames, this->buffer, length * this->channels * sizeof(*frames)); memcpy(frames, this->buffer, length * this->channels * sizeof(*frames));
this->offset = this->offset - length; this->offset = this->offset - length;
if (this->offset != 0) { if (this->offset != 0) {
memmove(this->buffer, &this->buffer[length * this->channels], this->offset * this->channels * sizeof(*this->buffer)); memmove(this->buffer, &this->buffer[length * this->channels], this->offset * this->channels * sizeof(float));
} }
} }
return 1; return 1;
} }
int AdaptiveBuffer::PushFrames(float *frames, uint32_t length) { int AdaptiveBuffer::PushFrames(const float *frames, uint32_t length) {
if (this->buffer == nullptr) { if (this->buffer == nullptr) {
return 0; return 0;
} }
@ -73,13 +73,13 @@ int AdaptiveBuffer::PushFrames(float *frames, uint32_t length) {
if (length != 0) { if (length != 0) {
if (this->offset + length > this->length) { if (this->offset + length > this->length) {
auto tmp = new float[(this->offset + length) * this->channels]; auto tmp = new float[(this->offset + length) * this->channels];
memcpy(tmp, this->buffer, this->offset * this->channels * sizeof(*this->buffer)); memcpy(tmp, this->buffer, this->offset * this->channels * sizeof(float));
delete this->buffer; delete this->buffer;
this->buffer = tmp; this->buffer = tmp;
this->length = this->offset + length; this->length = this->offset + length;
} }
memcpy(&this->buffer[this->offset * this->channels], frames, length * this->channels * sizeof(*frames)); memcpy(&this->buffer[this->offset * this->channels], frames, length * this->channels * sizeof(float));
this->offset = this->offset + length; this->offset = this->offset + length;
} }
@ -93,13 +93,13 @@ int AdaptiveBuffer::PushZero(uint32_t length) {
if (this->offset + length > this->length) { if (this->offset + length > this->length) {
auto tmp = new float[(this->offset + length) * this->channels]; auto tmp = new float[(this->offset + length) * this->channels];
memcpy(tmp, this->buffer, this->offset * this->channels * sizeof(*this->buffer)); memcpy(tmp, this->buffer, this->offset * this->channels * sizeof(float));
delete this->buffer; delete this->buffer;
this->buffer = tmp; this->buffer = tmp;
this->length = this->offset + length; this->length = this->offset + length;
} }
memset(&this->buffer[this->offset * this->channels], 0, length * this->channels * sizeof(*this->buffer)); memset(&this->buffer[this->offset * this->channels], 0, length * this->channels * sizeof(float));
this->offset = this->offset + length; this->offset = this->offset + length;
return 1; return 1;

View File

@ -8,13 +8,13 @@ public:
~AdaptiveBuffer(); ~AdaptiveBuffer();
void FlushBuffer(); void FlushBuffer();
uint32_t GetBufferLength(); uint32_t GetBufferLength() const;
uint32_t GetBufferOffset(); uint32_t GetBufferOffset() const;
float *GetBufferPointer(); float *GetBufferPointer() const;
uint32_t GetChannels(); uint32_t GetChannels() const;
void PanFrames(float left, float right); void PanFrames(float left, float right);
int PopFrames(float *frames, uint32_t length); int PopFrames(float *frames, uint32_t length);
int PushFrames(float *frames, uint32_t length); int PushFrames(const float *frames, uint32_t length);
int PushZero(uint32_t length); int PushZero(uint32_t length);
void ScaleFrames(float scale); void ScaleFrames(float scale);
void SetBufferOffset(uint32_t offset); void SetBufferOffset(uint32_t offset);

View File

@ -1,9 +1,5 @@
//
// Created by mart on 7/26/21.
//
#include <cstring>
#include "CAllpassFilter.h" #include "CAllpassFilter.h"
#include <cstring>
CAllpassFilter::CAllpassFilter() { CAllpassFilter::CAllpassFilter() {
this->buffer = nullptr; this->buffer = nullptr;
@ -12,6 +8,10 @@ CAllpassFilter::CAllpassFilter() {
this->feedback = 0; this->feedback = 0;
} }
float CAllpassFilter::GetFeedback() {
return this->feedback;
}
void CAllpassFilter::Mute() { void CAllpassFilter::Mute() {
memset(this->buffer, 0, this->bufsize * sizeof(float)); memset(this->buffer, 0, this->bufsize * sizeof(float));
} }
@ -26,10 +26,6 @@ float CAllpassFilter::Process(float sample) {
return outSample - sample; return outSample - sample;
} }
float CAllpassFilter::GetFeedback() {
return this->feedback;
}
void CAllpassFilter::SetBuffer(float *buffer, uint32_t size) { void CAllpassFilter::SetBuffer(float *buffer, uint32_t size) {
this->buffer = buffer; this->buffer = buffer;
this->bufsize = size; this->bufsize = size;

View File

@ -1,7 +1,3 @@
//
// Created by mart on 7/26/21.
//
#pragma once #pragma once
#include <cstdint> #include <cstdint>
@ -10,16 +6,13 @@ class CAllpassFilter {
public: public:
CAllpassFilter(); CAllpassFilter();
void Mute();
float Process(float sample);
float GetFeedback(); float GetFeedback();
void Mute();
float Process(float sample);
void SetBuffer(float *buffer, uint32_t size); void SetBuffer(float *buffer, uint32_t size);
void SetFeedback(float feedback); void SetFeedback(float feedback);
private:
float *buffer; float *buffer;
uint32_t bufidx; uint32_t bufidx;
uint32_t bufsize; uint32_t bufsize;

View File

@ -1,9 +1,5 @@
//
// Created by mart on 7/27/21.
//
#include <cstring>
#include "CCombFilter.h" #include "CCombFilter.h"
#include <cstring>
CCombFilter::CCombFilter() { CCombFilter::CCombFilter() {
this->buffer = nullptr; this->buffer = nullptr;
@ -15,9 +11,21 @@ CCombFilter::CCombFilter() {
this->damp2 = 0; this->damp2 = 0;
} }
float CCombFilter::GetDamp() {
return this->damp;
}
float CCombFilter::GetFeedback() {
return this->feedback;
}
void CCombFilter::Mute() {
memset(this->buffer, 0, this->size * sizeof(float));
}
float CCombFilter::Process(float sample) { float CCombFilter::Process(float sample) {
float output = this->buffer[this->bufidx]; float output = this->buffer[this->bufidx];
this->filterstore = output * this->damp2 + this->filterstore * this->damp;; this->filterstore = output * this->damp2 + this->filterstore * this->damp;
this->buffer[this->bufidx] = sample + this->filterstore * this->feedback; this->buffer[this->bufidx] = sample + this->filterstore * this->feedback;
this->bufidx++; this->bufidx++;
if (this->bufidx >= this->size) { if (this->bufidx >= this->size) {
@ -26,16 +34,9 @@ float CCombFilter::Process(float sample) {
return output; return output;
} }
void CCombFilter::Mute() { void CCombFilter::SetBuffer(float *buffer, uint32_t size) {
memset(this->buffer, 0, this->size * sizeof(float)); this->buffer = buffer;
} this->size = size;
float CCombFilter::GetDamp() {
return this->damp;
}
float CCombFilter::GetFeedback() {
return this->feedback;
} }
void CCombFilter::SetDamp(float damp) { void CCombFilter::SetDamp(float damp) {
@ -46,8 +47,3 @@ void CCombFilter::SetDamp(float damp) {
void CCombFilter::SetFeedback(float feedback) { void CCombFilter::SetFeedback(float feedback) {
this->feedback = feedback; this->feedback = feedback;
} }
void CCombFilter::SetBuffer(float *buffer, uint32_t size) {
this->buffer = buffer;
this->size = size;
}

View File

@ -10,20 +10,15 @@ class CCombFilter {
public: public:
CCombFilter(); CCombFilter();
float Process(float sample);
void Mute();
float GetDamp(); float GetDamp();
float GetFeedback(); float GetFeedback();
void Mute();
float Process(float sample);
void SetBuffer(float *buffer, uint32_t size);
void SetDamp(float damp); void SetDamp(float damp);
void SetFeedback(float feedback); void SetFeedback(float feedback);
void SetBuffer(float *buffer, uint32_t size); private:
float feedback; float feedback;
float filterstore; float filterstore;
float damp; float damp;

View File

@ -12,9 +12,11 @@ DepthSurround::DepthSurround() {
this->enabled = false; this->enabled = false;
this->strengthAtLeast500 = false; this->strengthAtLeast500 = false;
this->gain = 0; this->gain = 0;
memset(&this->prev, 0, 2 * sizeof(float)); for (auto &prev : this->prev) {
SetSamplingRate(DEFAULT_SAMPLERATE); prev = 0.0f;
RefreshStrength(this->strength); }
this->SetSamplingRate(DEFAULT_SAMPLERATE);
this->RefreshStrength(this->strength);
} }
void DepthSurround::Process(float *samples, uint32_t size) { void DepthSurround::Process(float *samples, uint32_t size) {
@ -61,11 +63,11 @@ void DepthSurround::RefreshStrength(short strength) {
this->strengthAtLeast500 = strength >= 500; this->strengthAtLeast500 = strength >= 500;
this->enabled = strength != 0; this->enabled = strength != 0;
if (strength != 0) { if (strength != 0) {
float _gain = powf(10.f, ((strength / 1000.f) * 10.f - 15.f) / 20.f); float gain = powf(10.0f, ((strength / 1000.0f) * 10.0f - 15.0f) / 20.0f);
if (fabsf(_gain) > 1.f) { if (fabsf(gain) > 1.0f) {
_gain = 1.f; gain = 1.0f;
} }
this->gain = _gain; this->gain = gain;
} else { } else {
this->gain = 0; this->gain = 0;
} }
@ -74,11 +76,13 @@ void DepthSurround::RefreshStrength(short strength) {
void DepthSurround::SetSamplingRate(uint32_t samplerate) { void DepthSurround::SetSamplingRate(uint32_t samplerate) {
this->delay[0].SetParameters(samplerate, 0.02); this->delay[0].SetParameters(samplerate, 0.02);
this->delay[1].SetParameters(samplerate, 0.014); this->delay[1].SetParameters(samplerate, 0.014);
this->highpass.SetHighPassParameter(800.f, samplerate, -11.0f, 0.72f, 0); this->highpass.SetHighPassParameter(800.0f, samplerate, -11.0f, 0.72f, 0);
memset(&this->prev, 0, 2 * sizeof(float)); for (auto &prev : this->prev) {
prev = 0.0f;
}
} }
void DepthSurround::SetStrength(short strength) { void DepthSurround::SetStrength(short strength) {
this->strength = strength; this->strength = strength;
RefreshStrength(strength); this->RefreshStrength(strength);
} }

View File

@ -0,0 +1,35 @@
#include "FIR.h"
FIR::FIR() {
}
FIR::~FIR() {
delete this->offsetBlock;
delete this->coeffs;
delete this->block;
}
void FIR::FilterSamples(int *samples, uint32_t size) {
this->FilterSamplesInterleaved(samples, size, 1);
}
void FIR::FilterSamplesInterleaved(int *samples, uint32_t size, uint32_t channels) {
}
int FIR::GetBlockLength() {
return this->blockLength;
}
int FIR::LoadCoefficients(float *coeffs, uint32_t coeffsize, int blockLength) {
return 0;
}
void FIR::Reset() {
if (this->offsetBlock != nullptr && this->coeffsize + this->blockLength > -1) {
for (int i = 0; i < this->coeffsize + this->blockLength; i++) {
this->offsetBlock[i] = 0;
}
}
}

26
src/cpp/viper/utils/FIR.h Normal file
View File

@ -0,0 +1,26 @@
#pragma once
#include <cstdint>
class FIR {
public:
FIR();
~FIR();
void FilterSamples(int *samples, uint32_t size);
void FilterSamplesInterleaved(int *samples, uint32_t size, uint32_t channels);
int GetBlockLength();
int LoadCoefficients(float *coeffs, uint32_t coeffsize, int blockLength);
void Reset();
private:
int *offsetBlock;
float *coeffs;
float *block;
int coeffsize;
int blockLength;
bool enabled;
};

View File

@ -1,7 +1,3 @@
//
// Created by mart on 7/31/21.
//
#include "HiFi.h" #include "HiFi.h"
#include "../constants.h" #include "../constants.h"

View File

@ -1,7 +1,3 @@
//
// Created by mart on 7/31/21.
//
#pragma once #pragma once

View File

@ -30,8 +30,6 @@ float MultiBiquad::ProcessSample(float sample) {
void void
MultiBiquad::RefreshFilter(FilterType type, float gainAmp, float freq, float samplerate, float qFactor, bool param_7) { MultiBiquad::RefreshFilter(FilterType type, float gainAmp, float freq, float samplerate, float qFactor, bool param_7) {
bool uVar1; bool uVar1;
int iVar2;
int iVar3;
double dVar4; double dVar4;
double dVar5; double dVar5;
double dVar6; double dVar6;

View File

@ -0,0 +1,26 @@
#include "Polyphase.h"
Polyphase::Polyphase() {
}
Polyphase::~Polyphase() {
}
uint32_t Polyphase::GetLatency() {
return 63;
}
void Polyphase::Process(float *samples, uint32_t size) {
}
void Polyphase::Reset() {
}
void Polyphase::SetSamplingRate(uint32_t samplingRate) {
}

View File

@ -0,0 +1,28 @@
#pragma once
#include <cstdint>
#include "WaveBuffer_I32.h"
#include "FIR.h"
class Polyphase {
public:
Polyphase();
~Polyphase();
uint32_t GetLatency();
void Process(float *samples, uint32_t size);
void Reset();
void SetSamplingRate(uint32_t samplingRate);
private:
FIR *fir1;
FIR *fir2;
WaveBuffer_I32 *waveBuffer1;
WaveBuffer_I32 *waveBuffer2;
int *unknown1;
bool enabled;
// 3 unknowns
uint32_t samplingRate;
};

View File

@ -0,0 +1,22 @@
#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;
}
void Stereo3DSurround::Process(float *samples, uint32_t size) {
}
void Stereo3DSurround::SetMiddleImage(float middleImage) {
}
void Stereo3DSurround::SetStereoWiden(float stereoWiden) {
}

View File

@ -0,0 +1,22 @@
#pragma once
#include <cstdint>
class Stereo3DSurround {
public:
Stereo3DSurround();
void Process(float *samples, uint32_t size);
void SetMiddleImage(float middleImage);
void SetStereoWiden(float stereoWiden);
private:
float stereoWiden;
float midImage;
float unknown1;
float unknown2;
float coeffLeft;
float coeffRight;
};

View File

@ -1,7 +1,3 @@
//
// Created by mart on 7/31/21.
//
#include <cstdlib> #include <cstdlib>
#include <cstring> #include <cstring>
#include "WaveBuffer_I32.h" #include "WaveBuffer_I32.h"

View File

@ -1,7 +1,3 @@
//
// Created by mart on 7/31/21.
//
#pragma once #pragma once