Alsa Loopback Devices for Fun, but not yet profit...

So you want to be able to capture the output of N Alsa "devices" (think N separate programs). It seems like the correct solution to this should be an Alsa loopback device... so, here's how to create them.

  • Add snd-aloop to your /etc/modules
  • Add a file named /etc/modprobe.d/alsa-aloop.conf (content below)
  • Create a .asoundrc that makes it easy to reference the loopbacks...

The aloop conf file looks much like a dummy conf file:

options snd-aloop index=1,2,3,4,5,6,7,8 enable=1,1,1,1,1,1,1,1 pcm_substreams=4,4,4,4,4,4,4,4 id=Loopback0,Loopback1,Loopback2,Loopback3,Loopback4,Loopback5,Loopback6,Loopback7

Okay, now your .asoundrc looks something like this (See how to control the default alsa device for an explanation of the default stanza):

pcm.spk0 {
  type dmix
  ipc_key 328210
  slave.pcm "hw:Loopback0,0,0"
}
pcm.monitor0 {
  type dsnoop
  ipc_key 686590
  slave.pcm "hw:Loopback0,1,0"
}
pcm.!default {
 @func getenv
 vars [ DISPLAY_ALSA_DEVICE ]
 default spk0
}

Repeating the pcm.spk and pcm.monitor stanzas for each of Loopback0 through Loopback7.

That's all working quite nicely, I get all of the loopback devices, and the audio does show up when I ask gstreamer to read monitor0 , but it's garbled somehow. So, a nice little bit of fun, but nothing useful yet.

Comments

Comments are closed.

Pingbacks

Pingbacks are closed.