@motionscript/browser 0.1.0-alpha.3 → 0.1.0-alpha.5

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 (75) hide show
  1. package/CHANGELOG.md +95 -0
  2. package/LICENSE +201 -201
  3. package/NOTICE +48 -0
  4. package/README.md +118 -69
  5. package/dist/asset-bytes.js.map +1 -1
  6. package/dist/audio/bus-graph.d.ts +2 -2
  7. package/dist/audio/bus-graph.d.ts.map +1 -1
  8. package/dist/audio/bus-graph.js +6 -6
  9. package/dist/audio/bus-graph.js.map +1 -1
  10. package/dist/audio/filter-graph.d.ts +5 -5
  11. package/dist/audio/filter-graph.d.ts.map +1 -1
  12. package/dist/audio/filter-graph.js +15 -15
  13. package/dist/audio/filter-graph.js.map +1 -1
  14. package/dist/audio/index.js.map +1 -1
  15. package/dist/audio/loop-region.d.ts +31 -0
  16. package/dist/audio/loop-region.d.ts.map +1 -0
  17. package/dist/audio/loop-region.js +43 -0
  18. package/dist/audio/loop-region.js.map +1 -0
  19. package/dist/audio/mixer.d.ts.map +1 -1
  20. package/dist/audio/mixer.js +26 -10
  21. package/dist/audio/mixer.js.map +1 -1
  22. package/dist/audio/player.d.ts +4 -4
  23. package/dist/audio/player.d.ts.map +1 -1
  24. package/dist/audio/player.js +15 -14
  25. package/dist/audio/player.js.map +1 -1
  26. package/dist/browser/THIRD_PARTY_LICENSES.txt +432 -0
  27. package/dist/browser/audio.js +1 -1
  28. package/dist/browser/chunks/chunk-2MAFJWBZ.js +2 -0
  29. package/dist/browser/chunks/chunk-2MAFJWBZ.js.map +7 -0
  30. package/dist/browser/index.js +130 -276
  31. package/dist/browser/index.js.map +4 -4
  32. package/dist/browser/manifest.json +19 -2
  33. package/dist/concat.js.map +1 -1
  34. package/dist/decode/image-levels.js.map +1 -1
  35. package/dist/decode/levels.js.map +1 -1
  36. package/dist/decode/video-levels.js.map +1 -1
  37. package/dist/dynamic-nodes.js.map +1 -1
  38. package/dist/engine.d.ts.map +1 -1
  39. package/dist/engine.js +1 -0
  40. package/dist/engine.js.map +1 -1
  41. package/dist/exporter.d.ts +8 -2
  42. package/dist/exporter.d.ts.map +1 -1
  43. package/dist/exporter.js +8 -7
  44. package/dist/exporter.js.map +1 -1
  45. package/dist/getter.js.map +1 -1
  46. package/dist/index.js.map +1 -1
  47. package/dist/measure-context.js.map +1 -1
  48. package/dist/mix-timeline-audio.d.ts +2 -2
  49. package/dist/mix-timeline-audio.d.ts.map +1 -1
  50. package/dist/mix-timeline-audio.js +1 -2
  51. package/dist/mix-timeline-audio.js.map +1 -1
  52. package/dist/render-context.js.map +1 -1
  53. package/dist/screenshot.d.ts +3 -3
  54. package/dist/screenshot.d.ts.map +1 -1
  55. package/dist/screenshot.js +1 -2
  56. package/dist/screenshot.js.map +1 -1
  57. package/dist/still.d.ts +6 -4
  58. package/dist/still.d.ts.map +1 -1
  59. package/dist/still.js +12 -9
  60. package/dist/still.js.map +1 -1
  61. package/dist/storage-adapter.d.ts.map +1 -1
  62. package/dist/storage-adapter.js +5 -4
  63. package/dist/storage-adapter.js.map +1 -1
  64. package/dist/three/renderer.js.map +1 -1
  65. package/dist/ticker.d.ts +22 -4
  66. package/dist/ticker.d.ts.map +1 -1
  67. package/dist/ticker.js +65 -28
  68. package/dist/ticker.js.map +1 -1
  69. package/package.json +7 -6
  70. package/dist/browser/chunks/chunk-M7XD73ED.js +0 -2
  71. package/dist/browser/chunks/chunk-M7XD73ED.js.map +0 -7
  72. package/dist/output.d.ts +0 -7
  73. package/dist/output.d.ts.map +0 -1
  74. package/dist/output.js +0 -6
  75. package/dist/output.js.map +0 -1
