pacat(1) is a simple tool for playing back or capturing raw or encoded audio files on a PulseAudio sound server. It understands all audio file formats supported by libsndfile.
It is also present under the aliases paplay, parecord, parec, and pamon.
Installation
pacat is installed by default with PulseAudio, as part of the libpulse package.
Usage
See the pacat(1) man page for information on pacat's flags.
-
paplayis equivalent topacat --file-format -
parecordis equivalent topacat -r --file-format -
parecis equivalent topacat -r --raw -
pamonis equivalent topacat --raw - When invoking
pacatdirectly, the defaults are equivalent topacat -p --raw.
To summarize, parecord and parec both record by default, whereas pacat and paplay play back by default. parecord and paplay both deal with encoded audio, whereas parec and pacat work on raw PCM (and thus can be used in pipelines).
Note that a single instance of pacat cannot record and play back at the same time; for that, see #Playing back an audio input.
Select a sink or source
Configuring which sink to play to, or which source to record, can be done using a PulseAudio front-end, or programmatically using the -d option.
To list the available sinks:
$ pactl list sinks short
To list the available sources:
$ pactl list sources short
Removing the short keyword produces detailed output about each sink/source.
There are two ways to refer to a given sink/source: either by name, or by ID. Taking the following source list as an example:
$ pactl list sources short
0 alsa_output.pci-0000_00_1f.3.analog-stereo.monitor module-alsa-card.c s16le 2ch 44100Hz RUNNING 1 alsa_input.pci-0000_00_1f.3.analog-stereo module-alsa-card.c s16le 2ch 44100Hz RUNNING 2 alsa_output.hw_0_7.monitor module-alsa-sink.c s16le 2ch 48000Hz RUNNING 3 rtp.monitor module-null-sink.c s16le 2ch 44100Hz RUNNING
Then the following two lines produce the same result.
$ parecord -d alsa_input.pci-0000_00_1f.3.analog-stereo speech.flac $ parecord -d 1 speech.flac
Tips and tricks
Low-latency playback
By default, pacat lets the PulseAudio server pick the latency, "usually relatively high for power saving reasons". If this is not desirable, for example for #Playing back an audio input, one can pass the latency (in bytes) or latency-msec option to pacat. For example:
$ pacat -d 0 --latency-msec 1
Note that this usually only needs to be done when playing back, not when recording.
Playing back an audio input
If you are recording an external audio source (for example via a jack male-male cable), you may want to have feedback on what you are recording. This can be done by using parec to capture the input, and piping it into pacat to play it back.
$ parec | pacat
It may be practical to #Select a sink or source directly, for example:
$ parec -d 0 | pacat -d 1
It is possible to record the sound at the same time by adding tee to the pipeline:
$ parec | tee speech.raw | pacat
Though you may want to launch a separate instance of parec or parecord instead.