0

I am trying to create a virtual sound card that can capture audio on the desktop. For this, I am using the snd-aloop module. After the snd-aloop module has loaded the output of aplay -L is shown below:

null
    Discard all samples (playback) or generate zero samples (capture)
default
    Playback/recording through the PulseAudio sound server
hubcap
sysdefault:CARD=PCH
    HDA Intel PCH, ALC3234 Analog
    Default Audio Device
front:CARD=PCH,DEV=0
    HDA Intel PCH, ALC3234 Analog
    Front speakers
surround21:CARD=PCH,DEV=0
    HDA Intel PCH, ALC3234 Analog
    2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=PCH,DEV=0
    HDA Intel PCH, ALC3234 Analog
    4.0 Surround output to Front and Rear speakers
surround41:CARD=PCH,DEV=0
    HDA Intel PCH, ALC3234 Analog
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=PCH,DEV=0
    HDA Intel PCH, ALC3234 Analog
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=PCH,DEV=0
    HDA Intel PCH, ALC3234 Analog
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=PCH,DEV=0
    HDA Intel PCH, ALC3234 Analog
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
hdmi:CARD=PCH,DEV=0
    HDA Intel PCH, HDMI 0
    HDMI Audio Output
hdmi:CARD=PCH,DEV=1
    HDA Intel PCH, HDMI 1
    HDMI Audio Output
hdmi:CARD=PCH,DEV=2
    HDA Intel PCH, HDMI 2
    HDMI Audio Output
dmix:CARD=PCH,DEV=0
    HDA Intel PCH, ALC3234 Analog
    Direct sample mixing device
dmix:CARD=PCH,DEV=3
    HDA Intel PCH, HDMI 0
    Direct sample mixing device
dmix:CARD=PCH,DEV=7
    HDA Intel PCH, HDMI 1
    Direct sample mixing device
dmix:CARD=PCH,DEV=8
    HDA Intel PCH, HDMI 2
    Direct sample mixing device
dsnoop:CARD=PCH,DEV=0
    HDA Intel PCH, ALC3234 Analog
    Direct sample snooping device
dsnoop:CARD=PCH,DEV=3
    HDA Intel PCH, HDMI 0
    Direct sample snooping device
dsnoop:CARD=PCH,DEV=7
    HDA Intel PCH, HDMI 1
    Direct sample snooping device
dsnoop:CARD=PCH,DEV=8
    HDA Intel PCH, HDMI 2
    Direct sample snooping device
hw:CARD=PCH,DEV=0
    HDA Intel PCH, ALC3234 Analog
    Direct hardware device without any conversions
hw:CARD=PCH,DEV=3
    HDA Intel PCH, HDMI 0
    Direct hardware device without any conversions
hw:CARD=PCH,DEV=7
    HDA Intel PCH, HDMI 1
    Direct hardware device without any conversions
hw:CARD=PCH,DEV=8
    HDA Intel PCH, HDMI 2
    Direct hardware device without any conversions
plughw:CARD=PCH,DEV=0
    HDA Intel PCH, ALC3234 Analog
    Hardware device with all software conversions
plughw:CARD=PCH,DEV=3
    HDA Intel PCH, HDMI 0
    Hardware device with all software conversions
plughw:CARD=PCH,DEV=7
    HDA Intel PCH, HDMI 1
    Hardware device with all software conversions
plughw:CARD=PCH,DEV=8
    HDA Intel PCH, HDMI 2
    Hardware device with all software conversions
sysdefault:CARD=Loopback
    Loopback, Loopback PCM
    Default Audio Device
front:CARD=Loopback,DEV=0
    Loopback, Loopback PCM
    Front speakers
surround21:CARD=Loopback,DEV=0
    Loopback, Loopback PCM
    2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=Loopback,DEV=0
    Loopback, Loopback PCM
    4.0 Surround output to Front and Rear speakers
surround41:CARD=Loopback,DEV=0
    Loopback, Loopback PCM
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=Loopback,DEV=0
    Loopback, Loopback PCM
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=Loopback,DEV=0
    Loopback, Loopback PCM
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=Loopback,DEV=0
    Loopback, Loopback PCM
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
dmix:CARD=Loopback,DEV=0
    Loopback, Loopback PCM
    Direct sample mixing device
dmix:CARD=Loopback,DEV=1
    Loopback, Loopback PCM
    Direct sample mixing device
dsnoop:CARD=Loopback,DEV=0
    Loopback, Loopback PCM
    Direct sample snooping device
dsnoop:CARD=Loopback,DEV=1
    Loopback, Loopback PCM
    Direct sample snooping device
hw:CARD=Loopback,DEV=0
    Loopback, Loopback PCM
    Direct hardware device without any conversions
hw:CARD=Loopback,DEV=1
    Loopback, Loopback PCM
    Direct hardware device without any conversions
plughw:CARD=Loopback,DEV=0
    Loopback, Loopback PCM
    Hardware device with all software conversions
plughw:CARD=Loopback,DEV=1
    Loopback, Loopback PCM
    Hardware device with all software conversions

The contents of the /etc/asound.conf are as follows:

defaults.pcm.!card 1
defaults.ctl.!card 1
defaults.pcm.!device 1
defaults.ctl.!device 1

pcm.!default {
     type plug
     slave.pcm {
         type dmix
         ipc_key 2867
         slave {
             pcm "hw:Loopback,0,0"
             rate 48000
             format S16_LE
             channels 2
             period_size 1024
             buffer_size 8192
         }
     }
 }

pcm.hubcap {
     type plug
     slave.pcm {
         slave {
             pcm "hw:Loopback,1,0"
             rate 48000
             format S16_LE
         }
     }
 }

Now due to this configuration, I think my default card should be 1 i.e the Loopback device. However when I skip the above 2 lines

defaults.pcm.!device 1
defaults.ctl.!device 1

my default sound card is PCH only. So I need to add these two lines as well(don't know why). Since the device is a subpart of the card so the lines below:

defaults.pcm.!device 0
defaults.ctl.!device 0

should not make the difference as it would imply hw:1,0 as default. But it is not as I am able to hear sound from my inbuilt speakers if I execute

aplay -vv test.wav

After setting the device to 1, I get the desired result(at least think so). aplay -vv test.wav doesn't play through the inbuilt speakers. Since the default card is Loopback (virtual). Now using the alsaloop command I want to route the audio. For this is used the below command

alsaloop -C hw:Loopback,0,0 -P hw:PCH,0

And now if I play any audio in my desktop it is routed to the inbuilt speakers.

Now my question is I created a hubcap plug as shown above in /etc/asound.conf But using the alsaloop command for that is not routing my audio.

alsaloop -C hw:Loopback,1,0 -P hw:PCH,0
alsaloop -C hubcap -P hw:PCH,0

Can someone explain to me what went wrong, and what is the alsa configuration necessary to create a Capture device and a Playback device?

How can I use dmix and dsnoop in alsa commands to capture audio. My main target here is to achieve this

Just to give you a gist that I want to send audio over a network in UDP protocol and I am using TRX as a software to do this. The link for TRX is here

New contributor
kamal pandey is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Your Answer

kamal pandey is a new contributor. Be nice, and check out our Code of Conduct.

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

Browse other questions tagged or ask your own question.