@@ -398,7 +398,8 @@ void circshift(float *x, int n, int k)
398398 k < 0 ? shift (x , - k , n ) : shift (x , n - k , n );
399399}
400400#define NUMPTS 15
401- ierper pch1 , pch2 ;
401+ #define NUMPTS_DRS (7)
402+ ierper pch1 , pch2 , pch3 ;
402403__attribute__((constructor )) static void initialize (void )
403404{
404405 if (decompressedCoefficients )
@@ -407,13 +408,15 @@ __attribute__((constructor)) static void initialize(void)
407408 decompressResamplerMQ (compressedCoeffMQ , decompressedCoefficients );
408409 initIerper (& pch1 , NUMPTS + 2 );
409410 initIerper (& pch2 , NUMPTS + 2 );
411+ initIerper (& pch3 , NUMPTS_DRS + 2 );
410412}
411413__attribute__((destructor )) static void destruction (void )
412414{
413415 free (decompressedCoefficients );
414416 decompressedCoefficients = 0 ;
415417 freeIerper (& pch1 );
416418 freeIerper (& pch2 );
419+ freeIerper (& pch3 );
417420}
418421void JamesDSPOfflineResampling (float const * in , float * out , size_t lenIn , size_t lenOut , int channels , double src_ratio , int resampleQuality )
419422{
@@ -680,9 +683,32 @@ JNIEXPORT jint JNICALL Java_james_dsp_activity_JdspImpResToolbox_ComputeEqRespon
680683 lerpPtr = & pch2 ;
681684 }
682685 for (int i = 0 ; i < queryPts ; i ++ )
683- {
684686 javaResponsePtr [i ] = (float )getValueAt (& lerpPtr -> cb , javadispFreqPtr [i ]);
685- }
687+ (* env )-> ReleaseDoubleArrayElements (env , dispFreq , javadispFreqPtr , 0 );
688+ (* env )-> SetFloatArrayRegion (env , response , 0 , queryPts , javaResponsePtr );
689+ return 0 ;
690+ }
691+ double freqComp [NUMPTS_DRS + 2 ];
692+ double gainComp [NUMPTS_DRS + 2 ];
693+ JNIEXPORT jint JNICALL Java_james_dsp_activity_JdspImpResToolbox_ComputeCompResponse
694+ (JNIEnv * env , jobject obj , jint n , jdoubleArray jfreq , jdoubleArray jgain , jint queryPts , jdoubleArray dispFreq , jfloatArray response )
695+ {
696+ jdouble * javaFreqPtr = (jdouble * ) (* env )-> GetDoubleArrayElements (env , jfreq , 0 );
697+ jdouble * javaGainPtr = (jdouble * ) (* env )-> GetDoubleArrayElements (env , jgain , 0 );
698+ jdouble * javadispFreqPtr = (jdouble * ) (* env )-> GetDoubleArrayElements (env , dispFreq , 0 );
699+ jfloat * javaResponsePtr = (jfloat * ) (* env )-> GetFloatArrayElements (env , response , 0 );
700+ memcpy (freqComp + 1 , javaFreqPtr , NUMPTS_DRS * sizeof (double ));
701+ memcpy (gainComp + 1 , javaGainPtr , NUMPTS_DRS * sizeof (double ));
702+ (* env )-> ReleaseDoubleArrayElements (env , jfreq , javaFreqPtr , 0 );
703+ (* env )-> ReleaseDoubleArrayElements (env , jgain , javaGainPtr , 0 );
704+ freqComp [0 ] = 0.0 ;
705+ gainComp [0 ] = gainComp [1 ];
706+ freqComp [NUMPTS_DRS + 1 ] = 24000.0 ;
707+ gainComp [NUMPTS_DRS + 1 ] = gainComp [NUMPTS_DRS ];
708+ makima (& pch3 , freqComp , gainComp , NUMPTS_DRS + 2 , 1 , 1 );
709+ ierper * lerpPtr = & pch3 ;
710+ for (int i = 0 ; i < queryPts ; i ++ )
711+ javaResponsePtr [i ] = (float )getValueAt (& lerpPtr -> cb , javadispFreqPtr [i ]);
686712 (* env )-> ReleaseDoubleArrayElements (env , dispFreq , javadispFreqPtr , 0 );
687713 (* env )-> SetFloatArrayRegion (env , response , 0 , queryPts , javaResponsePtr );
688714 return 0 ;
0 commit comments