05-20-2019, 09:41 PM
(12-20-2018, 07:09 PM)Tim Curtis Wrote: Thats interesting, I also see 4 dB gain at ALSA 100% for the on-board audio device. It could be a Kernel bug.
I'll do some checking...
Granted I was trying understand the software (not hardware) volume, ALSA configs are not the source for where the volume is set to 100% with 4dB gain. Instead I discovered default levels are set by "/var/www/command/worker.php". Line 566 of worker.php is where I found modifying the end of sysCmd from 100 to 95 achieved the desired result since setting volume from the web interface is not persistent with reboots. The problem may be illustrated by running an example of the same command that "/var/www/command/util.sh" will call on line 84.
Example of current problem:
pi@moode:~ $ amixer -c 0 sset "'PCM'" 100%
Simple mixer control 'PCM',0
Capabilities: pvolume pvolume-joined pswitch pswitch-joined
Playback channels: Mono
Limits: Playback -10239 - 400
Mono: Playback 400 [100%] [4.00dB] [on]
versus adding the parameter to specify gain dB in addition to volume percent gets this result, which is what I was looking for to avoid clipping.
pi@moode:~ $ amixer -c 0 sset "'PCM'" 0,100%
Simple mixer control 'PCM',0
Capabilities: pvolume pvolume-joined pswitch pswitch-joined
Playback channels: Mono
Limits: Playback -10239 - 400
Mono: Playback 0 [96%] [0.00dB] [on]
*Notice that 0 dB gain plus 100% volume translates to 96%. Adding " 0," on line 566 of "/var/www/command/worker.php" should fix this bug to prevent clipping as a default persistent state after rebooting.
Bottom line quick fix, edit line 566 of "/var/www/command/worker.php" to the following
$result = sysCmd('/var/www/command/util.sh set-alsavol ' . '"' . $_SESSION['amixname'] . '"' . ' 0,100');
** I still experienced some noticeable clipping at 100% on an rPi2 model B, so playing it safe at 96% in my own config.