Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Streaming a custom format  (Read 2930 times)

0 Members and 1 Guest are viewing this topic.

ZeroZ30o

  • Newbie
  • *
  • Posts: 47
    • View Profile
Streaming a custom format
« 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?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10195
    • View Profile
    • development blog
    • Email
Re: Streaming a custom format
« Reply #1 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 and implement your own streaming class.
SFML also ships with a complete example for VoIP, quite basic, but should give you an idea. :)
Official FAQ: https://www.sfml-dev.org/faq.php
Nightly Builds: https://www.nightlybuilds.ch/
——————————————————————
Dev Blog: https://dev.my-gate.net/
Thor: http://www.bromeon.ch/libraries/thor/

ZeroZ30o

  • Newbie
  • *
  • Posts: 47
    • View Profile
Re: Streaming a custom format
« Reply #2 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.

ZeroZ30o

  • Newbie
  • *
  • Posts: 47
    • View Profile
Re: Streaming a custom format
« Reply #3 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

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Streaming a custom format
« Reply #4 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.
Laurent Gomila - SFML developer

 

anything