I’ve got a long WAV file containing a number of really short samples. It doesn’t really seem to make any sense to load each sample separately when I could just play a region of that file (I don’t need polyphony or anything).
channel->setPosition gets me half way there, but I can’t think of a good way to stop at a given position.
setLoopPoints seems to get some of the way, but it looks like once the number of loops have been played, the file continues to the end?
I’m sure someone will have tried to do this before. Any tips?
- prehensile asked 6 years ago
Take a look at the syncpoint part of the API. You would set a syncpoint at the end location of every sound. You then get a callback when a particular part of the file is reached, and you can do whatever you want from there. (Stop, pause, whatever…)
You might also try Channel::setDelay() with a DELAYTYPE_END or DELAYTYPE_PAUSE. That’ll let you set the precise time at which the sound should stop playing, but is a little less convenient usage-wise.
Hope that helps!
- Adiss answered 6 years ago
I did experiment a bit with callbacks on syncpoints but was a bit worried that it wouldn’t work too well, since it’s only as accurate as the frequency at which you call System::update(). However, I’ve got it working nicely with a 25hz update and a safe gap between sounds. Thanks Adiss!
- prehensile answered 6 years ago
Please login first to submit.