enum Dither { None = 0, Rectangle, Triangle }; inline quint32 prng_madplay_32bit() { static quint32 state; state = (state * 0x0019660dL + 0x3c6ef35fL) & 0xffffffffL; return state; } template inline qint32 dither(qint32 sample); template <> inline qint32 dither(qint32 sample) { return sample - (prng_madplay_32bit() & 0xffff); } template <> inline qint32 dither(qint32 sample) { static qint32 last; qint32 current = prng_madplay_32bit() & 0xffff; qint32 dither = current - last; last = current; qint64 tmp = sample + dither; return (qint32)qBound(-2147483648LL, tmp, 2147483647LL); }