@motionscript/audio 0.1.0-alpha.5 → 0.1.0-alpha.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,4 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- import { Node2D, node, fillOps, property, } from "@motionscript/sdk";
8
- import { declarePaints } from "@motionscript/sdk/component";
1
+ import { Types, component2d, fillOps, } from "@motionscript/sdk";
9
2
  import { EMPTY_ENVELOPE, forSpeaker, sampleEnvelope, } from "./envelope.js";
10
3
  import { clamp01, groupByPaint, layOutBars, livePaintKey, paintBars, voiceColor, } from "./shared.js";
11
4
  /**
@@ -28,7 +21,7 @@ import { clamp01, groupByPaint, layOutBars, livePaintKey, paintBars, voiceColor,
28
21
  *
29
22
  * ## The speaker filter
30
23
  *
31
- * {@link speaker} narrows the node to one voice of a diarized recording, and it
24
+ * `speaker` narrows the node to one voice of a diarized recording, and it
32
25
  * is the reason this node knows about transcripts at all. Two visualisers beside
33
26
  * two headshots, each filtered to its own host, is a podcast edit that would
34
27
  * otherwise be done by hand for every turn — and because the filter *silences*
@@ -41,132 +34,97 @@ import { clamp01, groupByPaint, layOutBars, livePaintKey, paintBars, voiceColor,
41
34
  * true, where falling back to the unfiltered mix would be a silent lie about
42
35
  * whose voice you were watching.
43
36
  */
