This commit is contained in:
Iscle 2022-10-13 03:01:20 +02:00
parent f0e899ab3a
commit d5a7ba77be
32 changed files with 407 additions and 455 deletions

View File

@ -21,79 +21,72 @@ extern "C" {
#define PARAM_SET_RESET_STATUS 0x9003 #define PARAM_SET_RESET_STATUS 0x9003
enum ParamsSet { enum ParamsSet {
PARAM_FX_TYPE_SWITCH = 0x10001, // 0x10001 PARAM_CONV_PROCESS_ENABLED = 0x10002, // 0x10002
PARAM_HPFX_CONV_PROCESS_ENABLED, // 0x10002 PARAM_CONV_UPDATEKERNEL, // 0x10003
PARAM_HPFX_CONV_UPDATEKERNEL, // 0x10003 PARAM_CONV_CROSSCHANNEL = 0x10007, // 0x10007
/*****************************************/ PARAM_VHE_PROCESS_ENABLED, // 0x10008
// Please use PARAM_HPFX_CONV_UPDATEKERNEL instead PARAM_VHE_EFFECT_LEVEL, // 0x10009
PARAM_HPFX_CONV_PREPAREBUFFER, // 0x10004 PARAM_VDDC_PROCESS_ENABLED, // 0x1000A
PARAM_HPFX_CONV_SETBUFFER, // 0x10005 PARAM_VDDC_COEFFS, // 0x1000B
PARAM_HPFX_CONV_COMMITBUFFER, // 0x10006 PARAM_VSE_PROCESS_ENABLED, // 0x1000C
/*****************************************/ PARAM_VSE_REFERENCE_BARK, // 0x1000D
PARAM_HPFX_CONV_CROSSCHANNEL, // 0x10007 PARAM_VSE_BARK_RECONSTRUCT, // 0x1000E
PARAM_HPFX_VHE_PROCESS_ENABLED, // 0x10008 PARAM_FIREQ_PROCESS_ENABLED, // 0x1000F
PARAM_HPFX_VHE_EFFECT_LEVEL, // 0x10009 PARAM_FIREQ_BANDLEVEL, // 0x10010
PARAM_HPFX_VDDC_PROCESS_ENABLED, // 0x1000A PARAM_COLM_PROCESS_ENABLED, // 0x10011
PARAM_HPFX_VDDC_COEFFS, // 0x1000B PARAM_COLM_WIDENING, // 0x10012
PARAM_HPFX_VSE_PROCESS_ENABLED, // 0x1000C PARAM_COLM_MIDIMAGE, // 0x10013
PARAM_HPFX_VSE_REFERENCE_BARK, // 0x1000D PARAM_COLM_DEPTH, // 0x10014
PARAM_HPFX_VSE_BARK_RECONSTRUCT, // 0x1000E PARAM_DIFFSURR_PROCESS_ENABLED, // 0x10015
PARAM_HPFX_FIREQ_PROCESS_ENABLED, // 0x1000F PARAM_DIFFSURR_DELAYTIME, // 0x10016
PARAM_HPFX_FIREQ_BANDLEVEL, // 0x10010 PARAM_REVB_PROCESS_ENABLED, // 0x10017
PARAM_HPFX_COLM_PROCESS_ENABLED, // 0x10011 PARAM_REVB_ROOMSIZE, // 0x10018
PARAM_HPFX_COLM_WIDENING, // 0x10012 PARAM_REVB_WIDTH, // 0x10019
PARAM_HPFX_COLM_MIDIMAGE, // 0x10013 PARAM_REVB_DAMP, // 0x1001A
PARAM_HPFX_COLM_DEPTH, // 0x10014 PARAM_REVB_WET, // 0x1001B
PARAM_HPFX_DIFFSURR_PROCESS_ENABLED, // 0x10015 PARAM_REVB_DRY, // 0x1001C
PARAM_HPFX_DIFFSURR_DELAYTIME, // 0x10016 PARAM_AGC_PROCESS_ENABLED, // 0x1001D
PARAM_HPFX_REVB_PROCESS_ENABLED, // 0x10017 PARAM_AGC_RATIO, // 0x1001E
PARAM_HPFX_REVB_ROOMSIZE, // 0x10018 PARAM_AGC_VOLUME, // 0x1001F
PARAM_HPFX_REVB_WIDTH, // 0x10019 PARAM_AGC_MAXSCALER, // 0x10020
PARAM_HPFX_REVB_DAMP, // 0x1001A PARAM_DYNSYS_PROCESS_ENABLED, // 0x10021
PARAM_HPFX_REVB_WET, // 0x1001B PARAM_DYNSYS_XCOEFFS, // 0x10022
PARAM_HPFX_REVB_DRY, // 0x1001C PARAM_DYNSYS_YCOEFFS, // 0x10023
PARAM_HPFX_AGC_PROCESS_ENABLED, // 0x1001D PARAM_DYNSYS_SIDEGAIN, // 0x10024
PARAM_HPFX_AGC_RATIO, // 0x1001E PARAM_DYNSYS_BASSGAIN, // 0x10025
PARAM_HPFX_AGC_VOLUME, // 0x1001F PARAM_VIPERBASS_PROCESS_ENABLED, // 0x10026
PARAM_HPFX_AGC_MAXSCALER, // 0x10020 PARAM_VIPERBASS_MODE, // 0x10027
PARAM_HPFX_DYNSYS_PROCESS_ENABLED, // 0x10021 PARAM_VIPERBASS_SPEAKER, // 0x10028
PARAM_HPFX_DYNSYS_XCOEFFS, // 0x10022 PARAM_VIPERBASS_BASSGAIN, // 0x10029
PARAM_HPFX_DYNSYS_YCOEFFS, // 0x10023 PARAM_VIPERCLARITY_PROCESS_ENABLED, // 0x1002A
PARAM_HPFX_DYNSYS_SIDEGAIN, // 0x10024 PARAM_VIPERCLARITY_MODE, // 0x1002B
PARAM_HPFX_DYNSYS_BASSGAIN, // 0x10025 PARAM_VIPERCLARITY_CLARITY, // 0x1002C
PARAM_HPFX_VIPERBASS_PROCESS_ENABLED, // 0x10026 PARAM_CURE_PROCESS_ENABLED, // 0x1002D
PARAM_HPFX_VIPERBASS_MODE, // 0x10027 PARAM_CURE_CROSSFEED, // 0x1002E
PARAM_HPFX_VIPERBASS_SPEAKER, // 0x10028 PARAM_TUBE_PROCESS_ENABLED, // 0x1002F
PARAM_HPFX_VIPERBASS_BASSGAIN, // 0x10029 PARAM_ANALOGX_PROCESS_ENABLED, // 0x10030
PARAM_HPFX_VIPERCLARITY_PROCESS_ENABLED, // 0x1002A PARAM_ANALOGX_MODE, // 0x10031
PARAM_HPFX_VIPERCLARITY_MODE, // 0x1002B PARAM_OUTPUT_VOLUME, // 0x10032
PARAM_HPFX_VIPERCLARITY_CLARITY, // 0x1002C PARAM_OUTPUT_PAN, // 0x10033
PARAM_HPFX_CURE_PROCESS_ENABLED, // 0x1002D PARAM_LIMITER_THRESHOLD, // 0x10034
PARAM_HPFX_CURE_CROSSFEED, // 0x1002E PARAM_SPKFX_AGC_PROCESS_ENABLED = 0x10043, // 0x10043
PARAM_HPFX_TUBE_PROCESS_ENABLED, // 0x1002F PARAM_FETCOMP_PROCESS_ENABLED = 0x10049, // 0x10049
PARAM_HPFX_ANALOGX_PROCESS_ENABLED, // 0x10030 PARAM_FETCOMP_THRESHOLD, // 0x1004A
PARAM_HPFX_ANALOGX_MODE, // 0x10031 PARAM_FETCOMP_RATIO, // 0x1004B
PARAM_HPFX_OUTPUT_VOLUME, // 0x10032 PARAM_FETCOMP_KNEEWIDTH, // 0x1004C
PARAM_HPFX_OUTPUT_PAN, // 0x10033 PARAM_FETCOMP_AUTOKNEE_ENABLED, // 0x1004D
PARAM_HPFX_LIMITER_THRESHOLD, // 0x10034 PARAM_FETCOMP_GAIN, // 0x1004E
PARAM_SPKFX_AGC_PROCESS_ENABLED, // 0x10043 PARAM_FETCOMP_AUTOGAIN_ENABLED, // 0x1004F
PARAM_HPFX_FETCOMP_PROCESS_ENABLED, // 0x10049 PARAM_FETCOMP_ATTACK, // 0x10050
PARAM_HPFX_FETCOMP_THRESHOLD, // 0x1004A PARAM_FETCOMP_AUTOATTACK_ENABLED, // 0x10051
PARAM_HPFX_FETCOMP_RATIO, // 0x1004B PARAM_FETCOMP_RELEASE, // 0x10052
PARAM_HPFX_FETCOMP_KNEEWIDTH, // 0x1004C PARAM_FETCOMP_AUTORELEASE_ENABLED, // 0x10053
PARAM_HPFX_FETCOMP_AUTOKNEE_ENABLED, // 0x1004D PARAM_FETCOMP_META_KNEEMULTI, // 0x10054
PARAM_HPFX_FETCOMP_GAIN, // 0x1004E PARAM_FETCOMP_META_MAXATTACK, // 0x10055
PARAM_HPFX_FETCOMP_AUTOGAIN_ENABLED, // 0x1004F PARAM_FETCOMP_META_MAXRELEASE, // 0x10056
PARAM_HPFX_FETCOMP_ATTACK, // 0x10050 PARAM_FETCOMP_META_CREST, // 0x10057
PARAM_HPFX_FETCOMP_AUTOATTACK_ENABLED, // 0x10051 PARAM_FETCOMP_META_ADAPT, // 0x10058
PARAM_HPFX_FETCOMP_RELEASE, // 0x10052 PARAM_FETCOMP_META_NOCLIP_ENABLED, // 0x10059
PARAM_HPFX_FETCOMP_AUTORELEASE_ENABLED, // 0x10053
PARAM_HPFX_FETCOMP_META_KNEEMULTI, // 0x10054
PARAM_HPFX_FETCOMP_META_MAXATTACK, // 0x10055
PARAM_HPFX_FETCOMP_META_MAXRELEASE, // 0x10056
PARAM_HPFX_FETCOMP_META_CREST, // 0x10057
PARAM_HPFX_FETCOMP_META_ADAPT, // 0x10058
PARAM_HPFX_FETCOMP_META_NOCLIP_ENABLED, // 0x10059
}; };
} }

