Speex on Android

Source: Internet
Author: User
Speex on androidposted on Limit L 6, 2011, am, by Mario, under
Android,
OMG ponies !.

Jspeex does not work very well on Android, encoding times are between 0.03 to 0.2 seconds for a 320 samples frame. way to much for any real-time app (Can you say in-game voice chat? : P). So I set out to get
Native speex to compile for Android. A couple of steps are involved if you don't want to go the configure Road with ndk r5b.

  1. Download the latest speex source distri.
  2. Create your project's folder, and a JNI/FOLDER inside that folder
  3. Copy the libspeex/and include/folders from the speex distri to your JNI/folder. You shocould end up with $ Project/JNI/libspeex and $ Project/JNI/include
  4. Add the following thingy as your android. mk file in your JNI/folder
    LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE    := libspeexLOCAL_CFLAGS = -DFIXED_POINT -DUSE_KISS_FFT -DEXPORT="" -UHAVE_CONFIG_HLOCAL_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)

  5. Add the following thingy as your application. mk file in the JNI/folder
    APP_ABI := armeabi armeabi-v7a

    This will compile binaries for the arm and arm-v7a CPUs.

  6. Add the following thingy as a file called speex_config_types.h to the $ Project/JNI/include/speex/folder.
    #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

  7. Switch to the JNI/folder in your shell and type ndk-build. You'll end up with shared libs in the libs/armeabi and libs/armeabi-v7a folder
  8. Write a JNI wrapper for decoding and encoding
  9. ...
  10. Profit!

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.

Paste: http://www.badlogicgames.com/wordpress? P = 1726 & utm_source = feedburner & utm_medium = feed & utm_campaign = feed % 3A + planetandroidcom + % 28 planet + Android % 29

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.