SFML community forums
Help => Audio => Topic started by: mkalex777 on September 23, 2015, 02:18:59 pm
-
I need to play raw sound stream which is produced in realtime.
Actually, I wrote some interactive engine which produces realtime raw audio & video streams.
The content is interactive, so buffering is possible for a very short time - 50-100 ms.
Currently I'm using Direct3D and DirectSound directly.
But it's hardly linked with Windows, and I want to porting it into Linux and iOS.
I tested SFML and its really simple and beautiful :)
So, I'm thinking about using SFML...
Does SFML support such functionality?
-
What format are your streams in (no "raw" is not format)?
You can call update() on a texture with a RGBA pixel array and sf::Music is able to play from a stream that is correctly formatted for OpenAL.
-
The sf::SoundStream class is what you're looking for, but it currently doesn't allow to change the buffer size (currently, 2 seconds of audio data).
sf::Music is able to play from a stream that is correctly formatted for OpenAL.
Leave OpenAL alone ;)
sf::Music plays audio files, not raw data.
-
Format is 16 bit stereo, engine has it's own resampler, and is able to produce stream with any sample rate supported by hardware. Higher sample rate is better, because sounds may contains complex sound effects with wide range frequencies (up to 115 kHz), usually I'm using 192 kHz.
Does SoundBuffer support loopback playing with notifications of current position?
I want to write at position just before sound card will read it.
Actually it's how I implemented it in DirectSound...
I used the folowing technique:
1) create surface with loopback buffer for 160 ms
2) set position notifications for each 20 ms segment
3) when notification is raised I read current playback position, calculate current segment number and write next portion of samples into previous segment (which playback is just completed)
Can I use the same technique in SFML?
-
The only solution to this problem with SFML is what I already told you:
The sf::SoundStream class is what you're looking for, but it currently doesn't allow to change the buffer size (currently, 2 seconds of audio data).
So, unless you tweak SFML itself a little bit, you won't be able to achieve exactly what you want. Suggestions for making the API more flexible are welcome though :)