I’ve written a program in C#, which:

  • Loads sound to memory
  • Extracts decompressed samples and places them in my own buffer (short[])
  • Creates a stream, which gets a pointer to these samples.

Now I want to play looped part of these samples. Everything works fine until I try to play very short part of this sound (say, samples from 8400 to 8600). I’m doing it in the following way:

Safe(channel.setLoopPoints(8400, FMOD.TIMEUNIT.PCM, 8600, FMOD.TIMEUNIT.PCM));
Safe(channel.setPosition(8400, FMOD.TIMEUNIT.PCM));

Sound plays OK, but when I’m trying to get current PCM position during playback, I’m getting values outside specified range:

PCM Position: 8400
PCM Position: 9477
PCM Position: 11495
PCM Position: 12774
PCM Position: 14993
PCM Position: 16272
PCM Position: 18491
PCM Position: 19569
PCM Position: 21788
PCM Position: 23807
PCM Position: 25085
PCM Position: 26364
PCM Position: 28382
PCM Position: 29460

When I specify a larger range, everything works just fine. Also, when I use sound created from file, even the short range works fine.

I’m attaching the demo project to this post. It’s written in C#, in VS 2013 Express.

Is it bug in FMODex or am I doing something wrong?

Best regards — Wojciech "Spook" Sura.

  • You must to post comments

Just to mention, I am fully aware of the issue with createStream:

[quote:3o9pip7i]Issues with streamed audio. (Sounds created with with System::createStream or FMOD_CREATESTREAM).
When changing the loop mode, sounds created with System::createStream or FMOD_CREATESTREAM may already have been pre-buffered and executed their loop logic ahead of time, before this call was even made.
This is dependant on the size of the sound versus the size of the stream decode buffer. See FMOD_CREATESOUNDEXINFO.
If this happens, you may need to reflush the stream buffer. To do this, you can call Channel::setPosition which forces a reflush of the stream buffer.
Note this will usually only happen if you have sounds or looppoints that are smaller than the stream decode buffer size. Otherwise you will not normally encounter any problems.[/quote:3o9pip7i]

This is why I’m calling the setPosition immediately prior to unpausing the channel. But that doesn’t solve the problem, unfortunately.

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.