The best way to synchronize a stream, such as a wav or mp3 is by using <ahref="../HTML/FSOUND_Stream_SetSyncCallback.html">FSOUND_Stream_SetSyncCallback</a>.<br>
All you have to do is drop 'markers' into a wav editing program like SoundForge, and FMOD will automatically generate callbacks as the stream plays when the play cursor runs over the markers!.<br>
The strings that you label markers with are even passed into the callback.<br>
Note that only WAV files and MP3 with RIFF wrappers will work here. The markers are saved in a RIFF chunk.
<br>
<br>
If you don't have this luxury or want to use a format that doesn't support this feature, then the next best way to synchronize a stream is by using custom sync points. This way you can add and remove your own points that wav markers would normally generate.
See <ahref="../HTML/FSOUND_Stream_AddSyncPoint.html">FSOUND_Stream_AddSyncPoint</a>.<br>
Add your markers manually with this and set your sync point callback with <ahref="../HTML/FSOUND_Stream_SetSyncCallback.html">FSOUND_Stream_SetSyncCallback</a><br>
Your callback could then look something like this but you can put what you like in the callback function.<br>
<br>
<b>
signed char endcallback(FSOUND_STREAM *stream, void *buff, int len, int param)<br>
{<br>
<ul>
// end of stream callback doesn't have a 'buff' value, if it doesn't it could be a sync point.<br>
if (buff)<br>
{
<ul>
printf("\nSYNCPOINT : \"%s\"\n", buff);<br>
</ul>
}<br>
<br>
return TRUE;<br>
</ul>
}<br>
</b>
<br>
Remember FMOD is a real-time system and the amount of time spent in a callback has to be low, or you could cause buffer underrun or stuttering.<br>