-
Notifications
You must be signed in to change notification settings - Fork 23
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
Audio buffer stream #148
Audio buffer stream #148
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have some suggestions but this looks great, thank you!
I thought it would be interesting to have a new method to reset the BufferStream. Something like |
To be honest, I'm not the intended audience (I don't foresee needing buffer stream) so I'm not the right person to ask. Maybe the folks who're asking for the feature might tell you? Otherwise, in general, I'm a proponent of YAGNI. |
@alnitak The resetBufferStream method can be useful when audio stream needs to be interuppted due to any reason and new audio stream needs to feed. |
Thanks @prateekmedia, I was thinking of the
Anyway, let's flush this PR and shortly we will think better about what will be useful to add. |
Description
close #144
This new type of
AudioSource
is created by subclassing the SoLoud C++ AudioSource class.It works by initializing it with its parameters, then adding PCM audio data, and finally signaling that no more data is incoming:
setBufferStream
returns the newAudioSource
. Using its parameters, you can set the PCM audio format, the maximum memory usage, the buffering time required to resume playback (when paused to wait for more data), and a callback to handle buffering events.addAudioDataStream*
adds PCM audio data to the stream. Helper methods are available to add signed/unsigned 8-bit integers, signed 16- and 32-bit integers, and 32-bit floats.setDataIsEnded
marks the end of the data stream.The returned
AudioSource
is compatible with filters, oscillators and all other tools.Use-case
example/lib/buffer_stream/websocket.dart
is used for testing. It receives PCM data from a local websocket, provided by the websocketd tool. The Flutter app uses ffmpeg to stream PCM data over the websocket via websocketd, allowing you to simulate slow download speeds and buffering behavior.example/lib/generate.dart
generates audio and fills it into theAudioBuffer
.AudioSource
for flutter_soloud.Type of Change