LinuxCommandLibrary

alsaloop

Routes audio between ALSA soundcard devices

SYNOPSIS

alsaloop [OPTION]...

PARAMETERS

-h, --help
    Show help message and exit

-V, --version
    Print version information and exit

-D, --device=NAME
    Specify default PCM device name (default: hw:0)

-C, --capture=NAME
    Capture PCM device name

-P, --playback=NAME
    Playback PCM device name

-l, --loop=N
    Number of loopbacks (default: 1)

-r, --rate=RATE
    Sampling rate in Hz (default: 48000)

-f, --format=FORMAT
    Sample format, e.g., S16_LE (default: S16_LE)

-p, --period=NS
    Period size in microseconds

-b, --buffer=NS
    Buffer size in microseconds

-q, --queue=NS
    Queue size in samples (default: unlimited)

-m, --mmap
    Enable mmap mode

-M, --nommap
    Disable mmap mode

-x, --xrun
    Allow xrun recovery

-X, --noxrun
    Disable xrun recovery

-v, --verbose
    Enable verbose output

-d, --detach
    Daemonize (run in background)

DESCRIPTION

alsaloop is a utility from the ALSA (Advanced Linux Sound Architecture) utils package designed to create audio loopback connections between PCM devices entirely in user space. It reads audio data from a capture device (input) and writes it to a playback device (output), enabling audio routing without requiring the kernel's snd-aloop module.

This makes it ideal for scenarios where kernel modules can't be loaded, such as in containers or restricted environments. It supports multiple simultaneous loopbacks, customizable sample rates, formats, buffer sizes, and timing parameters for low-latency performance. Unlike full audio servers like JACK or PulseAudio, alsaloop is lightweight and focused solely on PCM-level looping.

Common use cases include testing audio hardware chains, routing output from one application to the input of another (e.g., for recording playback), or creating virtual audio cables. It handles resampling if needed and supports features like mmap for efficiency, timestamping for synchronization, and xrun recovery. Run it in foreground or detached mode with verbose logging for monitoring.

Performance depends on buffer/period tuning; smaller values reduce latency but increase CPU usage and risk underruns. It's particularly useful on systems without real-time kernels.

CAVEATS

Higher latency than kernel snd-aloop; requires proper buffer tuning to avoid xruns; needs read/write access to sound devices; not suitable for high-channel-count or ultra-low-latency pro audio.

EXAMPLE USAGE

alsaloop -C hw:0,0 -P plug:dmix loops capture from card 0 to system playback.
alsaloop -C default -P hw:1,0 -r 44100 -d detaches a 44.1kHz loop.

PERMISSIONS

Add user to audio group or run as root: sudo usermod -aG audio $USER

HISTORY

Developed as a user-space alternative to the ALSA kernel loopback module snd-aloop, first appearing in ALSA utils around 2010-2012 to enable loopback without kernel recompilation or module loading.

SEE ALSO

aplay(1), arecord(1), alsamixer(1), alsa-info(1), snd-aloop(4)

Copied to clipboard