APLAY(1)

๐Ÿ“ฆ
version 1.2.16 ยท 2 versions
  • 1.2.16 ยท alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, centos-stream 10, centos-stream 9, debian trixie, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu questing, ubuntu resolute, ubuntu stonking (latest)
  • 1.2.9 ยท debian bookworm, ubuntu jammy, ubuntu noble
, in alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, centos-stream 10, centos-stream 9, debian trixie, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu questing, ubuntu resolute, ubuntu stonking

okay bestie, this is the General Commands Manual page for APLAY(1) ๐ŸŽ€ two sound tools, one vibe, let's go ๐Ÿ’…

โœจ NAME โœจ

arecord, aplay: command-line sound recorder and player for the ALSA soundcard driver ๐ŸŽง

โœจ SYNOPSIS โœจ

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

โœจ DESCRIPTION โœจ

okay so arecord is a command-line soundfile recorder for the ALSA soundcard driver ๐ŸŽ™๏ธ it's giving versatility bc it supports several file formats AND multiple soundcards with multiple devices ๐Ÿ’– also if you're recording with interleaved mode samples, the file gets automatically split before the 2GB filesize so you don't lose your bag ๐Ÿซถ

aplay is basically the same energy, just on the playing side instead of recording ๐Ÿ”Š for supported soundfile formats, the sampling rate, bit depth, and so forth can be automatically figured out from the soundfile header, so it does the homework for you ๐Ÿงš

if you don't specify a filename, the standard output or input gets used instead ๐ŸŒธ and aplay accepts multiple filenames, so you can queue up the whole playlist ๐Ÿ’œ

โœจ OPTIONS โœจ

  • -h, --help โ€” need a refresher? shows the syntax ๐Ÿ“–
  • --version โ€” prints the current version ๐Ÿ”ข
  • -l, --list-devices โ€” lists all soundcards and digital audio devices ๐ŸŽ›๏ธ
  • -L, --list-pcms โ€” lists all the PCMs that are defined ๐Ÿงพ
  • -D, --device=NAME โ€” selects a PCM by name ๐ŸŽฏ
  • -q, --quiet โ€” quiet mode! it suppresses messages (not sound :)) ๐Ÿคซ
  • -t, --file-type TYPE โ€” picks the file type: voc, wav, raw or au ๐Ÿ“ if you leave this out, WAVE format is used ๐ŸŒŠ
  • -c, --channels=# โ€” the number of channels ๐ŸŽš๏ธ default is one channel, and the valid values are 1 through 32 ๐Ÿ’…
  • -f, --format=FORMAT โ€” the sample format ๐ŸŽถ these are the recognized ones:
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
heads up: some of these might not be available on your hardware, so don't be shocked if one ghosts you ๐Ÿ’€

the format shortcuts are also a whole mood โœจ

-f cd (16 bit little endian, 44100, stereo) [-f S16_LE -c2 -r44100]
-f cdr (16 bit big endian, 44100, stereo) [-f S16_BE -c2 -r44100]
-f dat (16 bit little endian, 48000, stereo) [-f S16_LE -c2 -r48000]

