Martin Roth
unread,Dec 4, 2009, 7:20:56 AM12/4/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Android Music Developers
Alex, it was great to meet you on Wednesday. Thanks for starting the
group! Hopefully we can get more people involved.
One thing that has become clear is that a canonical design pattern for
low-latency real-time audio has emerged for Android. From a high
level, the audio thread looks like:
audioRecord.read(inputBuffer, 0, inputBuffer.length);
audioGenerator.processBuffers(inputBuffer, outputBuffer); // this
method should be implemented with the NDK
audioTrack.write(outputBuffer, 0, outputBuffer.length);
Of course, the audio thread should be set to the maximum priority:
Thread.setPriority(Thread.MAX_PRIORITY);
And the process in which the thread is running should also be set the
maximum priority:
Process.setThreadPriority(Process.THREAD_PRIORITY_URGENT_AUDIO);
Unfortunately there is no native access to the audio buffers yet, and
so we must always go through Java. This isn't ideal, but it is the
best that we can do at the moment.