0
0

Hello, I use fmod to mix some songs and jingles (mp3 format), using FSOUND_Stream_Open, Play,etc.

I just have a problem with some songs which have a few seconds blank at the end. To go on the next song in my list, I only test with a timer if the time elapsed is equal or greater than the length of the song.

Do you see a way of looking after the blanks at the end of a mp3, and if there is one (let’s say more than 2 seconds long, in order to prevent to cut a song in his middle just if there is a break in it…) to go on the next ?

thanks

Tom Sawyer

  • You must to post comments
0
0

I was thinking about that sort of stuff…

Thanks for your reply, I’m going to try this

Tom Sawyer

  • You must to post comments
0
0

Hi Brett (and the others who can help too), still me, but new problems…

Thanks again for your useful help.
I left the idea of quickly checking the end of a stream for the moment, but I succeeded in working on the samples, basing my code on the documentation/fmod/sample/fmod example. I created a dsp unit, initialized it, used it and finally freeed it without problems.
As a test for the change made to the samples, I chose to double the value of each with this code :

[code:lx4rq6yj]void* F_CALLBACKAPI my_function(void* orig_buffer,void* new_buffer,int length,int param)
{
int count;
signed short *srcleft, *srcright, *destleft, *destright;
int mixertype = FSOUND_GetMixer();

if (mixertype == FSOUND_MIXER_BLENDMODE || mixertype == FSOUND_MIXER_QUALITY_FPU)
{
    return new_buffer;
}

srcleft   = ((signed short *)new_buffer);
srcright  = ((signed short *)new_buffer)+1;
destleft  = ((signed short *)param);
destright = ((signed short *)param)+1;

length <<= 1; // *2 for stereo (number of 16 bit samples) 


for (count=0; count<length; count+=2)
{
    signed int l, r;

    l = (signed int)((float)srcleft[count]*2); // change made here
    r = (signed int)((float)srcright[count]*2); // change made here

    if      (l < -32768) l = -32768;
    else if (l >  32767) l =  32767;
    if      (r < -32768) r = -32768;
    else if (r >  32767) r =  32767;

    destleft[count] = (signed short)l;
    destright[count] = (signed short)r;

}
return (void *)param;

}[/code:lx4rq6yj]

And the result is good : when I toggle the effect on, the “volume” is twice as much higher. Good point, but I would like to go depper.

I’d like to always have the same “volume” in the end , no mind of the original volume of the mp3. Because, due to the way they were encoded, some have a volume higher than the others. And when I mix them, you can hear the difference, and have to adjust manually the gobal volume (with FSOUND_SetSFXMasterVolume(value)).

I search the net, and found a formula that told to compute the square root of the sum of the samples squared. According to that formula it would give an average value for the amplitude of the samples tested. And then I would have to compute the coefficient that represents the difference between this value, and the value I want for the outing of my stream. Finally, I have to multiply each sample by this coefficient, and that would be fine.

But the values are not in the same unit : for the samples, it’s signed shorts between -32768 and 32767, and for my volume out it’s about integers between 0 and 255 (or a percentage that I easily compute,O% is 0 and 100% is 255, but that’s not the problem…)

Does anybody know how to do that ? Is there an easiest way ?

Thanks all, please forgive me if my explanations are not very clear, but english is not my mother language, so I try to explain the best that I can.

Tom Sawyer

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.