• WANTED: Happy members who like to discuss audio and other topics related to our interest. Desire to learn and share knowledge of science required. There are many reviews of audio hardware and expert members to help answer your questions. Click here to have your audio equipment measured for free!

Dithering is a Mathematical Process - NOT a psychoacoustic process.

xr100

Addicted to Fun and Learning
Joined
Jan 6, 2020
Messages
518
Likes
237
Location
London, UK
Please, try your demonstration with "round" not "floor".

(Recall that this is for a 1kHz sine wave at -40dBr, but scaled to 0dBr for the plots. Sample rate = 96kHz.)

Round:

1581081052866.png


c.f. Truncate toward negative:

1581081100056.png


Approx. error:

Round: -47dB
Truncate toward negative: -56dB
Dithered and noise shaped: -30dB

Brickwall HP filter at 20Hz (remove DC offset) and brickwall LP filter at 20kHz:

Round: -64dB
Truncate toward negative: -64dB
Dithered and noise shaped: -79dB
 
Last edited:

xr100

Addicted to Fun and Learning
Joined
Jan 6, 2020
Messages
518
Likes
237
Location
London, UK
If you add dither to my finances, will my bank account go up and down by a few cents every time I look at the balance?

GUIDANCE NOTE FOR RETAIL FUEL DISPENSERS (PETROL PUMPS) AND ROAD TANKER MOUNTED METER MEASURING SYSTEMS FITTED WITH STANDARD TEMPERATURE ACCOUNTING (STA) DISPLAYS

Not a link to be clicked on unless really curious. Rather, it's evidence that, when you fill the tank(s) of your vehicle(s) with petrol/gasoline, the amount dispensed is not exact, instead being within certain tolerances.

So, it just goes to show that dithering occurs, anyway. ;-)
 

Arpiben

Member
Joined
Dec 1, 2019
Messages
38
Likes
37
Perhaps you can clarify why certain test discs (CD) of mine use different (to one another) digitally generated (not from analog sign gen) prime frequencies for the high precision THD testing tracks?

The Denon uses (small excerpts- not complete) 1001/3149/6301/9999/15999Hz etc. The CBS-CD1 uses 997/4001/7993/19997Hz etc The Philips test disc 3 uses 997/10007/16001Hz etc. My Sony test discs use even figures (1KHz,10KHz etc)

I've seen and read various explanations about hitting absolute 16 bit values or correlation with the sampling frequency but the only one that lines up with that is the Denon disc (1982) and it would have been a 44,056 sample rate on a Umatic based source (via a PCM-xxxx adapter at the time I assume), which makes no sense as the frequencies are spot on at 44,100.

Way back in 1984, Louis Challis compared the Sony YEDs with the Denon 99 track test disc and found a big difference in the 5th harmonic. Were/are digitally generated sines synthesized from lookup tables? Is the difference in 5th to do with the chosen frequency or a flaw in the generated sine itself?

(The Sony is a misprint, the frequency is 1000Hz)
View attachment 48940

I tried 997,8,9 1000 and 1001,2,3 generated sines on loopback (ARTA) and could repeatedly get better (very tiny amount) residual THD than the 1KHz. That was with either 24/44.1 or 24/48. I couldn't do 16/44.

Anyway, I'll be perfectly honest, I'm confused about it all and have been for years.

And the Denon disc gives lower THD than the CBS CD-1 test disc (which was the test standard for years at all the audio magazines) on many of its high precision tracks too. Not only that, the Denon is balls accurate (benchtop freq counter) on all the spot frequencies, whereas the CD-1 isn't.

"If frequencies are used which are sub multiples of the sample rate, the waveform will exercise only a few codes of the digital word.
For example generating 1 kHz in a 48 kHz sample rate system will require only 48 different data values. This may leave large portions of a converter untested. If frequencies are used which are prime to the sample rate then eventually every code in the data word will be used. Using 997 Hz instead of 1 kHz will result in all codes of a digital system (operating at standard sample rates) being exercised. This frequency makes a good digital 1 kHz since it is also prime to the 44.1 kHz consumer standard sampling frequency."
Abstract from Fundamentals of Modern Audio Measurement Richard C. Cabot, AES Fellow page 5/24
http://www.hit.bme.hu/~papay/edu/Acrobat/Fund.pdf

