MAD Fixed point audio problems

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?

/** 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

Wow!
Thank you, robiwan!

I’ll test it today.

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

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

You’re very welcome :slight_smile: