refactor(12.A): rename Mix* visualizer engine to Waveform* abstraction
This commit is contained in:
+11
-11
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* MixVisualizer — the scrolling Mix waveform background (Phase 10 + Lava Reframe).
|
||||
* WaveformVisualizer — the scrolling waveform background (Phase 10 + Lava Reframe).
|
||||
*
|
||||
* What this renders: a *windowed* slice of a mix's loudness profile, scrolling
|
||||
* bottom-to-top, coupled to playback position. New audio enters at the bottom,
|
||||
@@ -60,7 +60,7 @@ export const MAX_VISIBLE_SECONDS = 30;
|
||||
export const DEFAULT_VISIBLE_SECONDS = 10;
|
||||
|
||||
// ── Control tuning anchors. These mirror the C#-side defaults in ──────────────────
|
||||
// MixVisualizerControlState.cs — keep the two in sync, exactly as the
|
||||
// WaveformVisualizerControlState.ts — keep the two in sync, exactly as the
|
||||
// DEFAULT_VISIBLE_SECONDS / DefaultVisibleSeconds pair is kept in sync. All seven are
|
||||
// normalized [0,1] (scroll speed is mapped to a visible time-span on the C# side before it
|
||||
// reaches setScrollSpeed; it arrives here already in seconds).
|
||||
@@ -359,7 +359,7 @@ const PLAYHEAD_CORRECTION_SNAP_SECONDS = 0.0005;
|
||||
// ── Diagnostics ──────────────────────────────────────────────────────────────────
|
||||
//
|
||||
// Set true to surface the init/draw/datum/playback seams to the browser console
|
||||
// (all prefixed `[MixVisualizer]`). The error/warn paths fire regardless of this
|
||||
// (all prefixed `[WaveformVisualizer]`). The error/warn paths fire regardless of this
|
||||
// flag — they only trigger on the abnormal path. The verbose `log` paths (datum
|
||||
// received/uploaded, first-draw dimensions, GL error after first draw) are gated
|
||||
// here so they can be silenced once the renderer is confirmed healthy. Leave it on
|
||||
@@ -367,7 +367,7 @@ const PLAYHEAD_CORRECTION_SNAP_SECONDS = 0.0005;
|
||||
// NOTE: defaults to false; set true temporarily to surface verbose seams in-browser.
|
||||
const DEBUG = false;
|
||||
|
||||
const TAG = '[MixVisualizer]';
|
||||
const TAG = '[WaveformVisualizer]';
|
||||
function debugLog(...args: unknown[]): void {
|
||||
if (DEBUG) console.log(TAG, ...args);
|
||||
}
|
||||
@@ -507,7 +507,7 @@ interface Playback {
|
||||
pushWallClockMs: number;
|
||||
}
|
||||
|
||||
export interface MixVisualizerHandle {
|
||||
export interface WaveformVisualizerHandle {
|
||||
setDatum(samplesBase64: string, durationSeconds: number): void;
|
||||
setPlayback(positionSeconds: number, isPlaying: boolean): void;
|
||||
/** Visible time-span in seconds — the scroll-speed control, mapped from [0,1] on the C# side. */
|
||||
@@ -1028,13 +1028,13 @@ void main() {
|
||||
/** Compile one shader stage, throwing with the info log on failure. */
|
||||
function compileShader(gl: WebGL2RenderingContext, type: number, source: string): WebGLShader {
|
||||
const shader = gl.createShader(type);
|
||||
if (!shader) throw new Error('MixVisualizer: gl.createShader returned null.');
|
||||
if (!shader) throw new Error('WaveformVisualizer: gl.createShader returned null.');
|
||||
gl.shaderSource(shader, source);
|
||||
gl.compileShader(shader);
|
||||
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
|
||||
const log = gl.getShaderInfoLog(shader);
|
||||
gl.deleteShader(shader);
|
||||
throw new Error(`MixVisualizer: shader compile failed: ${log}`);
|
||||
throw new Error(`WaveformVisualizer: shader compile failed: ${log}`);
|
||||
}
|
||||
return shader;
|
||||
}
|
||||
@@ -1044,7 +1044,7 @@ function linkProgram(gl: WebGL2RenderingContext): WebGLProgram {
|
||||
const vert = compileShader(gl, gl.VERTEX_SHADER, VERTEX_SHADER);
|
||||
const frag = compileShader(gl, gl.FRAGMENT_SHADER, FRAGMENT_SHADER);
|
||||
const program = gl.createProgram();
|
||||
if (!program) throw new Error('MixVisualizer: gl.createProgram returned null.');
|
||||
if (!program) throw new Error('WaveformVisualizer: gl.createProgram returned null.');
|
||||
gl.attachShader(program, vert);
|
||||
gl.attachShader(program, frag);
|
||||
gl.linkProgram(program);
|
||||
@@ -1054,13 +1054,13 @@ function linkProgram(gl: WebGL2RenderingContext): WebGLProgram {
|
||||
if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
|
||||
const log = gl.getProgramInfoLog(program);
|
||||
gl.deleteProgram(program);
|
||||
throw new Error(`MixVisualizer: program link failed: ${log}`);
|
||||
throw new Error(`WaveformVisualizer: program link failed: ${log}`);
|
||||
}
|
||||
return program;
|
||||
}
|
||||
|
||||
/** The no-op handle returned when WebGL2 is unavailable or setup fails. */
|
||||
function noopHandle(): MixVisualizerHandle {
|
||||
function noopHandle(): WaveformVisualizerHandle {
|
||||
return {
|
||||
setDatum() {},
|
||||
setPlayback() {},
|
||||
@@ -1077,7 +1077,7 @@ function noopHandle(): MixVisualizerHandle {
|
||||
};
|
||||
}
|
||||
|
||||
export function create(canvas: HTMLCanvasElement): MixVisualizerHandle {
|
||||
export function create(canvas: HTMLCanvasElement): WaveformVisualizerHandle {
|
||||
// premultipliedAlpha so the translucent ribbon composites correctly over the
|
||||
// page; antialias off (the soft-edge smoothstep handles AA in-shader, and MSAA
|
||||
// would cost fill rate we don't need for a backdrop).
|
||||
Reference in New Issue
Block a user