Improve Dynamic Range (DR) of converters #1041
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Improves Dynamic Range (DR) of converters.
Currently, at this stage, DR of 8-bit is improved. For example Float32 to 8-bit converters got around 8+ dB DR improvement:
Dithered variant was improved too by modifying the way the dithered noise is applied. Before we truncated sample by 1 bit to add space for a dither noise. With this approach valid audio data info was truncated and we were getting an explicit dither noise. But, if there is no initial truncation and dither noise is added then we effectively mix all valid audio data with noise first and truncate it afterwards - this approach increases DR by at least 1 dB in case of 8-bit converters (will work similarly for other formats).
New approach on example of
Int32_To_Int8_Dither
converter:Here we truncate 32-bit sample to 24-bit to add some gap for calculations, add dither and only then truncate to final 8-bits.
I can further extend this PR to other formats and cleanup and re-factor existing code, which in some places is incorrect, in order to get maximum DR for all converters. All implementations will be commented, so that we will no longer have unexplained calculations and conversions. The quality of audio output of PA will definitely improve.
Awaiting comments.