Skip to content

Commit b91f714

Browse files
committed
refactor: apply upstream changes for JdspImpResToolbox
1 parent c6e96de commit b91f714

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

libjamesdsp/JdspImpResToolbox.c

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,8 @@ void circshift(float *x, int n, int k)
258258
k < 0 ? shift(x, -k, n) : shift(x, n - k, n);
259259
}
260260
#define NUMPTS 15
261-
ierper pch1, pch2;
261+
#define NUMPTS_DRS (7)
262+
ierper pch1, pch2, pch3;
262263
__attribute__((constructor)) static void initialize(void)
263264
{
264265
if (decompressedCoefficients)
@@ -267,14 +268,16 @@ __attribute__((constructor)) static void initialize(void)
267268
decompressResamplerMQ(compressedCoeffMQ, decompressedCoefficients);
268269
initIerper(&pch1, NUMPTS + 2);
269270
initIerper(&pch2, NUMPTS + 2);
271+
initIerper(&pch3, NUMPTS_DRS + 2);
270272
}
271273
__attribute__((destructor)) static void destruction(void)
272274
{
273275
free(decompressedCoefficients);
274276
decompressedCoefficients = 0;
275277
freeIerper(&pch1);
276278
freeIerper(&pch2);
277-
}
279+
freeIerper(&pch3);
280+
}
278281
static void JamesDSPOfflineResampling(float const *in, float *out, size_t lenIn, size_t lenOut, int channels, double src_ratio, int resampleQuality)
279282
{
280283
if (lenOut == lenIn && lenIn == 1)
@@ -534,3 +537,20 @@ int ComputeEqResponse(const double* jfreq, double* jgain, int interpolationMode,
534537
return 0;
535538
}
536539

540+
int ComputeCompResponse(int n, const double* jfreq, const double* jgain, int queryPts, const double* dispFreq, float* response)
541+
{
542+
double freqComp[NUMPTS_DRS + 2];
543+
double gainComp[NUMPTS_DRS + 2];
544+
545+
memcpy(freqComp + 1, jfreq, NUMPTS_DRS * sizeof(double));
546+
memcpy(gainComp + 1, jgain, NUMPTS_DRS * sizeof(double));
547+
548+
freqComp[0] = 0.0;
549+
gainComp[0] = gainComp[1];
550+
freqComp[NUMPTS_DRS + 1] = 24000.0;
551+
gainComp[NUMPTS_DRS + 1] = gainComp[NUMPTS_DRS];
552+
makima(&pch3, freqComp, gainComp, NUMPTS_DRS + 2, 1, 1);
553+
ierper *lerpPtr = &pch3;
554+
for (int i = 0; i < queryPts; i++)
555+
response[i] = (float)getValueAt(&lerpPtr->cb, dispFreq[i]);
556+
}

libjamesdsp/JdspImpResToolbox.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33

44
extern float* ReadImpulseResponseToFloat(const char* mIRFileName, int targetSampleRate, int* jImpInfo, int convMode, int* javaAdvSetPtr);
55
extern int ComputeEqResponse(const double* jfreq, double* jgain, int interpolationMode, int queryPts, double* dispFreq, float* response);
6+
extern int ComputeCompResponse(int n, const double* jfreq, const double* jgain, int queryPts, const double* dispFreq, float* response);
67

78
#endif // JDSPIMPRESTOOLBOX_H

0 commit comments

Comments
 (0)