refactor(audio): migrate from gofft to FFmpeg av_tx RDFT#50
Conversation
Replace hand-rolled pure-Go FFT (gofft) with FFmpeg's av_tx real-input RDFT, unifying the audio pipeline on FFmpeg. Output remains bit-identical through log scale + noise gate + pixel quantisation. - Migrate ProcessChunk to av_tx with proper C-resource lifecycle (init/uninit) - Add Processor.Close() for av_tx teardown; wire deferred cleanup in both passes - Update NewProcessor signature to return (*Processor, error) for init validation - Remove gofft dependency and transitive imports - Update Pass 2 consumer to float32 Spectrum type Performance: 20789 ns/op → 3108 ns/op (0 allocs retained). No functional change; all downstream consumers unaffected. Signed-off-by: Martin Wimpress <code@wimpress.io>
There was a problem hiding this comment.
No issues found across 8 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Requires human review: This PR replaces the core FFT library and restructures audio processing logic, which carries significant risk of breaking downstream analysis and visualization even if the AI review found no issues.
Re-trigger cubic
- Replace pure-Go AudioFIFO (struct + 6 methods) with avAudioFIFO wrapper backed by FFmpeg's AVAudioFifo library. - Reorganise encode hot path: WriteAudioSamples and FlushAudioEncoder now route through AVAudioFifoWrite/Read with planar split at drain via existing writeStereoFloats/writeMonoFloats. - Zero-pad partial final frame; free FIFO handle on Encoder.Close. - Update AGENTS.md to reflect AVAudioFifo location in encoder.go. Signed-off-by: Martin Wimpress <code@wimpress.io>
The two BenchmarkAVAudioFIFO_* benchmarks served only the one-time merge gate, now signed off. The TestAVAudioFIFO_* functional tests cover correctness; the FIFO is off the critical path, so the micro-benchmarks add no ongoing value. Signed-off-by: Martin Wimpress <code@wimpress.io>
There was a problem hiding this comment.
0 issues found across 3 files (changes from recent commits).
Requires human review: This PR replaces a core FFT library with a C-based FFmpeg av_tx RDFT and swaps a Go FIFO for an FFmpeg AVAudioFifo, introducing new C memory management and unsafe code paths in the audio pipeline and encoder, which have high risk of silent correctness bugs or crashes despite no detected issues...
Re-trigger cubic
Replace hand-rolled pure-Go FFT (gofft) with FFmpeg's av_tx real-input RDFT, unifying the audio pipeline on FFmpeg. Output remains bit-identical through log scale + noise gate + pixel quantisation.
Performance: 20789 ns/op → 3108 ns/op (0 allocs retained). No functional change; all downstream consumers unaffected.