75 lines
2.0 KiB
Markdown
75 lines
2.0 KiB
Markdown
# 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)**
|
||
```
|
||
paru -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.5–3.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
|