I haven’t received an answer to my previous question, but after thinking about it a bit, I only have one real question :
When the DSP callback function is called for a Stream DSP, can I determine the position in the stream (in samples or milliseconds) of the first sample passed to the callback function?
I need this so I can sync some visuals with the sound (a spectrum analyzer, but seperate for each stream).
- Adion asked 14 years ago
I think I will have to know the samples since the song start, because what I wanted to do wa compare this value with GetPosition, so I know when the samples are actually played.
So I would have a buffer with the samples since song start and some matching visualisation, and then I compare to this value with GetPosition to know which buffer I have to show.
Will it be correct when I set my counter to the same value I passed to SetPosition, or will it align on mpeg frames,…?
I’ve got it working!
I count the samples as you said, and I compare this count with (FSOUND_Stream_GetPosition – 125) to get the correct buffer.
I don’t really know why -125 (maybe a buffer length + fmod’s mixing buffer)
When I compared the counted samples with FSOUND_Stream_GetPosition, GetPosition would always be ahead about 125ms.
Now my Visualisation is good, but my beat detection isn’t.
When I use my beat detection algorithm on fmod’s FFT data, I get the correct beats in about 10-20 seconds, but when I use my own FFT, it doesn’t really get it.
I’ve compared both FFT outputs and they differ indeed.
My FFT uses 1024 samples, and is multiplied with a sine as windowing function.
I store the time for each block of FFT, so the accuracy is about 25 ms.
When that didn’t gave the correct results, I tried overlapping buffers, so the last 512 samples and the first 512 samples of the next block combine to another buffer, so I have an FFT every 12 ms.
Still I don’t get the same results as fmod.
Any chance you could give me your fft source, or tell me what windowing function you used, and maybe what normalization function?
Please login first to submit.