Reputation: 157
I've downloaded and tested the CrossExample android app from Superpowered SDK, and here is my question: How can i listen in real-time my phone's microphone? I need some example codes... My goal is to apply some filters to the audio input (microphone) and listen the result instantly.
Thanks a lot!
Upvotes: 3
Views: 1299
Reputation: 337
Actually it is quiet easy to get the audio input. You just have to enable the input in the constructor of SuperpoweredAndroidAudioIO. To do so set the third parameter to true like this:
audioSystem = new SuperpoweredAndroidAudioIO(
samplerate, buffersize, true, true, audioProcessing, this, -1, SL_ANDROID_STREAM_MEDIA, buffersize * 2);
Now you get the audio input delivered in the process
method of the example. That means in
bool SuperpoweredExample::process(short int *output, unsigned int numberOfSamples)
the same buffer is used for input and output. The input is written to short int *output
and you can grab the length from unsigned int numberOfSamples
. You might want to rename short int *output
to short int *inputoutput
for clarification.
Make sure that you process the input before you overwrite it with the output data. If you want to apply any effects just do it on the input/output buffer in process method.
Also make sure that you have the RECORD_AUDIO
permission in your AndroidManifest.xml
:
<uses-permission android:name="android.permission.RECORD_AUDIO" />
Upvotes: 5
Reputation: 12445
CrossExample will just demonstrate mixing two predefined audio clips (from raw folder of project) using different effects. Team still didn't publish example that will demonstrate functionality you are looking for. It is not trivial (but fairly complex) so I recommend you to get deeper understanding of few existing examples until they publish more code/tutorials so you are getting around those easier later.
Upvotes: 0