This commit is contained in:
Iscle 2022-10-06 03:37:22 +02:00
parent e84cd53d79
commit 9d54379bd8
22 changed files with 237 additions and 199 deletions

View File

@ -1,25 +1,25 @@
cmake_minimum_required(VERSION 3.16.3) cmake_minimum_required(VERSION 3.16.3)
set(CMAKE_CXX_COMPILER_VERSION 20) set(CMAKE_CXX_COMPILER_VERSION 20)
# NDK Settings
#set(ANDROID_ABI arm64-v8a)
set(ANDROID_ABI armeabi-v7a)
#set(ANDROID_ARM_NEON true)
set(ANDROID_PLATFORM android-21)
SET(CMAKE_CXX_FLAGS "-O0")
SET(CMAKE_C_FLAGS "-O0")
project("ViPER4Android Reworked") project("ViPER4Android Reworked")
add_compile_definitions(VERSION_MAJOR=1) add_compile_definitions(VERSION_MAJOR=1)
add_compile_definitions(VERSION_MINOR=0) add_compile_definitions(VERSION_MINOR=0)
add_compile_definitions(VERSION_CODENAME="Reworked") add_compile_definitions(VERSION_CODENAME="Reworked")
# NDK Settings
if (NOT ANDROID_ABI)
set(ANDROID_ABI arm64-v8a)
endif()
if (NOT ANDROID_PLATFORM)
set(ANDROID_PLATFORM android-23)
endif()
# KISS FFT # KISS FFT
set(KISSFFT_PKGCONFIG OFF) set(KISSFFT_PKGCONFIG OFF)
set(KISSFFT_STATIC ON) set(KISSFFT_STATIC ON)
set(KISSFFT_TEST OFF) set(KISSFFT_TEST OFF)
set(KISSFFT_TOOLS OFF) set(KISSFFT_TOOLS OFF)
add_subdirectory(src/cpp/viper/kissfft) #add_subdirectory(src/cpp/viper/kissfft)
# ViPERFX # ViPERFX
include_directories(src/include) include_directories(src/include)
@ -90,4 +90,4 @@ add_library(
# Provides a relative path to your source file(s). # Provides a relative path to your source file(s).
${FILES}) ${FILES})
target_link_libraries(v4afx_r log kissfft) target_link_libraries(v4afx_r log) # kissfft)

View File

