MAD Fixed point audio problems


#1

Hi, Julian.

I’m trying to create MADAudioFormatReader and I almost succeeded. Almost, because the decoding process is OK except the produced sound.

As JUCE tells us I can use fixed point integers to fill the buffer on read. So, I pass fixed point PCM samples from MAD right into the JUCE buffer. The sound is terrible: it’s quiet, it glitches, it sounds slower, it’s full of noise and crackles but anyway, it’s still possible to hear a quiet tune in the background through the noise.

Julian, can you tell me how to transform the MAD fixed point PCM sample to get a clear sound?


#2
/** Converts mad fixed type to float
*/
inline float madFixedToIEEEfloat(const mad_fixed_t mad) const
{
    const double madToDoubleFactor = 1.0/(1<<MAD_F_FRACBITS);
    return (float)jlimit(-1.0, 1.0, (mad * madToDoubleFactor ));
}

Edit: Oh, this assumes that your AudioFormatReader uses float samples…
Edit2: Bug in code fixed.

Hope this helps
/R


#3

Wow!
Thank you, robiwan!

I’ll test it today.


#4

Everything is perfect!
robiwan, thank you ever so much!


#5

[quote=“Ptomaine”]Everything is perfect!
robiwan, thank you ever so much![/quote]

You’re very welcome :slight_smile:


#6