ALSA recording output while keeping it mixed

Everything about X, Gnome, KDE, ... and everything running on it

ALSA recording output while keeping it mixed

Postby aaaaa » 2017-11-14 15:59


I'm trying to record screencasts of my desktop and I would like to record the audio without having to install any additional software such as jackd or pulseaudio, just with ALSA. In order to be able to record the audio from a program (such as a game) in a file while still hearing it, I have followed this guide : ... tputdevice

I've copied the asound.conf configuration and it worked. The problem is that I lost the mixing. I can only have one program playing sound at a time.

If I change my config file with a dmix interface like in this example : I get mixing again.

But I don't know how to get both capture and mixing working. I've tried to put the "multi" device as a slave of the "dmix0" device but it doesn't work. it looks like the dmix0 device won't take anything as a slave but a "hw" type device.

What am I doing wrong ?

Bonus question : With this setup I'm able to record desktop audio output and microphone input in two separate files, which is what I wanted. If I run two programs at the same time though (e.g. a game and a voip software), is there any way to record audio output from those two in two different files, just with ALSA ? Or do I absolutely need jack/pulseaudio for that ?
Posts: 1
Joined: 2017-11-14 15:36

Re: ALSA recording output while keeping it mixed

Postby debiman » 2017-11-14 17:24

i've been hitting that exact same wall years ago;
in the end i decided that mixing is more important and left it at that.
fwiw, i recently managed to record audio by routing "line out" back into "line in" with a cable.
other than that, i've never seen a solution to do that with pure alsa.

if any body knows that solution, please let me/us know.
User avatar
Posts: 3064
Joined: 2013-03-12 07:18

Re: ALSA recording output while keeping it mixed

Postby steve_v » 2017-11-14 22:45

I haven't tried exactly what you're trying to do, but I am using a muti plug to duplicate audio to 2 soundcards...
What happens if you set one of the slaves to dmix, rather than hw as in the capture example?
Adapted from my setup, though at work so can't test:
Code: Select all
pcm.duplicate {
     type plug
     slave.pcm {
         type multi
         slaves {
             a { pcm "dmix:0,0" channels 2 }
             b { pcm "hw:Loopback,0,0" channels 2 }
         bindings [
             { slave a channel 0 }
             { slave a channel 1 }
             { slave b channel 0 }
             { slave b channel 1 }
     ttable [
         [ 1 0 1 0 ]
         [ 0 1 0 1 ]

If hw:Loopback,0,0 doesn't work, try dmix:Loopback,0,0 (not sure if this magic exists for loops) or make a dmix pcm for the purpose, something like:
Code: Select all
pcm.dmixloop {
    type dmix
    ipc_key 2048
    ipc_perm 0666 # allow other users
    slave.pcm "hw:Loopback,0,0"
    slave {
        period_time 0
        period_size 1024
        buffer_size 4096
        channels 2 # must match bindings
    bindings {
        0 0
        1 1
Posts: 695
Joined: 2012-10-06 05:31
Location: New Zealand

Return to Desktop & Multimedia

Who is online

Users browsing this forum: No registered users and 12 guests