Difference between revisions of "Dither"

From Audacity Wiki
Jump to: navigation, search
(Reorder first section and clarify that high-quality dither controls dither applied when editing)
m (update link to release manual)
(10 intermediate revisions by 4 users not shown)
Line 1: Line 1:
'''Related articles:'''
This page has been transferred to the [https://manual.audacityteam.org/man/dither.html Audacity Manual].
'''[[Bit Depth]]'''
'''Other articles in our [[:Category:Digital Audio Technology|Digital Audio Technology]] category'''
'''"Dither"''' is intentional noise which is added so as to randomise the {{external|[http://en.wikipedia.org/wiki/Quantization_error quantisation errors]}} (rounding errors) that occur when downsampling the [[Bit Depth]] of an audio stream to a lower resolution than the current format. The dither randomises the "arithmetical carry" on rounding the last bit to be used, rather than creating a repeatable, quantifiable rounding error. In this way the potentially audible distortion problems inherent in downsampling are minimised. The noise itself isn't audible unless heavily or repeatedly amplified.
Downsampling can occur when converting a file to a lesser bit depth, or in real time when Audacity plays audio at a lesser bit depth than the bit depth of the track. The bit depth of Audacity projects is set at "Default Sample Format" on the {{menu|Quality tab of Preferences}}.
An example of downsampling when converting a file is when you export from a 32-bit float or 24-bit project to a 16-bit export format. Downsampling also occurs in a 16-bit or 24-bit project every time you edit a section of audio (thus writing to the project's audio data), because Audacity temporarily converts the samples to 32-bit float format before downsampling back to the current format. Conversely, dithering will never be applied within a 32-bit float project because no downsampling occurs. Also, the precision of float samples is good enough to justify not applying dither. 
In a similar way, downsampling will occur with most sound cards every time you play audio in a 32-bit or 24-bit Audacity project, because most sounds cards are still 16-bit. 
You can choose the type of dither to be used in Audacity when performing operations requiring downsampling, or you can turn dither off altogether by setting it to none. The dither settings are again in the {{menu|Quality tab of Preferences}}. The setting for "real-time dither" applies to dithering done when playing back, and that for "high-quality dither" to file writing (editing or exporting). Note that applying dither can slow down processing (or potentially cause audio breakups when playing on slow machines) due to the extra calculations involved.
The rectangular and triangular types of dither are simply different methods for randomising the rounding process. The rectangular method can be thought of as like the roll of a die - any number has the same random probability of surfacing. The triangular method can be thought of as equivalent to a roll of two dice. The shaped  dither means that the created noise is shaped so that the quantisation errors occur less in the frequencies we can hear easily, and more in very high frequencies that we cannot hear so easily. The general consensus is that shaped or triangle dither tend to sound the best.
== Dither applied on Export - detailed explanation ==
Dither is only applied when converting from a higher bit depth to a lower bit depth. Exporting in WAV format is virtually lossless in all situations. However there is a very small amount of change to the audio data with some types of WAV export, depending on the settings in Audacity Preferences (see below).
*If you export to 32-bit PCM WAV format, it is 100% lossless - no dithering is applied.
*If you export to 24-bit PCM WAV format , it is 100% lossless - no dithering is applied.
*If you export to 16-bit PCM WAV format it will be between 100% and 99.975% lossless depending on the original audio format in Audacity and settings in Audacity Preferences.
For exporting to 16-bit, he maximum error is +/- 2 on a scale of -32768 to +32768 and you should bear in mind that 16-bit audio is at best only accurate to the nearest digit on this scale.
So where does the error come from?
Audacity performs calculations using 32bit float numbers, which provides incredible accuracy (considerably better than even the best top of the range sound cards). If Audacity needs to reduce the resolution to 16 bit, then there will be "rounding off" errors. If simple "rounding" is done by simply taking each sample value and converting it to the nearest 16 bit value, then a "steppiness" in the output will result which may be audible, particularly with extremely quiet sounds. To avoid this, Audacity applies "dither" in the conversion - ''this is often likened to "anti-aliasing" in graphics which is used to smooth the steppiness of curves''. Rather than always rounding the values to the nearest 16-bit value, dithering will apply a degree of randomness to the rounding off so as to prevent causing steps.
Audacity has 3 alternative algorithms for how it applies dither and they are found in "Edit menu > Preferences > Quality". The dither settings we are talking about are the ones for "High Quality Conversion". The available options are: None (no dither), rectangle, triangle and shaped. The differences between these settings are very subtle and you need to be listening carefully with good equipment to notice any difference. Generally, "triangle" or "shaped" will give the best (subjective) results.
*If dither is set to "none", then conversions from one bit depth to a lower bit depth will be done by simple rounding.
*If dither is set to "rectangle" or "triangle", then a random factor of +/- 1 bit is applied. In effect, this is applying a very small amount of "noise" to the signal.
*If dither is set to "shaped", then a random factor of +/- 2 bits is applied. While this may appear to be worse than the other 2 types of dither (the peak amplitude of the noise is greater) the distribution of these random variations is done in such a way that the noise is mostly at the high frequency end of the audio spectrum and as it is at a very low level it may be less noticeable than the other types of dither.
If you are working in Audacity with 32-bit audio, then dither should be enabled in the high quality conversion settings (it is by default). Dither will only be applied if the output is at a lower bit depth. Converting from a higher bit depth to a lower bit depth will inevitably have inaccuracies (because the lower bit depth is less accurate). Using dither just makes these inaccuracies less noticeable in the music.
Converting from 32-bit (float) to 24-bit does not introduce dither noise because 32 bit float uses 24-bit precision (and an 8-bit exponent) so the 24 bits are used without modification.
Here's the exception to the rule: If you have recorded in 16-bit and are only doing simple editing (cut, delete, paste, trim...) and not doing any processing (amplify, equalize, frequency filter....) then for highest accuracy dither can be set to "none". In this case, because there are no 32-bit operations prior to export there is no benefit to using dither. Exporting a 16-bit track to 16-bit with dither set to "none" will be lossless.
If you are doing any form of processing of the audio, then the highest quality will be achieved by using 32-bit (float) throughout. Note that 32-bit audio files are twice the size of 16-bit audio files.
[[Category:Digital Audio Technology]]

Latest revision as of 11:52, 21 October 2019

This page has been transferred to the Audacity Manual.