Dealing with coherent frequency sampling a good start reading:
The Frequency Distribution of Quantization Error in Digitizers for Coherent Sampling Sol Neeman, Ph.D. Johnson and Wales University
https://scholarsarchive.jwu.edu/cgi/viewcontent.cgi?article=1000&context=engineering_fac
 
Last edited:

xr100

Addicted to Fun and Learning
Joined
Jan 6, 2020
Messages
518
Likes
237
Location
London, UK
Then probably rounding operation, routinely used everywhere, is not the most correct and we should use some more sophisticated method for that?

Dither is used "everywhere," or to be more specific, whenever required, in correctly engineered digital audio processes/systems.
 

Serge Smirnoff

Active Member
Joined
Dec 7, 2019
Messages
240
Likes
136
(Recall that this is for a 1kHz sine wave at -40dBr, but scaled to 0dBr for the plots. Sample rate = 96kHz.)

Round:

View attachment 48989

c.f. Truncate towards negative:

View attachment 48990

Approx. error:

Round: -47dB
Truncate toward negative: -56dB
Dithered and noise shaped: -30dB

Brickwall HP filter at 20Hz (remove DC offset) and brickwall LP filter at 20kHz:

Round: -64dB
Truncate toward negative: -64dB
Dithered and noise shaped: -79dB
The only difference is a DC offset of 1/2 LSB.
Thank you, @xr100, for the computation.
Yes, floor and round are almost the same; there is a small difference around 0.5 -1dB for some signals but I did not understand its nature, does not matter in our case. What really matters is degradation of a signal. In order to demonstrate degradation of a signal due to dithering any complex analysis is not required. We have reference 32b signal and output 16bit one. Dithering and quantization are both time accurate operations, so we can just compute correlation coefficient for these two signals. The higher the coeff., the less output signal is distorted/degraded. Pure mathematical test and very accurate.

I took two signals - Sine1kHz(96k,-10dBFS) and White Noise(96k,-10dBFS)

Both signals were tested with three operations:

- rounding (in Adobe Audition)
- triangular dither + rounding (in Adobe Audition)
- Gaussian dither + rounding (in Adobe Audition)

The code for computing correlation:
ref = audioread('sine1k96.wav'); out = audioread('sine1k96_q.wav'); 10*log10((1-corrcoef(ref, out)))

The results are in dB (df levels), which is more convenient/habitual:

Sine 1kHz
- rounding: -91.92dB
- triangular dither + rounding: -86.33dB
- Gaussian dither + rounding: -85.10dB

White Noise
- rounding: -91.10dB
- triangular dither + rounding: -86.33dB
- Gaussian dither + rounding: -85.09dB

This simple math test shows that both signals being dithered+quantized were degraded to noticeably higher extent (+5dB/+6dB) than just rounded. If you send me the reference/processed signals from your examples I will compute df levels for them.
 

scott wurcer

Major Contributor
Audio Luminary
Technical Expert
Joined
Apr 24, 2019
Messages
1,501
Likes
2,822
This simple math test shows that both signals being dithered+quantized were degraded to noticeably higher extent (+5dB/+6dB) than just rounded. If you send me the reference/processed signals from your examples I will compute df levels for them.

Have you considered that your basic premise could be flawed?
 

Hayabusa

Addicted to Fun and Learning
Joined
Oct 12, 2019
Messages
838
Likes
585
Location
Abu Dhabi

Serge Smirnoff

Active Member
Joined
Dec 7, 2019
Messages
240
Likes
136
Have you considered that your basic premise could be flawed?
Yes, I usually examine the initial assumptions. Testing degradation of waveforms with corr.coeff looks suspicious to you? Or did I miss something again?
 
Last edited:

xr100

