![脉冲音频的采样率自行改变(坚决)](https://linux22.com/image/225503/%E8%84%89%E5%86%B2%E9%9F%B3%E9%A2%91%E7%9A%84%E9%87%87%E6%A0%B7%E7%8E%87%E8%87%AA%E8%A1%8C%E6%94%B9%E5%8F%98%EF%BC%88%E5%9D%9A%E5%86%B3%EF%BC%89.png)
我在使用pulseaudio在Linux计算机上配置外部声卡(fostex usb audio hp-A4 Stereo numerique (IEC958))的采样率时遇到问题:
> uname -a
Linux music 6.5.0-kali2-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.5.3-1kali2 (2023-10-03) x86_64 GNU/Linux
> pulseaudio --version
fostex usb audio hp-A4 stereo numerique (IEC958)
文件 ~/.config/pulse/daemon.conf 已修改为具有 192000 (Hz) 的高采样率:
> cat ~/.config/pulse/daemon.conf
...
default-sample-format = float32le ; s16le
default-sample-rate = 192000
alternate-sample-rate = 192000
...
更新之前一切正常,但现在我可以看到外置声卡上的 LED 指示 192000 持续 10 秒,然后变为 48000。
我可以了解一些详细信息(这些命令同时使用 VLC 播放一些音乐的结果):
> pacmd list-sinks
Aucun démon PulseAudio en cours d’exécution, ou ne s’exécutant pas dans une session de type démon.
> pulseaudio -D
> pacmd list-sinks
1 sink(s) available.
* index: 0
name: <auto_null>
driver: <module-null-sink.c>
flags: DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
state: IDLE
suspend cause: (none)
priority: 1000
volume: front-left: 65536 / 100% / 0.00 dB, front-right: 65536 / 100% / 0.00 dB
balance 0.00
base volume: 65536 / 100% / 0.00 dB
volume steps: 65537
muted: no
current latency: 1773.77 ms
max request: 3000 KiB
max rewind: 3000 KiB
monitor source: 1
sample spec: float32le 2ch 192000Hz
channel map: front-left,front-right
Stéréo
used by: 0
linked by: 0
configured latency: 2000.00 ms; range is 0.50 .. 2000.00 ms
module: 14
properties:
device.description = "Sortie factice"
device.class = "abstract"
device.icon_name = "audio-card"
再次详细说明:
> pactl list sinks
Destination #52
État : RUNNING
Nom : alsa_output.usb-FOSTEX_FOSTEX_USB_AUDIO_HP-A4_00001-00.iec958-stereo
Description : FOSTEX USB AUDIO HP-A4 Stéréo numérique (IEC958)
Pilote : PipeWire
Spécification de l’échantillon : s32le 2ch 48000Hz
Plan des canaux : front-left,front-right
Module du propriétaire : 4294967295
Sourdine : non
Volume : front-left: 65536 / 100% / 0,00 dB, front-right: 65536 / 100% / 0,00 dB
balance 0,00
Volume de base : 65536 / 100% / 0,00 dB
Source du moniteur : alsa_output.usb-FOSTEX_FOSTEX_USB_AUDIO_HP-A4_00001-00.iec958-stereo.monitor
Latence : 0 usec, configuré 0 usec
Marqueurs : HARDWARE DECIBEL_VOLUME LATENCY SET_FORMATS
Propriétés :
alsa.card = "2"
alsa.card_name = "FOSTEX USB AUDIO HP-A4"
alsa.class = "generic"
alsa.device = "0"
alsa.driver_name = "snd_usb_audio"
alsa.id = "USB Audio"
alsa.long_card_name = "FOSTEX FOSTEX USB AUDIO HP-A4 at usb-0000:00:10.0-1, high speed"
alsa.name = "USB Audio"
alsa.resolution_bits = "32"
alsa.subclass = "generic-mix"
alsa.subdevice = "0"
alsa.subdevice_name = "subdevice #0"
api.alsa.card.longname = "FOSTEX FOSTEX USB AUDIO HP-A4 at usb-0000:00:10.0-1, high speed"
api.alsa.card.name = "FOSTEX USB AUDIO HP-A4"
api.alsa.path = "iec958:2"
api.alsa.pcm.card = "2"
api.alsa.pcm.stream = "playback"
audio.channels = "2"
audio.position = "FL,FR"
card.profile.device = "2"
device.api = "alsa"
device.class = "sound"
device.id = "45"
device.profile.description = "Stéréo numérique (IEC958)"
device.profile.name = "iec958-stereo"
device.routes = "1"
factory.name = "api.alsa.pcm.sink"
media.class = "Audio/Sink"
device.description = "FOSTEX USB AUDIO HP-A4"
node.name = "alsa_output.usb-FOSTEX_FOSTEX_USB_AUDIO_HP-A4_00001-00.iec958-stereo"
node.nick = "FOSTEX USB AUDIO HP-A4"
node.pause-on-idle = "false"
object.path = "alsa:pcm:2:iec958:2:playback"
priority.driver = "1008"
priority.session = "1008"
factory.id = "18"
clock.quantum-limit = "8192"
client.id = "35"
node.driver = "true"
factory.mode = "merge"
audio.adapt.follower = ""
library.name = "audioconvert/libspa-audioconvert"
object.id = "52"
object.serial = "52"
node.max-latency = "16384/48000"
api.alsa.period-size = "512"
api.alsa.period-num = "64"
api.alsa.headroom = "512"
api.acp.auto-port = "false"
api.acp.auto-profile = "false"
api.alsa.card = "2"
api.alsa.use-acp = "true"
api.dbus.ReserveDevice1 = "Audio2"
device.bus = "usb"
device.bus-id = "usb-FOSTEX_FOSTEX_USB_AUDIO_HP-A4_00001-00"
device.bus_path = "pci-0000:00:10.0-usb-0:1:1.0"
device.enum.api = "udev"
device.icon_name = "audio-card-analog-usb"
device.name = "alsa_card.usb-FOSTEX_FOSTEX_USB_AUDIO_HP-A4_00001-00"
device.nick = "FOSTEX USB AUDIO HP-A4"
device.plugged.usec = "31679646"
device.product.id = "0x0011"
device.product.name = "FOSTEX USB AUDIO HP-A4"
device.serial = "FOSTEX_FOSTEX_USB_AUDIO_HP-A4_00001"
device.subsystem = "sound"
sysfs.path = "/devices/pci0000:00/0000:00:10.0/usb2/2-1/2-1:1.0/sound/card2"
device.vendor.id = "0x1019"
device.vendor.name = "Elitegroup Computer Systems (ECS)"
device.string = "2"
Ports :
iec958-stereo-output: Sortie numérique (S/PDIF) (type: SPDIF, priority: 0, availability unknown)
Port actif : iec958-stereo-output
Formats :
pcm
mpeg-iec61937, format.rate = "{ \"min\": 44100, \"max\": 352800 }"
答案1
我必须更改 pipelinewire 配置文件中的采样率才能使其工作:
首先我必须安装 pipeline-audio (关联)
> sudo apt-get install pipewire-audio
然后我必须创建一个新目录并复制 pipelinewire 的配置文件(关联):
> mkdir ~/.config/pipewire
> cp /usr/share/pipewire/pipewire.conf ~/.config/pipewire/pipewire.conf
然后编辑新的 pipeline.conf (关联):
> nano ~/.config/pipewire/pipewire.conf
...
context.properties = {
...
default.clock.rate = 192000
...
最后一件事,当操作系统启动时,不会读取配置文件,而是在播放某些声音时读取配置文件。