我正在尝试使用Android NDK编译SoundTouch lib。我从Here得到了一些指令,用于在android中编译这个lib。
但是当我尝试使用ndk-build
命令编译它时,它会在SoundTouch lib的各种源文件中显示错误:
我尝试按照说明中的说明关闭异常处理,但似乎无效。
我将SoundTouch源中的所有文件复制到项目的JNI文件夹中。这是我的android.mk
文件:
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_CFLAGS :- -frtti -fexceptions
LOCAL_SRC_FILES := AAFilter.cpp BPMDetect.cpp cpu_detect_x86.cpp FIFOSampleBuffer.cpp FIRFilter.cpp main.cpp mmx_optimized.cpp PeakFinder.cpp RateTransposer.cpp RunParameters.cpp SoundTouch.cpp sse_optimized.cpp TDStretch.cpp WavFile.cpp
LOCAL_LDLIBS := -lpcap
LOCAL_MODULE := libSoundTouch
LOCAL_C_INCLUDES := BPMDetect.h FIFOSampleBuffer.h FIFOSamplePipe.h SoundTouch.h STTypes.h
include $(BUILD_SHARED_LIBRARY)
有人可以帮我编译并在Android上使用SoundTouch lib吗?
更新:
我将android.mk
文件更改为
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_CPP_FEATURES += -fno-exceptions
LOCAL_SRC_FILES := \
SoundTouch/AAFilter.cpp \
SoundTouch/BPMDetect.cpp \
SoundTouch/cpu_detect_x86.cpp\
SoundTouch/FIFOSampleBuffer.cpp \
SoundTouch/FIRFilter.cpp \
SoundTouch/mmx_optimized.cpp \
SoundTouch/PeakFinder.cpp \
SoundTouch/RateTransposer.cpp \
SoundTouch/SoundTouch.cpp \
SoundTouch/sse_optimized.cpp \
SoundTouch/TDStretch.cpp
LOCAL_MODULE := libSoundTouch
LOCAL_C_INCLUDES := include/BPMDetect.h include/FIFOSampleBuffer.h include/FIFOSamplePipe.h include/SoundTouch.h include/STTypes.h
include $(BUILD_SHARED_LIBRARY)
现在它的工作一切正常。谢谢
答案 0 :(得分:2)
我已通过更改android.mk
文件成功编译:
这是我的android.mk
文件
include $(CLEAR_VARS)
LOCAL_PATH:= $(call my-dir)
LOCAL_CPP_FEATURES += -fno-exceptions
LOCAL_SRC_FILES := \
SoundTouch/AAFilter.cpp \
SoundTouch/BPMDetect.cpp \
SoundTouch/cpu_detect_x86.cpp\
SoundTouch/FIFOSampleBuffer.cpp \
SoundTouch/FIRFilter.cpp \
SoundTouch/mmx_optimized.cpp \
SoundTouch/PeakFinder.cpp \
SoundTouch/RateTransposer.cpp \
SoundTouch/SoundTouch.cpp \
SoundTouch/sse_optimized.cpp \
SoundTouch/TDStretch.cpp
LOCAL_MODULE := libSoundTouch
LOCAL_C_INCLUDES := include/BPMDetect.h include/FIFOSampleBuffer.h include/FIFOSamplePipe.h include/SoundTouch.h include/STTypes.h
include $(BUILD_SHARED_LIBRARY)
答案 1 :(得分:2)
查看已编译的THIS链接已准备好使用SoundTouch Android包装。
- 目前能够进行时间拉伸和音高变换。
- 目前仅支持带有FPU的机器人(armeabi-v7a)。
使用示例:
//There are currently 16 track id's you can use (0-15), each one has a separate SoundTouch processor.
//Set your audio processing requirements: track id, channels, samplingRate, bytesPerSample,
// tempoChange (1.0 is normal speed), pitchChange (in semi-tones)
SoundTouch soundTouch = new SoundTouch(0, 2, 44100, 2, 1.0f, 2.0f);
//byte[] sizes are recommended to be 8192 bytes.
//put a byte[] of PCM audio in the sound processor:
soundTouch.putBytes(input);
//write output to a byte[]:
int bytesReceived = soundTouch.getBytes(output);
//after you write the last byte[], call finish().
soundTouch.finish();
//now get the remaining bytes from the sound processor.
int bytesReceived = 0;
do
{
bytesReceived = soundTouch.getBytes(output);
//do stuff with output.
} while (bytesReceived != 0)
//if you stop playing, call clear on the track to clear the pipeline for later use.
soundTouch.clearBuffer()
访问上面的github链接了解更多详情。