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 02:53:37 +0300

>> My English bad, but i try answer.

>I am relatively sure that my native lanugage is the same as yours :)
>and what you wrote in English is perfectly readible to me :)

I'm glad :)

> > Yes, I hear.
> > 1. 16bit accuracy give 96 dB resolution. Human limit 120dB.
> > 2. For mostly purpose 96 dB enough. But when we truncate audio to 16
> > bit, we get new harmonics (distortion) with -60 dB level.
> > 3. When i play on midi keyboard, i set gain 0.1-0.2 to prevent
> > clipping. It narrows dynamic range. Without dithering i got only
> > 40-46
> > dB dynamic range when play one note.
> 
> The points 1 and 2 are interesting and improtant. This tells me that
> the
> 16 bit sampling was used as a trade-off and is not good enough for
> high quality audio. I was under the impression that audio CDs were
> adequate. Apparently not, thanks for this clarification.
> 
> Your point 3, however, indicates a problem somewhere else, which can
> not and should not be solved by dithering. My feeling is that this
> problem
> should be solved by a non-linear aplification process.

With dithering i don't hear any distortion, it enough for me. I also
try sound card with 24 bits (108 dB dynamic range)  - it slightly
better then dithering.

> > > Also, note if digital output is used, no dithering
> > > is needed. It is needed only if the data goes directly to DAC!!
> > Even in
> > > this latter case, see my  last comment.
> > 
> > Dithering should by done always, when we truncate.
> 
> I disagree... The my understanding of dithering (which is what is
> described on the wiki page you sent) is that on average to transmit
> 4.8 you transmit 80% 5 and 20% 4 and you get a 4.8. This is correct, by
> itself. This is useful in a communication channel which can only
> transmit
> integer numbers, but we want to transmit a float and by repeating a
> message several times we encode the fraction. In reality this is not
> happening. We want to transmit 4.8 but we have only one shot in doing
> that. There is no choice, we either transmit 4 or 5. That is it, end
> of story, as soon as we did it the original signal is destroyed. It
> does
> not matter if we did dithering or not. This process, unfrotunately
> introduces harmonics.

Truncation with dithering not produce new harmonics. Just try do
experiments in fresh audacity (old version have broken dithering).

> Dithering simply changes the harmonics which are
> introduced. My argument that only endpoint audio equipment has to
> decide
> how to handle the trancation artefacts. Otherwise, everytime
> float-int-float conversion is made, distortions are introduced.

If we do float-int-float conversion without dithering, we get distortion.
If we do it with dithering noise level slightly grows, without distortion.

> > > 4. I do not know how imporant it is and my feeling that dithering
> > > should not be applied at all, but the code above does not implement
> > > TPDF dithering. As I said, I do not think it is needed at all, but
> > if
> > > someone
> > > wants to implement TPDF than two calls to uniform random generator
> > are
> > > needed per entery in the table. Only one call is made by the code
> > > above.
> > > This leads to dithering which is different from  TPDF.
> > 
> > Not sure what you mean ... See source code in other apps, audacity
> > for
> > example.
> > 
> 
> Well, let me try to clarify. TPDF needs a random number from a
> triangular distribtion. To make a random number from a triangular
> distribtion, two
> random numbers are generated and the difference between the two is
> found. (just like rolling two dice) Thus, every noise point needs two
> calls to rand(). If "all apps" (herd in my language, do not think of me
> 
> as a rude person, please) does only one call than they do get a random
> number from a triangular distribution, but the noise is correleated
> from sample to sample. I do not think that this is what the goal of
> dithering is. Goal of dithering is to remove such correlations.
> So, sorry, unless you can provide a logic why the noise has to be
> correlated, even though all other apps do it, fluidsynth has to be
> modified.

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 would like to thank you for your comments. Hope to hear more from
> you.
> 
> ZF
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 




reply via email to

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