我正在使用snd-aloop来录制当前播放的声音。 我能够播放声音,听到它并录制它。 但我失去了软件混音功能:我不能再一次播放多个声音了。
这是我的工作配置,包括声音播放和录音(无混音):
pcm.multi {
type route;
slave.pcm {
type multi;
slaves.a.pcm "output";
slaves.b.pcm "loopin";
slaves.a.channels 2;
slaves.b.channels 2;
bindings.0.slave a;
bindings.0.channel 0;
bindings.1.slave a;
bindings.1.channel 1;
bindings.2.slave b;
bindings.2.channel 0;
bindings.3.slave b;
bindings.3.channel 1;
}
ttable.0.0 1;
ttable.1.1 1;
ttable.0.2 1;
ttable.1.3 1;
}
pcm.!default {
type plug
hint.description "default with sound loop"
slave.pcm "multi"
}
pcm.output {
type hw
card 0
}
pcm.loopin {
type plug
slave.pcm "hw:1,0,0"
}
pcm.loopout {
type plug
slave.pcm "hw:1,1,0"
}
我尝试了不同的配置https://unix.stackexchange.com/questions/194547/how-can-i-use-alsa-dmix-and-multi-plugins-together
我已经使用此配置进行了测试:
pcm.snd_card { # my usual sound card
type hw
card 0
}
ctl.!default { # default control; alsamixer and such will use this
type hw
card 0
}
# software mixer for sound card
pcm.dmixer {
type dmix
ipc_key 1024
ipc_perm 0666 # allow other users
slave.pcm "snd_card"
slave {
period_time 0
period_size 1024
buffer_size 4096
channels 2 # must match bindings
}
bindings {
0 0
1 1
}
}
# software mixer for loopback device
pcm.dmixerloop {
type dmix
ipc_key 2048
ipc_perm 0666 # allow other users
slave.pcm "hw:1,0,0"
slave {
period_time 0
period_size 1024
buffer_size 4096
channels 2 # must match bindings
}
bindings {
0 0
1 1
}
}
pcm.!default {
type plug
hint.description "default with sound loop"
slave.pcm "out"
}
# Multi, splitting onto usual card and loopback
pcm.out {
type plug
slave.pcm {
type multi
slaves {
a { channels 2 pcm "dmixer" }
b { channels 2 pcm "dmixerloop" }
}
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
]
}
以下是使用不同pcms的命令的结果:
aplay -D default /tmp/test.wav
ALSA lib pcm_dmix.c:1109:(snd_pcm_dmix_open) unable to open slave
aplay: main:788: erreur à l'ouverture audio: Argument invalide
> :( $ aplay -D dmixer /tmp/test.wav
ALSA lib pcm_dmix.c:1109:(snd_pcm_dmix_open) unable to open slave
aplay: main:788: erreur à l'ouverture audio: Argument invalide
> :( $ aplay -D snd_card /tmp/test.wav
Lecture WAVE '/tmp/test.wav' : Signed 16 bit Little Endian, Fréquence 48000 Hz, Stéréo
从这些测试中,我不明白几点:
aplay -D snd_card /tmp/test.wav
),我听到了混合
的声音。软件混合在哪里完成?当我玩的时候
“snd_card”dmix插件未使用如何进行软件混合和环回?