diff --git a/app/src/main/cpp/audio_player.cpp b/app/src/main/cpp/audio_player.cpp index 14c2725..fa54b26 100644 --- a/app/src/main/cpp/audio_player.cpp +++ b/app/src/main/cpp/audio_player.cpp @@ -283,7 +283,7 @@ AUDIO_PLAYER_FUNC(void, play, jstring input_jstr, jstring filter_jstr) { // goto end; } - jmethodID fft_method = env->GetMethodID(player_class, "fftCallbackFromJNI", "([I)V"); + jmethodID fft_method = env->GetMethodID(player_class, "fftCallbackFromJNI", "([S)V"); filter_sys_t *fft_filter = static_cast(malloc(sizeof(filter_sys_t))); open_visualizer(fft_filter); @@ -387,7 +387,8 @@ AUDIO_PLAYER_FUNC(void, release) { } void fft_callback(JNIEnv *jniEnv, jobject thiz, jmethodID fft_method, int16_t * arg) { - jintArray dataArray = jniEnv->NewIntArray(256); - jniEnv->SetIntArrayRegion(dataArray, 0, 256, (int*)arg); + LOGE(TAG, "arg[100]=%d,arg[101]=%d,arg[102]=%d", arg[100], arg[101], arg[102]); + jshortArray dataArray = jniEnv->NewShortArray(256); + jniEnv->SetShortArrayRegion(dataArray, 0, 256, arg); jniEnv->CallVoidMethod(thiz, fft_method, dataArray); } \ No newline at end of file diff --git a/app/src/main/cpp/visualizer/execute_fft.c b/app/src/main/cpp/visualizer/execute_fft.c index a50822f..08da528 100644 --- a/app/src/main/cpp/visualizer/execute_fft.c +++ b/app/src/main/cpp/visualizer/execute_fft.c @@ -304,6 +304,7 @@ void fft_once(void *p_data, block_t *block, int16_t *output) } memcpy(output, p_dest, FFT_BUFFER_SIZE); + LOGE("out[100]=%d,out[101]=%d,out[102]=%d", output[100], output[101], output[102]); release: window_close(&wind_ctx); diff --git a/app/src/main/java/com/frank/ffmpeg/AudioPlayer.java b/app/src/main/java/com/frank/ffmpeg/AudioPlayer.java index 8dbd6a6..fcc986d 100644 --- a/app/src/main/java/com/frank/ffmpeg/AudioPlayer.java +++ b/app/src/main/java/com/frank/ffmpeg/AudioPlayer.java @@ -63,14 +63,14 @@ public class AudioPlayer { private OnFFTCallback onFFTCallback; public interface OnFFTCallback { - void onFFT(int[] data); + void onFFT(short[] data); } public void setOnFftCallback(OnFFTCallback onFFTCallback) { this.onFFTCallback = onFFTCallback; } - public void fftCallbackFromJNI(int[] data) { + public void fftCallbackFromJNI(short[] data) { if (data != null && onFFTCallback != null) { onFFTCallback.onFFT(data); }