Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Low-level audio API for Android

Tags:

android

audio

I'm looking for some way in Android to play in-memory audio in a manner analogous to the waveOutOpen family of methods in Windows programming.

The waveOut... methods essentially let an application create arrays of sample values (like in-memory WAV files without the headers) and dump them into a queue for sequential playback. Windows transitions seamlessly from one array to the next, so as long as the application keeps dumping arrays into the queue ahead of playback, the program can create and play continuous audio of any arbitrary length. The Windows API also incorporates a callback mechanism that the application can use to indicate progress and load additional buffers.

As far as I can tell, the Android audio API lets an application play a file from local storage or a URL, or from a memory stream. Is there any way to get Android to "queue up" MediaPlayer.start() calls so that one player transitions (without glitches) into the next upon play completion? It appears that Jet does something like this, but only with its own internal synthesis engine.

Is there any other way of accessing Android audio in a waveOutOpen way?

like image 928
MusiGenesis Avatar asked Aug 09 '10 02:08

MusiGenesis


1 Answers

android.media.AudioTrack

... is the class you are probably looking for.

http://developer.android.com/reference/android/media/AudioTrack.html#AudioTrack%28int,%20int,%20int,%20int,%20int,%20int%29

After creating it you simply feed it with binary data with given format using following method:

AudioTrack.writeTo(...)
like image 55
plugmind Avatar answered Sep 23 '22 19:09

plugmind