@ -10,8 +10,12 @@
#define VIPER_EFFECT_NAME "ViPER4Android" #define VIPER_EFFECT_NAME "ViPER4Android"
static effect_descriptor_t viper_descriptor = { static effect_descriptor_t viper_descriptor = {
// ee48cf24-9221-4095-2cb9-40faa133111b
.type = EFFECT_UUID_INITIALIZER, .type = EFFECT_UUID_INITIALIZER,
.uuid = {0x90380da3, 0x8536, 0x4744, 0xa6a3, {0x57, 0x31, 0x97, 0x0e, 0x64, 0x0f}}, // 41d3c987-e6cf-11e3-a88a-11aba5d5c51b
// Original: {0x41d3c987, 0xe6cf, 0x11e3, 0xa88a, {0x11, 0xab, 0xa5, 0xd5, 0xc5, 0x1b}}
// New: {0x90380da3, 0x8536, 0x4744, 0xa6a3, {0x57, 0x31, 0x97, 0x0e, 0x64, 0x0f}}
.uuid = {0x41d3c987, 0xe6cf, 0x11e3, 0xa88a, {0x11, 0xab, 0xa5, 0xd5, 0xc5, 0x1b}},
.apiVersion = EFFECT_CONTROL_API_VERSION, .apiVersion = EFFECT_CONTROL_API_VERSION,
.flags = EFFECT_FLAG_OUTPUT_DIRECT | EFFECT_FLAG_INPUT_DIRECT | EFFECT_FLAG_INSERT_LAST | EFFECT_FLAG_TYPE_INSERT, .flags = EFFECT_FLAG_OUTPUT_DIRECT | EFFECT_FLAG_INPUT_DIRECT | EFFECT_FLAG_INSERT_LAST | EFFECT_FLAG_TYPE_INSERT,
.cpuLoad = 8, // In 0.1 MIPS units as estimated on an ARM9E core (ARMv5TE) with 0 WS .cpuLoad = 8, // In 0.1 MIPS units as estimated on an ARM9E core (ARMv5TE) with 0 WS
@ -30,6 +34,12 @@ struct ViperContext {
static int32_t Viper_IProcess(effect_handle_t self, audio_buffer_t *inBuffer, audio_buffer_t *outBuffer) { static int32_t Viper_IProcess(effect_handle_t self, audio_buffer_t *inBuffer, audio_buffer_t *outBuffer) {
auto pContext = reinterpret_cast<ViperContext *>(self); auto pContext = reinterpret_cast<ViperContext *>(self);
static uint32_t tmp = 0;
if (tmp % 50 == 0) {
VIPER_LOGD("Viper_IProcess called!");
}
tmp++;
if (pContext == nullptr || if (pContext == nullptr ||
inBuffer == nullptr || outBuffer == nullptr || inBuffer == nullptr || outBuffer == nullptr ||
inBuffer->raw == nullptr || outBuffer->raw == nullptr || inBuffer->raw == nullptr || outBuffer->raw == nullptr ||
@ -53,6 +63,13 @@ static int configure(ViperContext *pContext, effect_config_t *newConfig) {
VIPER_LOGI("Begin audio configure ..."); VIPER_LOGI("Begin audio configure ...");
VIPER_LOGI("Checking input and output configuration ..."); VIPER_LOGI("Checking input and output configuration ...");
VIPER_LOGD("Input sampling rate: %d", newConfig->inputCfg.samplingRate);
VIPER_LOGD("Input channels: %d", newConfig->inputCfg.channels);
VIPER_LOGD("Input format: %d", newConfig->inputCfg.format);
VIPER_LOGD("Output sampling rate: %d", newConfig->outputCfg.samplingRate);
VIPER_LOGD("Output channels: %d", newConfig->outputCfg.channels);
VIPER_LOGD("Output format: %d", newConfig->outputCfg.format);
if (newConfig->inputCfg.samplingRate != newConfig->outputCfg.samplingRate) { if (newConfig->inputCfg.samplingRate != newConfig->outputCfg.samplingRate) {
VIPER_LOGE("ViPER4Android disabled, reason [in.SR = %d, out.SR = %d]", VIPER_LOGE("ViPER4Android disabled, reason [in.SR = %d, out.SR = %d]",
newConfig->inputCfg.samplingRate, newConfig->outputCfg.samplingRate); newConfig->inputCfg.samplingRate, newConfig->outputCfg.samplingRate);
@ -75,12 +92,14 @@ static int configure(ViperContext *pContext, effect_config_t *newConfig) {
return -EINVAL; return -EINVAL;
} }
// AUDIO_FORMAT_PCM_16_BIT
if (newConfig->inputCfg.format != AUDIO_FORMAT_PCM_FLOAT) { if (newConfig->inputCfg.format != AUDIO_FORMAT_PCM_FLOAT) {
VIPER_LOGE("ViPER4Android disabled, reason [in.FMT = %d]", newConfig->inputCfg.format); VIPER_LOGE("ViPER4Android disabled, reason [in.FMT = %d]", newConfig->inputCfg.format);
VIPER_LOGE("We only accept f32 format"); VIPER_LOGE("We only accept f32 format");
return -EINVAL; return -EINVAL;
} }
// AUDIO_FORMAT_PCM_16_BIT
if (newConfig->outputCfg.format != AUDIO_FORMAT_PCM_FLOAT) { if (newConfig->outputCfg.format != AUDIO_FORMAT_PCM_FLOAT) {
VIPER_LOGE("ViPER4Android disabled, reason [out.FMT = %d]", newConfig->outputCfg.format); VIPER_LOGE("ViPER4Android disabled, reason [out.FMT = %d]", newConfig->outputCfg.format);
VIPER_LOGE("We only accept f32 format"); VIPER_LOGE("We only accept f32 format");
@ -182,13 +201,15 @@ static int32_t Viper_ICommand(effect_handle_t self,
// the parameter size to the next 32 bit alignment. // the parameter size to the next 32 bit alignment.
uint32_t vOffset = ((pCmdParam->psize + sizeof(int32_t) - 1) / sizeof(int32_t)) * sizeof(int32_t); uint32_t vOffset = ((pCmdParam->psize + sizeof(int32_t) - 1) / sizeof(int32_t)) * sizeof(int32_t);
memcpy(pReplyParam, pCmdParam, sizeof(effect_param_t) + pCmdParam->psize); VIPER_LOGD("Viper_ICommand() EFFECT_CMD_GET_PARAM called with data = %d, psize = %d, vsize = %d", *(uint32_t *) pCmdParam->data, pCmdParam->psize, pCmdParam->vsize);
//memcpy(pReplyParam, pCmdParam, sizeof(effect_param_t) + pCmdParam->psize);
switch (*(uint32_t *) pCmdParam->data) { switch (*(uint32_t *) pCmdParam->data) {
case PARAM_GET_DRIVER_VERSION: { case PARAM_GET_DRIVER_VERSION: {
pReplyParam->status = 0; pReplyParam->status = 0;
pReplyParam->vsize = sizeof(uint32_t); pReplyParam->vsize = sizeof(uint32_t);
*(uint32_t *) (pReplyParam->data + vOffset) = 0x2050004; // As original, change as needed *(uint32_t *) (pReplyParam->data + vOffset) = 0x2050005; // As original, change as needed
*replySize = sizeof(effect_param_t) + pReplyParam->psize + vOffset + pReplyParam->vsize; *replySize = sizeof(effect_param_t) + pReplyParam->psize + vOffset + pReplyParam->vsize;
return 0; return 0;
} }
@ -206,13 +227,6 @@ static int32_t Viper_ICommand(effect_handle_t self,
*replySize = sizeof(effect_param_t) + pReplyParam->psize + vOffset + pReplyParam->vsize; *replySize = sizeof(effect_param_t) + pReplyParam->psize + vOffset + pReplyParam->vsize;
return 0; return 0;
} }
case PARAM_GET_DRVCANWORK: {
pReplyParam->status = 0;
pReplyParam->vsize = sizeof(int32_t);
*(int32_t *) (pReplyParam->data + vOffset) = pContext->viper->init_ok;
*replySize = sizeof(effect_param_t) + pReplyParam->psize + vOffset + pReplyParam->vsize;
return 0;
}
case PARAM_GET_STREAMING: { // Is processing case PARAM_GET_STREAMING: { // Is processing
struct timeval time{}; struct timeval time{};
gettimeofday(&time, nullptr); gettimeofday(&time, nullptr);
@ -261,6 +275,8 @@ static int32_t Viper_ICommand(effect_handle_t self,
static int32_t Viper_IGetDescriptor(effect_handle_t self, effect_descriptor_t *pDescriptor) { static int32_t Viper_IGetDescriptor(effect_handle_t self, effect_descriptor_t *pDescriptor) {
auto pContext = reinterpret_cast<ViperContext *>(self); auto pContext = reinterpret_cast<ViperContext *>(self);
VIPER_LOGD("Viper_IGetDescriptor called");
if (pContext == nullptr || pDescriptor == nullptr) { if (pContext == nullptr || pDescriptor == nullptr) {
VIPER_LOGE("Viper_IGetDescriptor: pContext or pDescriptor is null!"); VIPER_LOGE("Viper_IGetDescriptor: pContext or pDescriptor is null!");
return -EINVAL; return -EINVAL;

View File

@ -10,10 +10,9 @@ enum ParamsMode {
}; };
enum ParamsGet { enum ParamsGet {
PARAM_GET_DRIVER_VERSION, PARAM_GET_DRIVER_VERSION = 0,
PARAM_GET_ENABLED, PARAM_GET_ENABLED,
PARAM_GET_CONFIGURE, PARAM_GET_CONFIGURE,
PARAM_GET_DRVCANWORK,
PARAM_GET_STREAMING, PARAM_GET_STREAMING,
PARAM_GET_SAMPLINGRATE, PARAM_GET_SAMPLINGRATE,
PARAM_GET_CONVKNLID PARAM_GET_CONVKNLID

View File

@ -1,5 +1,6 @@
#include "ViPER.h" #include "ViPER.h"
#include <ctime> #include <ctime>
#include <cstring>
#include "constants.h" #include "constants.h"
ViPER::ViPER() { ViPER::ViPER() {
@ -99,14 +100,11 @@ ViPER::ViPER() {
softwareLimiter->ResetLimiter(); softwareLimiter->ResetLimiter();
} }
this->fetcomp_enabled = false;
this->init_ok = true;
this->frame_scale = 1.0; this->frame_scale = 1.0;
this->left_pan = 1.0; this->left_pan = 1.0;
this->process_time_ms = 0; this->process_time_ms = 0;
this->right_pan = 1.0; this->right_pan = 1.0;
this->enabled = false; this->enabled = false;
this->force_enabled = false;
this->update_status = false; this->update_status = false;
} }
@ -137,9 +135,14 @@ ViPER::~ViPER() {
// TODO: Return int // TODO: Return int
void ViPER::processBuffer(float *buffer, uint32_t size) { void ViPER::processBuffer(float *buffer, uint32_t size) {
if (!this->enabled) return; if (!this->enabled) {
if (size == 0) return; VIPER_LOGD("ViPER is disabled, skip processing");
if (!this->init_ok) return; return;
}
if (size == 0) {
VIPER_LOGD("Buffer size is 0, skip processing");
return;
}
if (this->update_status) { if (this->update_status) {
struct timeval time{}; struct timeval time{};
@ -148,60 +151,86 @@ void ViPER::processBuffer(float *buffer, uint32_t size) {
} }
uint32_t ret; uint32_t ret;
float *tmpBuf;
uint32_t tmpBufSize;
// if convolver is enabled if (this->convolver->GetEnabled() || this->vhe->GetEnabled()) {
ret = this->waveBuffer->PushSamples(buffer, size); if (!this->waveBuffer->PushSamples(buffer, size)) {
if (ret == 0) { this->waveBuffer->Reset();
this->waveBuffer->Reset(); return;
return; }
float *ptr = this->waveBuffer->GetBuffer();
ret = this->convolver->Process(ptr, ptr, size);
ret = this->vhe->Process(ptr, ptr, ret);
this->waveBuffer->SetBufferOffset(ret);
if (!this->adaptiveBuffer->PushZero(ret)) {
this->waveBuffer->Reset();
this->adaptiveBuffer->FlushBuffer();
return;
}
ptr = this->adaptiveBuffer->GetBuffer();
ret = this->waveBuffer->PopSamples(ptr, ret, true);
this->adaptiveBuffer->SetBufferOffset(ret);
tmpBuf = ptr;
tmpBufSize = ret;
} else {
if (this->adaptiveBuffer->PushFrames(buffer, size)) {
this->adaptiveBuffer->SetBufferOffset(size);
tmpBuf = this->adaptiveBuffer->GetBuffer();
tmpBufSize = size;
} else {
this->adaptiveBuffer->FlushBuffer();
return;
}
} }
auto pWaveBuffer = this->waveBuffer->GetBuffer(); if (tmpBufSize != 0) {
this->convolver->Process(pWaveBuffer, pWaveBuffer, size); this->viperDdc->Process(tmpBuf, size);
this->vhe->Process(pWaveBuffer, pWaveBuffer, size); this->spectrumExtend->Process(tmpBuf, size);
this->waveBuffer->SetBufferOffset(size); this->iirFilter->Process(tmpBuf, tmpBufSize);
this->colorfulMusic->Process(tmpBuf, tmpBufSize);
ret = this->adaptiveBuffer->PushZero(size); this->diffSurround->Process(tmpBuf, tmpBufSize);
if (ret == 0) { this->reverberation->Process(tmpBuf, tmpBufSize);
this->waveBuffer->Reset(); this->speakerCorrection->Process(tmpBuf, tmpBufSize);
this->adaptiveBuffer->FlushBuffer(); this->playbackGain->Process(tmpBuf, tmpBufSize);
return; this->fetCompressor->Process(tmpBuf, tmpBufSize); // TODO: enable check
} this->dynamicSystem->Process(tmpBuf, tmpBufSize);
this->viperBass->Process(tmpBuf, tmpBufSize);
auto pAdaptiveBuffer = this->adaptiveBuffer->GetBufferPointer(); this->viperClarity->Process(tmpBuf, tmpBufSize);
ret = this->waveBuffer->PopSamples((float *) pAdaptiveBuffer, size, true); this->cure->Process(tmpBuf, tmpBufSize);
this->adaptiveBuffer->SetBufferOffset(ret); this->tubeSimulator->TubeProcess(tmpBuf, size);
this->analogX->Process(tmpBuf, tmpBufSize);
pAdaptiveBuffer = this->adaptiveBuffer->GetBufferPointer();
if (ret != 0) {
this->viperDdc->Process(pAdaptiveBuffer, size);
this->spectrumExtend->Process(pAdaptiveBuffer, size);
this->iirFilter->Process(pAdaptiveBuffer, ret);
this->colorfulMusic->Process(pAdaptiveBuffer, ret);
this->diffSurround->Process(pAdaptiveBuffer, ret);
this->reverberation->Process(pAdaptiveBuffer, ret);
this->speakerCorrection->Process(pAdaptiveBuffer, ret);
this->playbackGain->Process(pAdaptiveBuffer, ret);
this->fetCompressor->Process(pAdaptiveBuffer, ret);
this->dynamicSystem->Process(pAdaptiveBuffer, ret);
this->viperBass->Process(pAdaptiveBuffer, ret);
this->viperClarity->Process(pAdaptiveBuffer, ret);
this->cure->Process(pAdaptiveBuffer, ret);
this->tubeSimulator->TubeProcess(pAdaptiveBuffer, size);
this->analogX->Process(pAdaptiveBuffer, ret);
}
if (this->frame_scale != 1.0) {
this->adaptiveBuffer->ScaleFrames(this->frame_scale);
}
if (this->left_pan < 1.0 || this->right_pan < 1.0) {
this->adaptiveBuffer->PanFrames(this->left_pan, this->right_pan);
}
if (ret << 1 != 0) {
if (this->frame_scale != 1.0) {
this->adaptiveBuffer->ScaleFrames(this->frame_scale);
}
if (this->left_pan < 1.0 || this->right_pan < 1.0) {
this->adaptiveBuffer->PanFrames(this->left_pan, this->right_pan);
}
for (uint32_t i = 0; i < tmpBufSize * 2; i += 2) {
tmpBuf[i] = this->softwareLimiters[0]->Process(tmpBuf[i]);
tmpBuf[i + 1] = this->softwareLimiters[1]->Process(tmpBuf[i + 1]);
}
if (!this->adaptiveBuffer->PopFrames(buffer, tmpBufSize)) {
this->adaptiveBuffer->FlushBuffer();
return;
}
if (size <= tmpBufSize) {
return;
}
} }
memmove(buffer + (size - tmpBufSize) * 2, buffer, tmpBufSize * sizeof(float));
memset(buffer, 0, (size - tmpBufSize) * sizeof(float));
} }
void ViPER::DispatchCommand(int param, int val1, int val2, int val3, int val4, uint32_t arrSize, void ViPER::DispatchCommand(int param, int val1, int val2, int val3, int val4, uint32_t arrSize,

View File

@ -32,17 +32,15 @@ public:
void DispatchCommand(int param, int val1, int val2, int val3, int val4, uint32_t arrSize, signed char *arr); void DispatchCommand(int param, int val1, int val2, int val3, int val4, uint32_t arrSize, signed char *arr);
void ResetAllEffects(); void ResetAllEffects();
//private:
bool update_status; bool update_status;
uint64_t process_time_ms; uint64_t process_time_ms;
bool init_ok;
bool enabled; bool enabled;
bool force_enabled;
uint32_t samplingRate; uint32_t samplingRate;
// Effects // Effects
AdaptiveBuffer *adaptiveBuffer; AdaptiveBuffer *adaptiveBuffer;
WaveBuffer *waveBuffer; WaveBuffer *waveBuffer;
bool fetcomp_enabled;
Convolver *convolver; Convolver *convolver;
VHE *vhe; VHE *vhe;
ViPERDDC *viperDdc; ViPERDDC *viperDdc;

View File

@ -4,13 +4,9 @@
ColorfulMusic::ColorfulMusic() { ColorfulMusic::ColorfulMusic() {
this->samplingRate = DEFAULT_SAMPLERATE; this->samplingRate = DEFAULT_SAMPLERATE;
this->enabled = false; this->enabled = false;
this->stereo3DSurround->SetStereoWiden(0.0f); this->stereo3DSurround.SetStereoWiden(0.0f);
this->depthSurround->SetSamplingRate(this->samplingRate); this->depthSurround.SetSamplingRate(this->samplingRate);
this->depthSurround->SetStrength(0); this->depthSurround.SetStrength(0);
}
ColorfulMusic::~ColorfulMusic() {
} }
void ColorfulMusic::Process(float *samples, uint32_t size) { void ColorfulMusic::Process(float *samples, uint32_t size) {
@ -18,16 +14,16 @@ void ColorfulMusic::Process(float *samples, uint32_t size) {
return; return;
} }
this->depthSurround->Process(samples, size); this->depthSurround.Process(samples, size);
this->stereo3DSurround->Process(samples, size); this->stereo3DSurround.Process(samples, size);
} }
void ColorfulMusic::Reset() { void ColorfulMusic::Reset() {
this->depthSurround->SetSamplingRate(this->samplingRate); this->depthSurround.SetSamplingRate(this->samplingRate);
} }
void ColorfulMusic::SetDepthValue(short depthValue) { void ColorfulMusic::SetDepthValue(short depthValue) {
this->depthSurround->SetStrength(depthValue); this->depthSurround.SetStrength(depthValue);
} }
void ColorfulMusic::SetEnable(bool enable) { void ColorfulMusic::SetEnable(bool enable) {
@ -40,16 +36,16 @@ void ColorfulMusic::SetEnable(bool enable) {
} }
void ColorfulMusic::SetMidImageValue(float midImageValue) { void ColorfulMusic::SetMidImageValue(float midImageValue) {
this->stereo3DSurround->SetMiddleImage(midImageValue); this->stereo3DSurround.SetMiddleImage(midImageValue);
} }
void ColorfulMusic::SetSamplingRate(uint32_t samplingRate) { void ColorfulMusic::SetSamplingRate(uint32_t samplingRate) {
if (this->samplingRate != samplingRate) { if (this->samplingRate != samplingRate) {
this->samplingRate = samplingRate; this->samplingRate = samplingRate;
this->depthSurround->SetSamplingRate(this->samplingRate); this->depthSurround.SetSamplingRate(this->samplingRate);
} }
} }
void ColorfulMusic::SetWidenValue(float widenValue) { void ColorfulMusic::SetWidenValue(float widenValue) {
this->stereo3DSurround->SetStereoWiden(widenValue); this->stereo3DSurround.SetStereoWiden(widenValue);
} }

View File

@ -7,7 +7,6 @@
class ColorfulMusic { class ColorfulMusic {
public: public:
ColorfulMusic(); ColorfulMusic();
~ColorfulMusic();
void Process(float *samples, uint32_t size); void Process(float *samples, uint32_t size);
void Reset(); void Reset();
@ -18,8 +17,8 @@ public:
void SetWidenValue(float widenValue); void SetWidenValue(float widenValue);
private: private:
Stereo3DSurround *stereo3DSurround; Stereo3DSurround stereo3DSurround;
DepthSurround *depthSurround; DepthSurround depthSurround;
uint32_t samplingRate; uint32_t samplingRate;
bool enabled; bool enabled;

View File

@ -24,8 +24,8 @@ void Convolver::PrepareKernelBuffer(uint32_t param_1, uint32_t param_2, int32_t
} }
void Convolver::Process(float *source, float *dest, int32_t frameSize) { uint32_t Convolver::Process(float *source, float *dest, uint32_t frameSize) {
return frameSize;
} }
void Convolver::Reset() { void Convolver::Reset() {

View File

@ -11,7 +11,7 @@ public:
bool GetEnabled(); bool GetEnabled();
uint32_t GetKernelID(); uint32_t GetKernelID();
void PrepareKernelBuffer(uint32_t param_1, uint32_t param_2, int32_t kernelId); void PrepareKernelBuffer(uint32_t param_1, uint32_t param_2, int32_t kernelId);
void Process(float *source, float *dest, int32_t frameSize); uint32_t Process(float *source, float *dest, uint32_t frameSize);
void Reset(); void Reset();
void SetCrossChannel(float param_1); void SetCrossChannel(float param_1);
void SetEnable(bool enabled); void SetEnable(bool enabled);

View File

@ -11,8 +11,8 @@ SoftwareLimiter::SoftwareLimiter() {
this->ResetLimiter(); this->ResetLimiter();
} }
void SoftwareLimiter::Process(float *samples, uint32_t size) { float SoftwareLimiter::Process(float sample) {
return sample;
} }
void SoftwareLimiter::ResetLimiter() { void SoftwareLimiter::ResetLimiter() {

View File

@ -6,7 +6,7 @@ class SoftwareLimiter {
public: public:
SoftwareLimiter(); SoftwareLimiter();
void Process(float *samples, uint32_t size); float Process(float sample);
void ResetLimiter(); void ResetLimiter();
void SetGate(float gate); void SetGate(float gate);

View File

@ -17,7 +17,7 @@ VHE::~VHE() {
delete bufB; delete bufB;
} }
void VHE::Process(float *source, float *dest, int frameSize) { uint32_t VHE::Process(float *source, float *dest, uint32_t frameSize) {
if (enabled && convLeft.InstanceUsable() && convRight.InstanceUsable()) { if (enabled && convLeft.InstanceUsable() && convRight.InstanceUsable()) {
if (bufA->PushSamples(source, frameSize) != 0) { if (bufA->PushSamples(source, frameSize) != 0) {
while (bufA->GetBufferOffset() > convSize) { while (bufA->GetBufferOffset() > convSize) {
@ -27,9 +27,10 @@ void VHE::Process(float *source, float *dest, int frameSize) {
bufB->PushSamples(buffer, convSize); bufB->PushSamples(buffer, convSize);
bufA->PopSamples(convSize, true); bufA->PopSamples(convSize, true);
} }
bufB->PopSamples(dest, frameSize, false); return bufB->PopSamples(dest, frameSize, false);
} }
} }
return frameSize;
} }
void VHE::Reset() { void VHE::Reset() {

View File

@ -10,7 +10,7 @@ public:
~VHE(); ~VHE();
bool GetEnabled(); bool GetEnabled();
void Process(float *source, float *dest, int frameSize); uint32_t Process(float *source, float *dest, uint32_t frameSize);
void Reset(); void Reset();
void SetEffectLevel(uint32_t level); void SetEffectLevel(uint32_t level);
void SetEnable(bool enabled); void SetEnable(bool enabled);

View File

@ -28,7 +28,7 @@ uint32_t AdaptiveBuffer::GetBufferOffset() const {
return this->offset; return this->offset;
} }
float *AdaptiveBuffer::GetBufferPointer() const { float *AdaptiveBuffer::GetBuffer() const {
return this->buffer; return this->buffer;
} }

View File

@ -10,7 +10,7 @@ public:
void FlushBuffer(); void FlushBuffer();
uint32_t GetBufferLength() const; uint32_t GetBufferLength() const;
uint32_t GetBufferOffset() const; uint32_t GetBufferOffset() const;
float *GetBufferPointer() const; float *GetBuffer() const;
uint32_t GetChannels() const; 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);

View File

@ -11,9 +11,9 @@ FIR::FIR() {
} }
FIR::~FIR() { FIR::~FIR() {
delete this->offsetBlock; delete[] this->offsetBlock;
delete this->coeffs; delete[] this->coeffs;
delete this->block; delete[] this->block;
} }
void FIR::FilterSamples(float *samples, uint32_t size) { void FIR::FilterSamples(float *samples, uint32_t size) {
@ -57,9 +57,9 @@ uint32_t FIR::GetBlockLength() {
int FIR::LoadCoefficients(const float *coeffs, uint32_t coeffsSize, uint32_t blockLength) { int FIR::LoadCoefficients(const float *coeffs, uint32_t coeffsSize, uint32_t blockLength) {
if (coeffs == nullptr || coeffsSize == 0 || blockLength == 0) return 0; if (coeffs == nullptr || coeffsSize == 0 || blockLength == 0) return 0;
delete this->offsetBlock; delete[] this->offsetBlock;
delete this->coeffs; delete[] this->coeffs;
delete this->block; delete[] this->block;
this->offsetBlock = new float[coeffsSize + blockLength + 1]; this->offsetBlock = new float[coeffsSize + blockLength + 1];
this->coeffs = new float[coeffsSize]; this->coeffs = new float[coeffsSize];

View File

@ -26,26 +26,27 @@ Harmonic::~Harmonic() {
} }
float Harmonic::Process(float sample) { float Harmonic::Process(float sample) {
float prevLast = this->lastProcessed; // float prevLast = this->lastProcessed;
this->lastProcessed = ( // this->lastProcessed = (
sample * this->coeffs[0] + // sample * this->coeffs[0] +
sample * this->coeffs[1] + // sample * this->coeffs[1] +
sample * this->coeffs[2] + // sample * this->coeffs[2] +
sample * this->coeffs[3] + // sample * this->coeffs[3] +
sample * this->coeffs[4] + // sample * this->coeffs[4] +
sample * this->coeffs[5] + // sample * this->coeffs[5] +
sample * this->coeffs[6] + // sample * this->coeffs[6] +
sample * this->coeffs[7] + // sample * this->coeffs[7] +
sample * this->coeffs[8] + // sample * this->coeffs[8] +
sample * this->coeffs[9] + // sample * this->coeffs[9] +
sample * this->coeffs[10] // sample * this->coeffs[10]
); // );
this->prevOut = (this->lastProcessed + this->prevOut * 0.999f) - prevLast; // this->prevOut = (this->lastProcessed + this->prevOut * 0.999f) - prevLast;
if (this->sampleCounter < this->buildup) { // if (this->sampleCounter < this->buildup) {
this->sampleCounter++; // this->sampleCounter++;
return 0.0; // return 0.0;
} // }
return this->prevOut; // return this->prevOut;
return sample;
} }
void Harmonic::Reset() { void Harmonic::Reset() {
@ -60,58 +61,58 @@ void Harmonic::SetHarmonics(float *coefficients) {
} }
void Harmonic::UpdateCoeffs(float *coefficients) { void Harmonic::UpdateCoeffs(float *coefficients) {
float fVar5; // float fVar5;
float fVar6; // float fVar6;
float _coeffs[20]; // float _coeffs[20];
float afStack76[14]; // float afStack76[14];
//
memset(_coeffs, 0, 11 * sizeof(float)); // memset(_coeffs, 0, 11 * sizeof(float));
this->buildup = (int) fabsf(coefficients[10]); // this->buildup = (int) fabsf(coefficients[10]);
memcpy(&_coeffs[1], coefficients, 10 * sizeof(float)); // memcpy(&_coeffs[1], coefficients, 10 * sizeof(float));
//
fVar6 = 1.f / ( // fVar6 = 1.f / (
fabsf(_coeffs[1]) + // fabsf(_coeffs[1]) +
fabsf(_coeffs[2]) + // fabsf(_coeffs[2]) +
fabsf(_coeffs[3]) + // fabsf(_coeffs[3]) +
fabsf(_coeffs[4]) + // fabsf(_coeffs[4]) +
fabsf(_coeffs[5]) + // fabsf(_coeffs[5]) +
fabsf(_coeffs[6]) + // fabsf(_coeffs[6]) +
fabsf(_coeffs[7]) + // fabsf(_coeffs[7]) +
fabsf(_coeffs[8]) + // fabsf(_coeffs[8]) +
fabsf(_coeffs[9]) + // fabsf(_coeffs[9]) +
fabsf(_coeffs[10]) // fabsf(_coeffs[10])
); // );
//
for (int i = 0; i < 11; i++) { // for (int i = 0; i < 11; i++) {
_coeffs[i] *= fVar6; // _coeffs[i] *= fVar6;
} // }
//
for (int i = 0; i < 11; i++) { // for (int i = 0; i < 11; i++) {
afStack76[2 + i] = 0; // afStack76[2 + i] = 0;
_coeffs[10 + i] = 0; // _coeffs[10 + i] = 0;
} // }
//
_coeffs[11] = _coeffs[10]; // _coeffs[11] = _coeffs[10];
fVar6 = _coeffs[11]; // fVar6 = _coeffs[11];
for (int i = 2; i < 11; i++) { // for (int i = 2; i < 11; i++) {
for (int idx = 0; idx < i; idx++) { // for (int idx = 0; idx < i; idx++) {
_coeffs[11] = fVar6; // _coeffs[11] = fVar6;
fVar5 = _coeffs[10 - idx + i]; // fVar5 = _coeffs[10 - idx + i];
fVar6 = afStack76[2 - idx + i]; // fVar6 = afStack76[2 - idx + i];
afStack76[2 - idx + i] = _coeffs[11 - idx + i]; // afStack76[2 - idx + i] = _coeffs[11 - idx + i];
_coeffs[11 - idx + i] = 2 * fVar5 - fVar6; // _coeffs[11 - idx + i] = 2 * fVar5 - fVar6;
fVar6 = _coeffs[11]; // fVar6 = _coeffs[11];
} // }
fVar6 = _coeffs[11 - i] - afStack76[2]; // fVar6 = _coeffs[11 - i] - afStack76[2];
afStack76[2] = _coeffs[11]; // afStack76[2] = _coeffs[11];
} // }
//
for (int i = 1; i < 11; i++) { // for (int i = 1; i < 11; i++) {
afStack76[2 + i] = afStack76[i - 1] - afStack76[13 - i]; // afStack76[2 + i] = afStack76[i - 1] - afStack76[13 - i];
} // }
//
_coeffs[11] = _coeffs[0] * 0.5f - _coeffs[11]; // _coeffs[11] = _coeffs[0] * 0.5f - _coeffs[11];
for (int i = 0; i < 11; i++) { // for (int i = 0; i < 11; i++) {
this->coeffs[i] = _coeffs[11 + i]; // this->coeffs[i] = _coeffs[11 + i];
} // }
} }

View File

@ -102,7 +102,7 @@ MinPhaseIIRCoeffs::MinPhaseIIRCoeffs() {
} }
MinPhaseIIRCoeffs::~MinPhaseIIRCoeffs() { MinPhaseIIRCoeffs::~MinPhaseIIRCoeffs() {
delete this->coeffs; delete[] this->coeffs;
} }
void MinPhaseIIRCoeffs::Find_F1_F2(double param_2, double param_3, double *param_4, double *param_5) { void MinPhaseIIRCoeffs::Find_F1_F2(double param_2, double param_3, double *param_4, double *param_5) {
@ -158,7 +158,7 @@ int MinPhaseIIRCoeffs::UpdateCoeffs(uint32_t bands, uint32_t samplingRate) {
this->bands = bands; this->bands = bands;
this->samplingRate = samplingRate; this->samplingRate = samplingRate;
delete this->coeffs; delete[] this->coeffs;
this->coeffs = new float[bands * 4](); this->coeffs = new float[bands * 4]();
const float *coeffsArray; const float *coeffsArray;

View File

@ -155,7 +155,7 @@ Polyphase::~Polyphase() {
delete this->fir2; delete this->fir2;
delete this->waveBuffer1; delete this->waveBuffer1;
delete this->waveBuffer2; delete this->waveBuffer2;
delete this->buffer; delete[] this->buffer;
} }
uint32_t Polyphase::GetLatency() { uint32_t Polyphase::GetLatency() {

View File

@ -8,7 +8,7 @@ TimeConstDelay::TimeConstDelay() {
} }
TimeConstDelay::~TimeConstDelay() { TimeConstDelay::~TimeConstDelay() {
delete this->samples; delete[] this->samples;
} }
float TimeConstDelay::ProcessSample(float sample) { float TimeConstDelay::ProcessSample(float sample) {
@ -22,8 +22,8 @@ float TimeConstDelay::ProcessSample(float sample) {
} }
void TimeConstDelay::SetParameters(uint32_t samplingRate, float delay) { void TimeConstDelay::SetParameters(uint32_t samplingRate, float delay) {
this->sampleCount = samplingRate * (uint32_t) ceil(delay); this->sampleCount = (uint32_t) ((float) samplingRate * delay);
delete this->samples; delete[] this->samples;
this->samples = new float[this->sampleCount](); this->samples = new float[this->sampleCount]();
this->offset = 0; this->offset = 0;
} }

View File

@ -5,13 +5,12 @@
class TimeConstDelay { class TimeConstDelay {
public: public:
TimeConstDelay(); TimeConstDelay();
~TimeConstDelay(); ~TimeConstDelay();
float ProcessSample(float sample); float ProcessSample(float sample);
void SetParameters(uint32_t samplingRate, float delay); void SetParameters(uint32_t samplingRate, float delay);
private:
float *samples; float *samples;
uint32_t offset; uint32_t offset;
uint32_t sampleCount; uint32_t sampleCount;

View File

@ -9,7 +9,7 @@ WaveBuffer::WaveBuffer(uint32_t channels, uint32_t size) {
} }
WaveBuffer::~WaveBuffer() { WaveBuffer::~WaveBuffer() {
delete this->buffer; delete[] this->buffer;
} }
uint32_t WaveBuffer::GetBufferOffset() { uint32_t WaveBuffer::GetBufferOffset() {
@ -76,7 +76,7 @@ int WaveBuffer::PushSamples(float *source, uint32_t size) {
if (this->size < requiredSize) { if (this->size < requiredSize) {
auto *buf = new float[requiredSize]; auto *buf = new float[requiredSize];
memcpy(buf, this->buffer, this->index * sizeof(float)); memcpy(buf, this->buffer, this->index * sizeof(float));
delete this->buffer; delete[] this->buffer;
this->buffer = buf; this->buffer = buf;
this->size = requiredSize; this->size = requiredSize;
} }
@ -97,7 +97,7 @@ int WaveBuffer::PushZeros(uint32_t size) {
if (this->size < requiredSize) { if (this->size < requiredSize) {
auto *buf = new float[requiredSize]; auto *buf = new float[requiredSize];
memcpy(buf, this->buffer, this->index * sizeof(float)); memcpy(buf, this->buffer, this->index * sizeof(float));
delete this->buffer; delete[] this->buffer;
this->buffer = buf; this->buffer = buf;
this->size = requiredSize; this->size = requiredSize;
} }
@ -120,7 +120,7 @@ float *WaveBuffer::PushZerosGetBuffer(uint32_t size) {
if (this->size < requiredSize) { if (this->size < requiredSize) {
auto *buf = new float[requiredSize]; auto *buf = new float[requiredSize];
memcpy(buf, this->buffer, this->index * sizeof(float)); memcpy(buf, this->buffer, this->index * sizeof(float));
delete this->buffer; delete[] this->buffer;
this->buffer = buf; this->buffer = buf;
this->size = requiredSize; this->size = requiredSize;
} }