How process audio while recording realtime on android?


I want to process audio stream add some custom dsp while recording real time.
I can only see api for play or convert a file?
Could someone help me or show me some example ?



Have you had a look at our ‘Record’ project in the Lowlevel examples?

This example shows how to record continuously and play back the same data while, although the recording it does is from a microphone.

You might have to make your own dsp that writes out to a file, see the DSP_Custom example. This would allow you to add the write-to-file dsp after your custom dsp to get the final sound with the DSP effect.


Thanks for your anserwer!

I have mentioned the record demo in low level examples. It’s record via fmod system record api.

Now my impletation is recording via android original AudioRecord.startRecording api, and set listener via AudioRecord.setRecordPositionUpdateListener, and then read buffer when onPeriodicNotification called, and save buffer to my record audio file.

What I want to do is process the buffer via adding fmod dsp in onPeriodicNotification before the buffer written into file?

Here is my code:
private AudioRecord audioRecorder = new AudioRecord(AudioSource.MIC, 44100, AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_16BIT, bufferSize);
private byte[] buffer;
private AudioRecord.OnRecordPositionUpdateListener updateListener = new AudioRecord.OnRecordPositionUpdateListener() {
public void onPeriodicNotification(AudioRecord recorder) {, 0, buffer.length); // Fill buffer
//TODO: process buffer here via fmod dsp
try {
randomAccessWriter.write(buffer); // Write buffer to file
} catch (IOException e) {
Log.e(tag,“Error occured in updateListener, recording is aborted”);