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
5b99913a8f
commit
e2cee17b48
@ -221,13 +221,15 @@ static int32_t handleGetParam(ViperContext *pContext, effect_param_t *pCmdParam,
|
||||
static int32_t Viper_ICommand(effect_handle_t self,
|
||||
uint32_t cmdCode, uint32_t cmdSize, void *pCmdData,
|
||||
uint32_t *replySize, void *pReplyData) {
|
||||
VIPER_LOGD("Viper_ICommand(self = %p, cmdCode = %d, cmdSize = %d, pCmdData = %p, replySize = %p, pReplyData = %p)", self, cmdCode, cmdSize, pCmdData, replySize, pReplyData);
|
||||
|
||||
auto pContext = reinterpret_cast<ViperContext *>(self);
|
||||
|
||||
if (pContext == nullptr || pContext->viper == nullptr) {
|
||||
if (pContext == nullptr || pContext->viper == nullptr || replySize == nullptr || pReplyData == nullptr) {
|
||||
VIPER_LOGD("Viper_ICommand() called with null self or replySize or pReplyData");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
VIPER_LOGD("Viper_ICommand() called with cmdCode = %d", cmdCode);
|
||||
switch (cmdCode) {
|
||||
case EFFECT_CMD_INIT:
|
||||
*((int *) pReplyData) = 0;
|
||||
@ -248,7 +250,7 @@ static int32_t Viper_ICommand(effect_handle_t self,
|
||||
return 0;
|
||||
}
|
||||
case EFFECT_CMD_DISABLE: {
|
||||
pContext->viper->enabled = false;
|
||||
// pContext->viper->enabled = false;
|
||||
*((int *) pReplyData) = 0;
|
||||
return 0;
|
||||
}
|
||||
@ -293,11 +295,15 @@ static void Viper_Init(ViperContext *pContext) {
|
||||
|
||||
static int32_t
|
||||
Viper_Create(const effect_uuid_t *uuid, int32_t sessionId __unused, int32_t ioId __unused, effect_handle_t *pHandle) {
|
||||
VIPER_LOGD("Viper_Create(uuid = %p, sessionId = %d, ioId = %d, pHandle = %p)", uuid, sessionId, ioId, pHandle);
|
||||
|
||||
if (uuid == nullptr || pHandle == nullptr) {
|
||||
VIPER_LOGD("Viper_Create() called with null uuid or pHandle");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (memcmp(uuid, &viper_descriptor.uuid, sizeof(effect_uuid_t)) != 0) {
|
||||
VIPER_LOGD("Viper_Create() called with wrong uuid");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
@ -310,9 +316,12 @@ Viper_Create(const effect_uuid_t *uuid, int32_t sessionId __unused, int32_t ioId
|
||||
}
|
||||
|
||||
static int32_t Viper_Release(effect_handle_t handle) {
|
||||
VIPER_LOGD("Viper_Release(handle = %p)", handle);
|
||||
|
||||
auto pContext = reinterpret_cast<ViperContext *>(handle);
|
||||
|
||||
if (pContext == nullptr) {
|
||||
VIPER_LOGD("Viper_Release() called with null handle");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
@ -324,11 +333,15 @@ static int32_t Viper_Release(effect_handle_t handle) {
|
||||
}
|
||||
|
||||
static int32_t Viper_GetDescriptor(const effect_uuid_t *uuid, effect_descriptor_t *pDescriptor) {
|
||||
VIPER_LOGD("Viper_GetDescriptor(uuid = %p, pDescriptor = %p)", uuid, pDescriptor);
|
||||
|
||||
if (uuid == nullptr || pDescriptor == nullptr) {
|
||||
VIPER_LOGD("Viper_GetDescriptor() called with null uuid or pDescriptor");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (memcmp(uuid, &viper_descriptor.uuid, sizeof(effect_uuid_t)) != 0) {
|
||||
VIPER_LOGD("Viper_GetDescriptor() called with wrong uuid");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -20,73 +20,90 @@ extern "C" {
|
||||
#define PARAM_SET_UPDATE_STATUS 0x9002
|
||||
#define PARAM_SET_RESET_STATUS 0x9003
|
||||
|
||||
enum ParamsSet {
|
||||
PARAM_CONV_PROCESS_ENABLED = 0x10002, // 0x10002
|
||||
PARAM_CONV_UPDATEKERNEL, // 0x10003
|
||||
PARAM_CONV_CROSSCHANNEL = 0x10007, // 0x10007
|
||||
PARAM_VHE_PROCESS_ENABLED, // 0x10008
|
||||
PARAM_VHE_EFFECT_LEVEL, // 0x10009
|
||||
PARAM_VDDC_PROCESS_ENABLED, // 0x1000A
|
||||
PARAM_VDDC_COEFFS, // 0x1000B
|
||||
PARAM_VSE_PROCESS_ENABLED, // 0x1000C
|
||||
PARAM_VSE_REFERENCE_BARK, // 0x1000D
|
||||
PARAM_VSE_BARK_RECONSTRUCT, // 0x1000E
|
||||
PARAM_FIREQ_PROCESS_ENABLED, // 0x1000F
|
||||
PARAM_FIREQ_BANDLEVEL, // 0x10010
|
||||
PARAM_COLM_PROCESS_ENABLED, // 0x10011
|
||||
PARAM_COLM_WIDENING, // 0x10012
|
||||
PARAM_COLM_MIDIMAGE, // 0x10013
|
||||
PARAM_COLM_DEPTH, // 0x10014
|
||||
PARAM_DIFFSURR_PROCESS_ENABLED, // 0x10015
|
||||
PARAM_DIFFSURR_DELAYTIME, // 0x10016
|
||||
PARAM_REVB_PROCESS_ENABLED, // 0x10017
|
||||
PARAM_REVB_ROOMSIZE, // 0x10018
|
||||
PARAM_REVB_WIDTH, // 0x10019
|
||||
PARAM_REVB_DAMP, // 0x1001A
|
||||
PARAM_REVB_WET, // 0x1001B
|
||||
PARAM_REVB_DRY, // 0x1001C
|
||||
PARAM_AGC_PROCESS_ENABLED, // 0x1001D
|
||||
PARAM_AGC_RATIO, // 0x1001E
|
||||
PARAM_AGC_VOLUME, // 0x1001F
|
||||
PARAM_AGC_MAXSCALER, // 0x10020
|
||||
PARAM_DYNSYS_PROCESS_ENABLED, // 0x10021
|
||||
PARAM_DYNSYS_XCOEFFS, // 0x10022
|
||||
PARAM_DYNSYS_YCOEFFS, // 0x10023
|
||||
PARAM_DYNSYS_SIDEGAIN, // 0x10024
|
||||
PARAM_DYNSYS_BASSGAIN, // 0x10025
|
||||
PARAM_VIPERBASS_PROCESS_ENABLED, // 0x10026
|
||||
PARAM_VIPERBASS_MODE, // 0x10027
|
||||
PARAM_VIPERBASS_SPEAKER, // 0x10028
|
||||
PARAM_VIPERBASS_BASSGAIN, // 0x10029
|
||||
PARAM_VIPERCLARITY_PROCESS_ENABLED, // 0x1002A
|
||||
PARAM_VIPERCLARITY_MODE, // 0x1002B
|
||||
PARAM_VIPERCLARITY_CLARITY, // 0x1002C
|
||||
PARAM_CURE_PROCESS_ENABLED, // 0x1002D
|
||||
PARAM_CURE_CROSSFEED, // 0x1002E
|
||||
PARAM_TUBE_PROCESS_ENABLED, // 0x1002F
|
||||
PARAM_ANALOGX_PROCESS_ENABLED, // 0x10030
|
||||
PARAM_ANALOGX_MODE, // 0x10031
|
||||
PARAM_OUTPUT_VOLUME, // 0x10032
|
||||
PARAM_OUTPUT_PAN, // 0x10033
|
||||
PARAM_LIMITER_THRESHOLD, // 0x10034
|
||||
PARAM_SPKFX_AGC_PROCESS_ENABLED = 0x10043, // 0x10043
|
||||
PARAM_FETCOMP_PROCESS_ENABLED = 0x10049, // 0x10049
|
||||
PARAM_FETCOMP_THRESHOLD, // 0x1004A
|
||||
PARAM_FETCOMP_RATIO, // 0x1004B
|
||||
PARAM_FETCOMP_KNEEWIDTH, // 0x1004C
|
||||
PARAM_FETCOMP_AUTOKNEE_ENABLED, // 0x1004D
|
||||
PARAM_FETCOMP_GAIN, // 0x1004E
|
||||
PARAM_FETCOMP_AUTOGAIN_ENABLED, // 0x1004F
|
||||
PARAM_FETCOMP_ATTACK, // 0x10050
|
||||
PARAM_FETCOMP_AUTOATTACK_ENABLED, // 0x10051
|
||||
PARAM_FETCOMP_RELEASE, // 0x10052
|
||||
PARAM_FETCOMP_AUTORELEASE_ENABLED, // 0x10053
|
||||
PARAM_FETCOMP_META_KNEEMULTI, // 0x10054
|
||||
PARAM_FETCOMP_META_MAXATTACK, // 0x10055
|
||||
PARAM_FETCOMP_META_MAXRELEASE, // 0x10056
|
||||
PARAM_FETCOMP_META_CREST, // 0x10057
|
||||
PARAM_FETCOMP_META_ADAPT, // 0x10058
|
||||
PARAM_FETCOMP_META_NOCLIP_ENABLED, // 0x10059
|
||||
};
|
||||
#define PARAM_CONVOLUTION_ENABLE 65538
|
||||
#define PARAM_CONVOLUTION_PREPARE_BUFFER 65540
|
||||
#define PARAM_CONVOLUTION_SET_BUFFER 65541
|
||||
#define PARAM_CONVOLUTION_COMMIT_BUFFER 65542
|
||||
#define PARAM_CONVOLUTION_CROSS_CHANNEL 65543
|
||||
|
||||
#define PARAM_HEADPHONE_SURROUND_ENABLE 65544
|
||||
#define PARAM_HEADPHONE_SURROUND_STRENGTH 65545
|
||||
|
||||
#define PARAM_DDC_ENABLE 65546
|
||||
#define PARAM_DDC_COEFFICIENTS 65547
|
||||
|
||||
#define PARAM_SPECTRUM_EXTENSION_ENABLE 65548
|
||||
#define PARAM_SPECTRUM_EXTENSION_BARK 65549 // Bark is a scale like dB
|
||||
#define PARAM_SPECTRUM_EXTENSION_BARK_RECONSTRUCT 65550
|
||||
|
||||
#define PARAM_FIR_EQUALIZER_ENABLE 65551
|
||||
#define PARAM_FIR_EQUALIZER_BAND_LEVEL 65552
|
||||
|
||||
#define PARAM_FIELD_SURROUND_ENABLE 65553
|
||||
#define PARAM_FIELD_SURROUND_WIDENING 65554
|
||||
#define PARAM_FIELD_SURROUND_MID_IMAGE 65555
|
||||
#define PARAM_FIELD_SURROUND_DEPTH 65556
|
||||
|
||||
#define PARAM_DIFFERENTIAL_SURROUND_ENABLE 65557
|
||||
#define PARAM_DIFFERENTIAL_SURROUND_DELAY 65558
|
||||
|
||||
#define PARAM_REVERBERATION_ENABLE 0x10017
|
||||
#define PARAM_REVERBERATION_ROOM_SIZE 0x10018
|
||||
#define PARAM_REVERBERATION_ROOM_WIDTH 0x10019
|
||||
#define PARAM_REVERBERATION_ROOM_DAMPENING 0x1001A
|
||||
#define PARAM_REVERBERATION_ROOM_WET_SIGNAL 0x1001B
|
||||
#define PARAM_REVERBERATION_ROOM_DRY_SIGNAL 0x1001C
|
||||
|
||||
#define PARAM_AUTOMATIC_GAIN_CONTROL_ENABLE 65565
|
||||
#define PARAM_AUTOMATIC_GAIN_CONTROL_RATIO 65566
|
||||
#define PARAM_AUTOMATIC_GAIN_CONTROL_VOLUME 65567
|
||||
#define PARAM_AUTOMATIC_GAIN_CONTROL_MAX_SCALER 65568
|
||||
|
||||
#define PARAM_DYNAMIC_SYSTEM_ENABLE 65569
|
||||
#define PARAM_DYNAMIC_SYSTEM_X_COEFFICIENTS 65570
|
||||
#define PARAM_DYNAMIC_SYSTEM_Y_COEFFICIENTS 65571
|
||||
#define PARAM_DYNAMIC_SYSTEM_SIDE_GAIN 65572
|
||||
#define PARAM_DYNAMIC_SYSTEM_STRENGTH 65573
|
||||
|
||||
#define PARAM_FIDELITY_BASS_ENABLE 65574
|
||||
#define PARAM_FIDELITY_BASS_MODE 65575
|
||||
#define PARAM_FIDELITY_BASS_FREQUENCY 65576
|
||||
#define PARAM_FIDELITY_BASS_GAIN 65577
|
||||
|
||||
#define PARAM_FIDELITY_CLARITY_ENABLE 65578
|
||||
#define PARAM_FIDELITY_CLARITY_MODE 65579
|
||||
#define PARAM_FIDELITY_CLARITY_GAIN 65580
|
||||
|
||||
#define PARAM_CURE_CROSS_FEED_ENABLED 65581
|
||||
#define PARAM_CURE_CROSS_FEED_STRENGTH 65582
|
||||
|
||||
#define PARAM_TUBE_SIMULATOR_ENABLED 65583
|
||||
|
||||
#define PARAM_ANALOGX_ENABLE 65584
|
||||
#define PARAM_ANALOGX_MODE 65585
|
||||
|
||||
#define PARAM_GATE_OUTPUT_VOLUME 65586
|
||||
#define PARAM_GATE_CHANNEL_PAN 65587
|
||||
#define PARAM_GATE_LIMIT 65588
|
||||
|
||||
#define PARAM_SPEAKER_OPTIMIZATION 65603
|
||||
|
||||
#define PARAM_FET_COMPRESSOR_ENABLE 65610
|
||||
#define PARAM_FET_COMPRESSOR_THRESHOLD 65611
|
||||
#define PARAM_FET_COMPRESSOR_RATIO 65612
|
||||
#define PARAM_FET_COMPRESSOR_KNEE 65613
|
||||
#define PARAM_FET_COMPRESSOR_AUTO_KNEE 65614
|
||||
#define PARAM_FET_COMPRESSOR_GAIN 65615
|
||||
#define PARAM_FET_COMPRESSOR_AUTO_GAIN 65616
|
||||
#define PARAM_FET_COMPRESSOR_ATTACK 65617
|
||||
#define PARAM_FET_COMPRESSOR_AUTO_ATTACK 65618
|
||||
#define PARAM_FET_COMPRESSOR_RELEASE 65619
|
||||
#define PARAM_FET_COMPRESSOR_AUTO_RELEASE 65620
|
||||
#define PARAM_FET_COMPRESSOR_KNEE_MULTI 65621
|
||||
#define PARAM_FET_COMPRESSOR_MAX_ATTACK 65622
|
||||
#define PARAM_FET_COMPRESSOR_MAX_RELEASE 65623
|
||||
#define PARAM_FET_COMPRESSOR_CREST 65624
|
||||
#define PARAM_FET_COMPRESSOR_ADAPT 65625
|
||||
#define PARAM_FET_COMPRESSOR_NO_CLIP 65626
|
||||
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ void ViPER::processBuffer(float *buffer, uint32_t size) {
|
||||
uint32_t tmpBufSize;
|
||||
|
||||
if (this->convolver->GetEnabled() || this->vhe->GetEnabled()) {
|
||||
VIPER_LOGD("Convolver or VHE is enable, use wave buffer");
|
||||
// VIPER_LOGD("Convolver or VHE is enable, use wave buffer");
|
||||
|
||||
if (!this->waveBuffer->PushSamples(buffer, size)) {
|
||||
this->waveBuffer->Reset();
|
||||
@ -181,7 +181,7 @@ void ViPER::processBuffer(float *buffer, uint32_t size) {
|
||||
tmpBuf = ptr;
|
||||
tmpBufSize = ret;
|
||||
} else {
|
||||
VIPER_LOGD("Convolver and VHE are disabled, use adaptive buffer");
|
||||
// VIPER_LOGD("Convolver and VHE are disabled, use adaptive buffer");
|
||||
|
||||
if (this->adaptiveBuffer->PushFrames(buffer, size)) {
|
||||
this->adaptiveBuffer->SetBufferOffset(size);
|
||||
@ -251,172 +251,177 @@ void ViPER::DispatchCommand(int param, int val1, int val2, int val3, int val4, u
|
||||
this->ResetAllEffects();
|
||||
break;
|
||||
}
|
||||
case PARAM_CONV_PROCESS_ENABLED: {
|
||||
case PARAM_CONVOLUTION_ENABLE: {
|
||||
// this->convolver->SetEnabled(val1 != 0);
|
||||
break;
|
||||
} // 0x10002
|
||||
case PARAM_CONV_UPDATEKERNEL: {
|
||||
// this->convolver->SetKernel(arr, arrSize);
|
||||
case PARAM_CONVOLUTION_PREPARE_BUFFER: {
|
||||
break;
|
||||
}
|
||||
case PARAM_CONV_CROSSCHANNEL: {
|
||||
} // 0x10004
|
||||
case PARAM_CONVOLUTION_SET_BUFFER: {
|
||||
break;
|
||||
} // 0x10005
|
||||
case PARAM_CONVOLUTION_COMMIT_BUFFER: {
|
||||
break;
|
||||
} // 0x10006
|
||||
case PARAM_CONVOLUTION_CROSS_CHANNEL: {
|
||||
this->convolver->SetCrossChannel((float) val1 / 100.0f);
|
||||
break;
|
||||
} // 0x10007
|
||||
case PARAM_VHE_PROCESS_ENABLED: {
|
||||
case PARAM_HEADPHONE_SURROUND_ENABLE: {
|
||||
this->vhe->SetEnable(val1 != 0);
|
||||
break;
|
||||
} // 0x10008
|
||||
case PARAM_VHE_EFFECT_LEVEL: {
|
||||
case PARAM_HEADPHONE_SURROUND_STRENGTH: {
|
||||
this->vhe->SetEffectLevel(val1);
|
||||
break;
|
||||
} // 0x10009
|
||||
case PARAM_VDDC_PROCESS_ENABLED: {
|
||||
case PARAM_DDC_ENABLE: {
|
||||
this->viperDdc->SetEnable(val1 != 0);
|
||||
break;
|
||||
} // 0x1000A
|
||||
case PARAM_VDDC_COEFFS: {
|
||||
case PARAM_DDC_COEFFICIENTS: {
|
||||
// TODO: Finish
|
||||
//this->viperDdc->SetCoeffs();
|
||||
break;
|
||||
} // 0x1000B
|
||||
case PARAM_VSE_PROCESS_ENABLED: {
|
||||
case PARAM_SPECTRUM_EXTENSION_ENABLE: {
|
||||
this->spectrumExtend->SetEnable(val1 != 0);
|
||||
break;
|
||||
} // 0x1000C
|
||||
case PARAM_VSE_REFERENCE_BARK: {
|
||||
case PARAM_SPECTRUM_EXTENSION_BARK: {
|
||||
this->spectrumExtend->SetReferenceFrequency(val1);
|
||||
break;
|
||||
} // 0x1000D
|
||||
case PARAM_VSE_BARK_RECONSTRUCT: {
|
||||
case PARAM_SPECTRUM_EXTENSION_BARK_RECONSTRUCT: {
|
||||
this->spectrumExtend->SetExciter((float) val1 / 100.0f);
|
||||
break;
|
||||
} // 0x1000E
|
||||
case PARAM_FIREQ_PROCESS_ENABLED: {
|
||||
case PARAM_FIR_EQUALIZER_ENABLE: {
|
||||
this->iirFilter->SetEnable(val1 != 0);
|
||||
break;
|
||||
} // 0x1000F
|
||||
case PARAM_FIREQ_BANDLEVEL: {
|
||||
case PARAM_FIR_EQUALIZER_BAND_LEVEL: {
|
||||
this->iirFilter->SetBandLevel(val1, (float) val2 / 100.0f);
|
||||
break;
|
||||
} // 0x10010
|
||||
case PARAM_COLM_PROCESS_ENABLED: {
|
||||
case PARAM_FIELD_SURROUND_ENABLE: {
|
||||
this->colorfulMusic->SetEnable(val1 != 0);
|
||||
break;
|
||||
} // 0x10011
|
||||
case PARAM_COLM_WIDENING: {
|
||||
case PARAM_FIELD_SURROUND_WIDENING: {
|
||||
this->colorfulMusic->SetWidenValue((float) val1 / 100.0f);
|
||||
break;
|
||||
} // 0x10012
|
||||
case PARAM_COLM_MIDIMAGE: {
|
||||
case PARAM_FIELD_SURROUND_MID_IMAGE: {
|
||||
this->colorfulMusic->SetMidImageValue((float) val1 / 100.0f);
|
||||
break;
|
||||
} // 0x10013
|
||||
case PARAM_COLM_DEPTH: {
|
||||
case PARAM_FIELD_SURROUND_DEPTH: {
|
||||
this->colorfulMusic->SetDepthValue((short) val1);
|
||||
break;
|
||||
} // 0x10014
|
||||
case PARAM_DIFFSURR_PROCESS_ENABLED: {
|
||||
case PARAM_DIFFERENTIAL_SURROUND_ENABLE: {
|
||||
this->diffSurround->SetEnable(val1 != 0);
|
||||
break;
|
||||
} // 0x10015
|
||||
case PARAM_DIFFSURR_DELAYTIME: {
|
||||
case PARAM_DIFFERENTIAL_SURROUND_DELAY: {
|
||||
this->diffSurround->SetDelayTime((float) val1 / 100.0f);
|
||||
break;
|
||||
} // 0x10016
|
||||
case PARAM_REVB_PROCESS_ENABLED: {
|
||||
case PARAM_REVERBERATION_ENABLE: {
|
||||
this->reverberation->SetEnable(val1 != 0);
|
||||
break;
|
||||
} // 0x10017
|
||||
case PARAM_REVB_ROOMSIZE: {
|
||||
case PARAM_REVERBERATION_ROOM_SIZE: {
|
||||
this->reverberation->SetRoomSize((float) val1 / 100.0f);
|
||||
break;
|
||||
} // 0x10018
|
||||
case PARAM_REVB_WIDTH: {
|
||||
case PARAM_REVERBERATION_ROOM_WIDTH: {
|
||||
this->reverberation->SetWidth((float) val1 / 100.0f);
|
||||
break;
|
||||
} // 0x10019
|
||||
case PARAM_REVB_DAMP: {
|
||||
case PARAM_REVERBERATION_ROOM_DAMPENING: {
|
||||
this->reverberation->SetDamp((float) val1 / 100.0f);
|
||||
break;
|
||||
} // 0x1001A
|
||||
case PARAM_REVB_WET: {
|
||||
case PARAM_REVERBERATION_ROOM_WET_SIGNAL: {
|
||||
this->reverberation->SetWet((float) val1 / 100.0f);
|
||||
break;
|
||||
} // 0x1001B
|
||||
case PARAM_REVB_DRY: {
|
||||
case PARAM_REVERBERATION_ROOM_DRY_SIGNAL: {
|
||||
this->reverberation->SetDry((float) val1 / 100.0f);
|
||||
break;
|
||||
} // 0x1001C
|
||||
case PARAM_AGC_PROCESS_ENABLED: {
|
||||
case PARAM_AUTOMATIC_GAIN_CONTROL_ENABLE: {
|
||||
this->playbackGain->SetEnable(val1 != 0);
|
||||
break;
|
||||
} // 0x1001D
|
||||
case PARAM_AGC_RATIO: {
|
||||
case PARAM_AUTOMATIC_GAIN_CONTROL_RATIO: {
|
||||
this->playbackGain->SetRatio((float) val1 / 100.0f);
|
||||
break;
|
||||
} // 0x1001E
|
||||
case PARAM_AGC_VOLUME: {
|
||||
case PARAM_AUTOMATIC_GAIN_CONTROL_VOLUME: {
|
||||
this->playbackGain->SetVolume((float) val1 / 100.0f);
|
||||
break;
|
||||
} // 0x1001F
|
||||
case PARAM_AGC_MAXSCALER: {
|
||||
case PARAM_AUTOMATIC_GAIN_CONTROL_MAX_SCALER: {
|
||||
this->playbackGain->SetMaxGainFactor((float) val1 / 100.0f);
|
||||
break;
|
||||
} // 0x10020
|
||||
case PARAM_DYNSYS_PROCESS_ENABLED: {
|
||||
case PARAM_DYNAMIC_SYSTEM_ENABLE: {
|
||||
this->dynamicSystem->SetEnable(val1 != 0);
|
||||
break;
|
||||
} // 0x10021
|
||||
case PARAM_DYNSYS_XCOEFFS: {
|
||||
case PARAM_DYNAMIC_SYSTEM_X_COEFFICIENTS: {
|
||||
this->dynamicSystem->SetXCoeffs(val1, val2);
|
||||
break;
|
||||
} // 0x10022
|
||||
case PARAM_DYNSYS_YCOEFFS: {
|
||||
case PARAM_DYNAMIC_SYSTEM_Y_COEFFICIENTS: {
|
||||
this->dynamicSystem->SetYCoeffs(val1, val2);
|
||||
break;
|
||||
} // 0x10023
|
||||
case PARAM_DYNSYS_SIDEGAIN: {
|
||||
case PARAM_DYNAMIC_SYSTEM_SIDE_GAIN: {
|
||||
this->dynamicSystem->SetSideGain((float) val1 / 100.0f, (float) val2 / 100.0f);
|
||||
break;
|
||||
} // 0x10024
|
||||
case PARAM_DYNSYS_BASSGAIN: {
|
||||
case PARAM_DYNAMIC_SYSTEM_STRENGTH: {
|
||||
this->dynamicSystem->SetBassGain((float) val1 / 100.0f);
|
||||
break;
|
||||
} // 0x10025
|
||||
case PARAM_VIPERBASS_PROCESS_ENABLED: {
|
||||
case PARAM_FIDELITY_BASS_ENABLE: {
|
||||
this->viperBass->SetEnable(val1 != 0);
|
||||
break;
|
||||
} // 0x10026
|
||||
case PARAM_VIPERBASS_MODE: {
|
||||
case PARAM_FIDELITY_BASS_MODE: {
|
||||
this->viperBass->SetProcessMode((ViPERBass::ProcessMode) val1);
|
||||
break;
|
||||
} // 0x10027
|
||||
case PARAM_VIPERBASS_SPEAKER: {
|
||||
case PARAM_FIDELITY_BASS_FREQUENCY: {
|
||||
this->viperBass->SetSpeaker(val1);
|
||||
break;
|
||||
} // 0x10028
|
||||
case PARAM_VIPERBASS_BASSGAIN: {
|
||||
case PARAM_FIDELITY_BASS_GAIN: {
|
||||
this->viperBass->SetBassFactor((float) val1 / 100.0f);
|
||||
break;
|
||||
} // 0x10029
|
||||
case PARAM_VIPERCLARITY_PROCESS_ENABLED: {
|
||||
case PARAM_FIDELITY_CLARITY_ENABLE: {
|
||||
this->viperClarity->SetEnable(val1 != 0);
|
||||
break;
|
||||
} // 0x1002A
|
||||
case PARAM_VIPERCLARITY_MODE: {
|
||||
case PARAM_FIDELITY_CLARITY_MODE: {
|
||||
this->viperClarity->SetProcessMode((ViPERClarity::ClarityMode) val1);
|
||||
break;
|
||||
} // 0x1002B
|
||||
case PARAM_VIPERCLARITY_CLARITY: {
|
||||
case PARAM_FIDELITY_CLARITY_GAIN: {
|
||||
this->viperClarity->SetClarity((float) val1 / 100.0f);
|
||||
break;
|
||||
} // 0x1002C
|
||||
case PARAM_CURE_PROCESS_ENABLED: {
|
||||
case PARAM_CURE_CROSS_FEED_ENABLED: {
|
||||
this->cure->SetEnable(val1 != 0);
|
||||
break;
|
||||
} // 0x1002D
|
||||
case PARAM_CURE_CROSSFEED: {
|
||||
case PARAM_CURE_CROSS_FEED_STRENGTH: {
|
||||
switch (val1) {
|
||||
case 0:
|
||||
// Cure_R::SetPreset(pCVar17,0x5f028a);
|
||||
@ -430,11 +435,11 @@ void ViPER::DispatchCommand(int param, int val1, int val2, int val3, int val4, u
|
||||
}
|
||||
break;
|
||||
} // 0x1002E
|
||||
case PARAM_TUBE_PROCESS_ENABLED: {
|
||||
case PARAM_TUBE_SIMULATOR_ENABLED: {
|
||||
this->tubeSimulator->SetEnable(val1 != 0);
|
||||
break;
|
||||
} // 0x1002F
|
||||
case PARAM_ANALOGX_PROCESS_ENABLED: {
|
||||
case PARAM_ANALOGX_ENABLE: {
|
||||
this->analogX->SetEnable(val1 != 0);
|
||||
break;
|
||||
} // 0x10030
|
||||
@ -442,11 +447,11 @@ void ViPER::DispatchCommand(int param, int val1, int val2, int val3, int val4, u
|
||||
this->analogX->SetProcessingModel(val1);
|
||||
break;
|
||||
} // 0x10031
|
||||
case PARAM_OUTPUT_VOLUME: {
|
||||
case PARAM_GATE_OUTPUT_VOLUME: {
|
||||
this->frameScale = (float) val1 / 100.0f;
|
||||
break;
|
||||
} // 0x10032
|
||||
case PARAM_OUTPUT_PAN: {
|
||||
case PARAM_GATE_CHANNEL_PAN: {
|
||||
float tmp = (float) val1 / 100.0f;
|
||||
if (tmp < 0.0f) {
|
||||
this->leftPan = 1.0f;
|
||||
@ -457,67 +462,67 @@ void ViPER::DispatchCommand(int param, int val1, int val2, int val3, int val4, u
|
||||
}
|
||||
break;
|
||||
} // 0x10033
|
||||
case PARAM_LIMITER_THRESHOLD: {
|
||||
case PARAM_GATE_LIMIT: {
|
||||
this->softwareLimiters[0]->SetGate((float) val1 / 100.0f);
|
||||
this->softwareLimiters[1]->SetGate((float) val1 / 100.0f);
|
||||
break;
|
||||
} // 0x10034
|
||||
case PARAM_SPKFX_AGC_PROCESS_ENABLED: {
|
||||
case PARAM_SPEAKER_OPTIMIZATION: {
|
||||
this->speakerCorrection->SetEnable(val1 != 0);
|
||||
break;
|
||||
} // 0x10043
|
||||
case PARAM_FETCOMP_PROCESS_ENABLED: {
|
||||
case PARAM_FET_COMPRESSOR_ENABLE: {
|
||||
break;
|
||||
} // 0x10049
|
||||
case PARAM_FETCOMP_THRESHOLD: {
|
||||
case PARAM_FET_COMPRESSOR_THRESHOLD: {
|
||||
break;
|
||||
} // 0x1004A
|
||||
case PARAM_FETCOMP_RATIO: {
|
||||
case PARAM_FET_COMPRESSOR_RATIO: {
|
||||
this->fetCompressor->SetParameter(FETCompressor::THRESHOLD, (float) val1 / 100.0f);
|
||||
break;
|
||||
} // 0x1004B
|
||||
case PARAM_FETCOMP_KNEEWIDTH: {
|
||||
case PARAM_FET_COMPRESSOR_KNEE: {
|
||||
break;
|
||||
} // 0x1004C
|
||||
case PARAM_FETCOMP_AUTOKNEE_ENABLED: {
|
||||
case PARAM_FET_COMPRESSOR_AUTO_KNEE: {
|
||||
break;
|
||||
} // 0x1004D
|
||||
case PARAM_FETCOMP_GAIN: {
|
||||
case PARAM_FET_COMPRESSOR_GAIN: {
|
||||
break;
|
||||
} // 0x1004E
|
||||
case PARAM_FETCOMP_AUTOGAIN_ENABLED: {
|
||||
case PARAM_FET_COMPRESSOR_AUTO_GAIN: {
|
||||
this->fetCompressor->SetParameter(FETCompressor::GAIN, (float) val1 / 100.0f);
|
||||
break;
|
||||
} // 0x1004F
|
||||
case PARAM_FETCOMP_ATTACK: {
|
||||
case PARAM_FET_COMPRESSOR_ATTACK: {
|
||||
break;
|
||||
} // 0x10050
|
||||
case PARAM_FETCOMP_AUTOATTACK_ENABLED: {
|
||||
case PARAM_FET_COMPRESSOR_AUTO_ATTACK: {
|
||||
break;
|
||||
} // 0x10051
|
||||
case PARAM_FETCOMP_RELEASE: {
|
||||
case PARAM_FET_COMPRESSOR_RELEASE: {
|
||||
break;
|
||||
} // 0x10052
|
||||
case PARAM_FETCOMP_AUTORELEASE_ENABLED: {
|
||||
case PARAM_FET_COMPRESSOR_AUTO_RELEASE: {
|
||||
break;
|
||||
} // 0x10053
|
||||
case PARAM_FETCOMP_META_KNEEMULTI: {
|
||||
case PARAM_FET_COMPRESSOR_KNEE_MULTI: {
|
||||
break;
|
||||
} // 0x10054
|
||||
case PARAM_FETCOMP_META_MAXATTACK: {
|
||||
case PARAM_FET_COMPRESSOR_MAX_ATTACK: {
|
||||
break;
|
||||
} // 0x10055
|
||||
case PARAM_FETCOMP_META_MAXRELEASE: {
|
||||
case PARAM_FET_COMPRESSOR_MAX_RELEASE: {
|
||||
this->fetCompressor->SetParameter(FETCompressor::MAX_ATTACK, (float) val1 / 100.0f);
|
||||
break;
|
||||
} // 0x10056
|
||||
case PARAM_FETCOMP_META_CREST: {
|
||||
case PARAM_FET_COMPRESSOR_CREST: {
|
||||
break;
|
||||
} // 0x10057
|
||||
case PARAM_FETCOMP_META_ADAPT: {
|
||||
case PARAM_FET_COMPRESSOR_ADAPT: {
|
||||
break;
|
||||
} // 0x10058
|
||||
case PARAM_FETCOMP_META_NOCLIP_ENABLED: {
|
||||
case PARAM_FET_COMPRESSOR_NO_CLIP: {
|
||||
this->fetCompressor->SetParameter(FETCompressor::ADAPT, (float) val1 / 100.0f);
|
||||
break;
|
||||
} // 0x10059
|
||||
|
@ -4,18 +4,16 @@
|
||||
ColorfulMusic::ColorfulMusic() {
|
||||
this->samplingRate = VIPER_DEFAULT_SAMPLING_RATE;
|
||||
this->enabled = false;
|
||||
this->stereo3DSurround.SetStereoWiden(0.0f);
|
||||
this->stereo3dSurround.SetStereoWiden(0.0);
|
||||
this->depthSurround.SetSamplingRate(this->samplingRate);
|
||||
this->depthSurround.SetStrength(0);
|
||||
}
|
||||
|
||||
void ColorfulMusic::Process(float *samples, uint32_t size) {
|
||||
if (!this->enabled) {
|
||||
return;
|
||||
}
|
||||
if (!this->enabled) return;
|
||||
|
||||
this->depthSurround.Process(samples, size);
|
||||
this->stereo3DSurround.Process(samples, size);
|
||||
this->stereo3dSurround.Process(samples, size);
|
||||
}
|
||||
|
||||
void ColorfulMusic::Reset() {
|
||||
@ -28,15 +26,15 @@ void ColorfulMusic::SetDepthValue(short depthValue) {
|
||||
|
||||
void ColorfulMusic::SetEnable(bool enable) {
|
||||
if (this->enabled != enable) {
|
||||
this->enabled = enable;
|
||||
if (enable) {
|
||||
if (!this->enabled) {
|
||||
Reset();
|
||||
}
|
||||
this->enabled = enable;
|
||||
}
|
||||
}
|
||||
|
||||
void ColorfulMusic::SetMidImageValue(float midImageValue) {
|
||||
this->stereo3DSurround.SetMiddleImage(midImageValue);
|
||||
this->stereo3dSurround.SetMiddleImage(midImageValue);
|
||||
}
|
||||
|
||||
void ColorfulMusic::SetSamplingRate(uint32_t samplingRate) {
|
||||
@ -47,5 +45,5 @@ void ColorfulMusic::SetSamplingRate(uint32_t samplingRate) {
|
||||
}
|
||||
|
||||
void ColorfulMusic::SetWidenValue(float widenValue) {
|
||||
this->stereo3DSurround.SetStereoWiden(widenValue);
|
||||
this->stereo3dSurround.SetStereoWiden(widenValue);
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ public:
|
||||
void SetWidenValue(float widenValue);
|
||||
|
||||
private:
|
||||
Stereo3DSurround stereo3DSurround;
|
||||
Stereo3DSurround stereo3dSurround;
|
||||
DepthSurround depthSurround;
|
||||
uint32_t samplingRate;
|
||||
bool enabled;
|
||||
|
@ -5,36 +5,6 @@ Cure::Cure() {
|
||||
Reset();
|
||||
}
|
||||
|
||||
Cure::~Cure() {
|
||||
|
||||
}
|
||||
|
||||
void Cure::Process(float *buffer, uint32_t size) {
|
||||
if (this->enabled) {
|
||||
this->crossfeed.ProcessFrames(buffer, size);
|
||||
this->pass.ProcessFrames(buffer, size);
|
||||
}
|
||||
}
|
||||
|
||||
void Cure::Reset() {
|
||||
this->crossfeed.Reset();
|
||||
this->pass.Reset();
|
||||
}
|
||||
|
||||
void Cure::SetEnable(bool enabled) {
|
||||
if (this->enabled != enabled) {
|
||||
this->enabled = enabled;
|
||||
if (enabled) {
|
||||
Reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Cure::SetSamplingRate(uint32_t samplingRate) {
|
||||
this->crossfeed.SetSamplingRate(samplingRate);
|
||||
this->pass.SetSamplingRate(samplingRate);
|
||||
}
|
||||
|
||||
uint16_t Cure::GetCutoff() {
|
||||
return this->crossfeed.GetCutoff();
|
||||
}
|
||||
@ -51,10 +21,31 @@ struct Crossfeed::Preset Cure::GetPreset() {
|
||||
return this->crossfeed.GetPreset();
|
||||
}
|
||||
|
||||
void Cure::Process(float *buffer, uint32_t size) {
|
||||
if (this->enabled) {
|
||||
this->crossfeed.ProcessFrames(buffer, size);
|
||||
this->passFilter.ProcessFrames(buffer, size);
|
||||
}
|
||||
}
|
||||
|
||||
void Cure::Reset() {
|
||||
this->crossfeed.Reset();
|
||||
this->passFilter.Reset();
|
||||
}
|
||||
|
||||
void Cure::SetCutoff(uint16_t cutoff) {
|
||||
this->crossfeed.SetCutoff(cutoff);
|
||||
}
|
||||
|
||||
void Cure::SetEnable(bool enabled) {
|
||||
if (this->enabled != enabled) {
|
||||
this->enabled = enabled;
|
||||
if (enabled) {
|
||||
Reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Cure::SetFeedback(float feedback) {
|
||||
this->crossfeed.SetFeedback(feedback);
|
||||
}
|
||||
@ -63,3 +54,7 @@ void Cure::SetPreset(struct Crossfeed::Preset preset) {
|
||||
this->crossfeed.SetPreset(preset);
|
||||
}
|
||||
|
||||
void Cure::SetSamplingRate(uint32_t samplingRate) {
|
||||
this->crossfeed.SetSamplingRate(samplingRate);
|
||||
this->passFilter.SetSamplingRate(samplingRate);
|
||||
}
|
||||
|
@ -7,7 +7,6 @@
|
||||
class Cure {
|
||||
public:
|
||||
Cure();
|
||||
~Cure();
|
||||
|
||||
uint16_t GetCutoff();
|
||||
float GetFeedback();
|
||||
@ -21,7 +20,8 @@ public:
|
||||
void SetPreset(struct Crossfeed::Preset preset);
|
||||
void SetSamplingRate(uint32_t samplingRate);
|
||||
|
||||
private:
|
||||
Crossfeed crossfeed;
|
||||
PassFilter pass;
|
||||
PassFilter passFilter;
|
||||
bool enabled;
|
||||
};
|
||||
|
@ -9,6 +9,7 @@ DiffSurround::DiffSurround() {
|
||||
for (auto &buffer : this->buffers) {
|
||||
buffer = new WaveBuffer(1, 0x1000);
|
||||
}
|
||||
Reset();
|
||||
}
|
||||
|
||||
DiffSurround::~DiffSurround() {
|
||||
@ -42,11 +43,10 @@ void DiffSurround::Process(float *samples, uint32_t size) {
|
||||
}
|
||||
|
||||
void DiffSurround::Reset() {
|
||||
for (auto &buffer : this->buffers) {
|
||||
buffer->Reset();
|
||||
}
|
||||
this->buffers[0]->Reset();
|
||||
this->buffers[1]->Reset();
|
||||
|
||||
this->buffers[1]->PushZeros((uint32_t) (this->delayTime / 1000.0f * (float) this->samplingRate));
|
||||
this->buffers[1]->PushZeros((uint32_t) ((double) this->delayTime / 1000.0 * (double) this->samplingRate));
|
||||
}
|
||||
|
||||
void DiffSurround::SetDelayTime(float delayTime) {
|
||||
@ -58,10 +58,10 @@ void DiffSurround::SetDelayTime(float delayTime) {
|
||||
|
||||
void DiffSurround::SetEnable(bool enabled) {
|
||||
if (this->enabled != enabled) {
|
||||
this->enabled = enabled;
|
||||
if (enabled) {
|
||||
if (!this->enabled) {
|
||||
Reset();
|
||||
}
|
||||
this->enabled = enabled;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,55 +2,51 @@
|
||||
#include "../constants.h"
|
||||
|
||||
DynamicSystem::DynamicSystem() {
|
||||
this->enabled = false;
|
||||
this->samplingRate = VIPER_DEFAULT_SAMPLING_RATE;
|
||||
this->bass.SetSamplingRate(this->samplingRate);
|
||||
this->bass.Reset();
|
||||
this->enable = false;
|
||||
this->dynamicBass.SetSamplingRate(this->samplingRate);
|
||||
this->dynamicBass.Reset();
|
||||
}
|
||||
|
||||
void DynamicSystem::Process(float *samples, uint32_t size) {
|
||||
if (this->enabled) {
|
||||
this->bass.FilterSamples(samples, size);
|
||||
}
|
||||
if (!this->enable) return;
|
||||
|
||||
this->dynamicBass.FilterSamples(samples, size);
|
||||
}
|
||||
|
||||
void DynamicSystem::Reset() {
|
||||
this->bass.SetSamplingRate(this->samplingRate);
|
||||
this->bass.Reset();
|
||||
this->dynamicBass.SetSamplingRate(this->samplingRate);
|
||||
this->dynamicBass.Reset();
|
||||
}
|
||||
|
||||
void DynamicSystem::SetBassGain(float gain) {
|
||||
this->bass.SetBassGain(gain);
|
||||
this->dynamicBass.SetBassGain(gain);
|
||||
}
|
||||
|
||||
void DynamicSystem::SetEnable(bool enable) {
|
||||
if (this->enabled != enable) {
|
||||
this->enabled = enable;
|
||||
if (enable) {
|
||||
if (this->enable != enable) {
|
||||
if (!this->enable) {
|
||||
Reset();
|
||||
}
|
||||
this->enable = enable;
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicSystem::SetSideGain(float gainX, float gainY) {
|
||||
this->bass.SetSideGain(gainX, gainY);
|
||||
}
|
||||
|
||||
void DynamicSystem::SetXCoeffs(uint32_t low, uint32_t high) {
|
||||
this->bass.SetFilterXPassFrequency(low, high);
|
||||
}
|
||||
|
||||
void DynamicSystem::SetYCoeffs(uint32_t low, uint32_t high) {
|
||||
this->bass.SetFilterYPassFrequency(low, high);
|
||||
}
|
||||
|
||||
void DynamicSystem::SetSamplingRate(uint32_t samplingRate) {
|
||||
if (this->samplingRate != samplingRate) {
|
||||
this->samplingRate = samplingRate;
|
||||
this->bass.SetSamplingRate(samplingRate);
|
||||
this->dynamicBass.SetSamplingRate(samplingRate);
|
||||
}
|
||||
}
|
||||
|
||||
DynamicSystem::~DynamicSystem() {
|
||||
|
||||
void DynamicSystem::SetSideGain(float gainX, float gainY) {
|
||||
this->dynamicBass.SetSideGain(gainX, gainY);
|
||||
}
|
||||
|
||||
void DynamicSystem::SetXCoeffs(uint32_t low, uint32_t high) {
|
||||
this->dynamicBass.SetFilterXPassFrequency(low, high);
|
||||
}
|
||||
|
||||
void DynamicSystem::SetYCoeffs(uint32_t low, uint32_t high) {
|
||||
this->dynamicBass.SetFilterYPassFrequency(low, high);
|
||||
}
|
||||
|
@ -6,7 +6,6 @@
|
||||
class DynamicSystem {
|
||||
public:
|
||||
DynamicSystem();
|
||||
~DynamicSystem();
|
||||
|
||||
void Process(float *samples, uint32_t size);
|
||||
void Reset();
|
||||
@ -17,9 +16,10 @@ public:
|
||||
void SetXCoeffs(uint32_t low, uint32_t high);
|
||||
void SetYCoeffs(uint32_t low, uint32_t high);
|
||||
|
||||
DynamicBass bass;
|
||||
private:
|
||||
DynamicBass dynamicBass;
|
||||
uint32_t samplingRate;
|
||||
bool enabled;
|
||||
bool enable;
|
||||
};
|
||||
|
||||
|
||||
|
@ -66,6 +66,7 @@ float FETCompressor::GetParameterDefault(FETCompressor::Parameter parameter) {
|
||||
}
|
||||
|
||||
void FETCompressor::Process(float *samples, uint32_t size) {
|
||||
return;
|
||||
if (size == 0) return;
|
||||
|
||||
for (uint32_t i = 0; i < size * 2; i += 2) {
|
||||
|
@ -13,43 +13,11 @@ Crossfeed::Crossfeed() {
|
||||
this->b1_hi = 0.f;
|
||||
this->gain = 0.f;
|
||||
memset(&this->lfs, 0, 6 * sizeof(float));
|
||||
this->samplerate = VIPER_DEFAULT_SAMPLING_RATE;
|
||||
this->samplingRate = VIPER_DEFAULT_SAMPLING_RATE;
|
||||
this->preset.cutoff = 700;
|
||||
this->preset.feedback = 45;
|
||||
}
|
||||
|
||||
void Crossfeed::Reset() {
|
||||
uint16_t cutoff = this->preset.cutoff;
|
||||
uint16_t level = this->preset.feedback;
|
||||
|
||||
level /= 10.0;
|
||||
|
||||
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 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;
|
||||
|
||||
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 (uint32_t 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))
|
||||
|
||||
@ -75,7 +43,7 @@ float Crossfeed::GetFeedback() {
|
||||
}
|
||||
|
||||
float Crossfeed::GetLevelDelay() {
|
||||
if (this->preset.cutoff <= 1800) {
|
||||
if (this->preset.cutoff <= 1800) { // TODO: Previous version reports <= 2000
|
||||
return (float) ((18700.0 / (double) this->preset.cutoff) * 10.0);
|
||||
} else {
|
||||
return 0.0;
|
||||
@ -86,6 +54,38 @@ struct Crossfeed::Preset Crossfeed::GetPreset() {
|
||||
return this->preset;
|
||||
}
|
||||
|
||||
void Crossfeed::ProcessFrames(float *buffer, uint32_t size) {
|
||||
for (uint32_t i = 0; i < size; i += 2) {
|
||||
FilterSample(&buffer[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void Crossfeed::Reset() {
|
||||
uint16_t cutoff = this->preset.cutoff;
|
||||
uint16_t level = this->preset.feedback;
|
||||
|
||||
level /= 10.0;
|
||||
|
||||
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 x = exp(-2.0 * M_PI * cutoff / this->samplingRate);
|
||||
this->b1_lo = (float) x;
|
||||
this->a0_lo = (float) (G_lo * (1.0 - x));
|
||||
|
||||
x = exp(-2.0 * M_PI * Fc_hi / this->samplingRate);
|
||||
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));
|
||||
}
|
||||
|
||||
void Crossfeed::SetCutoff(uint16_t cutoff) {
|
||||
this->preset.cutoff = cutoff;
|
||||
Reset();
|
||||
@ -102,6 +102,8 @@ void Crossfeed::SetPreset(struct Crossfeed::Preset preset) {
|
||||
}
|
||||
|
||||
void Crossfeed::SetSamplingRate(uint32_t samplingRate) {
|
||||
this->samplerate = samplingRate;
|
||||
Reset();
|
||||
if (this->samplingRate != samplingRate) {
|
||||
this->samplingRate = samplingRate;
|
||||
Reset();
|
||||
}
|
||||
}
|
||||
|
@ -12,28 +12,19 @@ public:
|
||||
Crossfeed();
|
||||
|
||||
void Reset();
|
||||
|
||||
void ProcessFrames(float *buffer, uint32_t size);
|
||||
|
||||
void FilterSample(float *sample);
|
||||
|
||||
uint16_t GetCutoff();
|
||||
|
||||
float GetFeedback();
|
||||
|
||||
float GetLevelDelay();
|
||||
|
||||
struct Preset GetPreset();
|
||||
|
||||
void SetCutoff(uint16_t cutoff);
|
||||
|
||||
void SetFeedback(float feedback);
|
||||
|
||||
void SetPreset(struct Preset preset);
|
||||
|
||||
void SetSamplingRate(uint32_t samplingRate);
|
||||
|
||||
uint32_t samplerate;
|
||||
private:
|
||||
uint32_t samplingRate;
|
||||
float a0_lo, b1_lo;
|
||||
float a0_hi, b1_hi, a1_hi;
|
||||
float gain;
|
||||
|
@ -7,37 +7,21 @@ public:
|
||||
IIR_1st();
|
||||
|
||||
void Mute();
|
||||
|
||||
void SetCoefficients(float b0, float b1, float a1);
|
||||
|
||||
void setHPF_A(float frequency, uint32_t samplingRate);
|
||||
|
||||
void setHPF_BW(float frequency, uint32_t samplingRate);
|
||||
|
||||
void setHPF_C(float frequency, uint32_t samplingRate);
|
||||
|
||||
void setHPFwLPS_A(float frequency, uint32_t samplingRate);
|
||||
|
||||
void setHSF_A(float f1, float f2, uint32_t samplingRate);
|
||||
|
||||
void setLPF_A(float frequency, uint32_t samplingRate);
|
||||
|
||||
void setLPF_BW(float frequency, uint32_t samplingRate);
|
||||
|
||||
void setLPF_C(float frequency, uint32_t samplingRate);
|
||||
|
||||
void setLSF_A(float f1, float f2, uint32_t samplingRate);
|
||||
|
||||
void setPole(float a1);
|
||||
|
||||
void setPoleHPF(float frequency, uint32_t samplingRate);
|
||||
|
||||
void setPoleLPF(float frequency, uint32_t samplingRate);
|
||||
|
||||
void setZero(float b1);
|
||||
|
||||
void setZeroHPF(float frequency, uint32_t samplingRate);
|
||||
|
||||
void setZeroLPF(float frequency, uint32_t samplingRate);
|
||||
|
||||
float b0, b1, a1;
|
||||
|
@ -9,11 +9,10 @@ public:
|
||||
~IIR_NOrder_BW_LH();
|
||||
|
||||
void Mute();
|
||||
|
||||
void setLPF(float frequency, uint32_t samplingRate);
|
||||
|
||||
void setHPF(float frequency, uint32_t samplingRate);
|
||||
|
||||
|
||||
IIR_1st *filters;
|
||||
uint32_t order;
|
||||
};
|
||||
|
@ -17,25 +17,6 @@ PassFilter::~PassFilter() {
|
||||
delete this->filters[3];
|
||||
}
|
||||
|
||||
void PassFilter::Reset() {
|
||||
uint32_t cutoff;
|
||||
if (this->samplingRate < 44100) {
|
||||
cutoff = this->samplingRate - 100;
|
||||
} else {
|
||||
cutoff = 18000;
|
||||
}
|
||||
|
||||
this->filters[0]->setLPF((float) cutoff, this->samplingRate);
|
||||
this->filters[1]->setLPF((float) cutoff, this->samplingRate);
|
||||
this->filters[2]->setLPF(10.f, cutoff);
|
||||
this->filters[3]->setLPF(10.f, cutoff);
|
||||
|
||||
this->filters[0]->Mute();
|
||||
this->filters[1]->Mute();
|
||||
this->filters[2]->Mute();
|
||||
this->filters[3]->Mute();
|
||||
}
|
||||
|
||||
void PassFilter::ProcessFrames(float *buffer, uint32_t size) {
|
||||
for (uint32_t x = 0; x < size; x++) {
|
||||
float left = buffer[2 * x];
|
||||
@ -51,7 +32,28 @@ void PassFilter::ProcessFrames(float *buffer, uint32_t size) {
|
||||
}
|
||||
}
|
||||
|
||||
void PassFilter::SetSamplingRate(uint32_t samplingRate) {
|
||||
this->samplingRate = samplingRate;
|
||||
Reset();
|
||||
void PassFilter::Reset() {
|
||||
float cutoff;
|
||||
if (this->samplingRate < 44100) {
|
||||
cutoff = (float) this->samplingRate - 100.0f;
|
||||
} else {
|
||||
cutoff = 18000.0;
|
||||
}
|
||||
|
||||
this->filters[0]->setLPF(cutoff, this->samplingRate);
|
||||
this->filters[1]->setLPF(cutoff, this->samplingRate);
|
||||
this->filters[2]->setHPF(10.0, this->samplingRate);
|
||||
this->filters[3]->setHPF(10.0, this->samplingRate);
|
||||
|
||||
this->filters[0]->Mute();
|
||||
this->filters[1]->Mute();
|
||||
this->filters[2]->Mute();
|
||||
this->filters[3]->Mute();
|
||||
}
|
||||
|
||||
void PassFilter::SetSamplingRate(uint32_t samplingRate) {
|
||||
if (this->samplingRate != samplingRate) {
|
||||
this->samplingRate = samplingRate;
|
||||
Reset();
|
||||
}
|
||||
}
|
||||
|
@ -6,15 +6,13 @@
|
||||
class PassFilter {
|
||||
public:
|
||||
PassFilter();
|
||||
|
||||
~PassFilter();
|
||||
|
||||
void Reset();
|
||||
|
||||
void ProcessFrames(float *buffer, uint32_t size);
|
||||
|
||||
void SetSamplingRate(uint32_t samplingRate);
|
||||
|
||||
private:
|
||||
IIR_NOrder_BW_LH *filters[4];
|
||||
uint32_t samplingRate;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user