For a personal sound project with a raspberry PI 3 and an USB 7.1 channel sound card, I need to use the sound card as 8 independents mono channels, to play different mono sounds on specifics channel. And sometime 2 or more mono sounds car be played (mixed) in the same time on a given channel. I finally found the way to do that in my .asoundrc
configuration file :
pcm_slave.usbsoundcard {
pcm "hw:1"
rate 44100
channels 8
periods 128
period_time 0
period_size 1024
buffer_time 0
buffer_size 4096
}
pcm.ch1 {
type dmix
slave usbsoundcard
ipc_key 1001
bindings [ 0 ]
}
pcm.ch2 {
type dmix
slave usbsoundcard
ipc_key 1001
bindings [ 1 ]
}
pcm.ch3 {
type dmix
slave usbsoundcard
ipc_key 1001
bindings [ 6 ]
}
pcm.ch4 {
type dmix
slave usbsoundcard
ipc_key 1001
bindings [ 7 ]
}
pcm.ch5 {
type dmix
slave usbsoundcard
ipc_key 1001
bindings [ 2 ]
}
pcm.ch6 {
type dmix
slave usbsoundcard
ipc_key 1001
bindings [ 3 ]
}
pcm.ch7 {
type dmix
slave usbsoundcard
ipc_key 1001
bindings [ 4 ]
}
pcm.ch8 {
type dmix
slave usbsoundcard
ipc_key 1001
bindings [ 5 ]
}
With this config file, I can play what I want on the channel I want, and I can play multiple sound in same time on each independent channel if needed with commands like this:
aplay -D plug:ch3 sound1_mono.wav &
aplay -D plug:ch3 sound2_mono.wav & # sound 2 mixed with sound 1 on channel 3
aplay -D plug:ch7 sound3_mono.wav &
aplay -D plug:ch8 sound4_mono.wav &
etc...
But I want to add another possibility. I want to add a virtual channel named "all", which must route the played sound on ALL 8 mono channels. The final goal is to configure Asterisk pbx system configured as intercom to use this channel : when called, Asterisk will autoanswer, and I want voice routed (mixed) on all 8 channels of the sound card.
I naively tried that :
pcm.all {
type dmix
slave usbsoundcard
ipc_key 1001
bindings [ 0 1 2 3 4 5 6 7 ]
}
But it doesn't work. For testing I also play a mono sound on the 'all' virtual channel. If I do : aplay -D plug:all sound5_mono.wav The sound is correctly played on all channel ch1... ch8 where no other wav file is played. But on channel where a sound is already played, can't hear sound5_mono. wav but I have crackling noices
How can I write my. asoundrc file to have it working ? What I want to do is a kind of audio multiroom : play differents mono file on each channel ch1.... ch8 in differents room, and when I call the raspberry with a SIP phone, voice is played (mixed) in all rooms.
dmix
has no channel limit. How exactly are you trying to useall
?sound.wav
have? One? Eight? Please edit the question to specify what exactly should happen with the channels.