Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

ALSA recording output while keeping it mixed

Graphical Environments, Managers, Multimedia & Desktop questions.
Post Reply
Message
Author
aaaaa
Posts: 1
Joined: 2017-11-14 15:36

ALSA recording output while keeping it mixed

#1 Post by aaaaa »

Hello,

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 : https://trac.ffmpeg.org/wiki/Capture/AL ... 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 : https://alsa.opensrc.org/AlsaSharing 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 ?

User avatar
debiman
Posts: 3063
Joined: 2013-03-12 07:18

Re: ALSA recording output while keeping it mixed

#2 Post by debiman »

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.

steve_v
df -h | grep > 20TiB
df -h | grep > 20TiB
Posts: 1400
Joined: 2012-10-06 05:31
Location: /dev/chair
Has thanked: 79 times
Been thanked: 175 times

Re: ALSA recording output while keeping it mixed

#3 Post by steve_v »

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
    }
}
Once is happenstance. Twice is coincidence. Three times is enemy action. Four times is Official GNOME Policy.

Post Reply