如何在Android中使用Rubber Band库实现音高变换?

问题描述 投票:0回答:1

我正在开发一款用于变调的 Android 应用程序,并遇到了一些挑战。最初,我尝试使用 Superpowered,但在改变音调时遇到了声音失真的问题。现在,我正在尝试构建并使用适用于 Android 的 Rubber Band 库。然而,提供的示例相当过时,而且我还探索了其他第三方开源示例,但没有取得太大成功——它们要么没有维护,要么基于非常旧的代码。

我是在 Android 中使用本机代码的新手,所以我可能会遗漏一些基本的东西。有人可以逐步指导我如何将橡皮筋库集成到我的 Android 应用程序中吗?

这是我正在尝试构建的橡皮筋库的链接:Github 链接

我尝试使用 ndk-build 命令构建 .mk 文件,但由于参考资料相当过时,我遇到了许多错误。此外,从那时起,橡皮筋库经历了多次更新,这可能会导致这些问题。
这是我正在使用的 android.mk 文件。

LOCAL_PATH := $(call my-dir)/..
LOCAL_MODULE := rubberband
LOCAL_MODULE_FILENAME := librubberband-jni

RUBBERBAND_PATH := $(LOCAL_PATH)
RUBBERBAND_SRC_PATH := $(RUBBERBAND_PATH)/src

LOCAL_C_INCLUDES := $(LOCAL_PATH) $(LOCAL_PATH)/src

LOCAL_CFLAGS := \
    -Wall \
    -I$(RUBBERBAND_PATH) \
    -I$(RUBBERBAND_SRC_PATH) \
    -DUSE_SPEEX \
    -DUSE_KISSFFT \
    -DPROCESS_SAMPLE_TYPE=float \
    -DLACK_POSIX_MEMALIGN \
    -DUSE_OWN_ALIGNED_MALLOC \
    -DLACK_SINCOS \
    -DNO_EXCEPTIONS \
    -DNO_THREADING \
    -DNO_THREAD_CHECKS

RUBBERBAND_JNI_FILES := \
    $(RUBBERBAND_SRC_PATH)/jni/RubberBandStretcherJNI.cpp

RUBBERBAND_SRC_FILES := \
        $(RUBBERBAND_SRC_PATH)/base/Profiler.cpp \
        $(RUBBERBAND_SRC_PATH)/system/Thread.cpp \
        $(RUBBERBAND_SRC_PATH)/system/Allocators.cpp \
        $(RUBBERBAND_SRC_PATH)/system/sysutils.cpp \
        $(RUBBERBAND_SRC_PATH)/system/VectorOpsComplex.cpp \
        $(RUBBERBAND_SRC_PATH)/StretcherChannelData.cpp \
        $(RUBBERBAND_SRC_PATH)/dsp/AudioCurveCalculator.cpp \
        $(RUBBERBAND_SRC_PATH)/dsp/FFT.cpp \
        $(RUBBERBAND_SRC_PATH)/dsp/Resampler.cpp \
        $(RUBBERBAND_SRC_PATH)/audiocurves/SilentAudioCurve.cpp \
        $(RUBBERBAND_SRC_PATH)/audiocurves/CompoundAudioCurve.cpp \
        $(RUBBERBAND_SRC_PATH)/audiocurves/HighFrequencyAudioCurve.cpp \
        $(RUBBERBAND_SRC_PATH)/audiocurves/SpectralDifferenceAudioCurve.cpp \
        $(RUBBERBAND_SRC_PATH)/audiocurves/ConstantAudioCurve.cpp \
        $(RUBBERBAND_SRC_PATH)/audiocurves/PercussiveAudioCurve.cpp \
        $(RUBBERBAND_SRC_PATH)/StretcherImpl.cpp \
        $(RUBBERBAND_SRC_PATH)/StretcherProcess.cpp \
        $(RUBBERBAND_SRC_PATH)/StretchCalculator.cpp \
        $(RUBBERBAND_SRC_PATH)/RubberBandStretcher.cpp \
        $(RUBBERBAND_SRC_PATH)/speex/resample.c

LOCAL_SRC_FILES += \
    $(RUBBERBAND_JNI_FILES) \
        $(RUBBERBAND_SRC_FILES)

LOCAL_SRC_FILES += \
    $(RUBBERBAND_SRC_PATH)/kissfft/kiss_fft.c \
    $(RUBBERBAND_SRC_PATH)/kissfft/kiss_fftr.c

ifeq ($(TARGET_ARCH_ABI), x86_64)
LOCAL_CFLAGS += \
    -O3 \
    -DUSE_POMMIER_MATHFUN \
    -DNO_TIMING \
    -DNO_TIMING_COMPLETE_NOOP

endif

ifeq ($(TARGET_ARCH_ABI), arm64-v8a)
LOCAL_CFLAGS += \
    -O3 \
    -DUSE_POMMIER_MATHFUN \
    -DNO_TIMING \
    -DNO_TIMING_COMPLETE_NOOP

endif

ifeq ($(TARGET_ARCH_ABI), armeabi-v7a)
LOCAL_CFLAGS += \
    -O3 \
    -mfpu=neon \
    -mfloat-abi=softfp \
    -ffast-math \
    -ftree-vectorize \
    -freciprocal-math \
    -fsingle-precision-constant \
    -D__ARM_ARCH_7__ \
    -DARM_RUNFAST \
    -DUSE_POMMIER_MATHFUN \
    -DNO_TIMING \
    -DNO_TIMING_COMPLETE_NOOP

LOCAL_ARM_MODE := arm
LOCAL_ARM_NEON := true
endif

ifeq ($(TARGET_ARCH_ABI), armeabi)
LOCAL_CFLAGS += \
    -O3 \
    -DNO_TIMING \
    -DNO_TIMING_COMPLETE_NOOP

LOCAL_ARM_MODE := arm
LOCAL_ARM_NEON := false
endif

LOCAL_LDLIBS += -llog

include $(BUILD_SHARED_LIBRARY)
android cmake android-ndk pitch-shifting rubber-band
1个回答
0
投票

这是 android.mk 文件,它可以帮助我编译橡皮筋库:

LOCAL_PATH := $(call my-dir)
RUBBERBAND_SRC_PATH := $(LOCAL_PATH)/..

include $(CLEAR_VARS)

LOCAL_MODULE := rubberband

RUBBERBAND_JNI_FILES := \
$(RUBBERBAND_SRC_PATH)/src/jni/RubberBandStretcherJNI.cpp

LOCAL_SRC_FILES := $(RUBBERBAND_SRC_PATH)/single/RubberBandSingle.cpp

LOCAL_C_INCLUDES := \
$(RUBBERBAND_JNI_FILES) \
$(RUBBERBAND_SRC_PATH)/single

LOCAL_CPPFLAGS := -std=c++11

LOCAL_CPPFLAGS += -fexceptions


LOCAL_LDLIBS := -lc++_shared

include $(BUILD_SHARED_LIBRARY)
© www.soinside.com 2019 - 2024. All rights reserved.