原文地址:http://www.badlogicgames.com/wordpress/?p=1726&cpage=1#comment-109782
下载最新的SPEEX源代码,我的是1.21RC1
1 创建一个 jni目录,将libspeex与include放在jni目录下,即$jni/libspeex ,$jni/include
2 新建Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libspeex
LOCAL_CFLAGS = -DFIXED_POINT -DUSE_KISS_FFT -DEXPORT="" -UHAVE_CONFIG_H
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
LOCAL_SRC_FILES := \
./libspeex/bits.c \
./libspeex/buffer.c \
./libspeex/cb_search.c \
./libspeex/exc_10_16_table.c \
./libspeex/exc_10_32_table.c \
./libspeex/exc_20_32_table.c \
./libspeex/exc_5_256_table.c \
./libspeex/exc_5_64_table.c \
./libspeex/exc_8_128_table.c \
./libspeex/fftwrap.c \
./libspeex/filterbank.c \
./libspeex/filters.c \
./libspeex/gain_table.c \
./libspeex/gain_table_lbr.c \
./libspeex/hexc_10_32_table.c \
./libspeex/hexc_table.c \
./libspeex/high_lsp_tables.c \
./libspeex/jitter.c \
./libspeex/kiss_fft.c \
./libspeex/kiss_fftr.c \
./libspeex/lpc.c \
./libspeex/lsp.c \
./libspeex/lsp_tables_nb.c \
./libspeex/ltp.c \
./libspeex/mdf.c \
./libspeex/modes.c \
./libspeex/modes_wb.c \
./libspeex/nb_celp.c \
./libspeex/preprocess.c \
./libspeex/quant_lsp.c \
./libspeex/resample.c \
./libspeex/sb_celp.c \
./libspeex/scal.c \
./libspeex/smallft.c \
./libspeex/speex.c \
./libspeex/speex_callbacks.c \
./libspeex/speex_header.c \
./libspeex/stereo.c \
./libspeex/vbr.c \
./libspeex/vq.c \
./libspeex/window.c
include $(BUILD_SHARED_LIBRARY)
3 jni目录下新建Application.mk
APP_ABI := armeabi armeabi-v7a
4 在jni/include/speex 目录下 将speex_config_type.h修改为如下
#ifndef __SPEEX_TYPES_H__
#define __SPEEX_TYPES_H__
typedef short spx_int16_t;
typedef unsigned short spx_uint16_t;
typedef int spx_int32_t;
typedef unsigned int spx_uint32_t;
#endif
5 然后在shell终端中到你的jni目录下,运行ndk-build,就可以开始编译了
6 然后就可以看到下图,生成了我们要的libspeex.so啦
7 写一个jni包裹文件,去调用编码和解码函数
8 最后享受吧。。。
这个大牛还上传了自己的工程,在这里下载
I zipped up my jni folder, you can download it here. Just fire up your shell, make sure your NDK is in your $PATH and ndk-build the shit out of it. Enjoy.