Description Context
getFeatures() allocates a raw window buffer and then normalizes into a second buffer for every request.
v3/v4 request overlapping windows, so most frames are re-normalized repeatedly.
Evidence
src/lib/audio/mel.worker.ts → getFeatures copies into raw then normalizeMelFeatures() allocates out.
src/lib/audio/mel-math.ts → normalizeMelFeatures allocates a new Float32Array per call.
Impact
Extra allocations + CPU in feature extraction under continuous streaming.
Actions
Cache normalized frames per mel-bin in the circular buffer, or normalize in-place when raw is no longer needed.
For overlapping windows, reuse cached normalized frames and only normalize new frames.
Add a small LRU cache of recent getFeatures windows keyed by (start,end,normalize).
Acceptance
Feature extraction CPU time drops (p95) in a 30s capture.
Worker GC time reduced vs baseline.
Reactions are currently unavailable
You can’t perform that action at this time.
Context
getFeatures()allocates a raw window buffer and then normalizes into a second buffer for every request.Evidence
src/lib/audio/mel.worker.ts→getFeaturescopies intorawthennormalizeMelFeatures()allocatesout.src/lib/audio/mel-math.ts→normalizeMelFeaturesallocates a new Float32Array per call.Impact
Actions
getFeatureswindows keyed by (start,end,normalize).Acceptance