Re: [pulseaudio-discuss] Please help to explain the algorithm in pa_sw_volume_to_dB
On 2022/8/8 下午9:29, zhaochen...@uniontech.com 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-_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-_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-_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-_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-_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-_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-_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-_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
Re: [pulseaudio-discuss] How do different sound cards dynamically use different configurations?
Hi Sean, On 2022/7/20 上午2:59, Sean Greenslade wrote: On Mon, Jul 18, 2022 at 02:42:07PM +0800, zhaochen...@uniontech.com wrote: On 2022/7/17 上午3:18, Sean Greenslade wrote: On Fri, Jul 15, 2022 at 06:04:49PM +0800, zhaochen...@uniontech.com wrote: Hi guys, On a special PC, it is required to start the pulseaudio daemon with some special parameters in the file /etc/pulse/daemon.conf, as follows: --- default-sample-rate = 48000 default-fragments = 2 default-fragment-size-msec = 20 --- When plugging in a USB headset with a separate sound card to this special PC, I found that there was a noise in the playback audio. After investigation, the sound card of the USB headset needs to use the following default parameters. --- default-sample-rate = 44100 default-fragments = 4 default-fragment-size-msec = 25 --- After my further investigation, I found that noise is only generated when changing the sink-input volume (pa_context_set_sink_input_volume), but not when changing the sink volume (pa_context_set_sink_volume_by_index). Can you describe this noise more specifically? Does it go away with larger fragment size / counts? Have you enabled or disabled tsched? Have you run with Pulse debug logging enabled and looked for any hints there (e.g. underruns)? I found out I only modified the item default-sample-rate in the file '/etc/pulse/daemon.conf', and then it will occur the the noise when changed the sink input volume. default-sample-rate = 48000 ; alternate-sample-rate = 48000 I think the merge_requests 120 can fix this noise issue: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/120 Thanks a lot. Best Regards, Chengyi
[pulseaudio-discuss] Please help to explain the algorithm in pa_sw_volume_to_dB
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-_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-_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-_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-_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-_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-_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-_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-_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:
Re: [pulseaudio-discuss] How do different sound cards dynamically use different configurations?
Hi Sean, Thanks for your reply. On 2022/7/17 上午3:18, Sean Greenslade wrote: On Fri, Jul 15, 2022 at 06:04:49PM +0800, zhaochen...@uniontech.com wrote: Hi guys, On a special PC, it is required to start the pulseaudio daemon with some special parameters in the file /etc/pulse/daemon.conf, as follows: --- default-sample-rate = 48000 default-fragments = 2 default-fragment-size-msec = 20 --- When plugging in a USB headset with a separate sound card to this special PC, I found that there was a noise in the playback audio. After investigation, the sound card of the USB headset needs to use the following default parameters. --- default-sample-rate = 44100 default-fragments = 4 default-fragment-size-msec = 25 --- After my further investigation, I found that noise is only generated when changing the sink-input volume (pa_context_set_sink_input_volume), but not when changing the sink volume (pa_context_set_sink_volume_by_index). Thanks, Chengyi
[pulseaudio-discuss] How do different sound cards dynamically use different configurations?
Hi guys, On a special PC, it is required to start the pulseaudio daemon with some special parameters in the file /etc/pulse/daemon.conf, as follows: --- default-sample-rate = 48000 default-fragments = 2 default-fragment-size-msec = 20 --- When plugging in a USB headset with a separate sound card to this special PC, I found that there was a noise in the playback audio. After investigation, the sound card of the USB headset needs to use the following default parameters. --- default-sample-rate = 44100 default-fragments = 4 default-fragment-size-msec = 25 --- So, how to enable the parameters required by the sound card of the USB headset when using it. Thanks, Chengyi
[pulseaudio-discuss] Get or set volume instead of dB in most cases
Hi guys, Because many new models of sound cards have various problems with dB volume, I would like get or set the element volume in dB only when e->has_dB is true and e->db_fix is valid. That is, get or set volume instead of dB in most cases. Would you please tell me your opinion? Thanks. patch: diff --git a/src/modules/alsa/alsa-mixer.c b/src/modules/alsa/alsa-mixer.c index 49c3968..2e88610 100644 --- a/src/modules/alsa/alsa-mixer.c +++ b/src/modules/alsa/alsa-mixer.c @@ -849,7 +849,7 @@ static int element_get_volume(pa_alsa_element *e, snd_mixer_t *m, const pa_chann int r; pa_volume_t f; -if (e->has_dB) { +if (e->has_dB && e->db_fix) { long value = 0; if (e->direction == PA_ALSA_DIRECTION_OUTPUT) { @@ -1199,7 +1199,7 @@ static int element_set_volume(pa_alsa_element *e, snd_mixer_t *m, const pa_chann f = pa_cvolume_max(v); } -if (e->has_dB) { +if (e->has_dB && e->db_fix) { long value = to_alsa_dB(f); int rounding; --- Thanks, Chengyi
Re: [pulseaudio-discuss] Why does the USB headset show the Digital Output (S/PDIF) port?
Hi Tanu, Thanks for your reply. On 2022/6/28 下午5:18, Tanu Kaskinen wrote: On Tue, 2022-06-28 at 15:21 +0800, zhaochen...@uniontech.com wrote: Hi guys, I have a USB headset that the module is Edifier USB K800. Plug it into the PC's usb port, and then I found "Digital Output (S/PDIF)" audio port as below. Would you please tell me why the Digital Output (S/PDIF) port has been shown, and how to verify if this USB headset really have the output function of Digital Output (S/PDIF), and how to close this audio port. Thanks a lot! Many USB sound cards show non-existent S/PDIF devices, probably because the default configuration in ALSA maps both analog and digital to device 0. I think even a digital device can't be regarded as an S/PDIF device, so we can use the iecset(alsa-utils) tool to double check to verify if the device is really an S/PDIF(iec958) device. Thanks, Chengyi
[pulseaudio-discuss] Why does the USB headset show the Digital Output (S/PDIF) port?
Hi guys, I have a USB headset that the module is Edifier USB K800. Plug it into the PC's usb port, and then I found "Digital Output (S/PDIF)" audio port as below. Would you please tell me why the Digital Output (S/PDIF) port has been shown, and how to verify if this USB headset really have the output function of Digital Output (S/PDIF), and how to close this audio port. Thanks a lot! - $ pacmd list-cards index: 3 name: driver: owner module: 27 properties: alsa.card = "2" alsa.card_name = "USB PnP Sound Device" alsa.long_card_name = "C-Media Electronics Inc. USB PnP Sound Device at usb-:03:00.3-2, full speed" alsa.driver_name = "snd_usb_audio" device.bus_path = "pci-:03:00.3-usb-0:2:1.0" sysfs.path = "/devices/pci:00/:00:08.1/:03:00.3/usb1/1-2/1-2:1.0/sound/card2" udev.id = "usb-C-Media_Electronics_Inc._USB_PnP_Sound_Device-00" device.bus = "usb" device.vendor.id = "0d8c" device.vendor.name = "C-Media Electronics, Inc." device.product.id = "013a" device.product.name = "USB PnP Sound Device" device.serial = "C-Media_Electronics_Inc._USB_PnP_Sound_Device" device.string = "2" device.description = "USB PnP Sound Device" module-udev-detect.discovered = "1" device.icon_name = "audio-card-usb" profiles: input:analog-mono: Analog Mono Input (priority 7, available: unknown) output:analog-stereo: Analog Stereo Output (priority 6500, available: unknown) output:analog-stereo+input:analog-mono: Analog Stereo Output + Analog Mono Input (priority 6507, available: unknown) output:iec958-stereo: Digital Stereo (IEC958) Output (priority 5500, available: unknown) output:iec958-stereo+input:analog-mono: Digital Stereo (IEC958) Output + Analog Mono Input (priority 5507, available: unknown) output:iec958-ac3-surround-51: Digital Surround 5.1 (IEC958/AC3) Output (priority 300, available: unknown) output:iec958-ac3-surround-51+input:analog-mono: Digital Surround 5.1 (IEC958/AC3) Output + Analog Mono Input (priority 307, available: unknown) off: Off (priority 0, available: unknown) active profile: sinks: alsa_output.usb-C-Media_Electronics_Inc._USB_PnP_Sound_Device-00.iec958-stereo/#4: USB PnP Sound Device Digital Stereo (IEC958) sources: alsa_output.usb-C-Media_Electronics_Inc._USB_PnP_Sound_Device-00.iec958-stereo.monitor/#6: Monitor of USB PnP Sound Device Digital Stereo (IEC958) alsa_input.usb-C-Media_Electronics_Inc._USB_PnP_Sound_Device-00.analog-mono/#7: USB PnP Sound Device Analog Mono ports: analog-input-mic: Microphone (priority 8700, latency offset 0 usec, available: unknown) properties: device.icon_name = "audio-input-microphone" analog-output-speaker: Speakers (priority 1, latency offset 0 usec, available: unknown) properties: device.icon_name = "audio-speakers" iec958-stereo-output: Digital Output (S/PDIF) (priority 0, latency offset 0 usec, available: unknown) properties: - $ amixer -c 2 contents numid=10,iface=CARD,name='Keep Interface' ; type=BOOLEAN,access=rw--,values=1 : values=off numid=3,iface=MIXER,name='Mic Playback Switch' ; type=BOOLEAN,access=rw--,values=1 : values=off numid=4,iface=MIXER,name='Mic Playback Volume' ; type=INTEGER,access=rw---R--,values=1,min=0,max=127,step=0 : values=0 | dBminmax-min=0.00dB,max=23.81dB numid=7,iface=MIXER,name='Mic Capture Switch' ; type=BOOLEAN,access=rw--,values=1 : values=on numid=8,iface=MIXER,name='Mic Capture Volume' ; type=INTEGER,access=rw---R--,values=1,min=0,max=16,step=0 : values=3 | dBminmax-min=0.00dB,max=23.81dB numid=9,iface=MIXER,name='Auto Gain Control' ; type=BOOLEAN,access=rw--,values=1 : values=on numid=5,iface=MIXER,name='Speaker Playback Switch' ; type=BOOLEAN,access=rw--,values=1 : values=on numid=6,iface=MIXER,name='Speaker Playback Volume' ; type=INTEGER,access=rw---R--,values=2,min=0,max=151,step=0 : values=54,54 | dBminmax-min=-28.37dB,max=-0.06dB numid=2,iface=PCM,name='Capture Channel Map' ; type=INTEGER,access=rR--,values=1,min=0,max=36,step=0 : values=0 | container | chmap-fixed=MONO numid=1,iface=PCM,name='Playback Channel Map' ; type=INTEGER,access=rR--,values=2,min=0,max=36,step=0 : values=0,0 |