LinuxCommandLibrary

pacat

Play audio to a PulseAudio server

SYNOPSIS

pacat [OPTIONS] [FILE]
pacat -r [OPTIONS] [FILE]

PARAMETERS

-p, --playback
    Operate in playback mode (default). Reads audio from a file or stdin and plays it.

-r, --record
    Operate in record mode. Captures audio from a source and writes it to a file or stdout.

-s, --server=SERVER
    Connect to the PulseAudio/PipeWire server specified by SERVER.

-d, --device=DEVICE
    Specify the sink (for playback) or source (for recording) by its name or index.

-f, --format=FORMAT
    Set the sample format (e.g., s16le for signed 16-bit little-endian, s32le, u8, float32ne).

-c, --channels=CHANNELS
    Set the number of audio channels (e.g., 1 for mono, 2 for stereo).

-R, --rate=RATE
    Set the sample rate in Hertz (e.g., 44100, 48000).

--fix-format
    Attempt to convert the stream to a format supported by the device.

--fix-channels
    Attempt to convert the stream to a channel count supported by the device.

--fix-rate
    Attempt to convert the stream to a sample rate supported by the device.

-v, --verbose
    Enable verbose output, showing more details about the operation.

-h, --help
    Display a help message and exit.

DESCRIPTION

pacat is a command-line utility for playing or recording raw audio streams through a PulseAudio or PipeWire sound server.

In playback mode (default or via -p), it reads raw PCM audio data from standard input or a specified file and sends it to an audio sink (output device). In record mode (via -r), it captures raw PCM audio data from an audio source (input device) and writes it to standard output or a specified file.

It's an essential tool for developers and advanced users to debug audio setups, test specific audio stream configurations, or programmatically manipulate raw audio data. It requires precise specification of audio parameters such as sample format, rate, and channel count, though it can attempt to automatically adapt these to the device's capabilities.

CAVEATS

pacat exclusively handles raw PCM audio data; it does not support compressed audio formats like MP3, Ogg, or FLAC. For playback or recording of such formats, tools like paplay or parecord (which utilize GStreamer or FFmpeg) are more appropriate. It requires a running PulseAudio or PipeWire server to function.

RAW AUDIO STREAM HANDLING

Unlike higher-level tools, pacat operates directly on raw PCM audio data. This makes it ideal for scenarios where the exact audio format (sample rate, channels, bit depth) needs to be precisely controlled for testing, development, or specific audio processing pipelines.

PIPEWIRE COMPATIBILITY

While originally designed for PulseAudio, pacat works flawlessly with PipeWire. PipeWire provides a PulseAudio compatibility layer, allowing existing PulseAudio clients and utilities, including pacat, to connect and interact with the PipeWire multimedia server without modification, ensuring backward compatibility and a smooth transition.

HISTORY

pacat is an integral part of the PulseAudio project, which was initially released in 2004. It has served as a low-level interface for raw audio streaming with the PulseAudio sound server since its early days. With the advent of PipeWire, which aims to replace PulseAudio, JACK, and ALSA directly, pacat continues to function seamlessly thanks to PipeWire's robust PulseAudio compatibility layer. Its core functionality has remained consistent, focusing on direct raw audio manipulation.

SEE ALSO

paplay(1), parecord(1), pactl(1), pacmd(1), pulseaudio(1), pipewire(1)

Copied to clipboard