@motionscript/browser 0.1.0 → 0.1.1-alpha.0

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.
Files changed (102) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/asset-bytes.d.ts +12 -50
  3. package/dist/asset-bytes.d.ts.map +1 -1
  4. package/dist/asset-bytes.js +20 -52
  5. package/dist/asset-bytes.js.map +1 -1
  6. package/dist/audio/bus-graph.d.ts +4 -39
  7. package/dist/audio/bus-graph.d.ts.map +1 -1
  8. package/dist/audio/bus-graph.js +4 -38
  9. package/dist/audio/bus-graph.js.map +1 -1
  10. package/dist/audio/effect-graph.d.ts +4 -29
  11. package/dist/audio/effect-graph.d.ts.map +1 -1
  12. package/dist/audio/effect-graph.js +4 -31
  13. package/dist/audio/effect-graph.js.map +1 -1
  14. package/dist/audio/loop-region.d.ts +3 -21
  15. package/dist/audio/loop-region.d.ts.map +1 -1
  16. package/dist/audio/loop-region.js +3 -21
  17. package/dist/audio/loop-region.js.map +1 -1
  18. package/dist/audio/mixer.d.ts +9 -41
  19. package/dist/audio/mixer.d.ts.map +1 -1
  20. package/dist/audio/mixer.js +11 -44
  21. package/dist/audio/mixer.js.map +1 -1
  22. package/dist/audio/player.d.ts +3 -17
  23. package/dist/audio/player.d.ts.map +1 -1
  24. package/dist/audio/player.js +4 -23
  25. package/dist/audio/player.js.map +1 -1
  26. package/dist/browser/audio.js +1 -1
  27. package/dist/browser/chunks/chunk-NDJYMKIV.js +2 -0
  28. package/dist/browser/chunks/chunk-NDJYMKIV.js.map +7 -0
  29. package/dist/browser/index.js +19 -19
  30. package/dist/browser/index.js.map +4 -4
  31. package/dist/browser/manifest.json +1 -1
  32. package/dist/browser/ms_renderer_bg.wasm +0 -0
  33. package/dist/concat.d.ts +25 -84
  34. package/dist/concat.d.ts.map +1 -1
  35. package/dist/concat.js +19 -69
  36. package/dist/concat.js.map +1 -1
  37. package/dist/dynamic-nodes.d.ts +1 -6
  38. package/dist/dynamic-nodes.d.ts.map +1 -1
  39. package/dist/dynamic-nodes.js +3 -24
  40. package/dist/dynamic-nodes.js.map +1 -1
  41. package/dist/engine.d.ts +9 -42
  42. package/dist/engine.d.ts.map +1 -1
  43. package/dist/engine.js +10 -44
  44. package/dist/engine.js.map +1 -1
  45. package/dist/export-audio.d.ts +1 -6
  46. package/dist/export-audio.d.ts.map +1 -1
  47. package/dist/export-audio.js +1 -6
  48. package/dist/export-audio.js.map +1 -1
  49. package/dist/exporter.d.ts +28 -141
  50. package/dist/exporter.d.ts.map +1 -1
  51. package/dist/exporter.js +15 -90
  52. package/dist/exporter.js.map +1 -1
  53. package/dist/frame-loop.d.ts +19 -105
  54. package/dist/frame-loop.d.ts.map +1 -1
  55. package/dist/frame-loop.js +20 -82
  56. package/dist/frame-loop.js.map +1 -1
  57. package/dist/index.d.ts +1 -0
  58. package/dist/index.d.ts.map +1 -1
  59. package/dist/index.js +7 -15
  60. package/dist/index.js.map +1 -1
  61. package/dist/mix-timeline-audio.d.ts +7 -24
  62. package/dist/mix-timeline-audio.d.ts.map +1 -1
  63. package/dist/mix-timeline-audio.js +7 -23
  64. package/dist/mix-timeline-audio.js.map +1 -1
  65. package/dist/native-export.d.ts +29 -0
  66. package/dist/native-export.d.ts.map +1 -0
  67. package/dist/native-export.js +99 -0
  68. package/dist/native-export.js.map +1 -0
  69. package/dist/parallel/export-parallel.d.ts +2 -16
  70. package/dist/parallel/export-parallel.d.ts.map +1 -1
  71. package/dist/parallel/export-parallel.js +1 -11
  72. package/dist/parallel/export-parallel.js.map +1 -1
  73. package/dist/parallel/governor.d.ts +2 -15
  74. package/dist/parallel/governor.d.ts.map +1 -1
  75. package/dist/parallel/governor.js +1 -5
  76. package/dist/parallel/governor.js.map +1 -1
  77. package/dist/parallel/lane.d.ts +1 -5
  78. package/dist/parallel/lane.d.ts.map +1 -1
  79. package/dist/parallel/lane.js.map +1 -1
  80. package/dist/parallel/plan.d.ts +3 -7
  81. package/dist/parallel/plan.d.ts.map +1 -1
  82. package/dist/parallel/plan.js +1 -6
  83. package/dist/parallel/plan.js.map +1 -1
  84. package/dist/parallel/run-lanes.d.ts +4 -18
  85. package/dist/parallel/run-lanes.d.ts.map +1 -1
  86. package/dist/parallel/run-lanes.js +1 -12
  87. package/dist/parallel/run-lanes.js.map +1 -1
  88. package/dist/screenshot.d.ts +1 -12
  89. package/dist/screenshot.d.ts.map +1 -1
  90. package/dist/screenshot.js +1 -12
  91. package/dist/screenshot.js.map +1 -1
  92. package/dist/still.d.ts +17 -74
  93. package/dist/still.d.ts.map +1 -1
  94. package/dist/still.js +13 -50
  95. package/dist/still.js.map +1 -1
  96. package/dist/ticker.d.ts +10 -39
  97. package/dist/ticker.d.ts.map +1 -1
  98. package/dist/ticker.js +13 -45
  99. package/dist/ticker.js.map +1 -1
  100. package/package.json +4 -4
  101. package/dist/browser/chunks/chunk-F3AZKPHU.js +0 -2
  102. package/dist/browser/chunks/chunk-F3AZKPHU.js.map +0 -7
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # @motionscript/browser
2
2
 
