MP3 createStream setPosition incorrect playback

Hey, I’m not getting correct playback for a “streamed” mp3 file playback.
Here’s the setup code:

FMOD_RESULT       result;
result = system->createStream(Common_MediaPath("tama_drum_export.mp3"), FMOD_DEFAULT | FMOD_2D, 0, &sound);
result = system->playSound(sound_to_play, 0, false, &channel);
result = channel->setPosition(3000, FMOD_TIMEUNIT_MS);

.

The file (tama_drum_export.mp3) has a drum sound every 3 seconds.
When playing with the code above (the above can be pasted into the “play_stream” example project), no sound is heard for several seconds.

Switching to system->createSound for handle creation, or switching to .ogg file makes it work as expected (immediately hearing the drum sound).

This has been tested on Win and OSX example projects and happens on both.
I can also upload the project files if necessary.

Thanks!

Hi ,
MP3 has an inherent encoder and decoder latency built into it, and is not a good format for things like this. You’d be better off using a different format like ogg, or you could supply an offset to compensate for the mp3 latency. We can’t normally do it ourselves, because the latency is different for every bitrate and mpeg type, and it may cause clicks with the start of the sound not ramping in properly.

1 Like

Thanks!