Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Multimedia
  • Search

Recording desktop sounds with alsa loopback

Help with creation, editing, or playback of sounds, images, or video. Amarok, audacious, mplayer, grip, cdparanoia and anything else that makes a sound or plays a video.
Post Reply
Advanced search
1 post • Page 1 of 1
Author
Message
ecko
Tux's lil' helper
Tux's lil' helper
Posts: 120
Joined: Sun Jul 04, 2010 7:34 pm

Recording desktop sounds with alsa loopback

  • Quote

Post by ecko » Sat Jun 26, 2021 10:06 pm

I am playing with the loopback. My objective is to send the sounds going through the headphone to a loopback where I can capture them with media-video/simplescreenrecorder. I use plain ALSA (no pulseaudio and no jack). simplescreenrecorder has a nice preview feature that shows the audio levels in the selected channels, this is what I use.

First create the loopback:

Code: Select all

modprobe snd-aloop

lsmod|grep aloop
snd_aloop              36864  0
snd_pcm               135168  5 snd_hda_codec_hdmi,snd_hda_intel,snd_hda_codec,snd_aloop,snd_hda_core
snd_timer              49152  2 snd_aloop,snd_pcm
snd                   110592  13 snd_hda_codec_generic,snd_hda_codec_hdmi,snd_hwdep,snd_hda_intel,snd_hda_codec,snd_hda_codec_realtek,snd_timer,snd_aloop,snd_pcm
This creates a loopback sound card:

Code: Select all

aplay -l

[…]
card 2: Loopback [Loopback], device 0: Loopback PCM [Loopback PCM]
  Subdevices: 8/8
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
  Subdevice #7: subdevice #7
card 2: Loopback [Loopback], device 1: Loopback PCM [Loopback PCM]
  Subdevices: 8/8
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
  Subdevice #7: subdevice #7
At this point, simplescreenrecorder will show three loopback interfaces:
  • [sysdefault:2] Loopback (shared)
  • [hw:2,0] Loopback: Loopback PCM
  • [hw:2,1] Loopback: Loopback PCM
What works (iun the sense of: something happens, even if not what I wanted):

If I tell speaker-test or mpd to play into hw:2,0 then simplescreenrecorder can capture it in the loopback device

Code: Select all

cat /etc/mpd.conf

audio_output {
        type            "alsa"
        name            "My ALSA Device"
        device          "hw:2,0"
}

/etc/init.d/mpd restart
mpc play

Code: Select all

speaker-test -D hw:2,0
then simplescreenrecorder is able to capture when selecting the sound in "[hw:2,1] Loopback: Loopback PCM" (I confirm, mpd plays to 2,0 and simplescreenrecorder sees it in 2,1).

If I loop device hw:0,0 to hw:0,0, the microphone input is copied to the headphones (in alsamixer, I also have to make sure that card0 has "Input source" set to the "Front Mic" and not Rear Mic or Line).

Code: Select all

alsaloop -C hw:0,0 -P hw:0,0
I can hear myself, but this is not what I intended here.

Code: Select all

alsaloop -C hw:0,0 -P hw:2,0
The microphone goes into the loopback and simplescreenrecorder can capture it (this is not very useful, simplescreenrecorder could already capture the microphone directly by selecting hw:0,0)

What does not work:

Playing into the loopback using aplay in all possible loopback devices and subdevices.

Code: Select all

for i in 0 1 ; do for j in `seq 0 9` ; do aplay -c 2 -D hw:2,${i},${j}  /usr/share/sounds/alsa/Front_Left.wav  ; done ; done
It does not complain (at least for subdevices 1-7), takes 1-2 second and seems to play it somewhere, but simplescreenrecorder does not see the input in any the three hw:2,x (loopback) sources.

In alsamixer, a loopback capture control exists and is set to 100%.

I tried changing ~/.asoundrc like in the sources below, but this is arcane to me and I thought it could be done with command-line.

What I read is below.

https://lichtmetzger.de/en/2014/11/29/s ... o-no-jack/
https://sysplay.in/blog/linux/2019/06/p ... k-devices/
https://bbs.archlinux.org/viewtopic.php?id=147852
(and people who cite this work:)
https://noisybox.net/blog/2016/01/alsa_ ... ice_output
https://dt.iki.fi/record-system-output-alsa

So I'm still looking for a solution to push the headphones playback into a loopback.
Top
Post Reply
1 post • Page 1 of 1

Return to “Multimedia”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic