Skip to content
Related Articles

Related Articles

aplay command in Linux with examples
  • Last Updated : 05 Mar, 2019

aplay is a command-line audio player for ALSA(Advanced Linux Sound Architecture) sound card drivers. It supports several file formats and multiple soundcards with multiple devices. It is basically used to play audio on command-line interface. aplay is much the same as arecord only it plays instead of recording. For supported soundfile formats, the sampling rate, bit depth, and so forth can be automatically determined from the soundfile header.

Syntax:

aplay [flags] [filename [filename]] ...

If filename not specified uses Standard output.

Options:

  • -h, –help : Show the help information.
  • –version : Print current version.
  • -l, –list-devices : List all soundcards and digital audio devices.
  • -L, –list-pcms : List all PCMs(Pulse Code Modulation) defined.
  • -D, –device=NAME : Select PCM by name.
  • -q –quiet : Quiet mode. Suppress messages (not sound :)).
  • -t, –file-type TYPE : File type (voc, wav, raw or au). If this parameter is omitted the WAVE format is used.
  • -c, –channels=# : The number of channels. The default is one channel. Valid values are 1 through 32.
  • -f –format=FORMAT : If no format is given U8 is used.
  • -r, –rate=# : Sampling rate in Hertz. The default rate is 8000 Hertz.
  • -d, –duration=# : Interrupt after # seconds.
  • -s, –sleep-min=# : Min ticks to sleep. The default is not to sleep.
  • -M, –mmap : Use memory-mapped (mmap) I/O mode for the audio stream. If this option is not set, the read/write I/O mode will be used.
  • -N, –nonblock : Open the audio device in non-blocking mode.If the device is busy the program will exit immediately.

Note: This command contain various other options that we normally don’t need. If you want to know more about you can simply run following command on your terminal.



aplay --help

Recognized sample formats are: S8 U8 S16_LE S16_BE U16_LE U16_BE S24_LE S24_BE U24_LE U24_BE S32_LE S32_BE U32_LE U32_BE FLOAT_LE FLOAT_BE FLOAT64_LE FLOAT64_BE IEC958_SUBFRAME_LE IEC958_SUBFRAME_BE MU_LAW A_LAW IMA_ADPCM MPEG GSM SPECIAL S24_3LE S24_3BE U24_3LE U24_3BE S20_3LE S20_3BE U20_3LE U20_3BE S18_3LE S18_3BE U18_3LE U18_3BE G723_24 G723_24_1B G723_40 G723_40_1B DSD_U8 DSD_U16_LE DSD_U32_LE DSD_U16_BE DSD_U32_BE

Note: Some of these may not be available on selected hardware.

Examples:

  • Plays audio for only 10 secs at 2500hz frequency.

  • Plays full audio clip at 2500hz frezuency.

  • Display version information.

My Personal Notes arrow_drop_up
Recommended Articles
Page :