I am getting PCM streams through ethernet port. So far, I am able to capture the packets and takeout the pcm_payload data from them.
How to play this raw PCM data in android? The PCM data is 16-bit 2 channel, 44.1kHZ rate stream.
I am both new to android application programming and audio programming. Sorry if this is a trivial question.
You can use AudioTrack to play PCM data!
Maybe like this:
int bufsize = AudioTrack.getMinBufferSize(44100,
AudioFormat.CHANNEL_OUT_STEREO,
AudioFormat.ENCODING_PCM_16BIT);
AudioTrack audio = new AudioTrack(AudioManager.STREAM_MUSIC,
44100, //sample rate
AudioFormat.CHANNEL_OUT_STEREO, //2 channel
AudioFormat.ENCODING_PCM_16BIT, // 16-bit
bufsize,
AudioTrack.MODE_STREAM );
audio.play()
then invoke audio.write()
to write your PCM data.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With