Thread: C library for audio development in Android

  1. #1
    Registered User
    Join Date
    Oct 2008
    Posts
    77

    C library for audio development in Android

    Hi,
    I am currently doing audio development in Java under Android, and experiencing significant latency, which is very upsetting. I am skilled in using the NDK and doing C/C++ coding at sysinternals level.
    Since my developments are for Android devices, and because Android is based on the Linux kernel I would like to migrate most of the audio devices and processing code in C++, close to the kernel, then integrate it into a light application wrapper in Java via the JNI interface.
    My question is: what would be the most performant C++ audio library in terms of connecting to the Linux /devs: microphone, audio files and output (loudspeakers, headphones)? I've looked at SDL, OpenGL ES but have just a satellite, superficial view. Also, I've heared about other libs, so I appreciate your advice.
    Thanks!

  2. #2
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    Quote Originally Posted by Opariti View Post
    what would be the most performant C++ audio library in terms of connecting to the Linux /devs: microphone, audio files and output (loudspeakers, headphones)?
    OpenSL ES

  3. #3
    Registered User
    Join Date
    Oct 2008
    Posts
    77
    Thanks. I have arrived to compare OpenSL ES and ALSA. While ALSA is the lowest level to the Linux kernel its use doesn't provide portability. The Android interface to it is OpenSL ES which is a generic interface, therefore I'll use it. My primary concern is to reduce latency and, indeed, everything I've found points to OpenSL ES. If you have coding experience with it I'd appreciate some additional comments (best practice, links, traps to avoid ...).

  4. #4
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    Quote Originally Posted by Opariti View Post
    If you have coding experience with it I'd appreciate some additional comments (best practice, links, traps to avoid ...).
    I've never used it (I doubt many people do, being so low level). So, my (generic) advise would be to pay close attention to the manual. It's all to easy to think that you've learned-up all you need to once you "get it working", and miss important details that later come back to haunt you.

  5. #5
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Can you actually open an ALSA device directly on a stock Android build? I have never tried it.

    I maintain a native C++ audio layer for a commercial Android product and believe it or not, we do the audio capture in Java and then pass it into the C++ code. I looked into OpenSL ES once as a way to reduce some of the buffer copies, but it made my head hurt. We don't have extremely low latency requirements, so I didn't pursue it. But my experience and what I've heard around is that even native audio access still has an unacceptably high latency on Android for certain applications like real time audio synthesis or effects processing. Although it is apparently improving.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Android Development
    By Program_Me in forum Game Programming
    Replies: 2
    Last Post: 06-21-2012, 05:12 PM
  2. Audio Library
    By twomers in forum Tech Board
    Replies: 6
    Last Post: 09-18-2008, 02:42 PM
  3. Audio Compression Library in C++
    By peyman_k in forum C++ Programming
    Replies: 1
    Last Post: 07-24-2008, 08:27 PM
  4. Need help with audio library on DOS...
    By Marton79 in forum C Programming
    Replies: 10
    Last Post: 08-25-2006, 12:32 AM
  5. Portable Audio Library
    By CornedBee in forum C++ Programming
    Replies: 2
    Last Post: 05-19-2005, 02:09 AM

Tags for this Thread