Alsa: get audio from specific Input to specific Output stream for monitoring
Ok, let's look at the codec. The codec description is a graph representation of the analog parts of the codec chip. Go through the description node by node, and make a picture as you do that (connection
describes the input nodes), you are going to need it.
Your codec has actually 3 D/A converters, for Line Out, Speaker and Headphone (nodes 0x02, 0x03 and 0x04). However, ALSA in the default configuration can only drive one of these (for whatever reason). Each of the D/A Audio Output
s is then fed to a mixer (nodes 0x0c, 0x0d and 0x0e). The other input of each of these mixers is a feedback mixer (node 0x0b). The feedback mixer in turn gets signals from the most of the pins, including the inputs, and it has ALSA mixer controls associated with it (XXX Mic Playback Volume
, XXX Mic Playback Switch
).
Note that there's no "line in" and simple "mic" inputs, so I assume your "line in" is one of the Mic's, and your "mic" is the other Mic.
So: Try turning on Front Mic Playback Switch
and Rear Mic Playback Switch
in alsamixer
, set volumes for Front Mic Playback Volume
and Rear Mic Playback Volume
, and this should allow you to monitor both inputs when playing back to either Line-Out or the Headphones. The last part seems to be important, because if I interpret the values correctly, ALSA has not enabled one of the three 2-input mixers. According to your amixer
output, you seem to already have tried that, but increase the volume to make sure you are not missing it.
If that doesn't work, make another pastebin copy of /proc/asound/card*/codec\#*
with these settings in effect and playback active, so we can debug what goes wrong.
kiraito
Updated on September 18, 2022Comments
-
kiraito over 1 year
I'm currently trying to get Mic-in and Line-in monitored on Headphones port and Line-Out, respectively.
I tried with aplay / arecord even with alsamixer configuration; it doesn’t work.
How can I make this work?
Here is what
aplay -l and arecord -l
gives me:aplay -l **** List of PLAYBACK Hardware Devices **** card 0: PCH [HDA Intel PCH], device 0: ALC662 rev1 Analog [ALC662 rev1 Analog] Subdevices: 1/1 Subdevice #0: subdevice #0 card 0: PCH [HDA Intel PCH], device 1: ALC662 rev1 Digital [ALC662 rev1 Digital] Subdevices: 1/1 Subdevice #0: subdevice #0 arecord -l **** List of CAPTURE Hardware Devices **** card 0: PCH [HDA Intel PCH], device 0: ALC662 rev1 Analog [ALC662 rev1 Analog] Subdevices: 1/1 Subdevice #0: subdevice #0 card 0: PCH [HDA Intel PCH], device 2: ALC662 rev1 Alt Analog [ALC662 rev1 Alt Analog] Subdevices: 1/1 Subdevice #0: subdevice #0
"line out" is not listed in aplay -l even though I have it in alsamixer
More details, output of :
cat /proc/asound/card*/codec#* :
https://pastebin.com/embed_js/X0Yir5mr
amixer :
-
dirkt over 6 years
alsaloop -C hw:0,0 -P hw:1,0
(with your device ids, of course)? Are you sure you are not running Pulseaudio? -
kiraito over 6 yearsI added the list of devices in the question, and yes I already removed pulseaudio.
-
dirkt over 6 yearsTo clarify: You have two A/D converters (inputs) and a single D/A converter (output), so you can use either line out or headphones, unless you do mixer magic.
alsamixer
lists the internal codec mixers. So you can either (1) use an external application likealsaloop
(which will loop one A/D to an D/A, or (2) try internal mixer magic. For the latter, put output ofcat /proc/asound/card*/codec\#*
andamixer -c0 contents
into a pastebin or similar, and edit question with link. -
kiraito over 6 yearsAs you suggested, I added the commands output in the initial question
-
-
kiraito over 6 yearsThanks for the details, when I increase volume of Front and Rear Mic in alsamixer, I have the playback. the problem is that I get mixed signals : ( Rear Mic + Front Mic ) => Headphone , and the same for Line out ( Rear Mic + Front Mic ) => Line out Is it possible to get distinct signal for each input/output : (1) Rear Mic => headphone (2) Front Mic => Line out I'm also working on solution using Jack detection (call a script to restore alsamixer configuration) to enable one of configuration, as monitoring is being done separately ...
-
dirkt over 6 yearsYour codec has only one feedback mixer, so you can't make two distinct internal feedback loops. You could make one internal feedback loop, say Rear Mic -> Headphone, and then record the Front Mic audio, and play it back to Line Out with
alsaloop
. That means you can't play back anything else to the Headphone. Also, ALSA doesn't support this, you'd have to manipulate the codec directly withhda-verb
fromalsa-tools
, and everytime ALSA access the codec, it will overwrite your settings. -
kiraito over 6 yearsthank you a lot, now I'm sure I can't do what I planned first. So I will try the alternative solution, jack detection + alsa restore configuration