0
0

I just wanted to ask if anyone has got a better way of handling VBR encoded mp3 files. Currently I am doing this:

  1. Open the file normally.
    [i:34k7ju4h]han = FSOUND_Stream_Open(FileName.c_str(), FSOUND_HW2D, 0, 0);[/i:34k7ju4h]

  2. Load the same file on to another stream but with FSOUND_MPEGACCURATE and FSOUND_NONBLOCKING flags.
    [i:34k7ju4h]checkVBR = FSOUND_Stream_Open(FileName.c_str(), FSOUND_HW2D|FSOUND_NONBLOCKING|FSOUND_MPEGACCURATE, 0, 0);[/i:34k7ju4h]

  3. Once the 2nd stream has loaded check if the length’s (ms) are different, if they are different start playing the 2nd stream at the point of the first stream and then stop/unload the 1st stream.
    [i:34k7ju4h]int checkLength = FSOUND_Stream_GetLengthMs(checkVBR);
    if (PlayerLength – checkLength > 1000)
    {
    PlayerLength = checkLength;
    FSOUND_Stream_SetTime(checkVBR, FSOUND_Stream_GetTime(han) + 160);
    channel = FSOUND_Stream_Play(FSOUND_FREE, checkVBR);
    FSOUND_Stream_Close(han);
    han = checkVBR;
    checkVBR = NULL;
    FSOUND_Stream_SetEndCallback(han, (FSOUND_STREAMCALLBACK)endcallback, 0);
    }
    else
    {
    FSOUND_Stream_Close(checkVBR);
    checkVBR = NULL;
    }
    [/i:34k7ju4h]

The problem with this is that if you are listening really carefully you can hear a click when the 2nd stream starts playing.

I am sure somebody is using something more clever, any suggestions.

  • You must to post comments
0
0

I remember the post where Brett suggested the “twice opened” method, but it was also evident that he wasn’t certain that it would work correctly. He suggested (to someone) to give it a try.

I found that it wasn’t reliable (at least with 3.72 or 3.73–the current version at the time), because even if the MP3 was NOT VBR, the two times were not always identical.

Thus, I would suggest that the very first thing you do is test several CBR files to check if FMOD 3.74 reports identical media lengths for both open methods.

If you proceed, please let us the know your results.

  • SD
  • You must to post comments
0
0

[quote="chris_gorrie":1mxy27ay]if (PlayerLength – checkLength > 1000)[/quote:1mxy27ay]

The streams never come back as the same length but I found (after a bit of testing with different qualities and bit rates) that a VBR file will have a time difference of greater than 1 second and a CBR file will have a time difference of less than 1 second.

I am sure there are some exceptions to this rule but if a stream’s time difference is greater than 1 second it should be changed to the other stream any way (for more accurate seeking in the song).

The only downside is that there is a lot of errors that could come from this method. The user could change track before the stream has completed opening, he/she cannot seek through the song while this 2nd stream is loading…

I have simplified the code above but I cater for quite a lot of funny stuff that could happen when you have two streams open.

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.