Trying to hear audio coming from LINE IN using ALSA on Debian

alsa

I have a netbook with Debian sid, command line only, using it for a server. I am trying to configure it so that the speakers play back what is going in through the netbook's line in audio port. I can not find a simple way to do that.

As far as I know, I am using ALSA for all audio, no jack and no pulse audio.

I use alsamixer to manage audio levels, but I can not find a 'capture' mode in the PLAYBACK settings to turn on.

Card: HDA Intel
Chip: Realtek ID 268

Note: All other audio seems to work. Line in does record (although just can't figure out how to route it live to speakers) and speakers do work themselves. Tested by doing arecord then aplay.

Here is my 'aplay -L' output:

null
    Discard all samples (playback) or generate zero samples (capture)
default:CARD=Intel
    HDA Intel, ID 268 Analog
    Default Audio Device
sysdefault:CARD=Intel
    HDA Intel, ID 268 Analog
    Default Audio Device
front:CARD=Intel,DEV=0
    HDA Intel, ID 268 Analog
    Front speakers
surround40:CARD=Intel,DEV=0
    HDA Intel, ID 268 Analog
    4.0 Surround output to Front and Rear speakers
surround41:CARD=Intel,DEV=0
    HDA Intel, ID 268 Analog
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=Intel,DEV=0
    HDA Intel, ID 268 Analog
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=Intel,DEV=0
    HDA Intel, ID 268 Analog
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=Intel,DEV=0
    HDA Intel, ID 268 Analog
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers

Best Answer

The simplest way is to connect aplay and arecord by a pipe. There's no arecord -L information for PCM sources, but assuming it looks similar to the PCM sinks:

arecord -t au -r 44100 -D front:CARD=Intel,DEV=0 | aplay -t au -D front:CARD=Intel,DEV=0

There's a noticable delay until the output is played, because a pipe isn't intended for real-time audio processing.

The -t au options select the Sun Audio format. This is important, because e.g. the WAV format contains a header with the length of the file, so it can't be used across a pipe.

The default rate for arecord is 8000 samples/s, which is usually not what you want, so the -r option is also important.

The PCM sources and sinks may not support some combinations of rates/format/channels, so you either may have to pick valid combinations for your hardware using more options, or use plughw instead of front. For more modern ALSA installations, plughw entries are automatically generated, and they put a plug plugin in front of the real hardware to do format conversion. If your ALSA doesn't generate those automatically, you have to add them manually to your .asoundrc.

There are other ways to do it, for example with a chain of various ALSA plugins, if you want to have this feature permanently. It's not necessary for the hardware to be able to route audio directly.

Related Question