我在系统 [ubuntu 22.04] 上配置 ALSA 和环回时遇到了很多麻烦。我想结合耳机和环回流,这样当我播放任何音频时,我都可以从音频插孔听到它,也可以听到它被环回,我可以将其与程序一起使用。[分析它的频率模式]
我按照https://github.com/maximtrp/spectrumLED并加载了环回内核 snd-aloop
aplay -l 输出以下内容;
$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: Headphones [bcm2835 Headphones], device 0: bcm2835 Headphones [bcm2835 Headphones]
Subdevices: 8/8
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
Subdevice #2: subdevice #2
Subdevice #3: subdevice #3
Subdevice #4: subdevice #4
Subdevice #5: subdevice #5
Subdevice #6: subdevice #6
Subdevice #7: subdevice #7
card 1: Loopback [Loopback], device 0: Loopback PCM [Loopback PCM]
Subdevices: 8/8
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
Subdevice #2: subdevice #2
Subdevice #3: subdevice #3
Subdevice #4: subdevice #4
Subdevice #5: subdevice #5
Subdevice #6: subdevice #6
Subdevice #7: subdevice #7
card 1: Loopback [Loopback], device 1: Loopback PCM [Loopback PCM]
Subdevices: 8/8
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
Subdevice #2: subdevice #2
Subdevice #3: subdevice #3
Subdevice #4: subdevice #4
Subdevice #5: subdevice #5
Subdevice #6: subdevice #6
Subdevice #7: subdevice #7
我尝试在 /etc 中创建一个 asound.conf,如下所示;
pcm.!default {
type plug
playback.pcm "out"
capture.pcm "loopin"
}
pcm.out {
type plug
slave.pcm {
type multi
slaves {
a { channels 2 pcm "output" }
b { channels 2 pcm "loopout" }
}
bindings {
0 { slave a channel 0 }
1 { slave a channel 1 }
2 { slave b channel 0 }
3 { slave b channel 1 }
}
}
ttable [
[ 1 0 1 0 ] # left -> a.left, b.left
[ 0 1 0 1 ] # right -> a.right, b.right
]
}
pcm.loopout {
type dmix
ipc_key 1025
slave.pcm "hw:1,0,0"
slave {
period_time 0
period_size 1024
buffer_size 8192
channels 2
}
bindings {
0 0
1 1
}
}
pcm.loopin {
type plug
slave.pcm "hw:1,1,0"
}
pcm.output {
type dmix
ipc_key 1024
slave.pcm "hw:0,0"
slave {
period_time 0
period_size 1024
buffer_size 8192
channels 2
}
bindings {
0 0
1 1
}
}
但是,无论我做什么,环回似乎都不能与播放同时工作;所以我可以使用
$播放文件.wav
[或者]
$ mpv 音乐.mp3
它仅提供来自耳机插孔的音频输出,并且不向我尝试用来分析频率的程序发送流......
唯一可行的方法是使用
$ aplay 文件.wav -D hw:1,1
但这不会播放音频插孔的任何输出;
我的 asound.conf 有问题吗?
我尝试搜索网络但没有找到任何有用的方法;
我尝试了基本版本https://stackoverflow.com/questions/7002423/how-to-mix-multiple-pcm-streams-using-alsa
asound.conf
pcm.!default {
type plug
slave.pcm "dmixer"
}
pcm.dmixer {
type dmix
ipc_key 1024
slave {
pcm "hw:1,0"
period_time 0
period_size 1024
buffer_size 4096
rate 44100
}
bindings {
0 0
1 1
}
}
ctl.dmixer {
type hw
card 0
}
但这似乎也不起作用;
我也很困惑为什么会有 2 个回送;
有人能帮我解决这个问题吗?这个 dmix 和 multi 插件到底是怎么工作的?文档看起来太混乱了