40

I've been trying to look into using the OpenSL ES library that is available for doing native audio with android 2.3, but it appears that the header files and the 600 page pdf of the spec are the only available documentation.

Where should I be looking for examples, tutorials, or a brief overview of the capabilities?

RzR
  • 3,068
  • 29
  • 26
mjr
  • 1,963
  • 4
  • 20
  • 21

5 Answers5

21

There's an example app that comes with the NDK called NativeAudio. It has examples of nearly anything you would ever want to implement: effects, streaming, synthesis, etc. If you look at its code, you'll get a good head start.

zwcloud
  • 4,546
  • 3
  • 40
  • 69
Phonon
  • 12,549
  • 13
  • 64
  • 114
16

You could also check victor lazzarini's audio programming blog, it has an android section: http://audioprograming.wordpress.com/category/android/

There you will find working examples, they were extremely useful to me to get started with openSL and can be used as a base to develop audio applications with ndk.

And also, don't overlook the specifications document, it's not so long after all, the first part is no more than fifty pages and gives you the needed perspective to understand how everything works, the rest is for reference use. Be careful that some things in android openSL implementation differ from the specifications: see in your-ndk-directory/docs/opensles/index.html for more informations about this.

athos
  • 1,281
  • 3
  • 14
  • 24
  • 1
    @Timo, the question is more than five years old, a lot of things have changed since then (there's even a new audio API that can be used instead of OpenSL on newer devices!). If you are still looking for examples, have a look at these google's github repos: https://github.com/googlesamples/android-ndk/tree/master/audio-echo and https://github.com/googlesamples/android-audio-high-performance . My advice regarding the OpenSL specs still stands. Another source of info is the ndk google group: https://groups.google.com/forum/#!forum/android-ndk , just search with the "audio" keyword. – athos Jan 08 '18 at 03:02
12

After a quite searching the more valuable information I've found:

zwcloud
  • 4,546
  • 3
  • 40
  • 69
gergonzalez
  • 2,488
  • 1
  • 22
  • 21
7

For those of you wanting just to play single soundfiles or record a short snapshot (in a single buffer), the NDK project will be enough. I had a look at the "Android NDK Beginner's Guide" and it really does not explain too much more than the sample NDK project.

But really, for these applications, you are probably better off with one of the Java APIs. Using OpenSL ES for them is a bit of an overkill IMHO. There will be much more code to write and no real gain.

The advantage of OpenSL is for those interested in lower latencies (when these become available) for audio synthesis and processing, and for this, you will probably want to stream audio, rather than play/record single buffers. The book chapter and the NDK example will not teach you about that. The blogposts in the audio programming blog are more informative for these purposes.

R F
  • 79
  • 1
  • 1
  • and what are those blog posts ? Is your answer is really an answer ? it looks like a comment to me.. – Amit Dec 07 '12 at 10:25
  • I believe he's referring to this: http://audioprograming.wordpress.com/, which is actually called "The Audio Programming Blog" – Mike Ortiz Feb 06 '13 at 18:58
1

One of Victor Lazzarini's audio programming blog on android section is really a good start. http://audioprograming.wordpress.com/category/android/

And there is a direct downloadable example code from bitbucket git repository for this blog, that's the most welcome part.

The build and run is quite simple. For me, I need these steps for build and run this example:

  1. Install SWIG: swig-3.0.2 . Install it by 3 steps:

    $ configure $ make $ sudo make install.

  2. Edit the build.sh to reflect the location of your NDK. And run the build.sh script at the top-level directory.
  3. Generate build.xml by:

    $ android update project --name opensl-es-audiotest --target 1 --path ./

  4. Build with ant: $ ant debug
  5. Then, you can install it to your device and test it:

    $ adb install bin/opensl-es-audiotest-debug.apk

gary
  • 1,569
  • 3
  • 20
  • 30