diff --git a/README.md b/README.md index 952de35..118c4b9 100644 --- a/README.md +++ b/README.md @@ -5,9 +5,8 @@ Record audio to a WAV file on **Linux** using **ALSA** as the recording source. `tuxrecord` is the Linux port of the former macOS-only **macrecord** tool. The Swift/AVFoundation code was rewritten in **C99** and now uses the native ALSA capture API (`libasound`); it builds with **GCC**. - -The port is derived from [macrecord](https://codeberg.org/armin/macrecord) -which was created by my good friend armin. +macrecord was created by my good friend Armin. You can find his code here: +[https://codeberg.org/armin/macrecord](https://codeberg.org/armin/macrecord) ## Requirements @@ -32,6 +31,9 @@ tuxrecord -p myrec # Use a specific ALSA capture device tuxrecord -D hw:1,0 + +# Record from PipeWire (the PipeWire sound server) +tuxrecord -D pipewire ``` ## Options @@ -41,10 +43,12 @@ tuxrecord -D hw:1,0 | `-o ` | Output directory (default: current directory) | | `-d ` | Stop automatically after `` seconds | | `-p ` | Filename prefix instead of `tuxrecord` | -| `-D ` | ALSA capture device (default: `default`) | +| `-D ` | ALSA capture device (default: `default`; `pipewire` on PipeWire systems) | | `-h, --help` | Show help | -Run `arecord -l` to list available ALSA capture devices. +Run `arecord -l` to list available ALSA capture devices. On systems with +PipeWire, list the PipeWire source nodes with `pactl list short sources` +or `wpctl status` (see "Recording from PipeWire" below). ## Controls @@ -80,6 +84,67 @@ through. Point your players at `hw:Loopback,0` (default sink) and record from kernel version; if one direction is silent, try recording from `hw:Loopback,0` while playing to `hw:Loopback,1`. +## Recording from PipeWire + +On modern distributions (Fedora 34+, Ubuntu 22.04+, Arch Linux) the **PipeWire** +sound server takes over audio handling. PipeWire ships an ALSA compatibility +plugin (`pipewire-alsa`) that exposes the server as a normal ALSA capture +device named `pipewire`, so `tuxrecord` can record from it with no extra +setup: + +```bash +# Record from PipeWire's default source (usually the microphone) +tuxrecord -D pipewire + +# Record a fixed duration +tuxrecord -D pipewire -d 10 +``` + +### What "pipewire" records + +The pipewire-alsa plugin routes capture to PipeWire's **default source**: + +```bash +# Show the current default source +pactl get-default-source # or: wpctl status + +# List all available PipeWire sources +wpctl status +pactl list short sources +``` + +### Recording system audio (what you hear) + +To capture everything that is currently playing (system audio), point the +default source at the **monitor** of the default sink. This is the PipeWire +equivalent of the ALSA loopback approach above but needs no kernel module: + +```bash +# 1. Find the monitor of the default sink +pactl set-default-source "$(pactl get-default-sink).monitor" + +# 2. Record it with tuxrecord +tuxrecord -D pipewire +``` + +The `.monitor` source carries exactly what the sink is playing, so anything +your players output ends up in the WAV file. Every capture follows the same +`__.wav` naming and can be stopped with `q` or **Ctrl+C**. +The default setting can be restored later with +`pactl set-default-source `. + +### Troubleshooting + +- **"cannot open ALSA capture device 'pipewire'"** — the `pipewire-alsa` + plugin is missing. Install it (e.g. `pipewire-alsa` on Debian/Ubuntu/Arch, + `pipewire-alsa` on Fedora), or the PipeWire server is not running + (`systemctl --user status pipewire`). In that case fall back to a regular + ALSA device with `tuxrecord -D hw:0,0`. +- Recording from a specific device or virtual node instead of the default + source is possible by setting the default source first (see `pactl` / + `wpctl` output) or by creating a loopback with `pw-loopback` and recording + that node. + ## Build ```bash diff --git a/tuxrecord.c b/tuxrecord.c index 357b56e..1f0cee9 100644 --- a/tuxrecord.c +++ b/tuxrecord.c @@ -6,9 +6,8 @@ * * A Linux port of the former macOS-only "macrecord" tool, rewritten in C99 * and using the ALSA capture API (libasound) as the recording source. - * - * The port is derived from [macrecord](https://codeberg.org/armin/macrecord) - * which was created by my good friend armin. + * macrecord was created by my good friend Armin. You can find his code here: + * https://codeberg.org/armin/macrecord * * Copyright 2026 Johannes Findeisen * Licensed under the terms of the Apache-2.0 license. @@ -120,7 +119,13 @@ static void usage(void) "\n" "By default the ALSA capture device \"default\" is used, which is usually\n" "the microphone. To record system audio (everything playing on the\n" - "system) see the \"Recording system audio\" section in the README.\n", + "system) see the \"Recording system audio\" section in the README.\n" + "\n" + "PipeWire users: record from the PipeWire default source via the\n" + "ALSA compatibility plugin by passing the device name \"pipewire\":\n" + " tuxrecord -D pipewire (default source)\n" + " pactl set-default-source \"$(pactl get-default-sink).monitor\"\n" + " tuxrecord -D pipewire (system audio, uses the sink monitor)\n", DEFAULT_PREFIX, DEFAULT_PREFIX, DEFAULT_DEVICE); }