and if you don't give a format at all, U8 is used ๐Ÿซ 

  • -r, --rate=#<Hz> โ€” the sampling rate in Hertz ๐ŸŽผ default is 8000 Hertz. if the value you pass is less than 300, it gets read as kilohertz instead. valid values are 2000 through 192000 Hertz ๐Ÿ“ˆ
  • -d, --duration=# โ€” interrupts after # seconds โฑ๏ธ a value of zero means infinity. the default is zero, so if you skip this option, the record/playback keeps going until it gets killed ๐Ÿ’€ also '-d' and '-s' are exclusive, so you can only pick one bestie ๐Ÿ™…
  • -s, --samples=# โ€” interrupts after # PCM frames are transmitted ๐ŸŽž๏ธ zero means infinity, and the default is zero too, so without this option it runs until it's killed ๐Ÿ’€ and again, '-d' and '-s' can't be used together ๐Ÿ™…
  • -M, --mmap โ€” uses memory-mapped (mmap) I/O mode for the audio stream ๐Ÿง  if this isn't set, read/write I/O mode is used instead ๐Ÿ“
  • -N, --nonblock โ€” opens the audio device in non-blocking mode ๐Ÿšช if the device is busy, the program exits immediately ๐Ÿ˜ค if you don't set this, the program blocks until the audio device is free again ๐Ÿ•ฐ๏ธ
  • -F, --period-time=# โ€” the distance between interrupts is # microseconds ๐ŸŽต if you give no period time and no period size, a quarter of the buffer time gets set ๐Ÿฐ
  • -B, --buffer-time=# โ€” buffer duration is # microseconds ๐Ÿซง if you give no buffer time and no buffer size, the maximal allowed buffer time gets set, but never more than 500ms ๐Ÿง
  • --period-size=# โ€” the distance between interrupts is # frames ๐ŸŽž๏ธ if you give no period size and no period time, a quarter of the buffer size gets set ๐Ÿฐ
  • --buffer-size=# โ€” buffer duration is # frames ๐Ÿซง if you give no buffer time and no buffer size, the maximal allowed buffer time gets set, but not more than 500ms ๐Ÿง
  • -A, --avail-min=# โ€” the min available space for wakeup is # microseconds ๐Ÿ””
  • -R, --start-delay=# โ€” the delay for automatic PCM start is # microseconds โ–ถ๏ธ this is relative to buffer size if the value is <= 0 ๐ŸŒ€
  • -T, --stop-delay=# โ€” the delay for automatic PCM stop is # microseconds from xrun โน๏ธ
  • -v, --verbose โ€” shows the PCM structure and setup ๐Ÿ” this one is accumulative, and the VU meter shows up when you give it twice or three times ๐Ÿ“Š
  • -V, --vumeter=TYPE โ€” picks the VU-meter type, either stereo or mono ๐ŸŽš๏ธ the stereo VU-meter is only available for 2-channel stereo samples with interleaved format ๐Ÿ‘ฏ
  • -I, --separate-channels โ€” one file for each channel ๐Ÿ—‚๏ธ this option disables max-file-time and use-strftime, and it ignores SIGUSR1 ๐Ÿ™ˆ the stereo VU meter isn't available with separate channels either ๐Ÿ’”
  • -P โ€” playback! this is the default if you invoke the program by typing aplay โ–ถ๏ธ
  • -C โ€” record! this is the default if you invoke the program by typing arecord โบ๏ธ
  • -i, --interactive โ€” allows interactive operation via stdin ๐ŸŽฎ right now, only pause/resume via the space or enter key is implemented โฏ๏ธ
  • -m, --chmap=ch1,ch2,... โ€” gives the channel map to override or follow ๐Ÿ—บ๏ธ pass channel position strings like FL, FR, etc.
    • if a device supports overriding the channel map, aplay tries to pass the channel map you gave it ๐ŸŽฏ
    • if it doesn't support the override but still provides channel map info, aplay tries to rearrange the channel order in the buffer so it matches the channel map the device returned ๐Ÿ”€
  • --disable-resample โ€” disables automatic rate resample ๐Ÿšซ
  • --disable-channels โ€” disables automatic channel conversions ๐Ÿšซ
  • --disable-format โ€” disables automatic format conversions ๐Ÿšซ
  • --disable-softvol โ€” disables software volume control (softvol) ๐Ÿ”‡
  • --test-position โ€” tests the ring buffer position ๐Ÿงช
  • --test-coef=<coef> โ€” the test coefficient for ring buffer position ๐Ÿงฎ default is 8. the expression for validation is: coef * (buffer_size / 2), and the minimum value is 1 ๐Ÿ’…
  • --test-nowait โ€” doesn't wait for the ring buffer, which means it eats the whole CPU ๐Ÿ”ฅ use with caution, bestie ๐Ÿ’€
  • --max-file-time โ€” while recording, once the output file has been collecting sound for this long, it closes and a new output file opens ๐Ÿ“‚ the default is the max size the file format supports, which is 2 GiB for WAV files ๐Ÿ’พ this option has no effect if --separate-channels is specified ๐Ÿ™…
  • --process-id-file <file name> โ€” aplay writes its process ID here so other programs can send it signals ๐Ÿ“จ
  • --use-strftime โ€” when recording, the %-codes in the file name parameter get interpreted with the strftime facility every time the output file is opened ๐Ÿ—“๏ธ the important ones are: %Y is the year, %m is the month, %d is the day of the month, %H is the hour, %M is the minute and %S is the second โฐ also %v is the file number, starting at 1 ๐Ÿ”ข when this option is on, intermediate directories for the output file get created automatically ๐Ÿ“ and it has no effect if --separate-channels is specified ๐Ÿ™…
  • --dump-hw-params โ€” dumps the hw_params of the device's preconfigured status to stderr ๐Ÿ–จ๏ธ the dump lists the device's capabilities, like supported formats, sampling rates, numbers of channels, and period and buffer bytes/sizes/times ๐Ÿ“‹ for the raw device hw:X, this option basically lists the hardware capabilities of the soundcard ๐Ÿ”ฌ
  • --fatal-errors โ€” disables recovery attempts when errors (e.g. xrun) happen ๐Ÿ’ฅ instead, the aplay process aborts immediately ๐Ÿ›‘

