Skip to content

Commit 2bc10b1

Browse files
committed
DDC support arbitrary sample rate by analytical spectrum analyser and reverse calculation of peaking equation
DDC support arbitrary sample rate by analytical spectrum analyser and reverse calculation of peaking equation
1 parent 7b7f421 commit 2bc10b1

File tree

21 files changed

+210
-5561
lines changed

21 files changed

+210
-5561
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
APP_OPTIM := release
22
APP_PLATFORM := android-21
3-
APP_ABI := armeabi-v7a x86
3+
APP_ABI := armeabi-v7a arm64-v8a x86

Audio_Engine/eclipse_libjamesdsp_free_bp/jni/EffectDSPMain.cpp

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const double interpFreq[NUM_BANDS] = { 25.0, 40.0, 63.0, 100.0, 160.0, 250.0, 40
1919

2020
EffectDSPMain::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
}
885913
void 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;

Audio_Engine/eclipse_libjamesdsp_free_bp/jni/EffectDSPMain.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ class EffectDSPMain : public Effect
2424
protected:
2525
int stringLength;
2626
char *stringEq;
27-
DirectForm2 **df441, **df48, **sosPointer;
28-
int sosCount;
27+
DirectForm2 **df441, **df48, **dfResampled, **sosPointer;
28+
int sosCount, resampledSOSCount, usedSOSCount;
2929
typedef struct threadParamsConv {
3030
AutoConvolverMono **conv;
3131
double **in, **out;

0 commit comments

Comments
 (0)