2

我正在尝试使用 Android NDK编译SoundTouch库。我从这里得到了一些指令来在 android 中编译这个库。

但是当我尝试使用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)

现在一切正常。谢谢

4

2 回答 2

2

I have successfully compiled by changing my android.mk file :

here is my android.mk file

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)
于 2012-07-05T10:11:59.473 回答
2

看看这个链接这个家伙已经编译准备使用 SoundTouch Android 包装器。

  • 目前能够进行时间拉伸和音高转换。
  • 目前仅支持带有 FPU (armeabi-v7a) 的 Android。

示例用法:

//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 链接了解更多详情。

于 2014-10-03T11:49:18.597 回答