0
0

Crosspost Warning: http://stackoverflow.com/questions/2345 … using-fmod

I need to play just part of a sound, say seconds 1-2 of a 4 second sound.
The only way I know to achieve that right now is to add a syncpoint and then stop playback in the callback. Problem is, since events are only triggered by update(), I can’t precisely stop playback at 2.000s.
Assuming I call update() every 30ms, the stream may not be stopped until 2.030s.
How can I play part of a sound, with the most accurate possible interval boundaries?

Thanks for your help!

  • You must to post comments
0
0

Hi carneades, welcome to the FMOD forums!

You can use Channel::setDelay for sample accurate starting and stopping of sounds. Use FMOD_DELAYTYPE_DSPCLOCK_START to set the start time of the sound and FMOD_DELAYTYPE_DSPCLOCK_END to set the end time.

  • You must to post comments
0
0

Thank you for your help peter! I got it working.

It’s unfortunate there are no full examples of playing a sub-interval of a sound available. After googling this issue for days I see I’m not the first to have this problem. Perhaps I could submit my playSound(filename, startFrame, endFrame) code to the wiki? Or maybe an example could be added by the FMOD team?

Back on topic, is there any callback that can inform me when a delay endpoint has been reached?

(Last thing: the limited number of searches permitted on these boards makes it difficult to make sure you’re not re-posting something that has already been answered. Does the limit really need to be set so low?)

Thanks again!

  • You must to post comments
0
0

[quote:21l9sbvu]Perhaps I could submit my playSound(filename, startFrame, endFrame) code to the wiki? Or maybe an example could be added by the FMOD team? [/quote:21l9sbvu]
Please do, that would be great!

[quote:21l9sbvu]Back on topic, is there any callback that can inform me when a delay endpoint has been reached? [/quote:21l9sbvu]
There isn’t a specific delay endpoint callback but you can use Channel::addSyncPoint to get a callback at any offset in the sound.

[quote:21l9sbvu]Last thing: the limited number of searches permitted on these boards makes it difficult to make sure you’re not re-posting something that has already been answered. Does the limit really need to be set so low?[/quote:21l9sbvu]
That is a good point, I will look into that for you.

  • You must to post comments
0
0

Thanks again!

I will submit the C-interface library I wrote.
It provides :
startPlayback(filename, startFrame, endFrame)
streamPosition()
stopPlayback()
playbackInProgress()

Right now startPlayback() does not turn off the stream by itself (requires explicit call to stopPlayback() once the endframe has been reached), but with the syncpoint suggestion I will be able to make startPlayback() independent from explicit calls to stopPlayback() while still keeping it non-blocking.

The only "catch" will be that without regular calls to streamPosition() (that’s where update() is called), the self-stopping behavior will not work.

  • You must to post comments
0
0

Ok that sounds good. With regard to the forum searching, there isn’t a limit on how many total searches you can do, just a minimum of 15 seconds between each search. I too find this a little frustrating, especially when I have a typo and I just want to search again immediately. However we are reluctant to reduce this minimum time because bots might thrash the search and reduce the speed of the whole website.

  • You must to post comments
Showing 5 results
Your Answer

Please first to submit.