Two things came up on the new tab. Floated and sized down, it spilled its knobs out of its window, and sized up it left the window empty. Auto-gain lifted far too much: it brought 0 dB back to 0 dB, which at -40 dB, 4:1 and knee 6 is +28.1 dB, so a sound at -24 dB came out at -6 dB. And as a knob from 0 to 1 it blended between makeup and auto-gain, so at 1 the makeup knob did nothing. Layout: - The knobs stay on the bottom line, centred, with the help line above them. - The levels fill the height left above. The curve is a square at their right, centred up and down. It grows with the tab from 180 to 360 px and takes no more than 40 % of its width (picturesLayout). - A floated window cannot be sized below what its pane needs. A pane says so in its minWidth and minHeight, and the Compressor's is every knob and the smallest pictures. Other panes keep 320 x 200. - A pane put into an open window that is too small grows the window. Auto-gain, as decided in #378: - A Compressor's auto-gain gives back what it takes from a sound at -18 dB, so that one comes out as loud as it went in. At the numbers above that is +14.6 dB. - Auto-gain is a switch on the Compressor, the Limiter and the Saturation alike, a setting and no longer an input. The makeup or output is added on top of it instead of being blended with it. - A project from before reads a number as on above 0. Nodes never set keep their defaults: off on the Compressor, on on the other two. - The tab shows the switch at the right of the knobs, with the dB it gives below it. With it on, the curve has a line at -18 dB from the curve up to the diagonal. - Every level reading keeps the gain of its time. Before, the whole picture was read by the current makeup, so after a change the tinting of the last seconds was wrong or missing. Findings: - My first e2e run of the layout clicked Dock where it was before the window was sized up, so the window stayed open and the next check went red. The check reads the button again. Tests: - Gate (melektaus-atx): 282 files, 4344 tests (6 new) - e2e 34 (melektaus-atx): ALL PASSED, 118 checks (2 new) - Offline in Chrome: a sine at -18 dB through -24 dB and 4:1 came out at -17.92 dB with auto-gain on and -22.42 dB with it off. - Counter-checks: the curve set at the top instead of the middle, and every reading read at a gain of 0, each fail exactly their test. - Looked at the window in screenshots: at its least every knob and the switch show. At 1280 x 797 the levels fill the height, the curve is centred at the right and the knobs are at the bottom. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
167 lines
8.8 KiB
TypeScript
167 lines
8.8 KiB
TypeScript
import type { Application } from 'pixi.js';
|
||
import { physicsStatus } from '../runtime/physics/engine';
|
||
import type { SchedulerOptions } from '../core/music/Scheduler';
|
||
import type { Sequence } from '../core/music/sequence';
|
||
import type { FxEnvelope, FxStage } from '../core/soundfx/nodes';
|
||
import { Music } from '../viewport/music';
|
||
import { bothAtCenter, envelopeDriver, followCurve, releaseEnvelope, stageNodes } from '../viewport/fxNodes';
|
||
import { soundLibrary } from '../viewport/SoundLibrary';
|
||
import { saturationAutoGain } from '../core/soundfx/saturation';
|
||
import { compressorMakeup } from '../core/soundfx/dynamics';
|
||
import { bakeHooks } from './debug/bakeHooks';
|
||
import { curveHooks } from './debug/curveHooks';
|
||
import { soundHooks } from './debug/soundHooks';
|
||
import { patternHooks } from './debug/patternHooks';
|
||
import { routingHooks } from './debug/routingHooks';
|
||
import { songHooks } from './debug/songHooks';
|
||
import { documentHooks } from './debug/documentHooks';
|
||
import { graphHooks } from './debug/graphHooks';
|
||
import { centreOf, type HookContext } from './debug/hookHelpers';
|
||
import { pixelArtHooks } from './debug/pixelArtHooks';
|
||
import { renderHooks } from './debug/renderHooks';
|
||
import { sceneHooks } from './debug/sceneHooks';
|
||
import { uiHooks } from './debug/uiHooks';
|
||
import { vectorArtHooks } from './debug/vectorArtHooks';
|
||
import type { DocumentId, Editor, TabId } from './Editor';
|
||
import { NodeBoard } from './plugins/NodeBoard';
|
||
import type { EditorState } from './state';
|
||
import { rectOf } from './textProbe';
|
||
|
||
/**
|
||
* Installs `window.__gm`, which the check scripts in tools/ use to find widgets by their
|
||
* visible text and to read editor state. The hooks of each area live in `debug/`.
|
||
*/
|
||
export function installDebugHook(app: Application, state: EditorState, editor: Editor): void {
|
||
const context: HookContext = { app, state, editor };
|
||
const music = new Music(() => state.project);
|
||
(window as unknown as { __gm: unknown }).__gm = {
|
||
state,
|
||
/** The Pixi application, for probes that need the renderer or the stage. */
|
||
app,
|
||
...uiHooks(context),
|
||
...sceneHooks(context),
|
||
...graphHooks(context),
|
||
...documentHooks(context),
|
||
...pixelArtHooks(context),
|
||
...vectorArtHooks(context),
|
||
...curveHooks(context),
|
||
...patternHooks(context),
|
||
...songHooks(context),
|
||
...routingHooks(context),
|
||
...soundHooks(context),
|
||
...bakeHooks(context),
|
||
...renderHooks(context),
|
||
/**
|
||
* Voices started, stopped and in flight. CI runs the browser with `--mute-audio`, so nothing
|
||
* is ever heard there: these counters are the only way a check can see that a graph played
|
||
* anything at all, the way `renderStats` is for a repaint that did not happen.
|
||
*/
|
||
sound: {
|
||
stats: () => soundLibrary.stats(),
|
||
duration: (file: string) => soundLibrary.duration(file),
|
||
/** Where the knobs of each voice of that file are now, oldest first, a pitch as its speed (#315). */
|
||
levels: (file: string) => soundLibrary.levels(file),
|
||
fxWorkletUrl: () => soundLibrary.fxWorkletUrl(),
|
||
/** Seconds on the audio clock: the time a voice really runs on. */
|
||
clock: () => soundLibrary.clock(),
|
||
/** Decodes ahead of a check, so a play can be asserted without racing the network. */
|
||
load: (file: string) => soundLibrary.load(file).then((buffer) => buffer?.duration ?? null),
|
||
stopAll: () => soundLibrary.stopAll(),
|
||
/** What Stop sound asks for: every voice of that file, its echoes cut or left to ring (#324). */
|
||
stop: (file: string, letRing: boolean) => soundLibrary.stop(file, letRing),
|
||
/** The patterns and songs a game plays, with the notes and clips last planned of each. */
|
||
playbacks: () => soundLibrary.playbacks(),
|
||
/** Every bus there is, the master and those of the project among them (#325), and how loud one is. */
|
||
buses: () => soundLibrary.busLevels(),
|
||
mixVolume: (name: string) => soundLibrary.mixVolume(name),
|
||
/** Whether the audio clock is held by the pause of the toolbar or runs. */
|
||
clockState: () => soundLibrary.clockState(),
|
||
/** The second of the audio clock a voice started at, and the rate that clock runs at (#346). */
|
||
startedAt: (voice: number) => soundLibrary.startedAt(voice),
|
||
playing: (voice: number) => soundLibrary.playing(voice),
|
||
sampleRate: () => soundLibrary.liveContext().sampleRate,
|
||
/**
|
||
* The nodes a stage of a voice becomes, in any context – an offline one renders what it does.
|
||
* `at` is when its voice starts, which a Flanger's sweep counts from (#341), `impulse` the
|
||
* sound a Reverb that takes one has (#328).
|
||
*/
|
||
stageNodes: (context: BaseAudioContext, stage: FxStage, at?: number, impulse?: AudioBuffer) =>
|
||
stageNodes(context, stage, undefined, at, impulse),
|
||
/** The gain in dB a Saturation's auto-gain gives at a drive (#323). */
|
||
saturationAutoGain,
|
||
/** The gain after a Compressor as a factor, from its makeup and auto-gain (#326, #378). */
|
||
compressorMakeup,
|
||
/** What drives the two shares of a Mix "Both at center", in any context (unstarted). */
|
||
bothAtCenter: (context: BaseAudioContext, mix: number, a: GainNode, b: GainNode) =>
|
||
bothAtCenter(context, mix, a, b),
|
||
/** The curve of an Envelope from `at` (unstarted), its release, and how it moves a number (#335). */
|
||
envelopeDriver: (context: BaseAudioContext, envelope: FxEnvelope, at: number) =>
|
||
envelopeDriver(context, envelope, at),
|
||
releaseEnvelope: (level: AudioParam, envelope: FxEnvelope, startedAt: number, at: number) =>
|
||
releaseEnvelope(level, envelope, startedAt, at),
|
||
stageWith: (context: BaseAudioContext, stage: FxStage, driver: ConstantSourceNode) =>
|
||
stageNodes(context, stage, (mod, param, ratio, map) =>
|
||
followCurve(context, driver, mod, param, ratio, map),
|
||
),
|
||
},
|
||
/**
|
||
* The scheduler (#332), which nothing in the editor plays yet: a check hands it a sequence of
|
||
* notes and reads back what was planned for which second of the audio clock.
|
||
*/
|
||
music: {
|
||
play: (sequence: Sequence, options?: SchedulerOptions & { from?: number }) =>
|
||
music.play(sequence, options),
|
||
edit: (sequence: Sequence) => music.edit(sequence),
|
||
stop: () => music.stop(),
|
||
position: () => music.current?.position() ?? null,
|
||
playing: () => music.current?.playing ?? false,
|
||
planned: () => [...music.planned],
|
||
latency: () => soundLibrary.latency(),
|
||
},
|
||
world: () => editor.worldSnapshot(),
|
||
playInfo: () => editor.playInfo(),
|
||
/** Which scene Play would start, and under which of the two rules (#183: set in the settings). */
|
||
playFrom: () => editor.playFromInfo(),
|
||
/** The two run buttons of the top bar: the picture each wears, and whether it takes a click. */
|
||
runButtons: () => editor.runButtons(),
|
||
/** Where to click one of the icon buttons: menu, undo, redo, play, pause. */
|
||
toolbarAt: (name: keyof Editor['toolbarControls']) => centreOf(editor.toolbarControls[name]),
|
||
/** Behaviors running without Play (`Run in editor`), and how long they have been at it. */
|
||
editorRun: () => editor.editorRunInfo(),
|
||
physics: () => physicsStatus(),
|
||
tab: () => editor.tab,
|
||
showTab: (tab: TabId) => editor.showTab(tab),
|
||
/** The open documents in tab order and the one showing (#171); a document is `asset:<id>` or `list`. */
|
||
documents: () => editor.openDocuments(),
|
||
openDocument: (doc: DocumentId) => editor.openDocument(doc),
|
||
closeDocument: (doc: DocumentId) => editor.closeDocument(doc),
|
||
/** The tabs in windows of their own (#371): kind, document, box, and where to press. */
|
||
floatWindows: () => editor.floatWindows(),
|
||
floatDocument: (doc: DocumentId) => editor.floatDocument(doc),
|
||
/** The kind Delete, Copy and Paste go to: the window pressed last, else the tab showing. */
|
||
keyTarget: () => editor.keyTarget(),
|
||
plugins: {
|
||
/** Every file in `data/plugins/` and what became of it. */
|
||
records: () => [...(editor.plugins?.records ?? [])],
|
||
/** The plugins in the user management tab (#179): one row per file, with its switch. */
|
||
pane: () => ({ ...editor.pluginsPane.debugInfo(), visible: editor.tab === 'management' }),
|
||
/** Where to click the switch of one plugin; null when it has no row. */
|
||
switchAt: (file: string) => {
|
||
const box = editor.pluginsPane.switchOf(file);
|
||
return box ? centreOf(box) : null;
|
||
},
|
||
/** A plugin tab's node board as drawn, with its canvas and Fit button; null without one. */
|
||
board: (tabId: string) => {
|
||
const pane = editor.pluginPane(tabId);
|
||
if (!(pane instanceof NodeBoard)) return null;
|
||
return {
|
||
...pane.debugInfo(),
|
||
visible: pane.visible,
|
||
rect: rectOf(pane),
|
||
fit: centreOf(pane.fitButton),
|
||
};
|
||
},
|
||
},
|
||
};
|
||
}
|