LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

aplay

Play audio files via ALSA

TLDR

Play a specific file
$ aplay [path/to/file]
copy
Play the first 10 seconds at 2500 Hz
$ aplay -d 10 -r 2500 [path/to/file]
copy
Play a raw file with specific format
$ aplay -c 1 -t raw -r 22050 -f mu_law [path/to/file]
copy
List available audio devices
$ aplay -l
copy

SYNOPSIS

aplay [-d duration] [-r rate] [-c channels] [-t type] [-f format] [file]

DESCRIPTION

aplay is a command-line sound player for ALSA soundcard drivers. It supports various audio formats and can automatically determine sampling rate, bit depth, and other parameters from the file format.

PARAMETERS

-d, --duration seconds

Stop playback after the specified number of seconds
-r, --rate rate
Sampling rate in Hz
-c, --channels count
Number of channels (1 for mono, 2 for stereo)
-t, --file-type type
File type (voc, wav, raw, au)
-f, --format format
Sample format (S16LE, U8, mulaw, etc.)
-l, --list-devices
List all available audio devices
-L, --list-pcms
List all PCM devices
-D, --device name
Select PCM device by name
-q, --quiet
Quiet mode; suppress messages
-v, --verbose
Verbose mode; show PCM structure and setup
-i, --interactive
Allow interactive operation via stdin (pause/resume with space or enter key)

CONFIGURATION

/etc/asound.conf

System-wide ALSA configuration file for device defaults and plugin definitions.
~/.asoundrc
Per-user ALSA configuration overriding system defaults.

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

Requires ALSA drivers to be installed and configured. Raw files require explicit format specification.

HISTORY

Part of ALSA (Advanced Linux Sound Architecture) utilities package, which replaced OSS as the standard Linux sound system.

SEE ALSO

arecord(1), alsamixer(1), amixer(1)

Copied to clipboard
Kai