# Dithering is a Mathematical Process - NOT a psychoacoustic process.

#### j_j

##### Addicted to Fun and Learning
Audio Luminary
Technical Expert
I have calculated a sine wave of magnitude .4, rounded it, added uniform dither, rounded that, and added tpd, and rounded THAT, i.e. I've set a step size of '1' in the quantizer.

The routine that does this will follow in a comment.

The photo I'm attaching now has 4 lines. each line shows a signal. The four columns are
(signal) (signal spectrum) (error signal) and (error spectrum)

The four lines are

undithered unquantized
undithered quantized - NOTE THE SIGNAL IS GONE. POOF, LOST, MISSING, GONE. Information is ***LOST***
uniform dithered quantized - Note, signal is back, but noise level changes with data value, so data modulates noise level.
TPD - Note, signal is back at same level, noise is 3dB higher, but there is no modulation of the noise level.

This shows, clearly, visibly, and without debate, that DITHERING PRESERVES INFORMATION.

That is all!

#### j_j

##### Addicted to Fun and Learning
Audio Luminary
Technical Expert
This script generates that screen shot:

clc
clear all
close all

x=.4*sin((1:8192)/512*2*pi);

xnd=round(x);

for ii=1:8192
t=rand();
xud(ii)=round(x(ii)+t-.5);
t=rand()+rand();
xtd(ii)=round(x(ii)+t-1);
end

xt=abs(fft(x));
xndt=abs(fft(xnd));
xudt=abs(fft(xud));
xtdt=abs(fft(xtd));

xe=x-x;
xnde=x-xnd;
xude=x-xud;
xtde=x-xtd;
xet=abs(fft(xe));
xndet=abs(fft(xnde));
xudet=abs(fft(xude));
xtdet=abs(fft(xtde));

subplot(4,4,1)
plot(x)
title('x');
subplot(4,4,2)
plot(xt);
title('spectrum of x');
subplot(4,4,3)
plot(xe)
title(' error');
subplot(4,4,4)
plot(xet)
title('error spectrum');

subplot(4,4,5)
plot(xnd);
title('no dither');
subplot(4,4,6)
plot(xndt);
title(' spectrum ');
subplot(4,4,7)
plot(xnde)
title('error');
subplot(4,4,8)
plot(xndet);
title('error spectrum');

subplot(4,4,9)
plot(xud)
title('uniform dither')
subplot(4,4,10)
plot(xudt)
title('spectrum uniform');
subplot(4,4,11)
plot(xude)
title('error')
subplot(4,4,12)
plot(xudet)
title('error spectrum')

subplot(4,4,13)
plot(xtd)
title('tpd');
subplot(4,4,14)
plot(xtdt)
title('tpd spectrum');
subplot(4,4,15)
plot(xtde)
title('tpd error');
subplot(4,4,16)
plot(xtdet)
title('tpd error spectrum');

#### j_j

##### Addicted to Fun and Learning
Audio Luminary
Technical Expert
Just so the difference beween uniform and TPD is clear, I also did a plot with a lower frequency sine wave.

#### amirm

Staff Member
CFO (Chief Fun Officer)
I was going blind trying to read the plots then realized I could click on them for full size.

Thanks for the visualization. It helps a lot.

#### j_j

##### Addicted to Fun and Learning
Audio Luminary
Technical Expert
I was going blind trying to read the plots then realized I could click on them for full size.

Thanks for the visualization. It helps a lot.