@@ -0,0 +1,432 @@
1
+ Third-party software bundled into @motionscript/browser's browser build (dist/browser/).
2
+
3
+ esbuild-wasm 0.28.2
4
+ License: MIT
5
+
6
+ MIT License
7
+
8
+ Copyright (c) 2020 Evan Wallace
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ ------------------------------------------------------------------------------
29
+
30
+ mediabunny 1.49.0
31
+ License: MPL-2.0
32
+
33
+ Mozilla Public License Version 2.0
34
+ ==================================
35
+
36
+ 1. Definitions
37
+ --------------
38
+
39
+ 1.1. "Contributor"
40
+ means each individual or legal entity that creates, contributes to
41
+ the creation of, or owns Covered Software.
42
+
43
+ 1.2. "Contributor Version"
44
+ means the combination of the Contributions of others (if any) used
45
+ by a Contributor and that particular Contributor's Contribution.
46
+
47
+ 1.3. "Contribution"
48
+ means Covered Software of a particular Contributor.
49
+
50
+ 1.4. "Covered Software"
51
+ means Source Code Form to which the initial Contributor has attached
52
+ the notice in Exhibit A, the Executable Form of such Source Code
53
+ Form, and Modifications of such Source Code Form, in each case
54
+ including portions thereof.
55
+
56
+ 1.5. "Incompatible With Secondary Licenses"
57
+ means
58
+
59
+ (a) that the initial Contributor has attached the notice described
60
+ in Exhibit B to the Covered Software; or
61
+
62
+ (b) that the Covered Software was made available under the terms of
63
+ version 1.1 or earlier of the License, but not also under the
64
+ terms of a Secondary License.
65
+
66
+ 1.6. "Executable Form"
67
+ means any form of the work other than Source Code Form.
68
+
69
+ 1.7. "Larger Work"
70
+ means a work that combines Covered Software with other material, in
71
+ a separate file or files, that is not Covered Software.
72
+
73
+ 1.8. "License"
74
+ means this document.
75
+
76
+ 1.9. "Licensable"
77
+ means having the right to grant, to the maximum extent possible,
78
+ whether at the time of the initial grant or subsequently, any and
79
+ all of the rights conveyed by this License.
80
+
81
+ 1.10. "Modifications"
82
+ means any of the following:
83
+
84
+ (a) any file in Source Code Form that results from an addition to,
85
+ deletion from, or modification of the contents of Covered
86
+ Software; or
87
+
88
+ (b) any new file in Source Code Form that contains any Covered
89
+ Software.
90
+
91
+ 1.11. "Patent Claims" of a Contributor
92
+ means any patent claim(s), including without limitation, method,
93
+ process, and apparatus claims, in any patent Licensable by such
94
+ Contributor that would be infringed, but for the grant of the
95
+ License, by the making, using, selling, offering for sale, having
96
+ made, import, or transfer of either its Contributions or its
97
+ Contributor Version.
98
+
99
+ 1.12. "Secondary License"
100
+ means either the GNU General Public License, Version 2.0, the GNU
101
+ Lesser General Public License, Version 2.1, the GNU Affero General
102
+ Public License, Version 3.0, or any later versions of those
103
+ licenses.
104
+
105
+ 1.13. "Source Code Form"
106
+ means the form of the work preferred for making modifications.
107
+
108
+ 1.14. "You" (or "Your")
109
+ means an individual or a legal entity exercising rights under this
110
+ License. For legal entities, "You" includes any entity that
111
+ controls, is controlled by, or is under common control with You. For
112
+ purposes of this definition, "control" means (a) the power, direct
113
+ or indirect, to cause the direction or management of such entity,
114
+ whether by contract or otherwise, or (b) ownership of more than
115
+ fifty percent (50%) of the outstanding shares or beneficial
116
+ ownership of such entity.
117
+
118
+ 2. License Grants and Conditions
119
+ --------------------------------
120
+
121
+ 2.1. Grants
122
+
123
+ Each Contributor hereby grants You a world-wide, royalty-free,
124
+ non-exclusive license:
125
+
126
+ (a) under intellectual property rights (other than patent or trademark)
127
+ Licensable by such Contributor to use, reproduce, make available,
128
+ modify, display, perform, distribute, and otherwise exploit its
129
+ Contributions, either on an unmodified basis, with Modifications, or
130
+ as part of a Larger Work; and
131
+
132
+ (b) under Patent Claims of such Contributor to make, use, sell, offer
133
+ for sale, have made, import, and otherwise transfer either its
134
+ Contributions or its Contributor Version.
135
+
136
+ 2.2. Effective Date
137
+
138
+ The licenses granted in Section 2.1 with respect to any Contribution
139
+ become effective for each Contribution on the date the Contributor first
140
+ distributes such Contribution.
141
+
142
+ 2.3. Limitations on Grant Scope
143
+
144
+ The licenses granted in this Section 2 are the only rights granted under
145
+ this License. No additional rights or licenses will be implied from the
146
+ distribution or licensing of Covered Software under this License.
147
+ Notwithstanding Section 2.1(b) above, no patent license is granted by a
148
+ Contributor:
149
+
150
+ (a) for any code that a Contributor has removed from Covered Software;
151
+ or
152
+
153
+ (b) for infringements caused by: (i) Your and any other third party's
154
+ modifications of Covered Software, or (ii) the combination of its
155
+ Contributions with other software (except as part of its Contributor
156
+ Version); or
157
+
158
+ (c) under Patent Claims infringed by Covered Software in the absence of
159
+ its Contributions.
160
+
161
+ This License does not grant any rights in the trademarks, service marks,
162
+ or logos of any Contributor (except as may be necessary to comply with
163
+ the notice requirements in Section 3.4).
164
+
165
+ 2.4. Subsequent Licenses
166
+
167
+ No Contributor makes additional grants as a result of Your choice to
168
+ distribute the Covered Software under a subsequent version of this
169
+ License (see Section 10.2) or under the terms of a Secondary License (if
170
+ permitted under the terms of Section 3.3).
171
+
172
+ 2.5. Representation
173
+
174
+ Each Contributor represents that the Contributor believes its
175
+ Contributions are its original creation(s) or it has sufficient rights
176
+ to grant the rights to its Contributions conveyed by this License.
177
+
178
+ 2.6. Fair Use
179
+
180
+ This License is not intended to limit any rights You have under
181
+ applicable copyright doctrines of fair use, fair dealing, or other
182
+ equivalents.
183
+
184
+ 2.7. Conditions
185
+
186
+ Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
187
+ in Section 2.1.
188
+
189
+ 3. Responsibilities
190
+ -------------------
191
+
192
+ 3.1. Distribution of Source Form
193
+
194
+ All distribution of Covered Software in Source Code Form, including any
195
+ Modifications that You create or to which You contribute, must be under
196
+ the terms of this License. You must inform recipients that the Source
197
+ Code Form of the Covered Software is governed by the terms of this
198
+ License, and how they can obtain a copy of this License. You may not
199
+ attempt to alter or restrict the recipients' rights in the Source Code
200
+ Form.
201
+
202
+ 3.2. Distribution of Executable Form
203
+
204
+ If You distribute Covered Software in Executable Form then:
205
+
206
+ (a) such Covered Software must also be made available in Source Code
207
+ Form, as described in Section 3.1, and You must inform recipients of
208
+ the Executable Form how they can obtain a copy of such Source Code
209
+ Form by reasonable means in a timely manner, at a charge no more
210
+ than the cost of distribution to the recipient; and
211
+
212
+ (b) You may distribute such Executable Form under the terms of this
213
+ License, or sublicense it under different terms, provided that the
214
+ license for the Executable Form does not attempt to limit or alter
215
+ the recipients' rights in the Source Code Form under this License.
216
+
217
+ 3.3. Distribution of a Larger Work
218
+
219
+ You may create and distribute a Larger Work under terms of Your choice,
220
+ provided that You also comply with the requirements of this License for
221
+ the Covered Software. If the Larger Work is a combination of Covered
222
+ Software with a work governed by one or more Secondary Licenses, and the
223
+ Covered Software is not Incompatible With Secondary Licenses, this
224
+ License permits You to additionally distribute such Covered Software
225
+ under the terms of such Secondary License(s), so that the recipient of
226
+ the Larger Work may, at their option, further distribute the Covered
227
+ Software under the terms of either this License or such Secondary
228
+ License(s).
229
+
230
+ 3.4. Notices
231
+
232
+ You may not remove or alter the substance of any license notices
233
+ (including copyright notices, patent notices, disclaimers of warranty,
234
+ or limitations of liability) contained within the Source Code Form of
235
+ the Covered Software, except that You may alter any license notices to
236
+ the extent required to remedy known factual inaccuracies.
237
+
238
+ 3.5. Application of Additional Terms
239
+
240
+ You may choose to offer, and to charge a fee for, warranty, support,
241
+ indemnity or liability obligations to one or more recipients of Covered
242
+ Software. However, You may do so only on Your own behalf, and not on
243
+ behalf of any Contributor. You must make it absolutely clear that any
244
+ such warranty, support, indemnity, or liability obligation is offered by
245
+ You alone, and You hereby agree to indemnify every Contributor for any
246
+ liability incurred by such Contributor as a result of warranty, support,
247
+ indemnity or liability terms You offer. You may include additional
248
+ disclaimers of warranty and limitations of liability specific to any
249
+ jurisdiction.
250
+
251
+ 4. Inability to Comply Due to Statute or Regulation
252
+ ---------------------------------------------------
253
+
254
+ If it is impossible for You to comply with any of the terms of this
255
+ License with respect to some or all of the Covered Software due to
256
+ statute, judicial order, or regulation then You must: (a) comply with
257
+ the terms of this License to the maximum extent possible; and (b)
258
+ describe the limitations and the code they affect. Such description must
259
+ be placed in a text file included with all distributions of the Covered
260
+ Software under this License. Except to the extent prohibited by statute
261
+ or regulation, such description must be sufficiently detailed for a
262
+ recipient of ordinary skill to be able to understand it.
263
+
264
+ 5. Termination
265
+ --------------
266
+
267
+ 5.1. The rights granted under this License will terminate automatically
268
+ if You fail to comply with any of its terms. However, if You become
269
+ compliant, then the rights granted under this License from a particular
270
+ Contributor are reinstated (a) provisionally, unless and until such
271
+ Contributor explicitly and finally terminates Your grants, and (b) on an
272
+ ongoing basis, if such Contributor fails to notify You of the
273
+ non-compliance by some reasonable means prior to 60 days after You have
274
+ come back into compliance. Moreover, Your grants from a particular
275
+ Contributor are reinstated on an ongoing basis if such Contributor
276
+ notifies You of the non-compliance by some reasonable means, this is the
277
+ first time You have received notice of non-compliance with this License
278
+ from such Contributor, and You become compliant prior to 30 days after
279
+ Your receipt of the notice.
280
+
281
+ 5.2. If You initiate litigation against any entity by asserting a patent
282
+ infringement claim (excluding declaratory judgment actions,
283
+ counter-claims, and cross-claims) alleging that a Contributor Version
284
+ directly or indirectly infringes any patent, then the rights granted to
285
+ You by any and all Contributors for the Covered Software under Section
286
+ 2.1 of this License shall terminate.
287
+
288
+ 5.3. In the event of termination under Sections 5.1 or 5.2 above, all
289
+ end user license agreements (excluding distributors and resellers) which
290
+ have been validly granted by You or Your distributors under this License
291
+ prior to termination shall survive termination.
292
+
293
+ ************************************************************************
294
+ * *
295
+ * 6. Disclaimer of Warranty *
296
+ * ------------------------- *
297
+ * *
298
+ * Covered Software is provided under this License on an "as is" *
299
+ * basis, without warranty of any kind, either expressed, implied, or *
300
+ * statutory, including, without limitation, warranties that the *
301
+ * Covered Software is free of defects, merchantable, fit for a *
302
+ * particular purpose or non-infringing. The entire risk as to the *
303
+ * quality and performance of the Covered Software is with You. *
304
+ * Should any Covered Software prove defective in any respect, You *
305
+ * (not any Contributor) assume the cost of any necessary servicing, *
306
+ * repair, or correction. This disclaimer of warranty constitutes an *
307
+ * essential part of this License. No use of any Covered Software is *
308
+ * authorized under this License except under this disclaimer. *
309
+ * *
310
+ ************************************************************************
311
+
312
+ ************************************************************************
313
+ * *
314
+ * 7. Limitation of Liability *
315
+ * -------------------------- *
316
+ * *
317
+ * Under no circumstances and under no legal theory, whether tort *
318
+ * (including negligence), contract, or otherwise, shall any *
319
+ * Contributor, or anyone who distributes Covered Software as *
320
+ * permitted above, be liable to You for any direct, indirect, *
321
+ * special, incidental, or consequential damages of any character *
322
+ * including, without limitation, damages for lost profits, loss of *
323
+ * goodwill, work stoppage, computer failure or malfunction, or any *
324
+ * and all other commercial damages or losses, even if such party *
325
+ * shall have been informed of the possibility of such damages. This *
326
+ * limitation of liability shall not apply to liability for death or *
327
+ * personal injury resulting from such party's negligence to the *
328
+ * extent applicable law prohibits such limitation. Some *
329
+ * jurisdictions do not allow the exclusion or limitation of *
330
+ * incidental or consequential damages, so this exclusion and *
331
+ * limitation may not apply to You. *
332
+ * *
333
+ ************************************************************************
334
+
335
+ 8. Litigation
336
+ -------------
337
+
338
+ Any litigation relating to this License may be brought only in the
339
+ courts of a jurisdiction where the defendant maintains its principal
340
+ place of business and such litigation shall be governed by laws of that
341
+ jurisdiction, without reference to its conflict-of-law provisions.
342
+ Nothing in this Section shall prevent a party's ability to bring
343
+ cross-claims or counter-claims.
344
+
345
+ 9. Miscellaneous
346
+ ----------------
347
+
348
+ This License represents the complete agreement concerning the subject
349
+ matter hereof. If any provision of this License is held to be
350
+ unenforceable, such provision shall be reformed only to the extent
351
+ necessary to make it enforceable. Any law or regulation which provides
352
+ that the language of a contract shall be construed against the drafter
353
+ shall not be used to construe this License against a Contributor.
354
+
355
+ 10. Versions of the License
356
+ ---------------------------
357
+
358
+ 10.1. New Versions
359
+
360
+ Mozilla Foundation is the license steward. Except as provided in Section
361
+ 10.3, no one other than the license steward has the right to modify or
362
+ publish new versions of this License. Each version will be given a
363
+ distinguishing version number.
364
+
365
+ 10.2. Effect of New Versions
366
+
367
+ You may distribute the Covered Software under the terms of the version
368
+ of the License under which You originally received the Covered Software,
369
+ or under the terms of any subsequent version published by the license
370
+ steward.
371
+
372
+ 10.3. Modified Versions
373
+
374
+ If you create software not governed by this License, and you want to
375
+ create a new license for such software, you may create and use a
376
+ modified version of this License if you rename the license and remove
377
+ any references to the name of the license steward (except to note that
378
+ such modified license differs from this License).
379
+
380
+ 10.4. Distributing Source Code Form that is Incompatible With Secondary
381
+ Licenses
382
+
383
+ If You choose to distribute Source Code Form that is Incompatible With
384
+ Secondary Licenses under the terms of this version of the License, the
385
+ notice described in Exhibit B of this License must be attached.
386
+
387
+ Exhibit A - Source Code Form License Notice
388
+ -------------------------------------------
389
+
390
+ This Source Code Form is subject to the terms of the Mozilla Public
391
+ License, v. 2.0. If a copy of the MPL was not distributed with this
392
+ file, You can obtain one at https://mozilla.org/MPL/2.0/.
393
+
394
+ If it is not possible or desirable to put the notice in a particular
395
+ file, then You may include the notice in a location (such as a LICENSE
396
+ file in a relevant directory) where a recipient would be likely to look
397
+ for such a notice.
398
+
399
+ You may add additional accurate notices of copyright ownership.
400
+
401
+ Exhibit B - "Incompatible With Secondary Licenses" Notice
402
+ ---------------------------------------------------------
403
+
404
+ This Source Code Form is "Incompatible With Secondary Licenses", as
405
+ defined by the Mozilla Public License, v. 2.0.
406
+
407
+ ------------------------------------------------------------------------------
408
+
409
+ three 0.185.1
410
+ License: MIT
411
+
412
+ The MIT License
413
+
414
+ Copyright © 2010-2026 three.js authors
415
+
416
+ Permission is hereby granted, free of charge, to any person obtaining a copy
417
+ of this software and associated documentation files (the "Software"), to deal
418
+ in the Software without restriction, including without limitation the rights
419
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
420
+ copies of the Software, and to permit persons to whom the Software is
421
+ furnished to do so, subject to the following conditions:
422
+
423
+ The above copyright notice and this permission notice shall be included in
424
+ all copies or substantial portions of the Software.
425
+
426
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
427
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
428
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
429
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
430
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
431
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
432
+ THE SOFTWARE.
@@ -1,2 +1,2 @@
1
- import{d as e,e as i,f as r,g as A,h as d,i as o}from"./chunks/chunk-M7XD73ED.js";import"./chunks/chunk-FY3BTKY4.js";export{e as AudioBusGraph,i as DEFAULT_SAMPLE_RATE,A as WebAudioMixer,o as WebAudioPlayer,o as WebAudioSink,d as encodeWav,r as mixAudio};
1
+ import{d as e,e as i,f as r,g as A,h as d,i as o}from"./chunks/chunk-2MAFJWBZ.js";import"./chunks/chunk-FY3BTKY4.js";export{e as AudioBusGraph,i as DEFAULT_SAMPLE_RATE,A as WebAudioMixer,o as WebAudioPlayer,o as WebAudioSink,d as encodeWav,r as mixAudio};
2
2
  //# sourceMappingURL=audio.js.map
