SFML community forums

Help => Audio => Topic started by: ZeroZ30o on November 24, 2018, 07:34:19 pm

Title: Streaming a custom format
Post 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?
Title: Re: Streaming a custom format
Post by: eXpl0it3r on November 24, 2018, 09:43:24 pm
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. :)
Title: Re: Streaming a custom format
Post by: ZeroZ30o on November 24, 2018, 09:59:05 pm
Ah, I didn't know a specialized stream class already existed, must've missed it on the tutorial. Thanks.
Title: Re: Streaming a custom format
Post by: ZeroZ30o on November 24, 2018, 11:16:05 pm
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
Title: Re: Streaming a custom format
Post by: Laurent on November 25, 2018, 10:00:15 am
For the record: when you load a sf::Music from a sf::InputStream, the stream must provide a file, not raw audio data.