@motionscript/core 0.1.0-alpha.7 → 0.1.0-alpha.8
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.
- package/CHANGELOG.md +6 -0
- package/NOTICE +15 -14
- package/README.md +4 -4
- package/dist/assets/manager.d.ts.map +1 -1
- package/dist/assets/manager.js +7 -5
- package/dist/assets/manager.js.map +1 -1
- package/dist/attributes/audio/effects/chain.d.ts +73 -0
- package/dist/attributes/audio/effects/chain.d.ts.map +1 -0
- package/dist/attributes/audio/effects/chain.js +67 -0
- package/dist/attributes/audio/effects/chain.js.map +1 -0
- package/dist/attributes/audio/effects/implementations/echo.d.ts +14 -0
- package/dist/attributes/audio/effects/implementations/echo.d.ts.map +1 -0
- package/dist/attributes/audio/effects/implementations/echo.js +11 -0
- package/dist/attributes/audio/effects/implementations/echo.js.map +1 -0
- package/dist/attributes/audio/effects/implementations/gain.d.ts +10 -0
- package/dist/attributes/audio/effects/implementations/gain.d.ts.map +1 -0
- package/dist/attributes/audio/effects/implementations/gain.js +6 -0
- package/dist/attributes/audio/effects/implementations/gain.js.map +1 -0
- package/dist/attributes/audio/effects/implementations/highpass.d.ts +12 -0
- package/dist/attributes/audio/effects/implementations/highpass.d.ts.map +1 -0
- package/dist/attributes/audio/effects/implementations/highpass.js +10 -0
- package/dist/attributes/audio/effects/implementations/highpass.js.map +1 -0
- package/dist/attributes/audio/effects/implementations/lowpass.d.ts +12 -0
- package/dist/attributes/audio/effects/implementations/lowpass.d.ts.map +1 -0
- package/dist/attributes/audio/effects/implementations/lowpass.js +10 -0
- package/dist/attributes/audio/effects/implementations/lowpass.js.map +1 -0
- package/dist/attributes/audio/effects/implementations/tremolo.d.ts +12 -0
- package/dist/attributes/audio/effects/implementations/tremolo.d.ts.map +1 -0
- package/dist/attributes/audio/effects/implementations/tremolo.js +10 -0
- package/dist/attributes/audio/effects/implementations/tremolo.js.map +1 -0
- package/dist/attributes/audio/effects/index.d.ts +12 -0
- package/dist/attributes/audio/effects/index.d.ts.map +1 -0
- package/dist/attributes/audio/effects/index.js +4 -0
- package/dist/attributes/audio/effects/index.js.map +1 -0
- package/dist/attributes/audio/effects/registry.d.ts +36 -0
- package/dist/attributes/audio/effects/registry.d.ts.map +1 -0
- package/dist/attributes/audio/effects/registry.js +80 -0
- package/dist/attributes/audio/effects/registry.js.map +1 -0
- package/dist/attributes/audio/effects/union.d.ts +14 -0
- package/dist/attributes/audio/effects/union.d.ts.map +1 -0
- package/dist/attributes/audio/effects/union.js +24 -0
- package/dist/attributes/audio/effects/union.js.map +1 -0
- package/dist/attributes/audio/ramp.d.ts +103 -0
- package/dist/attributes/audio/ramp.d.ts.map +1 -0
- package/dist/attributes/audio/ramp.js +246 -0
- package/dist/attributes/audio/ramp.js.map +1 -0
- package/dist/attributes/audio/request.d.ts +24 -13
- package/dist/attributes/audio/request.d.ts.map +1 -1
- package/dist/attributes/audio/request.js +4 -3
- package/dist/attributes/audio/request.js.map +1 -1
- package/dist/attributes/audio/schedule.d.ts +21 -13
- package/dist/attributes/audio/schedule.d.ts.map +1 -1
- package/dist/attributes/audio/schedule.js +42 -28
- package/dist/attributes/audio/schedule.js.map +1 -1
- package/dist/attributes/audio/sound.d.ts +15 -12
- package/dist/attributes/audio/sound.d.ts.map +1 -1
- package/dist/attributes/audio/sound.js +8 -10
- package/dist/attributes/audio/sound.js.map +1 -1
- package/dist/attributes/audio/transition.d.ts +33 -0
- package/dist/attributes/audio/transition.d.ts.map +1 -0
- package/dist/attributes/audio/transition.js +48 -0
- package/dist/attributes/audio/transition.js.map +1 -0
- package/dist/attributes/index.d.ts +4 -3
- package/dist/attributes/index.d.ts.map +1 -1
- package/dist/attributes/index.js +4 -7
- package/dist/attributes/index.js.map +1 -1
- package/dist/attributes/layout/matrix2d.d.ts +2 -2
- package/dist/attributes/layout/matrix2d.js.map +1 -1
- package/dist/attributes/layout/space3d.js +1 -1
- package/dist/attributes/layout/space3d.js.map +1 -1
- package/dist/attributes/properties/typed.d.ts +7 -7
- package/dist/attributes/properties/typed.d.ts.map +1 -1
- package/dist/attributes/properties/typed.js +6 -6
- package/dist/attributes/properties/typed.js.map +1 -1
- package/dist/attributes/shape/corners/corner-radius.d.ts +1 -2
- package/dist/attributes/shape/corners/corner-radius.d.ts.map +1 -1
- package/dist/attributes/shape/corners/corner-radius.js +1 -2
- package/dist/attributes/shape/corners/corner-radius.js.map +1 -1
- package/dist/attributes/shape/effects/chain.d.ts +96 -409
- package/dist/attributes/shape/effects/chain.d.ts.map +1 -1
- package/dist/attributes/shape/effects/chain.js +93 -283
- package/dist/attributes/shape/effects/chain.js.map +1 -1
- package/dist/attributes/shape/effects/effect-data.d.ts +1 -1
- package/dist/attributes/shape/effects/effect-data.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/ascii.d.ts +45 -13
- package/dist/attributes/shape/effects/implementations/ascii.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/ascii.js +29 -23
- package/dist/attributes/shape/effects/implementations/ascii.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/bit-crush.d.ts +32 -7
- package/dist/attributes/shape/effects/implementations/bit-crush.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/bit-crush.js +17 -15
- package/dist/attributes/shape/effects/implementations/bit-crush.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/block-displace.d.ts +46 -10
- package/dist/attributes/shape/effects/implementations/block-displace.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/block-displace.js +21 -19
- package/dist/attributes/shape/effects/implementations/block-displace.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/bloom.d.ts +32 -7
- package/dist/attributes/shape/effects/implementations/bloom.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/bloom.js +17 -11
- package/dist/attributes/shape/effects/implementations/bloom.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/blur.d.ts +16 -3
- package/dist/attributes/shape/effects/implementations/blur.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/blur.js +13 -5
- package/dist/attributes/shape/effects/implementations/blur.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/bulge.d.ts +28 -9
- package/dist/attributes/shape/effects/implementations/bulge.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/bulge.js +15 -14
- package/dist/attributes/shape/effects/implementations/bulge.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/chromatic-aberration.d.ts +21 -5
- package/dist/attributes/shape/effects/implementations/chromatic-aberration.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/chromatic-aberration.js +15 -10
- package/dist/attributes/shape/effects/implementations/chromatic-aberration.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/color-adjustment.d.ts +96 -26
- package/dist/attributes/shape/effects/implementations/color-adjustment.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/color-adjustment.js +29 -26
- package/dist/attributes/shape/effects/implementations/color-adjustment.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/curves.d.ts +20 -6
- package/dist/attributes/shape/effects/implementations/curves.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/curves.js +26 -23
- package/dist/attributes/shape/effects/implementations/curves.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/directional-blur.d.ts +26 -5
- package/dist/attributes/shape/effects/implementations/directional-blur.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/directional-blur.js +15 -10
- package/dist/attributes/shape/effects/implementations/directional-blur.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/dither.d.ts +58 -11
- package/dist/attributes/shape/effects/implementations/dither.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/dither.js +26 -20
- package/dist/attributes/shape/effects/implementations/dither.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/drop-shadow.d.ts +46 -14
- package/dist/attributes/shape/effects/implementations/drop-shadow.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/drop-shadow.js +24 -29
- package/dist/attributes/shape/effects/implementations/drop-shadow.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/duotone.d.ts +26 -7
- package/dist/attributes/shape/effects/implementations/duotone.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/duotone.js +17 -16
- package/dist/attributes/shape/effects/implementations/duotone.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/edges.d.ts +29 -7
- package/dist/attributes/shape/effects/implementations/edges.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/edges.js +17 -14
- package/dist/attributes/shape/effects/implementations/edges.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/glass.d.ts +76 -19
- package/dist/attributes/shape/effects/implementations/glass.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/glass.js +28 -22
- package/dist/attributes/shape/effects/implementations/glass.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/glow.d.ts +149 -42
- package/dist/attributes/shape/effects/implementations/glow.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/glow.js +74 -72
- package/dist/attributes/shape/effects/implementations/glow.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/grain.d.ts +43 -11
- package/dist/attributes/shape/effects/implementations/grain.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/grain.js +21 -18
- package/dist/attributes/shape/effects/implementations/grain.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/grayscale.d.ts +17 -3
- package/dist/attributes/shape/effects/implementations/grayscale.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/grayscale.js +13 -5
- package/dist/attributes/shape/effects/implementations/grayscale.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/halftone.d.ts +40 -9
- package/dist/attributes/shape/effects/implementations/halftone.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/halftone.js +20 -16
- package/dist/attributes/shape/effects/implementations/halftone.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/invert.d.ts +23 -5
- package/dist/attributes/shape/effects/implementations/invert.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/invert.js +15 -10
- package/dist/attributes/shape/effects/implementations/invert.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/kaleidoscope.d.ts +57 -18
- package/dist/attributes/shape/effects/implementations/kaleidoscope.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/kaleidoscope.js +25 -22
- package/dist/attributes/shape/effects/implementations/kaleidoscope.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/lut.d.ts +34 -7
- package/dist/attributes/shape/effects/implementations/lut.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/lut.js +20 -16
- package/dist/attributes/shape/effects/implementations/lut.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/magnify.d.ts +27 -9
- package/dist/attributes/shape/effects/implementations/magnify.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/magnify.js +17 -14
- package/dist/attributes/shape/effects/implementations/magnify.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/motion-blur.d.ts +54 -19
- package/dist/attributes/shape/effects/implementations/motion-blur.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/motion-blur.js +42 -20
- package/dist/attributes/shape/effects/implementations/motion-blur.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/oil-paint.d.ts +17 -3
- package/dist/attributes/shape/effects/implementations/oil-paint.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/oil-paint.js +13 -9
- package/dist/attributes/shape/effects/implementations/oil-paint.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/outline.d.ts +28 -8
- package/dist/attributes/shape/effects/implementations/outline.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/outline.js +18 -17
- package/dist/attributes/shape/effects/implementations/outline.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/pixelate.d.ts +25 -6
- package/dist/attributes/shape/effects/implementations/pixelate.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/pixelate.js +16 -14
- package/dist/attributes/shape/effects/implementations/pixelate.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/posterize.d.ts +14 -3
- package/dist/attributes/shape/effects/implementations/posterize.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/posterize.js +13 -9
- package/dist/attributes/shape/effects/implementations/posterize.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/progressive-blur.d.ts +91 -26
- package/dist/attributes/shape/effects/implementations/progressive-blur.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/progressive-blur.js +27 -28
- package/dist/attributes/shape/effects/implementations/progressive-blur.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/radial-blur.d.ts +49 -10
- package/dist/attributes/shape/effects/implementations/radial-blur.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/radial-blur.js +19 -20
- package/dist/attributes/shape/effects/implementations/radial-blur.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/rgb-shift.d.ts +36 -6
- package/dist/attributes/shape/effects/implementations/rgb-shift.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/rgb-shift.js +16 -15
- package/dist/attributes/shape/effects/implementations/rgb-shift.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/scanlines.d.ts +52 -11
- package/dist/attributes/shape/effects/implementations/scanlines.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/scanlines.js +21 -18
- package/dist/attributes/shape/effects/implementations/scanlines.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/scatter.d.ts +23 -9
- package/dist/attributes/shape/effects/implementations/scatter.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/scatter.js +15 -12
- package/dist/attributes/shape/effects/implementations/scatter.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/shader.d.ts +90 -34
- package/dist/attributes/shape/effects/implementations/shader.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/shader.js +42 -26
- package/dist/attributes/shape/effects/implementations/shader.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/sharpen.d.ts +23 -5
- package/dist/attributes/shape/effects/implementations/sharpen.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/sharpen.js +16 -11
- package/dist/attributes/shape/effects/implementations/sharpen.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/streak.d.ts +40 -9
- package/dist/attributes/shape/effects/implementations/streak.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/streak.js +19 -16
- package/dist/attributes/shape/effects/implementations/streak.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/threshold.d.ts +24 -5
- package/dist/attributes/shape/effects/implementations/threshold.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/threshold.js +17 -11
- package/dist/attributes/shape/effects/implementations/threshold.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/twirl.d.ts +35 -8
- package/dist/attributes/shape/effects/implementations/twirl.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/twirl.js +17 -16
- package/dist/attributes/shape/effects/implementations/twirl.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/vignette.d.ts +37 -7
- package/dist/attributes/shape/effects/implementations/vignette.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/vignette.js +19 -18
- package/dist/attributes/shape/effects/implementations/vignette.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/vintage.d.ts +24 -5
- package/dist/attributes/shape/effects/implementations/vintage.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/vintage.js +15 -10
- package/dist/attributes/shape/effects/implementations/vintage.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/wave.d.ts +61 -14
- package/dist/attributes/shape/effects/implementations/wave.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/wave.js +26 -23
- package/dist/attributes/shape/effects/implementations/wave.js.map +1 -1
- package/dist/attributes/shape/effects/index.d.ts +4 -2
- package/dist/attributes/shape/effects/index.d.ts.map +1 -1
- package/dist/attributes/shape/effects/index.js +1 -1
- package/dist/attributes/shape/effects/index.js.map +1 -1
- package/dist/attributes/shape/effects/registry.d.ts +11 -0
- package/dist/attributes/shape/effects/registry.d.ts.map +1 -1
- package/dist/attributes/shape/effects/registry.js +113 -102
- package/dist/attributes/shape/effects/registry.js.map +1 -1
- package/dist/attributes/shape/effects/spec.d.ts +229 -0
- package/dist/attributes/shape/effects/spec.d.ts.map +1 -0
- package/dist/attributes/shape/effects/spec.js +178 -0
- package/dist/attributes/shape/effects/spec.js.map +1 -0
- package/dist/attributes/shape/fill/chain.d.ts +7 -9
- package/dist/attributes/shape/fill/chain.d.ts.map +1 -1
- package/dist/attributes/shape/fill/chain.js +9 -11
- package/dist/attributes/shape/fill/chain.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/shader.d.ts +27 -26
- package/dist/attributes/shape/fill/implementations/shader.d.ts.map +1 -1
- package/dist/attributes/shape/fill/implementations/shader.js +20 -14
- package/dist/attributes/shape/fill/implementations/shader.js.map +1 -1
- package/dist/attributes/shape/fill/index.d.ts +1 -1
- package/dist/attributes/shape/fill/index.d.ts.map +1 -1
- package/dist/attributes/shape/fill/index.js.map +1 -1
- package/dist/attributes/shape/fill/registry.d.ts +1 -2
- package/dist/attributes/shape/fill/registry.d.ts.map +1 -1
- package/dist/attributes/shape/fill/registry.js +1 -2
- package/dist/attributes/shape/fill/registry.js.map +1 -1
- package/dist/attributes/shape/filters/chain.d.ts +2 -6
- package/dist/attributes/shape/filters/chain.d.ts.map +1 -1
- package/dist/attributes/shape/filters/chain.js +1 -5
- package/dist/attributes/shape/filters/chain.js.map +1 -1
- package/dist/attributes/shape/filters/implementations/color-matrix.d.ts +2 -2
- package/dist/attributes/shape/filters/implementations/color-matrix.d.ts.map +1 -1
- package/dist/attributes/shape/filters/implementations/color-matrix.js.map +1 -1
- package/dist/attributes/shape/filters/registry.d.ts +1 -1
- package/dist/attributes/shape/filters/registry.d.ts.map +1 -1
- package/dist/attributes/shape/filters/registry.js +3 -3
- package/dist/attributes/shape/filters/registry.js.map +1 -1
- package/dist/attributes/shape/filters/union.d.ts +2 -3
- package/dist/attributes/shape/filters/union.d.ts.map +1 -1
- package/dist/attributes/shape/filters/union.js.map +1 -1
- package/dist/attributes/shape/shaders/index.d.ts +2 -0
- package/dist/attributes/shape/shaders/index.d.ts.map +1 -1
- package/dist/attributes/shape/shaders/index.js +2 -0
- package/dist/attributes/shape/shaders/index.js.map +1 -1
- package/dist/attributes/shape/shaders/language.d.ts +26 -0
- package/dist/attributes/shape/shaders/language.d.ts.map +1 -0
- package/dist/attributes/shape/shaders/language.js +20 -0
- package/dist/attributes/shape/shaders/language.js.map +1 -0
- package/dist/attributes/shape/shaders/pack.d.ts +25 -11
- package/dist/attributes/shape/shaders/pack.d.ts.map +1 -1
- package/dist/attributes/shape/shaders/pack.js +9 -4
- package/dist/attributes/shape/shaders/pack.js.map +1 -1
- package/dist/attributes/shape/shaders/resolve.d.ts +4 -5
- package/dist/attributes/shape/shaders/resolve.d.ts.map +1 -1
- package/dist/attributes/shape/shaders/resolve.js +3 -6
- package/dist/attributes/shape/shaders/resolve.js.map +1 -1
- package/dist/attributes/shape/shaders/uniforms.d.ts +41 -0
- package/dist/attributes/shape/shaders/uniforms.d.ts.map +1 -0
- package/dist/attributes/shape/shaders/uniforms.js +0 -0
- package/dist/attributes/shape/shaders/uniforms.js.map +1 -0
- package/dist/browser/chunks/chunk-AOT33LMS.js +13 -0
- package/dist/browser/chunks/chunk-AOT33LMS.js.map +7 -0
- package/dist/browser/chunks/chunk-GKM6UZJR.js +6 -0
- package/dist/browser/chunks/chunk-GKM6UZJR.js.map +7 -0
- package/dist/browser/experimental.js +1 -1
- package/dist/browser/experimental.js.map +4 -4
- package/dist/browser/index.js +1 -1
- package/dist/browser/index.js.map +2 -2
- package/dist/browser/manifest.json +1 -1
- package/dist/browser/sdk.js +1 -1
- package/dist/components/builtins/audio/audio.d.ts +14 -5
- package/dist/components/builtins/audio/audio.d.ts.map +1 -1
- package/dist/components/builtins/audio/audio.js +10 -13
- package/dist/components/builtins/audio/audio.js.map +1 -1
- package/dist/components/builtins/geometry/composite.d.ts +3 -3
- package/dist/components/builtins/media/media.d.ts +7 -7
- package/dist/components/builtins/media/media.d.ts.map +1 -1
- package/dist/components/builtins/media/media.js +4 -10
- package/dist/components/builtins/media/media.js.map +1 -1
- package/dist/components/builtins/text/text.d.ts +12 -12
- package/dist/components/builtins/text/text.d.ts.map +1 -1
- package/dist/components/builtins/text/text.js +3 -0
- package/dist/components/builtins/text/text.js.map +1 -1
- package/dist/components/factory/api.d.ts +38 -11
- package/dist/components/factory/api.d.ts.map +1 -1
- package/dist/components/factory/api.js.map +1 -1
- package/dist/components/factory/component3d.d.ts.map +1 -1
- package/dist/components/factory/component3d.js +11 -3
- package/dist/components/factory/component3d.js.map +1 -1
- package/dist/components/factory/factory.d.ts +3 -0
- package/dist/components/factory/factory.d.ts.map +1 -1
- package/dist/components/factory/factory.js +39 -5
- package/dist/components/factory/factory.js.map +1 -1
- package/dist/components/modules/text-style.d.ts +1 -1
- package/dist/components/trees/2d/node-render.d.ts +1 -1
- package/dist/components/trees/2d/node-render.js +1 -1
- package/dist/components/trees/2d/node-render.js.map +1 -1
- package/dist/components/trees/2d/node2d.d.ts +1 -1
- package/dist/components/trees/2d/node2d.js +1 -1
- package/dist/components/trees/2d/node2d.js.map +1 -1
- package/dist/components/trees/audio/node-audio.d.ts +16 -9
- package/dist/components/trees/audio/node-audio.d.ts.map +1 -1
- package/dist/components/trees/audio/node-audio.js +15 -11
- package/dist/components/trees/audio/node-audio.js.map +1 -1
- package/dist/document/command-traits.d.ts +12 -2
- package/dist/document/command-traits.d.ts.map +1 -1
- package/dist/document/command-traits.js +34 -6
- package/dist/document/command-traits.js.map +1 -1
- package/dist/document/index.d.ts +8 -0
- package/dist/document/index.d.ts.map +1 -1
- package/dist/document/index.js +4 -0
- package/dist/document/index.js.map +1 -1
- package/dist/document/migrate.d.ts +70 -0
- package/dist/document/migrate.d.ts.map +1 -0
- package/dist/document/migrate.js +202 -0
- package/dist/document/migrate.js.map +1 -0
- package/dist/document/missing-node.d.ts +27 -0
- package/dist/document/missing-node.d.ts.map +1 -0
- package/dist/document/missing-node.js +48 -0
- package/dist/document/missing-node.js.map +1 -0
- package/dist/document/node-descriptor.d.ts +4 -0
- package/dist/document/node-descriptor.d.ts.map +1 -1
- package/dist/document/node-descriptor.js.map +1 -1
- package/dist/document/placement.d.ts +2 -1
- package/dist/document/placement.d.ts.map +1 -1
- package/dist/document/placement.js.map +1 -1
- package/dist/document/project.d.ts +2 -0
- package/dist/document/project.d.ts.map +1 -1
- package/dist/document/project.js +1 -0
- package/dist/document/project.js.map +1 -1
- package/dist/document/prop-evolution.d.ts +51 -0
- package/dist/document/prop-evolution.d.ts.map +1 -0
- package/dist/document/prop-evolution.js +83 -0
- package/dist/document/prop-evolution.js.map +1 -0
- package/dist/document/registry.d.ts +16 -0
- package/dist/document/registry.d.ts.map +1 -1
- package/dist/document/registry.js +30 -4
- package/dist/document/registry.js.map +1 -1
- package/dist/document/settled-index.d.ts +2 -0
- package/dist/document/settled-index.d.ts.map +1 -1
- package/dist/document/settled-index.js +5 -5
- package/dist/document/settled-index.js.map +1 -1
- package/dist/document/timeline-patch.d.ts +4 -0
- package/dist/document/timeline-patch.d.ts.map +1 -1
- package/dist/document/timeline-patch.js +28 -3
- package/dist/document/timeline-patch.js.map +1 -1
- package/dist/document/timeline.d.ts +45 -1
- package/dist/document/timeline.d.ts.map +1 -1
- package/dist/document/timeline.js +172 -42
- package/dist/document/timeline.js.map +1 -1
- package/dist/document/types.d.ts +14 -28
- package/dist/document/types.d.ts.map +1 -1
- package/dist/document/types.js.map +1 -1
- package/dist/document/validate.d.ts +17 -5
- package/dist/document/validate.d.ts.map +1 -1
- package/dist/document/validate.js +158 -21
- package/dist/document/validate.js.map +1 -1
- package/dist/document/vocabulary.d.ts +28 -0
- package/dist/document/vocabulary.d.ts.map +1 -0
- package/dist/document/vocabulary.js +42 -0
- package/dist/document/vocabulary.js.map +1 -0
- package/dist/experimental.d.ts +68 -8
- package/dist/experimental.d.ts.map +1 -1
- package/dist/experimental.js +22 -8
- package/dist/experimental.js.map +1 -1
- package/dist/platform/exporter.d.ts +13 -0
- package/dist/platform/exporter.d.ts.map +1 -1
- package/dist/platform/exporter.js.map +1 -1
- package/dist/renamed-scene-names.d.ts +1 -1
- package/dist/renamed-scene-names.d.ts.map +1 -1
- package/dist/renamed-scene-names.js +1 -1
- package/dist/renamed-scene-names.js.map +1 -1
- package/dist/render/canvas-render-context2d.d.ts +9 -0
- package/dist/render/canvas-render-context2d.d.ts.map +1 -1
- package/dist/render/canvas-render-context2d.js +10 -0
- package/dist/render/canvas-render-context2d.js.map +1 -1
- package/dist/render/clip-contains.js +1 -1
- package/dist/render/clip-contains.js.map +1 -1
- package/dist/render/descriptors/text.d.ts +2 -2
- package/dist/render/descriptors/text.js +2 -2
- package/dist/render/descriptors/text.js.map +1 -1
- package/dist/render/index.d.ts +2 -0
- package/dist/render/index.d.ts.map +1 -1
- package/dist/render/index.js +1 -0
- package/dist/render/index.js.map +1 -1
- package/dist/render/render-context2d.d.ts +1 -1
- package/dist/render/render-context2d.js.map +1 -1
- package/dist/render/render-issue.d.ts +39 -0
- package/dist/render/render-issue.d.ts.map +1 -0
- package/dist/render/render-issue.js +29 -0
- package/dist/render/render-issue.js.map +1 -0
- package/dist/render/surface.d.ts +2 -2
- package/dist/render/surface.js.map +1 -1
- package/dist/render3d/graphics3d.d.ts.map +1 -1
- package/dist/render3d/graphics3d.js +54 -5
- package/dist/render3d/graphics3d.js.map +1 -1
- package/dist/runtime/asset-refine.js +2 -1
- package/dist/runtime/asset-refine.js.map +1 -1
- package/dist/runtime/asset-timeline.d.ts +10 -0
- package/dist/runtime/asset-timeline.d.ts.map +1 -1
- package/dist/runtime/asset-timeline.js.map +1 -1
- package/dist/runtime/asset-update.d.ts.map +1 -1
- package/dist/runtime/asset-update.js +7 -0
- package/dist/runtime/asset-update.js.map +1 -1
- package/dist/runtime/clip-instance.d.ts +3 -1
- package/dist/runtime/clip-instance.d.ts.map +1 -1
- package/dist/runtime/clip-instance.js +4 -0
- package/dist/runtime/clip-instance.js.map +1 -1
- package/dist/runtime/clip-store.d.ts.map +1 -1
- package/dist/runtime/clip-store.js +17 -2
- package/dist/runtime/clip-store.js.map +1 -1
- package/dist/runtime/engine.d.ts +5 -3
- package/dist/runtime/engine.d.ts.map +1 -1
- package/dist/runtime/engine.js +2 -1
- package/dist/runtime/engine.js.map +1 -1
- package/dist/runtime/playback-controller.d.ts.map +1 -1
- package/dist/runtime/playback-controller.js +14 -4
- package/dist/runtime/playback-controller.js.map +1 -1
- package/dist/runtime/session.d.ts +7 -3
- package/dist/runtime/session.d.ts.map +1 -1
- package/dist/runtime/session.js +11 -4
- package/dist/runtime/session.js.map +1 -1
- package/dist/runtime/text-geometry.d.ts +1 -1
- package/dist/runtime/text-geometry.js.map +1 -1
- package/dist/sdk/index.d.ts +8 -6
- package/dist/sdk/index.d.ts.map +1 -1
- package/dist/sdk/index.js +10 -3
- package/dist/sdk/index.js.map +1 -1
- package/dist/tween/command-decorator.d.ts +7 -0
- package/dist/tween/command-decorator.d.ts.map +1 -1
- package/dist/tween/command-decorator.js +1 -0
- package/dist/tween/command-decorator.js.map +1 -1
- package/dist/tween/ease/describe.d.ts +2 -0
- package/dist/tween/ease/describe.d.ts.map +1 -1
- package/dist/tween/ease/describe.js +4 -0
- package/dist/tween/ease/describe.js.map +1 -1
- package/dist/tween/ease/spec.d.ts +31 -0
- package/dist/tween/ease/spec.d.ts.map +1 -0
- package/dist/tween/ease/spec.js +51 -0
- package/dist/tween/ease/spec.js.map +1 -0
- package/dist/tween/index.d.ts +1 -0
- package/dist/tween/index.d.ts.map +1 -1
- package/dist/tween/index.js +1 -0
- package/dist/tween/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/browser/chunks/chunk-D4FSTPML.js +0 -14
- package/dist/browser/chunks/chunk-D4FSTPML.js.map +0 -7
- package/dist/browser/chunks/chunk-RTNATFWX.js +0 -5
- package/dist/browser/chunks/chunk-RTNATFWX.js.map +0 -7
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/attributes/audio/effects/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,YAAY,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,YAAY,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,YAAY,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,YAAY,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAC9E,YAAY,EACR,iBAAiB,EACjB,iBAAiB,EACjB,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,EACpB,iBAAiB,GACpB,MAAM,SAAS,CAAC;AAEjB,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAClE,YAAY,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/attributes/audio/effects/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAW9E,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC","sourcesContent":["export type { GainEffect } from './implementations/gain';\r\nexport type { HighPassEffect } from './implementations/highpass';\r\nexport type { LowPassEffect } from './implementations/lowpass';\r\nexport type { TremoloEffect } from './implementations/tremolo';\r\nexport type { EchoEffect } from './implementations/echo';\r\n\r\nexport { AudioEffects, AudioEffectChain, resolveAudioEffects } from './chain';\r\nexport type {\r\n AudioEffectsInput,\r\n GainEffectOptions,\r\n HighPassEffectOptions,\r\n LowPassEffectOptions,\r\n TremoloEffectOptions,\r\n EchoEffectOptions,\r\n} from './chain';\r\n\r\nexport type { AudioEffect } from './union';\r\nexport { effectsKey } from './union';\r\n\r\nexport { AudioEffectRegistry, audioEffectsOps } from './registry';\r\nexport type { AudioEffectData } from './registry';\r\n"]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { AudioEffect } from "../../../attributes/audio/effects/union.js";
|
|
2
|
+
import { type AudioEffectsInput } from "../../../attributes/audio/effects/chain.js";
|
|
3
|
+
import type { AttributeOps } from "../../../attributes/shared/operators.js";
|
|
4
|
+
/** Interpolation and equality contract every registered audio effect must implement. */
|
|
5
|
+
export interface AudioEffectData<T extends AudioEffect> {
|
|
6
|
+
/** Return a new effect linearly interpolated between `from` and `to` at progress `t` (0–1). */
|
|
7
|
+
lerp(from: T, to: T, t: number): T;
|
|
8
|
+
/** Return true when both effects are audibly identical (used to skip redundant work). */
|
|
9
|
+
equals(a: T, b: T): boolean;
|
|
10
|
+
}
|
|
11
|
+
/** Central registry that maps audio-effect type strings to their `AudioEffectData` handlers. */
|
|
12
|
+
export declare class AudioEffectRegistry {
|
|
13
|
+
private static registry;
|
|
14
|
+
/**
|
|
15
|
+
* Register an effect type.
|
|
16
|
+
* Throws if the same `type` key is registered more than once to catch accidental double-imports.
|
|
17
|
+
*/
|
|
18
|
+
static register<T extends AudioEffect>(type: string, data: AudioEffectData<T>): void;
|
|
19
|
+
/** Look up the `AudioEffectData` for a given type key, or `undefined` if not registered. */
|
|
20
|
+
static get(type: string): AudioEffectData<AudioEffect> | undefined;
|
|
21
|
+
/** Return true when an effect type has been registered. */
|
|
22
|
+
static has(type: string): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Interpolate between two individual effects at progress `t`.
|
|
25
|
+
* Falls back to a hard cut at t = 0.5 when the types differ or are unregistered.
|
|
26
|
+
*/
|
|
27
|
+
static lerp(from: AudioEffect, to: AudioEffect, t: number): AudioEffect;
|
|
28
|
+
/**
|
|
29
|
+
* Interpolate between two effect arrays of potentially different lengths.
|
|
30
|
+
* Indices present in only one array are kept as-is; matched indices are lerped pairwise.
|
|
31
|
+
*/
|
|
32
|
+
static lerpArray(from: AudioEffect[], to: AudioEffect[], t: number): AudioEffect[];
|
|
33
|
+
}
|
|
34
|
+
/** The audio-effect-chain attribute's op set — the `effects` prop's resolve/lerp pair. */
|
|
35
|
+
export declare const audioEffectsOps: AttributeOps<AudioEffectsInput, AudioEffect[]>;
|
|
36
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../../src/attributes/audio/effects/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAC/D,OAAO,EAAE,KAAK,iBAAiB,EAAuB,MAAM,kCAAkC,CAAC;AAC/F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAOlE,wFAAwF;AACxF,MAAM,WAAW,eAAe,CAAC,CAAC,SAAS,WAAW;IAClD,+FAA+F;IAC/F,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC;IACnC,yFAAyF;IACzF,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC;CAC/B;AAiBD,gGAAgG;AAChG,qBAAa,mBAAmB;IAC5B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAErB;IAEF;;;OAGG;IACH,MAAM,CAAC,QAAQ,CAAC,CAAC,SAAS,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,CAAC,CAAC,CAAC,GAAG,IAAI;IAOpF,4FAA4F;IAC5F,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CAAC,WAAW,CAAC,GAAG,SAAS;IAIlE,2DAA2D;IAC3D,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAIjC;;;OAGG;IACH,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE,EAAE,EAAE,WAAW,EAAE,CAAC,EAAE,MAAM,GAAG,WAAW;IAMvE;;;OAGG;IACH,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,WAAW,EAAE,EAAE,EAAE,EAAE,WAAW,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,WAAW,EAAE;CAgBrF;AAED,0FAA0F;AAC1F,eAAO,MAAM,eAAe,EAAE,YAAY,CAAC,iBAAiB,EAAE,WAAW,EAAE,CAG1E,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { resolveAudioEffects } from "../../../attributes/audio/effects/chain.js";
|
|
2
|
+
import { gainEffect } from "./implementations/gain.js";
|
|
3
|
+
import { highPassEffect } from "./implementations/highpass.js";
|
|
4
|
+
import { lowPassEffect } from "./implementations/lowpass.js";
|
|
5
|
+
import { tremoloEffect } from "./implementations/tremolo.js";
|
|
6
|
+
import { echoEffect } from "./implementations/echo.js";
|
|
7
|
+
/**
|
|
8
|
+
* Every built-in effect's handler, keyed by its `type` — an effect missing here
|
|
9
|
+
* is a type error. Seeded into the registry rather than registered by each
|
|
10
|
+
* effect's own module: core is `sideEffects: false`, so a module imported only
|
|
11
|
+
* to run a `register` call is one a bundler may drop, and the effect it held
|
|
12
|
+
* would then hard-cut instead of interpolating, with nothing raised.
|
|
13
|
+
*/
|
|
14
|
+
const BUILT_IN_EFFECTS = {
|
|
15
|
+
gain: gainEffect,
|
|
16
|
+
highpass: highPassEffect,
|
|
17
|
+
lowpass: lowPassEffect,
|
|
18
|
+
tremolo: tremoloEffect,
|
|
19
|
+
echo: echoEffect,
|
|
20
|
+
};
|
|
21
|
+
/** Central registry that maps audio-effect type strings to their `AudioEffectData` handlers. */
|
|
22
|
+
export class AudioEffectRegistry {
|
|
23
|
+
static registry = new Map(Object.entries(BUILT_IN_EFFECTS));
|
|
24
|
+
/**
|
|
25
|
+
* Register an effect type.
|
|
26
|
+
* Throws if the same `type` key is registered more than once to catch accidental double-imports.
|
|
27
|
+
*/
|
|
28
|
+
static register(type, data) {
|
|
29
|
+
if (this.registry.has(type)) {
|
|
30
|
+
throw new Error(`Audio effect "${type}" is already registered`);
|
|
31
|
+
}
|
|
32
|
+
this.registry.set(type, data);
|
|
33
|
+
}
|
|
34
|
+
/** Look up the `AudioEffectData` for a given type key, or `undefined` if not registered. */
|
|
35
|
+
static get(type) {
|
|
36
|
+
return this.registry.get(type);
|
|
37
|
+
}
|
|
38
|
+
/** Return true when an effect type has been registered. */
|
|
39
|
+
static has(type) {
|
|
40
|
+
return this.registry.has(type);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Interpolate between two individual effects at progress `t`.
|
|
44
|
+
* Falls back to a hard cut at t = 0.5 when the types differ or are unregistered.
|
|
45
|
+
*/
|
|
46
|
+
static lerp(from, to, t) {
|
|
47
|
+
if (from.type !== to.type)
|
|
48
|
+
return t < 0.5 ? from : to;
|
|
49
|
+
const data = this.registry.get(from.type);
|
|
50
|
+
return data ? data.lerp(from, to, t) : (t < 0.5 ? from : to);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Interpolate between two effect arrays of potentially different lengths.
|
|
54
|
+
* Indices present in only one array are kept as-is; matched indices are lerped pairwise.
|
|
55
|
+
*/
|
|
56
|
+
static lerpArray(from, to, t) {
|
|
57
|
+
const maxLen = Math.max(from.length, to.length);
|
|
58
|
+
const result = [];
|
|
59
|
+
for (let i = 0; i < maxLen; i++) {
|
|
60
|
+
const a = from[i];
|
|
61
|
+
const b = to[i];
|
|
62
|
+
if (a && b) {
|
|
63
|
+
result.push(AudioEffectRegistry.lerp(a, b, t));
|
|
64
|
+
}
|
|
65
|
+
else if (a) {
|
|
66
|
+
result.push(a);
|
|
67
|
+
}
|
|
68
|
+
else if (b) {
|
|
69
|
+
result.push(b);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return result;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/** The audio-effect-chain attribute's op set — the `effects` prop's resolve/lerp pair. */
|
|
76
|
+
export const audioEffectsOps = {
|
|
77
|
+
resolve: resolveAudioEffects,
|
|
78
|
+
lerp: AudioEffectRegistry.lerpArray,
|
|
79
|
+
};
|
|
80
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../../src/attributes/audio/effects/registry.ts"],"names":[],"mappings":"AACA,OAAO,EAA0B,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAE/F,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAUpD;;;;;;GAMG;AACH,MAAM,gBAAgB,GAAuF;IACzG,IAAI,EAAE,UAAU;IAChB,QAAQ,EAAE,cAAc;IACxB,OAAO,EAAE,aAAa;IACtB,OAAO,EAAE,aAAa;IACtB,IAAI,EAAE,UAAU;CACnB,CAAC;AAEF,gGAAgG;AAChG,MAAM,OAAO,mBAAmB;IACpB,MAAM,CAAC,QAAQ,GAAG,IAAI,GAAG,CAC7B,MAAM,CAAC,OAAO,CAAC,gBAAgB,CAA6C,CAC/E,CAAC;IAEF;;;OAGG;IACH,MAAM,CAAC,QAAQ,CAAwB,IAAY,EAAE,IAAwB;QACzE,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,EA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AC,EAAE,EAAE,CAAC;YAC9B,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;YAClB,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;YAChB,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;gBACT,MAAM,CAAC,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;YACnD,CAAC;iBAAM,IAAI,CAAC,EAAE,CAAC;gBACX,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YACnB,CAAC;iBAAM,IAAI,CAAC,EAAE,CAAC;gBACX,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YACnB,CAAC;QACL,CAAC;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;;AAGL,0FAA0F;AAC1F,MAAM,CAAC,MAAM,eAAe,GAAmD;IAC3E,OAAO,EAAE,mBAAmB;IAC5B,IAAI,EAAE,mBAAmB,CAAC,SAAS;CACtC,CAAC","sourcesContent":["import { AudioEffect } from \"@/attributes/audio/effects/union\";\r\nimport { type AudioEffectsInput, resolveAudioEffects } from \"@/attributes/audio/effects/chain\";\r\nimport type { AttributeOps } from \"@/attributes/shared/operators\";\r\nimport { gainEffect } from \"./implementations/gain\";\r\nimport { highPassEffect } from \"./implementations/highpass\";\r\nimport { lowPassEffect } from \"./implementations/lowpass\";\r\nimport { tremoloEffect } from \"./implementations/tremolo\";\r\nimport { echoEffect } from \"./implementations/echo\";\r\n\r\n/** Interpolation and equality contract every registered audio effect must implement. */\r\nexport interface AudioEffectData<T extends AudioEffect> {\r\n /** Return a new effect linearly interpolated between `from` and `to` at progress `t` (0–1). */\r\n lerp(from: T, to: T, t: number): T;\r\n /** Return true when both effects are audibly identical (used to skip redundant work). */\r\n equals(a: T, b: T): boolean;\r\n}\r\n\r\n/**\r\n * Every built-in effect's handler, keyed by its `type` — an effect missing here\r\n * is a type error. Seeded into the registry rather than registered by each\r\n * effect's own module: core is `sideEffects: false`, so a module imported only\r\n * to run a `register` call is one a bundler may drop, and the effect it held\r\n * would then hard-cut instead of interpolating, with nothing raised.\r\n */\r\nconst BUILT_IN_EFFECTS: { [K in AudioEffect[\"type\"]]: AudioEffectData<Extract<AudioEffect, { type: K }>> } = {\r\n gain: gainEffect,\r\n highpass: highPassEffect,\r\n lowpass: lowPassEffect,\r\n tremolo: tremoloEffect,\r\n echo: echoEffect,\r\n};\r\n\r\n/** Central registry that maps audio-effect type strings to their `AudioEffectData` handlers. */\r\nexport class AudioEffectRegistry {\r\n private static registry = new Map<string, AudioEffectData<AudioEffect>>(\r\n Object.entries(BUILT_IN_EFFECTS) as [string, AudioEffectData<AudioEffect>][],\r\n );\r\n\r\n /**\r\n * Register an effect type.\r\n * Throws if the same `type` key is registered more than once to catch accidental double-imports.\r\n */\r\n static register<T extends AudioEffect>(type: string, data: AudioEffectData<T>): void {\r\n if (this.registry.has(type)) {\r\n throw new Error(`Audio effect \"${type}\" is already registered`);\r\n }\r\n this.registry.set(type, data as AudioEffectData<AudioEffect>);\r\n }\r\n\r\n /** Look up the `AudioEffectData` for a given type key, or `undefined` if not registered. */\r\n static get(type: string): AudioEffectData<AudioEffect> | undefined {\r\n return this.registry.get(type);\r\n }\r\n\r\n /** Return true when an effect type has been registered. */\r\n static has(type: string): boolean {\r\n return this.registry.has(type);\r\n }\r\n\r\n /**\r\n * Interpolate between two individual effects at progress `t`.\r\n * Falls back to a hard cut at t = 0.5 when the types differ or are unregistered.\r\n */\r\n static lerp(from: AudioEffect, to: AudioEffect, t: number): AudioEffect {\r\n if (from.type !== to.type) return t < 0.5 ? from : to;\r\n const data = this.registry.get(from.type);\r\n return data ? data.lerp(from, to, t) : (t < 0.5 ? from : to);\r\n }\r\n\r\n /**\r\n * Interpolate between two effect arrays of potentially different lengths.\r\n * Indices present in only one array are kept as-is; matched indices are lerped pairwise.\r\n */\r\n static lerpArray(from: AudioEffect[], to: AudioEffect[], t: number): AudioEffect[] {\r\n const maxLen = Math.max(from.length, to.length);\r\n const result: AudioEffect[] = [];\r\n for (let i = 0; i < maxLen; i++) {\r\n const a = from[i];\r\n const b = to[i];\r\n if (a && b) {\r\n result.push(AudioEffectRegistry.lerp(a, b, t));\r\n } else if (a) {\r\n result.push(a);\r\n } else if (b) {\r\n result.push(b);\r\n }\r\n }\r\n return result;\r\n }\r\n}\r\n\r\n/** The audio-effect-chain attribute's op set — the `effects` prop's resolve/lerp pair. */\r\nexport const audioEffectsOps: AttributeOps<AudioEffectsInput, AudioEffect[]> = {\r\n resolve: resolveAudioEffects,\r\n lerp: AudioEffectRegistry.lerpArray,\r\n};\r\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { GainEffect } from "./implementations/gain.js";
|
|
2
|
+
import type { HighPassEffect } from "./implementations/highpass.js";
|
|
3
|
+
import type { LowPassEffect } from "./implementations/lowpass.js";
|
|
4
|
+
import type { TremoloEffect } from "./implementations/tremolo.js";
|
|
5
|
+
import type { EchoEffect } from "./implementations/echo.js";
|
|
6
|
+
/** Every concrete audio effect a sound or a bus can carry. */
|
|
7
|
+
export type AudioEffect = GainEffect | HighPassEffect | LowPassEffect | TremoloEffect | EchoEffect;
|
|
8
|
+
/**
|
|
9
|
+
* Equal for two chains exactly when they sound the same. A device keys its
|
|
10
|
+
* playback by it, so an edited effect tears down the stale source rather than
|
|
11
|
+
* playing it until the next stop.
|
|
12
|
+
*/
|
|
13
|
+
export declare function effectsKey(effects: readonly AudioEffect[] | undefined): string;
|
|
14
|
+
//# sourceMappingURL=union.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"union.d.ts","sourceRoot":"","sources":["../../../../src/attributes/audio/effects/union.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAGzD,8DAA8D;AAC9D,MAAM,MAAM,WAAW,GACjB,UAAU,GACV,cAAc,GACd,aAAa,GACb,aAAa,GACb,UAAU,CAAC;AAEjB;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,SAAS,WAAW,EAAE,GAAG,SAAS,GAAG,MAAM,CAe9E"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { paramKey } from "../ramp.js";
|
|
2
|
+
/**
|
|
3
|
+
* Equal for two chains exactly when they sound the same. A device keys its
|
|
4
|
+
* playback by it, so an edited effect tears down the stale source rather than
|
|
5
|
+
* playing it until the next stop.
|
|
6
|
+
*/
|
|
7
|
+
export function effectsKey(effects) {
|
|
8
|
+
if (!effects || effects.length === 0)
|
|
9
|
+
return "";
|
|
10
|
+
return effects.map((f) => {
|
|
11
|
+
switch (f.type) {
|
|
12
|
+
case "gain":
|
|
13
|
+
return `gain:${paramKey(f.value)}`;
|
|
14
|
+
case "highpass":
|
|
15
|
+
case "lowpass":
|
|
16
|
+
return `${f.type}:${paramKey(f.frequency)}:${paramKey(f.q)}`;
|
|
17
|
+
case "tremolo":
|
|
18
|
+
return `tremolo:${paramKey(f.rate)}:${paramKey(f.depth)}`;
|
|
19
|
+
case "echo":
|
|
20
|
+
return `echo:${paramKey(f.delay)}:${paramKey(f.feedback)}:${paramKey(f.mix)}`;
|
|
21
|
+
}
|
|
22
|
+
}).join("|");
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=union.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"union.js","sourceRoot":"","sources":["../../../../src/attributes/audio/effects/union.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAUnC;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,OAA2C;IAClE,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAChD,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QACrB,QAAQ,CAAC,CAAC,IAAI,EAAE,CAAC;YACb,KAAK,MAAM;gBACP,OAAO,QAAQ,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;YACvC,KAAK,UAAU,CAAC;YAChB,KAAK,SAAS;gBACV,OAAO,GAAG,CAAC,CAAC,IAAI,IAAI,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YACjE,KAAK,SAAS;gBACV,OAAO,WAAW,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;YAC9D,KAAK,MAAM;gBACP,OAAO,QAAQ,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC;QACtF,CAAC;IACL,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACjB,CAAC","sourcesContent":["import type { GainEffect } from \"./implementations/gain\";\r\nimport type { HighPassEffect } from \"./implementations/highpass\";\r\nimport type { LowPassEffect } from \"./implementations/lowpass\";\r\nimport type { TremoloEffect } from \"./implementations/tremolo\";\r\nimport type { EchoEffect } from \"./implementations/echo\";\r\nimport { paramKey } from \"../ramp\";\r\n\r\n/** Every concrete audio effect a sound or a bus can carry. */\r\nexport type AudioEffect =\r\n | GainEffect\r\n | HighPassEffect\r\n | LowPassEffect\r\n | TremoloEffect\r\n | EchoEffect;\r\n\r\n/**\r\n * Equal for two chains exactly when they sound the same. A device keys its\r\n * playback by it, so an edited effect tears down the stale source rather than\r\n * playing it until the next stop.\r\n */\r\nexport function effectsKey(effects: readonly AudioEffect[] | undefined): string {\r\n if (!effects || effects.length === 0) return \"\";\r\n return effects.map((f) => {\r\n switch (f.type) {\r\n case \"gain\":\r\n return `gain:${paramKey(f.value)}`;\r\n case \"highpass\":\r\n case \"lowpass\":\r\n return `${f.type}:${paramKey(f.frequency)}:${paramKey(f.q)}`;\r\n case \"tremolo\":\r\n return `tremolo:${paramKey(f.rate)}:${paramKey(f.depth)}`;\r\n case \"echo\":\r\n return `echo:${paramKey(f.delay)}:${paramKey(f.feedback)}:${paramKey(f.mix)}`;\r\n }\r\n }).join(\"|\");\r\n}\r\n"]}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { type EaseSpec } from "../../tween/ease/spec.js";
|
|
2
|
+
import type { EasingFunction } from "../../tween/ease/type.js";
|
|
3
|
+
import type { AttributeOps } from "../../attributes/shared/operators.js";
|
|
4
|
+
/**
|
|
5
|
+
* One point of a {@link Ramp}: a value, placed `at` seconds after the start or
|
|
6
|
+
* `before` seconds before the end, and the ease of the segment arriving at it
|
|
7
|
+
* (linear when absent).
|
|
8
|
+
*/
|
|
9
|
+
export type RampKey = {
|
|
10
|
+
readonly at: number;
|
|
11
|
+
readonly before?: undefined;
|
|
12
|
+
readonly value: number;
|
|
13
|
+
readonly ease?: EaseSpec;
|
|
14
|
+
} | {
|
|
15
|
+
readonly before: number;
|
|
16
|
+
readonly at?: undefined;
|
|
17
|
+
readonly value: number;
|
|
18
|
+
readonly ease?: EaseSpec;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Automation for one audio param, as plain JSON.
|
|
22
|
+
*
|
|
23
|
+
* A `before` key stays where it is when the clip is trimmed, which is what makes
|
|
24
|
+
* "the last second" mean the last second of whatever length the clip has.
|
|
25
|
+
*/
|
|
26
|
+
export interface Ramp {
|
|
27
|
+
readonly keys: readonly RampKey[];
|
|
28
|
+
}
|
|
29
|
+
/** An audio param: a constant, or a {@link Ramp}. */
|
|
30
|
+
export type Param = number | Ramp;
|
|
31
|
+
/** A ramp key's time and ease, resolved against one length. */
|
|
32
|
+
export interface ResolvedRampKey {
|
|
33
|
+
readonly time: number;
|
|
34
|
+
readonly value: number;
|
|
35
|
+
readonly ease: EasingFunction;
|
|
36
|
+
/** Linear into this key, so a device can schedule a cheap ramp rather than a baked curve. */
|
|
37
|
+
readonly linear: boolean;
|
|
38
|
+
}
|
|
39
|
+
interface Segment {
|
|
40
|
+
readonly from?: number;
|
|
41
|
+
readonly to?: number;
|
|
42
|
+
readonly duration?: number;
|
|
43
|
+
readonly ease?: EaseSpec;
|
|
44
|
+
}
|
|
45
|
+
/** An ease as data, or an engine-built function (which records the data it came from). */
|
|
46
|
+
export type RampEase = EaseSpec | EasingFunction;
|
|
47
|
+
/**
|
|
48
|
+
* The fluent builder: `ramp(0, 1, 0.5).hold().ramp(1, 0, 1)`.
|
|
49
|
+
*
|
|
50
|
+
* Its one own field is `keys`, so it is a {@link Ramp} and serializes to one.
|
|
51
|
+
* Segments before the first bare `hold()` are placed from the start, segments
|
|
52
|
+
* after it from the end, and the hold stretches to fill whatever lies between.
|
|
53
|
+
*/
|
|
54
|
+
export declare class RampChain implements Ramp {
|
|
55
|
+
readonly keys: readonly RampKey[];
|
|
56
|
+
constructor(segments?: readonly Segment[]);
|
|
57
|
+
/** Append a ramp from `from` to `to` over `duration` seconds. */
|
|
58
|
+
ramp(from: number, to: number, duration: number, options?: {
|
|
59
|
+
readonly ease?: RampEase;
|
|
60
|
+
}): RampChain;
|
|
61
|
+
/** Append a hold: for `duration` seconds, or, bare, for whatever the clip leaves over. */
|
|
62
|
+
hold(duration?: number): RampChain;
|
|
63
|
+
private _append;
|
|
64
|
+
}
|
|
65
|
+
/** A ramp from `from` to `to` over `duration` seconds. */
|
|
66
|
+
export declare function ramp(from: number, to: number, duration: number, options?: {
|
|
67
|
+
readonly ease?: RampEase;
|
|
68
|
+
}): RampChain;
|
|
69
|
+
/** A hold; bare `hold()` stretches to fill the middle of the clip. */
|
|
70
|
+
export declare function hold(duration?: number): RampChain;
|
|
71
|
+
/** Whether `p` is a {@link Ramp}: anything with a `keys` array, a parsed copy included. */
|
|
72
|
+
export declare function isRamp(p: unknown): p is Ramp;
|
|
73
|
+
/**
|
|
74
|
+
* The keys of `ramp` placed on a clip `length` seconds long, in time order.
|
|
75
|
+
*
|
|
76
|
+
* Every time is clamped to the clip, so a ramp longer than its clip is cut, not
|
|
77
|
+
* squeezed. Keys whose anchors cross (a start key past an end key on a short
|
|
78
|
+
* clip) are sorted by where they land, with a development warning.
|
|
79
|
+
*/
|
|
80
|
+
export declare function resolveRamp(ramp: Ramp, length: number): readonly ResolvedRampKey[];
|
|
81
|
+
/** The value of `ramp` at `t` seconds into a clip `length` seconds long, `fallback` when it has no keys. */
|
|
82
|
+
export declare function sampleRamp(ramp: Ramp, t: number, length: number, fallback: number): number;
|
|
83
|
+
/** The value of `p` at `t`, for a number its own value. */
|
|
84
|
+
export declare function sampleParam(p: Param, t: number, length: number, fallback: number): number;
|
|
85
|
+
/** One representative number: the value itself, or the ramp's value at its start. */
|
|
86
|
+
export declare function staticValue(p: Param, fallback?: number): number;
|
|
87
|
+
/** Equal for two params exactly when they sound the same: what tells a device a param was edited. */
|
|
88
|
+
export declare function paramKey(p: Param | undefined): string;
|
|
89
|
+
/** Two numbers lerp; a ramp on either side hard-cuts at the midpoint. */
|
|
90
|
+
export declare function lerpParam(from: Param, to: Param, t: number): Param;
|
|
91
|
+
export declare function equalsParam(a: Param | undefined, b: Param | undefined): boolean;
|
|
92
|
+
/** The audio-param attribute's op set: resolve is the identity, lerp is {@link lerpParam}. */
|
|
93
|
+
export declare const audioParamOps: AttributeOps<Param, Param>;
|
|
94
|
+
/**
|
|
95
|
+
* Clip seconds spent playing the first `upper` source seconds under a speed
|
|
96
|
+
* ramp: `∫ 1/speed(τ) dτ`. The ramp is placed on `sourceLength`, the source
|
|
97
|
+
* seconds it is authored over, and speed is floored just above zero.
|
|
98
|
+
*/
|
|
99
|
+
export declare function integrateSpeedToClipTime(speed: Ramp, sourceLength: number, upper?: number, step?: number): number;
|
|
100
|
+
/** Inverse of {@link integrateSpeedToClipTime}: the source seconds reached after `clipElapsed` clip seconds. */
|
|
101
|
+
export declare function sourceTimeAtClipElapsed(speed: Ramp, sourceLength: number, clipElapsed: number, step?: number): number;
|
|
102
|
+
export {};
|
|
103
|
+
//# sourceMappingURL=ramp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ramp.d.ts","sourceRoot":"","sources":["../../../src/attributes/audio/ramp.ts"],"names":[],"mappings":"AACA,OAAO,EAA0B,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAElE;;;;GAIG;AACH,MAAM,MAAM,OAAO,GACb;IAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAA;CAAE,GACtG;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAA;CAAE,CAAC;AAE7G;;;;;GAKG;AACH,MAAM,WAAW,IAAI;IACjB,QAAQ,CAAC,IAAI,EAAE,SAAS,OAAO,EAAE,CAAC;CACrC;AAED,qDAAqD;AACrD,MAAM,MAAM,KAAK,GAAG,MAAM,GAAG,IAAI,CAAC;AAElC,+DAA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,CAAC,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,IAAI,SAAmB,GAAG,MAAM,CAa/H"}
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import { linear } from "../../tween/ease/constants.js";
|
|
2
|
+
import { easeOfSpec, specOfEase } from "../../tween/ease/spec.js";
|
|
3
|
+
import { lerpNumber } from "../../tween/lerp.js";
|
|
4
|
+
const segmentsOf = new WeakMap();
|
|
5
|
+
/**
|
|
6
|
+
* The fluent builder: `ramp(0, 1, 0.5).hold().ramp(1, 0, 1)`.
|
|
7
|
+
*
|
|
8
|
+
* Its one own field is `keys`, so it is a {@link Ramp} and serializes to one.
|
|
9
|
+
* Segments before the first bare `hold()` are placed from the start, segments
|
|
10
|
+
* after it from the end, and the hold stretches to fill whatever lies between.
|
|
11
|
+
*/
|
|
12
|
+
export class RampChain {
|
|
13
|
+
keys;
|
|
14
|
+
constructor(segments = []) {
|
|
15
|
+
segmentsOf.set(this, segments);
|
|
16
|
+
this.keys = keysOf(segments);
|
|
17
|
+
}
|
|
18
|
+
/** Append a ramp from `from` to `to` over `duration` seconds. */
|
|
19
|
+
ramp(from, to, duration, options) {
|
|
20
|
+
return this._append({ from, to, duration, ease: specOf(options?.ease) });
|
|
21
|
+
}
|
|
22
|
+
/** Append a hold: for `duration` seconds, or, bare, for whatever the clip leaves over. */
|
|
23
|
+
hold(duration) {
|
|
24
|
+
return this._append({ duration });
|
|
25
|
+
}
|
|
26
|
+
_append(segment) {
|
|
27
|
+
return new RampChain([...(segmentsOf.get(this) ?? []), segment]);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/** A ramp from `from` to `to` over `duration` seconds. */
|
|
31
|
+
export function ramp(from, to, duration, options) {
|
|
32
|
+
return new RampChain().ramp(from, to, duration, options);
|
|
33
|
+
}
|
|
34
|
+
/** A hold; bare `hold()` stretches to fill the middle of the clip. */
|
|
35
|
+
export function hold(duration) {
|
|
36
|
+
return new RampChain().hold(duration);
|
|
37
|
+
}
|
|
38
|
+
function specOf(ease) {
|
|
39
|
+
if (ease === undefined)
|
|
40
|
+
return undefined;
|
|
41
|
+
const spec = typeof ease === "function" ? specOfEase(ease) : ease;
|
|
42
|
+
if (!spec) {
|
|
43
|
+
throw new TypeError("A ramp's ease is stored as data, and this function has none: pass an EaseSpec, or an engine-built ease (easeIn, easeOut, easeInOut, curveEase).");
|
|
44
|
+
}
|
|
45
|
+
return spec.kind === "linear" ? undefined : spec;
|
|
46
|
+
}
|
|
47
|
+
function keysOf(segments) {
|
|
48
|
+
let previous;
|
|
49
|
+
const values = segments.map((s) => {
|
|
50
|
+
const from = s.from ?? previous;
|
|
51
|
+
const to = s.to ?? from;
|
|
52
|
+
previous = to;
|
|
53
|
+
return { from, to };
|
|
54
|
+
});
|
|
55
|
+
const keys = [];
|
|
56
|
+
const push = (key) => {
|
|
57
|
+
const last = keys[keys.length - 1];
|
|
58
|
+
if (last && !key.ease && last.at === key.at && last.before === key.before && last.value === key.value)
|
|
59
|
+
return;
|
|
60
|
+
keys.push(key);
|
|
61
|
+
};
|
|
62
|
+
const withEase = (s) => (s.ease ? { ease: s.ease } : {});
|
|
63
|
+
const fill = segments.findIndex((s) => s.duration === undefined);
|
|
64
|
+
const head = fill < 0 ? segments.length : fill;
|
|
65
|
+
let at = 0;
|
|
66
|
+
for (let i = 0; i < head; i++) {
|
|
67
|
+
const s = segments[i];
|
|
68
|
+
const duration = Math.max(0, s.duration ?? 0);
|
|
69
|
+
const { from, to } = values[i];
|
|
70
|
+
if (from !== undefined)
|
|
71
|
+
push({ at, value: from });
|
|
72
|
+
if (to !== undefined)
|
|
73
|
+
push({ at: at + duration, value: to, ...withEase(s) });
|
|
74
|
+
at += duration;
|
|
75
|
+
}
|
|
76
|
+
if (fill < 0)
|
|
77
|
+
return keys;
|
|
78
|
+
const tail = segments.slice(fill + 1);
|
|
79
|
+
if (tail.some((s) => s.duration === undefined) && process.env.NODE_ENV !== "production") {
|
|
80
|
+
console.warn("[motionscript] A ramp has more than one bare hold(); only the first stretches, the rest are zero-length.");
|
|
81
|
+
}
|
|
82
|
+
let before = tail.reduce((sum, s) => sum + Math.max(0, s.duration ?? 0), 0);
|
|
83
|
+
for (let i = fill + 1; i < segments.length; i++) {
|
|
84
|
+
const s = segments[i];
|
|
85
|
+
const duration = Math.max(0, s.duration ?? 0);
|
|
86
|
+
const { from, to } = values[i];
|
|
87
|
+
if (from !== undefined)
|
|
88
|
+
push({ before, value: from });
|
|
89
|
+
before -= duration;
|
|
90
|
+
if (to !== undefined)
|
|
91
|
+
push({ before: Math.max(0, before), value: to, ...withEase(s) });
|
|
92
|
+
}
|
|
93
|
+
return keys;
|
|
94
|
+
}
|
|
95
|
+
/** Whether `p` is a {@link Ramp}: anything with a `keys` array, a parsed copy included. */
|
|
96
|
+
export function isRamp(p) {
|
|
97
|
+
return typeof p === "object" && p !== null && Array.isArray(p.keys);
|
|
98
|
+
}
|
|
99
|
+
const LINEAR = linear();
|
|
100
|
+
const resolved = new WeakMap();
|
|
101
|
+
/**
|
|
102
|
+
* The keys of `ramp` placed on a clip `length` seconds long, in time order.
|
|
103
|
+
*
|
|
104
|
+
* Every time is clamped to the clip, so a ramp longer than its clip is cut, not
|
|
105
|
+
* squeezed. Keys whose anchors cross (a start key past an end key on a short
|
|
106
|
+
* clip) are sorted by where they land, with a development warning.
|
|
107
|
+
*/
|
|
108
|
+
export function resolveRamp(ramp, length) {
|
|
109
|
+
const clip = Number.isFinite(length) && length > 0 ? length : 0;
|
|
110
|
+
const cached = resolved.get(ramp);
|
|
111
|
+
if (cached && cached.length === clip)
|
|
112
|
+
return cached.keys;
|
|
113
|
+
let crossed = false;
|
|
114
|
+
let last = -Infinity;
|
|
115
|
+
const keys = ramp.keys.map((key) => {
|
|
116
|
+
const time = Math.min(clip, Math.max(0, key.before !== undefined ? clip - key.before : key.at ?? 0));
|
|
117
|
+
if (time < last)
|
|
118
|
+
crossed = true;
|
|
119
|
+
last = time;
|
|
120
|
+
const ease = key.ease ? easeOfSpec(key.ease) : LINEAR;
|
|
121
|
+
return { time, value: key.value, ease, linear: !key.ease || key.ease.kind === "linear" };
|
|
122
|
+
});
|
|
123
|
+
if (crossed) {
|
|
124
|
+
keys.sort((a, b) => a.time - b.time);
|
|
125
|
+
if (process.env.NODE_ENV !== "production") {
|
|
126
|
+
console.warn(`[motionscript] A ramp's start and end keys cross on a ${clip.toFixed(3)}s clip; they play in the order they land.`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
resolved.set(ramp, { length: clip, keys });
|
|
130
|
+
return keys;
|
|
131
|
+
}
|
|
132
|
+
/** The value of `ramp` at `t` seconds into a clip `length` seconds long, `fallback` when it has no keys. */
|
|
133
|
+
export function sampleRamp(ramp, t, length, fallback) {
|
|
134
|
+
const keys = resolveRamp(ramp, length);
|
|
135
|
+
if (keys.length === 0)
|
|
136
|
+
return fallback;
|
|
137
|
+
if (t <= keys[0].time)
|
|
138
|
+
return keys[0].value;
|
|
139
|
+
for (let i = 1; i < keys.length; i++) {
|
|
140
|
+
const key = keys[i];
|
|
141
|
+
if (t > key.time)
|
|
142
|
+
continue;
|
|
143
|
+
const previous = keys[i - 1];
|
|
144
|
+
const span = key.time - previous.time;
|
|
145
|
+
return lerpNumber(previous.value, key.value, key.ease(span > 0 ? (t - previous.time) / span : 1));
|
|
146
|
+
}
|
|
147
|
+
return keys[keys.length - 1].value;
|
|
148
|
+
}
|
|
149
|
+
/** The value of `p` at `t`, for a number its own value. */
|
|
150
|
+
export function sampleParam(p, t, length, fallback) {
|
|
151
|
+
return isRamp(p) ? sampleRamp(p, t, length, fallback) : p;
|
|
152
|
+
}
|
|
153
|
+
/** One representative number: the value itself, or the ramp's value at its start. */
|
|
154
|
+
export function staticValue(p, fallback = 0) {
|
|
155
|
+
if (!isRamp(p))
|
|
156
|
+
return p;
|
|
157
|
+
let first;
|
|
158
|
+
for (const key of p.keys) {
|
|
159
|
+
if (key.at !== undefined && (first?.at === undefined || key.at < first.at))
|
|
160
|
+
first = key;
|
|
161
|
+
}
|
|
162
|
+
return (first ?? p.keys[0])?.value ?? fallback;
|
|
163
|
+
}
|
|
164
|
+
/** Equal for two params exactly when they sound the same: what tells a device a param was edited. */
|
|
165
|
+
export function paramKey(p) {
|
|
166
|
+
if (p === undefined)
|
|
167
|
+
return "_";
|
|
168
|
+
return isRamp(p) ? `r${JSON.stringify(p.keys)}` : String(p);
|
|
169
|
+
}
|
|
170
|
+
/** Two numbers lerp; a ramp on either side hard-cuts at the midpoint. */
|
|
171
|
+
export function lerpParam(from, to, t) {
|
|
172
|
+
if (typeof from === "number" && typeof to === "number")
|
|
173
|
+
return lerpNumber(from, to, t);
|
|
174
|
+
return t < 0.5 ? from : to;
|
|
175
|
+
}
|
|
176
|
+
export function equalsParam(a, b) {
|
|
177
|
+
if (a === b)
|
|
178
|
+
return true;
|
|
179
|
+
if (typeof a === "number" || typeof b === "number" || a === undefined || b === undefined)
|
|
180
|
+
return false;
|
|
181
|
+
return paramKey(a) === paramKey(b);
|
|
182
|
+
}
|
|
183
|
+
/** The audio-param attribute's op set: resolve is the identity, lerp is {@link lerpParam}. */
|
|
184
|
+
export const audioParamOps = {
|
|
185
|
+
resolve: (value) => value,
|
|
186
|
+
lerp: lerpParam,
|
|
187
|
+
};
|
|
188
|
+
const INTEGRATION_STEP = 0.001;
|
|
189
|
+
/** The most cells one table holds: past it a long source gets coarser cells, not a bigger table. */
|
|
190
|
+
const MAX_CELLS = 20000;
|
|
191
|
+
const speedTables = new WeakMap();
|
|
192
|
+
function speedTableOf(speed, sourceLength, step) {
|
|
193
|
+
let byLength = speedTables.get(speed);
|
|
194
|
+
if (!byLength)
|
|
195
|
+
speedTables.set(speed, (byLength = new Map()));
|
|
196
|
+
const key = `${sourceLength}:${step}`;
|
|
197
|
+
const cached = byLength.get(key);
|
|
198
|
+
if (cached)
|
|
199
|
+
return cached;
|
|
200
|
+
const cells = Math.max(1, Math.min(MAX_CELLS, Math.ceil(sourceLength / step)));
|
|
201
|
+
const size = sourceLength / cells;
|
|
202
|
+
const clip = new Float64Array(cells + 1);
|
|
203
|
+
const rate = new Float64Array(cells);
|
|
204
|
+
for (let i = 0; i < cells; i++) {
|
|
205
|
+
rate[i] = Math.max(1e-6, sampleRamp(speed, (i + 0.5) * size, sourceLength, 1));
|
|
206
|
+
clip[i + 1] = clip[i] + size / rate[i];
|
|
207
|
+
}
|
|
208
|
+
const table = { step: size, clip, rate };
|
|
209
|
+
if (byLength.size >= 8)
|
|
210
|
+
byLength.clear();
|
|
211
|
+
byLength.set(key, table);
|
|
212
|
+
return table;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Clip seconds spent playing the first `upper` source seconds under a speed
|
|
216
|
+
* ramp: `∫ 1/speed(τ) dτ`. The ramp is placed on `sourceLength`, the source
|
|
217
|
+
* seconds it is authored over, and speed is floored just above zero.
|
|
218
|
+
*/
|
|
219
|
+
export function integrateSpeedToClipTime(speed, sourceLength, upper = sourceLength, step = INTEGRATION_STEP) {
|
|
220
|
+
const end = Math.min(upper, sourceLength);
|
|
221
|
+
if (end <= 0)
|
|
222
|
+
return 0;
|
|
223
|
+
const table = speedTableOf(speed, sourceLength, step);
|
|
224
|
+
const cell = Math.min(table.rate.length - 1, Math.floor(end / table.step));
|
|
225
|
+
return table.clip[cell] + (end - cell * table.step) / table.rate[cell];
|
|
226
|
+
}
|
|
227
|
+
/** Inverse of {@link integrateSpeedToClipTime}: the source seconds reached after `clipElapsed` clip seconds. */
|
|
228
|
+
export function sourceTimeAtClipElapsed(speed, sourceLength, clipElapsed, step = INTEGRATION_STEP) {
|
|
229
|
+
if (clipElapsed <= 0 || sourceLength <= 0)
|
|
230
|
+
return 0;
|
|
231
|
+
const table = speedTableOf(speed, sourceLength, step);
|
|
232
|
+
const { clip, rate } = table;
|
|
233
|
+
if (clipElapsed >= clip[clip.length - 1])
|
|
234
|
+
return sourceLength;
|
|
235
|
+
let lo = 0;
|
|
236
|
+
let hi = rate.length - 1;
|
|
237
|
+
while (lo < hi) {
|
|
238
|
+
const mid = (lo + hi + 1) >> 1;
|
|
239
|
+
if (clip[mid] <= clipElapsed)
|
|
240
|
+
lo = mid;
|
|
241
|
+
else
|
|
242
|
+
hi = mid - 1;
|
|
243
|
+
}
|
|
244
|
+
return Math.min(sourceLength, lo * table.step + (clipElapsed - clip[lo]) * rate[lo]);
|
|
245
|
+
}
|
|
246
|
+
//# sourceMappingURL=ramp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ramp.js","sourceRoot":"","sources":["../../../src/attributes/audio/ramp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAiB,MAAM,mBAAmB,CAAC;AAE1E,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AA4C1C,MAAM,UAAU,GAAG,IAAI,OAAO,EAAiC,CAAC;AAEhE;;;;;;GAMG;AACH,MAAM,OAAO,SAAS;IACT,IAAI,CAAqB;IAElC,YAAY,WAA+B,EAAE;QACzC,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAC/B,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC;IAED,iEAAiE;IACjE,IAAI,CAAC,IAAY,EAAE,EAAU,EAAE,QAAgB,EAAE,OAAsC;QACnF,OAAO,IAAI,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IAC7E,CAAC;IAED,0FAA0F;IAC1F,IAAI,CAAC,QAAiB;QAClB,OAAO,IAAI,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC;IACtC,CAAC;IAEO,OAAO,CAAC,OAAgB;QAC5B,OAAO,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AAED,gHAAgH;AAChH,MAAM,UAAU,uBAAuB,CAAC,KAAW,EAAE,YAAoB,EAAE,WAAmB,EAAE,IAAI,GAAG,gBAAgB;IACnH,IAAI,WAAW,IAAI,CAAC,IAAI,YAAY,IAAI,CAAC;QAAE,OAAO,CAAC,CAAC;IACpD,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,EAAE,YAAY,EAAE,IAAI,CAAC,CAAC;IACtD,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;IAC7B,IAAI,WAAW,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;QAAE,OAAO,YAAY,CAAC;IAC9D,IAAI,EAAE,GAAG,CAAC,CAAC;IACX,IAAI,EAAE,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IACzB,OAAO,EAAE,GAAG,EAAE,EAAE,CAAC;QACb,MAAM,GAAG,GAAG,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC;QAC/B,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,WAAW;YAAE,EAAE,GAAG,GAAG,CAAC;;YAClC,EAAE,GAAG,GAAG,GAAG,CAAC,CAAC;IACtB,CAAC;IACD,OAAO,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE,EAAE,GAAG,KAAK,CAAC,IAAI,GAAG,CAAC,WAAW,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;AACzF,CAAC","sourcesContent":["import { linear } from \"@/tween/ease/constants\";\r\nimport { easeOfSpec, specOfEase, type EaseSpec } from \"@/tween/ease/spec\";\r\nimport type { EasingFunction } from \"@/tween/ease/type\";\r\nimport { lerpNumber } from \"@/tween/lerp\";\r\nimport type { AttributeOps } from \"@/attributes/shared/operators\";\r\n\r\n/**\r\n * One point of a {@link Ramp}: a value, placed `at` seconds after the start or\r\n * `before` seconds before the end, and the ease of the segment arriving at it\r\n * (linear when absent).\r\n */\r\nexport type RampKey =\r\n | { readonly at: number; readonly before?: undefined; readonly value: number; readonly ease?: EaseSpec }\r\n | { readonly before: number; readonly at?: undefined; readonly value: number; readonly ease?: EaseSpec };\r\n\r\n/**\r\n * Automation for one audio param, as plain JSON.\r\n *\r\n * A `before` key stays where it is when the clip is trimmed, which is what makes\r\n * \"the last second\" mean the last second of whatever length the clip has.\r\n */\r\nexport interface Ramp {\r\n readonly keys: readonly RampKey[];\r\n}\r\n\r\n/** An audio param: a constant, or a {@link Ramp}. */\r\nexport type Param = number | Ramp;\r\n\r\n/** A ramp key's time and ease, resolved against one length. */\r\nexport interface ResolvedRampKey {\r\n readonly time: number;\r\n readonly value: number;\r\n readonly ease: EasingFunction;\r\n /** Linear into this key, so a device can schedule a cheap ramp rather than a baked curve. */\r\n readonly linear: boolean;\r\n}\r\n\r\ninterface Segment {\r\n readonly from?: number;\r\n readonly to?: number;\r\n readonly duration?: number;\r\n readonly ease?: EaseSpec;\r\n}\r\n\r\n/** An ease as data, or an engine-built function (which records the data it came from). */\r\nexport type RampEase = EaseSpec | EasingFunction;\r\n\r\nconst segmentsOf = new WeakMap<RampChain, readonly Segment[]>();\r\n\r\n/**\r\n * The fluent builder: `ramp(0, 1, 0.5).hold().ramp(1, 0, 1)`.\r\n *\r\n * Its one own field is `keys`, so it is a {@link Ramp} and serializes to one.\r\n * Segments before the first bare `hold()` are placed from the start, segments\r\n * after it from the end, and the hold stretches to fill whatever lies between.\r\n */\r\nexport class RampChain implements Ramp {\r\n readonly keys: readonly RampKey[];\r\n\r\n constructor(segments: readonly Segment[] = []) {\r\n segmentsOf.set(this, segments);\r\n this.keys = keysOf(segments);\r\n }\r\n\r\n /** Append a ramp from `from` to `to` over `duration` seconds. */\r\n ramp(from: number, to: number, duration: number, options?: { readonly ease?: RampEase }): RampChain {\r\n return this._append({ from, to, duration, ease: specOf(options?.ease) });\r\n }\r\n\r\n /** Append a hold: for `duration` seconds, or, bare, for whatever the clip leaves over. */\r\n hold(duration?: number): RampChain {\r\n return this._append({ duration });\r\n }\r\n\r\n private _append(segment: Segment): RampChain {\r\n return new RampChain([...(segmentsOf.get(this) ?? []), segment]);\r\n }\r\n}\r\n\r\n/** A ramp from `from` to `to` over `duration` seconds. */\r\nexport function ramp(from: number, to: number, duration: number, options?: { readonly ease?: RampEase }): RampChain {\r\n return new RampChain().ramp(from, to, duration, options);\r\n}\r\n\r\n/** A hold; bare `hold()` stretches to fill the middle of the clip. */\r\nexport function hold(duration?: number): RampChain {\r\n return new RampChain().hold(duration);\r\n}\r\n\r\nfunction specOf(ease: RampEase | undefined): EaseSpec | undefined {\r\n if (ease === undefined) return undefined;\r\n const spec = typeof ease === \"function\" ? specOfEase(ease) : ease;\r\n if (!spec) {\r\n throw new TypeError(\"A ramp's ease is stored as data, and this function has none: pass an EaseSpec, or an engine-built ease (easeIn, easeOut, easeInOut, curveEase).\");\r\n }\r\n return spec.kind === \"linear\" ? undefined : spec;\r\n}\r\n\r\nfunction keysOf(segments: readonly Segment[]): RampKey[] {\r\n let previous: number | undefined;\r\n const values = segments.map((s) => {\r\n const from = s.from ?? previous;\r\n const to = s.to ?? from;\r\n previous = to;\r\n return { from, to };\r\n });\r\n\r\n const keys: RampKey[] = [];\r\n const push = (key: RampKey): void => {\r\n const last = keys[keys.length - 1];\r\n if (last && !key.ease && last.at === key.at && last.before === key.before && last.value === key.value) return;\r\n keys.push(key);\r\n };\r\n const withEase = (s: Segment) => (s.ease ? { ease: s.ease } : {});\r\n\r\n const fill = segments.findIndex((s) => s.duration === undefined);\r\n const head = fill < 0 ? segments.length : fill;\r\n let at = 0;\r\n for (let i = 0; i < head; i++) {\r\n const s = segments[i];\r\n const duration = Math.max(0, s.duration ?? 0);\r\n const { from, to } = values[i];\r\n if (from !== undefined) push({ at, value: from });\r\n if (to !== undefined) push({ at: at + duration, value: to, ...withEase(s) });\r\n at += duration;\r\n }\r\n if (fill < 0) return keys;\r\n\r\n const tail = segments.slice(fill + 1);\r\n if (tail.some((s) => s.duration === undefined) && process.env.NODE_ENV !== \"production\") {\r\n console.warn(\"[motionscript] A ramp has more than one bare hold(); only the first stretches, the rest are zero-length.\");\r\n }\r\n let before = tail.reduce((sum, s) => sum + Math.max(0, s.duration ?? 0), 0);\r\n for (let i = fill + 1; i < segments.length; i++) {\r\n const s = segments[i];\r\n const duration = Math.max(0, s.duration ?? 0);\r\n const { from, to } = values[i];\r\n if (from !== undefined) push({ before, value: from });\r\n before -= duration;\r\n if (to !== undefined) push({ before: Math.max(0, before), value: to, ...withEase(s) });\r\n }\r\n return keys;\r\n}\r\n\r\n/** Whether `p` is a {@link Ramp}: anything with a `keys` array, a parsed copy included. */\r\nexport function isRamp(p: unknown): p is Ramp {\r\n return typeof p === \"object\" && p !== null && Array.isArray((p as Ramp).keys);\r\n}\r\n\r\nconst LINEAR = linear();\r\nconst resolved = new WeakMap<Ramp, { readonly length: number; readonly keys: readonly ResolvedRampKey[] }>();\r\n\r\n/**\r\n * The keys of `ramp` placed on a clip `length` seconds long, in time order.\r\n *\r\n * Every time is clamped to the clip, so a ramp longer than its clip is cut, not\r\n * squeezed. Keys whose anchors cross (a start key past an end key on a short\r\n * clip) are sorted by where they land, with a development warning.\r\n */\r\nexport function resolveRamp(ramp: Ramp, length: number): readonly ResolvedRampKey[] {\r\n const clip = Number.isFinite(length) && length > 0 ? length : 0;\r\n const cached = resolved.get(ramp);\r\n if (cached && cached.length === clip) return cached.keys;\r\n\r\n let crossed = false;\r\n let last = -Infinity;\r\n const keys = ramp.keys.map((key) => {\r\n const time = Math.min(clip, Math.max(0, key.before !== undefined ? clip - key.before : key.at ?? 0));\r\n if (time < last) crossed = true;\r\n last = time;\r\n const ease = key.ease ? easeOfSpec(key.ease) : LINEAR;\r\n return { time, value: key.value, ease, linear: !key.ease || key.ease.kind === \"linear\" };\r\n });\r\n if (crossed) {\r\n keys.sort((a, b) => a.time - b.time);\r\n if (process.env.NODE_ENV !== \"production\") {\r\n console.warn(`[motionscript] A ramp's start and end keys cross on a ${clip.toFixed(3)}s clip; they play in the order they land.`);\r\n }\r\n }\r\n resolved.set(ramp, { length: clip, keys });\r\n return keys;\r\n}\r\n\r\n/** The value of `ramp` at `t` seconds into a clip `length` seconds long, `fallback` when it has no keys. */\r\nexport function sampleRamp(ramp: Ramp, t: number, length: number, fallback: number): number {\r\n const keys = resolveRamp(ramp, length);\r\n if (keys.length === 0) return fallback;\r\n if (t <= keys[0].time) return keys[0].value;\r\n for (let i = 1; i < keys.length; i++) {\r\n const key = keys[i];\r\n if (t > key.time) continue;\r\n const previous = keys[i - 1];\r\n const span = key.time - previous.time;\r\n return lerpNumber(previous.value, key.value, key.ease(span > 0 ? (t - previous.time) / span : 1));\r\n }\r\n return keys[keys.length - 1].value;\r\n}\r\n\r\n/** The value of `p` at `t`, for a number its own value. */\r\nexport function sampleParam(p: Param, t: number, length: number, fallback: number): number {\r\n return isRamp(p) ? sampleRamp(p, t, length, fallback) : p;\r\n}\r\n\r\n/** One representative number: the value itself, or the ramp's value at its start. */\r\nexport function staticValue(p: Param, fallback = 0): number {\r\n if (!isRamp(p)) return p;\r\n let first: RampKey | undefined;\r\n for (const key of p.keys) {\r\n if (key.at !== undefined && (first?.at === undefined || key.at < first.at)) first = key;\r\n }\r\n return (first ?? p.keys[0])?.value ?? fallback;\r\n}\r\n\r\n/** Equal for two params exactly when they sound the same: what tells a device a param was edited. */\r\nexport function paramKey(p: Param | undefined): string {\r\n if (p === undefined) return \"_\";\r\n return isRamp(p) ? `r${JSON.stringify(p.keys)}` : String(p);\r\n}\r\n\r\n/** Two numbers lerp; a ramp on either side hard-cuts at the midpoint. */\r\nexport function lerpParam(from: Param, to: Param, t: number): Param {\r\n if (typeof from === \"number\" && typeof to === \"number\") return lerpNumber(from, to, t);\r\n return t < 0.5 ? from : to;\r\n}\r\n\r\nexport function equalsParam(a: Param | undefined, b: Param | undefined): boolean {\r\n if (a === b) return true;\r\n if (typeof a === \"number\" || typeof b === \"number\" || a === undefined || b === undefined) return false;\r\n return paramKey(a) === paramKey(b);\r\n}\r\n\r\n/** The audio-param attribute's op set: resolve is the identity, lerp is {@link lerpParam}. */\r\nexport const audioParamOps: AttributeOps<Param, Param> = {\r\n resolve: (value) => value,\r\n lerp: lerpParam,\r\n};\r\n\r\nconst INTEGRATION_STEP = 0.001;\r\n/** The most cells one table holds: past it a long source gets coarser cells, not a bigger table. */\r\nconst MAX_CELLS = 20000;\r\n\r\n/**\r\n * `∫ 1/speed` tabulated once per ramp and source length: `clip[i]` is the clip\r\n * seconds spent by the start of cell `i`, so either direction is a lookup\r\n * rather than a walk from zero. A device asks hundreds of times a second of\r\n * clip while scheduling a rate, and walking from zero each time was quadratic.\r\n */\r\ninterface SpeedTable {\r\n readonly step: number;\r\n readonly clip: Float64Array;\r\n readonly rate: Float64Array;\r\n}\r\n\r\nconst speedTables = new WeakMap<Ramp, Map<string, SpeedTable>>();\r\n\r\nfunction speedTableOf(speed: Ramp, sourceLength: number, step: number): SpeedTable {\r\n let byLength = speedTables.get(speed);\r\n if (!byLength) speedTables.set(speed, (byLength = new Map()));\r\n const key = `${sourceLength}:${step}`;\r\n const cached = byLength.get(key);\r\n if (cached) return cached;\r\n const cells = Math.max(1, Math.min(MAX_CELLS, Math.ceil(sourceLength / step)));\r\n const size = sourceLength / cells;\r\n const clip = new Float64Array(cells + 1);\r\n const rate = new Float64Array(cells);\r\n for (let i = 0; i < cells; i++) {\r\n rate[i] = Math.max(1e-6, sampleRamp(speed, (i + 0.5) * size, sourceLength, 1));\r\n clip[i + 1] = clip[i] + size / rate[i];\r\n }\r\n const table = { step: size, clip, rate };\r\n if (byLength.size >= 8) byLength.clear();\r\n byLength.set(key, table);\r\n return table;\r\n}\r\n\r\n/**\r\n * Clip seconds spent playing the first `upper` source seconds under a speed\r\n * ramp: `∫ 1/speed(τ) dτ`. The ramp is placed on `sourceLength`, the source\r\n * seconds it is authored over, and speed is floored just above zero.\r\n */\r\nexport function integrateSpeedToClipTime(speed: Ramp, sourceLength: number, upper: number = sourceLength, step = INTEGRATION_STEP): number {\r\n const end = Math.min(upper, sourceLength);\r\n if (end <= 0) return 0;\r\n const table = speedTableOf(speed, sourceLength, step);\r\n const cell = Math.min(table.rate.length - 1, Math.floor(end / table.step));\r\n return table.clip[cell] + (end - cell * table.step) / table.rate[cell];\r\n}\r\n\r\n/** Inverse of {@link integrateSpeedToClipTime}: the source seconds reached after `clipElapsed` clip seconds. */\r\nexport function sourceTimeAtClipElapsed(speed: Ramp, sourceLength: number, clipElapsed: number, step = INTEGRATION_STEP): number {\r\n if (clipElapsed <= 0 || sourceLength <= 0) return 0;\r\n const table = speedTableOf(speed, sourceLength, step);\r\n const { clip, rate } = table;\r\n if (clipElapsed >= clip[clip.length - 1]) return sourceLength;\r\n let lo = 0;\r\n let hi = rate.length - 1;\r\n while (lo < hi) {\r\n const mid = (lo + hi + 1) >> 1;\r\n if (clip[mid] <= clipElapsed) lo = mid;\r\n else hi = mid - 1;\r\n }\r\n return Math.min(sourceLength, lo * table.step + (clipElapsed - clip[lo]) * rate[lo]);\r\n}\r\n"]}
|