3
+ ## 0.1.1-alpha.0
4
+
5
+ ### Patch Changes
6
+
7
+ - e279864: **Breaking:** the deprecated shims and dead exports are gone. Core drops the `SceneDocument`, `SceneEffect`, `SceneTimeline`, `integrateSpeedToSceneTime` and `sourceTimeAtSceneElapsed` aliases, `Sound.sceneDurationFor`, the `Precomp*` aliases of the asset-timeline names, `ImageFilters` and `VideoFilters` (use `Adjustments` and `VideoAdjustments`), `PropertyMeta.withdrawn`, `AssetTimelineOptions.lifespans`, and the unused `opacity` and `blend` of per-shape descriptors (`ShapeState`). The `filters` prop of image and video fills is removed too: write the grade as `preset: { adjustments }`. Documents move to format 3, and opening one that carries `filters` on a media fill moves it into `preset.adjustments`. Also removed as unused: `sampleParam`, `IDENTITY_AFFINE3`, `neutralPreset`, `resolveMediaPreset`'s second argument, `paramAtDistance`, `arcPointFunction`, `segmentChord`, `isStyleOnlySegment`, `withTransformDescriptor`, `easeKey`, `isParentNode`, `AudioParams`, `ResolvedSoundProps`, `StarProps`, `RotatedBoxProps`, `ModelView3DProps` and `NumberNodeFormat`. In headless, `Semaphore`, `withDeadline`, `toRenderError` and `cleanPageErrorMessage` were internal and are deleted.
8
+
9
+ Migration: a stored document needs nothing done to it. Opening a format 2 document moves a media fill's `filters` into `preset.adjustments` (dropped where `preset.adjustments` already states the grade), and saving it writes format 3. Code that named a removed export uses what it aliased: `Adjustments` for `ImageFilters`, `VideoAdjustments` for `VideoFilters`, and the asset-timeline names for the `Precomp*` aliases.
10
+
11
+ - e9db554: An asset is downloaded and decoded once while it is loading, however many ask for it: the weights of one font family share its files (each weight used to fetch the whole family), two draws of one image or video share one decode, and every session, still and export on a page shares one request per source (`loadAssetBytes`, which the audio mix now goes through as well). A load that fails is asked for again next time.
12
+ - Updated dependencies [3630b74]
13
+ - Updated dependencies [1c43a37]
14
+ - Updated dependencies [6b89575]
15
+ - Updated dependencies [e279864]
16
+ - Updated dependencies [e279864]
17
+ - Updated dependencies [e9db554]
18
+ - Updated dependencies [7cd4e53]
19
+ - @motionscript/core@0.1.1-alpha.0
20
+ - @motionscript/renderer@0.1.1-alpha.0
21
+
3
22
  ## 0.1.0
4
23
 
5
24
  ### Patch Changes
@@ -1,59 +1,21 @@
1
1
  /**
2
- * Where a source URL's bytes come from: a host's local store, then the network.
3
- * The renderer's storage adapter reads every asset through it (`loadBytes`).
4
- *
5
- * ## Why the web adapter needs this at all
6
- *
7
- * The storage adapter addresses every asset by URL and fetches it. That is
8
- * right for an asset that lives somewhere, and wrong for one whose bytes the
9
- * host already has in hand — a file the user has just chosen, a render a local
10
- * model has just produced, a picture whose upload has not finished or cannot
11
- * start because there is no network. In all three the adapter downloads bytes
12
- * that never needed to travel.
13
- *
14
- * `NodeStorageAdapter` has had the answer since it was written: an injected
15
- * `AssetLoader`, with an `inline` map consulted ahead of the disk. This is the
16
- * same seam for the browser.
17
- *
18
- * ## Why it is module-level
19
- *
20
- * The storage adapter is constructed at several sites *inside* this package —
21
- * sessions, the exporter, the audio mixer and the still renderer — none of
22
- * which a host can reach. A constructor argument would
23
- * therefore cover the preview and leave export and stills on the network,
24
- * which is the worst of both: the picture a user sees would come from local
25
- * bytes and the one they render would not.
26
- *
27
- * So this is an *injection point*, not a cache. The adapter still owns every
28
- * decode, every cache, every size ceiling and every eviction rule; all this
29
- * changes is where the compressed bytes came from. A source that answers `null`
30
- * — which is what an unregistered URL, an evicted entry or a host with no local
31
- * store does — leaves the adapter exactly as it was.
2
+ * Where a source URL's bytes come from: a host's local store, then the network. The renderer's storage adapter reads
3
+ * every asset through it (`loadBytes`). The adapter otherwise fetches every asset by URL, which is wrong for bytes the
4
+ * host already holds (a file just chosen, a local model's render, an upload still in flight or offline).
5
+ *
6
+ * It is module-level because the adapter is constructed at several sites inside this package (sessions, the exporter,
7
+ * the audio mixer, the still renderer) a host cannot reach; a constructor argument would cover the preview and leave
8
+ * export and stills on the network. This is an *injection point*, not a cache: the adapter still owns every decode,
9
+ * cache and eviction rule, and a source answering `null` leaves it exactly as it was.
32
10
  */
33
11
  /** Local bytes for a source URL, or `null` to go to the network. */
34
12
  export type AssetByteSource = (src: string) => Promise<Blob | null>;
35
- /**
36
- * Installs the byte source for this browsing context, or clears it with `null`.
37
- *
38
- * Called once per window that renders. Later calls replace the previous source
39
- * rather than stacking, because two sources disagreeing about one URL has no
40
- * sensible answer.
41
- */
13
+ /** Installs the byte source for this browsing context, or clears it with `null`. Later calls replace the previous source rather than stacking: two sources disagreeing about one URL has no sensible answer. */
42
14
  export declare function setAssetByteSource(next: AssetByteSource | null): void;
43
- /**
44
- * The bytes for `src`, or `null`.
45
- *
46
- * Swallows a throwing source on purpose. A host's local store failing is a
47
- * cache miss, not a render failure — the caller falls through to `fetch`, which
48
- * is what it would have done had the source never been installed.
49
- */
15
+ /** The bytes for `src`, or `null`. Swallows a throwing source on purpose: a failing local store is a cache miss, not a render failure, and the caller falls through to `fetch`. */
50
16
  export declare function localAssetBytes(src: string): Promise<Blob | null>;
51
- /**
52
- * The network's bytes for `url`. A response that is not OK is a failed load,
53
- * never bytes: a 404 page handed to the font manager marked a family loaded
54
- * with no face in it.
55
- */
17
+ /** The network's bytes for `url`. A non-OK response is a failed load, never bytes (a 404 page handed to the font manager marked a family loaded with no face). */
56
18
  export declare function fetchAssetBytes(url: string): Promise<Blob>;
57
- /** The bytes for `src`: the host's local store first, then the network. */
19
+ /** The bytes for `src`: the host's local store first, then the network. A second ask while the first is out joins it, page-wide. */
58
20
  export declare function loadAssetBytes(src: string): Promise<Blob>;
59
21
  //# sourceMappingURL=asset-bytes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"asset-bytes.d.ts","sourceRoot":"","sources":["../src/asset-bytes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,oEAAoE;AACpE,MAAM,MAAM,eAAe,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;AAIpE;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,eAAe,GAAG,IAAI,GAAG,IAAI,CAErE;AAED;;;;;;GAMG;AACH,wBAAsB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,CAOvE;AAED;;;;GAIG;AACH,wBAAsB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAOhE;AAED,2EAA2E;AAC3E,wBAAsB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE/D"}
1
+ {"version":3,"file":"asset-bytes.d.ts","sourceRoot":"","sources":["../src/asset-bytes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,oEAAoE;AACpE,MAAM,MAAM,eAAe,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;AAIpE,gNAAgN;AAChN,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,eAAe,GAAG,IAAI,GAAG,IAAI,CAErE;AAED,mLAAmL;AACnL,wBAAsB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,CAOvE;AAED,kKAAkK;AAClK,wBAAsB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAOhE;AAID,oIAAoI;AACpI,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAMzD"}
@@ -1,53 +1,19 @@
1
1
  /**
2
- * Where a source URL's bytes come from: a host's local store, then the network.
3
- * The renderer's storage adapter reads every asset through it (`loadBytes`).
4
- *
5
- * ## Why the web adapter needs this at all
6
- *
7
- * The storage adapter addresses every asset by URL and fetches it. That is
8
- * right for an asset that lives somewhere, and wrong for one whose bytes the
9
- * host already has in hand — a file the user has just chosen, a render a local
10
- * model has just produced, a picture whose upload has not finished or cannot
11
- * start because there is no network. In all three the adapter downloads bytes
12
- * that never needed to travel.
13
- *
14
- * `NodeStorageAdapter` has had the answer since it was written: an injected
15
- * `AssetLoader`, with an `inline` map consulted ahead of the disk. This is the
16
- * same seam for the browser.
17
- *
18
- * ## Why it is module-level
19
- *
20
- * The storage adapter is constructed at several sites *inside* this package —
21
- * sessions, the exporter, the audio mixer and the still renderer — none of
22
- * which a host can reach. A constructor argument would
23
- * therefore cover the preview and leave export and stills on the network,
24
- * which is the worst of both: the picture a user sees would come from local
25
- * bytes and the one they render would not.
26
- *
27
- * So this is an *injection point*, not a cache. The adapter still owns every
28
- * decode, every cache, every size ceiling and every eviction rule; all this
29
- * changes is where the compressed bytes came from. A source that answers `null`
30
- * — which is what an unregistered URL, an evicted entry or a host with no local
31
- * store does — leaves the adapter exactly as it was.
2
+ * Where a source URL's bytes come from: a host's local store, then the network. The renderer's storage adapter reads
3
+ * every asset through it (`loadBytes`). The adapter otherwise fetches every asset by URL, which is wrong for bytes the
4
+ * host already holds (a file just chosen, a local model's render, an upload still in flight or offline).
5
+ *
6
+ * It is module-level because the adapter is constructed at several sites inside this package (sessions, the exporter,
7
+ * the audio mixer, the still renderer) a host cannot reach; a constructor argument would cover the preview and leave
8
+ * export and stills on the network. This is an *injection point*, not a cache: the adapter still owns every decode,
9
+ * cache and eviction rule, and a source answering `null` leaves it exactly as it was.
32
10
  */
33
11
  let source = null;
34
- /**
35
- * Installs the byte source for this browsing context, or clears it with `null`.
36
- *
37
- * Called once per window that renders. Later calls replace the previous source
38
- * rather than stacking, because two sources disagreeing about one URL has no
39
- * sensible answer.
40
- */
12
+ /** Installs the byte source for this browsing context, or clears it with `null`. Later calls replace the previous source rather than stacking: two sources disagreeing about one URL has no sensible answer. */
41
13
  export function setAssetByteSource(next) {
42
14
  source = next;
43
15
  }
44
- /**
45
- * The bytes for `src`, or `null`.
46
- *
47
- * Swallows a throwing source on purpose. A host's local store failing is a
48
- * cache miss, not a render failure — the caller falls through to `fetch`, which
49
- * is what it would have done had the source never been installed.
50
- */
16
+ /** The bytes for `src`, or `null`. Swallows a throwing source on purpose: a failing local store is a cache miss, not a render failure, and the caller falls through to `fetch`. */
51
17
  export async function localAssetBytes(src) {
52
18
  if (!source)
53
19
  return null;
@@ -58,11 +24,7 @@ export async function localAssetBytes(src) {
58
24
  return null;
59
25
  }
60
26
  }
61
- /**
62
- * The network's bytes for `url`. A response that is not OK is a failed load,
63
- * never bytes: a 404 page handed to the font manager marked a family loaded
64
- * with no face in it.
65
- */
27
+ /** The network's bytes for `url`. A non-OK response is a failed load, never bytes (a 404 page handed to the font manager marked a family loaded with no face). */
66
28
  export async function fetchAssetBytes(url) {
67
29
  const response = await fetch(url);
68
30
  if (!response.ok) {
@@ -71,8 +33,14 @@ export async function fetchAssetBytes(url) {
71
33
  }
72
34
  return response.blob();
73
35
  }
74
- /** The bytes for `src`: the host's local store first, then the network. */
75
- export async function loadAssetBytes(src) {
76
- return (await localAssetBytes(src)) ?? fetchAssetBytes(src);
36
+ const loading = new Map();
37
+ /** The bytes for `src`: the host's local store first, then the network. A second ask while the first is out joins it, page-wide. */
38
+ export function loadAssetBytes(src) {
39
+ const running = loading.get(src);
40
+ if (running)
41
+ return running;
42
+ const job = (async () => (await localAssetBytes(src)) ?? fetchAssetBytes(src))().finally(() => loading.delete(src));
43
+ loading.set(src, job);
44
+ return job;
77
45
  }
78
46
  //# sourceMappingURL=asset-bytes.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"asset-bytes.js","sourceRoot":"","sources":["../src/asset-bytes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAKH,IAAI,MAAM,GAA2B,IAAI,CAAC;AAE1C;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAA4B;IAC3D,MAAM,GAAG,IAAI,CAAC;AAClB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,GAAW;IAC7C,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IACzB,IAAI,CAAC;QACD,OAAO,MAAM,MAAM,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;IAAC,MAAM,CAAC;QACL,OAAO,IAAI,CAAC;IAChB,CAAC;AACL,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,GAAW;IAC7C,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;IAClC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACf,MAAM,MAAM,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC;QACxG,MAAM,IAAI,KAAK,CAAC,aAAa,GAAG,kBAAkB,MAAM,EAAE,CAAC,CAAC;IAChE,CAAC;IACD,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;AAC3B,CAAC;AAED,2EAA2E;AAC3E,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,GAAW;IAC5C,OAAO,CAAC,MAAM,eAAe,CAAC,GAAG,CAAC,CAAC,IAAI,eAAe,CAAC,GAAG,CAAC,CAAC;AAChE,CAAC","sourcesContent":["/**\n * Where a source URL's bytes come from: a host's local store, then the network.\n * The renderer's storage adapter reads every asset through it (`loadBytes`).\n *\n * ## Why the web adapter needs this at all\n *\n * The storage adapter addresses every asset by URL and fetches it. That is\n * right for an asset that lives somewhere, and wrong for one whose bytes the\n * host already has in hand — a file the user has just chosen, a render a local\n * model has just produced, a picture whose upload has not finished or cannot\n * start because there is no network. In all three the adapter downloads bytes\n * that never needed to travel.\n *\n * `NodeStorageAdapter` has had the answer since it was written: an injected\n * `AssetLoader`, with an `inline` map consulted ahead of the disk. This is the\n * same seam for the browser.\n *\n * ## Why it is module-level\n *\n * The storage adapter is constructed at several sites *inside* this package —\n * sessions, the exporter, the audio mixer and the still renderer — none of\n * which a host can reach. A constructor argument would\n * therefore cover the preview and leave export and stills on the network,\n * which is the worst of both: the picture a user sees would come from local\n * bytes and the one they render would not.\n *\n * So this is an *injection point*, not a cache. The adapter still owns every\n * decode, every cache, every size ceiling and every eviction rule; all this\n * changes is where the compressed bytes came from. A source that answers `null`\n * — which is what an unregistered URL, an evicted entry or a host with no local\n * store does — leaves the adapter exactly as it was.\n */\n\n/** Local bytes for a source URL, or `null` to go to the network. */\nexport type AssetByteSource = (src: string) => Promise<Blob | null>;\n\nlet source: AssetByteSource | null = null;\n\n/**\n * Installs the byte source for this browsing context, or clears it with `null`.\n *\n * Called once per window that renders. Later calls replace the previous source\n * rather than stacking, because two sources disagreeing about one URL has no\n * sensible answer.\n */\nexport function setAssetByteSource(next: AssetByteSource | null): void {\n source = next;\n}\n\n/**\n * The bytes for `src`, or `null`.\n *\n * Swallows a throwing source on purpose. A host's local store failing is a\n * cache miss, not a render failure — the caller falls through to `fetch`, which\n * is what it would have done had the source never been installed.\n */\nexport async function localAssetBytes(src: string): Promise<Blob | null> {\n if (!source) return null;\n try {\n return await source(src);\n } catch {\n return null;\n }\n}\n\n/**\n * The network's bytes for `url`. A response that is not OK is a failed load,\n * never bytes: a 404 page handed to the font manager marked a family loaded\n * with no face in it.\n */\nexport async function fetchAssetBytes(url: string): Promise<Blob> {\n const response = await fetch(url);\n if (!response.ok) {\n const status = response.statusText ? `${response.status} ${response.statusText}` : `${response.status}`;\n throw new Error(`Fetching \"${url}\" failed: HTTP ${status}`);\n }\n return response.blob();\n}\n\n/** The bytes for `src`: the host's local store first, then the network. */\nexport async function loadAssetBytes(src: string): Promise<Blob> {\n return (await localAssetBytes(src)) ?? fetchAssetBytes(src);\n}\n"]}
1
+ {"version":3,"file":"asset-bytes.js","sourceRoot":"","sources":["../src/asset-bytes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,IAAI,MAAM,GAA2B,IAAI,CAAC;AAE1C,gNAAgN;AAChN,MAAM,UAAU,kBAAkB,CAAC,IAA4B;IAC3D,MAAM,GAAG,IAAI,CAAC;AAClB,CAAC;AAED,mLAAmL;AACnL,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,GAAW;IAC7C,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IACzB,IAAI,CAAC;QACD,OAAO,MAAM,MAAM,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;IAAC,MAAM,CAAC;QACL,OAAO,IAAI,CAAC;IAChB,CAAC;AACL,CAAC;AAED,kKAAkK;AAClK,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,GAAW;IAC7C,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;IAClC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACf,MAAM,MAAM,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC;QACxG,MAAM,IAAI,KAAK,CAAC,aAAa,GAAG,kBAAkB,MAAM,EAAE,CAAC,CAAC;IAChE,CAAC;IACD,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;AAC3B,CAAC;AAED,MAAM,OAAO,GAAG,IAAI,GAAG,EAAyB,CAAC;AAEjD,oIAAoI;AACpI,MAAM,UAAU,cAAc,CAAC,GAAW;IACtC,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACjC,IAAI,OAAO;QAAE,OAAO,OAAO,CAAC;IAC5B,MAAM,GAAG,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,MAAM,eAAe,CAAC,GAAG,CAAC,CAAC,IAAI,eAAe,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;IACpH,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACtB,OAAO,GAAG,CAAC;AACf,CAAC","sourcesContent":["/**\n * Where a source URL's bytes come from: a host's local store, then the network. The renderer's storage adapter reads\n * every asset through it (`loadBytes`). The adapter otherwise fetches every asset by URL, which is wrong for bytes the\n * host already holds (a file just chosen, a local model's render, an upload still in flight or offline).\n *\n * It is module-level because the adapter is constructed at several sites inside this package (sessions, the exporter,\n * the audio mixer, the still renderer) a host cannot reach; a constructor argument would cover the preview and leave\n * export and stills on the network. This is an *injection point*, not a cache: the adapter still owns every decode,\n * cache and eviction rule, and a source answering `null` leaves it exactly as it was.\n */\n\n/** Local bytes for a source URL, or `null` to go to the network. */\nexport type AssetByteSource = (src: string) => Promise<Blob | null>;\n\nlet source: AssetByteSource | null = null;\n\n/** Installs the byte source for this browsing context, or clears it with `null`. Later calls replace the previous source rather than stacking: two sources disagreeing about one URL has no sensible answer. */\nexport function setAssetByteSource(next: AssetByteSource | null): void {\n source = next;\n}\n\n/** The bytes for `src`, or `null`. Swallows a throwing source on purpose: a failing local store is a cache miss, not a render failure, and the caller falls through to `fetch`. */\nexport async function localAssetBytes(src: string): Promise<Blob | null> {\n if (!source) return null;\n try {\n return await source(src);\n } catch {\n return null;\n }\n}\n\n/** The network's bytes for `url`. A non-OK response is a failed load, never bytes (a 404 page handed to the font manager marked a family loaded with no face). */\nexport async function fetchAssetBytes(url: string): Promise<Blob> {\n const response = await fetch(url);\n if (!response.ok) {\n const status = response.statusText ? `${response.status} ${response.statusText}` : `${response.status}`;\n throw new Error(`Fetching \"${url}\" failed: HTTP ${status}`);\n }\n return response.blob();\n}\n\nconst loading = new Map<string, Promise<Blob>>();\n\n/** The bytes for `src`: the host's local store first, then the network. A second ask while the first is out joins it, page-wide. */\nexport function loadAssetBytes(src: string): Promise<Blob> {\n const running = loading.get(src);\n if (running) return running;\n const job = (async () => (await localAssetBytes(src)) ?? fetchAssetBytes(src))().finally(() => loading.delete(src));\n loading.set(src, job);\n return job;\n}\n"]}
@@ -1,52 +1,17 @@
1
1
  import { type AudioBusStop } from "@motionscript/core";
2
- /**
3
- * The live chains for one audio context's buses.
4
- *
5
- * Held per context rather than per clip, because that is the whole difference
6
- * between a bus and per-clip processing: every clip naming a bus connects into
7
- * the *same* nodes, so a reverb on a bus is one tail the group shares rather
8
- * than one tail each. Flattening the levels into per-clip gain would sound
9
- * right; flattening the effects would not.
10
- */
2
+ /** The live chains for one audio context's buses. Held per context, not per clip: every clip naming a bus connects into the *same* nodes, so a bus reverb is one shared tail (flattening levels into per-clip gain sounds right; flattening effects would not). */
11
3
  export declare class AudioBusGraph {
12
4
  private readonly ctx;
13
- /** Where the last bus in a chain connects — the master, or the destination. */
14
5
  private readonly destination;
15
- constructor(ctx: BaseAudioContext,
16
- /** Where the last bus in a chain connects — the master, or the destination. */
17
- destination: AudioNode);
18
- /**
19
- * The input node a clip on `bus` should connect to, building the chain the
20
- * first time it is asked for.
21
- *
22
- * `bus` is source-adjacent first, so `bus[0]` is the one the clip feeds and
23
- * each stop after it is that bus's own parent. An empty or absent chain
24
- * returns the destination, which is what every clip did before buses
25
- * existed.
26
- *
27
- * `startTime` is the context time a new chain's schedule starts from, and
28
- * `clipTime` the same instant in the stops' own seconds. A curve on a stop
29
- * runs over its `startAt`–`endAt`, so the two are what place it.
30
- */
6
+ constructor(ctx: BaseAudioContext, destination: AudioNode);
7
+ /** The input node a clip on `bus` should connect to, building the chain on first ask. `bus` is source-adjacent first (`bus[0]` is the one the clip feeds; each later stop is its parent); an empty or absent chain returns the destination. `startTime` is the context time a new chain's schedule starts from and `clipTime` the same instant in the stops' own seconds, which place a curve over its `startAt`–`endAt`. */
31
8
  inputFor(bus: readonly AudioBusStop[] | undefined, startTime: number, clipTime: number): AudioNode;
32
9
  /** Disconnect every live bus node, so the next {@link inputFor} builds afresh. Safe to call more than once. */
33
10
  dispose(): void;
34
11
  private readonly inputs;
35
12
  private readonly nodes;
36
13
  private readonly oscillators;
37
- /**
38
- * Build (or reuse) the chain for `bus[index]`, connected to whatever
39
- * `bus[index + 1]` resolves to.
40
- *
41
- * Recursive rather than iterative because a bus's *output* has to exist
42
- * before its own nodes can connect to it, and the outermost bus is the last
43
- * entry.
44
- *
45
- * Reused by everything that changes what it sounds like, down to the master,
46
- * not by id alone: a bus edited under a playing device, or one id on two
47
- * tracks, is a different chain, and one built for the first would play the
48
- * second through stale levels and a curve anchored to the wrong span.
49
- */
14
+ /** Builds (or reuses) the chain for `bus[index]`, connected to whatever `bus[index + 1]` resolves to. Recursive because a bus's *output* must exist before its own nodes connect to it. Reuse is keyed by everything that changes what it sounds like, not by id alone: a bus edited under a playing device, or one id on two tracks, is a different chain, and a stale one would play stale levels and a curve anchored to the wrong span. */
50
15
  private chainFrom;
51
16
  }
52
17
  //# sourceMappingURL=bus-graph.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bus-graph.d.ts","sourceRoot":"","sources":["../../src/audio/bus-graph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,YAAY,EAAoB,MAAM,oBAAoB,CAAC;AAGrF;;;;;;;;GAQG;AACH,qBAAa,aAAa;IAElB,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,+EAA+E;IAC/E,OAAO,CAAC,QAAQ,CAAC,WAAW;gBAFX,GAAG,EAAE,gBAAgB;IACtC,+EAA+E;IAC9D,WAAW,EAAE,SAAS;IAG3C;;;;;;;;;;;;OAYG;IACH,QAAQ,CAAC,GAAG,EAAE,SAAS,YAAY,EAAE,GAAG,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,SAAS;IAKlG,+GAA+G;IAC/G,OAAO,IAAI,IAAI;IAYf,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgC;IACvD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAmB;IACzC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAwB;IAEpD;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,SAAS;CAuCpB"}
1
+ {"version":3,"file":"bus-graph.d.ts","sourceRoot":"","sources":["../../src/audio/bus-graph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,YAAY,EAAoB,MAAM,oBAAoB,CAAC;AAGrF,mQAAmQ;AACnQ,qBAAa,aAAa;IAElB,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,WAAW;gBADX,GAAG,EAAE,gBAAgB,EACrB,WAAW,EAAE,SAAS;IAG3C,6ZAA6Z;IAC7Z,QAAQ,CAAC,GAAG,EAAE,SAAS,YAAY,EAAE,GAAG,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,SAAS;IAKlG,+GAA+G;IAC/G,OAAO,IAAI,IAAI;IAYf,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgC;IACvD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAmB;IACzC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAwB;IAEpD,+aAA+a;IAC/a,OAAO,CAAC,SAAS;CAuCpB"}
@@ -1,36 +1,14 @@
1
1
  import { busStopKey } from "@motionscript/core";
2
2
  import { applyTransitions, buildAudioEffectGraph } from "./effect-graph";
3
- /**
4
- * The live chains for one audio context's buses.
5
- *
6
- * Held per context rather than per clip, because that is the whole difference
7
- * between a bus and per-clip processing: every clip naming a bus connects into
8
- * the *same* nodes, so a reverb on a bus is one tail the group shares rather
9
- * than one tail each. Flattening the levels into per-clip gain would sound
10
- * right; flattening the effects would not.
11
- */
3
+ /** The live chains for one audio context's buses. Held per context, not per clip: every clip naming a bus connects into the *same* nodes, so a bus reverb is one shared tail (flattening levels into per-clip gain sounds right; flattening effects would not). */
12
4
  export class AudioBusGraph {
13
5
  ctx;
14
6
  destination;
15
- constructor(ctx,
16
- /** Where the last bus in a chain connects — the master, or the destination. */
17
- destination) {
7
+ constructor(ctx, destination) {
18
8
  this.ctx = ctx;
19
9
  this.destination = destination;
20
10
  }
21
- /**
22
- * The input node a clip on `bus` should connect to, building the chain the
23
- * first time it is asked for.
24
- *
25
- * `bus` is source-adjacent first, so `bus[0]` is the one the clip feeds and
26
- * each stop after it is that bus's own parent. An empty or absent chain
27
- * returns the destination, which is what every clip did before buses
28
- * existed.
29
- *
30
- * `startTime` is the context time a new chain's schedule starts from, and
31
- * `clipTime` the same instant in the stops' own seconds. A curve on a stop
32
- * runs over its `startAt`–`endAt`, so the two are what place it.
33
- */
11
+ /** The input node a clip on `bus` should connect to, building the chain on first ask. `bus` is source-adjacent first (`bus[0]` is the one the clip feeds; each later stop is its parent); an empty or absent chain returns the destination. `startTime` is the context time a new chain's schedule starts from and `clipTime` the same instant in the stops' own seconds, which place a curve over its `startAt`–`endAt`. */
34
12
  inputFor(bus, startTime, clipTime) {
35
13
  if (!bus || bus.length === 0)
36
14
  return this.destination;
@@ -57,19 +35,7 @@ export class AudioBusGraph {
57
35
  inputs = new Map();
58
36
  nodes = [];
59
37
  oscillators = [];
60
- /**
61
- * Build (or reuse) the chain for `bus[index]`, connected to whatever
62
- * `bus[index + 1]` resolves to.
63
- *
64
- * Recursive rather than iterative because a bus's *output* has to exist
65
- * before its own nodes can connect to it, and the outermost bus is the last
66
- * entry.
67
- *
68
- * Reused by everything that changes what it sounds like, down to the master,
69
- * not by id alone: a bus edited under a playing device, or one id on two
70
- * tracks, is a different chain, and one built for the first would play the
71
- * second through stale levels and a curve anchored to the wrong span.
72
- */
38
+ /** Builds (or reuses) the chain for `bus[index]`, connected to whatever `bus[index + 1]` resolves to. Recursive because a bus's *output* must exist before its own nodes connect to it. Reuse is keyed by everything that changes what it sounds like, not by id alone: a bus edited under a playing device, or one id on two tracks, is a different chain, and a stale one would play stale levels and a curve anchored to the wrong span. */
73
39
  chainFrom(bus, index, startTime, clipTime) {
74
40
  if (index >= bus.length)
75
41
  return this.destination;
@@ -1 +1 @@
1
- {"version":3,"file":"bus-graph.js","sourceRoot":"","sources":["../../src/audio/bus-graph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAuC,MAAM,oBAAoB,CAAC;AACrF,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAEzE;;;;;;;;GAQG;AACH,MAAM,OAAO,aAAa;IAED;IAEA;IAHrB,YACqB,GAAqB;IACtC,+EAA+E;IAC9D,WAAsB;QAFtB,QAAG,GAAH,GAAG,CAAkB;QAErB,gBAAW,GAAX,WAAW,CAAW;IACvC,CAAC;IAEL;;;;;;;;;;;;OAYG;IACH,QAAQ,CAAC,GAAwC,EAAE,SAAiB,EAAE,QAAgB;QAClF,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,IAAI,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AC5B,IAAI,GAAG,UAAU,CAAC;QACtB,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAErB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;QACvC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC;QAC5C,KAAK,MAAM,GAAG,IAAI,KAAK,CAAC,WAAW;YAAE,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QAE1D,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC5B,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ","sourcesContent":["import { busStopKey, type AudioBusStop, type AudioEffect } from \"@motionscript/core\";\nimport { applyTransitions, buildAudioEffectGraph } from \"./effect-graph\";\n\n/**\n * The live chains for one audio context's buses.\n *\n * Held per context rather than per clip, because that is the whole difference\n * between a bus and per-clip processing: every clip naming a bus connects into\n * the *same* nodes, so a reverb on a bus is one tail the group shares rather\n * than one tail each. Flattening the levels into per-clip gain would sound\n * right; flattening the effects would not.\n */\nexport class AudioBusGraph {\n constructor(\n private readonly ctx: BaseAudioContext,\n /** Where the last bus in a chain connects — the master, or the destination. */\n private readonly destination: AudioNode,\n ) { }\n\n /**\n * The input node a clip on `bus` should connect to, building the chain the\n * first time it is asked for.\n *\n * `bus` is source-adjacent first, so `bus[0]` is the one the clip feeds and\n * each stop after it is that bus's own parent. An empty or absent chain\n * returns the destination, which is what every clip did before buses\n * existed.\n *\n * `startTime` is the context time a new chain's schedule starts from, and\n * `clipTime` the same instant in the stops' own seconds. A curve on a stop\n * runs over its `startAt`–`endAt`, so the two are what place it.\n */\n inputFor(bus: readonly AudioBusStop[] | undefined, startTime: number, clipTime: number): AudioNode {\n if (!bus || bus.length === 0) return this.destination;\n return this.chainFrom(bus, 0, startTime, clipTime);\n }\n\n /** Disconnect every live bus node, so the next {@link inputFor} builds afresh. Safe to call more than once. */\n dispose(): void {\n for (const node of this.nodes) {\n try { node.disconnect(); } catch { /* already torn down */ }\n }\n for (const osc of this.oscillators) {\n try { osc.stop(); } catch { /* never started, or already stopped */ }\n }\n this.nodes.length = 0;\n this.oscillators.length = 0;\n this.inputs.clear();\n }\n\n private readonly inputs = new Map<string, AudioNode>();\n private readonly nodes: AudioNode[] = [];\n private readonly oscillators: OscillatorNode[] = [];\n\n /**\n * Build (or reuse) the chain for `bus[index]`, connected to whatever\n * `bus[index + 1]` resolves to.\n *\n * Recursive rather than iterative because a bus's *output* has to exist\n * before its own nodes can connect to it, and the outermost bus is the last\n * entry.\n *\n * Reused by everything that changes what it sounds like, down to the master,\n * not by id alone: a bus edited under a playing device, or one id on two\n * tracks, is a different chain, and one built for the first would play the\n * second through stale levels and a curve anchored to the wrong span.\n */\n private chainFrom(bus: readonly AudioBusStop[], index: number, startTime: number, clipTime: number): AudioNode {\n if (index >= bus.length) return this.destination;\n\n const stop = bus[index];\n const key = bus.slice(index).map(busStopKey).join(\">\");\n const existing = this.inputs.get(key);\n if (existing) return existing;\n\n const output = this.chainFrom(bus, index + 1, startTime, clipTime);\n\n // A pass-through head every clip connects to, so the bus has one input\n // whatever its effects turn out to be.\n const input = this.ctx.createGain();\n input.gain.value = 1;\n\n // The level is a gain after the effects, as a sound's own level is, so a\n // ramp on it is scheduled exactly as one in `effects` is.\n const level: AudioEffect = { type: \"gain\", value: stop.mute ? 0 : stop.volume };\n const span = stop.endAt - stop.startAt;\n const graph = buildAudioEffectGraph(\n this.ctx, input, [...(stop.effects ?? []), level], startTime, span, clipTime - stop.startAt,\n );\n let tail = graph.output;\n if (stop.transitionIn || stop.transitionOut) {\n const transition = this.ctx.createGain();\n applyTransitions(transition.gain, span, stop.transitionIn, stop.transitionOut, startTime, clipTime - stop.startAt);\n tail.connect(transition);\n this.nodes.push(transition);\n tail = transition;\n }\n tail.connect(output);\n\n this.nodes.push(input, ...graph.nodes);\n this.oscillators.push(...graph.oscillators);\n for (const osc of graph.oscillators) osc.start(startTime);\n\n this.inputs.set(key, input);\n return input;\n }\n}\n"]}
1
+ {"version":3,"file":"bus-graph.js","sourceRoot":"","sources":["../../src/audio/bus-graph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAuC,MAAM,oBAAoB,CAAC;AACrF,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAEzE,mQAAmQ;AACnQ,MAAM,OAAO,aAAa;IAED;IACA;IAFrB,YACqB,GAAqB,EACrB,WAAsB;QADtB,QAAG,GAAH,GAAG,CAAkB;QACrB,gBAAW,GAAX,WAAW,CAAW;IACvC,CAAC;IAEL,6ZAA6Z;IAC7Z,QAAQ,CAAC,GAAwC,EAAE,SAAiB,EAAE,QAAgB;QAClF,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC,WAAW,CAAC;QACtD,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;IACvD,CAAC;IAED,+GAA+G;IAC/G,OAAO;QACH,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAC5B,IAAI,CAAC;gBAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YAAC,CAAC;YAAC,MAAM,CAAC,CAAC,uBAAuB,CAAC,CAAC;QAChE,CAAC;QACD,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACjC,IAAI,CAAC;gBAAC,GAAG,CAAC,IAAI,EAAE,CAAC;YAAC,CAAC;YAAC,MAAM,CAAC,CAAC,uCAAuC,CAAC,CAAC;QACzE,CAAC;QACD,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;QACtB,IAAI,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC;QA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CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,GAAG,IAAI,CAAC,OAAO,CAC9F,CAAC;QACF,IAAI,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC;QACxB,IAAI,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YAC1C,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC;YACzC,gBAAgB,CAAC,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,aAAa,EAAE,SAAS,EAAE,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC;YACnH,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;YACzB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YAC5B,IAAI,GAAG,UAAU,CAAC;QACtB,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAErB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;QACvC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC;QAC5C,KAAK,MAAM,GAAG,IAAI,KAAK,CAAC,WAAW;YAAE,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QAE1D,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC5B,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ","sourcesContent":["import { busStopKey, type AudioBusStop, type AudioEffect } from \"@motionscript/core\";\nimport { applyTransitions, buildAudioEffectGraph } from \"./effect-graph\";\n\n/** The live chains for one audio context's buses. Held per context, not per clip: every clip naming a bus connects into the *same* nodes, so a bus reverb is one shared tail (flattening levels into per-clip gain sounds right; flattening effects would not). */\nexport class AudioBusGraph {\n constructor(\n private readonly ctx: BaseAudioContext,\n private readonly destination: AudioNode,\n ) { }\n\n /** The input node a clip on `bus` should connect to, building the chain on first ask. `bus` is source-adjacent first (`bus[0]` is the one the clip feeds; each later stop is its parent); an empty or absent chain returns the destination. `startTime` is the context time a new chain's schedule starts from and `clipTime` the same instant in the stops' own seconds, which place a curve over its `startAt`–`endAt`. */\n inputFor(bus: readonly AudioBusStop[] | undefined, startTime: number, clipTime: number): AudioNode {\n if (!bus || bus.length === 0) return this.destination;\n return this.chainFrom(bus, 0, startTime, clipTime);\n }\n\n /** Disconnect every live bus node, so the next {@link inputFor} builds afresh. Safe to call more than once. */\n dispose(): void {\n for (const node of this.nodes) {\n try { node.disconnect(); } catch { /* already torn down */ }\n }\n for (const osc of this.oscillators) {\n try { osc.stop(); } catch { /* never started, or already stopped */ }\n }\n this.nodes.length = 0;\n this.oscillators.length = 0;\n this.inputs.clear();\n }\n\n private readonly inputs = new Map<string, AudioNode>();\n private readonly nodes: AudioNode[] = [];\n private readonly oscillators: OscillatorNode[] = [];\n\n /** Builds (or reuses) the chain for `bus[index]`, connected to whatever `bus[index + 1]` resolves to. Recursive because a bus's *output* must exist before its own nodes connect to it. Reuse is keyed by everything that changes what it sounds like, not by id alone: a bus edited under a playing device, or one id on two tracks, is a different chain, and a stale one would play stale levels and a curve anchored to the wrong span. */\n private chainFrom(bus: readonly AudioBusStop[], index: number, startTime: number, clipTime: number): AudioNode {\n if (index >= bus.length) return this.destination;\n\n const stop = bus[index];\n const key = bus.slice(index).map(busStopKey).join(\">\");\n const existing = this.inputs.get(key);\n if (existing) return existing;\n\n const output = this.chainFrom(bus, index + 1, startTime, clipTime);\n\n // A pass-through head every clip connects to, so the bus has one input\n // whatever its effects turn out to be.\n const input = this.ctx.createGain();\n input.gain.value = 1;\n\n // The level is a gain after the effects, as a sound's own level is, so a\n // ramp on it is scheduled exactly as one in `effects` is.\n const level: AudioEffect = { type: \"gain\", value: stop.mute ? 0 : stop.volume };\n const span = stop.endAt - stop.startAt;\n const graph = buildAudioEffectGraph(\n this.ctx, input, [...(stop.effects ?? []), level], startTime, span, clipTime - stop.startAt,\n );\n let tail = graph.output;\n if (stop.transitionIn || stop.transitionOut) {\n const transition = this.ctx.createGain();\n applyTransitions(transition.gain, span, stop.transitionIn, stop.transitionOut, startTime, clipTime - stop.startAt);\n tail.connect(transition);\n this.nodes.push(transition);\n tail = transition;\n }\n tail.connect(output);\n\n this.nodes.push(input, ...graph.nodes);\n this.oscillators.push(...graph.oscillators);\n for (const osc of graph.oscillators) osc.start(startTime);\n\n this.inputs.set(key, input);\n return input;\n }\n}\n"]}
@@ -1,31 +1,13 @@
1
1
  import { type AudioEffect, type AudioRequest, type AudioTransition, type Ramp } from "@motionscript/core";
2
- /**
3
- * The Web Audio graph for one source's effect chain.
4
- *
5
- * `output` is the last node, to connect downstream; `nodes` are every node to
6
- * `disconnect()` on teardown; `oscillators` are tremolo LFOs the caller starts
7
- * and stops alongside the source.
8
- */
2
+ /** The Web Audio graph for one source's effect chain: `output` is the last node to connect downstream, `nodes` every node to `disconnect()` on teardown, `oscillators` tremolo LFOs the caller starts and stops with the source. */
9
3
  export interface AudioEffectGraph {
10
4
  output: AudioNode;
11
5
  nodes: AudioNode[];
12
6
  oscillators: OscillatorNode[];
13
7
  }
14
- /**
15
- * Builds the Web Audio graph for a clip's effect chain, after an
16
- * already-created `source`. Shared by live playback ({@link WebAudioSink}) and
17
- * offline export (`mixAudio`) so both sound identical.
18
- *
19
- * `startTime` is the context time the source starts; `clipDuration` the clip
20
- * seconds ramps run over (a clip's, or a bus's span); `elapsed` the clip seconds
21
- * already played at a mid-clip seek (0 for a clean start, negative before the
22
- * span begins).
23
- */
8
+ /** Builds the Web Audio graph for a clip's effect chain after an already-created `source`, shared by live playback ({@link WebAudioSink}) and offline export (`mixAudio`) so both sound identical. `startTime` is the context time the source starts; `clipDuration` the clip seconds ramps run over (a clip's, or a bus's span); `elapsed` the clip seconds already played at a mid-clip seek (0 for a clean start, negative before the span begins). */
24
9
  export declare function buildAudioEffectGraph(ctx: BaseAudioContext, source: AudioNode, effects: readonly AudioEffect[], startTime?: number, clipDuration?: number, elapsed?: number): AudioEffectGraph;
25
- /**
26
- * Schedule `transitionIn`/`transitionOut` onto a gain over a span `length`
27
- * seconds long, baked like an eased ramp. Between the two it holds at 1.
28
- */
10
+ /** Schedules `transitionIn`/`transitionOut` onto a gain over a span `length` seconds long, baked like an eased ramp; holds at 1 between them. */
29
11
  export declare function applyTransitions(gain: AudioParam, length: number, transitionIn: AudioTransition | undefined, transitionOut: AudioTransition | undefined, startTime: number, elapsed: number): void;
30
12
  /** How one request plays its source: the rate, and the lengths its ramps and transitions run over. */
31
13
  export interface Playback {
@@ -50,13 +32,6 @@ export declare function buildLevel(ctx: BaseAudioContext, from: AudioNode, req:
50
32
  output: AudioNode;
51
33
  nodes: AudioNode[];
52
34
  };
53
- /**
54
- * Schedule a speed ramp onto an `AudioBufferSourceNode.playbackRate`.
55
- *
56
- * The ramp runs over **source** seconds and Web Audio schedules in context
57
- * seconds, so this walks clip time in small steps, converts each to a source
58
- * offset through the integral inverse, and lays down the rate there. `elapsed`
59
- * is clip seconds already played at a mid-clip seek.
60
- */
35
+ /** Schedules a speed ramp onto `playbackRate`. The ramp runs over **source** seconds and Web Audio schedules in context seconds, so this walks clip time in small steps and converts each through the integral inverse. `elapsed` is clip seconds already played at a mid-clip seek. */
61
36
  export declare function applySpeedToPlaybackRate(rate: AudioParam, speed: Ramp | undefined, sourceLength: number, clipDuration: number, startTime: number, elapsed: number): void;
62
37
  //# sourceMappingURL=effect-graph.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"effect-graph.d.ts","sourceRoot":"","sources":["../../src/audio/effect-graph.ts"],"names":[],"mappings":"AAAA,OAAO,EASH,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,eAAe,EAEpB,KAAK,IAAI,EACZ,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AAI,CAAC;IACjB,gDAAgD;IAChD,YAAY,EAAE,MAAM,CAAC;IACrB,yDAAyD;IACzD,YAAY,EAAE,MAAM,CAAC;IACrB,iFAAiF;IACjF,gBAAgB,EAAE,MAAM,CAAC;CAC5B;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,GAAG,QAAQ,CAS9E;AAED,oFAAoF;AACpF,wBAAgB,cAAc,CAAC,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAI9E;AAED;;;GAGG;AACH,wBAAgB,UAAU,CACtB,GAAG,EAAE,gBAAgB,EACrB,IAAI,EAAE,SAAS,EACf,GAAG,EAAE,YAAY,EACjB,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,GAChB;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,SAAS,EAAE,CAAA;CAAE,CAS3C;AAED,wRAAwR;AACxR,wBAAgB,wBAAwB,CACpC,IAAI,EAAE,UAAU,EAChB,KAAK,EAAE,IAAI,GAAG,SAAS,EACvB,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,GAChB,IAAI,CAaN"}
@@ -1,15 +1,7 @@
1
1
  import { clipTimeAtSource, isRamp, resolveRamp, sampleRamp, sourceTimeAtClip, staticValue, transitionGainAt, transitionSpans, } from "@motionscript/core";
2
2
  /** Sample points per second an eased segment or a transition is baked into: about every 5 ms. */
3
3
  const CURVE_SAMPLES_PER_SECOND = 200;
4
- /**
5
- * Apply a {@link Param} to a Web Audio {@link AudioParam}: a number once, a
6
- * ramp as a schedule — linear segments as `linearRampToValueAtTime`, eased
7
- * ones baked into `setValueCurveAtTime`.
8
- *
9
- * `elapsed` is the clip seconds already played when a mid-clip seek starts the
10
- * source, so "now" reads the ramp at the clip's current position. `clamp` keeps
11
- * every scheduled value in a param's valid range.
12
- */
4
+ /** Applies a {@link Param} to a Web Audio {@link AudioParam}: a number once, a ramp as a schedule (linear segments via `linearRampToValueAtTime`, eased ones baked into `setValueCurveAtTime`). `elapsed` is the clip seconds already played at a mid-clip seek; `clamp` keeps scheduled values in the param's valid range. */
13
5
  function applyParam(audioParam, param, startTime, clipDuration, elapsed, clamp = (v) => v) {
14
6
  // The platform throws on a non-finite value.
15
7
  const finite = (v) => {
@@ -62,16 +54,7 @@ function applyParam(audioParam, param, startTime, clipDuration, elapsed, clamp =
62
54
  }
63
55
  }
64
56
  }
65
- /**
66
- * Builds the Web Audio graph for a clip's effect chain, after an
67
- * already-created `source`. Shared by live playback ({@link WebAudioSink}) and
68
- * offline export (`mixAudio`) so both sound identical.
69
- *
70
- * `startTime` is the context time the source starts; `clipDuration` the clip
71
- * seconds ramps run over (a clip's, or a bus's span); `elapsed` the clip seconds
72
- * already played at a mid-clip seek (0 for a clean start, negative before the
73
- * span begins).
74
- */
57
+ /** Builds the Web Audio graph for a clip's effect chain after an already-created `source`, shared by live playback ({@link WebAudioSink}) and offline export (`mixAudio`) so both sound identical. `startTime` is the context time the source starts; `clipDuration` the clip seconds ramps run over (a clip's, or a bus's span); `elapsed` the clip seconds already played at a mid-clip seek (0 for a clean start, negative before the span begins). */
75
58
  export function buildAudioEffectGraph(ctx, source, effects, startTime = ctx.currentTime, clipDuration = 0, elapsed = 0) {
76
59
  const nodes = [];
77
60
  const oscillators = [];
@@ -149,10 +132,7 @@ function clamp01(v) {
149
132
  function maxOf(p) {
150
133
  return isRamp(p) ? Math.max(0, ...p.keys.map((k) => k.value)) : p;
151
134
  }
152
- /**
153
- * Schedule `transitionIn`/`transitionOut` onto a gain over a span `length`
154
- * seconds long, baked like an eased ramp. Between the two it holds at 1.
155
- */
135
+ /** Schedules `transitionIn`/`transitionOut` onto a gain over a span `length` seconds long, baked like an eased ramp; holds at 1 between them. */
156
136
  export function applyTransitions(gain, length, transitionIn, transitionOut, startTime, elapsed) {
157
137
  if (!transitionIn && !transitionOut)
158
138
  return;
@@ -209,14 +189,7 @@ export function buildLevel(ctx, from, req, playback, startTime, elapsed) {
209
189
  level.connect(transition);
210
190
  return { output: transition, nodes: [level, transition] };
211
191
  }
212
- /**
213
- * Schedule a speed ramp onto an `AudioBufferSourceNode.playbackRate`.
214
- *
215
- * The ramp runs over **source** seconds and Web Audio schedules in context
216
- * seconds, so this walks clip time in small steps, converts each to a source
217
- * offset through the integral inverse, and lays down the rate there. `elapsed`
218
- * is clip seconds already played at a mid-clip seek.
219
- */
192
+ /** Schedules a speed ramp onto `playbackRate`. The ramp runs over **source** seconds and Web Audio schedules in context seconds, so this walks clip time in small steps and converts each through the integral inverse. `elapsed` is clip seconds already played at a mid-clip seek. */
220
193
  export function applySpeedToPlaybackRate(rate, speed, sourceLength, clipDuration, startTime, elapsed) {
221
194
  if (!speed)
222
195
  return;