When I try to create a sound using mp3 and FMOD_CREATECOMPRESSEDSAMPLE on OSX, the sound does not loop.
Using FMOD_CREATESAMPLE or FMOD_CREATESTREAM works.
The previous FMOD version used to work fine.
result = system->createSound(Common_MediaPath("wave.mp3"), FMOD_LOOP_NORMAL | FMOD_2D | FMOD_CREATECOMPRESSEDSAMPLE, 0, &sound);
CBR = constant bit rate
VBR = variable bit rate
Additional metadata don’t have an influence on the fact the codec is constant vs variable.
Per your explanation, that would mean that any mp3 with ID3 tag would be considered VBR which is not correct.
Also the fact that having an ID3 tag would break looping in fmod is worry some.
i did not say ‘tags’, i said ‘non standard tags’ or i should have just said ‘non standard data’ which happens all the time with mp3 files.
If you want consistent, predictable data, use FSB format which can use mp3 encoding.
Of course fmod supports tags, but unless you want fmod to scan the whole file byte by byte (which btw is what FMOD_ACCURATETIME does) how do you expect FMOD to instantly calculate the accurate length of the file? mp3 does not have a ‘format’, it is a raw bitstream.
Thanks for writing. You are right about that. It is a combination of a few different things that lead to this, and a refactoring of our resampler recently which introduced a bug.
The 3 factors that cause this are
- need to use FMOD_CREATECOMPRESSEDSAMPLE
- need to use a non FSB based file
- file needs to be VBR and have the length incorrectly calculated for it.
To eliminate point 3, you can work around this issue by adding FMOD_ACCURATETIME to your createSound call (so that the length is correctly calculated for it). This should fix the issue in the meantime while the new patch release comes out with the resampler fix in it.
The use of FMOD_ACCURATETIME in createSound fixes the problem however the issue is not happening just for mp3 VBR.
if you mean non VBR mp3, then the file is probably including data like non standard tags that are making the length value incorrect, as a CBR calculation is usually a raw size value divided by a fixed framesize (calculated by reading the first few frames) to work out how many frames are in the mp3, then multiplying that by 1152 pcm samples to get total pcm length.