Open renanyoy opened 1 year ago
Sorry, the buffer size gets decided by the native libraries themselves. You can have a look at the documentation of your platform of choice and find out whether there is any way to change it there. If you do find something we can integrate it.
I forked mic_stream and patched it with a fixed buffer at 512 bytes for both iOS and Android. it works well.
https://github.com/aestesis/mic_stream
on android I had some doubts it could work cause of AudioRecord.getMinBufferSize but I just ignore its result and it works ;)
btw, I use this code to transform the pcm values in float
for (int i = 0; i < data.length; i += 2) {
final int v0 = (data[i]) + (data[i + 1] << 8);
final int value = v0 > 32767 ? v0 - 65536 : v0;
final double vs = value / 32768.0;
...
}
I thing there is maybe a bug in your example
a fixed buffer size certainly works to some degree. I need to test it to ensure it doesn't misbehave, though.
also yes, the example isn't exactly good code. Feel free to improve it if you enjoy it.
for now the buffer seems to be set at 200 milliseconds (at 44100). I would like to use mic_stream to do real time things would be nice if we could setup the buffer size in milliseconds as config parameter. for example in my case at 20ms for a 60 fps renderer