Mar 23

How to record analog audio on Linux

Category: Linux,multimedia   — Published by goeszen on March 23, 2022 at 10:06 pm

alsamixer interface on CLI
The alsamixer main interface, useful to debug and review audio issues on Linux

In case you want to record analog audio on your Linux machine, here are some hints on how to get it working, debug muted audio or unmute channels and how you can actually hear what you are recording.

Monitoring your Line-In Interface

So you've plugged a line-out audio source (like the cinch cables coming from a tape deck or similar, via a cinch-to-headphone plug adapter) into the line-in connector of your sound card but you are not hearing anything? Then this next thing is the the most important step for you:
You need to load a pulse audio module that actually establishes a loop back / monitoring line on your system!

I've found this hint via this post. The thing is that you might think "plug it in and it will automagically just work" - well it doesn't. By default, the line-in input is not routed to the line-out audio output of your system. So execute this command to load the pulse audio module on runtime:

$ pactl load-module module-loopback

Check your line-in / capture device audio level

Use alsamixer to level your capture device and audacity to record
Use alsamixer to level your capture device and audacity to record

Go to the command line and fire up alsamixer.

This command line interface based tool will show you far more channels on your sound card than the standard system dialog. Use the arrow keys to navigate left to right through the channels and use the "M"-key to mute/unmute a selected channel.

Make sure the master volume is all the way up. Also, let some music running on your sytem and check through which sink your system is playing back audio normally and dial that up to 100% (if you're connected to some other amplifier and this external device actually does the volume control) or set it to your preferred level. In my case the channel for output was "front".

The default alsamixer "view" is playback. Switch to the "record" level sliders with key F4 or show all levels with F5. Look for a channel called "line boost" or similar and check if it is not too far up. On my system I had boost to zero.

Then look for a "recording device". In the screenshot above it's called "Aufnahme" and has a level of 22. With my well saturated line-in signal I leveled it to this mark so the audio had proper headroom and wasn't too low. Use audacity's audio levels to dial it in and use your ears to hear where distortion kicks in and then dial back a bit. If you are inputting audio from a tape deck, it might have its own level-meters. if appropriate, you can align recording levels in audacity with displayed playback levels on your tape-deck.

Use Audacity audio editor to record

For me, audacity was the best solution to actually record audio. It has a drop-down selector in the upper left where you can select available input sources. In my case it was the source named "default" but that may be different in your case.

As said in the previous paragraph, play with audio levels for the "recording" line-in connector strip / channel. You can run a recording while you do that so you see the waveform. Then adjust your audio level in alsamixer in a way that audacity gives you a nice fat audio histogram without clipping.

Ah, one last thing, before you record anything in audacity, make sure to adjust your project sample rate and bitrate to your liking. Recording bit depth is usually at 32 bits and that's a lot of headroom. With bit-depths larger than 16 bits, recorded audio levels begin to be less of an issue quality-wise and later normalizing won't reduce "vertical" resolution as much as in olden days with lower bitrates.

Leave a Reply

=