0
0

I have set a synch callback to a looping stream, and my callback only gets called the first time through. Would it be possible for fmod to continue calling the synch callback at the appropriate marks each time the sound loops?

I’ve also found that if a .wav marker is at the end of the file, my callback doesn’t get called.

-Kristine

  • You must to post comments
0
0

Hello, I’ve recently had this problem and managed to figure it out by playing around with it.

After assigning markers to my .wav file, I just take notice to where they are located. After taking notice of this, I then write a test to see if it was reached:
[code:3ofs5lxc]
signed char F_CALLBACKAPI edit(FSOUND_STREAM *stream, void *buff, int len, int param)
{
if(len == 1379474)
{
credit_1=1;
}
if(len == 2047440)
{
credit_2=1;
}
if(len == 2729920)
{
credit_3=1;
}
if(len == 3412400)
{
credit_4=1;
}
if(param == 1)
{
credit_5=1;
}
return TRUE;
}
[/code:3ofs5lxc]
The “len” is where the marker is at in the .wav file, since the callback function is initiated when a marker is met, the position is automatically passed in. I’ve declared the credit… variables global so they act as a flag. The ‘param’ is the argument you pass to the callback function, and is passed each time a marker is found.

In the beginning where you stream your file, it should probably look like this:
[code:3ofs5lxc]
ending = FSOUND_Stream_OpenFile(“credits.wav”, FSOUND_NORMAL | FSOUND_2D, 0);
FSOUND_Stream_Play(FSOUND_FREE, ending);
FSOUND_Stream_SetSynchCallback(ending, edit, 0);
FSOUND_Stream_SetEndCallback(ending, edit, 1);
[/code:3ofs5lxc]
Notice that the function “FSOUND_Stream_SetEndCallback(ending, edit, 1);” is initiated ONLY when the end of the file is reached. This initation calls the function callback “ending” and passes the ‘param’ as 1 rendering credit_5 as 1.

I hope I explained it clearly enough, if not, tell me and I’ll elucidate for you, plus there are people here who have far more better experience than me with such matters and they can be an assistance to you.

  • You must to post comments
0
0

Thanks for your example, dirty_code, but I need to write a very generalized synching callback where there may not always be a sound marker at the end of the sound. I need to know the difference between reaching the end of a sound that has DOES have a sound marker, and reaching the end of a sound that does NOT have a sound marker – it has to work for any sound.

We ended up placing the last sound marker just slightly before the end of the sound, and that works well enough for our case.

  • You must to post comments
0
0

Use this for a callback that when playing a sound that does NOT have a marker:
[code:5vf2sau8]
FSOUND_Stream_SetEndCallback(ending, edit, 1);
[/code:5vf2sau8]
The above will get called when the end of the sound is reached, even without a marker.

Use this for a callback that when playing a sound that DOES have a marker, could be at the very end.
[code:5vf2sau8]
FSOUND_Stream_SetSynchCallback(ending, edit, 0);
[/code:5vf2sau8]
Use an “if” statement in your callback for the position of the marker. This will NOT be called when the sound ends, if you put a maker near the end, it will only get called when it REACHES that marker, not the end of the sound.

I hope I got this right. If it isn’t tell me. 😀

  • You must to post comments
0
0

Kristine,

Just be aware that FSOUND_Stream_SetEndCallback does NOT get called
if the sound is set to loop until the sound is stopped – it does NOT get
called when the stream loops

  • You must to post comments
0
0

One more thing I thought of …

Don’t know if this is usefur or not, but

To distinguish between a sync marker and the end of a stream test the
void* buff parameter – if it is NULL, the stream has ended, otherwise
it will be a sync marker.

  • You must to post comments
0
0

To re-ask the first part of my question:

Would it be possible for fmod to continue calling the synch callback at the appropriate marks each time the sound loops? Right now, it only calls the synch callback the first time through the sound if the sound is looping.

  • You must to post comments
Showing 6 results
Your Answer

Please first to submit.