Time to become a sound guy!
**Think of this API (Application Programming Interface) as a huge soundboard in a recording studio. The computer screen is a window into the recording booth. The keywords and classes are buttons, dials, sliders and groups of all of the above situated on the interface/soundboard.
While learning the NDK for Android SDK, I am focusing on OpenSL ES for Android. Sound baby. I'll throw some notes up here. I'm not promising any organization and/or coherency.
This first link is titled, "OpenSL ES for Android". It refers specifically to using OpenSL ES within Android 2.3, the implementations and limitations thereof and other important knowledge and warnings.
Some extracted notes on the above link:
- ...Compiled and linked inline
- You can link your audio content directly into the shared library, and then play it using an audio player with buffer queue data locator. This is most suitable for short PCM format clips. The example code uses this technique for the "Hello" and "Android" clips. The PCM data was converted to hex strings using a
bin2ctool (not supplied).
Note that the field
samplesPerSecis actually in units of milliHz, despite the misleading name. To avoid accidentally using the wrong value, you should initialize this field using one of the symbolic constants defined for this purpose (such as
Platform configuration...OpenSL ES for Android is designed for multi-threaded applications, and is thread-safe.
OpenSL ES for Android supports a single engine per application, and up to 32 objects. Available device memory and CPU may further restrict the usable number of objects.
slCreateEnginerecognizes, but ignores, these engine options:
Planning for source compatibility [things to be very careful about]
...SL_DATAFORMAT_PCMdoes not permit the application to specify the representation of the data as signed integer, unsigned integer, or floating-point. The Android implementation assumes that 8-bit data is unsigned integer and 16-bit is signed integer. In addition, the field
samplesPerSecis a misnomer, as the actual units are milliHz. These issues are expected to be addressed in the next OpenSL ES version, which will introduce a new extended PCM data format that permits the application to explicitly specify the representation, and corrects the field name. As this will be a new data format, and the current PCM data format will still be available (though deprecated), it should not require any immediate changes to your code.
...The Android simple buffer queue data locator and interface are identical to the OpenSL ES 1.0.1 buffer queue locator and interface, except that Android simple buffer queues may be used with both audio players and audio recorders, and are limited to PCM data format. [OpenSL ES 1.0.1 buffer queues are for audio players only, and are not restricted to PCM data format.]
For recording, the application should enqueue empty buffers. Upon notification of completion via a registered callback, the filled buffer is available for the application to read.
For playback there is no difference. But for future source code compatibility, we suggest that applications use Android simple buffer queues instead of OpenSL ES 1.0.1 buffer queues.
Objects and interface initialization[Important to review this section extensively to understand how OpenSL operates. No room to paste it all here.]
[found these bits interesting]
...Callback handlers are called from internal non-application thread(s) which are not attached to the Dalvik virtual machine and thus are ineligible to use JNI...
PerformanceAs OpenSL ES is a native C API, non-Dalvik application threads which call OpenSL ES have no Dalvik-related overhead such as garbage collection pauses. However, there is no additional performance benefit to the use of OpenSL ES other than this. In particular, use of OpenSL ES does not result in lower audio latency, higher scheduling priority, etc. than what the platform generally provides. On the other hand, as the Android platform and specific device implementations continue to evolve, an OpenSL ES application can expect to benefit from any future system performance improvements.
I don't see the connection! Huh? What? If you can figure out how the above link is indirectly connected to an industrial metal group from the 80's and 90's you get a gold star.
The official Khronos site on OpenSL ES. (Non-specific to Android of course)
NOTE:I must apologize that there isn't some sort of tutorial or sample code or anything here. Unfortunately, I had to shift gears and run off and go a different direction for a while, so I never did really get into OpenSL ES any further (YET!). Those links are all I've got.