What is the method for getting seamless MP3 play? I now play a file with FSOUND_Stream_OpenFile and on the end_callback I do FSOUND_Stream_Close and start the next song. However, there is a small gap between mp3 files which is noticable on certain mix albums. Has anyone succeeded in removing such a gap or has does someone have a pointer to how to solve this? My first guess is pre-loading the next file on another stream just before the current song has ended and starting it as soon as the end_callback is triggered, but I’m not sure this method will be succesfull.
- DaCoTa asked 13 years ago
If you override FMOD’s file reading functions by yours (using FSOUND_File_SetCallbacks), you might get around the problem. For instance, overriding the READCALLBACK, you might write a function that does this:
- copy to a temporary buffer the desired number of bytes from the currently opened file using fread
- detect whether you have reached the end of the file before getting enough bytes
- if no, copy the temporary buffer to the buffer specified in the parameters
- if yes, append the remaining number of bytes from another file, and then copy the temp buffer to the “real” one
This amounts to implementing a new layer of buffering by yourself, since all the contents of the files are actually copied to a (static) memory buffer that you manage, and [i:267f7ehf]that[/i:267f7ehf] buffer is what FMOD actually reads.
I’m not sure that this would work, I’d have to try it. For example, when FMOD encounters the MP3 header of a file stitched to the end of a previous one, would it try to “play” it or parse it as if it were a new file? And most of all, would that procedure be fast enough?
Please login first to submit.