Need insight into how ALSA loopback should function

Optimize your system for ultimate performance.

Moderators: MattKingUSA, khz

Post Reply
to7m
Established Member
Posts: 4
Joined: Sun Nov 13, 2016 6:52 am

Need insight into how ALSA loopback should function

Post by to7m »

Edit: figured it out for the most part by trial and error.

Hi all,

I'm trying to sort out an ALSA-Jack loopback device (based on Mark Constable's examples: alsa.opensrc.org/Jack_and_Loopback_device_as_Alsa-to-Jack_bridge), and I'm running into a few problems so I'm trying to troubleshoot it.

In this scenario I have Jack running and I launch the ALSA-Jack bridge with this (which I then route to my headphones):

Code: Select all

alsa_in -j bridge -dploop
If I use Audacity (set to ALSA) to play a file through "loophw01", then it works (with lots of xruns which I'll tackle at some point). If I choose "Loopback: PCM (hw:0,0)" or "Loopback: PCM (hw:0,1)" instead, nothing comes out. My understanding is that one of the latter two options should be the port exposed to all programs, serving as some sort of alias for "loophw01", and should therefore give the same results when outputted to.

Code: Select all

/etc/modprobe.d/sound.conf consists of the following and seems load the loopback driver without any problem:
alias snd-card-0 snd-aloop
options snd-aloop index=0 pcm_substreams=2


/etc/asound.conf consists of this:

Code: Select all

pcm.loophw01 {
  type hw
  card Loopback
  device 0
  subdevice 1
  format S32_LE
  rate 96000
}
pcm.ploop {
  type hw
  card Loopback
  device 1
  subdevice 1
  format S32_LE
  rate 96000
}
Any insight into what I'm missing?

So, here's my current setup:

Bridge script:

nohup alsa_in -j alsa-bridge-out -dbridge_out -q 0 -p 4096 -n 2 &
nohup alsa_out -j alsa-bridge-in -dbridge_in -q 0 &

/etc/asound.conf:

# this is from adapted from http://alsa.opensrc.org/Jack_and_Loopba ... ack_bridge and I don't understand it

# speexrate seems to sound a bit better than samplerate, and might pop less, I don't know
defaults.pcm.rate_converter "speexrate"

# putting period/buffer size here will cause some youtube videos to be silent
pcm.amix {
type dmix
ipc_key 219345
slave {
pcm "hw:Loopback,0,0"
format S32_LE
rate 96000
}
}
# don't use braces for the slave device otherwise it won't work
pcm.asnoop {
type dsnoop
ipc_key 219346
slave.pcm "hw:Loopback,0,1"
}

# period/buffer size might not even do anything here except add delay, I can't tell... make sure youtube videos aren't too desyncronised
pcm.bridge_out {
type dsnoop
ipc_key 219348
slave {
pcm "hw:Loopback,1,0"
format S32_LE
rate 96000
period_size 4096
buffer_size 8192
}
}
# the braces thing probably applies here too
pcm.bridge_in {
type plug
slave.pcm "hw:Loopback,1,1"
}

pcm.aduplex {
type asym
playback.pcm "amix"
capture.pcm "asnoop"
}
# if changing this file, keep an eye on whether audacity still has a "default" option that works
pcm.!default {
type plug
slave.pcm "aduplex"
}
# apparently some programs look for card0 instead of default
pcm.card0 {
type plug
slave.pcm "aduplex"
}
# apparently some programs look for a corresponding ctl device so we might as well let them find one
ctl.aduplex {
type hw
card 0
}
ctl.!default {
type hw
card 0
}
ctl.card0 {
type hw
card 0
}

Post Reply