feat(processed-audio-sources): phase 2 - implement 11 audio filters

Add all audio filters that transform AudioAnalysis data:
- Channel Extract, Band Extract (migration from old source types)
- Peak Hold, Gain, Noise Gate, Envelope Follower
- Spectral Smoothing, Compressor, Inverter, Beat Gate, Delay
All registered via AudioFilterRegistry with option schemas.
This commit is contained in:
2026-03-31 18:43:36 +03:00
parent 86a9d344e6
commit eb94066386
15 changed files with 981 additions and 19 deletions
+10 -3
View File
@@ -9,13 +9,20 @@
- **Test:** `cd server && py -3.13 -m pytest tests/ --no-cov -q`
## Current State
Phase 1 (Audio Filter Framework) implemented. Core framework is in place:
Phase 1 (Audio Filter Framework) and Phase 2 (Audio Filters) implemented.
Phase 1 framework:
- `AudioFilter` base class, `AudioFilterRegistry`, `AudioFilterOptionDef` in `core/audio/filters/`
- `AudioProcessingTemplate` dataclass + `AudioProcessingTemplateStore` (SQLite-backed) in `storage/`
- `audio_filter_template` meta-filter with recursive resolution
- Full REST API: CRUD templates + filter registry discovery
- Dependency injection wired in `dependencies.py` and `main.py`
Phase 2 filters (12 total registered, 11 real + 1 meta):
- Stateless: `channel_extract`, `band_extract`, `gain`, `inverter`
- Stateful: `peak_hold`, `noise_gate`, `envelope_follower`, `spectral_smoothing`, `compressor`, `beat_gate`, `delay`
- All produce new `AudioAnalysis` via `dataclasses.replace()` (immutability preserved)
## Key Architecture Reference
### Existing Pattern to Mirror: Processed Picture Sources
@@ -83,7 +90,7 @@ _(none yet)_
| Phase | Agent Used | Test Writer | Parallel | Notes |
|-------|-----------|-------------|----------|-------|
| Phase 1 | impl-agent | — | No | Tasks 7+8 skipped (SQLite migration made them obsolete) |
| Phase 2 | | — | | |
| Phase 2 | impl-agent | — | No | All 11 filters implemented, no deviations |
| Phase 3 | — | — | — | — |
| Phase 4 | — | — | — | — |
| Phase 5 | — | — | — | — |
@@ -98,6 +105,6 @@ _(none yet)_
## Implementation Notes
- Clean-slate approach: no migration of existing MonoAudioSource/BandExtractAudioSource data
- 5 of 11 filters are stateful (peak hold, envelope follower, spectral smoothing, compressor, delay) — need per-stream instance lifecycle
- 7 of 11 filters are stateful (peak hold, noise gate, envelope follower, spectral smoothing, compressor, beat gate, delay) — need per-stream instance lifecycle
- Audio filters operate on AudioAnalysis snapshots, not raw audio samples
- Big Bang strategy: intermediate phases may break the build; only Phase 7 enforces build/tests