ALSA Configuration of Loopback Device


# NoSuck.org
# 2017年02月13日、05時13分
# This file demonstrates ALSA configuration for a loopback device that simultaneously saves both input and output. Thanks go to debianuser from #alsa on the Freenode network for providing guidance.

■ aplay -L | grep ‘^sysdefault’
sysdefault:CARD=PCH

■ aplay -l | grep PCH
card 0: PCH [HDA Intel PCH], device 0: ALC898 Analog [ALC898 Analog]
card 0: PCH [HDA Intel PCH], device 1: ALC898 Digital [ALC898 Digital]
card 0: PCH [HDA Intel PCH], device 3: HDMI 0 [HDMI 0]

■ cat /etc/modules-load.d/snd-aloop.conf
snd-aloop

■ cat /etc/modprobe.d/alsa.conf
options snd_hda_intel index=0
options snd_aloop index=1

■ cat ~/.asoundrc
defaults.pcm.dmix.!rate 48000
defaults.pcm.dmix.!format S16_LE
pcm.multi {
type multi
slaves.a.pcm “dmix:PCH”
slaves.a.channels 2
slaves.b.pcm “dmix:Loopback”
slaves.b.channels 2
bindings.0 { slave a; channel 0; }
bindings.1 { slave a; channel 1; }
bindings.2 { slave b; channel 0; }
bindings.3 { slave b; channel 1; }
}
pcm.both {
type route
slave.pcm “multi”
ttable.0.0 1
ttable.1.1 1
ttable.0.2 1
ttable.1.3 1
}
pcm.!default {
type asym
playback.pcm “plug:both”
capture.pcm “plug:dsnoop:PCH”
}

# Record.
■ ffmpeg -y -f alsa -ac 1 -i sysdefault -f alsa -i plughw:Loopback,1 -filter_complex [0:a][1:a]amerge=inputs=2 output.flac

# Record input only.
■ ffmpeg -y -f alsa -ac 1 -i sysdefault:CARD=PCH output.flac

# Official example.
■ cat /usr/share/alsa/cards/Loopback.conf

Comment...