Android audio programming nightmare - soundpool, audiotrack arrghh?

前端 未结 3 1658
眼角桃花
眼角桃花 2021-01-02 13:55

I\'ve built a simple music sequencer Android app that plays multiple audio files.

Originally I was using SoundPool to play mp3 files and it worked perfectly on 2.3.4

3条回答
  •  孤独总比滥情好
    2021-01-02 14:44

    Like user harikris suggests, I would highly recommend you move all your audio playback and processing code to Android NDK using the OpenSL ES library for the best performance.

    As I understand, the AudioTrack API is built on top of OpenSL ES Buffer Queue Audio Player. So you could probably improve performance by working directly with the NDK, writing C code that is called from your Java/Android layer to work with the sound.

    The native-audio example mentioned above contains code that will show you how to play a sound file directly from a URI. In my experience, the results from this method are better than AudioTrack in Static Mode.

    Soundpool is generally reserved for very short sounds that can be played from memory and its not a scalable solution for your sequencer especially if you introduce large files.

    Here are some links that have helped me out with my applications: -General Information on OpenSL ES for Android: http://mobilepearls.com/labs/native-android-api/opensles/

    -An Android audio blog with some great example code: http://audioprograming.wordpress.com

    Edit: The old mobile pearl link appears to be down. Here's a working one:http://mobilepearls.com/labs/native-android-api/ndk/docs/opensles/index.html

提交回复
热议问题