fluid-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [fluid-dev] Purpose of dither?


From: Mihail Zenkov
Subject: Re: [fluid-dev] Purpose of dither?
Date: Wed, 9 May 2007 13:17:07 +0300

On Wed, 9 May 2007 01:36:13 +0100
Miguel Lobo <address@hidden> wrote:

> > Yes, you absolutely right. But look at that code again:
> >
> >   for (c = 0; c < DITHER_CHANNELS; c++) {
> >     dp = 0;
> >     for (i = 0; i < DITHER_SIZE-1; i++) {
> >       d = rand() / (float)RAND_MAX - 0.5f;
> >       rand_table[c][i] = d - dp;
> >       dp = d;
> >     }
> >     rand_table[c][DITHER_SIZE-1] = 0 - dp;
> >
> > We subtract previous dither value from current to prevent noise
> > modulation. I use dither table to get maximum speed.
> 
> I actually felt curious about the subtraction of the previous value too.  
> What 
> do you mean by "noise modulation"?  (And yes, this time I have looked it up 
> in Wikipedia ;)).

Roughly, dither convert harmonic distortion to noise. If we just add
noise (random) to signal, distortion gone but noise will by modulated
by signal (correlate with signal). This noise not fully random. This is
rectangle dithering.

To prevent this modulation and get pure white (fully random) noise (it
much better for human ears) not correlated with signal, we consider
previous dither value.

Code from audacity:

#define DITHER_NOISE (rand() / (float)RAND_MAX - 0.5f)

    float r = DITHER_NOISE;
    float result = sample + r - mTriangleState;
    mTriangleState = r




reply via email to

[Prev in Thread] Current Thread [Next in Thread]