TODO
pcm.quad {
type multi
slaves.a.pcm "plughw:3,0"
slaves.a.channels 6
slaves.b.pcm "plughw:1,0"
slaves.b.channels 2
bindings.0.slave a
bindings.0.channel 0
bindings.1.slave a
bindings.1.channel 1
bindings.2.slave a
bindings.2.channel 2
bindings.3.slave a
bindings.3.channel 3
bindings.4.slave a
bindings.4.channel 4
bindings.5.slave a
bindings.5.channel 5
bindings.6.slave b
bindings.6.channel 0
bindings.7.slave b
bindings.7.channel 1
}
参考
https://stackoverflow.com/questions/5126169/programmatically-merging-two-pieces-of-audio/5126209#5126209
http://blog.bjornroche.com/2013/05/the-abcs-of-pcm-uncompressed-digital.html
https://bootlin.com/blog/audio-multi-channel-routing-and-mixing-using-alsalib/
https://alsa.opensrc.org/MultipleCards
https://www.alsa-project.org/wiki/Asoundrc
https://www.alsa-project.org/alsa-doc/alsa-lib/pcm_plugins.html
How can I use ALSA dmix and multi plugins together?
// 挺高级的用法
# thx
# http://wiki.ubuntuusers.de/.asoundrc
# http://alsa.opensrc.org/Dmix
# http://forums.linuxmint.com/viewtopic.php?f=196&t=94877
pcm.snd_card {
type hw
card 1
device 0
}
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:Loopback,0,0"
slave {
period_time 0
period_size 1024
buffer_size 4096
channels 2 # must match bindings
}
bindings {
0 0
1 1
}
}
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
]
}
[!default] → multi → dmix → hw [normal]
↳ dmix → hw [loopback]
#ALSA配置#如何在asound.conf中同时使用MMAP模式和Ladspa插件
# duplicate audio to both devices
pcm.!default plug:both
ctl.!default {
type hw
card SB
}
pcm.both {
type route;
slave.pcm {
type multi;
slaves.a.pcm "sblive";
slaves.b.pcm "onboard";
slaves.a.channels 2;
slaves.b.channels 4;
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;
bindings.4.slave b;
bindings.4.channel 2;
bindings.5.slave b;
bindings.5.channel 3;
}
ttable.0.0 1;
ttable.1.1 1;
ttable.0.2 1; # front left
ttable.1.3 1; # front right
ttable.0.4 1; # copy front left to rear left
ttable.1.5 1; # copy front right to rear right
}
ctl.both {
type hw;
card Live;
}
pcm.onboard {
type dmix
ipc_key 1024
slave {
pcm "hw:0,1"
period_time 0
period_size 2048
buffer_size 65536
buffer_time 0
periods 128
rate 48000
channels 4
}
bindings {
0 0
1 1
2 2
3 3
}
}
pcm.sblive {
type dmix
ipc_key 2048
slave {
pcm "hw:1,0"
period_time 0
period_size 2048
buffer_size 65536
buffer_time 0
periods 128
rate 48000
channels 2
}
bindings {
0 0
1 1
}
}
ctl.onboard {
type hw
card "SB"
}
ctl.sblive {
type hw
card "Live"
}
参考http://www.6by9.net/output-to-multiple-audio-devices-with-alsa/