anarchuser / mic_stream

Flutter plugin to get an infinite audio stream from the microphone
https://pub.dev/packages/mic_stream
GNU General Public License v3.0
100 stars 68 forks source link

Android PCM 16 Bit uses Big Endian. #75

Closed mannprerak2 closed 11 months ago

mannprerak2 commented 1 year ago

Seems like the android implementation is using byte[], which uses stores data in big endian.

byte[] data = new byte[BUFFER_SIZE];
recorder.read(data, 0, BUFFER_SIZE);

See: https://stackoverflow.com/a/76798533/7186086

anarchuser commented 1 year ago

That is strange as I am fairly certain that I received data in LE when I last checked. Regardless, it's high time to adapt this plugin to the AudioRecord changes, including using ByteBuffer. ETA ~1 week

liamappelbe commented 1 year ago

I just ran into this too. Looking at the AudioRecorder docs, the read function is overloaded. package:mic_stream is using this overload, which takes a byte[]. But the docs say that overload should only be used when you're using 8 bit PCM. The 16 bit overload is this one.

anarchuser commented 1 year ago

alright, I will take another look. I want to settle this matter once and for all by adding specific functions for getting ints, shorts, and whatever else, and making sure that those return proper values, by whatever means necessary.

I do need time though, I'm very busy at the moment. So please bear with it

anarchuser commented 11 months ago

Fixed in version 0.7.1. Feel free to check + reopen if any issues persist