0
0

Hello, I have application that requires accurate timing (approx. 1ms) for the relative onset of multiple streams (i.e. streams need to start at accurate times relative to each other). The latency between the initiation of the playback by the user and the real time that the sound is heard is not as critical (approx. 100ms).

After reading a number of posts on this forum on related topics and thinking about the issue I was wondering if the following approach using fmod would satisfy the requirements above.

1) Set the internal mixing buffer to a known size (e.g. FSOUND_SetBufferSize(len_ms) ).

2) Create a DSP unit with a priority prior to the FFT unit for the sole purpose of counting the number of samples mixed since the beginning (e.g. FSOUND_DSP_Create(myCountingCallback, 890, 0) ).

3) Create a user defined stream callback that given the known mix rate, current mix position, and mixing buffer size begins filling the buffer when the desried stream start time equals current mix position time plus the mixing buffer size (e.g. FSOUND_Stream_Create(myStreamCallback, len, FSOUND_16BITS | FSOUND_STEREO | FSOUND_SIGNED, sampleRate, 0) ).

I would rather use FSOUND_Stream_OpenFile to create the stream, however, it does not appear that will satisfy the application’s timing requirements. The approach above seems to allow multiple streams to be accurately timed at the expense of the latency of the audible onset to be at a maximum of 2 * len_ms.

Any comments, especially from Brett, are greatly appreciated.

  • You must to post comments
0
0

The approach you are suggesting seems good for streams that are relatively “quiet” at the beginning (i.e. for at least the mix buffer length). For streams that have rapid onset of content, like percussive attacks, the approach I initially described will probably have to be necessary.

Thanks for the advise!

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.