Addicted to Fun and Learning
Joined
Jan 6, 2020
Messages
518
Likes
237
Location
London, UK
This simple math test shows that both signals being dithered+quantized were degraded to noticeably higher extent (+5dB/+6dB) than just rounded.

"Delta Spectrogram" plots generated by DeltaWave for 1kHz sine @ -10dBr, 44.1kHz sample rate.

16-bits iZotope Ozone - Dither=Strong, Noise Shaping=Max:

1581115167793.png


16-bit TPDF dither (truncate toward negative):

1581115384405.png


16-bit truncate toward negative:

1581115463602.png
 

xr100

Addicted to Fun and Learning
Joined
Jan 6, 2020
Messages
518
Likes
237
Location
London, UK
DC offset is not accounted by corr.coeff by definition. Lowpass filter can spoil the waveform even further. I hope xr100 will send his files.

Which files would you like? Did you want them with the high-pass and low-pass filters imposed (post-dither/truncation) on the signal also?
 

xr100

Addicted to Fun and Learning
Joined
Jan 6, 2020
Messages
518
Likes
237
Location
London, UK
Perhaps you can clarify why certain test discs (CD) of mine use different (to one another) digitally generated (not from analog sign gen) prime frequencies for the high precision THD testing tracks?

The Denon uses (small excerpts- not complete) 1001/3149/6301/9999/15999Hz etc. The CBS-CD1 uses 997/4001/7993/19997Hz etc The Philips test disc 3 uses 997/10007/16001Hz etc. My Sony test discs use even figures (1KHz,10KHz etc) […]

997Hz sine @ -10dBr, truncate to 16-bit, 44.1kHz sample rate:

1581116542602.png



1000Hz sine @ -10dBr, truncate to 16-bit, 44.1kHz sample rate:

1581116587046.png



(As previously, rescaled so the amplitude of the sine wave is at 0dBr for the plots.)
 

Serge Smirnoff

Active Member
Joined
Dec 7, 2019
Messages
240
Likes
136
Which files would you like? Did you want them with the high-pass and low-pass filters imposed (post-dither/truncation) on the signal also?
The most interesting for me is to measure df before and after filtering. But if it is not difficult, please, send them all )). Or another option - choose the ones which are interesting for you to measure df.
 

mansr

Major Contributor
Joined
Oct 5, 2018
Messages
4,685
Likes
10,705
Location
Hampshire
997Hz sine @ -10dBr, truncate to 16-bit, 44.1kHz sample rate:

View attachment 49035


1000Hz sine @ -10dBr, truncate to 16-bit, 44.1kHz sample rate:

View attachment 49036


(As previously, rescaled so the amplitude of the sine wave is at 0dBr for the plots.)
Certain frequency and amplitude combinations at a given sample rate result in exact sample values. Many more yield minimal errors on simple truncation. You found one of these. This is useful for testing but of little importance in general use where any frequency may be encountered.
 

xr100

Addicted to Fun and Learning
Joined
Jan 6, 2020
Messages
518
Likes
237
Location
London, UK
The most interesting for me is to measure df before and after filtering. But if it is not difficult, please, send them all )).

OK, here's all of them:

Files

(Download link expires in one week.)

Note that the "original" 1kHz sine @ -40dBr is the file named "64-bit FP."

The rest should be self-explanatory, but do note that the files marked "16-bit" that are suffixed with "BANDPASSED" are 64-bit float, as the bandpass filter is AFTER the dithering/noise shaping/truncation (as applicable) stage, and the filter process operates in 64-bit float. Note that the bandpass filters are IIR so not "linear phase."

Also note that a bandpassed version of the "original" is included, where needed so that modification to the signal by the bandpass filter can be disregarded when comparing to the dithered/noise shaped/truncated (as applicable) files. After all, the BP filter is only there to substantially attenuate parts of the spectrum outside the audible range. (Plus remove DC offset where applicable.)
 
Last edited:
OP
j_j

j_j

Major Contributor
Audio Luminary
Technical Expert
Joined
Oct 10, 2017
Messages
2,282
Likes
4,792
Location
My kitchen or my listening room.
Top Bottom