mirror of
https://github.com/cookiengineer/audacity
synced 2026-01-12 07:35:51 +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:
@@ -248,6 +248,7 @@ void Dither::Apply(enum DitherType ditherType,
|
|||||||
DITHER(TriangleDither, dest, destFormat, source, sourceFormat, len, stride);
|
DITHER(TriangleDither, dest, destFormat, source, sourceFormat, len, stride);
|
||||||
break;
|
break;
|
||||||
case shaped:
|
case shaped:
|
||||||
|
Reset(); // reset shaped dither filter for this new conversion
|
||||||
DITHER(ShapedDither, dest, destFormat, source, sourceFormat, len, stride);
|
DITHER(ShapedDither, dest, destFormat, source, sourceFormat, len, stride);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -285,6 +286,8 @@ inline float Dither::ShapedDither(float sample)
|
|||||||
{
|
{
|
||||||
// Generate triangular dither, +-1 LSB, flat psd
|
// Generate triangular dither, +-1 LSB, flat psd
|
||||||
float r = DITHER_NOISE + DITHER_NOISE;
|
float r = DITHER_NOISE + DITHER_NOISE;
|
||||||
|
if(sample != sample) // test for NaN
|
||||||
|
sample = 0; // and do the best we can with it
|
||||||
|
|
||||||
// Run FIR
|
// Run FIR
|
||||||
float xe = sample + mBuffer[mPhase] * SHAPED_BS[0]
|
float xe = sample + mBuffer[mPhase] * SHAPED_BS[0]
|
||||||
|
|||||||
Reference in New Issue
Block a user