Welcome,
Guest
. Please
login
or
register
. Did you miss your
activation email?
French forum
Home
Help
Search
Login
Register
SFML community forums
»
Help
»
Audio
»
sf::SoundStream onGetData()
Print
Pages: [
1
]
Author
Topic: sf::SoundStream onGetData() (Read 2695 times)
0 Members and 1 Guest are viewing this topic.
Ectance
Newbie
Posts: 8
sf::SoundStream onGetData()
«
on:
May 06, 2014, 03:06:51 pm »
Hello again~!
Can I ask when exactly is onGetData() called ? When the previous chunk of samples has finished being played or a bit sooner ?
Is it possible if onGetData() takes lets say 2-3ms to return true , cracks or gaps in the sound to be produced ?
Thanks.
Logged
eXpl0it3r
SFML Team
Hero Member
Posts: 11032
Re: sf::SoundStream onGetData()
«
Reply #1 on:
May 06, 2014, 03:18:00 pm »
onGetData gets called in
fillAndPushBuffer
, which get's called by fillQueue, which gets called by streamData, which gets called by in the initialization list for the second thread.
I'm not sure whether it's possible to make assumption about the timing. You'd really just have to test it.
What are you trying to do?
Logged
Official FAQ:
https://www.sfml-dev.org/faq.php
Official Discord Server:
https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog:
https://duerrenberger.dev/blog/
Laurent
Administrator
Hero Member
Posts: 32498
Re: sf::SoundStream onGetData()
«
Reply #2 on:
May 06, 2014, 03:28:51 pm »
sf::SoundStream is triple-buffered, which means that when you fill a chunk, two others are still playing.
Computing the delay is simple, if you know how many samples you put into each. Divide by the sample rate, multiply by two.
«
Last Edit: May 06, 2014, 03:31:07 pm by Laurent
»
Logged
Laurent Gomila - SFML developer
Ectance
Newbie
Posts: 8
Re: sf::SoundStream onGetData()
«
Reply #3 on:
May 08, 2014, 12:28:40 pm »
The delay is not an issue . Even 250-300ms are fine in my case , I'm coding a standalone synthesizer/wave generator by the way .
When it's generating sounds in real-time ( instead writing them to a file ) , every time a chunk is popped from a queue and passed to the internal AL queue, I get "missing" part of a waveform.Not cutted or anything just audiable flat line for 1-2ms so I asked the question to understand if the problem is in my code or the speed of which the internal queue is filling.
And the pipeline :
Create chunk of N samples
->
write a sine/whatever wave
->
push in queue
->
pop from queue
->
pass to .data
(
main thread
;
SoundStream thread
)
«
Last Edit: May 08, 2014, 12:32:29 pm by Ectance
»
Logged
Laurent
Administrator
Hero Member
Posts: 32498
Re: sf::SoundStream onGetData()
«
Reply #4 on:
May 08, 2014, 02:50:48 pm »
You should experiment with a simpler use case, to make sure sf::SoundStream is behaving as expected. For example, you couldgenerate a sine wave directly in onGetData (no other thread involved).
Logged
Laurent Gomila - SFML developer
Print
Pages: [
1
]
SFML community forums
»
Help
»
Audio
»
sf::SoundStream onGetData()
anything