mirror of
https://github.com/AndroidAudioMods/ViPERFX_RE.git
synced 2025-01-03 16:13:35 +08:00
Update
This commit is contained in:
parent
fcd7da0f13
commit
40339a15cd
@ -50,6 +50,7 @@ set(FILES
|
||||
src/cpp/viper/utils/Crossfeed.cpp
|
||||
src/cpp/viper/utils/DepthSurround.cpp
|
||||
src/cpp/viper/utils/DynamicBass.cpp
|
||||
src/cpp/viper/utils/FIR.cpp
|
||||
src/cpp/viper/utils/FixedBiquad.cpp
|
||||
src/cpp/viper/utils/Harmonic.cpp
|
||||
src/cpp/viper/utils/HiFi.cpp
|
||||
@ -62,6 +63,8 @@ set(FILES
|
||||
src/cpp/viper/utils/PassFilter.cpp
|
||||
src/cpp/viper/utils/PConvSingle_F32.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/TimeConstDelay.cpp
|
||||
src/cpp/viper/utils/WaveBuffer_I32.cpp)
|
||||
|
@ -87,7 +87,7 @@ ViPER::ViPER() {
|
||||
this->tubeSimulator->Reset();
|
||||
|
||||
this->analogX = new AnalogX();
|
||||
this->analogX->enabled = false; //SetEnable(false);
|
||||
// this->analogX->SetEnable(false);
|
||||
this->analogX->SetSamplingRate(this->sampleRate);
|
||||
this->analogX->SetProcessingModel(0);
|
||||
this->analogX->Reset();
|
||||
@ -104,10 +104,10 @@ ViPER::ViPER() {
|
||||
|
||||
this->fetcomp_enabled = false;
|
||||
this->init_ok = true;
|
||||
this->scale_frames_if_not_1point0 = 1.0;
|
||||
this->pan_frames_if_less_than_1point0 = 1.0;
|
||||
this->frame_scale = 1.0;
|
||||
this->left_pan = 1.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->force_enabled = false;
|
||||
this->update_status = false;
|
||||
@ -171,7 +171,7 @@ ViPER::~ViPER() {
|
||||
delete this->speakerCorrection;
|
||||
this->speakerCorrection = nullptr;
|
||||
|
||||
for (auto &softwareLimiter: softwareLimiters) {
|
||||
for (auto &softwareLimiter: this->softwareLimiters) {
|
||||
delete softwareLimiter;
|
||||
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;
|
||||
}
|
||||
|
||||
int ret;
|
||||
uint32_t ret;
|
||||
|
||||
// if convolver is enabled
|
||||
ret = this->waveBuffer->PushSamples(buffer, frameSize);
|
||||
@ -366,11 +366,11 @@ void ViPER::processBuffer(float *buffer, int frameSize) {
|
||||
this->analogX->Process(pAdaptiveBuffer, ret);
|
||||
}
|
||||
|
||||
if (this->scale_frames_if_not_1point0 != 1.0) {
|
||||
this->adaptiveBuffer->ScaleFrames(this->scale_frames_if_not_1point0);
|
||||
if (this->frame_scale != 1.0) {
|
||||
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) {
|
||||
this->adaptiveBuffer->PanFrames(this->pan_frames_if_less_than_1point0, this->pan_frames_if_less_than_1point0_2);
|
||||
if (this->left_pan < 1.0 || this->right_pan < 1.0) {
|
||||
this->adaptiveBuffer->PanFrames(this->left_pan, this->right_pan);
|
||||
}
|
||||
|
||||
if (ret << 1 != 0) {
|
||||
|
@ -73,7 +73,7 @@ public:
|
||||
SpeakerCorrection *speakerCorrection;
|
||||
SoftwareLimiter *softwareLimiters[2];
|
||||
|
||||
float scale_frames_if_not_1point0;
|
||||
float pan_frames_if_less_than_1point0;
|
||||
float pan_frames_if_less_than_1point0_2;
|
||||
float frame_scale;
|
||||
float left_pan;
|
||||
float right_pan;
|
||||
};
|
||||
|
@ -7,12 +7,12 @@ static float ANALOGX_HARMONICS[10] = {
|
||||
0.02f,
|
||||
0.0001f,
|
||||
0.001f,
|
||||
0.f,
|
||||
0.f,
|
||||
0.f,
|
||||
0.f,
|
||||
0.f,
|
||||
0.f
|
||||
0.0f,
|
||||
0.0f,
|
||||
0.0f,
|
||||
0.0f,
|
||||
0.0f,
|
||||
0.0f
|
||||
};
|
||||
|
||||
AnalogX::AnalogX() {
|
||||
|
@ -14,6 +14,7 @@ public:
|
||||
void SetProcessingModel(int processingModel);
|
||||
void SetSamplingRate(uint32_t samplingRate);
|
||||
|
||||
private:
|
||||
MultiBiquad highpass[2];
|
||||
Harmonic harmonic[2];
|
||||
MultiBiquad lowpass[2];
|
||||
|
@ -1,7 +1,12 @@
|
||||
#include "ColorfulMusic.h"
|
||||
#include "../constants.h"
|
||||
|
||||
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() {
|
||||
@ -9,29 +14,42 @@ ColorfulMusic::~ColorfulMusic() {
|
||||
}
|
||||
|
||||
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() {
|
||||
|
||||
this->depthSurround->SetSamplingRate(this->samplingRate);
|
||||
}
|
||||
|
||||
void ColorfulMusic::SetDepthValue() {
|
||||
|
||||
void ColorfulMusic::SetDepthValue(short depthValue) {
|
||||
this->depthSurround->SetStrength(depthValue);
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
if (this->samplingRate != samplingRate) {
|
||||
this->samplingRate = samplingRate;
|
||||
this->depthSurround->SetSamplingRate(this->samplingRate);
|
||||
}
|
||||
}
|
||||
|
||||
void ColorfulMusic::SetWidenValue() {
|
||||
|
||||
void ColorfulMusic::SetWidenValue(float widenValue) {
|
||||
this->stereo3DSurround->SetStereoWiden(widenValue);
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include "../utils/Stereo3DSurround.h"
|
||||
#include "../utils/DepthSurround.h"
|
||||
|
||||
class ColorfulMusic {
|
||||
public:
|
||||
@ -9,11 +11,18 @@ public:
|
||||
|
||||
void Process(float *samples, uint32_t size);
|
||||
void Reset();
|
||||
void SetDepthValue();
|
||||
void SetDepthValue(short depthValue);
|
||||
void SetEnable(bool enable);
|
||||
void SetMidImageValue();
|
||||
void SetMidImageValue(float midImageValue);
|
||||
void SetSamplingRate(uint32_t samplingRate);
|
||||
void SetWidenValue();
|
||||
void SetWidenValue(float widenValue);
|
||||
|
||||
private:
|
||||
Stereo3DSurround *stereo3DSurround;
|
||||
DepthSurround *depthSurround;
|
||||
uint32_t samplingRate;
|
||||
bool enabled;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -26,8 +26,12 @@ void Cure::Reset() {
|
||||
}
|
||||
|
||||
void Cure::SetEnable(bool enabled) {
|
||||
Reset();
|
||||
if (this->enabled != enabled) {
|
||||
this->enabled = enabled;
|
||||
if (enabled) {
|
||||
Reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Cure::SetSamplingRate(uint32_t samplerate) {
|
||||
@ -53,7 +57,6 @@ preset_t Cure::GetPreset() {
|
||||
|
||||
void Cure::SetCutoff(uint16_t cutoff) {
|
||||
this->crossfeed.SetCutoff(cutoff);
|
||||
|
||||
}
|
||||
|
||||
void Cure::SetFeedback(float feedback) {
|
||||
|
@ -1,22 +1,21 @@
|
||||
//
|
||||
// Created by mart on 7/31/21.
|
||||
//
|
||||
|
||||
#include <cstring>
|
||||
#include "DiffSurround.h"
|
||||
#include "../constants.h"
|
||||
|
||||
DiffSurround::DiffSurround() {
|
||||
this->samplerate = DEFAULT_SAMPLERATE;
|
||||
this->delayTime = 0.f;
|
||||
this->delayTime = 0.0f;
|
||||
this->enabled = false;
|
||||
this->buffers[0] = new WaveBuffer_I32(1, 0x1000);
|
||||
this->buffers[1] = new WaveBuffer_I32(1, 0x1000);
|
||||
for (auto &buffer : this->buffers) {
|
||||
buffer = new WaveBuffer_I32(1, 0x1000);
|
||||
}
|
||||
}
|
||||
|
||||
DiffSurround::~DiffSurround() {
|
||||
delete this->buffers[0];
|
||||
delete this->buffers[1];
|
||||
for (auto &buffer : this->buffers) {
|
||||
delete buffer;
|
||||
buffer = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void DiffSurround::Process(float *samples, uint32_t size) {
|
||||
@ -44,25 +43,32 @@ void DiffSurround::Process(float *samples, uint32_t size) {
|
||||
}
|
||||
|
||||
void DiffSurround::Reset() {
|
||||
this->buffers[0]->Reset();
|
||||
this->buffers[1]->Reset();
|
||||
for (auto &buffer : this->buffers) {
|
||||
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) {
|
||||
this->delayTime = value;
|
||||
Reset();
|
||||
void DiffSurround::SetDelayTime(float delayTime) {
|
||||
if (this->delayTime != delayTime) {
|
||||
this->delayTime = delayTime;
|
||||
this->Reset();
|
||||
}
|
||||
}
|
||||
|
||||
void DiffSurround::SetEnable(bool enabled) {
|
||||
if (this->enabled != enabled) {
|
||||
this->enabled = enabled;
|
||||
if (this->enabled) {
|
||||
if (enabled) {
|
||||
Reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DiffSurround::SetSamplingRate(uint32_t samplerate) {
|
||||
if (this->samplerate != samplerate) {
|
||||
this->samplerate = samplerate;
|
||||
Reset();
|
||||
this->Reset();
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ public:
|
||||
|
||||
void Process(float *samples, uint32_t size);
|
||||
void Reset();
|
||||
void SetDelayTime(float value);
|
||||
void SetDelayTime(float delayTime);
|
||||
void SetEnable(bool enabled);
|
||||
void SetSamplingRate(uint32_t samplerate);
|
||||
|
||||
|
@ -28,7 +28,12 @@ void DynamicSystem::SetBassGain(float gain) {
|
||||
}
|
||||
|
||||
void DynamicSystem::SetEnable(bool enable) {
|
||||
if (this->enabled != enable) {
|
||||
this->enabled = enable;
|
||||
if (enable) {
|
||||
Reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
if (this->samplerate != samplerate) {
|
||||
this->samplerate = samplerate;
|
||||
this->bass.SetSamplingRate(samplerate);
|
||||
}
|
||||
}
|
||||
|
||||
DynamicSystem::~DynamicSystem() {
|
||||
|
@ -1,3 +1,4 @@
|
||||
#include <cmath>
|
||||
#include "ViPERBass.h"
|
||||
|
||||
ViPERBass::ViPERBass() {
|
||||
@ -13,18 +14,29 @@ void ViPERBass::Process(float *samples, uint32_t size) {
|
||||
}
|
||||
|
||||
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::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();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include "../utils/FixedBiquad.h"
|
||||
#include "../utils/Subwoofer.h"
|
||||
#include "../utils/WaveBuffer_I32.h"
|
||||
#include "../utils/Polyphase.h"
|
||||
|
||||
class ViPERBass {
|
||||
public:
|
||||
@ -9,11 +13,24 @@ public:
|
||||
|
||||
void Process(float *samples, uint32_t size);
|
||||
void Reset();
|
||||
void SetBassFactor();
|
||||
void SetBassFactor(float bassFactor);
|
||||
void SetEnable(bool enable);
|
||||
void SetProcessMode();
|
||||
void SetProcessMode(int processMode);
|
||||
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;
|
||||
};
|
||||
|
||||
|
||||
|
@ -1,7 +1,3 @@
|
||||
//
|
||||
// Created by mart on 7/31/21.
|
||||
//
|
||||
|
||||
#include "ViPERClarity.h"
|
||||
#include "../constants.h"
|
||||
|
||||
|
@ -21,19 +21,19 @@ void AdaptiveBuffer::FlushBuffer() {
|
||||
this->offset = 0;
|
||||
}
|
||||
|
||||
uint32_t AdaptiveBuffer::GetBufferLength() {
|
||||
uint32_t AdaptiveBuffer::GetBufferLength() const {
|
||||
return this->length;
|
||||
}
|
||||
|
||||
uint32_t AdaptiveBuffer::GetBufferOffset() {
|
||||
uint32_t AdaptiveBuffer::GetBufferOffset() const {
|
||||
return this->offset;
|
||||
}
|
||||
|
||||
float *AdaptiveBuffer::GetBufferPointer() {
|
||||
float *AdaptiveBuffer::GetBufferPointer() const {
|
||||
return this->buffer;
|
||||
}
|
||||
|
||||
uint32_t AdaptiveBuffer::GetChannels() {
|
||||
uint32_t AdaptiveBuffer::GetChannels() const {
|
||||
return this->channels;
|
||||
}
|
||||
|
||||
@ -58,14 +58,14 @@ int AdaptiveBuffer::PopFrames(float *frames, uint32_t length) {
|
||||
memcpy(frames, this->buffer, length * this->channels * sizeof(*frames));
|
||||
this->offset = this->offset - length;
|
||||
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;
|
||||
}
|
||||
|
||||
int AdaptiveBuffer::PushFrames(float *frames, uint32_t length) {
|
||||
int AdaptiveBuffer::PushFrames(const float *frames, uint32_t length) {
|
||||
if (this->buffer == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
@ -73,13 +73,13 @@ int AdaptiveBuffer::PushFrames(float *frames, uint32_t length) {
|
||||
if (length != 0) {
|
||||
if (this->offset + length > this->length) {
|
||||
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;
|
||||
this->buffer = tmp;
|
||||
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;
|
||||
}
|
||||
|
||||
@ -93,13 +93,13 @@ int AdaptiveBuffer::PushZero(uint32_t length) {
|
||||
|
||||
if (this->offset + length > this->length) {
|
||||
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;
|
||||
this->buffer = tmp;
|
||||
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;
|
||||
|
||||
return 1;
|
||||
|
@ -8,13 +8,13 @@ public:
|
||||
~AdaptiveBuffer();
|
||||
|
||||
void FlushBuffer();
|
||||
uint32_t GetBufferLength();
|
||||
uint32_t GetBufferOffset();
|
||||
float *GetBufferPointer();
|
||||
uint32_t GetChannels();
|
||||
uint32_t GetBufferLength() const;
|
||||
uint32_t GetBufferOffset() const;
|
||||
float *GetBufferPointer() const;
|
||||
uint32_t GetChannels() const;
|
||||
void PanFrames(float left, float right);
|
||||
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);
|
||||
void ScaleFrames(float scale);
|
||||
void SetBufferOffset(uint32_t offset);
|
||||
|
@ -1,9 +1,5 @@
|
||||
//
|
||||
// Created by mart on 7/26/21.
|
||||
//
|
||||
|
||||
#include <cstring>
|
||||
#include "CAllpassFilter.h"
|
||||
#include <cstring>
|
||||
|
||||
CAllpassFilter::CAllpassFilter() {
|
||||
this->buffer = nullptr;
|
||||
@ -12,6 +8,10 @@ CAllpassFilter::CAllpassFilter() {
|
||||
this->feedback = 0;
|
||||
}
|
||||
|
||||
float CAllpassFilter::GetFeedback() {
|
||||
return this->feedback;
|
||||
}
|
||||
|
||||
void CAllpassFilter::Mute() {
|
||||
memset(this->buffer, 0, this->bufsize * sizeof(float));
|
||||
}
|
||||
@ -26,10 +26,6 @@ float CAllpassFilter::Process(float sample) {
|
||||
return outSample - sample;
|
||||
}
|
||||
|
||||
float CAllpassFilter::GetFeedback() {
|
||||
return this->feedback;
|
||||
}
|
||||
|
||||
void CAllpassFilter::SetBuffer(float *buffer, uint32_t size) {
|
||||
this->buffer = buffer;
|
||||
this->bufsize = size;
|
||||
|
@ -1,7 +1,3 @@
|
||||
//
|
||||
// Created by mart on 7/26/21.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
@ -10,16 +6,13 @@ class CAllpassFilter {
|
||||
public:
|
||||
CAllpassFilter();
|
||||
|
||||
void Mute();
|
||||
|
||||
float Process(float sample);
|
||||
|
||||
float GetFeedback();
|
||||
|
||||
void Mute();
|
||||
float Process(float sample);
|
||||
void SetBuffer(float *buffer, uint32_t size);
|
||||
|
||||
void SetFeedback(float feedback);
|
||||
|
||||
private:
|
||||
float *buffer;
|
||||
uint32_t bufidx;
|
||||
uint32_t bufsize;
|
||||
|
@ -1,9 +1,5 @@
|
||||
//
|
||||
// Created by mart on 7/27/21.
|
||||
//
|
||||
|
||||
#include <cstring>
|
||||
#include "CCombFilter.h"
|
||||
#include <cstring>
|
||||
|
||||
CCombFilter::CCombFilter() {
|
||||
this->buffer = nullptr;
|
||||
@ -15,9 +11,21 @@ CCombFilter::CCombFilter() {
|
||||
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 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->bufidx++;
|
||||
if (this->bufidx >= this->size) {
|
||||
@ -26,16 +34,9 @@ float CCombFilter::Process(float sample) {
|
||||
return output;
|
||||
}
|
||||
|
||||
void CCombFilter::Mute() {
|
||||
memset(this->buffer, 0, this->size * sizeof(float));
|
||||
}
|
||||
|
||||
float CCombFilter::GetDamp() {
|
||||
return this->damp;
|
||||
}
|
||||
|
||||
float CCombFilter::GetFeedback() {
|
||||
return this->feedback;
|
||||
void CCombFilter::SetBuffer(float *buffer, uint32_t size) {
|
||||
this->buffer = buffer;
|
||||
this->size = size;
|
||||
}
|
||||
|
||||
void CCombFilter::SetDamp(float damp) {
|
||||
@ -46,8 +47,3 @@ void CCombFilter::SetDamp(float damp) {
|
||||
void CCombFilter::SetFeedback(float feedback) {
|
||||
this->feedback = feedback;
|
||||
}
|
||||
|
||||
void CCombFilter::SetBuffer(float *buffer, uint32_t size) {
|
||||
this->buffer = buffer;
|
||||
this->size = size;
|
||||
}
|
||||
|
@ -10,20 +10,15 @@ class CCombFilter {
|
||||
public:
|
||||
CCombFilter();
|
||||
|
||||
float Process(float sample);
|
||||
|
||||
void Mute();
|
||||
|
||||
float GetDamp();
|
||||
|
||||
float GetFeedback();
|
||||
|
||||
void Mute();
|
||||
float Process(float sample);
|
||||
void SetBuffer(float *buffer, uint32_t size);
|
||||
void SetDamp(float damp);
|
||||
|
||||
void SetFeedback(float feedback);
|
||||
|
||||
void SetBuffer(float *buffer, uint32_t size);
|
||||
|
||||
private:
|
||||
float feedback;
|
||||
float filterstore;
|
||||
float damp;
|
||||
|
@ -12,9 +12,11 @@ DepthSurround::DepthSurround() {
|
||||
this->enabled = false;
|
||||
this->strengthAtLeast500 = false;
|
||||
this->gain = 0;
|
||||
memset(&this->prev, 0, 2 * sizeof(float));
|
||||
SetSamplingRate(DEFAULT_SAMPLERATE);
|
||||
RefreshStrength(this->strength);
|
||||
for (auto &prev : this->prev) {
|
||||
prev = 0.0f;
|
||||
}
|
||||
this->SetSamplingRate(DEFAULT_SAMPLERATE);
|
||||
this->RefreshStrength(this->strength);
|
||||
}
|
||||
|
||||
void DepthSurround::Process(float *samples, uint32_t size) {
|
||||
@ -61,11 +63,11 @@ void DepthSurround::RefreshStrength(short strength) {
|
||||
this->strengthAtLeast500 = strength >= 500;
|
||||
this->enabled = strength != 0;
|
||||
if (strength != 0) {
|
||||
float _gain = powf(10.f, ((strength / 1000.f) * 10.f - 15.f) / 20.f);
|
||||
if (fabsf(_gain) > 1.f) {
|
||||
_gain = 1.f;
|
||||
float gain = powf(10.0f, ((strength / 1000.0f) * 10.0f - 15.0f) / 20.0f);
|
||||
if (fabsf(gain) > 1.0f) {
|
||||
gain = 1.0f;
|
||||
}
|
||||
this->gain = _gain;
|
||||
this->gain = gain;
|
||||
} else {
|
||||
this->gain = 0;
|
||||
}
|
||||
@ -74,11 +76,13 @@ void DepthSurround::RefreshStrength(short strength) {
|
||||
void DepthSurround::SetSamplingRate(uint32_t samplerate) {
|
||||
this->delay[0].SetParameters(samplerate, 0.02);
|
||||
this->delay[1].SetParameters(samplerate, 0.014);
|
||||
this->highpass.SetHighPassParameter(800.f, samplerate, -11.0f, 0.72f, 0);
|
||||
memset(&this->prev, 0, 2 * sizeof(float));
|
||||
this->highpass.SetHighPassParameter(800.0f, samplerate, -11.0f, 0.72f, 0);
|
||||
for (auto &prev : this->prev) {
|
||||
prev = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
void DepthSurround::SetStrength(short strength) {
|
||||
this->strength = strength;
|
||||
RefreshStrength(strength);
|
||||
this->RefreshStrength(strength);
|
||||
}
|
35
src/cpp/viper/utils/FIR.cpp
Normal file
35
src/cpp/viper/utils/FIR.cpp
Normal 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
26
src/cpp/viper/utils/FIR.h
Normal 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;
|
||||
|
||||
};
|
||||
|
||||
|
@ -1,7 +1,3 @@
|
||||
//
|
||||
// Created by mart on 7/31/21.
|
||||
//
|
||||
|
||||
#include "HiFi.h"
|
||||
#include "../constants.h"
|
||||
|
||||
|
@ -1,7 +1,3 @@
|
||||
//
|
||||
// Created by mart on 7/31/21.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
|
@ -30,8 +30,6 @@ float MultiBiquad::ProcessSample(float sample) {
|
||||
void
|
||||
MultiBiquad::RefreshFilter(FilterType type, float gainAmp, float freq, float samplerate, float qFactor, bool param_7) {
|
||||
bool uVar1;
|
||||
int iVar2;
|
||||
int iVar3;
|
||||
double dVar4;
|
||||
double dVar5;
|
||||
double dVar6;
|
||||
|
26
src/cpp/viper/utils/Polyphase.cpp
Normal file
26
src/cpp/viper/utils/Polyphase.cpp
Normal 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) {
|
||||
|
||||
}
|
||||
|
28
src/cpp/viper/utils/Polyphase.h
Normal file
28
src/cpp/viper/utils/Polyphase.h
Normal 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;
|
||||
};
|
||||
|
||||
|
22
src/cpp/viper/utils/Stereo3DSurround.cpp
Normal file
22
src/cpp/viper/utils/Stereo3DSurround.cpp
Normal 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) {
|
||||
|
||||
}
|
22
src/cpp/viper/utils/Stereo3DSurround.h
Normal file
22
src/cpp/viper/utils/Stereo3DSurround.h
Normal 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;
|
||||
};
|
||||
|
||||
|
@ -1,7 +1,3 @@
|
||||
//
|
||||
// Created by mart on 7/31/21.
|
||||
//
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include "WaveBuffer_I32.h"
|
||||
|
@ -1,7 +1,3 @@
|
||||
//
|
||||
// Created by mart on 7/31/21.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user