aplay
Play audio files from command line
TLDR
Play a specific file (sampling rate, bit depth, etc. will be automatically determined for the file format)
Play the first 10 seconds of a specific file at 2500 Hz
Play the raw file as a 22050 Hz, mono, 8-bit, Mu-Law .au file
SYNOPSIS
aplay [options] [file ...]
PARAMETERS
-h, --help
Show help message and exit.
-l, --list-devices
List available sound devices.
-L, --list-pcms
List available PCM devices.
-D, --device hw:X,Y
Select sound card device (X=card number, Y=device number).
-q, --quiet
Suppress output messages.
-t, --file-type RAW|WAV|...
Specify the file type. If not specified, it is determined from the file extension.
-c, --channels CHANNELS
Set the number of channels.
-f, --format FORMAT
Specify the sample format (e.g., S16_LE, U8).
-r, --rate RATE
Set the sample rate (Hz).
-V, --verbose
Verbose mode.
-N, --no-buffer
Disable buffer playback.
-d, --duration NUM
Interrupt after NUM seconds.
--disable-resample
Disable automatic rate resample.
[file ...]
The audio file(s) to play. If no file is specified, aplay reads from standard input.
DESCRIPTION
The aplay command is a command-line sound file player for the ALSA (Advanced Linux Sound Architecture) sound card driver. It supports a wide variety of audio file formats and hardware interfaces, allowing you to play audio files directly from your terminal.
aplay is primarily used for testing and debugging sound cards and audio playback, but it can also be used as a simple audio player for individual files. It offers options to control the playback device, sample rate, channels, format, and volume. While graphical audio players typically offer more user-friendly interfaces and advanced features, aplay provides a powerful and flexible way to play audio files from the command line, making it especially useful in scripting and automated audio processing scenarios. It directly interfaces with ALSA, bypassing higher-level audio server abstractions like PulseAudio (although ALSA may route audio through PulseAudio).
CAVEATS
The audio device must be correctly configured and accessible by the user running aplay. ALSA needs to be correctly configured for aplay to work. Sound server like PulseAudio may interfere, so direct ALSA device usage might require adjusting settings.
EXIT CODES
aplay returns 0 on success and a non-zero value on failure.
EXAMPLES
aplay myfile.wav: Plays the audio file myfile.wav.
aplay -D hw:1,0 myfile.wav: Plays the file on sound card 1, device 0.
aplay -c 2 -r 44100 -f S16_LE myfile.raw: Plays a raw audio file with 2 channels, 44100 Hz sample rate, and 16-bit little-endian format.