44
- let LiveWaveform = class LiveWaveform extends Node2D {
45
- declareAssets(assets) {
46
- super.declareAssets(assets);
47
- declarePaints(this, assets);
48
- }
49
- /**
50
- * The second of the recording the visualiser is showing.
51
- *
52
- * Off the node's own clock rather than the scene's, which is what "from the
53
- * moment this node appeared" means — the same clock the engine's own
54
- * `Video` times its picture from, and the same one that makes a node dropped
55
- * halfway through a clip start its recording at its entrance rather than
56
- * partway in.
57
- */
58
- get at() {
59
- return this.offset + (this.playing ? Math.max(0, this.time.elapsed) : 0);
60
- }
61
- renderSelf(ctx) {
62
- const rect = this.layoutBounds;
63
- const width = rect?.width ?? 0;
64
- const height = rect?.height ?? 0;
65
- if (width <= 0 || height <= 0)
66
- return;
67
- const count = Math.max(1, Math.round(this.bars));
68
- const span = Math.max(0.05, this.window);
69
- const at = this.at;
70
- const voice = this.speaker < 0 ? null : Math.round(this.speaker);
71
- // The window is centred on the playhead, so the bars run *toward* the
72
- // middle and away again — the arrangement every mixer's meter uses, and the
73
- // one that reads as sound arriving rather than as a strip scrolling past.
74
- const sampled = forSpeaker(sampleEnvelope(this.envelope, at - span / 2, at + span / 2, count), voice);
75
- const shaped = this.style === "line" ? taper(sampled) : sampled;
76
- const boxes = layOutBars(shaped, {
77
- width,
78
- height,
79
- gap: this.style === "blocks" ? 0.12 : this.gap,
80
- align: this.align,
81
- gain: this.gain,
82
- floor: this.floor,
83
- });
84
- if (boxes.length === 0)
85
- return;
86
- const groups = groupByPaint(boxes, (i) => livePaintKey(shaped[i].speaker, this.byVoice, voice));
87
- for (const [key, run] of groups) {
88
- const graphics = paintBars(run, this.paintFor(key), this.radius);
89
- if (graphics)
90
- ctx.draw(graphics);
91
- }
92
- }
93
- /** See {@link FullWaveform.paintFor} — a voice is a hue, never a gradient. */
94
- paintFor(key) {
95
- if (key === "all")
96
- return this.fill;
97
- const voice = Number(key.slice("voice:".length));
98
- if (!Number.isFinite(voice) || voice < 0)
99
- return this.fill;
100
- return this.voiceColors[voice] ?? voiceColor(voice);
37
+ export const LiveWaveform = component2d({
38
+ key: "liveWaveform",
39
+ state: {
40
+ /** The baked recording. See {@link AudioEnvelope} for why it is baked. */
41
+ envelope: Types.custom(EMPTY_ENVELOPE),
42
+ /** How many bars the visualiser is made of. */
43
+ bars: 48,
44
+ /** Space between bars, as a fraction of the pitch. */
45
+ gap: 0.35,
46
+ radius: 4,
47
+ /** How many seconds of audio are on screen at once. */
48
+ window: 3,
49
+ /** Seconds into the file the node's first frame shows. */
50
+ offset: 0,
51
+ /** Advance with the scene clock. Off freezes the picture at `offset`. */
52
+ playing: true,
53
+ /** Multiplies every magnitude before it is clamped. */
54
+ gain: 1.4,
55
+ /** How much of the box a silent bar still occupies, `0`–`1`. */
56
+ floor: 0.04,
57
+ align: Types.custom("center"),
58
+ style: Types.custom("bars"),
59
+ /**
60
+ * Show only this voice's activity, by index into the recording's own
61
+ * numbering. `-1` — the default — is every voice.
62
+ */
63
+ speaker: -1,
64
+ /** Colour each bar by whoever is speaking in it. */
65
+ byVoice: false,
66
+ /** A colour per voice index. Short or empty falls back to the palette. */
67
+ voiceColors: Types.custom([]),
68
+ fill: Types.custom("#6366f1", { resolve: fillOps.resolve, lerp: fillOps.lerp }),
69
+ },
70
+ // Nothing declares a component's paints but itself.
71
+ load: (loader, state) => loader.fill(state.fill),
72
+ render: (ctx, state) => {
73
+ drawBars(ctx, state);
74
+ ctx.children();
75
+ },
76
+ });
77
+ /**
78
+ * The second of the recording the visualiser is showing.
79
+ *
80
+ * Off the node's own clock rather than the scene's, which is what "from the
81
+ * moment this node appeared" means — the same clock the engine's own
82
+ * `Video` times its picture from, and the same one that makes a node dropped
83
+ * halfway through a clip start its recording at its entrance rather than
84
+ * partway in.
85
+ */
86
+ function at(ctx, s) {
87
+ return s.offset + (s.playing ? Math.max(0, ctx.time.elapsed) : 0);
88
+ }
89
+ function drawBars(ctx, s) {
90
+ const { width, height } = ctx.size;
91
+ if (width <= 0 || height <= 0)
92
+ return;
93
+ const count = Math.max(1, Math.round(s.bars));
94
+ const span = Math.max(0.05, s.window);
95
+ const now = at(ctx, s);
96
+ const voice = s.speaker < 0 ? null : Math.round(s.speaker);
97
+ // The window is centred on the playhead, so the bars run *toward* the
98
+ // middle and away again — the arrangement every mixer's meter uses, and the
99
+ // one that reads as sound arriving rather than as a strip scrolling past.
100
+ const sampled = forSpeaker(sampleEnvelope(s.envelope, now - span / 2, now + span / 2, count), voice);
101
+ const shaped = s.style === "line" ? taper(sampled) : sampled;
102
+ const boxes = layOutBars(shaped, {
103
+ width,
104
+ height,
105
+ gap: s.style === "blocks" ? 0.12 : s.gap,
106
+ align: s.align,
107
+ gain: s.gain,
108
+ floor: s.floor,
109
+ });
110
+ if (boxes.length === 0)
111
+ return;
112
+ const groups = groupByPaint(boxes, (i) => livePaintKey(shaped[i].speaker, s.byVoice, voice));
113
+ for (const [key, run] of groups) {
114
+ const graphics = paintBars(run, paintFor(s, key), s.radius);
115
+ if (graphics)
116
+ ctx.draw(graphics);
101
117
  }
102
- };
103
- __decorate([
104
- property({ default: EMPTY_ENVELOPE })
105
- ], LiveWaveform.prototype, "envelope", void 0);
106
- __decorate([
107
- property({ default: 48 })
108
- ], LiveWaveform.prototype, "bars", void 0);
109
- __decorate([
110
- property({ default: 0.35 })
111
- ], LiveWaveform.prototype, "gap", void 0);
112
- __decorate([
113
- property({ default: 4 })
114
- ], LiveWaveform.prototype, "radius", void 0);
115
- __decorate([
116
- property({ default: 3 })
117
- ], LiveWaveform.prototype, "window", void 0);
118
- __decorate([
119
- property({ default: 0 })
120
- ], LiveWaveform.prototype, "offset", void 0);
121
- __decorate([
122
- property({ default: true })
123
- ], LiveWaveform.prototype, "playing", void 0);
124
- __decorate([
125
- property({ default: 1.4 })
126
- ], LiveWaveform.prototype, "gain", void 0);
127
- __decorate([
128
- property({ default: 0.04 })
129
- ], LiveWaveform.prototype, "floor", void 0);
130
- __decorate([
131
- property({ default: "center" })
132
- ], LiveWaveform.prototype, "align", void 0);
133
- __decorate([
134
- property({ default: "bars" })
135
- ], LiveWaveform.prototype, "style", void 0);
136
- __decorate([
137
- property({ default: -1 })
138
- ], LiveWaveform.prototype, "speaker", void 0);
139
- __decorate([
140
- property({ default: false })
141
- ], LiveWaveform.prototype, "byVoice", void 0);
142
- __decorate([
143
- property({ default: [] })
144
- ], LiveWaveform.prototype, "voiceColors", void 0);
145
- __decorate([
146
- property({
147
- default: "#6366f1",
148
- mapper: fillOps.resolve,
149
- tween: fillOps.lerp,
150
- })
151
- ], LiveWaveform.prototype, "fill", void 0);
152
- LiveWaveform = __decorate([
153
- node({
154
- key: "liveWaveform",
155
- parentKey: "node",
156
- forkable: true,
157
- layout: {
158
- children: "freeform",
159
- defaultWidthMode: "fixed",
160
- defaultHeightMode: "fixed",
161
- acceptsChildren: true,
162
- },
163
- seed: {
164
- width: 420,
165
- height: 220,
166
- },
167
- })
168
- ], LiveWaveform);
169
- export { LiveWaveform };
118
+ }
119
+ /** See `FullWaveform`'s paints — a voice is a hue, never a gradient. */
120
+ function paintFor(s, key) {
121
+ if (key === "all")
122
+ return s.fill;
123
+ const voice = Number(key.slice("voice:".length));
124
+ if (!Number.isFinite(voice) || voice < 0)
125
+ return s.fill;
126
+ return s.voiceColors[voice] ?? voiceColor(voice);
127
+ }
170
128
  /**
171
129
  * Rolls the ends of a window off toward silence.
172
130
  *
@@ -1 +1 @@
1
- {"version":3,"file":"live-waveform.js","sourceRoot":"","sources":["../../src/waveform/live-waveform.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EACL,MAAM,EACN,IAAI,EACJ,OAAO,EACP,QAAQ,GAKT,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAC3D,OAAO,EACL,cAAc,EACd,UAAU,EACV,cAAc,GAGf,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,OAAO,EACP,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,SAAS,EACT,UAAU,GAGX,MAAM,UAAU,CAAA;AAkCjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAgBI,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,MAAyB;IAuBhD,aAAa,CAA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O,CAAC,OAAO;QACvB,KAAK,EAAE,OAAO,CAAC,IAAI;KACpB,CAAC;0CACgB;AArBP,YAAY;IAfxB,IAAI,CAAC;QACJ,GAAG,EAAE,cAAc;QACnB,SAAS,EAAE,MAAM;QACjB,QAAQ,EAAE,IAAI;QACd,MAAM,EAAE;YACN,QAAQ,EAAE,UAAU;YACpB,gBAAgB,EAAE,OAAO;YACzB,iBAAiB,EAAE,OAAO;YAC1B,eAAe,EAAE,IAAI;SACtB;QACD,IAAI,EAAE;YACJ,KAAK,EAAE,GAAG;YACV,MAAM,EAAE,GAAG;SACZ;KACF,CAAC;GACW,YAAY,CAwFxB;;AAED;;;;;;;;;GASG;AACH,SAAS,KAAK,CAAC,IAA4B;IACzC,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAA;IACzB,IAAI,KAAK,GAAG,CAAC;QAAE,OAAO,CAAC,GAAG,IAAI,CAAC,CAAA;IAC/B,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAA;IAE/C,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE;QACzB,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,GAAG,CAAC,CAAC,CAAA;QAC1C,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAAA;QACtC,OAAO,EAAE,SAAS,EAAE,GAAG,CAAC,SAAS,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,CAAA;IACpE,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import {\r\n Node2D,\r\n node,\r\n fillOps,\r\n property,\r\n type AssetScope,\r\n type Fill,\r\n type Node2DProps,\r\n type RenderContext2D,\r\n} from \"@motionscript/sdk\"\r\n\r\nimport { declarePaints } from \"@motionscript/sdk/component\"\r\nimport {\r\n EMPTY_ENVELOPE,\r\n forSpeaker,\r\n sampleEnvelope,\r\n type AudioEnvelope,\r\n type EnvelopeBar,\r\n} from \"./envelope\"\r\nimport {\r\n clamp01,\r\n groupByPaint,\r\n layOutBars,\r\n livePaintKey,\r\n paintBars,\r\n voiceColor,\r\n type WaveformAlignment,\r\n type WaveformStyle,\r\n} from \"./shared\"\r\n\r\nexport interface LiveWaveformProps extends Node2DProps {\r\n /** The baked recording. See {@link AudioEnvelope} for why it is baked. */\r\n envelope: AudioEnvelope\r\n /** How many bars the visualiser is made of. */\r\n bars: number\r\n /** Space between bars, as a fraction of the pitch. */\r\n gap: number\r\n radius: number\r\n /** How many seconds of audio are on screen at once. */\r\n window: number\r\n /** Seconds into the file the node's first frame shows. */\r\n offset: number\r\n /** Advance with the scene clock. Off freezes the picture at {@link offset}. */\r\n playing: boolean\r\n /** Multiplies every magnitude before it is clamped. */\r\n gain: number\r\n /** How much of the box a silent bar still occupies, `0`–`1`. */\r\n floor: number\r\n align: WaveformAlignment\r\n style: WaveformStyle\r\n /**\r\n * Show only this voice's activity, by index into the recording's own\r\n * numbering. `-1` — the default — is every voice.\r\n */\r\n speaker: number\r\n /** Colour each bar by whoever is speaking in it. */\r\n byVoice: boolean\r\n /** A colour per voice index. Short or empty falls back to the palette. */\r\n voiceColors: string[]\r\n fill: Fill\r\n}\r\n\r\n/**\r\n * A **live audio visualiser**: bars that move with the recording as it plays.\r\n *\r\n * The thing every podcast-to-video tool puts beside the artwork. It is not a\r\n * picture of the file — that is {@link FullWaveform} — it is a picture of *this\r\n * moment*, and what it is for is making a static frame of a talking head feel\r\n * like it is playing.\r\n *\r\n * ## \"Live\" without listening\r\n *\r\n * Nothing here reads an audio device. The bars are sampled out of a baked\r\n * envelope at the node's own elapsed time, which is what makes the visualiser\r\n * survive the thing it exists for: an **export**, where there is no playback to\r\n * analyse and frames may be rendered out of order or in parallel. A frame is a\r\n * pure function of its time, so scrubbing back and forth over the visualiser\r\n * redraws exactly what it drew the first time — which an analyser node, by\r\n * construction, cannot promise. See {@link AudioEnvelope}.\r\n *\r\n * ## The speaker filter\r\n *\r\n * {@link speaker} narrows the node to one voice of a diarized recording, and it\r\n * is the reason this node knows about transcripts at all. Two visualisers beside\r\n * two headshots, each filtered to its own host, is a podcast edit that would\r\n * otherwise be done by hand for every turn — and because the filter *silences*\r\n * rather than skips (see {@link forSpeaker}), the quiet host visibly stops\r\n * talking instead of vanishing. Nothing about that requires the words: only who\r\n * is talking when, which is what the diarizer produces.\r\n *\r\n * A filter naming a voice the recording doesn't have draws a resting row rather\r\n * than everything — a picture of \"this person never speaks here\", which is\r\n * true, where falling back to the unfiltered mix would be a silent lie about\r\n * whose voice you were watching.\r\n */\r\n@node({\r\n key: \"liveWaveform\",\r\n parentKey: \"node\",\r\n forkable: true,\r\n layout: {\r\n children: \"freeform\",\r\n defaultWidthMode: \"fixed\",\r\n defaultHeightMode: \"fixed\",\r\n acceptsChildren: true,\r\n },\r\n seed: {\r\n width: 420,\r\n height: 220,\r\n },\r\n})\r\nexport class LiveWaveform extends Node2D<LiveWaveformProps> {\r\n @property({ default: EMPTY_ENVELOPE }) declare envelope: AudioEnvelope\r\n @property({ default: 48 }) declare bars: number\r\n @property({ default: 0.35 }) declare gap: number\r\n @property({ default: 4 }) declare radius: number\r\n @property({ default: 3 }) declare window: number\r\n @property({ default: 0 }) declare offset: number\r\n @property({ default: true }) declare playing: boolean\r\n @property({ default: 1.4 }) declare gain: number\r\n @property({ default: 0.04 }) declare floor: number\r\n @property({ default: \"center\" }) declare align: WaveformAlignment\r\n @property({ default: \"bars\" }) declare style: WaveformStyle\r\n @property({ default: -1 }) declare speaker: number\r\n @property({ default: false }) declare byVoice: boolean\r\n @property({ default: [] }) declare voiceColors: string[]\r\n\r\n @property({\r\n default: \"#6366f1\",\r\n mapper: fillOps.resolve,\r\n tween: fillOps.lerp,\r\n })\r\n declare fill: Fill\r\n\r\n override declareAssets(assets: AssetScope): void {\r\n super.declareAssets(assets)\r\n declarePaints(this, assets)\r\n }\r\n\r\n /**\r\n * The second of the recording the visualiser is showing.\r\n *\r\n * Off the node's own clock rather than the scene's, which is what \"from the\r\n * moment this node appeared\" means — the same clock the engine's own\r\n * `Video` times its picture from, and the same one that makes a node dropped\r\n * halfway through a clip start its recording at its entrance rather than\r\n * partway in.\r\n */\r\n private get at(): number {\r\n return this.offset + (this.playing ? Math.max(0, this.time.elapsed) : 0)\r\n }\r\n\r\n protected renderSelf(ctx: RenderContext2D): void {\r\n const rect = this.layoutBounds\r\n const width = rect?.width ?? 0\r\n const height = rect?.height ?? 0\r\n if (width <= 0 || height <= 0) return\r\n\r\n const count = Math.max(1, Math.round(this.bars))\r\n const span = Math.max(0.05, this.window)\r\n const at = this.at\r\n const voice = this.speaker < 0 ? null : Math.round(this.speaker)\r\n\r\n // The window is centred on the playhead, so the bars run *toward* the\r\n // middle and away again — the arrangement every mixer's meter uses, and the\r\n // one that reads as sound arriving rather than as a strip scrolling past.\r\n const sampled = forSpeaker(\r\n sampleEnvelope(this.envelope, at - span / 2, at + span / 2, count),\r\n voice\r\n )\r\n\r\n const shaped = this.style === \"line\" ? taper(sampled) : sampled\r\n const boxes = layOutBars(shaped, {\r\n width,\r\n height,\r\n gap: this.style === \"blocks\" ? 0.12 : this.gap,\r\n align: this.align,\r\n gain: this.gain,\r\n floor: this.floor,\r\n })\r\n if (boxes.length === 0) return\r\n\r\n const groups = groupByPaint(boxes, (i) =>\r\n livePaintKey(shaped[i].speaker, this.byVoice, voice)\r\n )\r\n\r\n for (const [key, run] of groups) {\r\n const graphics = paintBars(run, this.paintFor(key), this.radius)\r\n if (graphics) ctx.draw(graphics)\r\n }\r\n }\r\n\r\n /** See {@link FullWaveform.paintFor} — a voice is a hue, never a gradient. */\r\n private paintFor(key: string): Fill {\r\n if (key === \"all\") return this.fill\r\n const voice = Number(key.slice(\"voice:\".length))\r\n if (!Number.isFinite(voice) || voice < 0) return this.fill\r\n return this.voiceColors[voice] ?? voiceColor(voice)\r\n }\r\n}\r\n\r\n/**\r\n * Rolls the ends of a window off toward silence.\r\n *\r\n * What separates the `line` style from `bars`: a hard-edged window makes the\r\n * loud bar entering at the right edge appear from nothing, which reads as a\r\n * glitch rather than as sound arriving. Fading the outer fifth turns the same\r\n * data into a shape that grows out of the baseline — the profile a spectrum\r\n * display has, and the reason it looks like one object rather than a row of\r\n * separate meters.\r\n */\r\nfunction taper(bars: readonly EnvelopeBar[]): EnvelopeBar[] {\r\n const count = bars.length\r\n if (count < 3) return [...bars]\r\n const edge = Math.max(1, Math.floor(count / 5))\r\n\r\n return bars.map((bar, i) => {\r\n const fromEnd = Math.min(i, count - 1 - i)\r\n const weight = clamp01(fromEnd / edge)\r\n return { magnitude: bar.magnitude * weight, speaker: bar.speaker }\r\n })\r\n}\r\n"]}
1
+ {"version":3,"file":"live-waveform.js","sourceRoot":"","sources":["../../src/waveform/live-waveform.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,WAAW,EACX,OAAO,GAQR,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EACL,cAAc,EACd,UAAU,EACV,cAAc,GAGf,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,OAAO,EACP,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,SAAS,EACT,UAAU,GAGX,MAAM,UAAU,CAAA;AAEjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,WAAW,CAAC;IACtC,GAAG,EAAE,cAAc;IACnB,KAAK,EAAE;QACL,0EAA0E;QAC1E,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAgB,cAAc,CAAC;QACrD,+CAA+C;QAC/C,IAAI,EAAE,EAAE;QACR,sDAAsD;QACtD,GAAG,EAAE,IAAI;QACT,MAAM,EAAE,CAAC;QACT,uDAAuD;QACvD,MAAM,EAAE,CAAC;QACT,0DAA0D;QAC1D,MAAM,EAAE,CAAC;QACT,yEAAy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CAAC,EAAE,KAAK,GAAG,CAAC,GAAG,CAAC,CAAC,CAAA;QAC1C,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAAA;QACtC,OAAO,EAAE,SAAS,EAAE,GAAG,CAAC,SAAS,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,CAAA;IACpE,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import {\r\n Types,\r\n component2d,\r\n fillOps,\r\n type Fill,\r\n type FillResolved,\r\n type NodeOf,\r\n type RenderContext,\r\n // Named so the emitted declaration reaches these through the sdk, not core.\r\n type Node2D as _Node2D,\r\n type Node2DProps as _Node2DProps,\r\n} from \"@motionscript/sdk\"\r\n\r\nimport {\r\n EMPTY_ENVELOPE,\r\n forSpeaker,\r\n sampleEnvelope,\r\n type AudioEnvelope,\r\n type EnvelopeBar,\r\n} from \"./envelope\"\r\nimport {\r\n clamp01,\r\n groupByPaint,\r\n layOutBars,\r\n livePaintKey,\r\n paintBars,\r\n voiceColor,\r\n type WaveformAlignment,\r\n type WaveformStyle,\r\n} from \"./shared\"\r\n\r\n/**\r\n * A **live audio visualiser**: bars that move with the recording as it plays.\r\n *\r\n * The thing every podcast-to-video tool puts beside the artwork. It is not a\r\n * picture of the file — that is {@link FullWaveform} — it is a picture of *this\r\n * moment*, and what it is for is making a static frame of a talking head feel\r\n * like it is playing.\r\n *\r\n * ## \"Live\" without listening\r\n *\r\n * Nothing here reads an audio device. The bars are sampled out of a baked\r\n * envelope at the node's own elapsed time, which is what makes the visualiser\r\n * survive the thing it exists for: an **export**, where there is no playback to\r\n * analyse and frames may be rendered out of order or in parallel. A frame is a\r\n * pure function of its time, so scrubbing back and forth over the visualiser\r\n * redraws exactly what it drew the first time — which an analyser node, by\r\n * construction, cannot promise. See {@link AudioEnvelope}.\r\n *\r\n * ## The speaker filter\r\n *\r\n * `speaker` narrows the node to one voice of a diarized recording, and it\r\n * is the reason this node knows about transcripts at all. Two visualisers beside\r\n * two headshots, each filtered to its own host, is a podcast edit that would\r\n * otherwise be done by hand for every turn — and because the filter *silences*\r\n * rather than skips (see {@link forSpeaker}), the quiet host visibly stops\r\n * talking instead of vanishing. Nothing about that requires the words: only who\r\n * is talking when, which is what the diarizer produces.\r\n *\r\n * A filter naming a voice the recording doesn't have draws a resting row rather\r\n * than everything — a picture of \"this person never speaks here\", which is\r\n * true, where falling back to the unfiltered mix would be a silent lie about\r\n * whose voice you were watching.\r\n */\r\nexport const LiveWaveform = component2d({\r\n key: \"liveWaveform\",\r\n state: {\r\n /** The baked recording. See {@link AudioEnvelope} for why it is baked. */\r\n envelope: Types.custom<AudioEnvelope>(EMPTY_ENVELOPE),\r\n /** How many bars the visualiser is made of. */\r\n bars: 48,\r\n /** Space between bars, as a fraction of the pitch. */\r\n gap: 0.35,\r\n radius: 4,\r\n /** How many seconds of audio are on screen at once. */\r\n window: 3,\r\n /** Seconds into the file the node's first frame shows. */\r\n offset: 0,\r\n /** Advance with the scene clock. Off freezes the picture at `offset`. */\r\n playing: true,\r\n /** Multiplies every magnitude before it is clamped. */\r\n gain: 1.4,\r\n /** How much of the box a silent bar still occupies, `0`–`1`. */\r\n floor: 0.04,\r\n align: Types.custom<WaveformAlignment>(\"center\"),\r\n style: Types.custom<WaveformStyle>(\"bars\"),\r\n /**\r\n * Show only this voice's activity, by index into the recording's own\r\n * numbering. `-1` — the default — is every voice.\r\n */\r\n speaker: -1,\r\n /** Colour each bar by whoever is speaking in it. */\r\n byVoice: false,\r\n /** A colour per voice index. Short or empty falls back to the palette. */\r\n voiceColors: Types.custom<string[]>([]),\r\n fill: Types.custom<Fill, FillResolved[]>(\"#6366f1\", { resolve: fillOps.resolve, lerp: fillOps.lerp }),\r\n },\r\n // Nothing declares a component's paints but itself.\r\n load: (loader, state) => loader.fill(state.fill),\r\n render: (ctx, state) => {\r\n drawBars(ctx, state)\r\n ctx.children()\r\n },\r\n})\r\n\r\nexport type LiveWaveform = NodeOf<typeof LiveWaveform>\r\nexport type LiveWaveformProps = NonNullable<Parameters<typeof LiveWaveform>[0]>\r\n\r\ninterface LiveState {\r\n readonly envelope: AudioEnvelope\r\n readonly bars: number\r\n readonly gap: number\r\n readonly radius: number\r\n readonly window: number\r\n readonly offset: number\r\n readonly playing: boolean\r\n readonly gain: number\r\n readonly floor: number\r\n readonly align: WaveformAlignment\r\n readonly style: WaveformStyle\r\n readonly speaker: number\r\n readonly byVoice: boolean\r\n readonly voiceColors: string[]\r\n readonly fill: FillResolved[]\r\n}\r\n\r\n/**\r\n * The second of the recording the visualiser is showing.\r\n *\r\n * Off the node's own clock rather than the scene's, which is what \"from the\r\n * moment this node appeared\" means — the same clock the engine's own\r\n * `Video` times its picture from, and the same one that makes a node dropped\r\n * halfway through a clip start its recording at its entrance rather than\r\n * partway in.\r\n */\r\nfunction at(ctx: RenderContext, s: LiveState): number {\r\n return s.offset + (s.playing ? Math.max(0, ctx.time.elapsed) : 0)\r\n}\r\n\r\nfunction drawBars(ctx: RenderContext, s: LiveState): void {\r\n const { width, height } = ctx.size\r\n if (width <= 0 || height <= 0) return\r\n\r\n const count = Math.max(1, Math.round(s.bars))\r\n const span = Math.max(0.05, s.window)\r\n const now = at(ctx, s)\r\n const voice = s.speaker < 0 ? null : Math.round(s.speaker)\r\n\r\n // The window is centred on the playhead, so the bars run *toward* the\r\n // middle and away again — the arrangement every mixer's meter uses, and the\r\n // one that reads as sound arriving rather than as a strip scrolling past.\r\n const sampled = forSpeaker(\r\n sampleEnvelope(s.envelope, now - span / 2, now + span / 2, count),\r\n voice\r\n )\r\n\r\n const shaped = s.style === \"line\" ? taper(sampled) : sampled\r\n const boxes = layOutBars(shaped, {\r\n width,\r\n height,\r\n gap: s.style === \"blocks\" ? 0.12 : s.gap,\r\n align: s.align,\r\n gain: s.gain,\r\n floor: s.floor,\r\n })\r\n if (boxes.length === 0) return\r\n\r\n const groups = groupByPaint(boxes, (i) =>\r\n livePaintKey(shaped[i].speaker, s.byVoice, voice)\r\n )\r\n\r\n for (const [key, run] of groups) {\r\n const graphics = paintBars(run, paintFor(s, key), s.radius)\r\n if (graphics) ctx.draw(graphics)\r\n }\r\n}\r\n\r\n/** See `FullWaveform`'s paints — a voice is a hue, never a gradient. */\r\nfunction paintFor(s: LiveState, key: string): Fill {\r\n if (key === \"all\") return s.fill\r\n const voice = Number(key.slice(\"voice:\".length))\r\n if (!Number.isFinite(voice) || voice < 0) return s.fill\r\n return s.voiceColors[voice] ?? voiceColor(voice)\r\n}\r\n\r\n/**\r\n * Rolls the ends of a window off toward silence.\r\n *\r\n * What separates the `line` style from `bars`: a hard-edged window makes the\r\n * loud bar entering at the right edge appear from nothing, which reads as a\r\n * glitch rather than as sound arriving. Fading the outer fifth turns the same\r\n * data into a shape that grows out of the baseline — the profile a spectrum\r\n * display has, and the reason it looks like one object rather than a row of\r\n * separate meters.\r\n */\r\nfunction taper(bars: readonly EnvelopeBar[]): EnvelopeBar[] {\r\n const count = bars.length\r\n if (count < 3) return [...bars]\r\n const edge = Math.max(1, Math.floor(count / 5))\r\n\r\n return bars.map((bar, i) => {\r\n const fromEnd = Math.min(i, count - 1 - i)\r\n const weight = clamp01(fromEnd / edge)\r\n return { magnitude: bar.magnitude * weight, speaker: bar.speaker }\r\n })\r\n}\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@motionscript/audio",
3
- "version": "0.1.0-alpha.5",
3
+ "version": "0.1.0-alpha.6",
4
4
  "type": "module",
5
5
  "description": "Waveform components for Motion Script: a full recording drawn as bars, and a live meter that moves with playback. Both draw a loudness envelope the host supplies.",
6
6
  "repository": {
@@ -49,7 +49,7 @@
49
49
  ],
50
50
  "license": "Apache-2.0",
51
51
  "peerDependencies": {
52
- "@motionscript/sdk": "^0.1.0-alpha.5"
52
+ "@motionscript/sdk": "^0.1.0-alpha.6"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@types/node": "^25.6.2",
@@ -60,8 +60,8 @@
60
60
  "typescript": "^6.0.3",
61
61
  "typescript-eslint": "^8.48.0",
62
62
  "vitest": "^4.1.5",
63
- "@motionscript/core": "0.1.0-alpha.5",
64
- "@motionscript/sdk": "0.1.0-alpha.5"
63
+ "@motionscript/sdk": "0.1.0-alpha.6",
64
+ "@motionscript/core": "0.1.0-alpha.6"
65
65
  },
66
66
  "scripts": {
67
67
  "build": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json --resolve-full-paths && node ../../../scripts/build-browser.mjs",
package/src/nodes.ts CHANGED
@@ -5,15 +5,13 @@ import { LiveWaveform } from "./waveform/live-waveform";
5
5
  * Every node type this package publishes.
6
6
  *
7
7
  * A host registers these by handing the array to an engine —
8
- * `new Engine(platform, { nodes: NODES })` — which reads each class's `@node()`
9
- * key. The decorator only *declares* that key: nothing is registered by the mere
10
- * act of importing a module, so a registry holds exactly what its owner asked
11
- * for and two engines in one process can differ about it.
8
+ * `new Engine(platform, { nodes: NODES })` — which reads each component's key.
9
+ * Defining a component only *declares* that key: nothing is registered by
10
+ * importing a module, so a registry holds exactly what its owner asked for.
12
11
  *
13
- * Listing class **values** is also what survives bundling. This package declares
14
- * `sideEffects: false`, which licenses a bundler to drop a module nothing
15
- * imports a value from, and a document names a node type by string — so
16
- * `import "./waveform/full-waveform"` for its side effect is exactly what gets shaken out, where an
17
- * array of bindings is a data dependency that cannot be.
12
+ * Listing the component **values** is also what survives bundling: this package
13
+ * declares `sideEffects: false`, and a document names a node type by string, so
14
+ * an import kept only for its side effect is exactly what gets shaken out.
18
15
  */
19
- export const NODES = [FullWaveform, LiveWaveform];
16
+ // Typed by name, so the declaration names each component rather than spelling out its type through core.
17
+ export const NODES: (typeof FullWaveform | typeof LiveWaveform)[] = [FullWaveform, LiveWaveform];