Improve Dynamic Range (DR) of converters#1041
Improve Dynamic Range (DR) of converters#1041dmitrykos wants to merge 1 commit intoPortAudio:masterfrom
Conversation
|
@dmitrykos - Please hold off on changes to pa_converters until we finish #1034. |
@philburk I see, I did not notice that work. Regarding I can later adopt this PR or cancel it depending on the amount of changes in your earlier PR, so will wait until you finish #1034. |
|
Mea culpa #1043 |
|
@RossBencina I commented regarding scaling in #1042 and reasoned why 0x80 would be better. |
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_Ditherconverter: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.