Greetings. My name is Jesús Zazueta, I’m from Mexico and I have some thoughts about sample synchronization using the FSOUND_Stream api.

As I am not completely familiar with good program design yet, my first attempt with Fmod is to create a simple program that triggers events based on the beats and measures of a song that I previously calculated.

As a test, I picked up a song which runs at 127 BPM, 44.1Khz, 16 bits, stereo packed in OGG format. It has an approximate time interval of 472.440944 milliseconds between each beat.

I do not know if this design approach is practical, but it occurred to me that I could use sync points to indicate my program where to mark the next beat. And I partially managed to do this in the following way.

Bearing in mind that OGG cannot supply Fmod with marker points, I decided to use FSOUND_Stream_AddSynchPoint() in the following steps:

Get Fmod initialized and running.

Open the music stream.

Insert the points.

Set the callback function.

Start playing.

And be happy 😉

However, my problem arises when I get to insert the sync points in the stream. Keeping in mind the time interval between beats, I estimated that the first point would have to be set at sample 5586 and the rest would get set by an approximation of the time interval in samples (as Fmod requests). That is, 20835 samples until the song has been traversed.

But I cannot insert more than 256 points! Is this a limitation of the system? Or are there any additional parameters I should specify at stream initialization time?

A workaround I thought about was to load the stream and use the FSOUND_Stream_GetSample() function, and from the sample pointer acquired, measure the length of the song in samples and work my own way around using an external sample point list. Then, I dumbly realized that I already knew the length of the song in samples 😛

As it seems, the only way to set points in an unsupported stream is by specifying sample offsets. So I would like to know if my design approaches are totally screwed up or if there is any other way to implement beat marking on a song.

Anyway, I think it might be good to add an api function that can insert points to a stream specifying the offsets in milliseconds.

Well, thanks for your time.

  • You must to post comments

I will make good use of that conversion formula! And um, assuming my strategy could work, in the meantime I could probably distribute the current amount of points available by marking only the fourth note and trying to locate the other three using that formula as a reference.

Anyway, I hope that functionality is added and thanks again for the help!

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.