SFML community forums
Help => Audio => Topic started by: SamuraiCrow on January 10, 2009, 08:51:41 pm
-
I was just thinking about writing a traditional music file player (such as the old FastTracker 2 file format) in SFML. I was looking for a way to trigger an event or some other type of hook when a sound finishes playing.
This would be useful because I need to implement a looping sample after a sample that is not looped is done playing in order for the instrument sound to be complete. Also, the .XM file format supports what is called "ping-pong" looping where the sound playback is reversed (negative frequency on some sound cards) at the beginning and end of a looping sample.
It may be possible to do some of this already using threads but I'm not that familiar with threading.
-
You could use a pausable clock (http://hiura.123.fr/doku.php?id=cpp:sf:pausableclock), as long as you know how long the song is.
-
I'm afraid that won't work. I'd need a pausable clock for each of 32 voices playing at the same time and a precise way to switch samples as soon as any one of them is done playing.
The idea is that most of the instruments in music module formats have a portion of the sample that doesn't loop followed by a portion that does. Sometimes the loop requires the computer to reverse the playback direction at the end of the loop and then resume forward playback at the beginning of the loop.
Perhaps I should have posted this in the Feature Requests forum.
-
Here's a thought: streamed audio requires a seamless enqueue of samples in order for there to be no skips between the buffers. If this could be done in parallel on 32 voices playing at the same time, then it would be a practical means by which I could implement my instrument playback.
-
Update: Examining the example source on the OpenAL Soft website revealed that OpenAL Soft does indeed queue samples when streaming. I'll have to see what can be done to make a musical instrument class.