Record/capture internal sound playback of Android app and export mp3?

fxfuture picture fxfuture · Aug 8, 2013 · Viewed 16.2k times · Source

Is it possible to record the internal sound generated by the app?

My app allows you to create and play back musical sequences.

soundPool.play(soundIds[i], 1f, 1f, 1, 0,  Constants.TIME_RATE);

I'd like to be able to record the sequence and export to mp3.

I've looked into Audio Capture but setAudioSource (int audio_source) only seems to accept MIC recording.

Thanks

Answer

Michael picture Michael · Aug 8, 2013

No, there's no API for getting the audio output, even for your own app (actually that's not entirely true, because you can get it through the Visualizer API, but it would be of such low quality that I doubt it would be of any use for you).

If you want that kind of functionality you'll have to implement it yourself. That is; as you start playback of sounds, mix them and write the result to a file as well. If the sounds are compressed you'll also have to take case of decoding them yourself.

Note that there's no MP3 encoder included with Android, so you'd have to supply your own MP3 encoder anyway if that's the format you want to export in.