@@ -19,7 +19,7 @@ const double interpFreq[NUM_BANDS] = { 25.0, 40.0, 63.0, 100.0, 160.0, 250.0, 40
1919
2020EffectDSPMain::EffectDSPMain ()
2121 : DSPbufferLength(1024 ), inOutRWPosition(0 ), equalizerEnabled(0 ), ramp(1.0 ), pregain(12.0 ), threshold(-60.0 ), knee(30.0 ), ratio(12.0 ), attack(0.001 ), release(0.24 ), isBenchData(0 ), mPreset(0 ), reverbEnabled(0 ), threadResult(0 )
22- , mMatrixMCoeff(1.0 ), mMatrixSCoeff(1.0 ), bassBoostLp(0 ), FIREq(0 ), convolver(0 ), fullStereoConvolver(0 ), sosCount(0 ), df441(0 ), df48(0 )
22+ , mMatrixMCoeff(1.0 ), mMatrixSCoeff(1.0 ), bassBoostLp(0 ), FIREq(0 ), convolver(0 ), fullStereoConvolver(0 ), sosCount(0 ), resampledSOSCount( 0 ), usedSOSCount( 0 ), df441(0 ), df48( 0 ), dfResampled (0 )
2323 , tempImpulseIncoming(0 ), tempImpulsedouble(0 ), finalImpulse(0 ), convolverReady(-1 ), bassLpReady(-1 ), analogModelEnable(0 ), tubedrive(2.0 ), eqFilterType(0 ), arbEq(0 ), xaxis(0 ), yaxis(0 ), eqFIRReady(0 )
2424{
2525 double c0[12 ] = { 2.138018534150542e-5 , 4.0608501987194246e-5 , 7.950414700590711e-5 , 1.4049065318523225e-4 , 2.988065284903209e-4 , 0.0013061668170781858 , 0.0036204239724680425 , 0.008959629624060151 , 0.027083658741258742 , 0.08156916666666666 , 0.1978822177777778 , 0.4410733777777778 };
@@ -90,6 +90,14 @@ EffectDSPMain::~EffectDSPMain()
9090 free (df441);
9191 free (df48);
9292 sosCount = 0 ;
93+ if (resampledSOSCount)
94+ {
95+ for (int i = 0 ; i < resampledSOSCount; i++)
96+ free (dfResampled[i]);
97+ free (dfResampled);
98+ dfResampled = 0 ;
99+ resampledSOSCount = 0 ;
100+ }
93101 }
94102#ifdef DEBUG
95103 LOGI (" Buffer freed" );
@@ -587,18 +595,22 @@ int32_t EffectDSPMain::command(uint32_t cmdCode, uint32_t cmdSize, void* pCmdDat
587595 int16_t oldVal = viperddcEnabled;
588596 if (mSamplingRate == 44100.0 && df441)
589597 {
590- viperddcEnabled = ((int16_t *)cep)[8 ];
591598 sosPointer = df441;
599+ usedSOSCount = sosCount;
600+ viperddcEnabled = ((int16_t *)cep)[8 ];
592601 }
593602 else if (mSamplingRate == 48000.0 && df48)
594603 {
595- viperddcEnabled = ((int16_t *)cep)[8 ];
596604 sosPointer = df48;
605+ usedSOSCount = sosCount;
606+ viperddcEnabled = ((int16_t *)cep)[8 ];
597607 }
598608 else
599609 {
600- viperddcEnabled = 0 ;
601- sosPointer = 0 ;
610+ resampledSOSCount = PeakingFilterResampler (df48, 48000.0 , &dfResampled, mSamplingRate , sosCount);
611+ usedSOSCount = resampledSOSCount;
612+ sosPointer = dfResampled;
613+ viperddcEnabled = ((int16_t *)cep)[8 ];
602614 }
603615#ifdef DEBUG
604616 LOGI (" viperddcEnabled: %d" , viperddcEnabled);
@@ -622,6 +634,14 @@ int32_t EffectDSPMain::command(uint32_t cmdCode, uint32_t cmdSize, void* pCmdDat
622634 free (df48);
623635 df48 = 0 ;
624636 sosCount = 0 ;
637+ if (resampledSOSCount)
638+ {
639+ for (int i = 0 ; i < resampledSOSCount; i++)
640+ free (dfResampled[i]);
641+ free (dfResampled);
642+ dfResampled = 0 ;
643+ resampledSOSCount = 0 ;
644+ }
625645 sosPointer = 0 ;
626646 }
627647 }
@@ -716,6 +736,14 @@ int32_t EffectDSPMain::command(uint32_t cmdCode, uint32_t cmdSize, void* pCmdDat
716736 free (df48);
717737 df48 = 0 ;
718738 sosCount = 0 ;
739+ if (resampledSOSCount)
740+ {
741+ for (int i = 0 ; i < resampledSOSCount; i++)
742+ free (dfResampled[i]);
743+ free (dfResampled);
744+ dfResampled = 0 ;
745+ resampledSOSCount = 0 ;
746+ }
719747 sosPointer = 0 ;
720748 }
721749 }
@@ -884,7 +912,7 @@ int32_t EffectDSPMain::command(uint32_t cmdCode, uint32_t cmdSize, void* pCmdDat
884912}
885913void EffectDSPMain::refreshTubeAmp ()
886914{
887- if (!InitTube (&tubeP[0 ], 0 , mSamplingRate , tubedrive, 6.5 , 5.6 , 4.5 , 5 , 8192 , 0 ))
915+ if (!InitTube (&tubeP[0 ], 0 , mSamplingRate , tubedrive, 8192 , 0 ))
888916 analogModelEnable = 0 ;
889917 tubeP[1 ] = tubeP[0 ];
890918 rightparams2.tube = tubeP;
@@ -1219,7 +1247,7 @@ int32_t EffectDSPMain::process(audio_buffer_t *in, audio_buffer_t *out)
12191247 for (i = 0 ; i < DSPbufferLength; i++)
12201248 {
12211249 double sampleOutL = inputBuffer[0 ][i], sampleOutR = inputBuffer[1 ][i];
1222- for (int j = 0 ; j < sosCount ; j++)
1250+ for (int j = 0 ; j < usedSOSCount ; j++)
12231251 SOS_DF2_StereoProcess (sosPointer[j], sampleOutL, sampleOutR, &sampleOutL, &sampleOutR);
12241252 outputBuffer[0 ][i] = sampleOutL;
12251253 outputBuffer[1 ][i] = sampleOutR;
@@ -1353,7 +1381,7 @@ int32_t EffectDSPMain::process(audio_buffer_t *in, audio_buffer_t *out)
13531381 for (i = 0 ; i < DSPbufferLength; i++)
13541382 {
13551383 double sampleOutL = inputBuffer[0 ][i], sampleOutR = inputBuffer[1 ][i];
1356- for (int j = 0 ; j < sosCount ; j++)
1384+ for (int j = 0 ; j < usedSOSCount ; j++)
13571385 SOS_DF2_StereoProcess (sosPointer[j], sampleOutL, sampleOutR, &sampleOutL, &sampleOutR);
13581386 outputBuffer[0 ][i] = sampleOutL;
13591387 outputBuffer[1 ][i] = sampleOutR;
@@ -1487,7 +1515,7 @@ int32_t EffectDSPMain::process(audio_buffer_t *in, audio_buffer_t *out)
14871515 for (i = 0 ; i < DSPbufferLength; i++)
14881516 {
14891517 double sampleOutL = inputBuffer[0 ][i], sampleOutR = inputBuffer[1 ][i];
1490- for (int j = 0 ; j < sosCount ; j++)
1518+ for (int j = 0 ; j < usedSOSCount ; j++)
14911519 SOS_DF2_StereoProcess (sosPointer[j], sampleOutL, sampleOutR, &sampleOutL, &sampleOutR);
14921520 outputBuffer[0 ][i] = sampleOutL;
14931521 outputBuffer[1 ][i] = sampleOutR;
0 commit comments