Alsa: get audio from specific Input to specific Output stream for monitoring

8,682

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 Outputs 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.

Share:
8,682
kiraito
Author by

kiraito

Updated on September 18, 2022

Comments

  • kiraito
    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 :

    https://pastebin.com/embed_js/r2B8X21V

    • dirkt
      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
      kiraito over 6 years
      I added the list of devices in the question, and yes I already removed pulseaudio.
    • dirkt
      dirkt over 6 years
      To 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 like alsaloop (which will loop one A/D to an D/A, or (2) try internal mixer magic. For the latter, put output of cat /proc/asound/card*/codec\#* and amixer -c0 contents into a pastebin or similar, and edit question with link.
    • kiraito
      kiraito over 6 years
      As you suggested, I added the commands output in the initial question
  • kiraito
    kiraito over 6 years
    Thanks 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
    dirkt over 6 years
    Your 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 with hda-verb from alsa-tools, and everytime ALSA access the codec, it will overwrite your settings.
  • kiraito
    kiraito over 6 years
    thank 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