feat: runtime controls, configurable audio format, README, UX polish

- Add runtime key bindings: [/] drop-off, ,/. log scaling, -/+ sensitivity
- Add --fps named flag (was positional), --rate and --channels CLI args
- Fix version string to auto-read from Cargo.toml
- Graceful error when pw-record is not found
- Add README with usage table, input mode examples, runtime controls
- Improve arg help text with ranges and clearer descriptions

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-23 21:16:02 +02:00
parent 5201b503e6
commit b7e861093e
2 changed files with 158 additions and 31 deletions
+74
View File
@@ -0,0 +1,74 @@
# spectrust
A terminal audio spectrum analyzer written in Rust. Visualizes PCM audio in real time using block characters — reads from PipeWire, a file, or stdin.
```
▁▂▃▄▅▆▇█▇▆▅▄▃▂▁▁▂▃▄▅▆▇█▇▆▅▄▃▂▁▁▂▃▄▅▆▇█
```
## Installation
**Arch Linux (AUR)**
```
yay -S spectrust
```
**From source**
```
cargo install --path .
```
Requires Rust 1.70+. PipeWire (`pw-record`) is only needed for the `-p` capture mode.
## Usage
```
spectrust [OPTIONS]
```
| Option | Default | Description |
|--------|---------|-------------|
| `-f, --fps <N>` | `60` | Target frames per second |
| `-p, --pipewire` | — | Capture audio directly from PipeWire |
| `-i, --input <FILE>` | — | Read PCM from a file (stdin if omitted) |
| `-l, --log-power <N>` | `1.4` | Frequency scaling power (0.53.0); higher values give more space to bass |
| `-d, --drop-off <N>` | `0.75` | Bar drop-off factor per frame (0.0 = instant, 1.0 = no drop) |
| `--rate <HZ>` | `48000` | Sample rate — must match the audio source |
| `--channels <N>` | `2` | Channel count — must match the audio source |
### Input modes
**PipeWire** — capture system audio directly:
```
spectrust -p
```
**stdin** — pipe from any recorder:
```
pw-record --format=s16 --rate=48000 --channels=2 --raw - | spectrust
arecord -f S16_LE -r 48000 -c 2 | spectrust
```
**File** — replay a raw PCM file:
```
spectrust -i recording.pcm
```
### Runtime controls
| Key | Action |
|-----|--------|
| `q` / `Ctrl+C` | Quit |
| `[` / `]` | Decrease / increase drop-off speed |
| `,` / `.` | Decrease / increase log frequency scaling |
| `-` / `+` | Decrease / increase sensitivity |
## Notes
- Input is expected as signed 16-bit little-endian PCM (s16le). This matches `pw-record --format=s16 --raw` and `arecord -f S16_LE`.
- If `--rate` or `--channels` don't match the actual source the visualization will be distorted.
- The sensitivity control scales bar heights at render time; it has the most noticeable effect on quiet signals.
## License
MIT