Reformatted code

Indentated with 4 spaces
This commit is contained in:
Iscle 2022-08-23 00:26:44 +02:00
parent 7912b7deec
commit 926aec54bb
61 changed files with 703 additions and 518 deletions

View File

@ -43,12 +43,12 @@ int32_t Effect::process(audio_buffer_s *in, audio_buffer_s *out) {
}
int32_t Effect::command(uint32_t cmdCode, uint32_t cmdSize, void *pCmdData, uint32_t *replySize, void *pReplyData) {
switch(cmdCode) {
switch (cmdCode) {
case EFFECT_CMD_INIT:
case EFFECT_CMD_SET_CONFIG:
case EFFECT_CMD_SET_PARAM:
case EFFECT_CMD_SET_PARAM_COMMIT:
*((int*)pReplyData) = 0;
*((int *) pReplyData) = 0;
case EFFECT_CMD_RESET:
case EFFECT_CMD_SET_PARAM_DEFERRED:
case EFFECT_CMD_SET_DEVICE:
@ -58,7 +58,7 @@ int32_t Effect::command(uint32_t cmdCode, uint32_t cmdSize, void *pCmdData, uint
case EFFECT_CMD_SET_AUDIO_SOURCE:
break;
case EFFECT_CMD_SET_CONFIG_REVERSE:
*((int*)pReplyData) = -EINVAL;
*((int *) pReplyData) = -EINVAL;
default:
return -EINVAL;
case EFFECT_CMD_GET_CONFIG:
@ -79,7 +79,8 @@ int32_t Effect::configure(effect_config_t *newConfig) {
v4a_print(ANDROID_LOG_INFO, "Checking input and output configuration ...");
if (newConfig->inputCfg.samplingRate != newConfig->outputCfg.samplingRate) {
v4a_printf(ANDROID_LOG_ERROR, "ViPER4Android disabled, reason [in.SR = %d, out.SR = %d]", newConfig->inputCfg.samplingRate, newConfig->outputCfg.samplingRate);
v4a_printf(ANDROID_LOG_ERROR, "ViPER4Android disabled, reason [in.SR = %d, out.SR = %d]",
newConfig->inputCfg.samplingRate, newConfig->outputCfg.samplingRate);
DO_ERROR();
}
@ -89,7 +90,8 @@ int32_t Effect::configure(effect_config_t *newConfig) {
}
if (newConfig->inputCfg.channels != newConfig->outputCfg.channels) {
v4a_printf(ANDROID_LOG_ERROR, "ViPER4Android disabled, reason [in.CH = %d, out.CH = %d]", newConfig->inputCfg.channels, newConfig->outputCfg.channels);
v4a_printf(ANDROID_LOG_ERROR, "ViPER4Android disabled, reason [in.CH = %d, out.CH = %d]",
newConfig->inputCfg.channels, newConfig->outputCfg.channels);
DO_ERROR();
}

View File

@ -10,11 +10,14 @@
class Effect {
public:
Effect();
~Effect();
virtual int32_t command(uint32_t cmdCode, uint32_t cmdSize, void* pCmdData, uint32_t* replySize, void* pReplyData);
virtual int32_t command(uint32_t cmdCode, uint32_t cmdSize, void *pCmdData, uint32_t *replySize, void *pReplyData);
int32_t process(audio_buffer_s *in, audio_buffer_s *out);
int32_t configure(effect_config_t* config);
int32_t configure(effect_config_t *config);
bool enabled;
bool configureOk;
@ -23,7 +26,7 @@ public:
// Misc data here?
// TODO: Figure out what buffer is used for
float* buffer;
float *buffer;
uint32_t bufferSize;
void* instance; // type: ProcessUnit_FX
void *instance; // type: ProcessUnit_FX
};

View File

@ -15,7 +15,8 @@ ProcessUnit_FX::~ProcessUnit_FX() {
}
int32_t ProcessUnit_FX::command(uint32_t cmdCode, uint32_t cmdSize, void *pCmdData, uint32_t *replySize, void *pReplyData) {
int32_t
ProcessUnit_FX::command(uint32_t cmdCode, uint32_t cmdSize, void *pCmdData, uint32_t *replySize, void *pReplyData) {
// TODO
return -1;
}

View File

@ -20,38 +20,40 @@
class ProcessUnit_FX : public Effect {
public:
ProcessUnit_FX();
~ProcessUnit_FX();
int32_t command(uint32_t cmdCode, uint32_t cmdSize, void* pCmdData, uint32_t* replySize, void* pReplyData) override;
int32_t command(uint32_t cmdCode, uint32_t cmdSize, void *pCmdData, uint32_t *replySize, void *pReplyData) override;
void processBuffer(float* buffer, int frameSize);
void processBuffer(float *buffer, int frameSize);
// TODO: Parameter types/names
void DispatchCommand(int param_1, int param_2,int param_3, int param_4,int param_5, int param_6,int param_7);
void DispatchCommand(int param_1, int param_2, int param_3, int param_4, int param_5, int param_6, int param_7);
void ResetAllEffects();
bool init_ok, enabled, force_enabled, fetcomp_enabled;
FxMode mode;
// AdaptiveBuffer_F32* adaptiveBuffer;
WaveBuffer_I32* waveBuffer;
WaveBuffer_I32 *waveBuffer;
// Convolver* convolver;
VHE* vhe;
VHE *vhe;
// ViPERDDC* vddc;
SpectrumExtend* spectrumExtend;
SpectrumExtend *spectrumExtend;
// IIRFilter* iirfilter;
// ColorfulMusic* colm;
Reverberation* reverb;
Reverberation *reverb;
// PlaybackGain* playbackGain;
// FETCompressor* fetcomp;
DynamicSystem* dynsys;
DynamicSystem *dynsys;
// ViPERBass* bass;
ViPERClarity* clarity;
DiffSurround* diffSurround;
Cure* cure;
TubeSimulator* tube;
AnalogX* analogx;
SpeakerCorrection* speakerCorrection;
ViPERClarity *clarity;
DiffSurround *diffSurround;
Cure *cure;
TubeSimulator *tube;
AnalogX *analogx;
SpeakerCorrection *speakerCorrection;
// SoftwareLimiter* limiter[2];
int unk[3];

View File

@ -7,7 +7,9 @@
#ifdef ANDROID_TOOLCHAIN
#include <android/errno.h>
#else
#include <cerrno>
#endif
#include "log.h" // TODO: Remove this dependency

View File

@ -27,7 +27,7 @@ AnalogX::AnalogX() {
}
void AnalogX::Process(float *samples, uint32_t size) {
for (int i = 0; i < 2*size; i++) {
for (int i = 0; i < 2 * size; i++) {
float sample = samples[i];
int index = i % 2;
@ -47,11 +47,11 @@ void AnalogX::Process(float *samples, uint32_t size) {
}
void AnalogX::Reset() {
this->highpass[0].RefreshFilter(FilterType::HIGHPASS, 0.f, 240.f, (float)this->samplerate, 0.717, false);
this->highpass[1].RefreshFilter(FilterType::HIGHPASS, 0.f, 240.f, (float)this->samplerate, 0.717, false);
this->highpass[0].RefreshFilter(FilterType::HIGHPASS, 0.f, 240.f, (float) this->samplerate, 0.717, false);
this->highpass[1].RefreshFilter(FilterType::HIGHPASS, 0.f, 240.f, (float) this->samplerate, 0.717, false);
this->peak[0].RefreshFilter(FilterType::PEAK, 0.58f, 633.f, (float)this->samplerate, 6.28, true);
this->peak[1].RefreshFilter(FilterType::PEAK, 0.58f, 633.f, (float)this->samplerate, 6.28, true);
this->peak[0].RefreshFilter(FilterType::PEAK, 0.58f, 633.f, (float) this->samplerate, 6.28, true);
this->peak[1].RefreshFilter(FilterType::PEAK, 0.58f, 633.f, (float) this->samplerate, 6.28, true);
this->harmonics[0].Reset();
this->harmonics[1].Reset();
@ -60,20 +60,20 @@ void AnalogX::Reset() {
this->harmonics[0].SetHarmonics(ANALOGX_HARMONICS);
this->harmonics[1].SetHarmonics(ANALOGX_HARMONICS);
this->gain = 0.6f;
this->lowpass[0].RefreshFilter(FilterType::LOWPASS, 0.0, 18233.f, (float)this->samplerate, 0.717f, false);
this->lowpass[1].RefreshFilter(FilterType::LOWPASS, 0.0, 18233.f, (float)this->samplerate, 0.717f, false);
this->lowpass[0].RefreshFilter(FilterType::LOWPASS, 0.0, 18233.f, (float) this->samplerate, 0.717f, false);
this->lowpass[1].RefreshFilter(FilterType::LOWPASS, 0.0, 18233.f, (float) this->samplerate, 0.717f, false);
} else if (this->processingModel == 1) {
this->harmonics[0].SetHarmonics(ANALOGX_HARMONICS);
this->harmonics[1].SetHarmonics(ANALOGX_HARMONICS);
this->gain = 1.2f;
this->lowpass[0].RefreshFilter(FilterType::LOWPASS, 0.0, 19650.f, (float)this->samplerate, 0.717f, false);
this->lowpass[1].RefreshFilter(FilterType::LOWPASS, 0.0, 19650.f, (float)this->samplerate, 0.717f, false);
this->lowpass[0].RefreshFilter(FilterType::LOWPASS, 0.0, 19650.f, (float) this->samplerate, 0.717f, false);
this->lowpass[1].RefreshFilter(FilterType::LOWPASS, 0.0, 19650.f, (float) this->samplerate, 0.717f, false);
} else if (this->processingModel == 2) {
this->harmonics[0].SetHarmonics(ANALOGX_HARMONICS);
this->harmonics[1].SetHarmonics(ANALOGX_HARMONICS);
this->gain = 2.4f;
this->lowpass[0].RefreshFilter(FilterType::LOWPASS, 0.0, 16307.f, (float)this->samplerate, 0.717f, false);
this->lowpass[1].RefreshFilter(FilterType::LOWPASS, 0.0, 16307.f, (float)this->samplerate, 0.717f, false);
this->lowpass[0].RefreshFilter(FilterType::LOWPASS, 0.0, 16307.f, (float) this->samplerate, 0.717f, false);
this->lowpass[1].RefreshFilter(FilterType::LOWPASS, 0.0, 16307.f, (float) this->samplerate, 0.717f, false);
}
this->freqRange = 0;

View File

@ -12,10 +12,12 @@ class AnalogX {
public:
AnalogX();
void Process(float* samples, uint32_t size);
void Process(float *samples, uint32_t size);
void Reset();
void SetProcessingModel(int model);
void SetSamplingRate(uint32_t samplerate);
MultiBiquad highpass[2];

View File

@ -12,17 +12,26 @@ class Cure {
public:
Cure();
void Process(float* buffer, uint32_t size);
void Process(float *buffer, uint32_t size);
void Reset();
void SetEnable(bool enabled);
uint16_t GetCutoff();
float GetFeedback();
float GetLevelDelay();
preset_t GetPreset();
void SetCutoff(uint16_t cutoff);
void SetFeedback(float feedback);
void SetPreset(preset_t preset);
void SetSamplingRate(uint32_t samplerate);
Crossfeed crossfeed;

View File

@ -20,8 +20,8 @@ DiffSurround::~DiffSurround() {
}
void DiffSurround::Process(float *samples, uint32_t size) {
float* bufs[2];
float* outbufs[2];
float *bufs[2];
float *outbufs[2];
if (this->enabled) {
bufs[0] = this->buffers[0]->PushZerosGetBuffer(size);
@ -47,7 +47,7 @@ void DiffSurround::Reset() {
this->buffers[0]->Reset();
this->buffers[1]->Reset();
this->buffers[1]->PushZeros((uint32_t)(this->delayTime / 1000.f * (float)this->samplerate));
this->buffers[1]->PushZeros((uint32_t) (this->delayTime / 1000.f * (float) this->samplerate));
}
void DiffSurround::SetDelayTime(float value) {

View File

@ -11,19 +11,23 @@
class DiffSurround {
public:
DiffSurround();
~DiffSurround();
void Process(float* samples, uint32_t size);
void Process(float *samples, uint32_t size);
void Reset();
void SetDelayTime(float value);
void SetEnable(bool enabled);
void SetSamplingRate(uint32_t samplerate);
uint32_t samplerate;
bool enabled;
float delayTime;
WaveBuffer_I32* buffers[2];
WaveBuffer_I32 *buffers[2];
};

View File

@ -12,7 +12,7 @@ DynamicSystem::DynamicSystem() {
this->bass.Reset();
}
void DynamicSystem::Process(float* samples, uint32_t size) {
void DynamicSystem::Process(float *samples, uint32_t size) {
if (this->enabled) {
this->bass.FilterSamples(samples, size);
}

View File

@ -11,14 +11,20 @@ class DynamicSystem {
public:
DynamicSystem();
void Process(float* samples, uint32_t size);
void Process(float *samples, uint32_t size);
void Reset();
void SetBassGain(float gain);
void SetEnable(bool enable);
void SetSideGain(float gainX, float gainY);
void SetXCoeffs(uint32_t low, uint32_t high);
void SetYCoeffs(uint32_t low, uint32_t high);
void SetSamplingRate(uint32_t samplerate);
DynamicBass bass;

View File

@ -11,14 +11,21 @@ public:
Reverberation();
void Reset();
void Process(float* buffer, uint32_t size);
void Process(float *buffer, uint32_t size);
void SetEnable(bool enable);
void SetRoomSize(float value);
void SetDamp(float value);
void SetWet(float value);
void SetDry(float value);
void SetWidth(float value);
void SetSamplingRate(uint32_t value);
float roomsize;

View File

@ -28,8 +28,8 @@ void SpeakerCorrection::Reset() {
this->bandpass[0].Reset();
this->bandpass[1].Reset();
this->highpass[0].RefreshFilter(FilterType::HIGHPASS, 0.f, 80.f, (float)this->samplerate, 1.f, false);
this->highpass[1].RefreshFilter(FilterType::HIGHPASS, 0.f, 80.f, (float)this->samplerate, 1.f, false);
this->highpass[0].RefreshFilter(FilterType::HIGHPASS, 0.f, 80.f, (float) this->samplerate, 1.f, false);
this->highpass[1].RefreshFilter(FilterType::HIGHPASS, 0.f, 80.f, (float) this->samplerate, 1.f, false);
this->lowpass[0].SetLowPassParameter(13500.f, this->samplerate, 1.0);
this->lowpass[1].SetLowPassParameter(13500.f, this->samplerate, 1.0);
this->bandpass[0].SetBandPassParameter(420.f, this->samplerate, 3.88f);

View File

@ -11,10 +11,12 @@ class SpeakerCorrection {
public:
SpeakerCorrection();
void Process(float* samples, uint32_t size);
void Process(float *samples, uint32_t size);
void Reset();
void SetEnable(bool enabled);
void SetSamplingRate(uint32_t samplerate);
uint32_t samplerate;

View File

@ -42,11 +42,15 @@ void SpectrumExtend::Process(float *samples, uint32_t size) {
}
void SpectrumExtend::Reset() {
this->highpass[0].RefreshFilter(FilterType::HIGHPASS, 0.0, (float)this->referenceFreq, (float)this->samplerate, 0.717, false);
this->highpass[1].RefreshFilter(FilterType::HIGHPASS, 0.0, (float)this->referenceFreq, (float)this->samplerate, 0.717, false);
this->highpass[0].RefreshFilter(FilterType::HIGHPASS, 0.0, (float) this->referenceFreq, (float) this->samplerate,
0.717, false);
this->highpass[1].RefreshFilter(FilterType::HIGHPASS, 0.0, (float) this->referenceFreq, (float) this->samplerate,
0.717, false);
this->lowpass[0].RefreshFilter(FilterType::LOWPASS, 0.0, (float)this->referenceFreq / 2.f - 2000.f, (float)this->referenceFreq, 0.717, false);
this->lowpass[1].RefreshFilter(FilterType::LOWPASS, 0.0, (float)this->referenceFreq / 2.f - 2000.f, (float)this->referenceFreq, 0.717, false);
this->lowpass[0].RefreshFilter(FilterType::LOWPASS, 0.0, (float) this->referenceFreq / 2.f - 2000.f,
(float) this->referenceFreq, 0.717, false);
this->lowpass[1].RefreshFilter(FilterType::LOWPASS, 0.0, (float) this->referenceFreq / 2.f - 2000.f,
(float) this->referenceFreq, 0.717, false);
this->harmonics[0].Reset();
this->harmonics[1].Reset();

View File

@ -11,13 +11,19 @@
class SpectrumExtend {
public:
SpectrumExtend();
~SpectrumExtend();
void Process(float* samples, uint32_t size);
void Process(float *samples, uint32_t size);
void Reset();
void SetEnable(bool enable);
void SetExciter(float value);
void SetReferenceFrequency(uint32_t freq);
void SetSamplingRate(uint32_t samplerate);
MultiBiquad highpass[2];

View File

@ -19,10 +19,10 @@ void TubeSimulator::Reset() {
void TubeSimulator::TubeProcess(float *buffer, uint32_t size) {
if (this->enabled && size > 0) {
for (int x = 0; x < size; x++) {
this->acc[0] = (this->acc[0] + buffer[2*x]) / 2.f;
this->acc[1] = (this->acc[1] + buffer[2*x+1]) / 2.f;
buffer[2*x] = this->acc[0];
buffer[2*x+1] = this->acc[1];
this->acc[0] = (this->acc[0] + buffer[2 * x]) / 2.f;
this->acc[1] = (this->acc[1] + buffer[2 * x + 1]) / 2.f;
buffer[2 * x] = this->acc[0];
buffer[2 * x + 1] = this->acc[1];
}
}
}

View File

@ -11,7 +11,8 @@ public:
TubeSimulator();
void Reset();
void TubeProcess(float* buffer, uint32_t size);
void TubeProcess(float *buffer, uint32_t size);
float acc[2];
bool enabled;

View File

@ -11,14 +11,19 @@
class VHE {
public:
VHE();
~VHE();
void Process(float* source, float* dest, int frameSize);
void Process(float *source, float *dest, int frameSize);
void Reset();
bool GetEnabled();
void SetEffectLevel(uint32_t level);
void SetEnable(bool enabled);
void SetSamplingRate(uint32_t srate);
PConvSingle_F32 convLeft, convRight;

View File

@ -19,13 +19,18 @@ class ViPERClarity {
public:
ViPERClarity();
void Process(float* samples, uint32_t size);
void Process(float *samples, uint32_t size);
void Reset();
void SetClarity(float gainPercent);
void SetClarityToFilter();
void SetEnable(bool enabled);
void SetProcessMode(ClarityMode mode);
void SetSamplingRate(uint32_t samplerate);
NoiseSharpening sharp;

View File

@ -11,13 +11,16 @@ public:
CAllpassFilter();
void Mute();
float Process(float sample);
float GetFeedback();
void SetBuffer(float* buffer, uint32_t size);
void SetBuffer(float *buffer, uint32_t size);
void SetFeedback(float feedback);
float* buffer;
float *buffer;
uint32_t bufidx;
uint32_t bufsize;
float feedback;

View File

@ -11,19 +11,24 @@ public:
CCombFilter();
float Process(float sample);
void Mute();
float GetDamp();
float GetFeedback();
void SetDamp(float damp);
void SetFeedback(float feedback);
void SetBuffer(float* buffer, uint32_t size);
void SetBuffer(float *buffer, uint32_t size);
float feedback;
float filterstore;
float damp;
float damp2;
float* buffer;
float *buffer;
uint32_t size;
uint32_t bufidx;
};

View File

@ -85,11 +85,11 @@ void CRevModel::Mute() {
return;
}
for (int i=0; i<8; i++) {
for (int i = 0; i < 8; i++) {
combL[i].Mute();
combR[i].Mute();
}
for (int i=0; i<4; i++) {
for (int i = 0; i < 4; i++) {
allpassL[i].Mute();
allpassR[i].Mute();
}
@ -101,18 +101,18 @@ void CRevModel::ProcessReplace(float *bufL, float *bufR, uint32_t size) {
float outR = 0.f;
float input = (*bufL + *bufR) * gain;
for (int i=0; i<8; i++) {
for (int i = 0; i < 8; i++) {
outL += combL[i].Process(input);
outR += combR[i].Process(input);
}
for (int i=0; i<4; i++) {
for (int i = 0; i < 4; i++) {
outL = allpassL[i].Process(outL);
outR = allpassR[i].Process(outR);
}
*bufL = outL*wet1 + outR*wet2 + *bufL * dry;
*bufR = outR*wet1 + outL*wet2 + *bufR * dry;
*bufL = outL * wet1 + outR * wet2 + *bufL * dry;
*bufR = outR * wet1 + outL * wet2 + *bufR * dry;
bufL += 1;
bufR += 1;
@ -120,8 +120,8 @@ void CRevModel::ProcessReplace(float *bufL, float *bufR, uint32_t size) {
}
void CRevModel::UpdateCoeffs() {
wet1 = wet*(width/2.f + 0.5f);
wet2 = wet*((1.f-width)/2.f);
wet1 = wet * (width / 2.f + 0.5f);
wet2 = wet * ((1.f - width) / 2.f);
if (mode == 1) {
roomsize1 = 1.f;
@ -133,46 +133,46 @@ void CRevModel::UpdateCoeffs() {
gain = 0.015f;
}
for (int i=0; i<8; i++) {
for (int i = 0; i < 8; i++) {
combL[i].SetFeedback(roomsize1);
combR[i].SetFeedback(roomsize1);
}
for(int i=0; i<8; i++) {
for (int i = 0; i < 8; i++) {
combL[i].SetDamp(damp1);
combR[i].SetDamp(damp1);
}
}
void CRevModel::Reset() {
for (int i=0; i<8; i++) {
for (int i = 0; i < 8; i++) {
combL[i].Mute();
combR[i].Mute();
}
for(int i=0; i<4; i++) {
for (int i = 0; i < 4; i++) {
allpassL[i].Mute();
allpassR[i].Mute();
}
}
void CRevModel::SetRoomSize(float value) {
roomsize = (value*0.28f) + 0.7f;
roomsize = (value * 0.28f) + 0.7f;
UpdateCoeffs();
}
void CRevModel::SetDamp(float value) {
damp = value*0.4f;
damp = value * 0.4f;
UpdateCoeffs();
}
void CRevModel::SetWet(float value) {
wet = value*3.f;
wet = value * 3.f;
UpdateCoeffs();
}
void CRevModel::SetDry(float value) {
dry = value*2.f;
dry = value * 2.f;
}
void CRevModel::SetWidth(float value) {
@ -186,19 +186,19 @@ void CRevModel::SetMode(int value) {
}
float CRevModel::GetRoomSize() {
return (roomsize-0.7f)/0.28f;
return (roomsize - 0.7f) / 0.28f;
}
float CRevModel::GetDamp() {
return damp/0.4f;
return damp / 0.4f;
}
float CRevModel::GetWet() {
return wet/3.f;
return wet / 3.f;
}
float CRevModel::GetDry() {
return dry/2.f;
return dry / 2.f;
}
float CRevModel::GetWidth() {

View File

@ -10,24 +10,39 @@
class CRevModel {
public:
CRevModel();
~CRevModel();
void Mute();
void ProcessReplace(float *bufL, float *bufR, uint32_t size);
void UpdateCoeffs();
void Reset();
void SetRoomSize(float value);
void SetDamp(float value);
void SetWet(float value);
void SetDry(float value);
void SetWidth(float value);
void SetMode(int value);
float GetRoomSize();
float GetDamp();
float GetWet();
float GetDry();
float GetWidth();
int GetMode();
float gain;
@ -48,7 +63,7 @@ public:
CAllpassFilter allpassL[4];
CAllpassFilter allpassR[4];
float* buffers[24];
float *buffers[24];
};

View File

@ -16,7 +16,7 @@ Crossfeed::Crossfeed() {
this->a1_hi = 0.f;
this->b1_hi = 0.f;
this->gain = 0.f;
memset(&this->lfs, 0, 6*sizeof(float));
memset(&this->lfs, 0, 6 * sizeof(float));
this->samplerate = DEFAULT_SAMPLERATE;
this->preset.cutoff = 700;
this->preset.feedback = 45;
@ -31,31 +31,32 @@ void Crossfeed::Reset() {
double GB_lo = level * -5.0 / 6.0 - 3.0;
double GB_hi = level / 6.0 - 3.0;
double G_lo = pow( 10, GB_lo / 20.0 );
double G_hi = 1.0 - pow( 10, GB_hi / 20.0 );
double Fc_hi = cutoff * pow( 2.0, ( GB_lo - 20.0 * log10( G_hi ) ) / 12.0 );
double G_lo = pow(10, GB_lo / 20.0);
double G_hi = 1.0 - pow(10, GB_hi / 20.0);
double Fc_hi = cutoff * pow(2.0, (GB_lo - 20.0 * log10(G_hi)) / 12.0);
double x = exp( -2.0 * M_PI * cutoff / this->samplerate );
this->b1_lo = (float)x;
this->a0_lo = (float)(G_lo * ( 1.0 - x ));
double x = exp(-2.0 * M_PI * cutoff / this->samplerate);
this->b1_lo = (float) x;
this->a0_lo = (float) (G_lo * (1.0 - x));
x = exp( -2.0 * M_PI * Fc_hi / this->samplerate );
this->b1_hi = (float)x;
this->a0_hi = (float)(1.0 - G_hi * ( 1.0 - x ));
this->a1_hi = (float)-x;
x = exp(-2.0 * M_PI * Fc_hi / this->samplerate);
this->b1_hi = (float) x;
this->a0_hi = (float) (1.0 - G_hi * (1.0 - x));
this->a1_hi = (float) -x;
this->gain = (float)(1.0 / ( 1.0 - G_hi + G_lo ));
memset(&this->lfs, 0, 6*sizeof(float));
this->gain = (float) (1.0 / (1.0 - G_hi + G_lo));
memset(&this->lfs, 0, 6 * sizeof(float));
}
void Crossfeed::ProcessFrames(float* buffer, uint32_t size) {
for (int x = 0; x < size; x+=2) {
void Crossfeed::ProcessFrames(float *buffer, uint32_t size) {
for (int x = 0; x < size; x += 2) {
FilterSample(&buffer[x]);
}
}
#define lo_filter(in, out_1) (this->a0_lo * (in) + this->b1_lo * (out_1))
#define hi_filter(in, in_1, out_1) (this->a0_hi * (in) + this->a1_hi * (in_1) + this->b1_hi * (out_1))
void Crossfeed::FilterSample(float *sample) {
this->lfs.lo[0] = lo_filter(sample[0], this->lfs.lo[0]);
this->lfs.lo[1] = lo_filter(sample[1], this->lfs.lo[1]);
@ -74,12 +75,12 @@ uint16_t Crossfeed::GetCutoff() {
}
float Crossfeed::GetFeedback() {
return (float)this->preset.feedback / 10.f;
return (float) this->preset.feedback / 10.f;
}
float Crossfeed::GetLevelDelay() {
if (this->preset.cutoff <= 1800) {
return (18700.f / (float)this->preset.cutoff) * 10.f;
return (18700.f / (float) this->preset.cutoff) * 10.f;
} else {
return 0.f;
}
@ -95,7 +96,7 @@ void Crossfeed::SetCutoff(uint16_t cutoff) {
}
void Crossfeed::SetFeedback(float feedback) {
this->preset.feedback = (uint16_t)(feedback * 10);
this->preset.feedback = (uint16_t) (feedback * 10);
Reset();
}

View File

@ -17,16 +17,25 @@ public:
Crossfeed();
void Reset();
void ProcessFrames(float* buffer, uint32_t size);
void FilterSample(float* sample);
void ProcessFrames(float *buffer, uint32_t size);
void FilterSample(float *sample);
uint16_t GetCutoff();
float GetFeedback();
float GetLevelDelay();
preset_t GetPreset();
void SetCutoff(uint16_t cutoff);
void SetFeedback(float feedback);
void SetPreset(preset_t preset);
void SetSamplingRate(uint32_t samplerate);
uint32_t samplerate;

View File

@ -21,8 +21,8 @@ void DepthSurround::Process(float *samples, uint32_t size) {
if (this->enabled) {
if (!this->strengthAtLeast500) {
for (int i = 0; i < size; i++) {
float sampleLeft = samples[2*i];
float sampleRight = samples[2*i+1];
float sampleLeft = samples[2 * i];
float sampleRight = samples[2 * i + 1];
this->prev[0] = this->gain * this->delay[0].ProcessSample(sampleLeft + this->prev[1]);
this->prev[1] = this->gain * this->delay[1].ProcessSample(sampleRight + this->prev[0]);
@ -33,13 +33,13 @@ void DepthSurround::Process(float *samples, uint32_t size) {
float diff = (l - r) / 2.f;
float avg = (l + r) / 2.f;
float avgOut = this->highpass.ProcessSample(diff);
samples[2*i] = avg + (diff - avgOut);
samples[2*i+1] = avg - (diff - avgOut);
samples[2 * i] = avg + (diff - avgOut);
samples[2 * i + 1] = avg - (diff - avgOut);
}
} else {
for (int i = 0; i < size; i++) {
float sampleLeft = samples[2*i];
float sampleRight = samples[2*i+1];
float sampleLeft = samples[2 * i];
float sampleRight = samples[2 * i + 1];
this->prev[0] = this->gain * this->delay[0].ProcessSample(sampleLeft + this->prev[1]);
this->prev[1] = -this->gain * this->delay[1].ProcessSample(sampleRight + this->prev[0]);
@ -50,8 +50,8 @@ void DepthSurround::Process(float *samples, uint32_t size) {
float diff = (l - r) / 2.f;
float avg = (l + r) / 2.f;
float avgOut = this->highpass.ProcessSample(diff);
samples[2*i] = avg + (diff - avgOut);
samples[2*i+1] = avg - (diff - avgOut);
samples[2 * i] = avg + (diff - avgOut);
samples[2 * i + 1] = avg - (diff - avgOut);
}
}
}
@ -61,7 +61,7 @@ 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);
float _gain = powf(10.f, ((strength / 1000.f) * 10.f - 15.f) / 20.f);
if (fabsf(_gain) > 1.f) {
_gain = 1.f;
}

View File

@ -13,9 +13,12 @@ class DepthSurround {
public:
DepthSurround();
void Process(float* samples, uint32_t size);
void Process(float *samples, uint32_t size);
void RefreshStrength(short strength);
void SetSamplingRate(uint32_t samplerate);
void SetStrength(short strength);
short strength;

View File

@ -14,7 +14,7 @@ DynamicBass::DynamicBass() {
this->lowFreqX = 120;
this->highFreqX = 80;
this->lowFreqY = 40;
this->highFreqY = (float)this->samplerate / 4.f;
this->highFreqY = (float) this->samplerate / 4.f;
this->filterX.SetPassFilter(this->lowFreqX, this->highFreqX);
this->filterY.SetPassFilter(this->lowFreqY, this->highFreqY);
@ -30,23 +30,23 @@ void DynamicBass::Reset() {
void DynamicBass::FilterSamples(float *samples, uint32_t size) {
if (this->lowFreqX <= 120) {
for (int i = 0; i < size; i++) {
float left = samples[2*i];
float right = samples[2*i+1];
float left = samples[2 * i];
float right = samples[2 * i + 1];
float avg = this->lowPass.ProcessSample(left + right);
samples[2*i] = left + avg;
samples[2*i+1] = right + avg;
samples[2 * i] = left + avg;
samples[2 * i + 1] = right + avg;
}
} else {
for (int i = 0; i < size; i++) {
float x1, x2, x3, x4, x5, x6, y1, y2, y3, y4, y5, y6;
this->filterX.DoFilterLeft(samples[2*i], &x1, &x2, &x3);
this->filterX.DoFilterRight(samples[2*i+1], &x4, &x5, &x6);
this->filterX.DoFilterLeft(samples[2 * i], &x1, &x2, &x3);
this->filterX.DoFilterRight(samples[2 * i + 1], &x4, &x5, &x6);
this->filterY.DoFilterLeft(this->bassGain * x1, &y1, &y2, &y3);
this->filterY.DoFilterRight(this->bassGain * x4, &y4, &y5, &y6);
samples[2*i] = x2 + y3 + this->sideGainX * y2 + this->sideGainY * y1 + x3;
samples[2*i+1] = x5 + y6 + this->sideGainX * y5 + this->sideGainY * y4 + x6;
samples[2 * i] = x2 + y3 + this->sideGainX * y2 + this->sideGainY * y1 + x3;
samples[2 * i + 1] = x5 + y6 + this->sideGainX * y5 + this->sideGainY * y4 + x6;
}
}
}

View File

@ -12,12 +12,18 @@ class DynamicBass {
public:
DynamicBass();
void FilterSamples(float* samples, uint32_t size);
void FilterSamples(float *samples, uint32_t size);
void Reset();
void SetBassGain(float gain);
void SetFilterXPassFrequency(uint32_t low, uint32_t high);
void SetFilterYPassFrequency(uint32_t low, uint32_t high);
void SetSamplingRate(uint32_t samplerate);
void SetSideGain(float gainX, float gainY);
uint32_t lowFreqX, highFreqX;

View File

@ -11,7 +11,8 @@ FixedBiquad::FixedBiquad() {
}
float FixedBiquad::ProcessSample(float sample) {
float out = sample * this->b0 + this->x_1 * this->b1 + this->x_2 * this->b2 + this->y_1 * this->a1 + this->y_2 * this->a2;
float out = sample * this->b0 + this->x_1 * this->b1 + this->x_2 * this->b2 + this->y_1 * this->a1 +
this->y_2 * this->a2;
this->y_2 = this->y_1;
this->y_1 = out;
this->x_2 = this->x_1;
@ -44,16 +45,17 @@ void FixedBiquad::SetCoeffs(float a0, float a1, float a2, float b0, float b1, fl
}
void FixedBiquad::SetBandPassParameter(float frequency, uint32_t samplerate, float qFactor) {
float x = (2.f * frequency * (float)M_PI / (float)samplerate);
float x = (2.f * frequency * (float) M_PI / (float) samplerate);
float sinX = sinf(x);
float cosX = cosf(x);
float y = x / (2.f * qFactor);
SetCoeffs(y + 1.f, -2.f * cosX, 1.f - y, sinX / 2.f, 0.f, -sinX / 2.f);
}
void FixedBiquad::SetHighPassParameter(float frequency, uint32_t samplerate, float param_4, float qFactor, float param_6) {
void
FixedBiquad::SetHighPassParameter(float frequency, uint32_t samplerate, float param_4, float qFactor, float param_6) {
// TODO: Cleanup and named params
float fVar12 = (frequency * 2.f * (float)M_PI) / (float)samplerate;
float fVar12 = (frequency * 2.f * (float) M_PI) / (float) samplerate;
float x = powf(10.f, param_4 / 40.f);
float fVar5 = (1.f / x + x) * (1.f / qFactor - 1.f) + 2.f;
float fVar7 = sqrtf(x);
@ -63,7 +65,7 @@ void FixedBiquad::SetHighPassParameter(float frequency, uint32_t samplerate, flo
fVar5 = cosf(fVar12);
fVar12 = fVar10 + fVar8 * fVar5;
float fVar11 = fVar10 - fVar8 * fVar5;
float fVar2 = powf(10.f,param_6 / 20.f);
float fVar2 = powf(10.f, param_6 / 20.f);
float fVar9 = fVar8 - fVar10 * fVar5;
SetCoeffs(fVar11 + (fVar7 + fVar7) * fVar6,
fVar9 + fVar9,
@ -74,7 +76,7 @@ void FixedBiquad::SetHighPassParameter(float frequency, uint32_t samplerate, flo
}
void FixedBiquad::SetLowPassParameter(float frequency, uint32_t samplerate, float qFactor) {
float x = (frequency * 2.f * (float)M_PI) / (float)samplerate;
float x = (frequency * 2.f * (float) M_PI) / (float) samplerate;
float sinX = sinf(x);
float y = sinX / (qFactor * 2.f);
float cosX = cosf(x);

View File

@ -12,10 +12,15 @@ public:
FixedBiquad();
float ProcessSample(float sample);
void Reset();
void SetCoeffs(float a0, float a1, float a2, float b0, float b1, float b2);
void SetBandPassParameter(float frequency, uint32_t samplerate, float qFactor);
void SetHighPassParameter(float frequency, uint32_t samplerate, float param_4, float qFactor, float param_6);
void SetLowPassParameter(float frequency, uint32_t samplerate, float qFactor);

View File

@ -70,7 +70,7 @@ void Harmonic::UpdateCoeffs(float *coefficients) {
float afStack76[14];
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));
fVar6 = 1.f / (
@ -98,7 +98,7 @@ void Harmonic::UpdateCoeffs(float *coefficients) {
_coeffs[11] = _coeffs[10];
fVar6 = _coeffs[11];
for (int i = 2; i < 11; i++) {
for(int idx = 0; idx < i; idx++) {
for (int idx = 0; idx < i; idx++) {
_coeffs[11] = fVar6;
fVar5 = _coeffs[10 - idx + i];
fVar6 = afStack76[2 - idx + i];
@ -116,6 +116,6 @@ void Harmonic::UpdateCoeffs(float *coefficients) {
_coeffs[11] = _coeffs[0] * 0.5f - _coeffs[11];
for (int i = 0; i < 11; i++) {
this->coeffs[i] = _coeffs[11+i];
this->coeffs[i] = _coeffs[11 + i];
}
}

View File

@ -10,13 +10,16 @@
class Harmonic {
public:
Harmonic();
~Harmonic();
float Process(float sample);
void Reset();
void SetHarmonics(float* coeffs);
void UpdateCoeffs(float* coeffs);
void SetHarmonics(float *coeffs);
void UpdateCoeffs(float *coeffs);
float coeffs[11];
float lastProcessed;

View File

@ -28,14 +28,14 @@ HiFi::~HiFi() {
void HiFi::Process(float *samples, uint32_t size) {
if (size > 0) {
float* bpBuf = this->buffers[0]->PushZerosGetBuffer(size);
float* lpBuf = this->buffers[1]->PushZerosGetBuffer(size);
float *bpBuf = this->buffers[0]->PushZerosGetBuffer(size);
float *lpBuf = this->buffers[1]->PushZerosGetBuffer(size);
if (bpBuf == nullptr || lpBuf == nullptr) {
Reset();
return;
}
for (int i = 0; i < size*2; i++) {
for (int i = 0; i < size * 2; i++) {
int index = i % 2;
float out1 = do_filter_lh(this->filters[index].lowpass, samples[i]);
float out2 = do_filter_lh(this->filters[index].highpass, samples[i]);
@ -44,8 +44,8 @@ void HiFi::Process(float *samples, uint32_t size) {
lpBuf[i] = out1;
bpBuf[i] = out3;
}
float* bpOut = this->buffers[0]->GetCurrentBufferI32Ptr();
float* lpOut = this->buffers[1]->GetCurrentBufferI32Ptr();
float *bpOut = this->buffers[0]->GetCurrentBufferI32Ptr();
float *lpOut = this->buffers[1]->GetCurrentBufferI32Ptr();
for (int i = 0; i < size * 2; i++) {
float hp = samples[i] * this->gain * 1.2f;
float bp = bpOut[i] * this->gain;
@ -66,9 +66,9 @@ void HiFi::Reset() {
this->filters[i].bandpass->Mute();
}
this->buffers[0]->Reset();
this->buffers[0]->PushZeros(this->samplerate/400);
this->buffers[0]->PushZeros(this->samplerate / 400);
this->buffers[1]->Reset();
this->buffers[1]->PushZeros(this->samplerate/200);
this->buffers[1]->PushZeros(this->samplerate / 200);
}

View File

@ -12,19 +12,22 @@
class HiFi {
public:
HiFi();
~HiFi();
void Process(float* samples, uint32_t size);
void Process(float *samples, uint32_t size);
void Reset();
void SetClarity(float value);
void SetSamplingRate(uint32_t samplerate);
WaveBuffer_I32* buffers[2];
WaveBuffer_I32 *buffers[2];
struct {
IIR_NOrder_BW_LH* lowpass;
IIR_NOrder_BW_LH* highpass;
IIR_NOrder_BW_BP* bandpass;
IIR_NOrder_BW_LH *lowpass;
IIR_NOrder_BW_LH *highpass;
IIR_NOrder_BW_BP *bandpass;
} filters[2];
float gain;
uint32_t samplerate;

View File

@ -6,7 +6,8 @@
#include "HighShelf.h"
float HighShelf::Process(float sample) {
float out = sample * this->b0 + this->x_1 * this->b1 + this->x_2 * this->b2 + this->y_1 * this->a1 + this->y_2 * this->a2;
float out = sample * this->b0 + this->x_1 * this->b1 + this->x_2 * this->b2 + this->y_1 * this->a1 +
this->y_2 * this->a2;
this->y_2 = this->y_1;
this->y_1 = out;
this->x_2 = this->x_1;

View File

@ -3,6 +3,7 @@
//
#pragma once
#include <cstdint>
class HighShelf {
@ -10,8 +11,11 @@ public:
float Process(float sample);
void SetFrequency(uint32_t freq);
void SetGain(float gain);
void SetQuality(float q);
void SetSamplingRate(uint32_t samplerate);
uint32_t frequency, samplerate;

View File

@ -32,7 +32,7 @@ void IIR_1st::SetCoefficients(float b0, float b1, float a1) {
void IIR_1st::setHPF_A(float frequency, uint32_t samplerate) {
this->a1 = angle(frequency, samplerate);
float norm = (1+a1)/2.f;
float norm = (1 + a1) / 2.f;
this->b0 = norm;
this->b1 = -norm;
}
@ -40,22 +40,22 @@ void IIR_1st::setHPF_A(float frequency, uint32_t samplerate) {
void IIR_1st::setHPF_BW(float frequency, uint32_t samplerate) {
float omega_2 = omega_2();
float tan_omega_2 = tanf(omega_2);
this->b0 = 1/(1+tan_omega_2);
this->b0 = 1 / (1 + tan_omega_2);
this->b1 = -this->b0;
this->a1 = (1-tan_omega_2)/(1+tan_omega_2);
this->a1 = (1 - tan_omega_2) / (1 + tan_omega_2);
}
void IIR_1st::setHPF_C(float frequency, uint32_t samplerate) {
this->b0 = (float)samplerate/((float)samplerate+frequency);
this->b0 = (float) samplerate / ((float) samplerate + frequency);
this->b1 = -1 * this->b0;
this->a1 = ((float)samplerate-frequency)/((float)samplerate+frequency);
this->a1 = ((float) samplerate - frequency) / ((float) samplerate + frequency);
}
void IIR_1st::setHPFwLPS_A(float frequency, uint32_t samplerate) {
this->a1 = -0.12f;
this->b0 = -1.f;
this->b1 = angle(frequency, samplerate);
float norm = (1-this->a1) / fabsf(this->b0 + this->b1);
float norm = (1 - this->a1) / fabsf(this->b0 + this->b1);
this->b0 *= norm;
this->b1 *= norm;;
}
@ -64,7 +64,7 @@ void IIR_1st::setHSF_A(float f1, float f2, uint32_t samplerate) {
this->a1 = angle(f1, samplerate);
this->b0 = -1.f;
this->b1 = angle(f2, samplerate);
float norm = (1-this->a1)/(this->b0 + this->b1);
float norm = (1 - this->a1) / (this->b0 + this->b1);
this->b0 *= norm;
this->b1 *= norm;
}
@ -73,7 +73,7 @@ void IIR_1st::setLPF_A(float frequency, uint32_t samplerate) {
this->a1 = angle(frequency, samplerate);
this->b0 = 1.f;
this->b1 = 0.12f;
float norm = (1+this->a1)/(this->b0 + this->b1);
float norm = (1 + this->a1) / (this->b0 + this->b1);
this->b0 *= norm;
this->b1 *= norm;
}
@ -81,15 +81,15 @@ void IIR_1st::setLPF_A(float frequency, uint32_t samplerate) {
void IIR_1st::setLPF_BW(float frequency, uint32_t samplerate) {
float omega_2 = omega_2();
float tan_omega_2 = tanf(omega_2);
this->a1 = (1-tan_omega_2)/(1+tan_omega_2);
this->b0 = tan_omega_2/(1+tan_omega_2);
this->a1 = (1 - tan_omega_2) / (1 + tan_omega_2);
this->b0 = tan_omega_2 / (1 + tan_omega_2);
this->b1 = this->b0;
}
void IIR_1st::setLPF_C(float frequency, uint32_t samplerate) {
this->b0 = frequency/((float)samplerate+frequency);
this->b0 = frequency / ((float) samplerate + frequency);
this->b1 = this->b0;
this->a1 = ((float)samplerate-frequency)/((float)samplerate+frequency);
this->a1 = ((float) samplerate - frequency) / ((float) samplerate + frequency);
}
void IIR_1st::setLSF_A(float f1, float f2, uint32_t samplerate) {
@ -100,7 +100,7 @@ void IIR_1st::setLSF_A(float f1, float f2, uint32_t samplerate) {
void IIR_1st::setPole(float a1) {
this->a1 = a1;
this->b0 = 1.f-fabsf(a1);
this->b0 = 1.f - fabsf(a1);
this->b1 = 0.f;
}
@ -108,7 +108,7 @@ void IIR_1st::setPoleHPF(float frequency, uint32_t samplerate) {
float omega = omega();
float cos_omega = cosf(omega);
float tmp = (2.f + cos_omega);
float coeff = tmp-sqrtf(tmp*tmp-1.f);
float coeff = tmp - sqrtf(tmp * tmp - 1.f);
this->a1 = -coeff;
this->b0 = 1.f - coeff;
this->b1 = 0;
@ -118,7 +118,7 @@ void IIR_1st::setPoleLPF(float frequency, uint32_t samplerate) {
float omega = omega();
float cos_omega = cosf(omega);
float tmp = (2.f - cos_omega);
float coeff = tmp-sqrtf(tmp*tmp-1.f);
float coeff = tmp - sqrtf(tmp * tmp - 1.f);
this->a1 = coeff;
this->b0 = 1.f - coeff;
this->b1 = 0.f;
@ -137,18 +137,18 @@ void IIR_1st::setZeroHPF(float frequency, uint32_t samplerate) {
float omega = omega();
float cos_omega = cosf(omega);
float tmp = (1.f - 2.f * cos_omega);
float coeff = tmp-sqrtf(tmp*tmp-1.f);
float coeff = tmp - sqrtf(tmp * tmp - 1.f);
this->a1 = 0.f;
this->b0 = 1.f/(1.f+coeff);
this->b1 = -coeff/(1.f+coeff);
this->b0 = 1.f / (1.f + coeff);
this->b1 = -coeff / (1.f + coeff);
}
void IIR_1st::setZeroLPF(float frequency, uint32_t samplerate) {
float omega = omega();
float cos_omega = cosf(omega);
float tmp = (1.f + 2.f * cos_omega);
float coeff = tmp-sqrtf(tmp*tmp-1.f);
float coeff = tmp - sqrtf(tmp * tmp - 1.f);
this->a1 = 0.f;
this->b0 = 1.f/(1.f+coeff);
this->b1 = coeff/(1.f+coeff);
this->b0 = 1.f / (1.f + coeff);
this->b1 = coeff / (1.f + coeff);
}

View File

@ -3,6 +3,7 @@
//
#pragma once
#include <cstdint>
class IIR_1st {
@ -10,28 +11,44 @@ public:
IIR_1st();
void Mute();
void SetCoefficients(float b0, float b1, float a1);
void setHPF_A(float frequency, uint32_t samplerate);
void setHPF_BW(float frequency, uint32_t samplerate);
void setHPF_C(float frequency, uint32_t samplerate);
void setHPFwLPS_A(float frequency, uint32_t samplerate);
void setHSF_A(float f1, float f2, uint32_t samplerate);
void setLPF_A(float frequency, uint32_t samplerate);
void setLPF_BW(float frequency, uint32_t samplerate);
void setLPF_C(float frequency, uint32_t samplerate);
void setLSF_A(float f1, float f2, uint32_t samplerate);
void setPole(float a1);
void setPoleHPF(float frequency, uint32_t samplerate);
void setPoleLPF(float frequency, uint32_t samplerate);
void setZero(float b1);
void setZeroHPF(float frequency, uint32_t samplerate);
void setZeroLPF(float frequency, uint32_t samplerate);
float b0, b1, a1;
float prevSample;
};
inline float do_filter(IIR_1st* filter, float sample) {
inline float do_filter(IIR_1st *filter, float sample) {
float hist = sample * filter->b1;
sample = filter->prevSample + sample * filter->b0;
filter->prevSample = sample * filter->a1 + hist;

View File

@ -9,30 +9,32 @@
class IIR_NOrder_BW_BP {
public:
explicit IIR_NOrder_BW_BP(uint32_t order);
~IIR_NOrder_BW_BP();
void Mute();
void setBPF(float highCut, float lowCut, uint32_t samplerate);
IIR_1st* lowpass;
IIR_1st* highpass;
IIR_1st *lowpass;
IIR_1st *highpass;
uint32_t order;
};
inline float do_filter_bplp(IIR_NOrder_BW_BP* filt, float sample) {
inline float do_filter_bplp(IIR_NOrder_BW_BP *filt, float sample) {
for (int idx = 0; idx < filt->order; idx++) {
sample = do_filter(&filt->lowpass[idx], sample);
}
return sample;
}
inline float do_filter_bphp(IIR_NOrder_BW_BP* filt, float sample) {
inline float do_filter_bphp(IIR_NOrder_BW_BP *filt, float sample) {
for (int idx = 0; idx < filt->order; idx++) {
sample = do_filter(&filt->highpass[idx], sample);
}
return sample;
}
inline float do_filter_bp(IIR_NOrder_BW_BP* filt, float sample) {
inline float do_filter_bp(IIR_NOrder_BW_BP *filt, float sample) {
return do_filter_bphp(filt, do_filter_bplp(filt, sample));
}

View File

@ -9,17 +9,20 @@
class IIR_NOrder_BW_LH {
public:
explicit IIR_NOrder_BW_LH(uint32_t order);
~IIR_NOrder_BW_LH();
void Mute();
void setLPF(float frequency, uint32_t samplerate);
void setHPF(float frequency, uint32_t samplerate);
IIR_1st* filters;
IIR_1st *filters;
uint32_t order;
};
inline float do_filter_lh(IIR_NOrder_BW_LH* filt, float sample) {
inline float do_filter_lh(IIR_NOrder_BW_LH *filt, float sample) {
for (int idx = 0; idx < filt->order; idx++) {
sample = do_filter(&filt->filters[idx], sample);
}

View File

@ -18,7 +18,8 @@ MultiBiquad::MultiBiquad() {
}
float MultiBiquad::ProcessSample(float sample) {
float out = sample * this->b0 + this->x_1 * this->b1 + this->x_2 * this->b2 + this->y_1 * this->a1 + this->y_2 * this->a2;
float out = sample * this->b0 + this->x_1 * this->b1 + this->x_2 * this->b2 + this->y_1 * this->a1 +
this->y_2 * this->a2;
this->y_2 = this->y_1;
this->y_1 = out;
this->x_2 = this->x_1;
@ -26,7 +27,8 @@ float MultiBiquad::ProcessSample(float sample) {
return out;
}
void MultiBiquad::RefreshFilter(FilterType type, float gainAmp, float freq, float samplerate, float qFactor, bool param_7) {
void
MultiBiquad::RefreshFilter(FilterType type, float gainAmp, float freq, float samplerate, float qFactor, bool param_7) {
bool uVar1;
int iVar2;
int iVar3;
@ -45,24 +47,24 @@ void MultiBiquad::RefreshFilter(FilterType type, float gainAmp, float freq, floa
double b1;
double b2;
dVar10 = pow(10.0,gainAmp / 40.0);
dVar4 = (freq * 2*M_PI) / samplerate;
dVar10 = pow(10.0, gainAmp / 40.0);
dVar4 = (freq * 2 * M_PI) / samplerate;
dVar5 = sin(dVar4);
dVar11 = cos(dVar4);
uVar1 = type == HIGHSHELF;
dVar4 = (1.0 / dVar10 + dVar10) * (1.0 / qFactor - 1.0) + 2.0;
dVar6 = sqrt(dVar4);
if (!(bool)uVar1) {
if (!(bool) uVar1) {
dVar4 = sinh(dVar4);
dVar6 = dVar4;
}
dVar4 = sqrt(dVar10);
dVar5 = dVar5 * 0.5 * dVar6;
if (!(bool)uVar1) {
if (!(bool) uVar1) {
dVar4 = sinh(dVar10);
}
dVar4 = (dVar4 + dVar4) * dVar5;
switch(type) {
switch (type) {
case LOWPASS:
b1 = 1.0 - dVar11;
dVar10 = b1;

View File

@ -22,6 +22,7 @@ public:
MultiBiquad();
float ProcessSample(float sample);
void RefreshFilter(FilterType type, float gainAmp, float freq, float samplerate, float qFactor, bool param_7);
float y_2, y_1, x_2, x_1;

View File

@ -13,8 +13,8 @@ NoiseSharpening::NoiseSharpening() {
void NoiseSharpening::Process(float *buffer, uint32_t size) {
for (int i = 0; i < size; i++) {
float sampleLeft = buffer[i*2];
float sampleRight = buffer[i*2+1];
float sampleLeft = buffer[i * 2];
float sampleRight = buffer[i * 2 + 1];
float prevLeft = this->in[0];
float prevRight = this->in[1];
this->in[0] = sampleLeft;
@ -33,8 +33,8 @@ void NoiseSharpening::Process(float *buffer, uint32_t size) {
float right = this->filters[1].prevSample + (sampleRightIn) * this->filters[1].b0;
this->filters[1].prevSample = (sampleRightIn) * this->filters[1].a1 + hist;
buffer[i*2] = left;
buffer[i*2+1] = right;
buffer[i * 2] = left;
buffer[i * 2 + 1] = right;
}
}

View File

@ -11,9 +11,12 @@ class NoiseSharpening {
public:
NoiseSharpening();
void Process(float* buffer, uint32_t size);
void Process(float *buffer, uint32_t size);
void Reset();
void SetGain(float gain);
void SetSamplingRate(uint32_t samplerate);
IIR_1st filters[2];

View File

@ -56,7 +56,7 @@ int PConvSingle_F32::LoadKernel(float *buf, int param_2, int segmentSize) {
if (param_2 > 0 && segmentSize > 0 && segmentSize % 2 == 0) {
this->enabled = false;
ReleaseResources();
this->data = (PConvData *)malloc(0x140); // TODO: Sizeof
this->data = (PConvData *) malloc(0x140); // TODO: Sizeof
memset(this->data, 0, 0x140); // Ditto
this->segmentSize = segmentSize;
int n = ProcessKernel(buf, param_2, 1);
@ -76,7 +76,7 @@ int PConvSingle_F32::LoadKernel(float *buf, float *param_2, int segmentSize, int
if (param_5 > 0 && segmentSize > 0 && segmentSize % 2 == 0) {
this->enabled = false;
ReleaseResources();
this->data = (PConvData *)malloc(0x140); // TODO: Sizeof
this->data = (PConvData *) malloc(0x140); // TODO: Sizeof
memset(this->data, 0, 0x140); // Ditto
this->segmentSize = segmentSize;
int n = ProcessKernel(1, param_2, param_4, param_5);

View File

@ -8,46 +8,58 @@ typedef struct {
int unk_0x00;
int unk_0x04;
int unk_0x08;
float* unk_buffer;
float* fftInputBuffer;
float* fftOutputBuffer;
float* unk_buffer_2;
float* unk_buffer_3;
float *unk_buffer;
float *fftInputBuffer;
float *fftOutputBuffer;
float *unk_buffer_2;
float *unk_buffer_3;
int size_A;
void* field_A1;
void* field_A2;
void *field_A1;
void *field_A2;
int size_B;
void* field_B1;
void* field_B2;
int* unk_0x120;
void* fft_plan_1;
void* fft_plan_2;
void *field_B1;
void *field_B2;
int *unk_0x120;
void *fft_plan_1;
void *fft_plan_2;
} PConvData;
class PConvSingle_F32 {
public:
PConvSingle_F32();
~PConvSingle_F32();
void Reset();
int GetFFTSize();
int GetSegmentCount();
int GetSegmentSize();
bool InstanceUsable();
void Convolve(float* buffer);
void ConvolveInterleaved(float* buffer, int channel);
void ConvSegment(float* buffer, bool interleaved, int channel);
void Convolve(float *buffer);
void ConvolveInterleaved(float *buffer, int channel);
void ConvSegment(float *buffer, bool interleaved, int channel);
int LoadKernel(float *buf, int param_2, int segmentSize);
int LoadKernel(float *buf, float *param_2, int segmentSize, int param_4, int param_5);
int ProcessKernel(float *param_1, int param_2, int param_3);
int LoadKernel(float* buf, int param_2, int segmentSize);
int LoadKernel(float* buf, float* param_2, int segmentSize, int param_4, int param_5);
int ProcessKernel(float* param_1, int param_2, int param_3);
int ProcessKernel(int param_2, float *param_3, int param_4, int param_5);
void ReleaseResources();
void UnloadKernel();
bool enabled;
int segments, segmentSize;
PConvData* data; // TODO: Type
PConvData *data; // TODO: Type
};

View File

@ -29,8 +29,8 @@ void PassFilter::Reset() {
cutoff = 18000;
}
this->filters[0]->setLPF((float)cutoff, this->samplerate);
this->filters[1]->setLPF((float)cutoff, this->samplerate);
this->filters[0]->setLPF((float) cutoff, this->samplerate);
this->filters[1]->setLPF((float) cutoff, this->samplerate);
this->filters[2]->setLPF(10.f, cutoff);
this->filters[3]->setLPF(10.f, cutoff);
@ -42,16 +42,16 @@ void PassFilter::Reset() {
void PassFilter::ProcessFrames(float *buffer, uint32_t size) {
for (int x = 0; x < size; x++) {
float left = buffer[2*x];
float right = buffer[2*x+1];
float left = buffer[2 * x];
float right = buffer[2 * x + 1];
left = do_filter_lh(this->filters[2], left);
left = do_filter_lh(this->filters[0], left);
right = do_filter_lh(this->filters[3], right);
right = do_filter_lh(this->filters[1], right);
buffer[2*x] = left;
buffer[2*x+1] = right;
buffer[2 * x] = left;
buffer[2 * x + 1] = right;
}
}

View File

@ -10,12 +10,15 @@
class PassFilter {
public:
PassFilter();
~PassFilter();
void Reset();
void ProcessFrames(float* buffer, uint32_t size);
void ProcessFrames(float *buffer, uint32_t size);
void SetSamplingRate(uint32_t samplerate);
IIR_NOrder_BW_LH* filters[4];
IIR_NOrder_BW_LH *filters[4];
uint32_t samplerate;
};

View File

@ -22,13 +22,13 @@ void PolesFilter::UpdateCoeff() {
memset(&this->channels[0], 0, sizeof(channel));
memset(&this->channels[1], 0, sizeof(channel));
this->channels[0].lower_angle = ((float)this->lower_freq * M_PI / (float)this->samplerate);
this->channels[1].lower_angle = ((float)this->lower_freq * M_PI / (float)this->samplerate);
this->channels[0].upper_angle = ((float)this->upper_freq * M_PI / (float)this->samplerate);
this->channels[1].upper_angle = ((float)this->upper_freq * M_PI / (float)this->samplerate);
this->channels[0].lower_angle = ((float) this->lower_freq * M_PI / (float) this->samplerate);
this->channels[1].lower_angle = ((float) this->lower_freq * M_PI / (float) this->samplerate);
this->channels[0].upper_angle = ((float) this->upper_freq * M_PI / (float) this->samplerate);
this->channels[1].upper_angle = ((float) this->upper_freq * M_PI / (float) this->samplerate);
}
inline void DoFilterSide(channel* side, float sample, float* out1, float* out2, float* out3) {
inline void DoFilterSide(channel *side, float sample, float *out1, float *out2, float *out3) {
float oldestSampleIn = side->in[2];
side->in[2] = side->in[1];
side->in[1] = side->in[0];

View File

@ -21,11 +21,15 @@ public:
PolesFilter();
void Reset();
void UpdateCoeff();
void DoFilterLeft(float sample, float* out1, float* out2, float* out3);
void DoFilterRight(float sample, float* out1, float* out2, float* out3);
void DoFilterLeft(float sample, float *out1, float *out2, float *out3);
void DoFilterRight(float sample, float *out1, float *out2, float *out3);
void SetPassFilter(uint32_t lower_freq, uint32_t upper_freq);
void SetSamplingRate(uint32_t samplerate);
channel channels[2];

View File

@ -7,7 +7,7 @@
#include <cmath>
Subwoofer::Subwoofer() {
float samplerate = (float)DEFAULT_SAMPLERATE;
float samplerate = (float) DEFAULT_SAMPLERATE;
this->peak[0].RefreshFilter(FilterType::PEAK, 0.f, 37.f, samplerate, 1.f, false);
this->peak[1].RefreshFilter(FilterType::PEAK, 0.f, 37.f, samplerate, 1.f, false);
this->peakLow[0].RefreshFilter(FilterType::PEAK, 0.f, 75.f, samplerate, 1.f, false);
@ -31,10 +31,10 @@ void Subwoofer::SetBassGain(uint32_t samplerate, float gainDb) {
float gain = 20.f * log10f(gainDb);
float gainLower = 20.f * log10f(gainDb / 8.f);
this->peak[0].RefreshFilter(FilterType::PEAK, gain, 44.f, (float)samplerate, 0.75, true);
this->peak[1].RefreshFilter(FilterType::PEAK, gain, 44.f, (float)samplerate, 0.75, true);
this->peakLow[0].RefreshFilter(FilterType::PEAK, gainLower, 80.f, (float)samplerate, 0.2, true);
this->peakLow[1].RefreshFilter(FilterType::PEAK, gainLower, 80.f, (float)samplerate, 0.2, true);
this->lowpass[0].RefreshFilter(FilterType::LOWPASS, 0.f, 380.f, (float)samplerate, 0.6, false);
this->lowpass[1].RefreshFilter(FilterType::LOWPASS, 0.f, 380.f, (float)samplerate, 0.6, false);
this->peak[0].RefreshFilter(FilterType::PEAK, gain, 44.f, (float) samplerate, 0.75, true);
this->peak[1].RefreshFilter(FilterType::PEAK, gain, 44.f, (float) samplerate, 0.75, true);
this->peakLow[0].RefreshFilter(FilterType::PEAK, gainLower, 80.f, (float) samplerate, 0.2, true);
this->peakLow[1].RefreshFilter(FilterType::PEAK, gainLower, 80.f, (float) samplerate, 0.2, true);
this->lowpass[0].RefreshFilter(FilterType::LOWPASS, 0.f, 380.f, (float) samplerate, 0.6, false);
this->lowpass[1].RefreshFilter(FilterType::LOWPASS, 0.f, 380.f, (float) samplerate, 0.6, false);
}

View File

@ -12,7 +12,7 @@ class Subwoofer {
public:
Subwoofer();
void Process(float* samples, uint32_t size);
void Process(float *samples, uint32_t size);
void SetBassGain(uint32_t samplerate, float gainDb);

View File

@ -23,14 +23,14 @@ float TimeConstDelay::ProcessSample(float sample) {
if (this->samples != nullptr) {
float val = this->samples[this->offset];
this->samples[this->offset] = sample;
this->offset = (int)modf((float)this->offset + 1, (float*)&this->sampleCount);
this->offset = (int) modf((float) this->offset + 1, (float *) &this->sampleCount);
return val;
}
return 0.f;
}
void TimeConstDelay::SetParameters(uint32_t samplerate, float delay) {
this->sampleCount = (int)((float)samplerate * delay * 0.5f);
this->sampleCount = (int) ((float) samplerate * delay * 0.5f);
if (this->samples != nullptr) {
free(this->samples);
}

View File

@ -8,12 +8,14 @@
class TimeConstDelay {
public:
TimeConstDelay();
~TimeConstDelay();
float ProcessSample(float sample);
void SetParameters(uint32_t samplerate, float delay);
float* samples;
float *samples;
uint32_t offset;
uint32_t sampleCount;
};

View File

@ -10,7 +10,7 @@ WaveBuffer_I32::WaveBuffer_I32(int channels, uint32_t size) {
this->channels = channels;
this->size = size * channels;
this->index = 0;
this->buffer = (float*)malloc(this->size * sizeof(float));
this->buffer = (float *) malloc(this->size * sizeof(float));
}
WaveBuffer_I32::~WaveBuffer_I32() {
@ -40,7 +40,7 @@ uint32_t WaveBuffer_I32::PopSamples(uint32_t size, bool resetIndex) {
if (this->channels * size <= this->index) {
this->index -= this->channels * size;
memmove(this->buffer, &this->buffer[this->channels*size], this->index * sizeof(float));
memmove(this->buffer, &this->buffer[this->channels * size], this->index * sizeof(float));
return size;
}
@ -61,7 +61,7 @@ uint32_t WaveBuffer_I32::PopSamples(float *dest, uint32_t size, bool resetIndex)
if (this->channels * size <= this->index) {
memcpy(dest, this->buffer, this->index * sizeof(float));
this->index -= this->channels * size;
memmove(this->buffer, &this->buffer[this->channels*size], this->index * sizeof(float));
memmove(this->buffer, &this->buffer[this->channels * size], this->index * sizeof(float));
return size;
}
@ -82,7 +82,7 @@ int WaveBuffer_I32::PushSamples(float *source, uint32_t size) {
if (size > 0) {
if (this->size < this->channels * size + this->index) {
float* buf = (float*)malloc((this->channels * size + this->index) * sizeof(float));
float *buf = (float *) malloc((this->channels * size + this->index) * sizeof(float));
if (buf == nullptr) {
return 0;
}
@ -105,7 +105,7 @@ int WaveBuffer_I32::PushZeros(uint32_t size) {
if (size > 0) {
if (this->size < this->channels * size + this->index) {
float* buf = (float*)malloc((this->channels * size + this->index) * sizeof(float));
float *buf = (float *) malloc((this->channels * size + this->index) * sizeof(float));
if (buf == nullptr) {
return 0;
}
@ -128,7 +128,7 @@ float *WaveBuffer_I32::PushZerosGetBuffer(uint32_t size) {
if (size > 0) {
if (this->size < this->channels * size + this->index) {
float* buf = (float*)malloc((this->channels * size + this->index) * sizeof(float));
float *buf = (float *) malloc((this->channels * size + this->index) * sizeof(float));
if (buf == nullptr) {
return nullptr;
}

View File

@ -10,21 +10,30 @@
class WaveBuffer_I32 {
public:
WaveBuffer_I32(int channels, uint32_t size);
~WaveBuffer_I32();
void Reset();
uint32_t GetBufferOffset();
uint32_t GetBufferSize();
float* GetCurrentBufferI32Ptr();
float *GetCurrentBufferI32Ptr();
uint32_t PopSamples(uint32_t size, bool resetIndex);
uint32_t PopSamples(float* dest, uint32_t size, bool resetIndex);
int PushSamples(float* source, uint32_t size);
uint32_t PopSamples(float *dest, uint32_t size, bool resetIndex);
int PushSamples(float *source, uint32_t size);
int PushZeros(uint32_t size);
float* PushZerosGetBuffer(uint32_t size);
float *PushZerosGetBuffer(uint32_t size);
void SetBufferOffset(uint32_t offset);
float* buffer;
float *buffer;
uint32_t size;
uint32_t index;
int channels;

View File

@ -7,8 +7,8 @@
static effect_descriptor_t viper_descriptor = {
// Identical type/uuid to original ViPER4Android
.type = {0x00000000, 0x0000, 0x0000, 0x0000, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } },
.uuid = {0x41d3c987, 0xe6cf, 0x11e3, 0xa88a, { 0x11, 0xab, 0xa5, 0xd5, 0xc5, 0x1b } },
.type = {0x00000000, 0x0000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
.uuid = {0x41d3c987, 0xe6cf, 0x11e3, 0xa88a, {0x11, 0xab, 0xa5, 0xd5, 0xc5, 0x1b}},
.apiVersion = EFFECT_CONTROL_API_VERSION,
.flags = EFFECT_FLAG_OUTPUT_BOTH | EFFECT_FLAG_INPUT_BOTH | 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
@ -16,147 +16,153 @@ static effect_descriptor_t viper_descriptor = {
};
extern "C" {
struct ViperContext {
const struct effect_interface_s *interface;
ProcessUnit_FX *effect;
effect_descriptor_t *descriptor;
};
struct ViperContext {
const struct effect_interface_s *interface;
ProcessUnit_FX *effect;
effect_descriptor_t *descriptor;
};
static int32_t viper_process(effect_handle_t self, audio_buffer_t *in, audio_buffer_t *out) {
auto pContext = (ViperContext *) self;
static int32_t viper_process(effect_handle_t self, audio_buffer_t *in, audio_buffer_t *out) {
auto pContext = (ViperContext *) self;
if (pContext == nullptr) {
v4a_printf(ANDROID_LOG_ERROR, "viper_process(), Error [pContext = NULL]");
return -EINVAL;
}
if (in == nullptr) {
v4a_printf(ANDROID_LOG_ERROR, "viper_process(), Error [in = NULL]");
return -EINVAL;
}
if (out == nullptr) {
v4a_printf(ANDROID_LOG_ERROR, "viper_process(), Error [out = NULL]");
return -EINVAL;
}
return pContext->effect->process(in, out);
if (pContext == nullptr) {
v4a_printf(ANDROID_LOG_ERROR, "viper_process(), Error [pContext = NULL]");
return -EINVAL;
}
static int32_t viper_command(effect_handle_t self, uint32_t cmdCode, uint32_t cmdSize, void *pCmdData, uint32_t *replySize, void *pReplyData) {
auto pContext = (ViperContext *) self;
if (pContext == nullptr) {
v4a_printf(ANDROID_LOG_ERROR, "viper_command(), Error [pContext = NULL]");
return -EINVAL;
}
return pContext->effect->command(cmdCode, cmdSize, pCmdData, replySize, pReplyData);
if (in == nullptr) {
v4a_printf(ANDROID_LOG_ERROR, "viper_process(), Error [in = NULL]");
return -EINVAL;
}
static int32_t viper_get_descriptor(effect_handle_t self, effect_descriptor_t *pDescriptor) {
auto *pContext = (ViperContext *) self;
if (pContext == nullptr) {
v4a_printf(ANDROID_LOG_ERROR, "viper_get_descriptor(), Error [pContext = NULL]");
return -EINVAL;
}
if (pDescriptor == nullptr) {
v4a_print(ANDROID_LOG_ERROR, "viper_get_descriptor(), Error [pDescriptor = NULL]");
return -EINVAL;
}
*pDescriptor = *pContext->descriptor;
return 0;
if (out == nullptr) {
v4a_printf(ANDROID_LOG_ERROR, "viper_process(), Error [out = NULL]");
return -EINVAL;
}
const effect_interface_s viper_interface = {
return pContext->effect->process(in, out);
}
static int32_t
viper_command(effect_handle_t self, uint32_t cmdCode, uint32_t cmdSize, void *pCmdData, uint32_t *replySize,
void *pReplyData) {
auto pContext = (ViperContext *) self;
if (pContext == nullptr) {
v4a_printf(ANDROID_LOG_ERROR, "viper_command(), Error [pContext = NULL]");
return -EINVAL;
}
return pContext->effect->command(cmdCode, cmdSize, pCmdData, replySize, pReplyData);
}
static int32_t viper_get_descriptor(effect_handle_t self, effect_descriptor_t *pDescriptor) {
auto *pContext = (ViperContext *) self;
if (pContext == nullptr) {
v4a_printf(ANDROID_LOG_ERROR, "viper_get_descriptor(), Error [pContext = NULL]");
return -EINVAL;
}
if (pDescriptor == nullptr) {
v4a_print(ANDROID_LOG_ERROR, "viper_get_descriptor(), Error [pDescriptor = NULL]");
return -EINVAL;
}
*pDescriptor = *pContext->descriptor;
return 0;
}
const effect_interface_s viper_interface = {
.process = viper_process,
.command = viper_command,
.get_descriptor = viper_get_descriptor
};
};
int32_t viper_effect_create(const effect_uuid_t *uuid, int32_t sessionId, int32_t ioId, effect_handle_t *pHandle) {
v4a_print(ANDROID_LOG_INFO, "Enter viper_effect_create()");
int32_t viper_effect_create(const effect_uuid_t *uuid, int32_t sessionId, int32_t ioId, effect_handle_t *pHandle) {
v4a_print(ANDROID_LOG_INFO, "Enter viper_effect_create()");
if (uuid == nullptr) {
v4a_printf(ANDROID_LOG_ERROR, "viper_effect_create(), Error [uuid = NULL]");
return -EINVAL;
}
if (pHandle == nullptr) {
v4a_printf(ANDROID_LOG_ERROR, "viper_effect_create(), Error [pHandle = NULL]");
return -EINVAL;
}
if (memcmp(uuid, &viper_descriptor.uuid, sizeof(effect_uuid_t)) != 0) {
v4a_print(ANDROID_LOG_ERROR, "viper_effect_create(), Error [effect not found]");
return -EINVAL;
}
v4a_printf(ANDROID_LOG_INFO, "viper_effect_create(), uuid = %08x-%04x-%04x-%04x-%02x%02x%02x%02x%02x%02x", uuid->timeLow, uuid->timeMid, uuid->timeHiAndVersion, uuid->clockSeq, uuid->node[0], uuid->node[1], uuid->node[2], uuid->node[3], uuid->node[4], uuid->node[5]);
v4a_print(ANDROID_LOG_INFO, "viper_effect_create(), v4a standard effect (normal), Constructing ProcessUnit_FX");
auto *pContext = new ViperContext;
pContext->interface = &viper_interface;
pContext->effect = new ProcessUnit_FX();
pContext->descriptor = &viper_descriptor;
v4a_print(ANDROID_LOG_INFO, "Creating ViPER4Android Reworked [" VERSION_STRING "]");
*pHandle = (effect_handle_t) pContext;
return 0;
if (uuid == nullptr) {
v4a_printf(ANDROID_LOG_ERROR, "viper_effect_create(), Error [uuid = NULL]");
return -EINVAL;
}
int32_t viper_effect_release(effect_handle_t handle) {
auto *pContext = (ViperContext *) handle;
v4a_print(ANDROID_LOG_INFO, "Enter viper_effect_release()");
if (pContext == nullptr) {
v4a_printf(ANDROID_LOG_ERROR, "viper_effect_release(), Error [pContext = NULL]");
return -EINVAL;
}
v4a_print(ANDROID_LOG_INFO, "viper_effect_release(), Deconstructing ProcessUnit");
if (pContext->effect != nullptr) {
delete pContext->effect;
pContext->effect = nullptr;
}
delete pContext;
return 0;
if (pHandle == nullptr) {
v4a_printf(ANDROID_LOG_ERROR, "viper_effect_create(), Error [pHandle = NULL]");
return -EINVAL;
}
int32_t viper_effect_get_descriptor(const effect_uuid_t *uuid, effect_descriptor_t *pDescriptor) {
v4a_print(ANDROID_LOG_INFO, "Enter viper_effect_get_descriptor()");
if (uuid == nullptr) {
v4a_printf(ANDROID_LOG_ERROR, "viper_effect_get_descriptor(), Error [uuid = NULL]");
return -EINVAL;
}
if (pDescriptor == nullptr) {
v4a_printf(ANDROID_LOG_ERROR, "viper_effect_get_descriptor(), Error [pDescriptor = NULL]");
return -EINVAL;
}
if (memcmp(uuid, &viper_descriptor.uuid, sizeof(effect_uuid_t)) != 0) {
v4a_print(ANDROID_LOG_ERROR, "viper_effect_get_descriptor(), Error [effect not found]");
return -EINVAL;
}
v4a_printf(ANDROID_LOG_INFO, "viper_effect_get_descriptor(), uuid = %08x-%04x-%04x-%04x-%02x%02x%02x%02x%02x%02x", uuid->timeLow, uuid->timeMid, uuid->timeHiAndVersion, uuid->clockSeq, uuid->node[0], uuid->node[1], uuid->node[2], uuid->node[3], uuid->node[4], uuid->node[5]);
*pDescriptor = viper_descriptor;
return 0;
if (memcmp(uuid, &viper_descriptor.uuid, sizeof(effect_uuid_t)) != 0) {
v4a_print(ANDROID_LOG_ERROR, "viper_effect_create(), Error [effect not found]");
return -EINVAL;
}
audio_effect_library_t AUDIO_EFFECT_LIBRARY_INFO_SYM = {
v4a_printf(ANDROID_LOG_INFO, "viper_effect_create(), uuid = %08x-%04x-%04x-%04x-%02x%02x%02x%02x%02x%02x",
uuid->timeLow, uuid->timeMid, uuid->timeHiAndVersion, uuid->clockSeq, uuid->node[0], uuid->node[1],
uuid->node[2], uuid->node[3], uuid->node[4], uuid->node[5]);
v4a_print(ANDROID_LOG_INFO, "viper_effect_create(), v4a standard effect (normal), Constructing ProcessUnit_FX");
auto *pContext = new ViperContext;
pContext->interface = &viper_interface;
pContext->effect = new ProcessUnit_FX();
pContext->descriptor = &viper_descriptor;
v4a_print(ANDROID_LOG_INFO, "Creating ViPER4Android Reworked [" VERSION_STRING "]");
*pHandle = (effect_handle_t) pContext;
return 0;
}
int32_t viper_effect_release(effect_handle_t handle) {
auto *pContext = (ViperContext *) handle;
v4a_print(ANDROID_LOG_INFO, "Enter viper_effect_release()");
if (pContext == nullptr) {
v4a_printf(ANDROID_LOG_ERROR, "viper_effect_release(), Error [pContext = NULL]");
return -EINVAL;
}
v4a_print(ANDROID_LOG_INFO, "viper_effect_release(), Deconstructing ProcessUnit");
if (pContext->effect != nullptr) {
delete pContext->effect;
pContext->effect = nullptr;
}
delete pContext;
return 0;
}
int32_t viper_effect_get_descriptor(const effect_uuid_t *uuid, effect_descriptor_t *pDescriptor) {
v4a_print(ANDROID_LOG_INFO, "Enter viper_effect_get_descriptor()");
if (uuid == nullptr) {
v4a_printf(ANDROID_LOG_ERROR, "viper_effect_get_descriptor(), Error [uuid = NULL]");
return -EINVAL;
}
if (pDescriptor == nullptr) {
v4a_printf(ANDROID_LOG_ERROR, "viper_effect_get_descriptor(), Error [pDescriptor = NULL]");
return -EINVAL;
}
if (memcmp(uuid, &viper_descriptor.uuid, sizeof(effect_uuid_t)) != 0) {
v4a_print(ANDROID_LOG_ERROR, "viper_effect_get_descriptor(), Error [effect not found]");
return -EINVAL;
}
v4a_printf(ANDROID_LOG_INFO, "viper_effect_get_descriptor(), uuid = %08x-%04x-%04x-%04x-%02x%02x%02x%02x%02x%02x",
uuid->timeLow, uuid->timeMid, uuid->timeHiAndVersion, uuid->clockSeq, uuid->node[0], uuid->node[1],
uuid->node[2], uuid->node[3], uuid->node[4], uuid->node[5]);
*pDescriptor = viper_descriptor;
return 0;
}
audio_effect_library_t AUDIO_EFFECT_LIBRARY_INFO_SYM = {
.tag = AUDIO_EFFECT_LIBRARY_TAG,
.version = EFFECT_LIBRARY_API_VERSION,
.name = "ViPER4Android FX Reworked",
@ -164,5 +170,5 @@ extern "C" {
.create_effect = viper_effect_create,
.release_effect = viper_effect_release,
.get_descriptor = viper_effect_get_descriptor,
};
};
}

View File

@ -7,154 +7,154 @@
// Source: https://github.com/vipersaudio/viperfx_core_binary/blob/master/viperfx_intf.h
extern "C" {
enum ParamsMode {
COMMAND_CODE_GET = 0x01,
COMMAND_CODE_SET,
};
enum ParamsMode {
COMMAND_CODE_GET = 0x01,
COMMAND_CODE_SET,
};
enum ParamsGet {
PARAM_GET_STATUS_BEGIN = 0x08000,
PARAM_GET_DRIVER_VERSION,
PARAM_GET_NEONENABLED,
PARAM_GET_ENABLED,
PARAM_GET_DRVCANWORK,
PARAM_GET_EFFECT_TYPE,
PARAM_GET_SAMPLINGRATE,
PARAM_GET_CONVKNLID,
PARAM_GET_STATUS_END
};
enum ParamsGet {
PARAM_GET_STATUS_BEGIN = 0x08000,
PARAM_GET_DRIVER_VERSION,
PARAM_GET_NEONENABLED,
PARAM_GET_ENABLED,
PARAM_GET_DRVCANWORK,
PARAM_GET_EFFECT_TYPE,
PARAM_GET_SAMPLINGRATE,
PARAM_GET_CONVKNLID,
PARAM_GET_STATUS_END
};
enum ParamsSet {
PARAM_SET_STATUS_BEGIN = 0x09000,
PARAM_SET_RESET_STATUS,
PARAM_SET_SAMPLINGRATE,
PARAM_SET_DOPROCESS_STATUS,
PARAM_SET_STATUS_END
};
enum ParamsSet {
PARAM_SET_STATUS_BEGIN = 0x09000,
PARAM_SET_RESET_STATUS,
PARAM_SET_SAMPLINGRATE,
PARAM_SET_DOPROCESS_STATUS,
PARAM_SET_STATUS_END
};
enum ParamsConfigure {
PARAM_PROCESSUNIT_FX_BEGIN = 0x10000,
enum ParamsConfigure {
PARAM_PROCESSUNIT_FX_BEGIN = 0x10000,
PARAM_FX_TYPE_SWITCH,
PARAM_HPFX_CONV_PROCESS_ENABLED,
PARAM_HPFX_CONV_UPDATEKERNEL,
/*****************************************/
// Please use PARAM_HPFX_CONV_UPDATEKERNEL instead
PARAM_HPFX_CONV_PREPAREBUFFER,
PARAM_HPFX_CONV_SETBUFFER,
PARAM_HPFX_CONV_COMMITBUFFER,
/*****************************************/
PARAM_HPFX_CONV_CROSSCHANNEL,
PARAM_HPFX_VHE_PROCESS_ENABLED,
PARAM_HPFX_VHE_EFFECT_LEVEL,
PARAM_HPFX_VDDC_PROCESS_ENABLED,
PARAM_HPFX_VDDC_COEFFS,
PARAM_HPFX_VSE_PROCESS_ENABLED,
PARAM_HPFX_VSE_REFERENCE_BARK,
PARAM_HPFX_VSE_BARK_RECONSTRUCT,
PARAM_HPFX_FIREQ_PROCESS_ENABLED,
PARAM_HPFX_FIREQ_BANDLEVEL,
PARAM_HPFX_COLM_PROCESS_ENABLED,
PARAM_HPFX_COLM_WIDENING,
PARAM_HPFX_COLM_MIDIMAGE,
PARAM_HPFX_COLM_DEPTH,
PARAM_HPFX_DIFFSURR_PROCESS_ENABLED,
PARAM_HPFX_DIFFSURR_DELAYTIME,
PARAM_HPFX_REVB_PROCESS_ENABLED,
PARAM_HPFX_REVB_ROOMSIZE,
PARAM_HPFX_REVB_WIDTH,
PARAM_HPFX_REVB_DAMP,
PARAM_HPFX_REVB_WET,
PARAM_HPFX_REVB_DRY,
PARAM_HPFX_AGC_PROCESS_ENABLED,
PARAM_HPFX_AGC_RATIO,
PARAM_HPFX_AGC_VOLUME,
PARAM_HPFX_AGC_MAXSCALER,
PARAM_HPFX_DYNSYS_PROCESS_ENABLED,
PARAM_HPFX_DYNSYS_XCOEFFS,
PARAM_HPFX_DYNSYS_YCOEFFS,
PARAM_HPFX_DYNSYS_SIDEGAIN,
PARAM_HPFX_DYNSYS_BASSGAIN,
PARAM_HPFX_VIPERBASS_PROCESS_ENABLED,
PARAM_HPFX_VIPERBASS_MODE,
PARAM_HPFX_VIPERBASS_SPEAKER,
PARAM_HPFX_VIPERBASS_BASSGAIN,
PARAM_HPFX_VIPERCLARITY_PROCESS_ENABLED,
PARAM_HPFX_VIPERCLARITY_MODE,
PARAM_HPFX_VIPERCLARITY_CLARITY,
PARAM_HPFX_CURE_PROCESS_ENABLED,
PARAM_HPFX_CURE_CROSSFEED,
PARAM_HPFX_TUBE_PROCESS_ENABLED,
PARAM_HPFX_ANALOGX_PROCESS_ENABLED,
PARAM_HPFX_ANALOGX_MODE,
PARAM_HPFX_OUTPUT_VOLUME,
PARAM_HPFX_OUTPUT_PAN,
PARAM_HPFX_LIMITER_THRESHOLD,
PARAM_SPKFX_CONV_PROCESS_ENABLED,
PARAM_SPKFX_CONV_UPDATEKERNEL,
PARAM_SPKFX_CONV_PREPAREBUFFER,
PARAM_SPKFX_CONV_SETBUFFER,
PARAM_SPKFX_CONV_COMMITBUFFER,
PARAM_SPKFX_CONV_CROSSCHANNEL,
PARAM_SPKFX_FIREQ_PROCESS_ENABLED,
PARAM_SPKFX_FIREQ_BANDLEVEL,
PARAM_SPKFX_REVB_PROCESS_ENABLED,
PARAM_SPKFX_REVB_ROOMSIZE,
PARAM_SPKFX_REVB_WIDTH,
PARAM_SPKFX_REVB_DAMP,
PARAM_SPKFX_REVB_WET,
PARAM_SPKFX_REVB_DRY,
PARAM_SPKFX_AGC_PROCESS_ENABLED,
PARAM_SPKFX_AGC_RATIO,
PARAM_SPKFX_AGC_VOLUME,
PARAM_SPKFX_AGC_MAXSCALER,
PARAM_SPKFX_OUTPUT_VOLUME,
PARAM_SPKFX_LIMITER_THRESHOLD,
PARAM_HPFX_FETCOMP_PROCESS_ENABLED,
PARAM_HPFX_FETCOMP_THRESHOLD,
PARAM_HPFX_FETCOMP_RATIO,
PARAM_HPFX_FETCOMP_KNEEWIDTH,
PARAM_HPFX_FETCOMP_AUTOKNEE_ENABLED,
PARAM_HPFX_FETCOMP_GAIN,
PARAM_HPFX_FETCOMP_AUTOGAIN_ENABLED,
PARAM_HPFX_FETCOMP_ATTACK,
PARAM_HPFX_FETCOMP_AUTOATTACK_ENABLED,
PARAM_HPFX_FETCOMP_RELEASE,
PARAM_HPFX_FETCOMP_AUTORELEASE_ENABLED,
PARAM_HPFX_FETCOMP_META_KNEEMULTI,
PARAM_HPFX_FETCOMP_META_MAXATTACK,
PARAM_HPFX_FETCOMP_META_MAXRELEASE,
PARAM_HPFX_FETCOMP_META_CREST,
PARAM_HPFX_FETCOMP_META_ADAPT,
PARAM_HPFX_FETCOMP_META_NOCLIP_ENABLED,
PARAM_SPKFX_FETCOMP_PROCESS_ENABLED,
PARAM_SPKFX_FETCOMP_THRESHOLD,
PARAM_SPKFX_FETCOMP_RATIO,
PARAM_SPKFX_FETCOMP_KNEEWIDTH,
PARAM_SPKFX_FETCOMP_AUTOKNEE_ENABLED,
PARAM_SPKFX_FETCOMP_GAIN,
PARAM_SPKFX_FETCOMP_AUTOGAIN_ENABLED,
PARAM_SPKFX_FETCOMP_ATTACK,
PARAM_SPKFX_FETCOMP_AUTOATTACK_ENABLED,
PARAM_SPKFX_FETCOMP_RELEASE,
PARAM_SPKFX_FETCOMP_AUTORELEASE_ENABLED,
PARAM_SPKFX_FETCOMP_META_KNEEMULTI,
PARAM_SPKFX_FETCOMP_META_MAXATTACK,
PARAM_SPKFX_FETCOMP_META_MAXRELEASE,
PARAM_SPKFX_FETCOMP_META_CREST,
PARAM_SPKFX_FETCOMP_META_ADAPT,
PARAM_SPKFX_FETCOMP_META_NOCLIP_ENABLED,
PARAM_FX_TYPE_SWITCH,
PARAM_HPFX_CONV_PROCESS_ENABLED,
PARAM_HPFX_CONV_UPDATEKERNEL,
/*****************************************/
// Please use PARAM_HPFX_CONV_UPDATEKERNEL instead
PARAM_HPFX_CONV_PREPAREBUFFER,
PARAM_HPFX_CONV_SETBUFFER,
PARAM_HPFX_CONV_COMMITBUFFER,
/*****************************************/
PARAM_HPFX_CONV_CROSSCHANNEL,
PARAM_HPFX_VHE_PROCESS_ENABLED,
PARAM_HPFX_VHE_EFFECT_LEVEL,
PARAM_HPFX_VDDC_PROCESS_ENABLED,
PARAM_HPFX_VDDC_COEFFS,
PARAM_HPFX_VSE_PROCESS_ENABLED,
PARAM_HPFX_VSE_REFERENCE_BARK,
PARAM_HPFX_VSE_BARK_RECONSTRUCT,
PARAM_HPFX_FIREQ_PROCESS_ENABLED,
PARAM_HPFX_FIREQ_BANDLEVEL,
PARAM_HPFX_COLM_PROCESS_ENABLED,
PARAM_HPFX_COLM_WIDENING,
PARAM_HPFX_COLM_MIDIMAGE,
PARAM_HPFX_COLM_DEPTH,
PARAM_HPFX_DIFFSURR_PROCESS_ENABLED,
PARAM_HPFX_DIFFSURR_DELAYTIME,
PARAM_HPFX_REVB_PROCESS_ENABLED,
PARAM_HPFX_REVB_ROOMSIZE,
PARAM_HPFX_REVB_WIDTH,
PARAM_HPFX_REVB_DAMP,
PARAM_HPFX_REVB_WET,
PARAM_HPFX_REVB_DRY,
PARAM_HPFX_AGC_PROCESS_ENABLED,
PARAM_HPFX_AGC_RATIO,
PARAM_HPFX_AGC_VOLUME,
PARAM_HPFX_AGC_MAXSCALER,
PARAM_HPFX_DYNSYS_PROCESS_ENABLED,
PARAM_HPFX_DYNSYS_XCOEFFS,
PARAM_HPFX_DYNSYS_YCOEFFS,
PARAM_HPFX_DYNSYS_SIDEGAIN,
PARAM_HPFX_DYNSYS_BASSGAIN,
PARAM_HPFX_VIPERBASS_PROCESS_ENABLED,
PARAM_HPFX_VIPERBASS_MODE,
PARAM_HPFX_VIPERBASS_SPEAKER,
PARAM_HPFX_VIPERBASS_BASSGAIN,
PARAM_HPFX_VIPERCLARITY_PROCESS_ENABLED,
PARAM_HPFX_VIPERCLARITY_MODE,
PARAM_HPFX_VIPERCLARITY_CLARITY,
PARAM_HPFX_CURE_PROCESS_ENABLED,
PARAM_HPFX_CURE_CROSSFEED,
PARAM_HPFX_TUBE_PROCESS_ENABLED,
PARAM_HPFX_ANALOGX_PROCESS_ENABLED,
PARAM_HPFX_ANALOGX_MODE,
PARAM_HPFX_OUTPUT_VOLUME,
PARAM_HPFX_OUTPUT_PAN,
PARAM_HPFX_LIMITER_THRESHOLD,
PARAM_SPKFX_CONV_PROCESS_ENABLED,
PARAM_SPKFX_CONV_UPDATEKERNEL,
PARAM_SPKFX_CONV_PREPAREBUFFER,
PARAM_SPKFX_CONV_SETBUFFER,
PARAM_SPKFX_CONV_COMMITBUFFER,
PARAM_SPKFX_CONV_CROSSCHANNEL,
PARAM_SPKFX_FIREQ_PROCESS_ENABLED,
PARAM_SPKFX_FIREQ_BANDLEVEL,
PARAM_SPKFX_REVB_PROCESS_ENABLED,
PARAM_SPKFX_REVB_ROOMSIZE,
PARAM_SPKFX_REVB_WIDTH,
PARAM_SPKFX_REVB_DAMP,
PARAM_SPKFX_REVB_WET,
PARAM_SPKFX_REVB_DRY,
PARAM_SPKFX_AGC_PROCESS_ENABLED,
PARAM_SPKFX_AGC_RATIO,
PARAM_SPKFX_AGC_VOLUME,
PARAM_SPKFX_AGC_MAXSCALER,
PARAM_SPKFX_OUTPUT_VOLUME,
PARAM_SPKFX_LIMITER_THRESHOLD,
PARAM_HPFX_FETCOMP_PROCESS_ENABLED,
PARAM_HPFX_FETCOMP_THRESHOLD,
PARAM_HPFX_FETCOMP_RATIO,
PARAM_HPFX_FETCOMP_KNEEWIDTH,
PARAM_HPFX_FETCOMP_AUTOKNEE_ENABLED,
PARAM_HPFX_FETCOMP_GAIN,
PARAM_HPFX_FETCOMP_AUTOGAIN_ENABLED,
PARAM_HPFX_FETCOMP_ATTACK,
PARAM_HPFX_FETCOMP_AUTOATTACK_ENABLED,
PARAM_HPFX_FETCOMP_RELEASE,
PARAM_HPFX_FETCOMP_AUTORELEASE_ENABLED,
PARAM_HPFX_FETCOMP_META_KNEEMULTI,
PARAM_HPFX_FETCOMP_META_MAXATTACK,
PARAM_HPFX_FETCOMP_META_MAXRELEASE,
PARAM_HPFX_FETCOMP_META_CREST,
PARAM_HPFX_FETCOMP_META_ADAPT,
PARAM_HPFX_FETCOMP_META_NOCLIP_ENABLED,
PARAM_SPKFX_FETCOMP_PROCESS_ENABLED,
PARAM_SPKFX_FETCOMP_THRESHOLD,
PARAM_SPKFX_FETCOMP_RATIO,
PARAM_SPKFX_FETCOMP_KNEEWIDTH,
PARAM_SPKFX_FETCOMP_AUTOKNEE_ENABLED,
PARAM_SPKFX_FETCOMP_GAIN,
PARAM_SPKFX_FETCOMP_AUTOGAIN_ENABLED,
PARAM_SPKFX_FETCOMP_ATTACK,
PARAM_SPKFX_FETCOMP_AUTOATTACK_ENABLED,
PARAM_SPKFX_FETCOMP_RELEASE,
PARAM_SPKFX_FETCOMP_AUTORELEASE_ENABLED,
PARAM_SPKFX_FETCOMP_META_KNEEMULTI,
PARAM_SPKFX_FETCOMP_META_MAXATTACK,
PARAM_SPKFX_FETCOMP_META_MAXRELEASE,
PARAM_SPKFX_FETCOMP_META_CREST,
PARAM_SPKFX_FETCOMP_META_ADAPT,
PARAM_SPKFX_FETCOMP_META_NOCLIP_ENABLED,
PARAM_PROCESSUNIT_FX_END
};
PARAM_PROCESSUNIT_FX_END
};
enum FxMode {
ViPER_FX_TYPE_NONE = 0,
enum FxMode {
ViPER_FX_TYPE_NONE = 0,
ViPER_FX_TYPE_HEADPHONE = 1,
ViPER_FX_TYPE_SPEAKER = 2,
ViPER_FX_TYPE_HEADPHONE = 1,
ViPER_FX_TYPE_SPEAKER = 2,
ViPER_FX_TYPE_COUNT
};
ViPER_FX_TYPE_COUNT
};
}