SpectrogramProvider supplies spectrogram components and functionality to the @waveform-playlist/browser package through the integration context pattern.
Import
This provider is part of the optional
@waveform-playlist/spectrogram package. Install it separately: npm install @waveform-playlist/spectrogram fft.jsUsage
Wrap your application withSpectrogramProvider to enable spectrogram visualization:
Props
TheSpectrogramProvider currently accepts no configuration props. All spectrogram settings are controlled through the UI components (SpectrogramMenuItems, SpectrogramSettingsModal) or via the integration context.
Integration Context Pattern
The spectrogram package follows the same integration pattern as annotations: 1. Browser package defines the interface:Context Value
WhenSpectrogramProvider is present, the integration context provides:
- SpectrogramChannel component - Frequency visualization component
- Spectrogram state management - Color map, frequency scale, visibility settings
- Web Worker coordination - FFT computation and OffscreenCanvas rendering
Features Enabled
WithSpectrogramProvider installed:
✅ Frequency-domain visualization alongside waveforms✅ Real-time FFT computation in Web Workers
✅ Configurable color maps (viridis, plasma, inferno, etc.)
✅ Linear or logarithmic frequency scales
✅ Virtual scrolling for memory efficiency
✅ UI controls for spectrogram settings
Example with Settings
Browser Requirements
Spectrogram rendering requires:- Web Workers - All modern browsers
- OffscreenCanvas - Chrome 69+, Firefox 105+, Safari 16.4+, Edge 79+
Performance Considerations
Memory Usage
- Virtual scrolling renders only visible chunks (1000px wide)
- Typical memory: ~150MB for 10-hour stereo file
- Without virtual scrolling: ~1.5GB (10x more)
Computation Cost
- FFT runs in Web Workers (off main thread)
- Rendering uses OffscreenCanvas (GPU accelerated)
- Initial computation: ~2-5 seconds for 10-hour file
- Real-time updates during playback: 60fps
Related Documentation
- Spectrogram Package - Complete package documentation
- AnnotationProvider - Similar integration pattern
- WaveformPlaylistProvider - Main provider
- Browser Compatibility - OffscreenCanvas support