Files
prism/src/plugin-ui/BridgeLUFSMeterAnalyzer.ts
T
Boof2015 63ef5ffa0f Merge pull request #10 from Boof2015/VSTs
Add cross platform VSTs
2026-06-03 10:21:21 -04:00

35 lines
1.1 KiB
TypeScript

import type { LUFSMeterNativeAnalyzer, LUFSMeterNativeSnapshot } from '../renderer/audio/native'
/**
* Drop-in `LUFSMeterNativeAnalyzer` for the plugin webview.
*
* The loudness DSP (K-weighting, gated integration, fast VU/peak/correlation) runs
* in the C++ plugin, which pushes a finished scalar snapshot each frame. This shim
* caches that snapshot and serves it through the interface `LUFSMeter` consumes.
* `pushSamples` is a no-op (audio never flows through the webview); `reset` clears
* only the cache (the C++ integrator keeps its own state).
*/
export class BridgeLUFSMeterAnalyzer implements LUFSMeterNativeAnalyzer {
private snapshot: LUFSMeterNativeSnapshot | null = null
/** Called by the bridge whenever the host emits a new LUFS frame. */
setSnapshot(snapshot: LUFSMeterNativeSnapshot): void {
this.snapshot = snapshot
}
isAvailable(): boolean {
return true
}
setSampleRate(_sampleRate: number): void {}
pushSamples(_left: Float32Array, _right: Float32Array): void {}
getSnapshot(): LUFSMeterNativeSnapshot | null {
return this.snapshot
}
reset(): void {
this.snapshot = null
}
}