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

MicStream.sampleRate seems never completes #88

Open
westlinkin opened this issue Nov 20, 2023 · 9 comments
Open

MicStream.sampleRate seems never completes #88

westlinkin opened this issue Nov 20, 2023 · 9 comments

Comments

@westlinkin
Copy link

double? sampleRate = await MicStream.sampleRate; works fine in 0.6.5

but in 0.7.1+2, use int sampleRate = await MicStream.sampleRate never completes. Is there something I am missing? the same code upgraded from 0.6.5 to 0.7.1+2

@anarchuser
Copy link
Owner

Does the await complete once you start listening to the stream?

@westlinkin
Copy link
Author

Does the await complete once you start listening to the stream?

I get the sampleRate after creating the stream. I was not tested after listening.

But I have to get the sample rate beforehand, to connect wss server (as a parameter). I read somewhere in the document, even if i set the sample rate, the iOS platform may not obey the configuration i set, so i have to get it after creating the stream and before listening.

I will try it later though, and get back to you.

@anarchuser
Copy link
Owner

 even if i set the sample rate, the iOS platform may not obey the configuration i set

This is correct and the main issue. There is no good semantic to resolve this.
Either you assert that your preferred sample rate will be the actually used one, then you can send the sample rate you're configuring the stream with to your server.
Or you send whatever the platform tells you is correct, requiring at least one set of samples to have been recorded.

I'm still looking for ways to improve this situation but I cannot circumvent platform limitations. You will have to adjust your server semantics, or not support iOS for the time being. Or you start recording before connecting to the server.

@anarchuser
Copy link
Owner

also have a look at #72 for a previous discussion the topic

@timmolter
Copy link

@westlinkin How are you piping the audio to a WS server? I'm trying to accomplish the same thing.

@westlinkin
Copy link
Author

@westlinkin How are you piping the audio to a WS server? I'm trying to accomplish the same thing.

Sorry for the late reply. You can just listen to the stream, and _channel.sink.add(uint8List);, _channel is the websocket channel, uint8List is the onData call of the StreamSubscription.

@westlinkin
Copy link
Author

westlinkin commented Feb 20, 2024

even if i set the sample rate, the iOS platform may not obey the configuration i set

This is correct and the main issue. There is no good semantic to resolve this. Either you assert that your preferred sample rate will be the actually used one, then you can send the sample rate you're configuring the stream with to your server. Or you send whatever the platform tells you is correct, requiring at least one set of samples to have been recorded.

I'm still looking for ways to improve this situation but I cannot circumvent platform limitations. You will have to adjust your server semantics, or not support iOS for the time being. Or you start recording before connecting to the server.

Even after I start listening to the stream, the await MicStream.sampleRate did not complete. version 0.6.5, on my iPad (ios 17.2.0) and macOS, it works fine. on ios simulator( ios 17.0.1), it brokes. but vesion 0.7.1+2, it brokes even on macOS.

@anarchuser
Copy link
Owner

oh alright. If the problem occurs on an iOS emulator, this is a duplicate of #27

@anarchuser
Copy link
Owner

I'll give it another look to see what changes could have resulted in a different behaviour for macOS

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

3 participants