View File

@ -7,7 +7,7 @@ ViPER::ViPER() {
VIPER_LOGI("Welcome to ViPER FX"); VIPER_LOGI("Welcome to ViPER FX");
VIPER_LOGI("Current version is %s %s", VERSION_STRING, VERSION_CODENAME); VIPER_LOGI("Current version is %s %s", VERSION_STRING, VERSION_CODENAME);
this->samplingRate = DEFAULT_SAMPLERATE; this->samplingRate = VIPER_DEFAULT_SAMPLING_RATE;
this->adaptiveBuffer = new AdaptiveBuffer(2, 4096); this->adaptiveBuffer = new AdaptiveBuffer(2, 4096);
this->waveBuffer = new WaveBuffer(2, 4096); this->waveBuffer = new WaveBuffer(2, 4096);
@ -46,7 +46,6 @@ ViPER::ViPER() {
this->reverberation = new Reverberation(); this->reverberation = new Reverberation();
this->reverberation->SetEnable(false); this->reverberation->SetEnable(false);
this->reverberation->SetSamplingRate(this->samplingRate);
this->reverberation->Reset(); this->reverberation->Reset();
this->playbackGain = new PlaybackGain(); this->playbackGain = new PlaybackGain();
@ -252,180 +251,172 @@ void ViPER::DispatchCommand(int param, int val1, int val2, int val3, int val4, u
this->ResetAllEffects(); this->ResetAllEffects();
break; break;
} }
case PARAM_HPFX_CONV_PROCESS_ENABLED: { case PARAM_CONV_PROCESS_ENABLED: {
// this->convolver->SetEnabled(val1 != 0); // this->convolver->SetEnabled(val1 != 0);
break; break;
} // 0x10002 } // 0x10002
case PARAM_HPFX_CONV_PREPAREBUFFER: { case PARAM_CONV_UPDATEKERNEL: {
this->convolver->PrepareKernelBuffer(val1, val2, val3); // this->convolver->SetKernel(arr, arrSize);
break; break;
} // 0x10004 }
case PARAM_HPFX_CONV_SETBUFFER: { case PARAM_CONV_CROSSCHANNEL: {
this->convolver->SetKernelBuffer(val1, (float *) arr, arrSize);
break;
} // 0x10005
case PARAM_HPFX_CONV_COMMITBUFFER: {
this->convolver->CommitKernelBuffer(val1, val2, val3);
break;
} // 0x10006
case PARAM_HPFX_CONV_CROSSCHANNEL: {
this->convolver->SetCrossChannel((float) val1 / 100.0f); this->convolver->SetCrossChannel((float) val1 / 100.0f);
break; break;
} // 0x10007 } // 0x10007
case PARAM_HPFX_VHE_PROCESS_ENABLED: { case PARAM_VHE_PROCESS_ENABLED: {
this->vhe->SetEnable(val1 != 0); this->vhe->SetEnable(val1 != 0);
break; break;
} // 0x10008 } // 0x10008
case PARAM_HPFX_VHE_EFFECT_LEVEL: { case PARAM_VHE_EFFECT_LEVEL: {
this->vhe->SetEffectLevel(val1); this->vhe->SetEffectLevel(val1);
break; break;
} // 0x10009 } // 0x10009
case PARAM_HPFX_VDDC_PROCESS_ENABLED: { case PARAM_VDDC_PROCESS_ENABLED: {
this->viperDdc->SetEnable(val1 != 0); this->viperDdc->SetEnable(val1 != 0);
break; break;
} // 0x1000A } // 0x1000A
case PARAM_HPFX_VDDC_COEFFS: { case PARAM_VDDC_COEFFS: {
// TODO: Finish // TODO: Finish
//this->viperDdc->SetCoeffs(); //this->viperDdc->SetCoeffs();
break; break;
} // 0x1000B } // 0x1000B
case PARAM_HPFX_VSE_PROCESS_ENABLED: { case PARAM_VSE_PROCESS_ENABLED: {
this->spectrumExtend->SetEnable(val1 != 0); this->spectrumExtend->SetEnable(val1 != 0);
break; break;
} // 0x1000C } // 0x1000C
case PARAM_HPFX_VSE_REFERENCE_BARK: { case PARAM_VSE_REFERENCE_BARK: {
this->spectrumExtend->SetReferenceFrequency(val1); this->spectrumExtend->SetReferenceFrequency(val1);
break; break;
} // 0x1000D } // 0x1000D
case PARAM_HPFX_VSE_BARK_RECONSTRUCT: { case PARAM_VSE_BARK_RECONSTRUCT: {
this->spectrumExtend->SetExciter((float) val1 / 100.0f); this->spectrumExtend->SetExciter((float) val1 / 100.0f);
break; break;
} // 0x1000E } // 0x1000E
case PARAM_HPFX_FIREQ_PROCESS_ENABLED: { case PARAM_FIREQ_PROCESS_ENABLED: {
this->iirFilter->SetEnable(val1 != 0); this->iirFilter->SetEnable(val1 != 0);
break; break;
} // 0x1000F } // 0x1000F
case PARAM_HPFX_FIREQ_BANDLEVEL: { case PARAM_FIREQ_BANDLEVEL: {
this->iirFilter->SetBandLevel(val1, (float) val2 / 100.0f); this->iirFilter->SetBandLevel(val1, (float) val2 / 100.0f);
break; break;
} // 0x10010 } // 0x10010
case PARAM_HPFX_COLM_PROCESS_ENABLED: { case PARAM_COLM_PROCESS_ENABLED: {
this->colorfulMusic->SetEnable(val1 != 0); this->colorfulMusic->SetEnable(val1 != 0);
break; break;
} // 0x10011 } // 0x10011
case PARAM_HPFX_COLM_WIDENING: { case PARAM_COLM_WIDENING: {
this->colorfulMusic->SetWidenValue((float) val1 / 100.0f); this->colorfulMusic->SetWidenValue((float) val1 / 100.0f);
break; break;
} // 0x10012 } // 0x10012
case PARAM_HPFX_COLM_MIDIMAGE: { case PARAM_COLM_MIDIMAGE: {
this->colorfulMusic->SetMidImageValue((float) val1 / 100.0f); this->colorfulMusic->SetMidImageValue((float) val1 / 100.0f);
break; break;
} // 0x10013 } // 0x10013
case PARAM_HPFX_COLM_DEPTH: { case PARAM_COLM_DEPTH: {
this->colorfulMusic->SetDepthValue((short) val1); this->colorfulMusic->SetDepthValue((short) val1);
break; break;
} // 0x10014 } // 0x10014
case PARAM_HPFX_DIFFSURR_PROCESS_ENABLED: { case PARAM_DIFFSURR_PROCESS_ENABLED: {
this->diffSurround->SetEnable(val1 != 0); this->diffSurround->SetEnable(val1 != 0);
break; break;
} // 0x10015 } // 0x10015
case PARAM_HPFX_DIFFSURR_DELAYTIME: { case PARAM_DIFFSURR_DELAYTIME: {
this->diffSurround->SetDelayTime((float) val1 / 100.0f); this->diffSurround->SetDelayTime((float) val1 / 100.0f);
break; break;
} // 0x10016 } // 0x10016
case PARAM_HPFX_REVB_PROCESS_ENABLED: { case PARAM_REVB_PROCESS_ENABLED: {
this->reverberation->SetEnable(val1 != 0); this->reverberation->SetEnable(val1 != 0);
break; break;
} // 0x10017 } // 0x10017
case PARAM_HPFX_REVB_ROOMSIZE: { case PARAM_REVB_ROOMSIZE: {
this->reverberation->SetRoomSize((float) val1 / 100.0f); this->reverberation->SetRoomSize((float) val1 / 100.0f);
break; break;
} // 0x10018 } // 0x10018
case PARAM_HPFX_REVB_WIDTH: { case PARAM_REVB_WIDTH: {
this->reverberation->SetWidth((float) val1 / 100.0f); this->reverberation->SetWidth((float) val1 / 100.0f);
break; break;
} // 0x10019 } // 0x10019
case PARAM_HPFX_REVB_DAMP: { case PARAM_REVB_DAMP: {
this->reverberation->SetDamp((float) val1 / 100.0f); this->reverberation->SetDamp((float) val1 / 100.0f);
break; break;
} // 0x1001A } // 0x1001A
case PARAM_HPFX_REVB_WET: { case PARAM_REVB_WET: {
this->reverberation->SetWet((float) val1 / 100.0f); this->reverberation->SetWet((float) val1 / 100.0f);
break; break;
} // 0x1001B } // 0x1001B
case PARAM_HPFX_REVB_DRY: { case PARAM_REVB_DRY: {
this->reverberation->SetDry((float) val1 / 100.0f); this->reverberation->SetDry((float) val1 / 100.0f);
break; break;
} // 0x1001C } // 0x1001C
case PARAM_HPFX_AGC_PROCESS_ENABLED: { case PARAM_AGC_PROCESS_ENABLED: {
this->playbackGain->SetEnable(val1 != 0); this->playbackGain->SetEnable(val1 != 0);
break; break;
} // 0x1001D } // 0x1001D
case PARAM_HPFX_AGC_RATIO: { case PARAM_AGC_RATIO: {
this->playbackGain->SetRatio((float) val1 / 100.0f); this->playbackGain->SetRatio((float) val1 / 100.0f);
break; break;
} // 0x1001E } // 0x1001E
case PARAM_HPFX_AGC_VOLUME: { case PARAM_AGC_VOLUME: {
this->playbackGain->SetVolume((float) val1 / 100.0f); this->playbackGain->SetVolume((float) val1 / 100.0f);
break; break;
} // 0x1001F } // 0x1001F
case PARAM_HPFX_AGC_MAXSCALER: { case PARAM_AGC_MAXSCALER: {
this->playbackGain->SetMaxGainFactor((float) val1 / 100.0f); this->playbackGain->SetMaxGainFactor((float) val1 / 100.0f);
break; break;
} // 0x10020 } // 0x10020
case PARAM_HPFX_DYNSYS_PROCESS_ENABLED: { case PARAM_DYNSYS_PROCESS_ENABLED: {
this->dynamicSystem->SetEnable(val1 != 0); this->dynamicSystem->SetEnable(val1 != 0);
break; break;
} // 0x10021 } // 0x10021
case PARAM_HPFX_DYNSYS_XCOEFFS: { case PARAM_DYNSYS_XCOEFFS: {
this->dynamicSystem->SetXCoeffs(val1, val2); this->dynamicSystem->SetXCoeffs(val1, val2);
break; break;
} // 0x10022 } // 0x10022
case PARAM_HPFX_DYNSYS_YCOEFFS: { case PARAM_DYNSYS_YCOEFFS: {
this->dynamicSystem->SetYCoeffs(val1, val2); this->dynamicSystem->SetYCoeffs(val1, val2);
break; break;
} // 0x10023 } // 0x10023
case PARAM_HPFX_DYNSYS_SIDEGAIN: { case PARAM_DYNSYS_SIDEGAIN: {
this->dynamicSystem->SetSideGain((float) val1 / 100.0f, (float) val2 / 100.0f); this->dynamicSystem->SetSideGain((float) val1 / 100.0f, (float) val2 / 100.0f);
break; break;
} // 0x10024 } // 0x10024
case PARAM_HPFX_DYNSYS_BASSGAIN: { case PARAM_DYNSYS_BASSGAIN: {
this->dynamicSystem->SetBassGain((float) val1 / 100.0f); this->dynamicSystem->SetBassGain((float) val1 / 100.0f);
break; break;
} // 0x10025 } // 0x10025
case PARAM_HPFX_VIPERBASS_PROCESS_ENABLED: { case PARAM_VIPERBASS_PROCESS_ENABLED: {
this->viperBass->SetEnable(val1 != 0); this->viperBass->SetEnable(val1 != 0);
break; break;
} // 0x10026 } // 0x10026
case PARAM_HPFX_VIPERBASS_MODE: { case PARAM_VIPERBASS_MODE: {
this->viperBass->SetProcessMode((ViPERBass::ProcessMode) val1); this->viperBass->SetProcessMode((ViPERBass::ProcessMode) val1);
break; break;
} // 0x10027 } // 0x10027
case PARAM_HPFX_VIPERBASS_SPEAKER: { case PARAM_VIPERBASS_SPEAKER: {
this->viperBass->SetSpeaker(val1); this->viperBass->SetSpeaker(val1);
break; break;
} // 0x10028 } // 0x10028
case PARAM_HPFX_VIPERBASS_BASSGAIN: { case PARAM_VIPERBASS_BASSGAIN: {
this->viperBass->SetBassFactor((float) val1 / 100.0f); this->viperBass->SetBassFactor((float) val1 / 100.0f);
break; break;
} // 0x10029 } // 0x10029
case PARAM_HPFX_VIPERCLARITY_PROCESS_ENABLED: { case PARAM_VIPERCLARITY_PROCESS_ENABLED: {
this->viperClarity->SetEnable(val1 != 0); this->viperClarity->SetEnable(val1 != 0);
break; break;
} // 0x1002A } // 0x1002A
case PARAM_HPFX_VIPERCLARITY_MODE: { case PARAM_VIPERCLARITY_MODE: {
this->viperClarity->SetProcessMode((ViPERClarity::ClarityMode) val1); this->viperClarity->SetProcessMode((ViPERClarity::ClarityMode) val1);
break; break;
} // 0x1002B } // 0x1002B
case PARAM_HPFX_VIPERCLARITY_CLARITY: { case PARAM_VIPERCLARITY_CLARITY: {
this->viperClarity->SetClarity((float) val1 / 100.0f); this->viperClarity->SetClarity((float) val1 / 100.0f);
break; break;
} // 0x1002C } // 0x1002C
case PARAM_HPFX_CURE_PROCESS_ENABLED: { case PARAM_CURE_PROCESS_ENABLED: {
this->cure->SetEnable(val1 != 0); this->cure->SetEnable(val1 != 0);
break; break;
} // 0x1002D } // 0x1002D
case PARAM_HPFX_CURE_CROSSFEED: { case PARAM_CURE_CROSSFEED: {
switch (val1) { switch (val1) {
case 0: case 0:
// Cure_R::SetPreset(pCVar17,0x5f028a); // Cure_R::SetPreset(pCVar17,0x5f028a);
@ -439,23 +430,23 @@ void ViPER::DispatchCommand(int param, int val1, int val2, int val3, int val4, u
} }
break; break;
} // 0x1002E } // 0x1002E
case PARAM_HPFX_TUBE_PROCESS_ENABLED: { case PARAM_TUBE_PROCESS_ENABLED: {
this->tubeSimulator->SetEnable(val1 != 0); this->tubeSimulator->SetEnable(val1 != 0);
break; break;
} // 0x1002F } // 0x1002F
case PARAM_HPFX_ANALOGX_PROCESS_ENABLED: { case PARAM_ANALOGX_PROCESS_ENABLED: {
this->analogX->SetEnable(val1 != 0); this->analogX->SetEnable(val1 != 0);
break; break;
} // 0x10030 } // 0x10030
case PARAM_HPFX_ANALOGX_MODE: { case PARAM_ANALOGX_MODE: {
this->analogX->SetProcessingModel(val1); this->analogX->SetProcessingModel(val1);
break; break;
} // 0x10031 } // 0x10031
case PARAM_HPFX_OUTPUT_VOLUME: { case PARAM_OUTPUT_VOLUME: {
this->frameScale = (float) val1 / 100.0f; this->frameScale = (float) val1 / 100.0f;
break; break;
} // 0x10032 } // 0x10032
case PARAM_HPFX_OUTPUT_PAN: { case PARAM_OUTPUT_PAN: {
float tmp = (float) val1 / 100.0f; float tmp = (float) val1 / 100.0f;
if (tmp < 0.0f) { if (tmp < 0.0f) {
this->leftPan = 1.0f; this->leftPan = 1.0f;
@ -466,7 +457,7 @@ void ViPER::DispatchCommand(int param, int val1, int val2, int val3, int val4, u
} }
break; break;
} // 0x10033 } // 0x10033
case PARAM_HPFX_LIMITER_THRESHOLD: { case PARAM_LIMITER_THRESHOLD: {
this->softwareLimiters[0]->SetGate((float) val1 / 100.0f); this->softwareLimiters[0]->SetGate((float) val1 / 100.0f);
this->softwareLimiters[1]->SetGate((float) val1 / 100.0f); this->softwareLimiters[1]->SetGate((float) val1 / 100.0f);
break; break;
@ -475,58 +466,58 @@ void ViPER::DispatchCommand(int param, int val1, int val2, int val3, int val4, u
this->speakerCorrection->SetEnable(val1 != 0); this->speakerCorrection->SetEnable(val1 != 0);
break; break;
} // 0x10043 } // 0x10043
case PARAM_HPFX_FETCOMP_PROCESS_ENABLED: { case PARAM_FETCOMP_PROCESS_ENABLED: {
break; break;
} // 0x10049 } // 0x10049
case PARAM_HPFX_FETCOMP_THRESHOLD: { case PARAM_FETCOMP_THRESHOLD: {
break; break;
} // 0x1004A } // 0x1004A
case PARAM_HPFX_FETCOMP_RATIO: { case PARAM_FETCOMP_RATIO: {
this->fetCompressor->SetParameter(1, (float) val1 / 100.0f); this->fetCompressor->SetParameter(1, (float) val1 / 100.0f);
break; break;
} // 0x1004B } // 0x1004B
case PARAM_HPFX_FETCOMP_KNEEWIDTH: { case PARAM_FETCOMP_KNEEWIDTH: {
break; break;
} // 0x1004C } // 0x1004C
case PARAM_HPFX_FETCOMP_AUTOKNEE_ENABLED: { case PARAM_FETCOMP_AUTOKNEE_ENABLED: {
break; break;
} // 0x1004D } // 0x1004D
case PARAM_HPFX_FETCOMP_GAIN: { case PARAM_FETCOMP_GAIN: {
break; break;
} // 0x1004E } // 0x1004E
case PARAM_HPFX_FETCOMP_AUTOGAIN_ENABLED: { case PARAM_FETCOMP_AUTOGAIN_ENABLED: {
this->fetCompressor->SetParameter(5, (float) val1 / 100.0f); this->fetCompressor->SetParameter(5, (float) val1 / 100.0f);
break; break;
} // 0x1004F } // 0x1004F
case PARAM_HPFX_FETCOMP_ATTACK: { case PARAM_FETCOMP_ATTACK: {
break; break;
} // 0x10050 } // 0x10050
case PARAM_HPFX_FETCOMP_AUTOATTACK_ENABLED: { case PARAM_FETCOMP_AUTOATTACK_ENABLED: {
break; break;
} // 0x10051 } // 0x10051
case PARAM_HPFX_FETCOMP_RELEASE: { case PARAM_FETCOMP_RELEASE: {
break; break;
} // 0x10052 } // 0x10052
case PARAM_HPFX_FETCOMP_AUTORELEASE_ENABLED: { case PARAM_FETCOMP_AUTORELEASE_ENABLED: {
break; break;
} // 0x10053 } // 0x10053
case PARAM_HPFX_FETCOMP_META_KNEEMULTI: { case PARAM_FETCOMP_META_KNEEMULTI: {
break; break;
} // 0x10054 } // 0x10054
case PARAM_HPFX_FETCOMP_META_MAXATTACK: { case PARAM_FETCOMP_META_MAXATTACK: {
break; break;
} // 0x10055 } // 0x10055
case PARAM_HPFX_FETCOMP_META_MAXRELEASE: { case PARAM_FETCOMP_META_MAXRELEASE: {
this->fetCompressor->SetParameter(12, (float) val1 / 100.0f); this->fetCompressor->SetParameter(12, (float) val1 / 100.0f);
break; break;
} // 0x10056 } // 0x10056
case PARAM_HPFX_FETCOMP_META_CREST: { case PARAM_FETCOMP_META_CREST: {
break; break;
} // 0x10057 } // 0x10057
case PARAM_HPFX_FETCOMP_META_ADAPT: { case PARAM_FETCOMP_META_ADAPT: {
break; break;
} // 0x10058 } // 0x10058
case PARAM_HPFX_FETCOMP_META_NOCLIP_ENABLED: { case PARAM_FETCOMP_META_NOCLIP_ENABLED: {
this->fetCompressor->SetParameter(15, (float) val1 / 100.0f); this->fetCompressor->SetParameter(15, (float) val1 / 100.0f);
break; break;
} // 0x10059 } // 0x10059
@ -565,7 +556,6 @@ void ViPER::ResetAllEffects() {
this->colorfulMusic->Reset(); this->colorfulMusic->Reset();
} }
if (this->reverberation != nullptr) { if (this->reverberation != nullptr) {
this->reverberation->SetSamplingRate(this->samplingRate);
this->reverberation->Reset(); this->reverberation->Reset();
} }
if (this->playbackGain != nullptr) { if (this->playbackGain != nullptr) {

View File

@ -12,5 +12,5 @@
#define STR(x) STR_HELPER(x) #define STR(x) STR_HELPER(x)
#define VERSION_STRING "v" STR(VERSION_MAJOR) "." STR(VERSION_MINOR) #define VERSION_STRING "v" STR(VERSION_MAJOR) "." STR(VERSION_MINOR)
#define DEFAULT_SAMPLERATE 44100 #define VIPER_DEFAULT_SAMPLING_RATE 44100
#define VIPER_AUTHORS "viper.WYF, Martmists, Iscle" #define VIPER_AUTHORS "viper.WYF, Martmists, Iscle"

View File

@ -16,7 +16,7 @@ static float ANALOGX_HARMONICS[10] = {
}; };
AnalogX::AnalogX() { AnalogX::AnalogX() {
this->samplingRate = DEFAULT_SAMPLERATE; this->samplingRate = VIPER_DEFAULT_SAMPLING_RATE;
this->processingModel = 0; this->processingModel = 0;
this->enable = false; this->enable = false;
Reset(); Reset();
@ -28,7 +28,7 @@ void AnalogX::Process(float *samples, uint32_t size) {
float sample = samples[i]; float sample = samples[i];
int channel = i % 2; int channel = i % 2;
float tmp = this->highpass[channel].ProcessSample(sample); double tmp = this->highpass[channel].ProcessSample(sample);
tmp = this->harmonic[channel].Process(tmp); tmp = this->harmonic[channel].Process(tmp);
tmp = this->lowpass[channel].ProcessSample(sample + tmp * this->gain); tmp = this->lowpass[channel].ProcessSample(sample + tmp * this->gain);

View File

@ -2,7 +2,7 @@
#include "../constants.h" #include "../constants.h"
ColorfulMusic::ColorfulMusic() { ColorfulMusic::ColorfulMusic() {
this->samplingRate = DEFAULT_SAMPLERATE; this->samplingRate = VIPER_DEFAULT_SAMPLING_RATE;
this->enabled = false; this->enabled = false;
this->stereo3DSurround.SetStereoWiden(0.0f); this->stereo3DSurround.SetStereoWiden(0.0f);
this->depthSurround.SetSamplingRate(this->samplingRate); this->depthSurround.SetSamplingRate(this->samplingRate);

View File

@ -3,7 +3,7 @@
#include "../constants.h" #include "../constants.h"
DiffSurround::DiffSurround() { DiffSurround::DiffSurround() {
this->samplingRate = DEFAULT_SAMPLERATE; this->samplingRate = VIPER_DEFAULT_SAMPLING_RATE;
this->delayTime = 0.0f; this->delayTime = 0.0f;
this->enabled = false; this->enabled = false;
for (auto &buffer : this->buffers) { for (auto &buffer : this->buffers) {

View File

@ -3,7 +3,7 @@
DynamicSystem::DynamicSystem() { DynamicSystem::DynamicSystem() {
this->enabled = false; this->enabled = false;
this->samplingRate = DEFAULT_SAMPLERATE; this->samplingRate = VIPER_DEFAULT_SAMPLING_RATE;
this->bass.SetSamplingRate(this->samplingRate); this->bass.SetSamplingRate(this->samplingRate);
this->bass.Reset(); this->bass.Reset();
} }

View File

@ -5,7 +5,7 @@
IIRFilter::IIRFilter(uint32_t bands) { IIRFilter::IIRFilter(uint32_t bands) {
this->enable = false; this->enable = false;
this->samplingRate = DEFAULT_SAMPLERATE; this->samplingRate = VIPER_DEFAULT_SAMPLING_RATE;
if (bands == 10 || bands == 15 || bands == 25 || bands == 31) { if (bands == 10 || bands == 15 || bands == 25 || bands == 31) {
this->bands = bands; this->bands = bands;
this->minPhaseIirCoeffs.UpdateCoeffs(this->bands, this->samplingRate); this->minPhaseIirCoeffs.UpdateCoeffs(this->bands, this->samplingRate);

View File

@ -3,7 +3,7 @@
PlaybackGain::PlaybackGain() { PlaybackGain::PlaybackGain() {
this->enable = false; this->enable = false;
this->samplingRate = DEFAULT_SAMPLERATE; this->samplingRate = VIPER_DEFAULT_SAMPLING_RATE;
this->unknown1 = 0.4342945; this->unknown1 = 0.4342945;
this->counterTo100 = 0; this->counterTo100 = 0;
this->ratio1 = 2.0; this->ratio1 = 2.0;

View File

@ -2,69 +2,51 @@
#include "../constants.h" #include "../constants.h"
Reverberation::Reverberation() { Reverberation::Reverberation() {
this->roomsize = 0.f; this->model.SetRoomSize(0.0);
this->width = 0.f; this->model.SetWidth(0.0);
this->damp = 0.f; this->model.SetDamp(0.0);
this->wet = 0.f; this->model.SetWet(0.0);
this->dry = 0.5f; this->model.SetDry(0.5);
this->model.Reset();
this->model.SetRoomSize(0.f); this->enable = false;
this->model.SetWidth(0.f); }
this->model.SetDamp(0.f);
this->model.SetWet(0.f);
this->model.SetDry(0.5f);
this->samplingRate = DEFAULT_SAMPLERATE; void Reverberation::Process(float *buffer, uint32_t size) {
this->enabled = false; if (this->enable) {
this->model.ProcessReplace(buffer, buffer + 1, size);
}
} }
void Reverberation::Reset() { void Reverberation::Reset() {
this->model.Reset(); this->model.Reset();
} }
void Reverberation::Process(float *buffer, uint32_t size) {
if (this->enabled) {
this->model.ProcessReplace(buffer, &buffer[1], size);
}
}
void Reverberation::SetEnable(bool enable) {
if (!this->enabled && enable) {
Reset();
}
this->enabled = enable;
}
void Reverberation::SetRoomSize(float value) {
this->roomsize = value;
this->model.SetRoomSize(value);
}
void Reverberation::SetDamp(float value) { void Reverberation::SetDamp(float value) {
this->damp = value;
this->model.SetDamp(value); this->model.SetDamp(value);
} }
void Reverberation::SetWet(float value) {
this->wet = value;
this->model.SetWet(value);
}
void Reverberation::SetDry(float value) { void Reverberation::SetDry(float value) {
this->dry = value;
this->model.SetDry(value); this->model.SetDry(value);
} }
void Reverberation::SetEnable(bool enable) {
if (this->enable != enable) {
if (!this->enable) {
Reset();
}
this->enable = enable;
}
}
void Reverberation::SetRoomSize(float value) {
this->model.SetRoomSize(value);
}
void Reverberation::SetWet(float value) {
this->model.SetWet(value);
}
void Reverberation::SetWidth(float value) { void Reverberation::SetWidth(float value) {
this->width = value;
this->model.SetWidth(value); this->model.SetWidth(value);
} }
void Reverberation::SetSamplingRate(uint32_t value) {
this->samplingRate = value;
this->model.Reset();
}
Reverberation::~Reverberation() {
}

View File

@ -6,7 +6,6 @@
class Reverberation { class Reverberation {
public: public:
Reverberation(); Reverberation();
~Reverberation();
void Process(float *buffer, uint32_t size); void Process(float *buffer, uint32_t size);
void Reset(); void Reset();
@ -14,18 +13,12 @@ public:
void SetDry(float value); void SetDry(float value);
void SetEnable(bool enable); void SetEnable(bool enable);
void SetRoomSize(float value); void SetRoomSize(float value);
void SetSamplingRate(uint32_t value);
void SetWet(float value); void SetWet(float value);
void SetWidth(float value); void SetWidth(float value);
float roomsize; private:
float width;
float damp;
float wet;
float dry;
CRevModel model; CRevModel model;
uint32_t samplingRate; bool enable;
bool enabled;
}; };

View File

@ -2,50 +2,57 @@
#include "../constants.h" #include "../constants.h"
SpeakerCorrection::SpeakerCorrection() { SpeakerCorrection::SpeakerCorrection() {
this->samplingRate = DEFAULT_SAMPLERATE; this->samplingRate = VIPER_DEFAULT_SAMPLING_RATE;
this->enabled = false; this->enable = false;
Reset(); Reset();
} }
void SpeakerCorrection::Process(float *samples, uint32_t size) { void SpeakerCorrection::Process(float *samples, uint32_t size) {
if (this->enabled) { if (!this->enable) return;
for (int i = 0; i < size * 2; i++) {
float sample = samples[i]; for (int i = 0; i < size * 2; i += 2) {
int index = i % 2; double outL = samples[i];
sample = this->lowpass[index].ProcessSample(sample); outL = this->lowPass[0].ProcessSample(outL);
sample = this->highpass[index].ProcessSample(sample); outL = this->highPass[0].ProcessSample(outL);
float tmp = sample / 2.f; outL /= 2.0;
samples[i] = tmp + this->bandpass[index].ProcessSample(tmp); outL += this->bandPass[0].ProcessSample(outL);
} samples[i] = (float) outL;
double outR = samples[i + 1];
outR = this->lowPass[1].ProcessSample(outR);
outR = this->highPass[1].ProcessSample(outR);
outR /= 2.0;
outR += this->bandPass[1].ProcessSample(outR);
samples[i + 1] = (float) outR;
} }
} }
void SpeakerCorrection::Reset() { void SpeakerCorrection::Reset() {
this->lowpass[0].Reset(); this->lowPass[0].Reset();
this->lowpass[1].Reset(); this->lowPass[1].Reset();
this->bandpass[0].Reset(); this->bandPass[0].Reset();
this->bandpass[1].Reset(); this->bandPass[1].Reset();
this->highpass[0].RefreshFilter(MultiBiquad::FilterType::HIGHPASS, 0.f, 80.f, (float) this->samplingRate, 1.f, false); this->highPass[0].RefreshFilter(MultiBiquad::FilterType::HIGHPASS, 0.0, 80.0, this->samplingRate, 1.0, false);
this->highpass[1].RefreshFilter(MultiBiquad::FilterType::HIGHPASS, 0.f, 80.f, (float) this->samplingRate, 1.f, false); this->highPass[1].RefreshFilter(MultiBiquad::FilterType::HIGHPASS, 0.0, 80.0, this->samplingRate, 1.0, false);
this->lowpass[0].SetLowPassParameter(13500.f, this->samplingRate, 1.0); this->lowPass[0].SetLowPassParameter(13500.0, this->samplingRate, 1.0);
this->lowpass[1].SetLowPassParameter(13500.f, this->samplingRate, 1.0); this->lowPass[1].SetLowPassParameter(13500.0, this->samplingRate, 1.0);
this->bandpass[0].SetBandPassParameter(420.f, this->samplingRate, 3.88f); this->bandPass[0].SetBandPassParameter(420.0, this->samplingRate, 3.88);
this->bandpass[1].SetBandPassParameter(420.f, this->samplingRate, 3.88f); this->bandPass[1].SetBandPassParameter(420.0, this->samplingRate, 3.88);
} }
void SpeakerCorrection::SetEnable(bool enabled) { void SpeakerCorrection::SetEnable(bool enable) {
this->enabled = enabled; if (this->enable != enable) {
if (this->enabled) { if (!this->enable) {
Reset(); Reset();
} }
this->enable = enable;
}
} }
void SpeakerCorrection::SetSamplingRate(uint32_t samplingRate) { void SpeakerCorrection::SetSamplingRate(uint32_t samplingRate) {
if (this->samplingRate != samplingRate) {
this->samplingRate = samplingRate; this->samplingRate = samplingRate;
Reset(); Reset();
} }
SpeakerCorrection::~SpeakerCorrection() {
} }

View File

@ -7,16 +7,16 @@
class SpeakerCorrection { class SpeakerCorrection {
public: public:
SpeakerCorrection(); SpeakerCorrection();
~SpeakerCorrection();
void Process(float *samples, uint32_t size); void Process(float *samples, uint32_t size);
void Reset(); void Reset();
void SetEnable(bool enabled); void SetEnable(bool enable);
void SetSamplingRate(uint32_t samplingRate); void SetSamplingRate(uint32_t samplingRate);
private:
uint32_t samplingRate; uint32_t samplingRate;
bool enabled; bool enable;
MultiBiquad highpass[2]; MultiBiquad highPass[2];
Biquad lowpass[2]; Biquad lowPass[2];
Biquad bandpass[2]; Biquad bandPass[2];
}; };

View File

@ -15,7 +15,7 @@ static float SPECTRUM_HARMONICS[10] = {
}; };
SpectrumExtend::SpectrumExtend() { SpectrumExtend::SpectrumExtend() {
this->samplingRate = DEFAULT_SAMPLERATE; this->samplingRate = VIPER_DEFAULT_SAMPLING_RATE;
this->referenceFreq = 7600; this->referenceFreq = 7600;
this->enabled = false; this->enabled = false;
this->exciter = 0.f; this->exciter = 0.f;

View File

@ -5,7 +5,7 @@ VHE::VHE() {
enabled = false; enabled = false;
effectLevel = 0; effectLevel = 0;
convSize = 0; convSize = 0;
samplingRate = DEFAULT_SAMPLERATE; samplingRate = VIPER_DEFAULT_SAMPLING_RATE;
bufA = new WaveBuffer(2, 0x1000); bufA = new WaveBuffer(2, 0x1000);
bufB = new WaveBuffer(2, 0x1000); bufB = new WaveBuffer(2, 0x1000);

View File

@ -3,9 +3,9 @@
ViPERBass::ViPERBass() { ViPERBass::ViPERBass() {
this->enable = false; this->enable = false;
this->samplingRate = DEFAULT_SAMPLERATE; this->samplingRate = VIPER_DEFAULT_SAMPLING_RATE;
this->speaker = 60; this->speaker = 60;
this->samplingRatePeriod = 1.0 / DEFAULT_SAMPLERATE; this->samplingRatePeriod = 1.0 / VIPER_DEFAULT_SAMPLING_RATE;
this->antiPop = 0.0; this->antiPop = 0.0;
this->processMode = ProcessMode::NATURAL_BASS; this->processMode = ProcessMode::NATURAL_BASS;
this->bassFactor = 0.0; this->bassFactor = 0.0;

View File

@ -5,12 +5,12 @@ ViPERClarity::ViPERClarity() {
for (auto &highShelf : this->highShelf) { for (auto &highShelf : this->highShelf) {
highShelf.SetFrequency(12000.0); highShelf.SetFrequency(12000.0);
highShelf.SetGain(1.0); highShelf.SetGain(1.0);
highShelf.SetSamplingRate(DEFAULT_SAMPLERATE); highShelf.SetSamplingRate(VIPER_DEFAULT_SAMPLING_RATE);
} }
this->enable = false; this->enable = false;
this->processMode = ClarityMode::NATURAL; this->processMode = ClarityMode::NATURAL;
this->samplingRate = DEFAULT_SAMPLERATE; this->samplingRate = VIPER_DEFAULT_SAMPLING_RATE;
this->clarityGainPercent = 0.0; this->clarityGainPercent = 0.0;
Reset(); Reset();
} }

View File

@ -42,7 +42,7 @@ void CCombFilter::SetBuffer(float *buffer, uint32_t size) {
void CCombFilter::SetDamp(float damp) { void CCombFilter::SetDamp(float damp) {
this->damp = damp; this->damp = damp;
this->damp2 = 1 - damp; this->damp2 = 1.0f - damp;
} }
void CCombFilter::SetFeedback(float feedback) { void CCombFilter::SetFeedback(float feedback) {

View File

@ -9,7 +9,7 @@ CRevModel::CRevModel() {
buffers[5] = new float[1300]; buffers[5] = new float[1300];
buffers[6] = new float[1356]; buffers[6] = new float[1356];
buffers[7] = new float[1379]; buffers[7] = new float[1379];
buffers[8] = new float[1356]; buffers[8] = new float[1422];
buffers[9] = new float[1445]; buffers[9] = new float[1445];
buffers[10] = new float[1491]; buffers[10] = new float[1491];
buffers[11] = new float[1514]; buffers[11] = new float[1514];
@ -17,6 +17,7 @@ CRevModel::CRevModel() {
buffers[13] = new float[1580]; buffers[13] = new float[1580];
buffers[14] = new float[1617]; buffers[14] = new float[1617];
buffers[15] = new float[1640]; buffers[15] = new float[1640];
buffers[16] = new float[556]; buffers[16] = new float[556];
buffers[17] = new float[579]; buffers[17] = new float[579];
buffers[18] = new float[441]; buffers[18] = new float[441];
@ -34,7 +35,7 @@ CRevModel::CRevModel() {
combR[2].SetBuffer(buffers[5], 1300); combR[2].SetBuffer(buffers[5], 1300);
combL[3].SetBuffer(buffers[6], 1356); combL[3].SetBuffer(buffers[6], 1356);
combR[3].SetBuffer(buffers[7], 1379); combR[3].SetBuffer(buffers[7], 1379);
combL[4].SetBuffer(buffers[8], 1356); combL[4].SetBuffer(buffers[8], 1422);
combR[4].SetBuffer(buffers[9], 1445); combR[4].SetBuffer(buffers[9], 1445);
combL[5].SetBuffer(buffers[10], 1491); combL[5].SetBuffer(buffers[10], 1491);
combR[5].SetBuffer(buffers[11], 1514); combR[5].SetBuffer(buffers[11], 1514);
@ -42,6 +43,7 @@ CRevModel::CRevModel() {
combR[6].SetBuffer(buffers[13], 1580); combR[6].SetBuffer(buffers[13], 1580);
combL[7].SetBuffer(buffers[14], 1617); combL[7].SetBuffer(buffers[14], 1617);
combR[7].SetBuffer(buffers[15], 1640); combR[7].SetBuffer(buffers[15], 1640);
allpassL[0].SetBuffer(buffers[16], 556); allpassL[0].SetBuffer(buffers[16], 556);
allpassR[0].SetBuffer(buffers[17], 579); allpassR[0].SetBuffer(buffers[17], 579);
allpassL[1].SetBuffer(buffers[18], 441); allpassL[1].SetBuffer(buffers[18], 441);
@ -51,40 +53,66 @@ CRevModel::CRevModel() {
allpassL[3].SetBuffer(buffers[22], 225); allpassL[3].SetBuffer(buffers[22], 225);
allpassR[3].SetBuffer(buffers[23], 248); allpassR[3].SetBuffer(buffers[23], 248);
allpassL[0].SetFeedback(0.5f); allpassL[0].SetFeedback(0.5);
allpassR[0].SetFeedback(0.5f); allpassR[0].SetFeedback(0.5);
allpassL[1].SetFeedback(0.5f); allpassL[1].SetFeedback(0.5);
allpassR[1].SetFeedback(0.5f); allpassR[1].SetFeedback(0.5);
allpassL[2].SetFeedback(0.5f); allpassL[2].SetFeedback(0.5);
allpassR[2].SetFeedback(0.5f); allpassR[2].SetFeedback(0.5);
allpassL[3].SetFeedback(0.5f); allpassL[3].SetFeedback(0.5);
allpassR[3].SetFeedback(0.5f); allpassR[3].SetFeedback(0.5);
SetWet(1 / 3.f); SetWet(0.167);
SetRoomSize(0.5f); SetRoomSize(0.5);
SetDry(0.f); SetDry(0.25);
SetDamp(0.5f); SetDamp(0.5);
SetWidth(1.f); SetWidth(1.0);
SetMode(0.f); SetMode(0.0);
Mute(); Reset();
} }
CRevModel::~CRevModel() { CRevModel::~CRevModel() {
for (int i = 0; i < 24; i++) { for (auto &buffer : buffers) {
delete[] buffers[i]; delete[] buffer;
} }
} }
void CRevModel::Mute() { float CRevModel::GetDamp() {
if (mode == 1) { return damp / 0.4f;
return;
} }
float CRevModel::GetDry() {
return dry / 2.0f;
}
float CRevModel::GetMode() {
if (this->mode >= 0.5) {
return 1.0;
}
return this->mode;
}
float CRevModel::GetRoomSize() {
return (this->roomSize - 0.7f) / 0.28f;
}
float CRevModel::GetWet() {
return wet / 3.0f;
}
float CRevModel::GetWidth() {
return width;
}
void CRevModel::Mute() {
if (GetMode() >= 0.5) return;
for (int i = 0; i < 8; i++) { for (int i = 0; i < 8; i++) {
combL[i].Mute(); combL[i].Mute();
combR[i].Mute(); combR[i].Mute();
} }
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
allpassL[i].Mute(); allpassL[i].Mute();
allpassR[i].Mute(); allpassR[i].Mute();
@ -92,55 +120,29 @@ void CRevModel::Mute() {
} }
void CRevModel::ProcessReplace(float *bufL, float *bufR, uint32_t size) { void CRevModel::ProcessReplace(float *bufL, float *bufR, uint32_t size) {
for (int idx = 0; idx < size; idx++) { for (uint32_t idx = 0; idx < size; idx++) {
float outL = 0.f; float outL = 0.0;
float outR = 0.f; float outR = 0.0;
float input = (*bufL + *bufR) * gain; float input = (bufL[idx] + bufR[idx]) * gain;
for (int i = 0; i < 8; i++) { for (uint32_t i = 0; i < 8; i++) {
outL += combL[i].Process(input); outL += combL[i].Process(input);
outR += combR[i].Process(input); outR += combR[i].Process(input);
} }
for (int i = 0; i < 4; i++) { for (uint32_t i = 0; i < 4; i++) {
outL = allpassL[i].Process(outL); outL = allpassL[i].Process(outL);
outR = allpassR[i].Process(outR); outR = allpassR[i].Process(outR);
} }
*bufL = outL * wet1 + outR * wet2 + *bufL * dry; bufL[idx] = outL * unknown1 + outR * unknown2 + bufL[idx] * dry;
*bufR = outR * wet1 + outL * wet2 + *bufR * dry; bufR[idx] = outR * unknown1 + outL * unknown2 + bufR[idx] * dry;
bufL += 1;
bufR += 1;
}
}
void CRevModel::UpdateCoeffs() {
wet1 = wet * (width / 2.f + 0.5f);
wet2 = wet * ((1.f - width) / 2.f);
if (mode == 1) {
roomsize1 = 1.f;
damp1 = 0.f;
gain = 0.f;
} else {
roomsize1 = roomsize;
damp1 = damp;
gain = 0.015f;
}
for (int i = 0; i < 8; i++) {
combL[i].SetFeedback(roomsize1);
combR[i].SetFeedback(roomsize1);
}
for (int i = 0; i < 8; i++) {
combL[i].SetDamp(damp1);
combR[i].SetDamp(damp1);
} }
} }
void CRevModel::Reset() { void CRevModel::Reset() {
if (GetMode() >= 0.5) return;
for (int i = 0; i < 8; i++) { for (int i = 0; i < 8; i++) {
combL[i].Mute(); combL[i].Mute();
combR[i].Mute(); combR[i].Mute();
@ -152,59 +154,53 @@ void CRevModel::Reset() {
} }
} }
void CRevModel::SetRoomSize(float value) { void CRevModel::SetDamp(float damp) {
roomsize = (value * 0.28f) + 0.7f; this->damp = damp * 0.4f;
UpdateCoeffs(); UpdateCoeffs();
} }
void CRevModel::SetDamp(float value) { void CRevModel::SetDry(float dry) {
damp = value * 0.4f; this->dry = dry * 2.0f;
}
void CRevModel::SetMode(float mode) {
this->mode = mode;
UpdateCoeffs(); UpdateCoeffs();
} }
void CRevModel::SetWet(float value) { void CRevModel::SetRoomSize(float roomSize) {
wet = value * 3.f; this->roomSize = (roomSize * 0.28f) + 0.7f;
UpdateCoeffs(); UpdateCoeffs();
} }
void CRevModel::SetDry(float value) { void CRevModel::SetWet(float wet) {
dry = value * 2.f; this->wet = wet * 3.0f;
}
void CRevModel::SetWidth(float value) {
width = value;
UpdateCoeffs(); UpdateCoeffs();
} }
void CRevModel::SetMode(int value) { void CRevModel::SetWidth(float width) {
mode = value; this->width = width;
UpdateCoeffs(); UpdateCoeffs();
} }
float CRevModel::GetRoomSize() { void CRevModel::UpdateCoeffs() {
return (roomsize - 0.7f) / 0.28f; this->unknown1 = this->wet * (this->width / 2.0f + 0.5f);
} this->unknown2 = this->wet * (1.0f - this->width) / 2.0f;
float CRevModel::GetDamp() { if (this->mode >= 0.5) {
return damp / 0.4f; this->internalRoomSize = 1.0;
} this->internalDamp = 0.0;
this->gain = 0.0;
float CRevModel::GetWet() {
return wet / 3.f;
}
float CRevModel::GetDry() {
return dry / 2.f;
}
float CRevModel::GetWidth() {
return width;
}
int CRevModel::GetMode() {
if (mode == 1) {
return 1.f;
} else { } else {
return 0.f; this->internalRoomSize = this->roomSize;
this->internalDamp = this->damp;
this->gain = 0.015;
}
for (int i = 0; i < 8; i++) {
this->combL[i].SetFeedback(this->internalRoomSize);
this->combL[i].SetDamp(this->internalDamp);
this->combR[i].SetFeedback(this->internalRoomSize);
this->combR[i].SetDamp(this->internalDamp);
} }
} }

View File

@ -6,52 +6,37 @@
class CRevModel { class CRevModel {
public: public:
CRevModel(); CRevModel();
~CRevModel(); ~CRevModel();
void Mute(); void Mute();
void ProcessReplace(float *bufL, float *bufR, uint32_t size); void ProcessReplace(float *bufL, float *bufR, uint32_t size);
void UpdateCoeffs(); void UpdateCoeffs();
void Reset(); void Reset();
void SetRoomSize(float roomSize);
void SetRoomSize(float value); void SetDamp(float damp);
void SetWet(float wet);
void SetDamp(float value); void SetDry(float dry);
void SetWidth(float width);
void SetWet(float value); void SetMode(float mode);
void SetDry(float value);
void SetWidth(float value);
void SetMode(int value);
float GetRoomSize(); float GetRoomSize();
float GetDamp(); float GetDamp();
float GetWet(); float GetWet();
float GetDry(); float GetDry();
float GetWidth(); float GetWidth();
float GetMode();
int GetMode(); private:
float gain; float gain;
float roomsize; float roomSize;
float roomsize1; float internalRoomSize;
float damp; float damp;
float damp1; float internalDamp;
float wet; float wet;
float wet1; float unknown1;
float wet2; float unknown2;
float dry; float dry;
float width; float width;
int mode; float mode;
CCombFilter combL[8]; CCombFilter combL[8];
CCombFilter combR[8]; CCombFilter combR[8];

View File

@ -13,7 +13,7 @@ Crossfeed::Crossfeed() {
this->b1_hi = 0.f; this->b1_hi = 0.f;
this->gain = 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->samplerate = VIPER_DEFAULT_SAMPLING_RATE;
this->preset.cutoff = 700; this->preset.cutoff = 700;
this->preset.feedback = 45; this->preset.feedback = 45;
} }

View File

@ -10,7 +10,7 @@ DepthSurround::DepthSurround() {
for (auto &prev : this->prev) { for (auto &prev : this->prev) {
prev = 0.0f; prev = 0.0f;
} }
this->SetSamplingRate(DEFAULT_SAMPLERATE); this->SetSamplingRate(VIPER_DEFAULT_SAMPLING_RATE);
this->RefreshStrength(this->strength); this->RefreshStrength(this->strength);
} }

View File

@ -3,7 +3,7 @@
DynamicBass::DynamicBass() { DynamicBass::DynamicBass() {
this->qPeak = 0; this->qPeak = 0;
SetSamplingRate(DEFAULT_SAMPLERATE); SetSamplingRate(VIPER_DEFAULT_SAMPLING_RATE);
this->bassGain = 1.f; this->bassGain = 1.f;
this->sideGainX = 1.f; this->sideGainX = 1.f;
this->sideGainY = 1.f; this->sideGainY = 1.f;

View File

@ -3,7 +3,7 @@
HiFi::HiFi() { HiFi::HiFi() {
this->gain = 1.f; this->gain = 1.f;
this->samplingRate = DEFAULT_SAMPLERATE; this->samplingRate = VIPER_DEFAULT_SAMPLING_RATE;
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
this->buffers[i] = new WaveBuffer(2, 0x800); this->buffers[i] = new WaveBuffer(2, 0x800);
this->filters[i].lowpass = new IIR_NOrder_BW_LH(1); this->filters[i].lowpass = new IIR_NOrder_BW_LH(1);

View File

@ -97,7 +97,7 @@ static const float MIN_PHASE_IIR_COEFFS_FREQ_31BANDS[] = {
MinPhaseIIRCoeffs::MinPhaseIIRCoeffs() { MinPhaseIIRCoeffs::MinPhaseIIRCoeffs() {
this->coeffs = nullptr; this->coeffs = nullptr;
this->samplingRate = DEFAULT_SAMPLERATE; this->samplingRate = VIPER_DEFAULT_SAMPLING_RATE;
this->bands = 0; this->bands = 0;
} }

View File

@ -2,24 +2,30 @@
#include <cmath> #include <cmath>
MultiBiquad::MultiBiquad() { MultiBiquad::MultiBiquad() {
this->y_2 = 0; this->a1 = 0.0;
this->y_1 = 0; this->a2 = 0.0;
this->x_2 = 0; this->b0 = 0.0;
this->x_1 = 0; this->b1 = 0.0;
this->b0 = 0; this->b2 = 0.0;
this->b1 = 0; this->x1 = 0.0;
this->b2 = 0; this->x2 = 0.0;
this->a1 = 0; this->y1 = 0.0;
this->a2 = 0; this->y2 = 0.0;
} }
double MultiBiquad::ProcessSample(double sample) { double MultiBiquad::ProcessSample(double sample) {
double out = sample * this->b0 + this->x_1 * this->b1 + this->x_2 * this->b2 + this->y_1 * this->a1 + double out =
this->y_2 * this->a2; sample * this->b0 +
this->y_2 = this->y_1; this->x1 * this->b1 +
this->y_1 = out; this->x2 * this->b2 +
this->x_2 = this->x_1; this->y1 * this->a1 +
this->x_1 = sample; this->y2 * this->a2;
this->x2 = this->x1;
this->x1 = sample;
this->y2 = this->y1;
this->y1 = out;
return out; return out;
} }
@ -33,21 +39,21 @@ MultiBiquad::RefreshFilter(FilterType type, float gainAmp, float frequency, uint
gain = pow(10.0f, gainAmp / 20.0f); gain = pow(10.0f, gainAmp / 20.0f);
} }
double x = (2.0 * M_PI * (double) frequency) / (double) samplingRate; double omega = (2.0 * M_PI * (double) frequency) / (double) samplingRate;
double sinX = sin(x); double sinOmega = sin(omega);
double cosX = cos(x); double cosOmega = cos(omega);
double y; double y;
double z; double z;
if (type - 6 < 2) { if (type - 6 < 2) {
y = sinX / 2.0 * sqrt((1.0 / ((double) gain * 2.0)) * (1.0 / (double) qFactor - 1.0) + 2.0); y = sinOmega / 2.0 * sqrt((1.0 / ((double) gain * 2.0)) * (1.0 / (double) qFactor - 1.0) + 2.0);
z = sqrt((double) gain) * y; z = sqrt((double) gain) * y;
} else if (!param_7) { } else if (!param_7) {
y = sinX / ((double) qFactor / 2.0); y = sinOmega / ((double) qFactor / 2.0);
z = -1.0; z = -1.0;
} else { } else {
y = sinh(((double) qFactor * (log(2.0) / 2.0) * x) / sinX); y = sinh(((double) qFactor * (log(2.0) / 2.0) * omega) / sinOmega);
z = -1.0; z = -1.0;
} }
@ -60,87 +66,87 @@ MultiBiquad::RefreshFilter(FilterType type, float gainAmp, float frequency, uint
switch (type) { switch (type) {
case LOWPASS: { case LOWPASS: {
b1 = 1.0 - cosX;
b0 = (1.0 - cosX) / 2.0;
a1 = -cosX * 2.0;
a2 = 1.0 - y;
a0 = 1.0 + y; a0 = 1.0 + y;
b2 = b0; a1 = -2.0 * cosOmega;
a2 = 1.0 - y;
b0 = (1.0 - cosOmega) / 2.0;
b1 = 1.0 - cosOmega;
b2 = (1.0 - cosOmega) / 2.0;
break; break;
} }
case HIGHPASS: { case HIGHPASS: {
b1 = -1.0 - cosX;
b0 = (1.0 + cosX) / 2.0;
a1 = -cosX * 2.0;
a2 = 1.0 - y;
a0 = 1.0 + y; a0 = 1.0 + y;
b2 = b0; a1 = -2.0 * cosOmega;
a2 = 1.0 - y;
b0 = (1.0 + cosOmega) / 2.0;
b1 = -1.0 - cosOmega;
b2 = (1.0 + cosOmega) / 2.0;
break; break;
} }
case BANDPASS: { case BANDPASS: {
b1 = 0.0;
a1 = -cosX * 2.0;
a2 = 1.0 - y;
a0 = 1.0 + y; a0 = 1.0 + y;
a1 = -2.0 * cosOmega;
a2 = 1.0 - y;
b0 = y; b0 = y;
b1 = 0.0;
b2 = -y; b2 = -y;
break; break;
} }
case BANDSTOP: { case BANDSTOP: {
b1 = -cosX * 2.0;
a2 = 1.0 - y;
a0 = 1.0 + y; a0 = 1.0 + y;
a1 = -2.0 * cosOmega;
a2 = 1.0 - y;
b0 = 1.0; b0 = 1.0;
b1 = -2.0 * cosOmega;
b2 = 1.0; b2 = 1.0;
a1 = b1;
break; break;
} }
case ALLPASS: { case ALLPASS: {
b1 = -cosX * 2.0;
a2 = 1.0 - y;
a0 = 1.0 + y; a0 = 1.0 + y;
b0 = a2; a1 = -2.0 * cosOmega;
b2 = a0; a2 = 1.0 - y;
a1 = b1; b0 = 1.0 - y;
b1 = -2.0 * cosOmega;
b2 = 1.0 + y;
break; break;
} }
case PEAK: { case PEAK: {
b1 = -cosX * 2.0;
a2 = 1.0 - y / (double) gain;
a0 = 1.0 + y / (double) gain; a0 = 1.0 + y / (double) gain;
a1 = -2.0 * cosOmega;
a2 = 1.0 - y / (double) gain;
b0 = 1.0 + y * (double) gain; b0 = 1.0 + y * (double) gain;
b1 = -2.0 * cosOmega;
b2 = 1.0 - y * (double) gain; b2 = 1.0 - y * (double) gain;
a1 = b1;
break; break;
} }
case LOWSHELF: { case LOWSHELF: {
double tmp1 = (gain + 1.0) - (gain - 1.0) * cosX; double tmp1 = (gain + 1.0) - (gain - 1.0) * cosOmega;
double tmp2 = (gain + 1.0) + (gain - 1.0) * cosX; double tmp2 = (gain + 1.0) + (gain - 1.0) * cosOmega;
a1 = ((gain - 1.0) + (gain + 1.0) * cosX) * -2.0; a1 = ((gain - 1.0) + (gain + 1.0) * cosOmega) * -2.0;
a2 = tmp2 - z; a2 = tmp2 - z;
b1 = (gain * 2.0) * ((gain - 1.0) - (gain + 1.0) * cosX); b1 = (gain * 2.0) * ((gain - 1.0) - (gain + 1.0) * cosOmega);
a0 = tmp2 + z; a0 = tmp2 + z;
b0 = (tmp1 + z) * gain; b0 = (tmp1 + z) * gain;
b2 = (tmp1 - z) * gain; b2 = (tmp1 - z) * gain;
break; break;
} }
case HIGHSHELF: { case HIGHSHELF: {
double tmp1 = (gain + 1.0) + (gain - 1.0) * cosX; double tmp1 = (gain + 1.0) + (gain - 1.0) * cosOmega;
double tmp2 = (gain + 1.0) - (gain - 1.0) * cosX; double tmp2 = (gain + 1.0) - (gain - 1.0) * cosOmega;
a2 = tmp2 - z; a2 = tmp2 - z;
a0 = tmp2 + z; a0 = tmp2 + z;
a1 = ((gain - 1.0) - (gain + 1.0) * cosX) * 2.0; a1 = ((gain - 1.0) - (gain + 1.0) * cosOmega) * 2.0;
b1 = gain * -2.0 * ((gain - 1.0) + (gain + 1.0) * cosX); b1 = gain * -2.0 * ((gain - 1.0) + (gain + 1.0) * cosOmega);
b0 = (tmp1 + z) * gain; b0 = (tmp1 + z) * gain;
b2 = (tmp1 - z) * gain; b2 = (tmp1 - z) * gain;
break; break;
} }
} }
this->x_1 = 0.0; this->x2 = 0.0;
this->x_2 = 0.0; this->x1 = 0.0;
this->y_1 = 0.0; this->y2 = 0.0;
this->y_2 = 0.0; this->y1 = 0.0;
this->a1 = -a1 / a0; this->a1 = -a1 / a0;
this->a2 = -a2 / a0; this->a2 = -a2 / a0;

View File

@ -21,10 +21,10 @@ public:
void RefreshFilter(FilterType type, float gainAmp, float frequency, uint32_t samplingRate, float qFactor, bool param_7); void RefreshFilter(FilterType type, float gainAmp, float frequency, uint32_t samplingRate, float qFactor, bool param_7);
private: private:
double x_1; double x1;
double x_2; double x2;
double y_1; double y1;
double y_2; double y2;
double a1; double a1;
double a2; double a2;
double b0; double b0;

View File

@ -2,7 +2,7 @@
#include "../constants.h" #include "../constants.h"
NoiseSharpening::NoiseSharpening() { NoiseSharpening::NoiseSharpening() {
this->samplingRate = DEFAULT_SAMPLERATE; this->samplingRate = VIPER_DEFAULT_SAMPLING_RATE;
this->gain = 0.0; this->gain = 0.0;
Reset(); Reset();
} }

View File

@ -6,7 +6,7 @@ PassFilter::PassFilter() {
this->filters[1] = new IIR_NOrder_BW_LH(3); this->filters[1] = new IIR_NOrder_BW_LH(3);
this->filters[2] = new IIR_NOrder_BW_LH(1); this->filters[2] = new IIR_NOrder_BW_LH(1);
this->filters[3] = new IIR_NOrder_BW_LH(1); this->filters[3] = new IIR_NOrder_BW_LH(1);
this->samplingRate = DEFAULT_SAMPLERATE; this->samplingRate = VIPER_DEFAULT_SAMPLING_RATE;
Reset(); Reset();
} }

View File

@ -4,7 +4,7 @@
#include <cmath> #include <cmath>
PolesFilter::PolesFilter() { PolesFilter::PolesFilter() {
this->samplingRate = DEFAULT_SAMPLERATE; this->samplingRate = VIPER_DEFAULT_SAMPLING_RATE;
this->lower_freq = 160; this->lower_freq = 160;
this->upper_freq = 8000; this->upper_freq = 8000;
UpdateCoeff(); UpdateCoeff();

View File

@ -134,7 +134,7 @@ static const float POLYPHASE_COEFFICIENTS_OTHER[] = {
}; };
Polyphase::Polyphase(int param_1) { Polyphase::Polyphase(int param_1) {
this->samplingRate = DEFAULT_SAMPLERATE; this->samplingRate = VIPER_DEFAULT_SAMPLING_RATE;
this->waveBuffer1 = new WaveBuffer(2, 0x1000); this->waveBuffer1 = new WaveBuffer(2, 0x1000);
this->waveBuffer2 = new WaveBuffer(2, 0x1000); this->waveBuffer2 = new WaveBuffer(2, 0x1000);
this->buffer = new float[0x7e0]; this->buffer = new float[0x7e0];

View File

@ -3,7 +3,7 @@
#include <cmath> #include <cmath>
Subwoofer::Subwoofer() { Subwoofer::Subwoofer() {
uint32_t samplingRate = DEFAULT_SAMPLERATE; uint32_t samplingRate = VIPER_DEFAULT_SAMPLING_RATE;
this->peak[0].RefreshFilter(MultiBiquad::FilterType::PEAK, 0.0, 37.0, samplingRate, 1.0, false); this->peak[0].RefreshFilter(MultiBiquad::FilterType::PEAK, 0.0, 37.0, samplingRate, 1.0, false);
this->peak[1].RefreshFilter(MultiBiquad::FilterType::PEAK, 0.0, 37.0, samplingRate, 1.0, false); this->peak[1].RefreshFilter(MultiBiquad::FilterType::PEAK, 0.0, 37.0, samplingRate, 1.0, false);
this->peakLow[0].RefreshFilter(MultiBiquad::FilterType::PEAK, 0.0, 75.0, samplingRate, 1.0, false); this->peakLow[0].RefreshFilter(MultiBiquad::FilterType::PEAK, 0.0, 75.0, samplingRate, 1.0, false);