How can I write a short[] array to a .wav file in Java?

19 Views Asked by At

I have a simple music application. It uses AudioTrack to playback music the user has created, and AudioTrack requires audio data in the form of a short[]. I would like to implement an "export" feature where the music is written to a .wav file.

Android does not seem to have a dedicated API for this. The best thing I can think of is just playing back the audio and somehow recording it right off the speaker output. Of course this is not good as the user might not want to play it back again, you have to wait for it to play through the whole song, system notification sounds might interrupt it, etc.

0

There are 0 best solutions below