@@ -0,0 +1,2 @@
1
+ var E=null;function tt(n){E=n}async function N(n){if(!E)return null;try{return await E(n)}catch{return null}}async function U(n){let t=await fetch(n);if(!t.ok){let e=t.statusText?`${t.status} ${t.statusText}`:`${t.status}`;throw new Error(`Fetching "${n}" failed: HTTP ${e}`)}return t.blob()}import{busStopKey as Q}from"@motionscript/core";import{isCurve as C,sourceTimeAtClipElapsed as O}from"@motionscript/core";var I=200;function H(n,t,e,o,c,l,h=a=>a){let a=s=>{let i=h(s);return Number.isFinite(i)?i:t.value};if(!C(e)){t.value=a(e);return}if(!Number.isFinite(c)||c<=0){t.value=a(e.staticValue(t.value));return}let p=o-l,u=e.resolve(c,t.value);if(u.length===0)return;let f=e.sampleAt(Math.max(0,l),c,t.value);t.setValueAtTime(a(f),o);for(let s of u){let i=p+s.startTime,r=p+s.endTime;if(r<=o||!Number.isFinite(i)||!Number.isFinite(r))continue;let d=s.endTime-s.startTime;if(d<=0){t.setValueAtTime(a(s.to),Math.max(i,o));continue}let x=Math.max(0,(o-i)/d),m=Math.max(i,o);if(s.isLinear)x===0&&t.setValueAtTime(a(s.from),m),t.linearRampToValueAtTime(a(s.to),r);else{let y=r-m;if(y<=0)continue;let A=Math.max(2,Math.ceil(y*I)),g=new Float32Array(A);for(let v=0;v<A;v++){let M=x+(1-x)*(v/(A-1));g[v]=a(s.from+(s.to-s.from)*s.ease(M))}t.setValueCurveAtTime(g,m,y)}}}function b(n,t,e,o=n.currentTime,c=0,l=0){let h=[],a=[],p=t,u=s=>{p.connect(s),h.push(s),p=s},f=(s,i,r)=>H(n,s,i,o,c,l,r);for(let s of e)switch(s.type){case"gain":{let i=n.createGain();f(i.gain,s.value),u(i);break}case"highpass":case"lowpass":{let i=n.createBiquadFilter();i.type=s.type==="highpass"?"highpass":"lowpass",f(i.frequency,s.frequency),s.q!==void 0&&f(i.Q,s.q),u(i);break}case"tremolo":{let i=n.createGain(),r=n.createOscillator(),d=n.createGain();f(i.gain,s.depth,x=>1-S(x)/2),f(d.gain,s.depth,x=>S(x)/2),f(r.frequency,s.rate),r.connect(d),d.connect(i.gain),h.push(d),a.push(r),u(i);break}case"echo":{let i=p,r=n.createGain(),d=n.createGain();f(d.gain,s.mix??.5,g=>1-S(g)),i.connect(d),d.connect(r);let x=K(s.delay),m=n.createDelay(Math.max(1,x+1));f(m.delayTime,s.delay);let y=n.createGain();f(y.gain,s.feedback,g=>Math.max(0,Math.min(.99,g)));let A=n.createGain();f(A.gain,s.mix??.5,g=>S(g)),i.connect(m),m.connect(y),y.connect(m),m.connect(A),A.connect(r),h.push(d,m,y,A,r),p=r;break}case"speed":break}return{output:p,nodes:h,oscillators:a}}function S(n){return Math.max(0,Math.min(1,n))}function K(n){return C(n)?n.staticValue(0):n}function F(n){if(!n)return 1;let t=1;for(let e of n)e.type==="speed"&&!C(e.value)&&e.value>0&&(t*=e.value);return t}function G(n){if(n){for(let t of n)if(t.type==="speed"&&C(t.value))return t.value}}function R(n,t,e,o,c,l,h){if(!t)return;let a=1/I,p=Math.max(0,h),u=O(t,e,p);n.setValueAtTime(Math.max(1e-4,t.sampleAt(u,e,1)*c),l);for(let f=p+a;f<=o+a;f+=a){let s=Math.min(f,o),i=O(t,e,s),r=Math.max(1e-4,t.sampleAt(i,e,1)*c),d=l+(s-p);if(n.linearRampToValueAtTime(r,d),s>=o)break}}var w=class{ctx;destination;constructor(t,e){this.ctx=t,this.destination=e}inputFor(t,e,o){return!t||t.length===0?this.destination:this.chainFrom(t,0,e,o)}dispose(){for(let t of this.nodes)try{t.disconnect()}catch{}for(let t of this.oscillators)try{t.stop()}catch{}this.nodes.length=0,this.oscillators.length=0,this.inputs.clear()}inputs=new Map;nodes=[];oscillators=[];chainFrom(t,e,o,c){if(e>=t.length)return this.destination;let l=t[e],h=t.slice(e).map(Q).join(">"),a=this.inputs.get(h);if(a)return a;let p=this.chainFrom(t,e+1,o,c),u=this.ctx.createGain();u.gain.value=1;let f={type:"gain",value:l.mute?0:l.volume},s=b(this.ctx,u,[...l.filters??[],f],o,l.endAt-l.startAt,c-l.startAt);s.output.connect(p),this.nodes.push(u,...s.nodes),this.oscillators.push(...s.oscillators);for(let i of s.oscillators)i.start(o);return this.inputs.set(h,u),u}};import{sourceTimeAtClipElapsed as J}from"@motionscript/core";function z(n,t){if(!n.loop)return null;let e=Math.min(Math.max(0,n.trimStart),t),o=Math.min(n.trimEnd??t,t);return o>e?{start:e,end:o}:null}function k(n,t){n.loop=t.loop;let e=n.buffer?z(t,n.buffer.duration):null;return e&&(n.loopStart=e.start,n.loopEnd=e.end),e}function _(n,t){return!n||t<n.end?t:n.start+(t-n.start)%(n.end-n.start)}var D=44100;function P(n,t){if(!t)return n;try{return t.getAudioMeta(n).src||n}catch{try{return t.getVideoMeta(n).src||n}catch{return n}}}async function X(n,t){let e=await N(n)??await U(n);return t.decodeAudioData(await e.arrayBuffer())}async function Y(n,t,e={}){if(n.length===0)return null;let o=e.sampleRate??D,c=Math.ceil(t*o);if(c<=0)return null;let l=[...new Set(n.map(s=>s.request.src))],h=new OfflineAudioContext(2,c,o),a=new Set(n.filter(s=>!s.request.optional).map(s=>s.request.src)),p=new Map;await Promise.all(l.map(async s=>{try{p.set(s,await X(P(s,e.catalog),h))}catch(i){if(a.has(s))throw i}}));let u=new OfflineAudioContext(2,c,o),f=new w(u,u.destination);for(let{request:s,globalOffset:i}of n){let r=p.get(s.src);if(!r)continue;let d=i+s.startAt,m=Math.min(i+s.endAt,t)-d;if(m<=0)continue;let y=u.createBufferSource();y.buffer=r,k(y,s);let A=F(s.filters),g=Number.isFinite(A)&&A>0?A:1,v=G(s.filters);g!==1&&!v&&(y.playbackRate.value=g);let M=u.createGain();M.gain.value=Number.isFinite(s.volume)?s.volume:1;let T=Math.max(0,r.duration-s.trimStart),B=Number.isFinite(s.endAt)?Math.max(0,s.endAt-s.startAt):T/g,V=b(u,y,s.filters??[],d,B,0);V.output.connect(M),M.connect(f.inputFor(s.bus,0,-i)),v&&R(y.playbackRate,v,T,B,g,d,0);let j=v?J(v,T,m):m*g;y.start(d,s.trimStart,j);for(let W of V.oscillators)W.start(d)}return u.startRendering()}var L=class{sampleRate;catalog;constructor(t=D,e){this.sampleRate=t,this.catalog=e}mix(t,e){return Y(t,e,{sampleRate:this.sampleRate,catalog:this.catalog})}};function pt(n){let t=n.numberOfChannels,e=n.length,o=2,c=t*o,l=e*c,h=new ArrayBuffer(44+l),a=new DataView(h),p=(s,i)=>{for(let r=0;r<i.length;r++)a.setUint8(s+r,i.charCodeAt(r))};p(0,"RIFF"),a.setUint32(4,36+l,!0),p(8,"WAVE"),p(12,"fmt "),a.setUint32(16,16,!0),a.setUint16(20,1,!0),a.setUint16(22,t,!0),a.setUint32(24,n.sampleRate,!0),a.setUint32(28,n.sampleRate*c,!0),a.setUint16(32,c,!0),a.setUint16(34,8*o,!0),p(36,"data"),a.setUint32(40,l,!0);let u=[];for(let s=0;s<t;s++)u.push(n.getChannelData(s));let f=44;for(let s=0;s<e;s++)for(let i=0;i<t;i++){let r=Math.max(-1,Math.min(1,u[i][s]));a.setInt16(f,r<0?r*32768:r*32767,!0),f+=o}return new Uint8Array(h)}import{AudioSink as Z,sourceTimeAtClipElapsed as q}from"@motionscript/core";var $=class extends Z{context;ownsContext;bufferCache=new Map;decoding=new Map;active=new Map;scheduled=[];disposed=!1;masterGain;buses;muted=!1;volume=1;constructor(t){super(),this.context=t??new AudioContext,this.ownsContext=!t,this.masterGain=this.context.createGain(),this.masterGain.connect(this.context.destination),this.buses=new w(this.context,this.masterGain)}getContext(){return this.context}unlock(){this.context.state==="suspended"&&this.context.resume()}has(t){return this.bufferCache.has(t)}async append(t,e){if(this.bufferCache.has(t))return;let o=this.decoding.get(t);if(o)return o;let c=this.context.decodeAudioData(e).then(l=>{this.bufferCache.set(t,l)}).finally(()=>{this.decoding.delete(t)});this.decoding.set(t,c),await c}retain(t){for(let e of[...this.bufferCache.keys()])t.has(e)||this.bufferCache.delete(e);for(let[e,o]of this.active)t.has(o.request.src)||this.stopSource(e,o)}schedule(t){let e=new Set(t.map(o=>o.id));for(let[o,c]of this.active)e.has(o)||this.stopSource(o,c);this.scheduled=t.slice()}syncTo(t){let e=new Set;for(let o of this.scheduled)if(t>=o.startAt&&t<o.endAt&&(e.add(o.id),!this.active.has(o.id))){let l=this.bufferCache.get(o.src);l&&this.playBuffer(l,o,t)}for(let[o,c]of this.active)e.has(o)||this.stopSource(o,c)}async play(t,e,o){this.context.state==="suspended"&&await this.context.resume(),this.syncTo(t)}stop(){for(let[t,e]of this.active)this.stopSource(t,e);this.buses.dispose()}setMuted(t){this.muted=t,this.applyMasterGain()}setVolume(t){this.volume=Math.max(0,t),this.applyMasterGain()}applyMasterGain(){this.masterGain.gain.value=this.muted?0:this.volume}playBuffer(t,e,o){let c=this.context.currentTime,l=this.context.createGain();l.gain.value=Number.isFinite(e.volume)?e.volume:1,l.connect(this.buses.inputFor(e.bus,c,o));let h=this.context.createBufferSource();h.buffer=t;let a=k(h,e),p=F(e.filters),u=Number.isFinite(p)&&p>0?p:1,f=G(e.filters);u!==1&&!f&&(h.playbackRate.value=u);let s=Math.max(0,o-e.startAt),i=Math.max(0,t.duration-e.trimStart),r=isFinite(e.endAt)?Math.max(0,e.endAt-e.startAt):i/(u||1),d=b(this.context,h,e.filters??[],c,r,s);d.output.connect(l);let x;f?(x=e.trimStart+q(f,i,s),R(h.playbackRate,f,i,r,u,c,s)):x=e.trimStart+s*u,h.start(c,_(a,x));for(let m of d.oscillators)m.start(c);h.onended=()=>{this.active.get(e.id)?.source===h&&this.active.delete(e.id)},this.active.set(e.id,{source:h,gainNode:l,request:e,filterNodes:d.nodes,oscillators:d.oscillators})}stopSource(t,e){try{e.source.onended=null,e.source.stop();for(let o of e.oscillators)o.stop();e.source.disconnect();for(let o of e.filterNodes)o.disconnect();e.gainNode.disconnect()}catch{}this.active.delete(t)}dispose(){if(!this.disposed){this.disposed=!0,super.dispose(),this.bufferCache.clear(),this.decoding.clear(),this.scheduled.length=0,this.buses.dispose();try{this.masterGain.disconnect()}catch{}this.ownsContext&&this.context.state!=="closed"&&this.context.close()}}};export{tt as a,N as b,U as c,w as d,D as e,Y as f,L as g,pt as h,$ as i};
2
+ //# sourceMappingURL=chunk-2MAFJWBZ.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/asset-bytes.ts", "../../../src/audio/bus-graph.ts", "../../../src/audio/filter-graph.ts", "../../../src/audio/mixer.ts", "../../../src/audio/loop-region.ts", "../../../src/audio/player.ts"],
4
+ "sourcesContent": ["/**\r\n * Where a source URL's bytes come from: a host's local store, then the network.\r\n *\r\n * ## Why the web adapter needs this at all\r\n *\r\n * `WebStorageAdapter` addresses every asset by URL and fetches it. That is\r\n * right for an asset that lives somewhere, and wrong for one whose bytes the\r\n * host already has in hand — a file the user has just chosen, a render a local\r\n * model has just produced, a picture whose upload has not finished or cannot\r\n * start because there is no network. In all three the adapter downloads bytes\r\n * that never needed to travel.\r\n *\r\n * `NodeStorageAdapter` has had the answer since it was written: an injected\r\n * `AssetLoader`, with an `inline` map consulted ahead of the disk. This is the\r\n * same seam for the browser.\r\n *\r\n * ## Why it is module-level\r\n *\r\n * `WebStorageAdapter` is constructed at five sites *inside* these packages —\r\n * the React player backend, the exporter, the audio mixer, and both still\r\n * renderers — none of which a host can reach. A constructor argument would\r\n * therefore cover the preview and leave export and stills on the network,\r\n * which is the worst of both: the picture a user sees would come from local\r\n * bytes and the one they render would not.\r\n *\r\n * So this is an *injection point*, not a cache. The adapter still owns every\r\n * decode, every cache, every size ceiling and every eviction rule; all this\r\n * changes is where the compressed bytes came from. A source that answers `null`\r\n * — which is what an unregistered URL, an evicted entry or a host with no local\r\n * store does — leaves the adapter exactly as it was.\r\n */\r\n\r\n/** Local bytes for a source URL, or `null` to go to the network. */\r\nexport type AssetByteSource = (src: string) => Promise<Blob | null>;\r\n\r\nlet source: AssetByteSource | null = null;\r\n\r\n/**\r\n * Installs the byte source for this browsing context, or clears it with `null`.\r\n *\r\n * Called once per window that renders. Later calls replace the previous source\r\n * rather than stacking, because two sources disagreeing about one URL has no\r\n * sensible answer.\r\n */\r\nexport function setAssetByteSource(next: AssetByteSource | null): void {\r\n source = next;\r\n}\r\n\r\n/**\r\n * The bytes for `src`, or `null`.\r\n *\r\n * Swallows a throwing source on purpose. A host's local store failing is a\r\n * cache miss, not a render failure — the caller falls through to `fetch`, which\r\n * is what it would have done had the source never been installed.\r\n */\r\nexport async function localAssetBytes(src: string): Promise<Blob | null> {\r\n if (!source) return null;\r\n try {\r\n return await source(src);\r\n } catch {\r\n return null;\r\n }\r\n}\r\n\r\n/**\r\n * The network's bytes for `url`. A response that is not OK is a failed load,\r\n * never bytes: a 404 page handed to the font manager marked a family loaded\r\n * with no face in it.\r\n */\r\nexport async function fetchAssetBytes(url: string): Promise<Blob> {\r\n const response = await fetch(url);\r\n if (!response.ok) {\r\n const status = response.statusText ? `${response.status} ${response.statusText}` : `${response.status}`;\r\n throw new Error(`Fetching \"${url}\" failed: HTTP ${status}`);\r\n }\r\n return response.blob();\r\n}\r\n", "import { busStopKey, type AudioBusStop, type AudioFilterItem } from \"@motionscript/core\";\r\nimport { buildAudioFilterGraph } from \"./filter-graph\";\r\n\r\n/**\r\n * The live chains for one audio context's buses.\r\n *\r\n * Held per context rather than per clip, because that is the whole difference\r\n * between a bus and per-clip processing: every clip naming a bus connects into\r\n * the *same* nodes, so a reverb on a bus is one tail the group shares rather\r\n * than one tail each. Flattening the levels into per-clip gain would sound\r\n * right; flattening the effects would not.\r\n */\r\nexport class AudioBusGraph {\r\n constructor(\r\n private readonly ctx: BaseAudioContext,\r\n /** Where the last bus in a chain connects — the master, or the destination. */\r\n private readonly destination: AudioNode,\r\n ) { }\r\n\r\n /**\r\n * The input node a clip on `bus` should connect to, building the chain the\r\n * first time it is asked for.\r\n *\r\n * `bus` is source-adjacent first, so `bus[0]` is the one the clip feeds and\r\n * each stop after it is that bus's own parent. An empty or absent chain\r\n * returns the destination, which is what every clip did before buses\r\n * existed.\r\n *\r\n * `startTime` is the context time a new chain's schedule starts from, and\r\n * `clipTime` the same instant in the stops' own seconds. A curve on a stop\r\n * runs over its `startAt`–`endAt`, so the two are what place it.\r\n */\r\n inputFor(bus: readonly AudioBusStop[] | undefined, startTime: number, clipTime: number): AudioNode {\r\n if (!bus || bus.length === 0) return this.destination;\r\n return this.chainFrom(bus, 0, startTime, clipTime);\r\n }\r\n\r\n /** Disconnect every live bus node, so the next {@link inputFor} builds afresh. Safe to call more than once. */\r\n dispose(): void {\r\n for (const node of this.nodes) {\r\n try { node.disconnect(); } catch { /* already torn down */ }\r\n }\r\n for (const osc of this.oscillators) {\r\n try { osc.stop(); } catch { /* never started, or already stopped */ }\r\n }\r\n this.nodes.length = 0;\r\n this.oscillators.length = 0;\r\n this.inputs.clear();\r\n }\r\n\r\n private readonly inputs = new Map<string, AudioNode>();\r\n private readonly nodes: AudioNode[] = [];\r\n private readonly oscillators: OscillatorNode[] = [];\r\n\r\n /**\r\n * Build (or reuse) the chain for `bus[index]`, connected to whatever\r\n * `bus[index + 1]` resolves to.\r\n *\r\n * Recursive rather than iterative because a bus's *output* has to exist\r\n * before its own nodes can connect to it, and the outermost bus is the last\r\n * entry.\r\n *\r\n * Reused by everything that changes what it sounds like, down to the master,\r\n * not by id alone: a bus edited under a playing device, or one id on two\r\n * tracks, is a different chain, and one built for the first would play the\r\n * second through stale levels and a curve anchored to the wrong span.\r\n */\r\n private chainFrom(bus: readonly AudioBusStop[], index: number, startTime: number, clipTime: number): AudioNode {\r\n if (index >= bus.length) return this.destination;\r\n\r\n const stop = bus[index];\r\n const key = bus.slice(index).map(busStopKey).join(\">\");\r\n const existing = this.inputs.get(key);\r\n if (existing) return existing;\r\n\r\n const output = this.chainFrom(bus, index + 1, startTime, clipTime);\r\n\r\n // A pass-through head every clip connects to, so the bus has one input\r\n // whatever its filters turn out to be.\r\n const input = this.ctx.createGain();\r\n input.gain.value = 1;\r\n\r\n // The level is a gain after the filters, as a sound's own level is, so a\r\n // curve on it is scheduled exactly as one in `filters` is.\r\n const level: AudioFilterItem = { type: \"gain\", value: stop.mute ? 0 : stop.volume };\r\n const graph = buildAudioFilterGraph(\r\n this.ctx, input, [...(stop.filters ?? []), level],\r\n startTime, stop.endAt - stop.startAt, clipTime - stop.startAt,\r\n );\r\n graph.output.connect(output);\r\n\r\n this.nodes.push(input, ...graph.nodes);\r\n this.oscillators.push(...graph.oscillators);\r\n for (const osc of graph.oscillators) osc.start(startTime);\r\n\r\n this.inputs.set(key, input);\r\n return input;\r\n }\r\n}\r\n", "import { AudioFilterItem, Param, isCurve, sourceTimeAtClipElapsed } from \"@motionscript/core\";\r\n\r\n/**\r\n * Result of building an audio-filter graph for one source.\r\n *\r\n * - `output` is the last node in the chain; connect it downstream (e.g. to the\r\n * per-request gain node).\r\n * - `nodes` are every intermediate node, so callers can `disconnect()` them on\r\n * teardown.\r\n * - `oscillators` are LFOs (from `tremolo`) the caller must `start()` — and may\r\n * `stop()` — alongside the source, since oscillators need an explicit start.\r\n */\r\nexport interface AudioFilterGraph {\r\n output: AudioNode;\r\n nodes: AudioNode[];\r\n oscillators: OscillatorNode[];\r\n}\r\n\r\n/**\r\n * How many sample points per second to bake an eased curve segment into for\r\n * `setValueCurveAtTime`. 200/s (≈ every 5ms) is smooth to the ear and cheap.\r\n */\r\nconst CURVE_SAMPLES_PER_SECOND = 200;\r\n\r\n/**\r\n * Apply a (possibly time-varying) {@link Param} to a Web Audio {@link AudioParam}.\r\n *\r\n * - **number** → set once (today's behavior; zero scheduling overhead).\r\n * - **Curve** → resolve against `clipDuration` and schedule each segment:\r\n * - linear segments via `setValueAtTime` + `linearRampToValueAtTime`,\r\n * - eased segments baked into a `Float32Array` via `setValueCurveAtTime`.\r\n *\r\n * `elapsed` (clip-seconds already played when a mid-clip seek starts the source)\r\n * shifts the schedule back by `elapsed` so \"now\" reads the curve's value at the\r\n * clip's *current* position, not its start. A `clamp(v)` hook lets a param keep a\r\n * valid range (e.g. echo mix 0–1) at every sampled point.\r\n */\r\nfunction applyParam(\r\n ctx: BaseAudioContext,\r\n audioParam: AudioParam,\r\n param: Param,\r\n startTime: number,\r\n clipDuration: number,\r\n elapsed: number,\r\n clamp: (v: number) => number = (v) => v,\r\n): void {\r\n // Coerce to a finite value before touching an AudioParam — the platform throws\r\n // on NaN/Infinity. Falls back to the current param value (never undefined here).\r\n const finite = (v: number): number => {\r\n const c = clamp(v);\r\n return Number.isFinite(c) ? c : audioParam.value;\r\n };\r\n\r\n if (!isCurve(param)) {\r\n audioParam.value = finite(param);\r\n return;\r\n }\r\n\r\n // A non-finite clip length yields no usable schedule; hold the curve's start value.\r\n if (!Number.isFinite(clipDuration) || clipDuration <= 0) {\r\n audioParam.value = finite(param.staticValue(audioParam.value));\r\n return;\r\n }\r\n\r\n const base = startTime - elapsed; // map curve t=0 to here so seeks line up\r\n const resolved = param.resolve(clipDuration, audioParam.value);\r\n if (resolved.length === 0) return;\r\n\r\n // Anchor the starting value at `startTime` (the seek point) so there is no\r\n // jump from the param's default before the first scheduled segment runs.\r\n const startValue = param.sampleAt(Math.max(0, elapsed), clipDuration, audioParam.value);\r\n audioParam.setValueAtTime(finite(startValue), startTime);\r\n\r\n for (const seg of resolved) {\r\n const segStart = base + seg.startTime;\r\n const segEnd = base + seg.endTime;\r\n // Skip segments wholly in the past relative to the seek point, or any with a\r\n // non-finite boundary (degenerate resolve) that would throw on schedule.\r\n if (segEnd <= startTime || !Number.isFinite(segStart) || !Number.isFinite(segEnd)) continue;\r\n\r\n const span = seg.endTime - seg.startTime;\r\n\r\n if (span <= 0) {\r\n audioParam.setValueAtTime(finite(seg.to), Math.max(segStart, startTime));\r\n continue;\r\n }\r\n\r\n // How far through this segment the seek lands. A segment already under way\r\n // carries on from the anchor rather than starting over from its `from` —\r\n // the case a bus hits whenever its first clip enters partway through it.\r\n const done = Math.max(0, (startTime - segStart) / span);\r\n const curveStart = Math.max(segStart, startTime);\r\n\r\n if (seg.isLinear) {\r\n if (done === 0) audioParam.setValueAtTime(finite(seg.from), curveStart);\r\n audioParam.linearRampToValueAtTime(finite(seg.to), segEnd);\r\n } else {\r\n const curveDur = segEnd - curveStart;\r\n if (curveDur <= 0) continue;\r\n const count = Math.max(2, Math.ceil(curveDur * CURVE_SAMPLES_PER_SECOND));\r\n const samples = new Float32Array(count);\r\n for (let i = 0; i < count; i++) {\r\n const local = done + (1 - done) * (i / (count - 1));\r\n samples[i] = finite(seg.from + (seg.to - seg.from) * seg.ease(local));\r\n }\r\n audioParam.setValueCurveAtTime(samples, curveStart, curveDur);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Builds the Web Audio graph for a clip's filter chain, returning the node to\r\n * connect downstream. Shared by live playback ({@link WebAudioSink}) and\r\n * offline export (`mixAudio`) so both paths sound identical.\r\n *\r\n * Filters apply in array order (index 0 closest to the source). `speed` filters\r\n * are intentionally ignored here — they're realized via `source.playbackRate`\r\n * by the caller (and affect timeline scheduling), not as a graph node.\r\n *\r\n * `startTime` is the AudioContext time the source starts; `clipDuration` is the\r\n * clip-time length the curves run over (a clip's, or a bus's span); `elapsed` is\r\n * clip-seconds already played at a mid-clip seek (0 for a clean start, negative\r\n * before the span begins). These let curve-valued params schedule and align.\r\n *\r\n * Pass the already-created `source` so its `playbackRate` can be set by the\r\n * caller; this function only wires nodes *after* the source.\r\n */\r\nexport function buildAudioFilterGraph(\r\n ctx: BaseAudioContext,\r\n source: AudioNode,\r\n filters: readonly AudioFilterItem[],\r\n startTime: number = ctx.currentTime,\r\n clipDuration: number = 0,\r\n elapsed: number = 0,\r\n): AudioFilterGraph {\r\n const nodes: AudioNode[] = [];\r\n const oscillators: OscillatorNode[] = [];\r\n let cursor: AudioNode = source;\r\n\r\n const series = (node: AudioNode): void => {\r\n cursor.connect(node);\r\n nodes.push(node);\r\n cursor = node;\r\n };\r\n\r\n const apply = (p: AudioParam, v: Param, clamp?: (n: number) => number): void =>\r\n applyParam(ctx, p, v, startTime, clipDuration, elapsed, clamp);\r\n\r\n for (const filter of filters) {\r\n switch (filter.type) {\r\n case \"gain\": {\r\n const gain = ctx.createGain();\r\n apply(gain.gain, filter.value);\r\n series(gain);\r\n break;\r\n }\r\n case \"highpass\":\r\n case \"lowpass\": {\r\n const biquad = ctx.createBiquadFilter();\r\n biquad.type = filter.type === \"highpass\" ? \"highpass\" : \"lowpass\";\r\n apply(biquad.frequency, filter.frequency);\r\n if (filter.q !== undefined) apply(biquad.Q, filter.q);\r\n series(biquad);\r\n break;\r\n }\r\n case \"tremolo\": {\r\n // Carrier gain whose value is modulated by an LFO. With depth d the\r\n // carrier base = (1 - d/2) and the LFO swing gain = d/2. The clamp\r\n // hook applies these transforms whether depth is scalar or a curve.\r\n const carrier = ctx.createGain();\r\n const lfo = ctx.createOscillator();\r\n const lfoDepth = ctx.createGain();\r\n\r\n apply(carrier.gain, filter.depth, (d) => 1 - clamp01(d) / 2);\r\n apply(lfoDepth.gain, filter.depth, (d) => clamp01(d) / 2);\r\n apply(lfo.frequency, filter.rate);\r\n\r\n lfo.connect(lfoDepth);\r\n lfoDepth.connect(carrier.gain);\r\n\r\n nodes.push(lfoDepth);\r\n oscillators.push(lfo);\r\n series(carrier);\r\n break;\r\n }\r\n case \"echo\": {\r\n // Dry + wet split. The wet path is a delay with feedback; both sum\r\n // into a merge node that becomes the new cursor.\r\n const split = cursor;\r\n const merge = ctx.createGain();\r\n\r\n const dry = ctx.createGain();\r\n apply(dry.gain, filter.mix ?? 0.5, (m) => 1 - clamp01(m));\r\n split.connect(dry);\r\n dry.connect(merge);\r\n\r\n // Delay buffer must accommodate the max delay; size from the static value.\r\n const maxDelay = staticOf(filter.delay);\r\n const delay = ctx.createDelay(Math.max(1, maxDelay + 1));\r\n apply(delay.delayTime, filter.delay);\r\n const feedbackGain = ctx.createGain();\r\n apply(feedbackGain.gain, filter.feedback, (f) => Math.max(0, Math.min(0.99, f)));\r\n const wet = ctx.createGain();\r\n apply(wet.gain, filter.mix ?? 0.5, (m) => clamp01(m));\r\n\r\n split.connect(delay);\r\n delay.connect(feedbackGain);\r\n feedbackGain.connect(delay); // feedback loop\r\n delay.connect(wet);\r\n wet.connect(merge);\r\n\r\n nodes.push(dry, delay, feedbackGain, wet, merge);\r\n cursor = merge;\r\n break;\r\n }\r\n case \"speed\":\r\n // Realized via source.playbackRate by the caller; no graph node.\r\n break;\r\n }\r\n }\r\n\r\n return { output: cursor, nodes, oscillators };\r\n}\r\n\r\n/** Clamp to [0, 1]. */\r\nfunction clamp01(v: number): number {\r\n return Math.max(0, Math.min(1, v));\r\n}\r\n\r\n/** The static/representative number of a param (number itself, or curve's t=0 value). */\r\nfunction staticOf(p: Param): number {\r\n return isCurve(p) ? p.staticValue(0) : p;\r\n}\r\n\r\n/**\r\n * Net *constant* playback-rate multiplier from any scalar `speed` filters in the\r\n * chain (product of all), defaulting to 1. Curve-valued speeds contribute 1 here\r\n * and are scheduled separately by {@link applySpeedToPlaybackRate}. Mirrors\r\n * `Sound.effectiveSpeed()` so the renderer applies the same rate the core timeline\r\n * reserved time for.\r\n */\r\nexport function effectiveSpeed(filters: readonly AudioFilterItem[] | undefined): number {\r\n if (!filters) return 1;\r\n let speed = 1;\r\n for (const f of filters) {\r\n if (f.type === \"speed\" && !isCurve(f.value) && f.value > 0) speed *= f.value;\r\n }\r\n return speed;\r\n}\r\n\r\n/** The first curve-valued `speed` filter in the chain, if any. */\r\nexport function speedCurveOf(filters: readonly AudioFilterItem[] | undefined) {\r\n if (!filters) return undefined;\r\n for (const f of filters) {\r\n if (f.type === \"speed\" && isCurve(f.value)) return f.value;\r\n }\r\n return undefined;\r\n}\r\n\r\n/**\r\n * Schedule a time-varying speed curve onto an `AudioBufferSourceNode.playbackRate`.\r\n *\r\n * The curve is authored over **source time** (rate as a function of how far through\r\n * the source we've played). `setValueAtTime`/`linearRampToValueAtTime` schedule in\r\n * **context time**, so we walk clip-time forward in small steps, convert each to a\r\n * source-time offset via the integral inverse, read the curve there, and lay down a\r\n * value point at the matching context time. `scalar` folds in any constant speed\r\n * filters (they scale the whole rate uniformly).\r\n *\r\n * `elapsed` is clip-seconds already played at a mid-clip seek, so the schedule\r\n * starts at the seek point and aligns the playbackRate to the clip's true position.\r\n */\r\nexport function applySpeedToPlaybackRate(\r\n rate: AudioParam,\r\n curve: ReturnType<typeof speedCurveOf>,\r\n sourceLength: number,\r\n clipDuration: number,\r\n scalar: number,\r\n startTime: number,\r\n elapsed: number,\r\n): void {\r\n if (!curve) return;\r\n const step = 1 / CURVE_SAMPLES_PER_SECOND; // clip-time sampling step\r\n const seekAt = Math.max(0, elapsed);\r\n // Seed the value exactly at the seek point.\r\n const seedSrc = sourceTimeAtClipElapsed(curve, sourceLength, seekAt);\r\n rate.setValueAtTime(Math.max(1e-4, curve.sampleAt(seedSrc, sourceLength, 1) * scalar), startTime);\r\n\r\n for (let s = seekAt + step; s <= clipDuration + step; s += step) {\r\n const clampedElapsed = Math.min(s, clipDuration);\r\n const srcT = sourceTimeAtClipElapsed(curve, sourceLength, clampedElapsed);\r\n const value = Math.max(1e-4, curve.sampleAt(srcT, sourceLength, 1) * scalar);\r\n const ctxTime = startTime + (clampedElapsed - seekAt);\r\n rate.linearRampToValueAtTime(value, ctxTime);\r\n if (clampedElapsed >= clipDuration) break;\r\n }\r\n}\r\n", "import { sourceTimeAtClipElapsed, type AssetCatalog } from \"@motionscript/core\";\r\nimport type { AudioMixer, ScheduledAudioRequest } from \"@motionscript/skia-render/export\";\r\nimport { fetchAssetBytes, localAssetBytes } from \"../asset-bytes\";\r\nimport { AudioBusGraph } from \"./bus-graph\";\r\nimport { applyLoop } from \"./loop-region\";\r\nimport {\r\n applySpeedToPlaybackRate,\r\n buildAudioFilterGraph,\r\n effectiveSpeed,\r\n speedCurveOf,\r\n} from \"./filter-graph\";\r\n\r\n/** Sample rate used when the caller doesn't pick one. */\r\nexport const DEFAULT_SAMPLE_RATE = 44100;\r\n\r\nexport interface MixAudioOptions {\r\n /** Defaults to {@link DEFAULT_SAMPLE_RATE}. */\r\n sampleRate?: number;\r\n /**\r\n * Resolves a request's `src` to the address its bytes live at, the same job\r\n * `WebStorageAdapter.assetUrl` does for the live paths. Omitted, a `src` is\r\n * fetched as written — right only while the host keys its manifest by URL.\r\n */\r\n catalog?: AssetCatalog;\r\n}\r\n\r\n/** Audio first, then video: a clip's own soundtrack is requested under the video's key. */\r\nfunction audioUrl(src: string, catalog: AssetCatalog | undefined): string {\r\n if (!catalog) return src;\r\n try {\r\n return catalog.getAudioMeta(src).src || src;\r\n } catch {\r\n try {\r\n return catalog.getVideoMeta(src).src || src;\r\n } catch {\r\n return src;\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Reads and decodes an audio source against a scratch `OfflineAudioContext`\r\n * (decoding requires a context but doesn't render through it). The host's byte\r\n * source is asked first, as for every other asset read: a mix that went to the\r\n * network would fail where the preview played, offline or for bytes not yet\r\n * uploaded.\r\n */\r\nasync function fetchAudioBuffer(src: string, ctx: OfflineAudioContext): Promise<AudioBuffer> {\r\n const blob = (await localAssetBytes(src)) ?? (await fetchAssetBytes(src));\r\n return ctx.decodeAudioData(await blob.arrayBuffer());\r\n}\r\n\r\n/**\r\n * Render every scheduled request into one timeline-length buffer.\r\n *\r\n * An `OfflineAudioContext` graph — gain per request, looping/trimming, and the\r\n * same filter chain the live {@link WebAudioSink} builds — rendered in one\r\n * pass rather than scheduled per frame.\r\n *\r\n * Shared by the video exporter and by `mixTimelineAudio`, deliberately: a split\r\n * export and a whole one have to be the same mix, and two implementations of\r\n * \"stack these clips\" would eventually disagree.\r\n *\r\n * Curve-valued filter params and `speed` curves schedule here exactly as they do\r\n * in {@link WebAudioSink.playBuffer}, which is the reference implementation —\r\n * the two must be read side by side when either changes.\r\n *\r\n * One deliberate difference: this schedules at absolute context times, so clip\r\n * starts are sample-accurate here and quantized to `1/fps` in live playback,\r\n * which starts sources at `currentTime` on a clock tick.\r\n */\r\nexport async function mixAudio(\r\n requests: readonly ScheduledAudioRequest[],\r\n totalDuration: number,\r\n options: MixAudioOptions = {},\r\n): Promise<AudioBuffer | null> {\r\n if (requests.length === 0) return null;\r\n const sampleRate = options.sampleRate ?? DEFAULT_SAMPLE_RATE;\r\n const frames = Math.ceil(totalDuration * sampleRate);\r\n if (frames <= 0) return null;\r\n\r\n const uniqueSrcs = [...new Set(requests.map(r => r.request.src))];\r\n const scratchCtx = new OfflineAudioContext(2, frames, sampleRate);\r\n\r\n // A source only a picture's own sound wants may hold no audio at all, which\r\n // is silence rather than a failed mix — see `AudioRequest.optional`.\r\n const asked = new Set(requests.filter(r => !r.request.optional).map(r => r.request.src));\r\n const decoded = new Map<string, AudioBuffer>();\r\n await Promise.all(uniqueSrcs.map(async (src) => {\r\n try {\r\n decoded.set(src, await fetchAudioBuffer(audioUrl(src, options.catalog), scratchCtx));\r\n } catch (cause) {\r\n if (asked.has(src)) throw cause;\r\n }\r\n }));\r\n\r\n const mixCtx = new OfflineAudioContext(2, frames, sampleRate);\r\n // The same shared-chain rule the live device uses, for the same reason: an\r\n // export that flattened buses into per-clip processing would not match what\r\n // the preview sounded like.\r\n const buses = new AudioBusGraph(mixCtx, mixCtx.destination);\r\n\r\n for (const { request: req, globalOffset } of requests) {\r\n const srcBuffer = decoded.get(req.src);\r\n if (!srcBuffer) continue;\r\n\r\n const globalStart = globalOffset + req.startAt;\r\n // `endAt` is `Infinity` for an open clip; either way the timeline bounds it.\r\n const globalEnd = Math.min(globalOffset + req.endAt, totalDuration);\r\n const playDuration = globalEnd - globalStart;\r\n if (playDuration <= 0) continue;\r\n\r\n const source = mixCtx.createBufferSource();\r\n source.buffer = srcBuffer;\r\n applyLoop(source, req);\r\n\r\n const scalarSpeed = effectiveSpeed(req.filters);\r\n const rate = Number.isFinite(scalarSpeed) && scalarSpeed > 0 ? scalarSpeed : 1;\r\n const speedCurve = speedCurveOf(req.filters);\r\n // With a curve the scalar is folded into the scheduled ramp below, so\r\n // setting it here as well would apply it twice.\r\n if (rate !== 1 && !speedCurve) source.playbackRate.value = rate;\r\n\r\n const gain = mixCtx.createGain();\r\n gain.gain.value = Number.isFinite(req.volume) ? req.volume : 1;\r\n\r\n // The trimmed source length the filter and speed curves are authored over.\r\n const sourceLength = Math.max(0, srcBuffer.duration - req.trimStart);\r\n // The clip's own clip-time length — what a curve resolves against.\r\n // Deliberately *not* `playDuration`, which is that length truncated by the\r\n // timeline end: resolving against the truncated value would squeeze the\r\n // whole curve into the surviving part instead of cutting it off.\r\n const clipDuration = Number.isFinite(req.endAt)\r\n ? Math.max(0, req.endAt - req.startAt)\r\n : sourceLength / rate;\r\n\r\n // Filter chain sits between the source and the per-request gain, matching\r\n // the live WebAudioSink graph so exports sound identical to preview.\r\n // Passing the start time and clip duration is what lets curve-valued params\r\n // schedule — with the defaults they collapse to a single static value.\r\n // `elapsed` is 0: unlike a live seek, the mix always starts a clip at its\r\n // own beginning.\r\n const graph = buildAudioFilterGraph(\r\n mixCtx, source, req.filters ?? [], globalStart, clipDuration, 0,\r\n );\r\n graph.output.connect(gain);\r\n // From the mix's start, whichever clip asks first: a bus's chain is shared,\r\n // so its schedule cannot begin at one clip's start. Context time 0 is\r\n // `-globalOffset` in this request's seconds, which are its stops' too.\r\n gain.connect(buses.inputFor(req.bus, 0, -globalOffset));\r\n\r\n if (speedCurve) {\r\n applySpeedToPlaybackRate(\r\n source.playbackRate, speedCurve, sourceLength, clipDuration, rate, globalStart, 0,\r\n );\r\n }\r\n\r\n // start()'s 3rd arg is a source-buffer duration. A constant rate scales it\r\n // linearly, but under a speed curve the buffer consumed over a span of\r\n // clip time is the integral of the rate, not a multiple of it.\r\n const consumed = speedCurve\r\n ? sourceTimeAtClipElapsed(speedCurve, sourceLength, playDuration)\r\n : playDuration * rate;\r\n\r\n source.start(globalStart, req.trimStart, consumed);\r\n for (const osc of graph.oscillators) osc.start(globalStart);\r\n }\r\n\r\n return mixCtx.startRendering();\r\n}\r\n\r\n/**\r\n * Adapter presenting {@link mixAudio} as the exporter's injected mixer seam.\r\n *\r\n * The sample rate is a constructor argument rather than a third `mix` parameter\r\n * because {@link AudioMixer} — the seam `renderTimeline` calls through — takes\r\n * exactly two, so anything passed as a third would be silently dropped. Fixing\r\n * it here rather than widening the interface keeps the rate a property of *this*\r\n * mixer, which is whose business it is.\r\n */\r\nexport class WebAudioMixer implements AudioMixer<AudioBuffer> {\r\n constructor(\r\n private readonly sampleRate: number = DEFAULT_SAMPLE_RATE,\r\n private readonly catalog?: AssetCatalog,\r\n ) { }\r\n\r\n mix(\r\n requests: readonly ScheduledAudioRequest[],\r\n totalDuration: number,\r\n ): Promise<AudioBuffer | null> {\r\n return mixAudio(requests, totalDuration, {\r\n sampleRate: this.sampleRate,\r\n catalog: this.catalog,\r\n });\r\n }\r\n}\r\n\r\n/**\r\n * Encode an `AudioBuffer` as a 16-bit PCM WAV.\r\n *\r\n * The only other encoder in this package is the AAC track inside the mp4 muxer,\r\n * which is reachable solely by exporting a video — so without this a mixdown has\r\n * no file representation at all. WAV because it needs no codec support and is\r\n * lossless; a host wanting mp3/aac can re-encode from here.\r\n */\r\nexport function encodeWav(buffer: AudioBuffer): Uint8Array<ArrayBuffer> {\r\n const channelCount = buffer.numberOfChannels;\r\n const frameCount = buffer.length;\r\n const bytesPerSample = 2;\r\n const blockAlign = channelCount * bytesPerSample;\r\n const dataBytes = frameCount * blockAlign;\r\n\r\n const out = new ArrayBuffer(44 + dataBytes);\r\n const view = new DataView(out);\r\n\r\n const ascii = (offset: number, text: string) => {\r\n for (let i = 0; i < text.length; i++) view.setUint8(offset + i, text.charCodeAt(i));\r\n };\r\n\r\n ascii(0, \"RIFF\");\r\n view.setUint32(4, 36 + dataBytes, true);\r\n ascii(8, \"WAVE\");\r\n ascii(12, \"fmt \");\r\n view.setUint32(16, 16, true); // PCM header length\r\n view.setUint16(20, 1, true); // format: PCM\r\n view.setUint16(22, channelCount, true);\r\n view.setUint32(24, buffer.sampleRate, true);\r\n view.setUint32(28, buffer.sampleRate * blockAlign, true);\r\n view.setUint16(32, blockAlign, true);\r\n view.setUint16(34, 8 * bytesPerSample, true);\r\n ascii(36, \"data\");\r\n view.setUint32(40, dataBytes, true);\r\n\r\n // Pull each channel out once — getChannelData is a live view, but calling it\r\n // per sample inside the interleave loop is measurably slower.\r\n const channels: Float32Array[] = [];\r\n for (let c = 0; c < channelCount; c++) channels.push(buffer.getChannelData(c));\r\n\r\n let offset = 44;\r\n for (let frame = 0; frame < frameCount; frame++) {\r\n for (let c = 0; c < channelCount; c++) {\r\n // Clamp before scaling: the mix bus can exceed [-1,1] where clips\r\n // overlap, and letting that wrap turns a loud passage into noise.\r\n const sample = Math.max(-1, Math.min(1, channels[c][frame]));\r\n view.setInt16(offset, sample < 0 ? sample * 0x8000 : sample * 0x7fff, true);\r\n offset += bytesPerSample;\r\n }\r\n }\r\n\r\n return new Uint8Array(out);\r\n}\r\n", "import type { AudioRequest } from \"@motionscript/core\";\r\n\r\n/** The span of a decoded buffer a looping request repeats, in source seconds. */\r\nexport interface LoopRegion {\r\n start: number;\r\n end: number;\r\n}\r\n\r\n/**\r\n * The region a looping request repeats: from its in-point to its out-point, or to\r\n * the end of the buffer when it has none. `null` for a request that does not loop,\r\n * and for a degenerate region (an out-point at or before the in-point), where the\r\n * device falls back to wrapping the whole buffer.\r\n *\r\n * Shared by the live device and the offline mixer so a preview and an export loop\r\n * the same samples.\r\n */\r\nexport function loopRegionOf(request: AudioRequest, bufferDuration: number): LoopRegion | null {\r\n if (!request.loop) return null;\r\n const start = Math.min(Math.max(0, request.trimStart), bufferDuration);\r\n const end = Math.min(request.trimEnd ?? bufferDuration, bufferDuration);\r\n return end > start ? { start, end } : null;\r\n}\r\n\r\n/**\r\n * Configure `source` to play `request`'s loop: on or off, and over the trimmed\r\n * region rather than the whole buffer (`loopStart`/`loopEnd` default to the\r\n * whole buffer, which is how a trim used to be lost).\r\n */\r\nexport function applyLoop(source: AudioBufferSourceNode, request: AudioRequest): LoopRegion | null {\r\n source.loop = request.loop;\r\n const region = source.buffer ? loopRegionOf(request, source.buffer.duration) : null;\r\n if (region) {\r\n source.loopStart = region.start;\r\n source.loopEnd = region.end;\r\n }\r\n return region;\r\n}\r\n\r\n/**\r\n * Fold a source offset into a loop region.\r\n *\r\n * A seek into the middle of a looping clip lands at `trimStart + elapsed`, which\r\n * can be many passes past the region's end; the device would not wrap an offset\r\n * that starts outside the region, so it is wrapped here.\r\n */\r\nexport function wrapIntoRegion(region: LoopRegion | null, offset: number): number {\r\n if (!region || offset < region.end) return offset;\r\n return region.start + ((offset - region.start) % (region.end - region.start));\r\n}\r\n", "import { AudioSink, AudioRequest, sourceTimeAtClipElapsed } from \"@motionscript/core\";\r\nimport { AudioBusGraph } from \"./bus-graph\";\r\nimport { applyLoop, wrapIntoRegion } from \"./loop-region\";\r\nimport { buildAudioFilterGraph, effectiveSpeed, speedCurveOf, applySpeedToPlaybackRate } from \"./filter-graph\";\r\n\r\ntype ActiveSource = {\r\n source: AudioBufferSourceNode;\r\n gainNode: GainNode;\r\n request: AudioRequest;\r\n /** Filter-graph nodes to disconnect on teardown. */\r\n filterNodes: AudioNode[];\r\n /** Tremolo LFOs to stop on teardown. */\r\n oscillators: OscillatorNode[];\r\n};\r\n\r\n/**\r\n * Web Audio implementation of {@link AudioSink} — decodes and caches source\r\n * buffers, then schedules/plays {@link AudioRequest}s as `AudioBufferSourceNode`s\r\n * through a shared master gain (global mute and volume). `schedule` registers the\r\n * active set of requests for the current frame; `syncTo` then starts/stops\r\n * sources to match `clipTime`, so playback follows scrubbing and seeks.\r\n */\r\nexport class WebAudioSink extends AudioSink {\r\n private context: AudioContext;\r\n private ownsContext: boolean;\r\n private bufferCache = new Map<string, AudioBuffer>();\r\n private decoding = new Map<string, Promise<void>>();\r\n private active = new Map<string, ActiveSource>();\r\n private scheduled: AudioRequest[] = [];\r\n private disposed: boolean = false;\r\n private masterGain: GainNode;\r\n /** The live bus chains, shared across every clip that names one. */\r\n private buses: AudioBusGraph;\r\n private muted = false;\r\n private volume = 1;\r\n\r\n constructor(context?: AudioContext) {\r\n super();\r\n this.context = context ?? new AudioContext();\r\n this.ownsContext = !context;\r\n this.masterGain = this.context.createGain();\r\n this.masterGain.connect(this.context.destination);\r\n this.buses = new AudioBusGraph(this.context, this.masterGain);\r\n }\r\n\r\n getContext(): AudioContext {\r\n return this.context;\r\n }\r\n\r\n /**\r\n * Resume the AudioContext. Must be called from within a user gesture\r\n * (e.g. a click handler) the first time, or browsers keep the context\r\n * suspended and no audio is heard.\r\n */\r\n unlock(): void {\r\n if (this.context.state === \"suspended\") {\r\n this.context.resume();\r\n }\r\n }\r\n\r\n has(src: string): boolean {\r\n return this.bufferCache.has(src);\r\n }\r\n\r\n async append(src: string, data: ArrayBuffer): Promise<void> {\r\n if (this.bufferCache.has(src)) return;\r\n const existing = this.decoding.get(src);\r\n if (existing) return existing;\r\n\r\n // decodeAudioData detaches `data` — that's fine, the caller in\r\n // AssetManager.fetchAudio discards its reference immediately after\r\n // awaiting append. Skipping the defensive .slice(0) saves a multi-MB\r\n // allocation per audio source.\r\n const job = this.context.decodeAudioData(data).then((buffer) => {\r\n this.bufferCache.set(src, buffer);\r\n }).finally(() => {\r\n this.decoding.delete(src);\r\n });\r\n this.decoding.set(src, job);\r\n await job;\r\n }\r\n\r\n /** Drops cached buffers and stops active sources for srcs/requests no longer referenced — called when the asset set changes (e.g. seeking across scene boundaries). */\r\n retain(keep: ReadonlySet<string>): void {\r\n for (const src of [...this.bufferCache.keys()]) {\r\n if (!keep.has(src)) this.bufferCache.delete(src);\r\n }\r\n for (const [id, active] of this.active) {\r\n if (!keep.has(active.request.src)) this.stopSource(id, active);\r\n }\r\n }\r\n\r\n /** Replaces the active request set; stops any currently-playing source whose request is no longer scheduled. Actual start/stop-to-match-time happens in `syncTo`. */\r\n schedule(requests: readonly AudioRequest[]): void {\r\n const next = new Set(requests.map(r => r.id));\r\n for (const [id, active] of this.active) {\r\n if (!next.has(id)) this.stopSource(id, active);\r\n }\r\n this.scheduled = requests.slice();\r\n }\r\n\r\n /** Starts sources whose `[startAt, endAt)` window now contains `clipTime` (computing the correct buffer offset for the seek point) and stops any that have fallen outside it. */\r\n syncTo(clipTime: number): void {\r\n const liveIds = new Set<string>();\r\n\r\n for (const req of this.scheduled) {\r\n // `endAt` is `Infinity` for an open clip, so the comparison needs no\r\n // nullish fallback — see AudioRequest.endAt.\r\n const isInWindow = clipTime >= req.startAt && clipTime < req.endAt;\r\n if (!isInWindow) continue;\r\n\r\n liveIds.add(req.id);\r\n if (!this.active.has(req.id)) {\r\n const buffer = this.bufferCache.get(req.src);\r\n if (buffer) this.playBuffer(buffer, req, clipTime);\r\n }\r\n }\r\n\r\n for (const [id, active] of this.active) {\r\n if (!liveIds.has(id)) this.stopSource(id, active);\r\n }\r\n }\r\n\r\n async play(time: number, _speed: number, _reverse: boolean): Promise<void> {\r\n if (this.context.state === \"suspended\") {\r\n await this.context.resume();\r\n }\r\n this.syncTo(time);\r\n }\r\n\r\n stop(): void {\r\n for (const [id, active] of this.active) {\r\n this.stopSource(id, active);\r\n }\r\n // A bus's curves are scheduled against the clock of the run that built\r\n // it, so the next play, from wherever it lands, builds them again.\r\n this.buses.dispose();\r\n }\r\n\r\n setMuted(muted: boolean): void {\r\n this.muted = muted;\r\n this.applyMasterGain();\r\n }\r\n\r\n setVolume(volume: number): void {\r\n this.volume = Math.max(0, volume);\r\n this.applyMasterGain();\r\n }\r\n\r\n /** Mute and volume are held separately so unmuting restores the set level. */\r\n private applyMasterGain(): void {\r\n this.masterGain.gain.value = this.muted ? 0 : this.volume;\r\n }\r\n\r\n /** Starts a buffer source mid-clip if `clipTime` lands after the request's start — `audioOffset` accounts for the request's trim, the elapsed time since `startAt`, and any speed (playbackRate) change. */\r\n private playBuffer(buffer: AudioBuffer, req: AudioRequest, clipTime: number): void {\r\n const startTime = this.context.currentTime;\r\n const gainNode = this.context.createGain();\r\n // Guard against a missing/NaN volume — a non-finite AudioParam value throws.\r\n gainNode.gain.value = Number.isFinite(req.volume) ? req.volume : 1;\r\n // Into this clip's bus chain, or straight to the master when it has none.\r\n // The chain is shared: two clips on one bus reach the same nodes, which is\r\n // what makes a bus effect one tail rather than one per clip.\r\n gainNode.connect(this.buses.inputFor(req.bus, startTime, clipTime));\r\n\r\n const source = this.context.createBufferSource();\r\n source.buffer = buffer;\r\n const loopRegion = applyLoop(source, req);\r\n\r\n const scalarSpeed = effectiveSpeed(req.filters);\r\n const rate = Number.isFinite(scalarSpeed) && scalarSpeed > 0 ? scalarSpeed : 1;\r\n const speedCurve = speedCurveOf(req.filters);\r\n if (rate !== 1 && !speedCurve) source.playbackRate.value = rate;\r\n\r\n const elapsed = Math.max(0, clipTime - req.startAt);\r\n // Trimmed source length the filter curves / speed curve are authored over.\r\n const sourceLength = Math.max(0, buffer.duration - req.trimStart);\r\n // Clip-time length of the clip. Prefer the bounded [startAt, endAt) span; if\r\n // endAt is unbounded (an open/looping clip reaching the device unresolved),\r\n // fall back to the source length scaled by speed so curve params still resolve\r\n // (a clipDuration of 0 would otherwise silently drop every fade/sweep).\r\n const clipDuration = isFinite(req.endAt)\r\n ? Math.max(0, req.endAt - req.startAt)\r\n : sourceLength / (rate || 1);\r\n\r\n // Insert the filter chain between the source and the per-request gain. Pass\r\n // the start time, clip duration, and elapsed so curve-valued params schedule\r\n // and align to a mid-clip seek.\r\n const graph = buildAudioFilterGraph(\r\n this.context, source, req.filters ?? [], startTime, clipDuration, elapsed,\r\n );\r\n graph.output.connect(gainNode);\r\n\r\n // Source-time offset for a mid-clip seek. Scalar speed scales linearly; a\r\n // speed curve uses the integral inverse to find the true source position.\r\n let audioOffset: number;\r\n if (speedCurve) {\r\n audioOffset = req.trimStart + sourceTimeAtClipElapsed(speedCurve, sourceLength, elapsed);\r\n // Schedule the time-varying playbackRate (folds in any scalar speed too).\r\n applySpeedToPlaybackRate(\r\n source.playbackRate, speedCurve, sourceLength, clipDuration, rate, startTime, elapsed,\r\n );\r\n } else {\r\n audioOffset = req.trimStart + elapsed * rate;\r\n }\r\n\r\n source.start(startTime, wrapIntoRegion(loopRegion, audioOffset));\r\n for (const osc of graph.oscillators) osc.start(startTime);\r\n\r\n source.onended = () => {\r\n if (this.active.get(req.id)?.source === source) {\r\n this.active.delete(req.id);\r\n }\r\n };\r\n\r\n this.active.set(req.id, {\r\n source,\r\n gainNode,\r\n request: req,\r\n filterNodes: graph.nodes,\r\n oscillators: graph.oscillators,\r\n });\r\n }\r\n\r\n private stopSource(id: string, active: ActiveSource): void {\r\n try {\r\n active.source.onended = null;\r\n active.source.stop();\r\n for (const osc of active.oscillators) osc.stop();\r\n active.source.disconnect();\r\n for (const node of active.filterNodes) node.disconnect();\r\n active.gainNode.disconnect();\r\n } catch {\r\n // already stopped\r\n }\r\n this.active.delete(id);\r\n }\r\n\r\n dispose(): void {\r\n if (this.disposed) return;\r\n this.disposed = true;\r\n super.dispose();\r\n this.bufferCache.clear();\r\n this.decoding.clear();\r\n this.scheduled.length = 0;\r\n this.buses.dispose();\r\n try {\r\n this.masterGain.disconnect();\r\n } catch {\r\n // already disconnected\r\n }\r\n if (this.ownsContext && this.context.state !== \"closed\") {\r\n this.context.close();\r\n }\r\n }\r\n}\r\n"],
5
+ "mappings": "AAmCA,IAAIA,EAAiC,KAS/B,SAAUC,GAAmBC,EAA4B,CAC3DF,EAASE,CACb,CASA,eAAsBC,EAAgBC,EAAW,CAC7C,GAAI,CAACJ,EAAQ,OAAO,KACpB,GAAI,CACA,OAAO,MAAMA,EAAOI,CAAG,CAC3B,MAAQ,CACJ,OAAO,IACX,CACJ,CAOA,eAAsBC,EAAgBC,EAAW,CAC7C,IAAMC,EAAW,MAAM,MAAMD,CAAG,EAChC,GAAI,CAACC,EAAS,GAAI,CACd,IAAMC,EAASD,EAAS,WAAa,GAAGA,EAAS,MAAM,IAAIA,EAAS,UAAU,GAAK,GAAGA,EAAS,MAAM,GACrG,MAAM,IAAI,MAAM,aAAaD,CAAG,kBAAkBE,CAAM,EAAE,CAC9D,CACA,OAAOD,EAAS,KAAI,CACxB,CC5EA,OAAS,cAAAE,MAA2D,qBCApE,OAAiC,WAAAC,EAAS,2BAAAC,MAA+B,qBAsBzE,IAAMC,EAA2B,IAejC,SAASC,EACLC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAAgCC,GAAMA,EAAC,CAIvC,IAAMC,EAAUD,GAAqB,CACjC,IAAME,EAAIH,EAAMC,CAAC,EACj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T,YAAamB,EAAM,MACnB,YAAaA,EAAM,YACtB,CACL,CAEQ,WAAW1B,EAAYC,EAAoB,CAC/C,GAAI,CACAA,EAAO,OAAO,QAAU,KACxBA,EAAO,OAAO,KAAI,EAClB,QAAW+B,KAAO/B,EAAO,YAAa+B,EAAI,KAAI,EAC9C/B,EAAO,OAAO,WAAU,EACxB,QAAWgC,KAAQhC,EAAO,YAAagC,EAAK,WAAU,EACtDhC,EAAO,SAAS,WAAU,CAC9B,MAAQ,CAER,CACA,KAAK,OAAO,OAAOD,CAAE,CACzB,CAEA,SAAO,CACH,GAAI,MAAK,SACT,MAAK,SAAW,GAChB,MAAM,QAAO,EACb,KAAK,YAAY,MAAK,EACtB,KAAK,SAAS,MAAK,EACnB,KAAK,UAAU,OAAS,EACxB,KAAK,MAAM,QAAO,EAClB,GAAI,CACA,KAAK,WAAW,WAAU,CAC9B,MAAQ,CAER,CACI,KAAK,aAAe,KAAK,QAAQ,QAAU,UAC3C,KAAK,QAAQ,MAAK,EAE1B",
6
+ "names": ["source", "setAssetByteSource", "next", "localAssetBytes", "src", "fetchAssetBytes", "url", "response", "status", "busStopKey", "isCurve", "sourceTimeAtClipElapsed", "CURVE_SAMPLES_PER_SECOND", "applyParam", "ctx", "audioParam", "param", "startTime", "clipDuration", "elapsed", "clamp", "v", "finite", "c", "base", "resolved", "startValue", "seg", "segStart", "segEnd", "span", "done", "curveStart", "curveDur", "count", "samples", "i", "local", "buildAudioFilterGraph", "source", "filters", "nodes", "oscillators", "cursor", "series", "node", "apply", "p", "filter", "gain", "biquad", "carrier", "lfo", "lfoDepth", "d", "clamp01", "split", "merge", "dry", "m", "maxDelay", "staticOf", "delay", "feedbackGain", "f", "wet", "effectiveSpeed", "speed", "speedCurveOf", "applySpeedToPlaybackRate", "rate", "curve", "sourceLength", "scalar", "step", "seekAt", "seedSrc", "s", "clampedElapsed", "srcT", "value", "ctxTime", "AudioBusGraph", "ctx", "destination", "bus", "startTime", "clipTime", "node", "osc", "index", "stop", "key", "busStopKey", "existing", "output", "input", "level", "graph", "buildAudioFilterGraph", "sourceTimeAtClipElapsed", "loopRegionOf", "request", "bufferDuration", "start", "end", "applyLoop", "source", "region", "wrapIntoRegion", "offset", "DEFAULT_SAMPLE_RATE", "audioUrl", "src", "catalog", "fetchAudioBuffer", "ctx", "blob", "localAssetBytes", "fetchAssetBytes", "mixAudio", "requests", "totalDuration", "options", "sampleRate", "frames", "uniqueSrcs", "r", "scratchCtx", "asked", "decoded", "cause", "mixCtx", "buses", "AudioBusGraph", "req", "globalOffset", "srcBuffer", "globalStart", "playDuration", "source", "applyLoop", "scalarSpeed", "effectiveSpeed", "rate", "speedCurve", "speedCurveOf", "gain", "sourceLength", "clipDuration", "graph", "buildAudioFilterGraph", "applySpeedToPlaybackRate", "consumed", "sourceTimeAtClipElapsed", "osc", "WebAudioMixer", "encodeWav", "buffer", "channelCount", "frameCount", "bytesPerSample", "blockAlign", "dataBytes", "out", "view", "ascii", "offset", "text", "i", "channels", "c", "frame", "sample", "AudioSink", "sourceTimeAtClipElapsed", "WebAudioSink", "AudioSink", "context", "AudioBusGraph", "src", "data", "existing", "job", "buffer", "keep", "id", "active", "requests", "next", "r", "clipTime", "liveIds", "req", "time", "_speed", "_reverse", "muted", "volume", "startTime", "gainNode", "source", "loopRegion", "applyLoop", "scalarSpeed", "effectiveSpeed", "rate", "speedCurve", "speedCurveOf", "elapsed", "sourceLength", "clipDuration", "graph", "buildAudioFilterGraph", "audioOffset", "sourceTimeAtClipElapsed", "applySpeedToPlaybackRate", "wrapIntoRegion", "osc", "node"]
7
+ }