8.在Java层创建Speex工具类,内容如下:
- package com.trunkbow.speextest;
- public class Speex {
- /* quality
- * 1 : 4kbps (very noticeable artifacts, usually intelligible)
- * 2 : 6kbps (very noticeable artifacts, good intelligibility)
- * 4 : 8kbps (noticeable artifacts sometimes)
- * 6 : 11kpbs (artifacts usually only noticeable with headphones)
- * 8 : 15kbps (artifacts not usually noticeable)
- */
- private static final int DEFAULT_COMPRESSION = 8;
- Speex() {
- }
- public void init() {
- load();
- open(DEFAULT_COMPRESSION);
- }
- private void load() {
- try {
- System.loadLibrary("speex");
- } catch (Throwable e) {
- e.printStackTrace();
- }
- }
- public native int open(int compression);
- public native int getFrameSize();
- public native int decode(byte encoded[], short lin[], int size);
- public native int encode(short lin[], int offset, byte encoded[], int size);
- public native void close();
- }
9、使用cygwin编译,生成so文件。
参考:
点击这里这个是一个Android recorder ,使用speex编码。
