Why Ogg Vorbis?
Compiling an open-source C++ project for Android NDK
The first step is to download the source code and save it to a directory on your hard drive. Then we'll open up a Cygwin prompt by running C:\cygwin\Cygwin.bat and navigate to that folder. Then execute the following command:
This creates a config.h file that tells the open-source project a bit about the destination architecture and environment.
Note: I don't know if those parameters above are exactly right. If you do know the optimal parameters, answer my question on Stack Overflow.

Now, you can either do things the hard way and use the Makefile to compile an Android library (.so) and link that into your project. Or just drag-and-drop the required files into Visual Studio:

Note: Before embedding an open-source library into Visual Studio instead of linking a library or loading a .DLL, check the license terms of the project to make sure this is ok.
Enable optimizations and fix compile problems
First off, I had some compile errors which I fixed by adding the following to os.h:
Then I wanted to enable the ARM-specific assembler optimizations (which sped up the decoding by about 100%), so I added the following to asm_arm.h:
Convert Ogg/Vorbis to PCM
The Tremor library is designed to work with FILE* input, but we're able to create our own callbacks to duplicate this behaviour while reading a memory buffer:
Now we can send it an Ogg/Vorbis buffer already resident in memory:
- MP3 technology is encumbered by patents and I don't want to have to worry about paying royalties or being sued sometime in the future.
- Vorbis is variable bitrate by default, and in listening tests the quality is at least as good as MP3.
- Vorbis also supports gapless encoding, which is a requirement for seamless looping (possible with MP3, but hard).
- There's a very efficient ARM-optimized New-BSD-licensed (free to use) decoder called Tremor (there is also Tremolo, which is even faster).
Compiling an open-source C++ project for Android NDK
The first step is to download the source code and save it to a directory on your hard drive. Then we'll open up a Cygwin prompt by running C:\cygwin\Cygwin.bat and navigate to that folder. Then execute the following command:
This creates a config.h file that tells the open-source project a bit about the destination architecture and environment.
Note: I don't know if those parameters above are exactly right. If you do know the optimal parameters, answer my question on Stack Overflow.

Now, you can either do things the hard way and use the Makefile to compile an Android library (.so) and link that into your project. Or just drag-and-drop the required files into Visual Studio:

Note: Before embedding an open-source library into Visual Studio instead of linking a library or loading a .DLL, check the license terms of the project to make sure this is ok.
Enable optimizations and fix compile problems
First off, I had some compile errors which I fixed by adding the following to os.h:
Then I wanted to enable the ARM-specific assembler optimizations (which sped up the decoding by about 100%), so I added the following to asm_arm.h:
Convert Ogg/Vorbis to PCM
The Tremor library is designed to work with FILE* input, but we're able to create our own callbacks to duplicate this behaviour while reading a memory buffer:
Now we can send it an Ogg/Vorbis buffer already resident in memory:
Continue reading Ogg Vorbis audio decoding on Android NDK.