LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

alsaloop

Create audio loopback between ALSA devices.

TLDR

Loop audio from capture to playback device
$ alsaloop -C [hw:0,0] -P [hw:1,0]
copy
Loop with specific sample rate
$ alsaloop -C [hw:0,0] -P [hw:1,0] -r [48000]
copy
Loop with specific format
$ alsaloop -C [hw:0,0] -P [hw:1,0] -f [S16_LE]
copy
Run in daemon mode
$ alsaloop -C [hw:0,0] -P [hw:1,0] -d
copy

SYNOPSIS

alsaloop [-C capture] [-P playback] [-r rate] [-f format] [options]

DESCRIPTION

alsaloop creates a loopback between an ALSA capture device and playback device. It reads audio from one device and writes it to another in real-time, useful for routing audio between different hardware interfaces.The tool handles buffer management, sample rate conversion if needed, and attempts to maintain synchronization between devices.

PARAMETERS

-C, --cdevice device

Capture (input) PCM device. Default is default.
-P, --pdevice device
Playback (output) PCM device. Default is default.
-r, --rate rate
Sample rate in Hz. Default is 48000.
-f, --format format
Sample format such as S16LE or S32LE. Default is S16_LE.
-c, --channels channels
Number of channels. Default is 2.
-d, --daemonize
Daemonize the main process and log messages to syslog.
-s, --seconds seconds
Duration of the loop in seconds.
-t, --tlatency usec
Requested latency in microseconds (1/1000000 sec).
-S, --sync mode
Synchronization mode: none, simple, captshift, playshift, samplerate, or auto.
-n, --resample
Enable rate resampling using alsa-lib.
-T, --thread number
Thread number; -1 creates a unique thread. Jobs with the same number share a thread.

INSTALL

sudo apt install alsa-utils
copy
sudo dnf install alsa-utils
copy
sudo pacman -S alsa-utils
copy
sudo apk add alsa-utils
copy
sudo zypper install alsa-utils
copy
nix profile install nixpkgs#alsa-utils
copy

CAVEATS

Latency depends on buffer sizes and hardware capabilities. Different sample rates between devices require resampling. CPU usage increases with lower latency settings.

HISTORY

alsaloop is part of the alsa-utils package, providing a simple tool for audio routing that complements the more complex ALSA loopback kernel module.

SEE ALSO

arecord(1), aplay(1), alsactl(1)

RESOURCES

Copied to clipboard
Kai