Yeah, there is a (*&(*&(*load of detail there. So I uploaded a full 1080P version. I might have done this at work and done a 4K, even, now that you point it out.

#### DonH56

##### Technical Expert
Technical Expert
Forum Donor
Nice job, @j_j ! Need to copy the script and fire up Matlab again.

I must have missed it -- who thought dither was psychoacoustic? How is such a conclusion even considered (I guess by audiophiles who dismiss all science and math as irrelevant?)

I first heard of dither (noise decorrelation) in the early 1980's and applied colored noise to an RF ADC for an X-band (8-12 GHz) radar system. It worked and I'm pretty sure no psychoacoustics were involved...

Last edited:

#### SIY

##### Technical Expert
Technical Expert
Sigh. This takes me back to my days at Nicolet...

/very old man

#### DonH56

##### Technical Expert
Technical Expert
Forum Donor
Sigh. This takes me back to my days at Nicolet...

/very old man
Nicolet, that brings back some memories... What happened to NTI? Sure I knew at one time, senility.

#### SIY

##### Technical Expert
Technical Expert
Nicolet, that brings back some memories... What happened to NTI? Sure I knew at one time, senility.
A few years after I left, they were acquired by Thermo-Fisher. AFAIK, the digital scopes are long gone, but their analytical instrumentation is still around, though with NIC sort of in the background as a brand.

#### pkane

##### Major Contributor
Forum Donor
I have calculated a sine wave of magnitude .4, rounded it, added uniform dither, rounded that, and added tpd, and rounded THAT, i.e. I've set a step size of '1' in the quantizer.

The routine that does this will follow in a comment.

The photo I'm attaching now has 4 lines. each line shows a signal. The four columns are
(signal) (signal spectrum) (error signal) and (error spectrum)

The four lines are View attachment 47956
undithered unquantized
undithered quantized - NOTE THE SIGNAL IS GONE. POOF, LOST, MISSING, GONE. Information is ***LOST***
uniform dithered quantized - Note, signal is back, but noise level changes with data value, so data modulates noise level.
TPD - Note, signal is back at same level, noise is 3dB higher, but there is no modulation of the noise level.

This shows, clearly, visibly, and without debate, that DITHERING PRESERVES INFORMATION.

That is all!
Here's an example of 4 bit quantization of 1kHz signal using my DISTORT software.

No dither:

TPDF dither:

Shaped dither, pushing quantization noise to higher frequencies (unfiltered):

Shaped dither, filtered at 20kHz:

Forum Donor

#### solderdude

##### Major Contributor
As far as I know, there are different dithering algorithms that generate different noise shaping responses, and the developers choose them by psychoacoustics tests.
The demo by @j_j was intended to show what dither does (preventing truncation) showing adding dither is and not :
Dithering is a signal processing that always results in degradation of a signal waveform (adding noise) but the same time it improves auditory perception of that signal..... So, dithering is a perfect example of psychoacoustic treatment of audio signal
Of course the NS3™ algorithm is based on psychoacoustic tests and improves the final result of added jitter by shifting noise into higher frequencies that are less audible by changing the 'shape' of the jitter as shown by @pkane. Paul's shaped dither most likely differs a bit from NS3™.

#### pkane

##### Major Contributor
Forum Donor
Of course the NS3™ algorithm is based on psychoacoustic tests and improves the final result of added jitter by shifting noise into higher frequencies that are less audible by changing the 'shape' of the jitter as shown by @pkane. Paul's shaped dither most likely differs a bit from NS3™.
DISTORT shaped dither is my own creation and will bear no resemblance to anything else out there. It was just meant to help demonstrate the difference between no dither, TPDF, and a simple shaped dither Of course, this being part of DISTORT, you can also listen to the differences.

#### Hayabusa

##### Active Member
Nice job, @j_j ! Need to copy the script and fire up Matlab again.

I must have missed it -- who thought dither was psychoacoustic? How is such a conclusion even considered (I guess by audiophiles who dismiss all science and math as irrelevant?)
The dither can be noise shaped with psycho-acoustic rules to minimize the audibility.

#### DonH56

##### Technical Expert
Technical Expert
Forum Donor
spin off from here
Ah, thank you. Using psychoacoustics (is that a euphemism for listening tests in this context?) to decide what sort of dither to use seems fundamentally different than explaining how dither works.

In my example the applied noise was out of the signal band and still impacted in-band signals as desired. It did require higher amplitude, natch. I do not recall trying different envelope shapes at that time; white noise is the only source I had and I filtered it to obtain the desired passband. It was a flash ADC, not delta-sigma.

#### DonH56

##### Technical Expert
Technical Expert
Forum Donor
The dither can be noise shaped with psycho-acoustic rules to minimize the audibility.
What rules? Curious... My system shaped the noise to move it out of band and control the amplitude. What sort of psychoacoustic rules are used to optimize dither in audio systems? Do they correlate to the math? Noise decorrelation is pretty well defined and has been for decades; I don't know anything (relatively) about psychoacoustics.

Forum Donor