Hey all,
first of all a happy new year!

I am still working on my DJ program, and the headphone pre-listening is working quite well.
I currently do the following :
I start each song (mp3) twice : once in 2d mode, so stereo is supported, and once in 3d mode with forcemono, so i can put it in the rear output (for headphones).
The problem is that the 2 streams don’t start exactly at the same time when you play the 2 streams.
So I have a loop that calls fsound_gettime, (or fsound_stream_gettime or something…) which gives me the current number of milliseconds from the start of the song.
Then I speed up or slow down one of the two songs until the difference is 0.
The problem is that it still isn’t exactly accurate, and I think it is because one millisecond isn’t precise enough…

Would it be possible to increase the accuracy of gettime to a floating point value, or to add a fsound_getposition function that retrieves the current play-position in samples.
I have tried using the getposition function as it is now, but that doesn’t work really well because it is the buffer position instead of the play position.

  • You must to post comments

I guess I would be happy enough to have them less then 1 millisecond appart.
If the problem is not in the accuracy smaller than 1 millisecond then the problem would be the accuracy of the FSOUND_Stream_GetTime function.
Is it possible that when calling
pos1 = FSOUND_Stream_GetTime(myStream(1))
pos2 = FSOUND_Stream_GetTime(myStream(2))

Immediately after each other that there is a 25 ms buffer difference?
If so then that would be the problem I am hearing, and not the difference smaller then 1 ms.
I try to sync (pos1 – pos2) to 0, but that wouldn’t do it if there is a constant offset due to different buffer starts.
Is there a way in that case to know where a song is that IS 1 ms exact, and not dependent of the 25 ms buffersize?
Or would it be accurate if I used a dsp callback that calls me on every buffer update, so that getTime will give me the exact time at that moment?

  • You must to post comments

I dont use timeGetTime since some time ago, because it is indeed inaccurate. For exact timing I use QueryPerformanceTimer, which is extremely accurate.
The problem indeed is seeking should be possible, but is not the main issue.
It would be ok if I could count the missing 25 ms myself, but the problem is that I don’t know when the buffer is updated.
The other problem is that I have one hardware and one software stream.
If I would make a dsp unit, and each time it is called I set some var to the time returned by stream_gettime as well as another var that stores the current time, would that be enough to have an accurate time?
And when is the hardware stream’s position updated?

It is not possible to get rid of the software stream, because I need to be able to save the result to a wav or mp3, and I also need the other stream in 3d, because it may only play in the rear out.

I hope fmod will soon support multiple sound cards, so I can just use 2 software streams…

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.