$ show cutterbl/SoundTouchJS
SoundTouchJS is a TypeScript audio processing library for real-time time-stretching and pitch-shifting in web applications using the Web Audio API. It implements the WSOLA algorithm and offers alternatives like phase vocoder for extreme ratios, with formant correction for vocal preservation. The monorepo structure includes core processing engine, AudioWorklet implementations, and interchangeable interpolation strategies. Key features include runtime parameter updates via message passing, offline processing capabilities, and observability metrics. The library is designed for integration via AudioWorklet to offload processing from the main thread, with a demo application and Storybook showcasing usage.
The LLM identified 5 files worth highlighting for reuse:
Abstract base class for AudioWorklet processors handling runtime parameter updates, sample buffer management, metrics collection, and error handling. Extractable as a foundation for any AudioWorklet processor needing communication with main thread and buffer management.
Registry for registering and retrieving interpolation strategies by name with dynamic loading and fallback. Demonstrates plugin architecture where strategies (lanczos, linear, etc.) self-register, enabling runtime switching without modifying core logic.
Abstract base class defining a sample processing pipeline with process, flush, and latency methods. Used by rate transposer and stretch processors, extractable for any sample-based audio processing chain requiring chunked input/output handling.
Efficient fixed-size circular buffer implementation for audio samples with read/write pointers. Independent of audio processing logic, reusable in any scenario requiring circular buffering (e.g., data streaming, network packets).
Self-contained pitch-shifting component of WSOLA algorithm that processes audio buffers with sample rate conversion. Extractable for any audio processing chain needing pitch shifting without tempo change, demonstrating clean separation of concerns in DSP pipelines.