Dither

Support questions for Neutron Player only.
Post Reply
blaubär
Posts: 1972
Joined: Tue Apr 02, 2019 6:48 am

Dither

Post by blaubär » Sun Jan 24, 2021 1:35 pm

On the equalizer screen you can activate or deactivate Dither.

crossfeed.jpg
crossfeed.jpg (3.6 KiB) Viewed 726 times
This might improve your SNR ( signal noise ratio ) if you use any DSP ( digital signal processing, meaning resampling, equalizer, crossfeed, surround, compressor etc ). Neutron internally calculates with 64 bit or 32 bit. It often happens that whatever gets its output, which in most cases is the DAC ( digital analag converter ), cannot handle that many bits, so some have to be truncated. To mitigate the adverse effects of this truncation Dither can help.

See Audio Dithering: What You Need to Know
So, what is dither? It’s a form of low-level noise that is intentionally added to a digital audio file as it’s rendered to a lower bit depth.
and Dither
This leads to the dither solution. Rather than predictably rounding up or down in a repeating pattern, it is possible to round up or down in a random pattern.
As a further option in this context you can enable or disable Noise Shaping . This doesn't apply just any noise, but such a noise that the resulting noise is shifted in the frequency spectrum to areas where humans hear it least.

20210124_161029.jpg
20210124_161029.jpg (21.86 KiB) Viewed 714 times
And finally: when do we need that ? If Neutron's output has at least 24 bit then humans won't hear the noise and the DAC won't be able to reproduce better than that anyway due to Johnson–Nyquist noise . Also if the music is loud ( pop, rock, etc ) noise doesn't matter. But the cost isn't high and so for the sake of simplicity I suggest you just keep it permanently switched on. Have a look at this topic, there a user tells us that he has music that he prefers to hear without Dither.

blaubär
Posts: 1972
Joined: Tue Apr 02, 2019 6:48 am

Re: Dither

Post by blaubär » Wed Jan 27, 2021 7:24 am

As I don't hear a difference between dithering and not dithering I wanted to find out whether this really does something or if the developer just pulls our legs :-) . How to do this ?

I first needed some very quiet music. So I took a test song ( Follow The Sun by The Beatles ) and attenuated it by factor 2000, that's about 66 dB, using the following command: ffmpeg -i "05 I'll Follow the Sun.wma" -af volume=0.0005 test-2000.wav. I transferred it to my smartphone and played it with Neutron.

I had "Settings > Audio Hardware > DSP Effect (Device)" enabled so that high-res-audio wouldn't work and neutron would have to use 16-bit output. And I used some DSP ( resampling to 48 kHz, equalizer and crossfeed ) so that the 16-bit-input would use more bits while being processed. Neutron would then have to truncate that to 16-bit when it transferred its output to the DAC. And then one might hope to get an effect with dither enabled.

I did three tests: without dithering, with dithering but without noise shaping, with dither and noise shaping. I connected the analog output of the phone to the analog input of an old linux laptop and recorded there with audacity. Then I amplified the recordings by 40 db and listened to them. I heard the difference. Here are the waveform and spectrum displays.

dither-wv-0.jpg
dither-wv-0.jpg (57.58 KiB) Viewed 666 times
dither-wv-1.jpg
dither-wv-1.jpg (47.34 KiB) Viewed 666 times
dither-wv-2.jpg
dither-wv-2.jpg (41.55 KiB) Viewed 666 times
dither-spectrum-comparison.jpg
dither-spectrum-comparison.jpg (146.94 KiB) Viewed 666 times
Look at the third spectrum, you'll see a bump in the lower right corner, that's the effect of the noise shaping. So I conclude that dithering really works with Neutron.

And here's an extract with a forth test using high-res-32-bit-output ( no need for dithering ) added.

d-0-w.jpg
d-0-w.jpg (56.88 KiB) Viewed 653 times
d-1-w.jpg
d-1-w.jpg (54.32 KiB) Viewed 653 times
d-2-w.jpg
d-2-w.jpg (44.11 KiB) Viewed 653 times
d-3-w.jpg
d-3-w.jpg (32.32 KiB) Viewed 653 times
d-s.jpg
d-s.jpg (99.31 KiB) Viewed 653 times
We see that dithering reduces the noise, dithering with noise shaping more so, and the best would be not to truncate the output in the first place, as we would expect.

blaubär
Posts: 1972
Joined: Tue Apr 02, 2019 6:48 am

Re: Dither

Post by blaubär » Wed Jan 27, 2021 11:13 am

And finally the spectrums in big for better comparison :

no dither :

d-0-s.jpg
d-0-s.jpg (57.37 KiB) Viewed 646 times
dither :

d-1-s.jpg
d-1-s.jpg (56.68 KiB) Viewed 646 times
dither and noise shaping :

d-2-s.jpg
d-2-s.jpg (52.27 KiB) Viewed 646 times
high-res with 32-bit :

d-3-s.jpg
d-3-s.jpg (47.73 KiB) Viewed 646 times
for comparison: that would be the ideal curve, obtained be calculation, without D/A and A/D conversions :

d-5-s.jpg
d-5-s.jpg (55.16 KiB) Viewed 646 times

blaubär
Posts: 1972
Joined: Tue Apr 02, 2019 6:48 am

Re: Dither

Post by blaubär » Wed Jan 27, 2021 8:43 pm

So, can we do this theoretically, play around with dither without having to mess with cables etc ? Yes, you can use Audacity. Like this: I disabled/enabled dither, then loaded a song, attenuated it by -33 dB and exported it as 16 bit wav, again, amplified it by 33 dB and exported, again. See the results, first the original song:

wv-1.jpg
wv-1.jpg (68.09 KiB) Viewed 630 times
sp-1.jpg
sp-1.jpg (91.56 KiB) Viewed 630 times
Then without dither - note the staircase-shaped waveform :

wv-2.jpg
wv-2.jpg (61.68 KiB) Viewed 630 times
sp-2.jpg
sp-2.jpg (65.57 KiB) Viewed 630 times
Then with dither and noiseshaping - note the bump in the spectrum at the high frequencies :

wv-3.jpg
wv-3.jpg (85.89 KiB) Viewed 630 times
sp-3.jpg
sp-3.jpg (78.07 KiB) Viewed 630 times
The difference can be heard clearly, the noise with dithering is much higher in tone.

And that would work even better with a higher sampling rate, see Re: What would be the benefit of upsampling. Here a comparison between the spectrum from above and a similar one using oversampling.

ups-sel-spek.jpg
ups-sel-spek.jpg (127.2 KiB) Viewed 612 times

Post Reply

Who is online

Users browsing this forum: No registered users and 10 guests