3

I am having some trouble wrapping my head around the snd_aloop module.

I am trying to route all my audio through alsa without using pulseaudio. If I start jackd there's not sound from non alsa apps but things like rhythmbox or any other native jack supported software works just fine.

The main reason is that I do mostly audio editing but I listen to videos online as well.

I was reading that I can use the alsa snd_aloop module to setup virtual hw that I can route my non jack away apps audio through to get things to play nicely with jack via the alsa_in and alsa_out mechanism.

i've read quite a few tutorials like this one, this one looked over a lot of the documentation here and here as well.

The part that is most confusing to me is the loopback setup and the way alsa_in and alsa_out works.

For example with the snd_aloop module there's 2 devices with 8 subdevices

my aplay-l looks like this

**** List of PLAYBACK Hardware Devices ****
card 0: Loopback [Loopback], device 0: Loopback PCM [Loopback PCM]
  Subdevices: 8/8
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
  Subdevice #7: subdevice #7
card 0: Loopback [Loopback], device 1: Loopback PCM [Loopback PCM]
  Subdevices: 8/8
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
  Subdevice #7: subdevice #7
card 1: PCH [HDA Intel PCH], device 0: CS4208 Analog [CS4208 Analog]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
card 1: PCH [HDA Intel PCH], device 1: CS4208 Digital [CS4208 Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: NVidia [HDA NVidia], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: NVidia [HDA NVidia], device 7: HDMI 1 [HDMI 1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: NVidia [HDA NVidia], device 8: HDMI 2 [HDMI 2]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

if I try to setup my system like this:

#jack capture and playback
pcm.jack_capture_1 {
    type plug
        slave.pcm "hw:Loopback,0,0"
}

pcm.jack_playback_1 {
    type plug
        slave.pcm "hw:Loopback,0,1"
}

#alsa capture and playback
pcm.alsa_input_1 {
    type plug
        slave.pcm "hw:Loopback,1,0"
}

pcm.alsa_output_1 {
    type plug
        slave.pcm "hw:Loopback,1,1"
}


#playback devices
pcm.jack_audio_1 {
  type asym
  playback.pcm "jack_playback_1"
  capture.pcm "jack_capture_1"
}

then do alsa_out -j "playback" -d jack_audio_1 sound.wav

I still get no output even after making the connections in the jack routing map.

My questions: Looking at my setup I have the loopback jack_capture_1 tied to hw:0,0 loopback jack_playback_1 tied to hw:0,1

that means any sound sent to jack_capture_1 should be echo out of jack_playback_1 is that correct?

also is the alsa_in is the the alsa audio stream that'll go into the jack session while alsa_out is the alsa audio stream that jack outputs after it finishes?

I have been reading everything that I can on the snd_aloop but even their official documentation seems a bit lacking.

Can someone help me sort this out?

  • For testing, use just aplay and arecord to check whether the loopback devices work correctly. – CL. Dec 27 '15 at 13:15
2

A bit late with the answer but maybe someone finds this helpful ;)

/etc/modprobe.d/alsa.conf
alias snd-card-8 snd-aloop
options snd_aloop index=8 id=loop0 enable=1

/etc/asound.conf

#### Linrad ####                                                                                                                                                                                                                              

pcm.loop0_0_0 {                                                                                                                                                                                                                               
  type plug                                                                                                                                                                                                                                   
    slave {                                                                                                                                                                                                                                   
      pcm "hw:loop0,0,0"                                                                                                                                                                                                                      
      format FLOAT_LE                                                                                                                                                                                                                         
      rate 96000                                                                                                                                                                                                                              
    }                                                                                                                                                                                                                                         
}                                                                                                                                                                                                                                             

pcm.linrad_alsa {                                                                                                                                                                                                                             
  type asym                                                                                                                                                                                                                                   
  playback.pcm "loop0_0_0"                                                                                                                                                                                                                    
  capture.pcm "loop0_0_0"                                                                                                                                                                                                                     
  hint {                                                                                                                                                                                                                                      
    show on                                                                                                                                                                                                                                   
    description "Linrad: ALSA"                                                                                                                                                                                                                
  }
}

pcm.loop0_1_0 {
  type plug
    slave {
      pcm "hw:loop0,1,0"
      format FLOAT_LE
      rate 96000
    }
}

pcm.linrad_jack {
  type asym
  playback.pcm "loop0_1_0"
  capture.pcm "loop0_1_0"
  hint {
    show on
    description "Linrad: JACK"
  }
}

#### WSJTX ####

pcm.loop0_0_1 {
  type plug
    slave {
      pcm "hw:loop0,0,1"
      format FLOAT_LE
      rate 96000
    }
}

pcm.wsjtx_alsa {
  type asym
  playback.pcm "loop0_0_1"
  capture.pcm "loop0_0_1"
  hint {
    show on
    description "WSJTX: ALSA"
  }
}

pcm.loop0_1_1 {
  type plug
    slave {
      pcm "hw:loop0,1,1"
      format FLOAT_LE
      rate 96000
    }
}

pcm.wsjtx_jack {
  type asym
  playback.pcm "loop0_1_1"
  capture.pcm "loop0_1_1"
  hint {
    show on
    description "WSJTX: JACK"
  }
}

....

And for the piping to jack something like this (placed in a shell script that runs after jackd starts)

alsa_in -j "WSJTX source" -d wsjtx_jack -q 1 &> /dev/null &
alsa_out -j "WSJTX sink" -d wsjtx_jack -q 1 &> /dev/null &

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.