How to loopback usb microphone to default output in Alsa?

5,851

You can use alsaloop to loopback an input device to an output device.

To use this together with other applications, a quick summary of ALSA configuration:

ALSA is configured in the per-user ~/.asoundrc or in the system-wide /etc/asound.conf. That's what you see in QasConfig, but to avoid surprises, better look at the files directly. If the existing setup doesn't work for you, you need to create or modify ~/.asoundrc.

Information about the "plugins" you can use to configure ALSA is e.g. here. The hw devices usually just allow one single application to read/write to them. To allow multiple applications to do that, you use dmix or dsnoop. plughw automates that by putting a number of plugins in front of hw.

QasHctl just shows the mixer (or any hardware-related control) settings that are also available with alsamixer or amixer.

So:

1) Make sure Pulseaudio is not running (ps axu). Really sure. Pulseaudio uses ALSA to access the hardware.

Now configure ~/.asoundrc:

2) Put a dmix in front of your output device(s).

3) Put a dsnoop in front of your input device(s).

These two should normally have been made available automatically, check aplay -L or QasConfig. If they are already present, use those.

4) If your default device was set to the pulse plugin, remove it -- that's the Pulseaudio compatability layer.

5) Set default to one of the dmix devices you just created (or plughw to use the automatically created ones).

If you've trouble configuring everything, edit question with output of cat /proc/asound/pcm so I can see your hardware, with the original ~/.asoundrc (if present) and the one you tried to make, and I'll have a look.

Share:
5,851

Related videos on Youtube

user2464424
Author by

user2464424

Updated on September 18, 2022

Comments

  • user2464424
    user2464424 over 1 year

    Given a Debian Stretch + Xfce system with Alsa, i would like to hear my USB microphone in my headphones. I cannot find any option to do so natively with graphical alsa mixers like Volti or QasTools.

    The problem seems to be that in both mixers the USB microphone is detected as a separate audio card and this somehow does not allow them to redirect its signal into the default motherboard card (Intel HDA) to which my headphones are attached. Or at least, they don't seem to present any option to do so, unless i'm missing something. Perhaps QasConfig or QasHctl allow advanced options that allow such?

    I'm also trying to avoid pavucontrol.

    • dirkt
      dirkt almost 7 years
      If you use Pulseaudio, without pavucontrol: pacmd load-module module-loopback .... If you use ALSA only: alsaloop (won't work when Pulseaudio is running).
    • user2464424
      user2464424 almost 7 years
      @dirkt The alsaloop command looks neat. I tried alsaloop -C hw:2,0 -P hw:0,0 -t 50000 -d which does what i want but as it is running i can't hear anymore the sounds coming from the PC itself. For example, VLC complains that the device 'default' is busy and watching youtube videos yields no audio.
    • dirkt
      dirkt almost 7 years
      Use plughw instead of hw (put dmix etc. plugins in front).
    • user2464424
      user2464424 almost 7 years
      @dirkt Ok i tried alsaloop -C plughw:2,0 -P plughw:0,0 -t 50000 and various combinations of hw and plughw but still complains... There are various discussions online but can't figure out anything certain for now.