โœจ SIGNALS โœจ

when recording, SIGINT, SIGTERM and SIGABRT will close the output file and exit ๐Ÿ‘‹ SIGUSR1 closes the output file, opens a new one, and keeps recording ๐Ÿ”„ but heads up: SIGUSR1 does not work with --separate-channels ๐Ÿ™…

โœจ EXAMPLES โœจ

aplay -c 1 -t raw -r 22050 -f mu_law foobar

this will play the raw file "foobar" as a 22050-Hz, mono, 8-bit, Mu-Law .au file ๐ŸŽถ

arecord -d 10 -f cd -t wav -D copy foobar.wav

this will record foobar.wav as a 10-second, CD-quality wave file, using the PCM "copy" (which might be defined in the user's .asoundrc file as:

pcm.copy {
  type plug
  slave {
    pcm hw
  }
  route_policy copy
}
arecord -t wav --max-file-time 30 mon.wav

this records from the default audio source in monaural, 8,000 samples per second, 8 bits per sample ๐ŸŽ™๏ธ a new file starts every 30 seconds ๐Ÿ•ง the file names are mon-nn.wav, where nn increases from 01, so the file after mon-99.wav is mon-100.wav ๐Ÿ”ข

arecord -f cd -t wav --max-file-time 3600 --use-strftime %Y/%m/%d/listen-%H-%M-%v.wav

this records in stereo from the default audio source ๐ŸŽง it creates a new file every hour ๐Ÿ• the files are placed in directories based on their start dates, and they have names that include their start times and file numbers ๐Ÿ—‚๏ธโœจ

โœจ SEE ALSO โœจ

alsamixer(1), amixer(1) ๐ŸŽ›๏ธ

โœจ BUGS โœจ

bug alert ๐Ÿšจ .aiff files are not currently supported ๐Ÿ˜ญ

โœจ AUTHOR โœจ

arecord and aplay are by Jaroslav Kysela <perex@perex.cz> ๐Ÿ’œ this document is by Paul Winkler <zarmzarm@erols.com>. Updated for Alsa 0.9 by James Tappin <james@xena.uklinux.net> ๐Ÿซถ


that's the whole tea, bestie ๐Ÿ“ APLAY(1) from the General Commands Manual, dated 1 January 2010. stay iconic ๐Ÿ‘‘๐Ÿฆ‹