How To Use aplay Command In Linux-Examples

aplay command in Linux indicates to an audio-player which runs through command line for ALSA sound card drivers. This audio player supports a wide range of file formats, sound cards and multiple devices as well. One who like to play an audio file through command-line-interface, aplay is the best option that works the same as arecord, however aplay just plays the sound rather than recording. The utility determines the sound file formats, sample rate, bit rate, and so on automatically from sound file header.

Also Read:   Using cc Command In Linux- Examples

Syntax to use aplay command in Linux

aplay [options] [filename]

Note: If the filename is not specified in the syntax above, the command will use Standard output.

Options available to use aplay command in Linux

  • -h | -help: displays help information (all options available to use with the command)
  • -version: displays current version of aplay
  • -l | -list-devies: lists soundcards and digital audio devices
  • -L | -list-pcms: lists all PCMs defined (PCM= Pulse Code Modulation)
  • -D | -device=name: determines PCM by name
  • -q | -quiet: enables the quiet mode
  • -t | -file-type Type: used for specifying file type, runs .wav format by default if type parameter is not passed
  • -c | -channels=#: used for setting number of channels where the default is one, and user can set it between 1 and 32
  • -f | -format=Format: used for specifying format
  • -r | -rate=#: used for specifying sample rate, where the default value is 8000 Hertz
  • -d | -duration=#: used for specifying interruption in seconds
  • -s | -sleep-min=#: used for specifying sleep duration in minutes
  • -M | -mmap: enables mmap (memory-mapped) I/O mode for the audio stream
  • -N | -nonblock: opens the device in non-blocking mode, however if the device is found busy, the program will exit nstantly
Also Read:   Using atd Command In Linux (Examples)

Examples to use aplay command in Linux

1: Playing audio for 5 seconds at 2000hz

aplay -d 10 -r 2000hz servonode.mp3

2: Displaying aplay version

aplay –version

3: Playing complete audio at 2000hz

aplay -r 2000hz servonode.mp3

Nishant

Nishant Verma is a senior web developer who love to share his knowledge about Linux, SysAdmin, and more other web handlers. Currently, he loves to write as content contributor for ServoNode.