mirror of
https://github.com/AndroidAudioMods/ViPERFX_RE.git
synced 2025-06-08 02:29:40 +08:00
Update
This commit is contained in:
parent
e84cd53d79
commit
9d54379bd8
@ -1,25 +1,25 @@
|
||||
cmake_minimum_required(VERSION 3.16.3)
|
||||
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")
|
||||
add_compile_definitions(VERSION_MAJOR=1)
|
||||
add_compile_definitions(VERSION_MINOR=0)
|
||||
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
|
||||
set(KISSFFT_PKGCONFIG OFF)
|
||||
set(KISSFFT_STATIC ON)
|
||||
set(KISSFFT_TEST OFF)
|
||||
set(KISSFFT_TOOLS OFF)
|
||||
add_subdirectory(src/cpp/viper/kissfft)
|
||||
#add_subdirectory(src/cpp/viper/kissfft)
|
||||
|
||||
# ViPERFX
|
||||
include_directories(src/include)
|
||||
@ -90,4 +90,4 @@ add_library(
|
||||
# Provides a relative path to your source file(s).
|
||||
${FILES})
|
||||
|
||||
target_link_libraries(v4afx_r log kissfft)
|
||||
target_link_libraries(v4afx_r log) # kissfft)
|
||||
|
@ -10,8 +10,12 @@
|
||||
#define VIPER_EFFECT_NAME "ViPER4Android"
|
||||
|
||||
static effect_descriptor_t viper_descriptor = {
|
||||
// ee48cf24-9221-4095-2cb9-40faa133111b
|
||||
.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,
|
||||
.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
|
||||
@ -30,6 +34,12 @@ struct ViperContext {
|
||||
static int32_t Viper_IProcess(effect_handle_t self, audio_buffer_t *inBuffer, audio_buffer_t *outBuffer) {
|
||||
auto pContext = reinterpret_cast<ViperContext *>(self);
|
||||
|
||||
static uint32_t tmp = 0;
|
||||
if (tmp % 50 == 0) {
|
||||
VIPER_LOGD("Viper_IProcess called!");
|
||||
}
|
||||
tmp++;
|
||||
|
||||
if (pContext == nullptr ||
|
||||
inBuffer == nullptr || outBuffer == 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("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) {
|
||||
VIPER_LOGE("ViPER4Android disabled, reason [in.SR = %d, out.SR = %d]",
|
||||
newConfig->inputCfg.samplingRate, newConfig->outputCfg.samplingRate);
|
||||
@ -75,12 +92,14 @@ static int configure(ViperContext *pContext, effect_config_t *newConfig) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
// AUDIO_FORMAT_PCM_16_BIT
|
||||
if (newConfig->inputCfg.format != AUDIO_FORMAT_PCM_FLOAT) {
|
||||
VIPER_LOGE("ViPER4Android disabled, reason [in.FMT = %d]", newConfig->inputCfg.format);
|
||||
VIPER_LOGE("We only accept f32 format");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
// AUDIO_FORMAT_PCM_16_BIT
|
||||
if (newConfig->outputCfg.format != AUDIO_FORMAT_PCM_FLOAT) {
|
||||
VIPER_LOGE("ViPER4Android disabled, reason [out.FMT = %d]", newConfig->outputCfg.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.
|
||||
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) {
|
||||
case PARAM_GET_DRIVER_VERSION: {
|
||||
pReplyParam->status = 0;
|
||||
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;
|
||||
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;
|
||||
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
|
||||
struct timeval time{};
|
||||
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) {
|
||||
auto pContext = reinterpret_cast<ViperContext *>(self);
|
||||
|
||||
VIPER_LOGD("Viper_IGetDescriptor called");
|
||||
|
||||
if (pContext == nullptr || pDescriptor == nullptr) {
|
||||
VIPER_LOGE("Viper_IGetDescriptor: pContext or pDescriptor is null!");
|
||||
return -EINVAL;
|
||||
|
@ -10,10 +10,9 @@ enum ParamsMode {
|
||||
};
|
||||
|
||||
enum ParamsGet {
|
||||
PARAM_GET_DRIVER_VERSION,
|
||||
PARAM_GET_DRIVER_VERSION = 0,
|
||||
PARAM_GET_ENABLED,
|
||||
PARAM_GET_CONFIGURE,
|
||||
PARAM_GET_DRVCANWORK,
|
||||
PARAM_GET_STREAMING,
|
||||
PARAM_GET_SAMPLINGRATE,
|
||||
PARAM_GET_CONVKNLID
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "ViPER.h"
|
||||
#include <ctime>
|
||||
#include <cstring>
|
||||
#include "constants.h"
|
||||
|
||||
ViPER::ViPER() {
|
||||
@ -99,14 +100,11 @@ ViPER::ViPER() {
|
||||
softwareLimiter->ResetLimiter();
|
||||
}
|
||||
|
||||
this->fetcomp_enabled = false;
|
||||
this->init_ok = true;
|
||||
this->frame_scale = 1.0;
|
||||
this->left_pan = 1.0;
|
||||
this->process_time_ms = 0;
|
||||
this->right_pan = 1.0;
|
||||
this->enabled = false;
|
||||
this->force_enabled = false;
|
||||
this->update_status = false;
|
||||
}
|
||||
|
||||
@ -137,9 +135,14 @@ ViPER::~ViPER() {
|
||||
|
||||
// TODO: Return int
|
||||
void ViPER::processBuffer(float *buffer, uint32_t size) {
|
||||
if (!this->enabled) return;
|
||||
if (size == 0) return;
|
||||
if (!this->init_ok) return;
|
||||
if (!this->enabled) {
|
||||
VIPER_LOGD("ViPER is disabled, skip processing");
|
||||
return;
|
||||
}
|
||||
if (size == 0) {
|
||||
VIPER_LOGD("Buffer size is 0, skip processing");
|
||||
return;
|
||||
}
|
||||
|
||||
if (this->update_status) {
|
||||
struct timeval time{};
|
||||
@ -148,60 +151,86 @@ void ViPER::processBuffer(float *buffer, uint32_t size) {
|
||||
}
|
||||
|
||||
uint32_t ret;
|
||||
float *tmpBuf;
|
||||
uint32_t tmpBufSize;
|
||||
|
||||
// if convolver is enabled
|
||||
ret = this->waveBuffer->PushSamples(buffer, size);
|
||||
if (ret == 0) {
|
||||
if (this->convolver->GetEnabled() || this->vhe->GetEnabled()) {
|
||||
if (!this->waveBuffer->PushSamples(buffer, size)) {
|
||||
this->waveBuffer->Reset();
|
||||
return;
|
||||
}
|
||||
|
||||
auto pWaveBuffer = this->waveBuffer->GetBuffer();
|
||||
this->convolver->Process(pWaveBuffer, pWaveBuffer, size);
|
||||
this->vhe->Process(pWaveBuffer, pWaveBuffer, size);
|
||||
this->waveBuffer->SetBufferOffset(size);
|
||||
float *ptr = this->waveBuffer->GetBuffer();
|
||||
ret = this->convolver->Process(ptr, ptr, size);
|
||||
ret = this->vhe->Process(ptr, ptr, ret);
|
||||
this->waveBuffer->SetBufferOffset(ret);
|
||||
|
||||
ret = this->adaptiveBuffer->PushZero(size);
|
||||
if (ret == 0) {
|
||||
if (!this->adaptiveBuffer->PushZero(ret)) {
|
||||
this->waveBuffer->Reset();
|
||||
this->adaptiveBuffer->FlushBuffer();
|
||||
return;
|
||||
}
|
||||
|
||||
auto pAdaptiveBuffer = this->adaptiveBuffer->GetBufferPointer();
|
||||
ret = this->waveBuffer->PopSamples((float *) pAdaptiveBuffer, size, true);
|
||||
ptr = this->adaptiveBuffer->GetBuffer();
|
||||
ret = this->waveBuffer->PopSamples(ptr, ret, true);
|
||||
this->adaptiveBuffer->SetBufferOffset(ret);
|
||||
|
||||
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);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
if (tmpBufSize != 0) {
|
||||
this->viperDdc->Process(tmpBuf, size);
|
||||
this->spectrumExtend->Process(tmpBuf, size);
|
||||
this->iirFilter->Process(tmpBuf, tmpBufSize);
|
||||
this->colorfulMusic->Process(tmpBuf, tmpBufSize);
|
||||
this->diffSurround->Process(tmpBuf, tmpBufSize);
|
||||
this->reverberation->Process(tmpBuf, tmpBufSize);
|
||||
this->speakerCorrection->Process(tmpBuf, tmpBufSize);
|
||||
this->playbackGain->Process(tmpBuf, tmpBufSize);
|
||||
this->fetCompressor->Process(tmpBuf, tmpBufSize); // TODO: enable check
|
||||
this->dynamicSystem->Process(tmpBuf, tmpBufSize);
|
||||
this->viperBass->Process(tmpBuf, tmpBufSize);
|
||||
this->viperClarity->Process(tmpBuf, tmpBufSize);
|
||||
this->cure->Process(tmpBuf, tmpBufSize);
|
||||
this->tubeSimulator->TubeProcess(tmpBuf, size);
|
||||
this->analogX->Process(tmpBuf, tmpBufSize);
|
||||
|
||||
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) {
|
||||
|
||||
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,
|
||||
|
@ -32,17 +32,15 @@ public:
|
||||
void DispatchCommand(int param, int val1, int val2, int val3, int val4, uint32_t arrSize, signed char *arr);
|
||||
void ResetAllEffects();
|
||||
|
||||
//private:
|
||||
bool update_status;
|
||||
uint64_t process_time_ms;
|
||||
bool init_ok;
|
||||
bool enabled;
|
||||
bool force_enabled;
|
||||
uint32_t samplingRate;
|
||||
|
||||
// Effects
|
||||
AdaptiveBuffer *adaptiveBuffer;
|
||||
WaveBuffer *waveBuffer;
|
||||
bool fetcomp_enabled;
|
||||
Convolver *convolver;
|
||||
VHE *vhe;
|
||||
ViPERDDC *viperDdc;
|
||||
|
@ -4,13 +4,9 @@
|
||||
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() {
|
||||
|
||||
this->stereo3DSurround.SetStereoWiden(0.0f);
|
||||
this->depthSurround.SetSamplingRate(this->samplingRate);
|
||||
this->depthSurround.SetStrength(0);
|
||||
}
|
||||
|
||||
void ColorfulMusic::Process(float *samples, uint32_t size) {
|
||||
@ -18,16 +14,16 @@ void ColorfulMusic::Process(float *samples, uint32_t size) {
|
||||
return;
|
||||
}
|
||||
|
||||
this->depthSurround->Process(samples, size);
|
||||
this->stereo3DSurround->Process(samples, size);
|
||||
this->depthSurround.Process(samples, size);
|
||||
this->stereo3DSurround.Process(samples, size);
|
||||
}
|
||||
|
||||
void ColorfulMusic::Reset() {
|
||||
this->depthSurround->SetSamplingRate(this->samplingRate);
|
||||
this->depthSurround.SetSamplingRate(this->samplingRate);
|
||||
}
|
||||
|
||||
void ColorfulMusic::SetDepthValue(short depthValue) {
|
||||
this->depthSurround->SetStrength(depthValue);
|
||||
this->depthSurround.SetStrength(depthValue);
|
||||
}
|
||||
|
||||
void ColorfulMusic::SetEnable(bool enable) {
|
||||
@ -40,16 +36,16 @@ void ColorfulMusic::SetEnable(bool enable) {
|
||||
}
|
||||
|
||||
void ColorfulMusic::SetMidImageValue(float midImageValue) {
|
||||
this->stereo3DSurround->SetMiddleImage(midImageValue);
|
||||
this->stereo3DSurround.SetMiddleImage(midImageValue);
|
||||
}
|
||||
|
||||
void ColorfulMusic::SetSamplingRate(uint32_t samplingRate) {
|
||||
if (this->samplingRate != samplingRate) {
|
||||
this->samplingRate = samplingRate;
|
||||
this->depthSurround->SetSamplingRate(this->samplingRate);
|
||||
this->depthSurround.SetSamplingRate(this->samplingRate);
|
||||
}
|
||||
}
|
||||
|
||||
void ColorfulMusic::SetWidenValue(float widenValue) {
|
||||
this->stereo3DSurround->SetStereoWiden(widenValue);
|
||||
this->stereo3DSurround.SetStereoWiden(widenValue);
|
||||
}
|
||||
|
@ -7,7 +7,6 @@
|
||||
class ColorfulMusic {
|
||||
public:
|
||||
ColorfulMusic();
|
||||
~ColorfulMusic();
|
||||
|
||||
void Process(float *samples, uint32_t size);
|
||||
void Reset();
|
||||
@ -18,8 +17,8 @@ public:
|
||||
void SetWidenValue(float widenValue);
|
||||
|
||||
private:
|
||||
Stereo3DSurround *stereo3DSurround;
|
||||
DepthSurround *depthSurround;
|
||||
Stereo3DSurround stereo3DSurround;
|
||||
DepthSurround depthSurround;
|
||||
uint32_t samplingRate;
|
||||
bool enabled;
|
||||
|
||||
|
@ -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() {
|
||||
|
@ -11,7 +11,7 @@ public:
|
||||
bool GetEnabled();
|
||||
uint32_t GetKernelID();
|
||||
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 SetCrossChannel(float param_1);
|
||||
void SetEnable(bool enabled);
|
||||
|
@ -11,8 +11,8 @@ SoftwareLimiter::SoftwareLimiter() {
|
||||
this->ResetLimiter();
|
||||
}
|
||||
|
||||
void SoftwareLimiter::Process(float *samples, uint32_t size) {
|
||||
|
||||
float SoftwareLimiter::Process(float sample) {
|
||||
return sample;
|
||||
}
|
||||
|
||||
void SoftwareLimiter::ResetLimiter() {
|
||||
|
@ -6,7 +6,7 @@ class SoftwareLimiter {
|
||||
public:
|
||||
SoftwareLimiter();
|
||||
|
||||
void Process(float *samples, uint32_t size);
|
||||
float Process(float sample);
|
||||
void ResetLimiter();
|
||||
void SetGate(float gate);
|
||||
|
||||
|
@ -17,7 +17,7 @@ VHE::~VHE() {
|
||||
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 (bufA->PushSamples(source, frameSize) != 0) {
|
||||
while (bufA->GetBufferOffset() > convSize) {
|
||||
@ -27,9 +27,10 @@ void VHE::Process(float *source, float *dest, int frameSize) {
|
||||
bufB->PushSamples(buffer, convSize);
|
||||
bufA->PopSamples(convSize, true);
|
||||
}
|
||||
bufB->PopSamples(dest, frameSize, false);
|
||||
return bufB->PopSamples(dest, frameSize, false);
|
||||
}
|
||||
}
|
||||
return frameSize;
|
||||
}
|
||||
|
||||
void VHE::Reset() {
|
||||
|
@ -10,7 +10,7 @@ public:
|
||||
~VHE();
|
||||
|
||||
bool GetEnabled();
|
||||
void Process(float *source, float *dest, int frameSize);
|
||||
uint32_t Process(float *source, float *dest, uint32_t frameSize);
|
||||
void Reset();
|
||||
void SetEffectLevel(uint32_t level);
|
||||
void SetEnable(bool enabled);
|
||||
|
@ -28,7 +28,7 @@ uint32_t AdaptiveBuffer::GetBufferOffset() const {
|
||||
return this->offset;
|
||||
}
|
||||
|
||||
float *AdaptiveBuffer::GetBufferPointer() const {
|
||||
float *AdaptiveBuffer::GetBuffer() const {
|
||||
return this->buffer;
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@ public:
|
||||
void FlushBuffer();
|
||||
uint32_t GetBufferLength() const;
|
||||
uint32_t GetBufferOffset() const;
|
||||
float *GetBufferPointer() const;
|
||||
float *GetBuffer() const;
|
||||
uint32_t GetChannels() const;
|
||||
void PanFrames(float left, float right);
|
||||
int PopFrames(float *frames, uint32_t length);
|
||||
|
@ -11,9 +11,9 @@ FIR::FIR() {
|
||||
}
|
||||
|
||||
FIR::~FIR() {
|
||||
delete this->offsetBlock;
|
||||
delete this->coeffs;
|
||||
delete this->block;
|
||||
delete[] this->offsetBlock;
|
||||
delete[] this->coeffs;
|
||||
delete[] this->block;
|
||||
}
|
||||
|
||||
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) {
|
||||
if (coeffs == nullptr || coeffsSize == 0 || blockLength == 0) return 0;
|
||||
|
||||
delete this->offsetBlock;
|
||||
delete this->coeffs;
|
||||
delete this->block;
|
||||
delete[] this->offsetBlock;
|
||||
delete[] this->coeffs;
|
||||
delete[] this->block;
|
||||
|
||||
this->offsetBlock = new float[coeffsSize + blockLength + 1];
|
||||
this->coeffs = new float[coeffsSize];
|
||||
|
@ -26,26 +26,27 @@ Harmonic::~Harmonic() {
|
||||
}
|
||||
|
||||
float Harmonic::Process(float sample) {
|
||||
float prevLast = this->lastProcessed;
|
||||
this->lastProcessed = (
|
||||
sample * this->coeffs[0] +
|
||||
sample * this->coeffs[1] +
|
||||
sample * this->coeffs[2] +
|
||||
sample * this->coeffs[3] +
|
||||
sample * this->coeffs[4] +
|
||||
sample * this->coeffs[5] +
|
||||
sample * this->coeffs[6] +
|
||||
sample * this->coeffs[7] +
|
||||
sample * this->coeffs[8] +
|
||||
sample * this->coeffs[9] +
|
||||
sample * this->coeffs[10]
|
||||
);
|
||||
this->prevOut = (this->lastProcessed + this->prevOut * 0.999f) - prevLast;
|
||||
if (this->sampleCounter < this->buildup) {
|
||||
this->sampleCounter++;
|
||||
return 0.0;
|
||||
}
|
||||
return this->prevOut;
|
||||
// float prevLast = this->lastProcessed;
|
||||
// this->lastProcessed = (
|
||||
// sample * this->coeffs[0] +
|
||||
// sample * this->coeffs[1] +
|
||||
// sample * this->coeffs[2] +
|
||||
// sample * this->coeffs[3] +
|
||||
// sample * this->coeffs[4] +
|
||||
// sample * this->coeffs[5] +
|
||||
// sample * this->coeffs[6] +
|
||||
// sample * this->coeffs[7] +
|
||||
// sample * this->coeffs[8] +
|
||||
// sample * this->coeffs[9] +
|
||||
// sample * this->coeffs[10]
|
||||
// );
|
||||
// this->prevOut = (this->lastProcessed + this->prevOut * 0.999f) - prevLast;
|
||||
// if (this->sampleCounter < this->buildup) {
|
||||
// this->sampleCounter++;
|
||||
// return 0.0;
|
||||
// }
|
||||
// return this->prevOut;
|
||||
return sample;
|
||||
}
|
||||
|
||||
void Harmonic::Reset() {
|
||||
@ -60,58 +61,58 @@ void Harmonic::SetHarmonics(float *coefficients) {
|
||||
}
|
||||
|
||||
void Harmonic::UpdateCoeffs(float *coefficients) {
|
||||
float fVar5;
|
||||
float fVar6;
|
||||
float _coeffs[20];
|
||||
float afStack76[14];
|
||||
|
||||
memset(_coeffs, 0, 11 * sizeof(float));
|
||||
this->buildup = (int) fabsf(coefficients[10]);
|
||||
memcpy(&_coeffs[1], coefficients, 10 * sizeof(float));
|
||||
|
||||
fVar6 = 1.f / (
|
||||
fabsf(_coeffs[1]) +
|
||||
fabsf(_coeffs[2]) +
|
||||
fabsf(_coeffs[3]) +
|
||||
fabsf(_coeffs[4]) +
|
||||
fabsf(_coeffs[5]) +
|
||||
fabsf(_coeffs[6]) +
|
||||
fabsf(_coeffs[7]) +
|
||||
fabsf(_coeffs[8]) +
|
||||
fabsf(_coeffs[9]) +
|
||||
fabsf(_coeffs[10])
|
||||
);
|
||||
|
||||
for (int i = 0; i < 11; i++) {
|
||||
_coeffs[i] *= fVar6;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 11; i++) {
|
||||
afStack76[2 + i] = 0;
|
||||
_coeffs[10 + i] = 0;
|
||||
}
|
||||
|
||||
_coeffs[11] = _coeffs[10];
|
||||
fVar6 = _coeffs[11];
|
||||
for (int i = 2; i < 11; i++) {
|
||||
for (int idx = 0; idx < i; idx++) {
|
||||
_coeffs[11] = fVar6;
|
||||
fVar5 = _coeffs[10 - idx + i];
|
||||
fVar6 = afStack76[2 - idx + i];
|
||||
afStack76[2 - idx + i] = _coeffs[11 - idx + i];
|
||||
_coeffs[11 - idx + i] = 2 * fVar5 - fVar6;
|
||||
fVar6 = _coeffs[11];
|
||||
}
|
||||
fVar6 = _coeffs[11 - i] - afStack76[2];
|
||||
afStack76[2] = _coeffs[11];
|
||||
}
|
||||
|
||||
for (int i = 1; i < 11; i++) {
|
||||
afStack76[2 + i] = afStack76[i - 1] - afStack76[13 - i];
|
||||
}
|
||||
|
||||
_coeffs[11] = _coeffs[0] * 0.5f - _coeffs[11];
|
||||
for (int i = 0; i < 11; i++) {
|
||||
this->coeffs[i] = _coeffs[11 + i];
|
||||
}
|
||||
// float fVar5;
|
||||
// float fVar6;
|
||||
// float _coeffs[20];
|
||||
// float afStack76[14];
|
||||
//
|
||||
// memset(_coeffs, 0, 11 * sizeof(float));
|
||||
// this->buildup = (int) fabsf(coefficients[10]);
|
||||
// memcpy(&_coeffs[1], coefficients, 10 * sizeof(float));
|
||||
//
|
||||
// fVar6 = 1.f / (
|
||||
// fabsf(_coeffs[1]) +
|
||||
// fabsf(_coeffs[2]) +
|
||||
// fabsf(_coeffs[3]) +
|
||||
// fabsf(_coeffs[4]) +
|
||||
// fabsf(_coeffs[5]) +
|
||||
// fabsf(_coeffs[6]) +
|
||||
// fabsf(_coeffs[7]) +
|
||||
// fabsf(_coeffs[8]) +
|
||||
// fabsf(_coeffs[9]) +
|
||||
// fabsf(_coeffs[10])
|
||||
// );
|
||||
//
|
||||
// for (int i = 0; i < 11; i++) {
|
||||
// _coeffs[i] *= fVar6;
|
||||
// }
|
||||
//
|
||||
// for (int i = 0; i < 11; i++) {
|
||||
// afStack76[2 + i] = 0;
|
||||
// _coeffs[10 + i] = 0;
|
||||
// }
|
||||
//
|
||||
// _coeffs[11] = _coeffs[10];
|
||||
// fVar6 = _coeffs[11];
|
||||
// for (int i = 2; i < 11; i++) {
|
||||
// for (int idx = 0; idx < i; idx++) {
|
||||
// _coeffs[11] = fVar6;
|
||||
// fVar5 = _coeffs[10 - idx + i];
|
||||
// fVar6 = afStack76[2 - idx + i];
|
||||
// afStack76[2 - idx + i] = _coeffs[11 - idx + i];
|
||||
// _coeffs[11 - idx + i] = 2 * fVar5 - fVar6;
|
||||
// fVar6 = _coeffs[11];
|
||||
// }
|
||||
// fVar6 = _coeffs[11 - i] - afStack76[2];
|
||||
// afStack76[2] = _coeffs[11];
|
||||
// }
|
||||
//
|
||||
// for (int i = 1; i < 11; i++) {
|
||||
// afStack76[2 + i] = afStack76[i - 1] - afStack76[13 - i];
|
||||
// }
|
||||
//
|
||||
// _coeffs[11] = _coeffs[0] * 0.5f - _coeffs[11];
|
||||
// for (int i = 0; i < 11; i++) {
|
||||
// this->coeffs[i] = _coeffs[11 + i];
|
||||
// }
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ 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) {
|
||||
@ -158,7 +158,7 @@ int MinPhaseIIRCoeffs::UpdateCoeffs(uint32_t bands, uint32_t samplingRate) {
|
||||
this->bands = bands;
|
||||
this->samplingRate = samplingRate;
|
||||
|
||||
delete this->coeffs;
|
||||
delete[] this->coeffs;
|
||||
this->coeffs = new float[bands * 4]();
|
||||
|
||||
const float *coeffsArray;
|
||||
|
@ -155,7 +155,7 @@ Polyphase::~Polyphase() {
|
||||
delete this->fir2;
|
||||
delete this->waveBuffer1;
|
||||
delete this->waveBuffer2;
|
||||
delete this->buffer;
|
||||
delete[] this->buffer;
|
||||
}
|
||||
|
||||
uint32_t Polyphase::GetLatency() {
|
||||
|
@ -8,7 +8,7 @@ TimeConstDelay::TimeConstDelay() {
|
||||
}
|
||||
|
||||
TimeConstDelay::~TimeConstDelay() {
|
||||
delete this->samples;
|
||||
delete[] this->samples;
|
||||
}
|
||||
|
||||
float TimeConstDelay::ProcessSample(float sample) {
|
||||
@ -22,8 +22,8 @@ float TimeConstDelay::ProcessSample(float sample) {
|
||||
}
|
||||
|
||||
void TimeConstDelay::SetParameters(uint32_t samplingRate, float delay) {
|
||||
this->sampleCount = samplingRate * (uint32_t) ceil(delay);
|
||||
delete this->samples;
|
||||
this->sampleCount = (uint32_t) ((float) samplingRate * delay);
|
||||
delete[] this->samples;
|
||||
this->samples = new float[this->sampleCount]();
|
||||
this->offset = 0;
|
||||
}
|
||||
|
@ -5,13 +5,12 @@
|
||||
class TimeConstDelay {
|
||||
public:
|
||||
TimeConstDelay();
|
||||
|
||||
~TimeConstDelay();
|
||||
|
||||
float ProcessSample(float sample);
|
||||
|
||||
void SetParameters(uint32_t samplingRate, float delay);
|
||||
|
||||
private:
|
||||
float *samples;
|
||||
uint32_t offset;
|
||||
uint32_t sampleCount;
|
||||
|
@ -9,7 +9,7 @@ WaveBuffer::WaveBuffer(uint32_t channels, uint32_t size) {
|
||||
}
|
||||
|
||||
WaveBuffer::~WaveBuffer() {
|
||||
delete this->buffer;
|
||||
delete[] this->buffer;
|
||||
}
|
||||
|
||||
uint32_t WaveBuffer::GetBufferOffset() {
|
||||
@ -76,7 +76,7 @@ int WaveBuffer::PushSamples(float *source, uint32_t size) {
|
||||
if (this->size < requiredSize) {
|
||||
auto *buf = new float[requiredSize];
|
||||
memcpy(buf, this->buffer, this->index * sizeof(float));
|
||||
delete this->buffer;
|
||||
delete[] this->buffer;
|
||||
this->buffer = buf;
|
||||
this->size = requiredSize;
|
||||
}
|
||||
@ -97,7 +97,7 @@ int WaveBuffer::PushZeros(uint32_t size) {
|
||||
if (this->size < requiredSize) {
|
||||
auto *buf = new float[requiredSize];
|
||||
memcpy(buf, this->buffer, this->index * sizeof(float));
|
||||
delete this->buffer;
|
||||
delete[] this->buffer;
|
||||
this->buffer = buf;
|
||||
this->size = requiredSize;
|
||||
}
|
||||
@ -120,7 +120,7 @@ float *WaveBuffer::PushZerosGetBuffer(uint32_t size) {
|
||||
if (this->size < requiredSize) {
|
||||
auto *buf = new float[requiredSize];
|
||||
memcpy(buf, this->buffer, this->index * sizeof(float));
|
||||
delete this->buffer;
|
||||
delete[] this->buffer;
|
||||
this->buffer = buf;
|
||||
this->size = requiredSize;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user