You are not logged in.
I want to record the audio that I'm hearing in my head phones (a few programs are running simultaneously that give off sound) basically. I'm using ALSA exclusively, no pulseaudio.
What I understood so far from reading what other people wrote:
1) In alsamixer -> capture devices there is only mic and line in, but no way to capture the "mix" that I can actually hear in my head phones.
1a) The absence of a "mix" capture device is a "specialty" of the snd_hda_intel driver.
2) The module snd-aloop together with an appropriate .asoundrc will provide a "Loopback" device in addition to the normal sound card, which has an input and an output and can take an audio stream on one of those ends and forward it to the other. I have installed this and it seems to work.
Now unfortunately I still don't understand how I can actually "capture what I'm hearing" with this setup.
Offline
I tried with pure ALSA too and had some success with the following /home/homer/.asoundrc. It records all ALSA audio output which is routed through the default device into an Ogg Vorbis file with a timestamp.
pcm.mycard {
type hw
card 0
}
ctl.mycard {
type hw
card 0
}
pcm.myconvert {
type plug
slave {
pcm "myrecord"
format S16_LE
}
}
pcm.myrecord {
type file
format "raw"
slave.pcm "mycard"
file "| oggenc -Q -q6 -r -B %b -C %c -R %r -o /home/homer/record-$(date +%%Y-%%m-%%d_%%H%%M%%S).ogg -"
}
pcm.!default{
type asym
playback.pcm "myconvert"
capture.pcm "mycard"
}
It is working here but has some limitations. It really records ALL default output and with this config file I have no way to temporarily disable the recording. There are many ways to configure ALSA to get this working too but I did not succeed. As I later wanted to record only specific applications, I did not find a (working) solution with pure ALSA and I had to use PulseAudio, which was not easy to setup either but it does the job.
Offline
Well that's interesting that you set it up that it actually writes to a file. oO
To be honest I don't like that idea, even though it is awesome in a way..lol.
I was hoping that there was a more "clean" solution, that would allow me to just use
ffmpeg -f alsa .... audio stuff here .... -f x11grab ... video stuff
to grab all audio + the display into a neat video.
It seems that it is surprisingly hard to accomplish this little task of just recording the "audio output mix", isn't it?
I'd REALLY like to avoid pulseaudio on my system
I must admit that I don't really understand how all the stuff written in asoundrc actually works, but wouldn't it be possible to use your setup, but not forward the mix to a file writer but instead to the loop device (which in turn can get captured easily by ffmpeg) ?
The important thing is that this shouldn't disable audio in my head phones! I want to listen and at the same time it should be forwarded to the loopback device for recording, I guess?
Last edited by Jindur (2013-08-07 12:35:44)
Offline
Well, just for "recording the audio output mix" the posted .asoundrc seems simple and is working for me.
Your requirements from your second post are another story though. I had similar requirements later on (recording with an external program, only when needed, only for specifiy apps, etc.) and as I wrote, I just could not get ALSA working this way while PulseAudio was able to do the job. It creates a "monitor" for your sound output which you can use as an input source for e.g. Audacity or any other recording program. Of course this way you can also hear what you record, that's why these setups are called "record what u hear".
Your suggestion with the loopback device sounds interesting but I don't want to mess around with ALSA again because I ran into far too many culs-de-sac. PulseAudio is hard enough to tame and I understand your avoidance, but routing audio is one of the things it was made for. Maybe you may want to take a look at JACK if you really want to avoid PA?
Offline
I haven't looked into this JACK stuff yet (I don't really know much about sound systems) but I have tinkered a bit more with ALSA:
As suggested by Kazuo, I added this to my .asoundrc
pcm.mout {
type plug
slave.pcm mdev
route_policy "duplicate"
}
pcm.mdev {
type multi
slaves.a.pcm "hw:Loopback,0,0"
slaves.a.channels 2
#slaves.b.pcm "hw:0,0"
slaves.b.pcm default
slaves.b.channels 2
bindings.0.slave a
bindings.0.channel 0
bindings.1.slave a
bindings.1.channel 1
bindings.2.slave b
bindings.2.channel 0
bindings.3.slave b
bindings.3.channel 1
}
and now I can output sound to device 'mout' and it is both audible via headphones as usual and recordable via the loop device!
The drawback is that apparently only one app at a time can use 'mout', but I'm willing to try it out a bit more even though it doesn't meet my requirements for forwarding the whole "mix" to the loop device.
Now I wanted to record the sound of a Windows app, so my next problem is, how to make Wine actually use this 'mout' device?
I added a new multi-string value in Wine's registry to HKCU/Software/Wine/Drivers - ALSAOutputDevices, and tried to set it to "mout" or to "plug:mout", but neither worked (recording from loop device while Wine app running would not record any sound).
(It worked when I tried a normal mplayer command instead:
mplayer -ao alsa:device=mout music.mp3
-> it is audible and at the same time gets recorded from the loop device.)
Offline
Use dmix with snd-aloop to have have multiple audio sources mixed into a 'dumpable' one:
https://bbs.archlinux.org/viewtopic.php?id=147852
Last edited by kokoko3k (2013-08-07 14:35:44)
Help me to improve ssh-rdp !
Retroarch User? Try my koko-aio shader !
Offline