SFML community forums
Help => Audio => Topic started by: ZeroZ30o on November 24, 2018, 07:34:19 pm
-
I've got real time data coming into a buffer, and I'd like to stream said buffer (think voIP).
I've tried to make a class inherit from sf::InputStream for sf::Music to be able to stream it, but I wasn't succesful.
Is an example of an sf::InputStream with a vector of sf::Int16 (sound data) provided anywhere so I could use it? Or is this not possible, since sf::Music seems to automatically detect a stream's sample rate?
-
What kind of data are you looking to playback?
If you already have the raw audio data, you can inherit from sf::SoundStream (https://www.sfml-dev.org/documentation/2.5.1/classsf_1_1SoundStream.php#details) and implement your own streaming class.
SFML also ships with a complete example for VoIP (https://github.com/SFML/SFML/tree/master/examples/voip), quite basic, but should give you an idea. :)
-
Ah, I didn't know a specialized stream class already existed, must've missed it on the tutorial. Thanks.
-
There's a mistake in https://www.sfml-dev.org/documentation/2.5.1/classsf_1_1SoundStream.php#details with the example:
You override "void onSeek(sf::Uint32 timeOffset)" instead of "void onSeek(sf::Time timeOffset)".
I got everything working tho
-
For the record: when you load a sf::Music from a sf::InputStream, the stream must provide a file, not raw audio data.