From 23a20cda111232b5d21dde12d10e19e4ecb71cea Mon Sep 17 00:00:00 2001 From: Ricard Wanderlof Date: Wed, 18 Apr 2018 17:03:09 +0200 Subject: [PATCH] pcm: softvol: Allow up to 90 dB of gain The gain algorithm used in softvol can handle gain factors of up to 32767 which is slightly more than 90 dB, so allow a max_dB of 90 dB. This doesn't affect existing asound.conf files, but does allow a max_dB of up to 90 dB when needed. Tested using Audacity that there is no undue distorsion or other artefacts when 90 dB of gain is applied to a suitable signal (i.e. a signal quiet enough not be clipped whan applying 90 dB of gain). Signed-off-by: Ricard Wanderlof Signed-off-by: Takashi Iwai --- src/pcm/pcm_softvol.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pcm/pcm_softvol.c b/src/pcm/pcm_softvol.c index 8bb4a397..0eaeacef 100644 --- a/src/pcm/pcm_softvol.c +++ b/src/pcm/pcm_softvol.c @@ -59,7 +59,11 @@ typedef struct { #define PRESET_RESOLUTION 256 #define PRESET_MIN_DB -51.0 #define ZERO_DB 0.0 -#define MAX_DB_UPPER_LIMIT 50 +/* + * The gain algorithm as it stands supports gain factors up to 32767, which + * is a fraction more than 90 dB, so set 90 dB as the maximum possible gain. + */ +#define MAX_DB_UPPER_LIMIT 90 static const unsigned int preset_dB_value[PRESET_RESOLUTION] = { 0x00b8, 0x00bd, 0x00c1, 0x00c5, 0x00ca, 0x00cf, 0x00d4, 0x00d9, -- 2.11.0