I need an millisecond accurate version of FSOUND_Stream_GetTime().
Here’s my current strategy:
in a DSP function for the stream, call timeGetTime() and FSOUND_Stream_GetTime():
eventTime = timeGetTime(); streamTime = FSOUND_Stream_GetTime();
Whenever I need the time (in my graphics loop), I call a function which looks like this:
return streamTime + (timeGetTime() - eventTime);
The problem is that FSOUND_Stream_GetTime() is very granular — especially when called from the DSP function (seems to have a resolution of about 100ms). Also, the time reported does not seem to be the playhead position time, but the write position time.
Is there anyway with FMOD to correct for the playhead time?
I tried using FSOUND_GetCurrentPosition(), but for streams, it seems to loop around a buffer of “indeterminate size” (can I use GetLoopPoints() on the stream’s sample to find out the limits of GetCurrentPosition for streams()?)
How accurate is FSOUND_GetCurrentPosition() (I assume it’s up to the underlying driver …)
Am I going about this the entirely wrong way? 😉
Wasn’t FMOD mixing in buffers of 20 ms?
I think that is possibile to synchronize music with graphics simply by defining another array of the same size of FMOD one. So you can fill it in your DSP routine.
So happens that you take exactly the same latency time to fill up the buffer.
You may use something like double buffering or “circular buffers”, so when you read last 20 ms of buffer, the dsp routine fills next 20 ms
Excuse me for my bad english.
Stream_GetTime is NOT millisecond accurate :
I added some debug code to my program, and I made it print the GetTime and the windows timer (using QueryPerformanceCounter) converted to milliseconds and here’s what I got :
Stream_GetTime: 10971 – Timer: 17266976
Stream_GetTime: 10971 – Timer: 17266982
Stream_GetTime: 10996 – Timer: 17266987
Stream_GetTime: 10996 – Timer: 17266992
Stream_GetTime: 10996 – Timer: 17266997
Stream_GetTime: 10996 – Timer: 17267002
Stream_GetTime: 11021 – Timer: 17267007
My program updates every 5 milliseconds, but fmod only updates every 25 milliseconds.
I don’t know if this is a real problem, but especially for syncronizing different pieces of music, a more precise update would be usefull.
In a stream dsp, you should be able to get the position of the first sample passed by the dsp both in milliseconds and in samples from the start of the song.
- Adion answered 17 years ago
Please login first to submit.