Re: Please help to explain the algorithm in pa_sw_volume_to_dB

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 2022/8/8 下午9:29, zhaochengyi@xxxxxxxxxxxxx wrote:
Hi guys,

The dB range of Playback Master of Sound Card is between -65.25 and 0.

I changed the sink volume to 8%, but the dB volume calculated by function pa_sw_volume_to_dB is -65.82 dB, this will result in
no sound playing when the volume is between %0 and 8%.

I think this is an issue, but I don't understand the algorithm
principle of function pa_sw_volume_to_dB.

Would you please help to explain it, thanks a lot!

logs:
------------------------------------
8月 08 21:06:32.535263 zhao-PC pulseaudio[5173]: D: [pulseaudio] protocol-native.c: Client dde-session-daemon changes volume of sink alsa_output.pci-0000_03_00.6.analog-stereo. 8月 08 21:06:32.535263 zhao-PC pulseaudio[5173]: D: [pulseaudio] sink.c: The reference volume of sink alsa_output.pci-0000_03_00.6.analog-stereo changed from front-left: 4587 /   7% / -69.30 dB,   front-right: 4587 /  7% / -69.30 dB to front-left: 5898 /   9% / -62.75 dB,   front-right: 5898 /   9% / -62.75 dB. 8月 08 21:06:32.535263 zhao-PC pulseaudio[5173]: D: [alsa-sink-ALC256 Analog] alsa-sink.c: Requested volume: front-left: 5898 /   9% / -62.75 dB,   front-right: 5898 /   9% / -62.75 dB 8月 08 21:06:32.535263 zhao-PC pulseaudio[5173]: D: [alsa-sink-ALC256 Analog] alsa-sink.c: Got hardware volume: front-left: 5919 /   9% / -62.65 dB,   front-right: 5919 /   9% / -62.65 dB 8月 08 21:06:32.536525 zhao-PC pulseaudio[5173]: D: [alsa-sink-ALC256 Analog] alsa-sink.c: Calculated software volume: front-left: 65303 / 100% / -0.09 dB,   front-right: 65303 / 100% / -0.09 dB (accurate-enough=yes) 8月 08 21:06:32.536525 zhao-PC pulseaudio[5173]: D: [alsa-sink-ALC256 Analog] sink.c: Volume going up to 5898 at 6577292163 8月 08 21:06:32.536525 zhao-PC pulseaudio[5173]: D: [alsa-sink-ALC256 Analog] ratelimit.c: 745 events suppressed 8月 08 21:06:32.536525 zhao-PC pulseaudio[5173]: D: [alsa-sink-ALC256 Analog] sink.c: Next volume change in 7992 usec 8月 08 21:06:32.536525 zhao-PC pulseaudio[5173]: D: [alsa-sink-ALC256 Analog] sink.c: Next volume change in 7981 usec 8月 08 21:06:32.536525 zhao-PC pulseaudio[5173]: I: [pulseaudio] module-device-restore.c: Storing volume/mute for device+port sink:alsa_output.pci-0000_03_00.6.analog-stereo:analog-output-speaker. 8月 08 21:06:32.543465 zhao-PC pulseaudio[5173]: D: [alsa-sink-ALC256 Analog] sink.c: Volume change to 5898 at 6577292163 was written 104 usec late 8月 08 21:06:40.507006 zhao-PC pulseaudio[5173]: D: [pulseaudio] protocol-native.c: Client dde-session-daemon changes volume of sink alsa_output.pci-0000_03_00.6.analog-stereo. 8月 08 21:06:40.507006 zhao-PC pulseaudio[5173]: D: [pulseaudio] sink.c: The reference volume of sink alsa_output.pci-0000_03_00.6.analog-stereo changed from front-left: 5898 /   9% / -62.75 dB,   front-right: 5898 /  9% / -62.75 dB to front-left: 4587 /   7% / -69.30 dB,   front-right: 4587 /   7% / -69.30 dB. 8月 08 21:06:40.507593 zhao-PC pulseaudio[5173]: D: [alsa-sink-ALC256 Analog] alsa-sink.c: Requested volume: front-left: 4587 /   7% / -69.30 dB,   front-right: 4587 /   7% / -69.30 dB 8月 08 21:06:40.507593 zhao-PC pulseaudio[5173]: D: [alsa-sink-ALC256 Analog] alsa-sink.c: Got hardware volume: front-left: 4605 /   7% / -69.20 dB,   front-right: 4605 /   7% / -69.20 dB 8月 08 21:06:40.507593 zhao-PC pulseaudio[5173]: D: [alsa-sink-ALC256 Analog] alsa-sink.c: Calculated software volume: front-left: 65280 / 100% / -0.10 dB,   front-right: 65280 / 100% / -0.10 dB (accurate-enough=yes) 8月 08 21:06:40.507593 zhao-PC pulseaudio[5173]: D: [alsa-sink-ALC256 Analog] sink.c: Volume going down to 4587 at 6585248016 8月 08 21:06:40.507593 zhao-PC pulseaudio[5173]: D: [alsa-sink-ALC256 Analog] sink.c: Volume change to 4587 at 6585248016 was written 8010 usec late 8月 08 21:06:40.507593 zhao-PC pulseaudio[5173]: I: [pulseaudio] module-device-restore.c: Storing volume/mute for device+port sink:alsa_output.pci-0000_03_00.6.analog-stereo:analog-output-speaker. 8月 08 21:06:42.535546 zhao-PC pulseaudio[5173]: I: [pulseaudio] module-device-restore.c: Synced. 8月 08 21:06:48.928087 zhao-PC pulseaudio[5173]: D: [pulseaudio] protocol-native.c: Client dde-session-daemon changes volume of sink alsa_output.pci-0000_03_00.6.analog-stereo. 8月 08 21:06:48.928087 zhao-PC pulseaudio[5173]: D: [pulseaudio] sink.c: The reference volume of sink alsa_output.pci-0000_03_00.6.analog-stereo changed from front-left: 4587 /   7% / -69.30 dB,   front-right: 4587 /  7% / -69.30 dB to front-left: 5242 /   8% / -65.82 dB,   front-right: 5242 /   8% / -65.82 dB. 8月 08 21:06:48.928812 zhao-PC pulseaudio[5173]: D: [alsa-sink-ALC256 Analog] alsa-sink.c: Requested volume: front-left: 5242 /   8% / -65.82 dB,   front-right: 5242 /   8% / -65.82 dB 8月 08 21:06:48.928812 zhao-PC pulseaudio[5173]: D: [alsa-sink-ALC256 Analog] alsa-sink.c: Got hardware volume: front-left: 5276 /   8% / -65.65 dB,   front-right: 5276 /   8% / -65.65 dB 8月 08 21:06:48.928812 zhao-PC pulseaudio[5173]: D: [alsa-sink-ALC256 Analog] alsa-sink.c: Calculated software volume: front-left: 65114 / 99% / -0.17 dB,   front-right: 65114 /  99% / -0.17 dB (accurate-enough=yes)
--------------------------------------------

The relevant functions are as follows:

static double linear_to_dB(double v) {
    return 20.0 * log10(v);
}

double pa_sw_volume_to_linear(pa_volume_t v) {
    double f;

    pa_return_val_if_fail(PA_VOLUME_IS_VALID(v), 0.0);

    if (v <= PA_VOLUME_MUTED)
        return 0.0;

    if (v == PA_VOLUME_NORM)
        return 1.0;

    f = ((double) v / PA_VOLUME_NORM);

    return f*f*f;
}

double pa_sw_volume_to_dB(pa_volume_t v) {

    pa_return_val_if_fail(PA_VOLUME_IS_VALID(v), PA_DECIBEL_MININFTY);

    if (v <= PA_VOLUME_MUTED)
        return PA_DECIBEL_MININFTY;

    return linear_to_dB(pa_sw_volume_to_linear(v));
}






[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux