Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: writing AudioTrack to .wav file - possible?

Tags:

android

audio

So I need to generate some tones with ToneGenerator and write them to .wav file. Is is possible using ToneGenerator or AudioTrack?

Are there any ways to access audio frames directly in AudioTrack, record to file with AudioOutput or do anything else?

like image 493
kagali-san Avatar asked Nov 23 '25 17:11

kagali-san


1 Answers

ToneGenerator specifies the output stream type, to which the generated audio data is written. There is no possibility to directly access the generated audio data.

Of course, you can record the played tones, e.g. via internal microphone. But that's probably not what you wanted.

You could also record them digitally on some devices by using AudioRecord when using the appropriate settings for audioSource, sampleRateInHz, channelConfig, audioFormat and streamType.

Concerning AudioTrack, since you have to use write() methods, you necessarily have direct access to the audio data.

like image 72
Hartmut Pfitzinger Avatar answered Nov 25 '25 07:11

Hartmut Pfitzinger



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!