Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

buffer time (size) configuration #70

Open
renanyoy opened this issue Jun 28, 2023 · 5 comments
Open

buffer time (size) configuration #70

renanyoy opened this issue Jun 28, 2023 · 5 comments

Comments

@renanyoy
Copy link

renanyoy commented Jun 28, 2023

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

@anarchuser
Copy link
Owner

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.

@renanyoy
Copy link
Author

renanyoy commented Jul 10, 2023

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 ;)

@renanyoy
Copy link
Author

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

@anarchuser
Copy link
Owner

a fixed buffer size certainly works to some degree. I need to test it to ensure it doesn't misbehave, though.

@anarchuser
Copy link
Owner

also yes, the example isn't exactly good code. Feel free to improve it if you enjoy it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants