1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-11-04 16:14:00 +01:00

In 'Shaped' dither, do the best we can with a NaN.

Reset the filter every time to prevent one conversion affecting the next.
This commit is contained in:
martynshaw99
2012-02-10 00:12:59 +00:00
parent 7cb5c6e763
commit 61410ebd79

View File

@@ -248,6 +248,7 @@ void Dither::Apply(enum DitherType ditherType,
DITHER(TriangleDither, dest, destFormat, source, sourceFormat, len, stride);
break;
case shaped:
Reset(); // reset shaped dither filter for this new conversion
DITHER(ShapedDither, dest, destFormat, source, sourceFormat, len, stride);
break;
default:
@@ -285,6 +286,8 @@ inline float Dither::ShapedDither(float sample)
{
// Generate triangular dither, +-1 LSB, flat psd
float r = DITHER_NOISE + DITHER_NOISE;
if(sample != sample) // test for NaN
sample = 0; // and do the best we can with it
// Run FIR
float xe = sample + mBuffer[mPhase] * SHAPED_BS[0]