@open-take/compositor 0.5.2 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cdp-CzT5BKNY.js +3 -0
- package/dist/cdp-QXbQfXna.js +373 -0
- package/dist/cdp-QXbQfXna.js.map +1 -0
- package/dist/index.d.ts +4327 -195
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +26282 -160
- package/dist/index.js.map +1 -1
- package/dist/server-841PMF2H.js +163 -0
- package/dist/server-841PMF2H.js.map +1 -0
- package/dist/server-C2aVv4-t.js +3 -0
- package/kit/audio.mjs +2366 -0
- package/kit/camera.js +587 -0
- package/kit/cursor.js +264 -0
- package/kit/cut.js +427 -0
- package/kit/draw.js +346 -0
- package/kit/look.js +589 -0
- package/kit/map.js +170 -0
- package/kit/media.js +3568 -0
- package/kit/motion.js +1115 -0
- package/kit/seams.js +1006 -0
- package/kit/stage.js +923 -0
- package/kit/time.js +812 -0
- package/kit/world.js +1072 -0
- package/package.json +7 -3
- package/src/ffmpeg.ts +63 -0
- package/src/film/beats.ts +1285 -0
- package/src/film/carry.ts +221 -0
- package/src/film/changes.ts +330 -0
- package/src/film/check.ts +996 -0
- package/src/film/clock.ts +2530 -0
- package/src/film/components-probe.ts +809 -0
- package/src/film/components.ts +1566 -0
- package/src/film/frames.ts +389 -0
- package/src/film/gallery.ts +3276 -0
- package/src/film/kit.ts +515 -0
- package/src/film/layout.ts +701 -0
- package/src/film/listen.ts +1979 -0
- package/src/film/look.ts +3829 -0
- package/src/film/materials.ts +976 -0
- package/src/film/moving.ts +248 -0
- package/src/film/part-files.ts +729 -0
- package/src/film/picture.ts +74 -0
- package/src/film/probe-text.ts +843 -0
- package/src/film/probe.ts +3456 -0
- package/src/film/provenance.ts +596 -0
- package/src/film/render.ts +2447 -0
- package/src/film/report.ts +1631 -0
- package/src/film/sheet.ts +156 -0
- package/src/film/study-declared.ts +123 -0
- package/src/film/study-picture.ts +791 -0
- package/src/film/study-sound.ts +416 -0
- package/src/film/study.ts +864 -0
- package/src/film/tuning.ts +155 -0
- package/src/film/viewer.ts +174 -0
- package/src/html/cdp.ts +575 -0
- package/src/html/server.ts +208 -0
- package/src/index.ts +202 -0
- package/src/launch-render.ts +3 -2
- package/src/math.ts +3 -3
- package/src/mjpeg-matroska.ts +228 -0
- package/src/render.ts +6 -4
- package/src/state-diff.ts +215 -0
- package/src/state-index.ts +99 -0
- package/src/types.ts +59 -1
- package/starter/PLAN.md +84 -0
- package/starter/START.md +460 -0
- package/starter/lib/anim.js +760 -0
- package/starter/lib/devices.js +1402 -0
- package/starter/lib/handoff.js +421 -0
- package/starter/lib/hud.js +1879 -0
- package/starter/lib/measure.mjs +154 -0
- package/starter/lib/moves.js +1095 -0
- package/starter/lib/palette.mjs +803 -0
- package/starter/lib/physics-seeds.mjs +198 -0
- package/starter/lib/physics.js +738 -0
- package/starter/lib/sampler.mjs +242 -0
- package/starter/lib/solid.js +727 -0
- package/starter/lib/space.js +1227 -0
- package/starter/lib/swarm.js +1398 -0
- package/starter/reference/motion.md +276 -0
- package/starter/reference/structure.md +466 -0
- package/starter/reference/travel/motion.md +433 -0
- package/starter/reference/travel/sound.md +241 -0
- package/starter/reference/travel/structure.md +518 -0
- package/starter/samples/NOTICE.txt +55 -0
- package/starter/samples/celli/celli_24_1.opus +0 -0
- package/starter/samples/celli/celli_24_3.opus +0 -0
- package/starter/samples/celli/celli_28_1.opus +0 -0
- package/starter/samples/celli/celli_28_3.opus +0 -0
- package/starter/samples/celli/celli_31_1.opus +0 -0
- package/starter/samples/celli/celli_31_3.opus +0 -0
- package/starter/samples/celli/celli_35_1.opus +0 -0
- package/starter/samples/celli/celli_35_3.opus +0 -0
- package/starter/samples/celli/celli_38_1.opus +0 -0
- package/starter/samples/celli/celli_38_3.opus +0 -0
- package/starter/samples/celli/celli_41_1.opus +0 -0
- package/starter/samples/celli/celli_41_3.opus +0 -0
- package/starter/samples/celli/celli_45_1.opus +0 -0
- package/starter/samples/celli/celli_45_3.opus +0 -0
- package/starter/samples/celli/celli_48_1.opus +0 -0
- package/starter/samples/celli/celli_48_3.opus +0 -0
- package/starter/samples/celli/celli_52_1.opus +0 -0
- package/starter/samples/celli/celli_52_3.opus +0 -0
- package/starter/samples/celli/celli_55_1.opus +0 -0
- package/starter/samples/celli/celli_55_3.opus +0 -0
- package/starter/samples/celli/celli_59_1.opus +0 -0
- package/starter/samples/celli/celli_59_3.opus +0 -0
- package/starter/samples/celli/celli_62_1.opus +0 -0
- package/starter/samples/celli/celli_62_3.opus +0 -0
- package/starter/samples/celli/celli_65_1.opus +0 -0
- package/starter/samples/celli/celli_65_3.opus +0 -0
- package/starter/samples/crash/crash_f_1.flac +0 -0
- package/starter/samples/crash/crash_fff_1.flac +0 -0
- package/starter/samples/ebass/ebass_0_x.flac +0 -0
- package/starter/samples/ebass/ebass_10_x.flac +0 -0
- package/starter/samples/ebass/ebass_11_x.flac +0 -0
- package/starter/samples/ebass/ebass_1_x.flac +0 -0
- package/starter/samples/ebass/ebass_2_x.flac +0 -0
- package/starter/samples/ebass/ebass_3_x.flac +0 -0
- package/starter/samples/ebass/ebass_4_x.flac +0 -0
- package/starter/samples/ebass/ebass_5_x.flac +0 -0
- package/starter/samples/ebass/ebass_6_x.flac +0 -0
- package/starter/samples/ebass/ebass_7_x.flac +0 -0
- package/starter/samples/ebass/ebass_8_x.flac +0 -0
- package/starter/samples/ebass/ebass_9_x.flac +0 -0
- package/starter/samples/ek_clap/ek_clap_1_1.flac +0 -0
- package/starter/samples/ek_hat/ek_hat_1_1.flac +0 -0
- package/starter/samples/ek_hat/ek_hat_1_2.flac +0 -0
- package/starter/samples/ek_kick/ek_kick_1_1.flac +0 -0
- package/starter/samples/ek_kick/ek_kick_1_2.flac +0 -0
- package/starter/samples/glock/glock_67_x.flac +0 -0
- package/starter/samples/glock/glock_72_x.flac +0 -0
- package/starter/samples/glock/glock_79_x.flac +0 -0
- package/starter/samples/glock/glock_84_x.flac +0 -0
- package/starter/samples/glock/glock_91_x.flac +0 -0
- package/starter/samples/glock/glock_96_x.flac +0 -0
- package/starter/samples/harp/harp_101_f.opus +0 -0
- package/starter/samples/harp/harp_28_f.opus +0 -0
- package/starter/samples/harp/harp_31_mp.opus +0 -0
- package/starter/samples/harp/harp_35_mf.opus +0 -0
- package/starter/samples/harp/harp_38_mf.opus +0 -0
- package/starter/samples/harp/harp_41_mf.opus +0 -0
- package/starter/samples/harp/harp_45_mf.opus +0 -0
- package/starter/samples/harp/harp_48_mf.opus +0 -0
- package/starter/samples/harp/harp_52_mf.opus +0 -0
- package/starter/samples/harp/harp_55_mf.opus +0 -0
- package/starter/samples/harp/harp_59_mf.opus +0 -0
- package/starter/samples/harp/harp_62_mf.opus +0 -0
- package/starter/samples/harp/harp_65_mf.opus +0 -0
- package/starter/samples/harp/harp_69_mf.opus +0 -0
- package/starter/samples/harp/harp_72_mf.opus +0 -0
- package/starter/samples/harp/harp_76_mf.opus +0 -0
- package/starter/samples/harp/harp_79_mf.opus +0 -0
- package/starter/samples/harp/harp_83_mf.opus +0 -0
- package/starter/samples/harp/harp_86_mf.opus +0 -0
- package/starter/samples/harp/harp_89_mf.opus +0 -0
- package/starter/samples/harp/harp_93_mf.opus +0 -0
- package/starter/samples/harp/harp_95_mf.opus +0 -0
- package/starter/samples/harp/harp_98_f.opus +0 -0
- package/starter/samples/manifest.json +2951 -0
- package/starter/samples/marimba/marimba_29_x.flac +0 -0
- package/starter/samples/marimba/marimba_36_x.flac +0 -0
- package/starter/samples/marimba/marimba_43_x.flac +0 -0
- package/starter/samples/marimba/marimba_47_x.flac +0 -0
- package/starter/samples/marimba/marimba_53_x.flac +0 -0
- package/starter/samples/marimba/marimba_60_x.flac +0 -0
- package/starter/samples/marimba/marimba_67_x.flac +0 -0
- package/starter/samples/marimba/marimba_71_x.flac +0 -0
- package/starter/samples/marimba/marimba_77_x.flac +0 -0
- package/starter/samples/marimba/marimba_84_x.flac +0 -0
- package/starter/samples/piano/piano_102_12.opus +0 -0
- package/starter/samples/piano/piano_102_16.opus +0 -0
- package/starter/samples/piano/piano_102_4.opus +0 -0
- package/starter/samples/piano/piano_102_8.opus +0 -0
- package/starter/samples/piano/piano_105_12.opus +0 -0
- package/starter/samples/piano/piano_105_16.opus +0 -0
- package/starter/samples/piano/piano_105_4.opus +0 -0
- package/starter/samples/piano/piano_105_8.opus +0 -0
- package/starter/samples/piano/piano_108_12.opus +0 -0
- package/starter/samples/piano/piano_108_16.opus +0 -0
- package/starter/samples/piano/piano_108_4.opus +0 -0
- package/starter/samples/piano/piano_108_8.opus +0 -0
- package/starter/samples/piano/piano_21_12.opus +0 -0
- package/starter/samples/piano/piano_21_16.opus +0 -0
- package/starter/samples/piano/piano_21_4.opus +0 -0
- package/starter/samples/piano/piano_21_8.opus +0 -0
- package/starter/samples/piano/piano_24_12.opus +0 -0
- package/starter/samples/piano/piano_24_16.opus +0 -0
- package/starter/samples/piano/piano_24_4.opus +0 -0
- package/starter/samples/piano/piano_24_8.opus +0 -0
- package/starter/samples/piano/piano_27_12.opus +0 -0
- package/starter/samples/piano/piano_27_16.opus +0 -0
- package/starter/samples/piano/piano_27_4.opus +0 -0
- package/starter/samples/piano/piano_27_8.opus +0 -0
- package/starter/samples/piano/piano_30_12.opus +0 -0
- package/starter/samples/piano/piano_30_16.opus +0 -0
- package/starter/samples/piano/piano_30_4.opus +0 -0
- package/starter/samples/piano/piano_30_8.opus +0 -0
- package/starter/samples/piano/piano_33_12.opus +0 -0
- package/starter/samples/piano/piano_33_16.opus +0 -0
- package/starter/samples/piano/piano_33_4.opus +0 -0
- package/starter/samples/piano/piano_33_8.opus +0 -0
- package/starter/samples/piano/piano_36_12.opus +0 -0
- package/starter/samples/piano/piano_36_16.opus +0 -0
- package/starter/samples/piano/piano_36_4.opus +0 -0
- package/starter/samples/piano/piano_36_8.opus +0 -0
- package/starter/samples/piano/piano_39_12.opus +0 -0
- package/starter/samples/piano/piano_39_16.opus +0 -0
- package/starter/samples/piano/piano_39_4.opus +0 -0
- package/starter/samples/piano/piano_39_8.opus +0 -0
- package/starter/samples/piano/piano_42_12.opus +0 -0
- package/starter/samples/piano/piano_42_16.opus +0 -0
- package/starter/samples/piano/piano_42_4.opus +0 -0
- package/starter/samples/piano/piano_42_8.opus +0 -0
- package/starter/samples/piano/piano_45_12.opus +0 -0
- package/starter/samples/piano/piano_45_16.opus +0 -0
- package/starter/samples/piano/piano_45_4.opus +0 -0
- package/starter/samples/piano/piano_45_8.opus +0 -0
- package/starter/samples/piano/piano_48_12.opus +0 -0
- package/starter/samples/piano/piano_48_16.opus +0 -0
- package/starter/samples/piano/piano_48_4.opus +0 -0
- package/starter/samples/piano/piano_48_8.opus +0 -0
- package/starter/samples/piano/piano_51_12.opus +0 -0
- package/starter/samples/piano/piano_51_16.opus +0 -0
- package/starter/samples/piano/piano_51_4.opus +0 -0
- package/starter/samples/piano/piano_51_8.opus +0 -0
- package/starter/samples/piano/piano_54_12.opus +0 -0
- package/starter/samples/piano/piano_54_16.opus +0 -0
- package/starter/samples/piano/piano_54_4.opus +0 -0
- package/starter/samples/piano/piano_54_8.opus +0 -0
- package/starter/samples/piano/piano_57_12.opus +0 -0
- package/starter/samples/piano/piano_57_16.opus +0 -0
- package/starter/samples/piano/piano_57_4.opus +0 -0
- package/starter/samples/piano/piano_57_8.opus +0 -0
- package/starter/samples/piano/piano_60_12.opus +0 -0
- package/starter/samples/piano/piano_60_16.opus +0 -0
- package/starter/samples/piano/piano_60_4.opus +0 -0
- package/starter/samples/piano/piano_60_8.opus +0 -0
- package/starter/samples/piano/piano_63_12.opus +0 -0
- package/starter/samples/piano/piano_63_16.opus +0 -0
- package/starter/samples/piano/piano_63_4.opus +0 -0
- package/starter/samples/piano/piano_63_8.opus +0 -0
- package/starter/samples/piano/piano_66_12.opus +0 -0
- package/starter/samples/piano/piano_66_16.opus +0 -0
- package/starter/samples/piano/piano_66_4.opus +0 -0
- package/starter/samples/piano/piano_66_8.opus +0 -0
- package/starter/samples/piano/piano_69_12.opus +0 -0
- package/starter/samples/piano/piano_69_16.opus +0 -0
- package/starter/samples/piano/piano_69_4.opus +0 -0
- package/starter/samples/piano/piano_69_8.opus +0 -0
- package/starter/samples/piano/piano_72_12.opus +0 -0
- package/starter/samples/piano/piano_72_16.opus +0 -0
- package/starter/samples/piano/piano_72_4.opus +0 -0
- package/starter/samples/piano/piano_72_8.opus +0 -0
- package/starter/samples/piano/piano_75_12.opus +0 -0
- package/starter/samples/piano/piano_75_16.opus +0 -0
- package/starter/samples/piano/piano_75_4.opus +0 -0
- package/starter/samples/piano/piano_75_8.opus +0 -0
- package/starter/samples/piano/piano_78_12.opus +0 -0
- package/starter/samples/piano/piano_78_16.opus +0 -0
- package/starter/samples/piano/piano_78_4.opus +0 -0
- package/starter/samples/piano/piano_78_8.opus +0 -0
- package/starter/samples/piano/piano_81_12.opus +0 -0
- package/starter/samples/piano/piano_81_16.opus +0 -0
- package/starter/samples/piano/piano_81_4.opus +0 -0
- package/starter/samples/piano/piano_81_8.opus +0 -0
- package/starter/samples/piano/piano_84_12.opus +0 -0
- package/starter/samples/piano/piano_84_16.opus +0 -0
- package/starter/samples/piano/piano_84_4.opus +0 -0
- package/starter/samples/piano/piano_84_8.opus +0 -0
- package/starter/samples/piano/piano_87_12.opus +0 -0
- package/starter/samples/piano/piano_87_16.opus +0 -0
- package/starter/samples/piano/piano_87_4.opus +0 -0
- package/starter/samples/piano/piano_87_8.opus +0 -0
- package/starter/samples/piano/piano_90_12.opus +0 -0
- package/starter/samples/piano/piano_90_16.opus +0 -0
- package/starter/samples/piano/piano_90_4.opus +0 -0
- package/starter/samples/piano/piano_90_8.opus +0 -0
- package/starter/samples/piano/piano_93_12.opus +0 -0
- package/starter/samples/piano/piano_93_16.opus +0 -0
- package/starter/samples/piano/piano_93_4.opus +0 -0
- package/starter/samples/piano/piano_93_8.opus +0 -0
- package/starter/samples/piano/piano_96_12.opus +0 -0
- package/starter/samples/piano/piano_96_16.opus +0 -0
- package/starter/samples/piano/piano_96_4.opus +0 -0
- package/starter/samples/piano/piano_96_8.opus +0 -0
- package/starter/samples/piano/piano_99_12.opus +0 -0
- package/starter/samples/piano/piano_99_16.opus +0 -0
- package/starter/samples/piano/piano_99_4.opus +0 -0
- package/starter/samples/piano/piano_99_8.opus +0 -0
- package/starter/samples/piano/piano_rel_102_x.opus +0 -0
- package/starter/samples/piano/piano_rel_105_x.opus +0 -0
- package/starter/samples/piano/piano_rel_108_x.opus +0 -0
- package/starter/samples/piano/piano_rel_21_x.opus +0 -0
- package/starter/samples/piano/piano_rel_24_x.opus +0 -0
- package/starter/samples/piano/piano_rel_27_x.opus +0 -0
- package/starter/samples/piano/piano_rel_30_x.opus +0 -0
- package/starter/samples/piano/piano_rel_33_x.opus +0 -0
- package/starter/samples/piano/piano_rel_36_x.opus +0 -0
- package/starter/samples/piano/piano_rel_39_x.opus +0 -0
- package/starter/samples/piano/piano_rel_42_x.opus +0 -0
- package/starter/samples/piano/piano_rel_45_x.opus +0 -0
- package/starter/samples/piano/piano_rel_48_x.opus +0 -0
- package/starter/samples/piano/piano_rel_51_x.opus +0 -0
- package/starter/samples/piano/piano_rel_54_x.opus +0 -0
- package/starter/samples/piano/piano_rel_57_x.opus +0 -0
- package/starter/samples/piano/piano_rel_60_x.opus +0 -0
- package/starter/samples/piano/piano_rel_63_x.opus +0 -0
- package/starter/samples/piano/piano_rel_66_x.opus +0 -0
- package/starter/samples/piano/piano_rel_69_x.opus +0 -0
- package/starter/samples/piano/piano_rel_72_x.opus +0 -0
- package/starter/samples/piano/piano_rel_75_x.opus +0 -0
- package/starter/samples/piano/piano_rel_78_x.opus +0 -0
- package/starter/samples/piano/piano_rel_81_x.opus +0 -0
- package/starter/samples/piano/piano_rel_84_x.opus +0 -0
- package/starter/samples/piano/piano_rel_87_x.opus +0 -0
- package/starter/samples/piano/piano_rel_90_x.opus +0 -0
- package/starter/samples/piano/piano_rel_93_x.opus +0 -0
- package/starter/samples/piano/piano_rel_96_x.opus +0 -0
- package/starter/samples/piano/piano_rel_99_x.opus +0 -0
- package/starter/samples/pizz/pizz_24_2.flac +0 -0
- package/starter/samples/pizz/pizz_28_2.flac +0 -0
- package/starter/samples/pizz/pizz_31_2.flac +0 -0
- package/starter/samples/pizz/pizz_35_2.flac +0 -0
- package/starter/samples/pizz/pizz_38_2.flac +0 -0
- package/starter/samples/pizz/pizz_41_2.flac +0 -0
- package/starter/samples/pizz/pizz_45_2.flac +0 -0
- package/starter/samples/pizz/pizz_48_2.flac +0 -0
- package/starter/samples/pizz/pizz_52_2.flac +0 -0
- package/starter/samples/pizz/pizz_57_2.flac +0 -0
- package/starter/samples/pizz/pizz_60_2.flac +0 -0
- package/starter/samples/pizz/pizz_64_2.flac +0 -0
- package/starter/samples/pizz/pizz_67_2.flac +0 -0
- package/starter/samples/pizz/pizz_71_2.flac +0 -0
- package/starter/samples/pizz/pizz_74_2.flac +0 -0
- package/starter/samples/pk_hat/pk_hat_2_1.flac +0 -0
- package/starter/samples/pk_hat/pk_hat_2_2.flac +0 -0
- package/starter/samples/pk_hat/pk_hat_6_1.flac +0 -0
- package/starter/samples/pk_hat/pk_hat_6_2.flac +0 -0
- package/starter/samples/pk_kick/pk_kick_3_1.flac +0 -0
- package/starter/samples/pk_kick/pk_kick_3_2.flac +0 -0
- package/starter/samples/pk_kick/pk_kick_7_1.flac +0 -0
- package/starter/samples/pk_kick/pk_kick_7_2.flac +0 -0
- package/starter/samples/pk_ohat/pk_ohat_3_1.flac +0 -0
- package/starter/samples/pk_ohat/pk_ohat_3_2.flac +0 -0
- package/starter/samples/pk_ohat/pk_ohat_6_1.flac +0 -0
- package/starter/samples/pk_ohat/pk_ohat_6_2.flac +0 -0
- package/starter/samples/pk_rim/pk_rim_2_1.flac +0 -0
- package/starter/samples/pk_rim/pk_rim_2_2.flac +0 -0
- package/starter/samples/pk_rim/pk_rim_5_1.flac +0 -0
- package/starter/samples/pk_rim/pk_rim_5_2.flac +0 -0
- package/starter/samples/pk_snare/pk_snare_3_1.flac +0 -0
- package/starter/samples/pk_snare/pk_snare_3_2.flac +0 -0
- package/starter/samples/pk_snare/pk_snare_7_1.flac +0 -0
- package/starter/samples/pk_snare/pk_snare_7_2.flac +0 -0
- package/starter/samples/shaker/shaker_1_1.flac +0 -0
- package/starter/samples/shaker/shaker_2_1.flac +0 -0
- package/starter/samples/snap/snap_r_1.flac +0 -0
- package/starter/samples/snap/snap_r_2.flac +0 -0
- package/starter/samples/snap/snap_r_3.flac +0 -0
- package/starter/samples/snap/snap_r_4.flac +0 -0
- package/starter/samples/snap/snap_r_5.flac +0 -0
- package/starter/samples/snap/snap_r_6.flac +0 -0
- package/starter/samples/tom/tom_3_1.flac +0 -0
- package/starter/samples/tom/tom_3_2.flac +0 -0
- package/starter/samples/tom/tom_4_1.flac +0 -0
- package/starter/samples/tom/tom_4_2.flac +0 -0
- package/starter/samples/vibes/vibes_41_1.opus +0 -0
- package/starter/samples/vibes/vibes_41_2.opus +0 -0
- package/starter/samples/vibes/vibes_45_1.opus +0 -0
- package/starter/samples/vibes/vibes_45_2.opus +0 -0
- package/starter/samples/vibes/vibes_48_1.opus +0 -0
- package/starter/samples/vibes/vibes_48_2.opus +0 -0
- package/starter/samples/vibes/vibes_52_1.opus +0 -0
- package/starter/samples/vibes/vibes_52_2.opus +0 -0
- package/starter/samples/vibes/vibes_55_1.opus +0 -0
- package/starter/samples/vibes/vibes_55_2.opus +0 -0
- package/starter/samples/vibes/vibes_59_1.opus +0 -0
- package/starter/samples/vibes/vibes_59_2.opus +0 -0
- package/starter/samples/vibes/vibes_62_1.opus +0 -0
- package/starter/samples/vibes/vibes_62_2.opus +0 -0
- package/starter/samples/vibes/vibes_65_1.opus +0 -0
- package/starter/samples/vibes/vibes_65_2.opus +0 -0
- package/starter/samples/vibes/vibes_69_1.opus +0 -0
- package/starter/samples/vibes/vibes_69_2.opus +0 -0
- package/starter/samples/vibes/vibes_72_1.opus +0 -0
- package/starter/samples/vibes/vibes_72_2.opus +0 -0
- package/starter/samples/vibes/vibes_76_1.opus +0 -0
- package/starter/samples/vibes/vibes_76_2.opus +0 -0
- package/starter/samples/violas/violas_36_1.opus +0 -0
- package/starter/samples/violas/violas_36_2.opus +0 -0
- package/starter/samples/violas/violas_38_1.opus +0 -0
- package/starter/samples/violas/violas_38_2.opus +0 -0
- package/starter/samples/violas/violas_40_1.opus +0 -0
- package/starter/samples/violas/violas_40_2.opus +0 -0
- package/starter/samples/violas/violas_43_1.opus +0 -0
- package/starter/samples/violas/violas_43_2.opus +0 -0
- package/starter/samples/violas/violas_47_1.opus +0 -0
- package/starter/samples/violas/violas_47_2.opus +0 -0
- package/starter/samples/violas/violas_50_1.opus +0 -0
- package/starter/samples/violas/violas_50_2.opus +0 -0
- package/starter/samples/violas/violas_53_1.opus +0 -0
- package/starter/samples/violas/violas_53_2.opus +0 -0
- package/starter/samples/violas/violas_57_1.opus +0 -0
- package/starter/samples/violas/violas_57_2.opus +0 -0
- package/starter/samples/violas/violas_60_1.opus +0 -0
- package/starter/samples/violas/violas_60_2.opus +0 -0
- package/starter/samples/violas/violas_64_1.opus +0 -0
- package/starter/samples/violas/violas_64_2.opus +0 -0
- package/starter/samples/violas/violas_67_1.opus +0 -0
- package/starter/samples/violas/violas_67_2.opus +0 -0
- package/starter/samples/violas/violas_71_1.opus +0 -0
- package/starter/samples/violas/violas_71_2.opus +0 -0
- package/starter/samples/violas/violas_74_1.opus +0 -0
- package/starter/samples/violas/violas_74_2.opus +0 -0
- package/starter/samples/violins/violins_43_1.opus +0 -0
- package/starter/samples/violins/violins_43_2.opus +0 -0
- package/starter/samples/violins/violins_45_1.opus +0 -0
- package/starter/samples/violins/violins_45_2.opus +0 -0
- package/starter/samples/violins/violins_47_1.opus +0 -0
- package/starter/samples/violins/violins_47_2.opus +0 -0
- package/starter/samples/violins/violins_50_1.opus +0 -0
- package/starter/samples/violins/violins_50_2.opus +0 -0
- package/starter/samples/violins/violins_54_1.opus +0 -0
- package/starter/samples/violins/violins_54_2.opus +0 -0
- package/starter/samples/violins/violins_57_1.opus +0 -0
- package/starter/samples/violins/violins_57_2.opus +0 -0
- package/starter/samples/violins/violins_60_1.opus +0 -0
- package/starter/samples/violins/violins_60_2.opus +0 -0
- package/starter/samples/violins/violins_64_1.opus +0 -0
- package/starter/samples/violins/violins_64_2.opus +0 -0
- package/starter/samples/violins/violins_67_1.opus +0 -0
- package/starter/samples/violins/violins_67_2.opus +0 -0
- package/starter/samples/violins/violins_71_1.opus +0 -0
- package/starter/samples/violins/violins_71_2.opus +0 -0
- package/starter/samples/violins/violins_74_1.opus +0 -0
- package/starter/samples/violins/violins_74_2.opus +0 -0
- package/starter/samples/woodblock/woodblock_f_1.flac +0 -0
- package/starter/samples/woodblock/woodblock_f_2.flac +0 -0
package/kit/cursor.js
ADDED
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
// A cursor for a film page — open-take's film kit. Say where it acts and
|
|
3
|
+
// when; it travels there the way open-take's take cursor does (tuned by eye
|
|
4
|
+
// on recordings):
|
|
5
|
+
//
|
|
6
|
+
// - a steady speed on screen: 0.35 content widths a second at full view, so
|
|
7
|
+
// a short hop takes its time and a long crossing does not crawl; each leg
|
|
8
|
+
// lasts 0.30–0.85 s and lands exactly on the action;
|
|
9
|
+
// - zoomed in, what the viewer sees is what counts: with the camera given,
|
|
10
|
+
// a leg is timed by the distance it covers in the picture, not in the page;
|
|
11
|
+
// - a smootherstep curve with a slight arc (5 % of the leg, at most 24 px).
|
|
12
|
+
//
|
|
13
|
+
// What it looks like is yours: at(t) says where it is, whether a button is
|
|
14
|
+
// held (a drag) and how far a click's ripple has spread (0..1 over 0.45 s).
|
|
15
|
+
// Every leg can set its own duration.
|
|
16
|
+
//
|
|
17
|
+
// const cur = cursor({ camera: cam, start: { x: 960, y: 900 } });
|
|
18
|
+
// cur.click(box, 12.4); // arrives at 12.4 s and clicks
|
|
19
|
+
// cur.drag([from, to], 14.0, 15.2); // button held from 14.0 to 15.2
|
|
20
|
+
// const c = cur.at(t); // { x, y, sx, sy, down, ripple }
|
|
21
|
+
|
|
22
|
+
/** @typedef {{ x: number, y: number }} Pt a point of the content, in its CSS px */
|
|
23
|
+
/** @typedef {{ x: number, y: number, width: number, height: number }} Box */
|
|
24
|
+
/** @typedef {{ pointAt: (t: number) => Pt, used?: (use: string, t: number) => unknown }} PartLike a part of the product (kit/media.js product()): acted on where the capture acted on it */
|
|
25
|
+
/** @typedef {{ path: Pt[], at: number, end: number, ease?: (p: number) => number }} DragLike a drag as product().drag() gives it */
|
|
26
|
+
/**
|
|
27
|
+
* @typedef {object} Leg
|
|
28
|
+
* @property {number} t0
|
|
29
|
+
* @property {number} t1
|
|
30
|
+
* @property {Pt} a
|
|
31
|
+
* @property {Pt} b
|
|
32
|
+
* @property {Pt[]} [path] a drag's stroke
|
|
33
|
+
* @property {(p: number) => number} [ease]
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
/** smootherstep, 6p⁵ − 15p⁴ + 10p³ */
|
|
37
|
+
/** @param {number} p */
|
|
38
|
+
const smooth = (p) => {
|
|
39
|
+
const x = Math.max(0, Math.min(1, p));
|
|
40
|
+
return x * x * x * (x * (x * 6 - 15) + 10);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/** @param {Pt | Box} target */
|
|
44
|
+
const pointOf = (target) =>
|
|
45
|
+
"width" in target ? { x: target.x + target.width / 2, y: target.y + target.height / 2 } : target;
|
|
46
|
+
|
|
47
|
+
/** a part of the product: the point it is acted on at t, the use said;
|
|
48
|
+
* a point or a box as it is
|
|
49
|
+
* @param {Pt | Box | PartLike} target @param {string} kind @param {number} at @returns {Pt | Box} */
|
|
50
|
+
const targetAt = (target, kind, at) => {
|
|
51
|
+
if (!("pointAt" in target) || typeof target.pointAt !== "function")
|
|
52
|
+
return /** @type {Pt | Box} */ (target);
|
|
53
|
+
target.used?.(kind, at);
|
|
54
|
+
return target.pointAt(at);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/** a point a fraction u along a polyline, by length */
|
|
58
|
+
/** @param {Pt[]} path @param {number} u */
|
|
59
|
+
function along(path, u) {
|
|
60
|
+
if (path.length === 1) return /** @type {Pt} */ (path[0]);
|
|
61
|
+
let total = 0;
|
|
62
|
+
const seg = [];
|
|
63
|
+
for (let i = 0; i < path.length - 1; i++) {
|
|
64
|
+
const a = /** @type {Pt} */ (path[i]);
|
|
65
|
+
const b = /** @type {Pt} */ (path[i + 1]);
|
|
66
|
+
const d = Math.hypot(b.x - a.x, b.y - a.y);
|
|
67
|
+
seg.push(d);
|
|
68
|
+
total += d;
|
|
69
|
+
}
|
|
70
|
+
if (total === 0) return /** @type {Pt} */ (path[0]);
|
|
71
|
+
let left = u * total;
|
|
72
|
+
for (let i = 0; i < seg.length; i++) {
|
|
73
|
+
const d = /** @type {number} */ (seg[i]);
|
|
74
|
+
if (left <= d || i === seg.length - 1) {
|
|
75
|
+
const a = /** @type {Pt} */ (path[i]);
|
|
76
|
+
const b = /** @type {Pt} */ (path[i + 1]);
|
|
77
|
+
const f = d > 0 ? Math.min(1, left / d) : 0;
|
|
78
|
+
return { x: a.x + (b.x - a.x) * f, y: a.y + (b.y - a.y) * f };
|
|
79
|
+
}
|
|
80
|
+
left -= d;
|
|
81
|
+
}
|
|
82
|
+
return /** @type {Pt} */ (path[path.length - 1]);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* @param {object} opts
|
|
87
|
+
* @param {{ content: { width: number, height: number }, view: { width: number, height: number }, at: (t: number) => { scale: number }, toView: (x: number, y: number, t: number) => number[] }} [opts.camera]
|
|
88
|
+
* the camera the cursor's layer is seen through (from kit/camera.js)
|
|
89
|
+
* @param {{ width: number, height: number }} [opts.content] the layer's size, when there is no camera
|
|
90
|
+
* @param {Pt} [opts.start] where it waits before its first move
|
|
91
|
+
* @param {number} [opts.speed] content widths a second, at full view
|
|
92
|
+
* @param {number} [opts.min] shortest leg (s)
|
|
93
|
+
* @param {number} [opts.max] longest leg (s)
|
|
94
|
+
* @param {number} [opts.ripple] how long a click's ripple lasts (s)
|
|
95
|
+
*/
|
|
96
|
+
export function cursor({
|
|
97
|
+
camera,
|
|
98
|
+
content,
|
|
99
|
+
start,
|
|
100
|
+
speed = 0.35,
|
|
101
|
+
min = 0.3,
|
|
102
|
+
max = 0.85,
|
|
103
|
+
ripple = 0.45,
|
|
104
|
+
} = {}) {
|
|
105
|
+
const size = camera?.content ?? content;
|
|
106
|
+
if (!size) throw new Error("cursor: give it the camera, or the content's { width, height }");
|
|
107
|
+
/** @type {{ kind: "click" | "move" | "drag" | "type", at: number, end: number, to: Pt, path?: Pt[], dur?: number, ease?: (p: number) => number }[]} */
|
|
108
|
+
const asked = [];
|
|
109
|
+
/** @type {{ legs: Leg[], clicks: number[], held: [number, number][] } | null} */
|
|
110
|
+
let planned = null;
|
|
111
|
+
|
|
112
|
+
// how much of the picture one content px buys at t, relative to full view:
|
|
113
|
+
// integrating it over a leg gives the distance the viewer sees it cross
|
|
114
|
+
const full = camera
|
|
115
|
+
? Math.min(camera.view.width / size.width, camera.view.height / size.height)
|
|
116
|
+
: 1;
|
|
117
|
+
/** @param {number} t */
|
|
118
|
+
const frac = (t) => (camera ? full / Math.max(camera.at(t).scale, 1e-6) : 1);
|
|
119
|
+
/** when a leg of `dist` content px must leave to land at `arrive` at the steady on-screen speed */
|
|
120
|
+
/** @param {number} dist @param {number} arrive */
|
|
121
|
+
const travel = (dist, arrive) => {
|
|
122
|
+
const pxPerS = speed * size.width;
|
|
123
|
+
let sec;
|
|
124
|
+
if (!camera) sec = dist / pxPerS;
|
|
125
|
+
else {
|
|
126
|
+
// walk back from the arrival, 5 ms at a time, until the leg's worth of
|
|
127
|
+
// full-view distance is covered (the take cursor inverts the same integral)
|
|
128
|
+
const need = dist / pxPerS;
|
|
129
|
+
const step = 0.005;
|
|
130
|
+
let acc = 0;
|
|
131
|
+
let t = arrive;
|
|
132
|
+
while (acc < need && arrive - t < max + step) {
|
|
133
|
+
const f = (frac(t) + frac(t - step)) / 2;
|
|
134
|
+
acc += f * step;
|
|
135
|
+
t -= step;
|
|
136
|
+
}
|
|
137
|
+
sec = arrive - t;
|
|
138
|
+
}
|
|
139
|
+
return Math.min(max, Math.max(min, sec));
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
const plan = () => {
|
|
143
|
+
if (planned) return planned;
|
|
144
|
+
const order = [...asked].sort((a, b) => a.at - b.at);
|
|
145
|
+
/** @type {Leg[]} */
|
|
146
|
+
const legs = [];
|
|
147
|
+
/** @type {number[]} */
|
|
148
|
+
const clicks = [];
|
|
149
|
+
/** @type {[number, number][]} */
|
|
150
|
+
const held = [];
|
|
151
|
+
let cur = start ?? { x: size.width / 2, y: size.height / 2 };
|
|
152
|
+
let free = 0; // when the last action ended: a move never departs before it
|
|
153
|
+
for (const a of order) {
|
|
154
|
+
const dist = Math.hypot(a.to.x - cur.x, a.to.y - cur.y);
|
|
155
|
+
// every move gets its leg, however small: skipping one would leave the
|
|
156
|
+
// cursor behind where the next one is measured from
|
|
157
|
+
if (dist > 0) {
|
|
158
|
+
const dur = a.dur ?? travel(dist, a.at);
|
|
159
|
+
const prev = legs.length ? /** @type {Leg} */ (legs[legs.length - 1]).t1 : 0;
|
|
160
|
+
const t0 = Math.min(a.at, Math.max(a.at - dur, prev, free, 0));
|
|
161
|
+
legs.push({ t0, t1: a.at, a: cur, b: a.to });
|
|
162
|
+
}
|
|
163
|
+
cur = a.to;
|
|
164
|
+
if (a.kind === "click") clicks.push(a.at);
|
|
165
|
+
if (a.kind === "drag" && a.path) {
|
|
166
|
+
legs.push({
|
|
167
|
+
t0: a.at,
|
|
168
|
+
t1: a.end,
|
|
169
|
+
a: a.to,
|
|
170
|
+
b: /** @type {Pt} */ (a.path[a.path.length - 1]),
|
|
171
|
+
path: a.path,
|
|
172
|
+
ease: a.ease ?? smooth,
|
|
173
|
+
});
|
|
174
|
+
held.push([a.at, a.end]);
|
|
175
|
+
cur = /** @type {Pt} */ (a.path[a.path.length - 1]);
|
|
176
|
+
}
|
|
177
|
+
free = Math.max(free, a.end);
|
|
178
|
+
}
|
|
179
|
+
planned = { legs, clicks, held };
|
|
180
|
+
return planned;
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
/** @param {number} t */
|
|
184
|
+
const pos = (t) => {
|
|
185
|
+
const { legs } = plan();
|
|
186
|
+
for (const lg of legs) {
|
|
187
|
+
if (t < lg.t0 || t > lg.t1) continue;
|
|
188
|
+
const span = lg.t1 - lg.t0;
|
|
189
|
+
const u = span > 0 ? Math.max(0, Math.min(1, (t - lg.t0) / span)) : 1;
|
|
190
|
+
if (lg.path) return along(lg.path, (lg.ease ?? smooth)(u));
|
|
191
|
+
const p = smooth(u);
|
|
192
|
+
const dx = lg.b.x - lg.a.x;
|
|
193
|
+
const dy = lg.b.y - lg.a.y;
|
|
194
|
+
const L = Math.hypot(dx, dy) || 1;
|
|
195
|
+
const arc = Math.min(0.05 * L, 24) * Math.sin(Math.PI * p);
|
|
196
|
+
return { x: lg.a.x + dx * p + (-dy / L) * arc, y: lg.a.y + dy * p + (dx / L) * arc };
|
|
197
|
+
}
|
|
198
|
+
let at = start ?? { x: size.width / 2, y: size.height / 2 };
|
|
199
|
+
for (const lg of legs)
|
|
200
|
+
if (lg.t1 <= t) at = lg.path ? /** @type {Pt} */ (lg.path[lg.path.length - 1]) : lg.b;
|
|
201
|
+
return at;
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
/** @param {"click" | "move" | "drag" | "type"} kind @param {Pt | Box | PartLike} target @param {number} at @param {number} end @param {{ dur?: number, ease?: (p: number) => number }} o @param {Pt[]} [path] */
|
|
205
|
+
const add = (kind, target, at, end, o, path) => {
|
|
206
|
+
if (!Number.isFinite(at)) throw new Error(`cursor: ${kind} needs a time`);
|
|
207
|
+
if (end < at) throw new Error(`cursor: ${kind} at ${at}s ends before it starts`);
|
|
208
|
+
const to = pointOf(targetAt(target, kind, at));
|
|
209
|
+
asked.push({ kind, at, end, to, path, dur: o.dur, ease: o.ease });
|
|
210
|
+
planned = null;
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
return {
|
|
214
|
+
/** travel to the target and click at `at` (`dur`: this leg's travel time);
|
|
215
|
+
* a part of the product is clicked where the capture clicked it */
|
|
216
|
+
/** @param {Pt | Box | PartLike} target @param {number} at @param {{ dur?: number }} [o] */
|
|
217
|
+
click: (target, at, o = {}) => add("click", target, at, at, o),
|
|
218
|
+
/** travel to the target, arriving at `at`, without clicking */
|
|
219
|
+
/** @param {Pt | Box | PartLike} target @param {number} at @param {{ dur?: number }} [o] */
|
|
220
|
+
move: (target, at, o = {}) => add("move", target, at, at, o),
|
|
221
|
+
/** travel to the field by `at` and stay there while typing until `end` */
|
|
222
|
+
/** @param {Pt | Box | PartLike} target @param {number} at @param {number} end @param {{ dur?: number }} [o] */
|
|
223
|
+
type: (target, at, end, o = {}) => add("type", target, at, end, o),
|
|
224
|
+
/** hold the button down along `path` from `at` to `end` (travelling to its
|
|
225
|
+
* start first) — or one drag as product().drag() gives it: its path,
|
|
226
|
+
* times and pace */
|
|
227
|
+
/** @param {Pt[] | DragLike} path @param {number} [at] @param {number} [end] @param {{ dur?: number, ease?: (p: number) => number }} [o] */
|
|
228
|
+
drag: (path, at, end, o = {}) => {
|
|
229
|
+
/** @type {Pt[]} */
|
|
230
|
+
let pts = /** @type {Pt[]} */ (path);
|
|
231
|
+
if (!Array.isArray(path)) {
|
|
232
|
+
pts = path?.path;
|
|
233
|
+
at = path?.at;
|
|
234
|
+
end = path?.end;
|
|
235
|
+
o = { ...o, ease: path?.ease ?? o.ease };
|
|
236
|
+
}
|
|
237
|
+
if (!Array.isArray(pts) || pts.length < 2)
|
|
238
|
+
throw new Error("cursor: a drag needs a path of at least two points");
|
|
239
|
+
if (end == null) throw new Error("cursor: a drag needs the time it ends");
|
|
240
|
+
add("drag", /** @type {Pt} */ (pts[0]), /** @type {number} */ (at), end, o, pts);
|
|
241
|
+
},
|
|
242
|
+
/** where it is at t (content px, and picture px with a camera), whether a
|
|
243
|
+
* button is held, and a click's ripple (0..1, or null) */
|
|
244
|
+
/** @param {number} t */
|
|
245
|
+
at: (t) => {
|
|
246
|
+
const { clicks, held } = plan();
|
|
247
|
+
const p = pos(t);
|
|
248
|
+
const v = camera ? camera.toView(p.x, p.y, t) : [p.x, p.y];
|
|
249
|
+
let r = null;
|
|
250
|
+
for (const c of clicks)
|
|
251
|
+
if (t >= c && t - c <= ripple + 1e-9) r = Math.min(1, (t - c) / ripple);
|
|
252
|
+
return {
|
|
253
|
+
x: p.x,
|
|
254
|
+
y: p.y,
|
|
255
|
+
sx: /** @type {number} */ (v[0]),
|
|
256
|
+
sy: /** @type {number} */ (v[1]),
|
|
257
|
+
down: held.some(([a, b]) => t >= a && t <= b),
|
|
258
|
+
ripple: r,
|
|
259
|
+
};
|
|
260
|
+
},
|
|
261
|
+
/** the legs as planned */
|
|
262
|
+
legs: () => plan().legs,
|
|
263
|
+
};
|
|
264
|
+
}
|
package/kit/cut.js
ADDED
|
@@ -0,0 +1,427 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
// Cutting on the music — open-take's film kit. Plain functions of numbers: a
|
|
3
|
+
// grid of the music's beats and bars to put cuts on, the framing that makes a
|
|
4
|
+
// subject land in the next shot where it left the last one, and the cuts
|
|
5
|
+
// declared as events for the score. Nothing here cuts on its own; where and
|
|
6
|
+
// how often the film cuts is yours.
|
|
7
|
+
//
|
|
8
|
+
// import { grid, matchCut, cuts, density } from "./kit/cut.js";
|
|
9
|
+
// import { throughCamera } from "./kit/media.js";
|
|
10
|
+
//
|
|
11
|
+
// // from `open-take film beats music.mp3` (fetched before window.__film is set)
|
|
12
|
+
// const g = grid(await (await fetch("music.beats.json")).json());
|
|
13
|
+
// // or a pulse of your own: grid({ bpm: /* the music's */, offset: /* s */ })
|
|
14
|
+
// g.bar(4) // when bar 4 starts (s)
|
|
15
|
+
// g.snap(3.1) // the nearest beat to 3.1 s
|
|
16
|
+
// g.snap(3.1, { to: "onset", within: 0.08 })// the nearest onset, if one is that near
|
|
17
|
+
// g.between(8, 12, { to: "bar" }) // the bar lines in [8, 12)
|
|
18
|
+
//
|
|
19
|
+
// // the subject left the last shot here (picture px) …
|
|
20
|
+
// const left = throughCamera(app.box("#export"), camA, tCut);
|
|
21
|
+
// // … so frame the next shot to put its own copy of it in the same place
|
|
22
|
+
// camB.cut(matchCut(left, result.box, { width: 1920, height: 1080 }), tCut, { keepInside: false });
|
|
23
|
+
//
|
|
24
|
+
// // a section that holds, one that bursts, one that breathes — on the grid
|
|
25
|
+
// const times = density(g, [
|
|
26
|
+
// { from: 0, to: g.bar(4), intent: "hold" },
|
|
27
|
+
// { from: g.bar(4), to: g.bar(8), intent: "burst" },
|
|
28
|
+
// { from: g.bar(8), to: g.bar(10), intent: { every: [4, 0.5] } }, // faster and faster
|
|
29
|
+
// ]);
|
|
30
|
+
// cuts(tl, times); // tl.event(t, "cut") each: `film render` keeps them
|
|
31
|
+
|
|
32
|
+
/** @typedef {{ x: number, y: number, width: number, height: number }} Box a region, in one place's own px */
|
|
33
|
+
/** @typedef {Box | { x: number, y: number, w: number, h: number }} BoxLike */
|
|
34
|
+
/** @typedef {{ cx: number, cy: number, w: number }} View what a camera shows: its centre and width, in its content's px */
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* `<name>.beats.json` as `open-take film beats` writes it (the fields used here).
|
|
38
|
+
* @typedef {object} BeatsJson
|
|
39
|
+
* @property {1} version
|
|
40
|
+
* @property {number} duration
|
|
41
|
+
* @property {{ bpm: number | null, periodS?: number, confidence?: number }} tempo
|
|
42
|
+
* @property {number[]} beats
|
|
43
|
+
* @property {number[]} downbeats
|
|
44
|
+
* @property {{ beatsPerBar: number | null }} [meter]
|
|
45
|
+
* @property {{ t: number, end: number, energy: number, label?: string }[]} [sections]
|
|
46
|
+
* @property {number[]} [drops]
|
|
47
|
+
* @property {number[]} [onsets]
|
|
48
|
+
*/
|
|
49
|
+
|
|
50
|
+
/** "beat", "half" (eighths), "quarter" (sixteenths), "bar", or what the music has: "onset", "section", "drop" */
|
|
51
|
+
/** @typedef {"beat" | "half" | "quarter" | "bar" | "onset" | "section" | "drop"} To */
|
|
52
|
+
|
|
53
|
+
/** @param {unknown} v @returns {v is number} */
|
|
54
|
+
const finite = (v) => typeof v === "number" && Number.isFinite(v);
|
|
55
|
+
|
|
56
|
+
/** @param {readonly number[]} xs @param {number} t the index of the last x ≤ t (−1 before the first) */
|
|
57
|
+
function floorIndex(xs, t) {
|
|
58
|
+
let lo = 0;
|
|
59
|
+
let hi = xs.length;
|
|
60
|
+
while (lo < hi) {
|
|
61
|
+
const mid = (lo + hi) >> 1;
|
|
62
|
+
if (/** @type {number} */ (xs[mid]) <= t) lo = mid + 1;
|
|
63
|
+
else hi = mid;
|
|
64
|
+
}
|
|
65
|
+
return lo - 1;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Times laid on a list of marks, with a length per step beyond its ends:
|
|
70
|
+
* at(n) for any n (fractional between marks, extrapolated past them), and
|
|
71
|
+
* indexOf(t), its inverse.
|
|
72
|
+
* @param {readonly number[]} marks sorted
|
|
73
|
+
* @param {number} step
|
|
74
|
+
* @param {number} origin the time of mark 0 when there are no marks
|
|
75
|
+
*/
|
|
76
|
+
function ruler(marks, step, origin) {
|
|
77
|
+
const n = marks.length;
|
|
78
|
+
/** @param {number} i */
|
|
79
|
+
const at = (i) => {
|
|
80
|
+
if (!n) return origin + i * step;
|
|
81
|
+
if (i <= 0) return /** @type {number} */ (marks[0]) + i * step;
|
|
82
|
+
if (i >= n - 1) return /** @type {number} */ (marks[n - 1]) + (i - (n - 1)) * step;
|
|
83
|
+
const k = Math.floor(i);
|
|
84
|
+
const a = /** @type {number} */ (marks[k]);
|
|
85
|
+
const b = /** @type {number} */ (marks[k + 1]);
|
|
86
|
+
return a + (b - a) * (i - k);
|
|
87
|
+
};
|
|
88
|
+
/** @param {number} t */
|
|
89
|
+
const indexOf = (t) => {
|
|
90
|
+
if (!n) return (t - origin) / step;
|
|
91
|
+
const first = /** @type {number} */ (marks[0]);
|
|
92
|
+
const last = /** @type {number} */ (marks[n - 1]);
|
|
93
|
+
if (t <= first) return (t - first) / step;
|
|
94
|
+
if (t >= last) return n - 1 + (t - last) / step;
|
|
95
|
+
const k = floorIndex(marks, t);
|
|
96
|
+
const a = /** @type {number} */ (marks[k]);
|
|
97
|
+
const b = /** @type {number} */ (marks[k + 1]);
|
|
98
|
+
return k + (t - a) / (b - a);
|
|
99
|
+
};
|
|
100
|
+
return { at, indexOf };
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* The music's grid, to put cuts and moves on: from a beats file (`open-take
|
|
105
|
+
* film beats`), or from a pulse you give — `{ bpm, offset }`, offset the time
|
|
106
|
+
* of beat 0, and `beatsPerBar` (default 4; from a beats file, its own).
|
|
107
|
+
* Beats and bars are numbered from 0; any number works, fractional ones fall
|
|
108
|
+
* between (beat(2.5) is the "and" of beat 2), and past the music's ends the
|
|
109
|
+
* grid carries on at its tempo. A beats file's beats follow the music where
|
|
110
|
+
* its tempo moves; a pulse's are even.
|
|
111
|
+
* @param {BeatsJson | { bpm: number, offset?: number, beatsPerBar?: number, onsets?: number[] }} src
|
|
112
|
+
*/
|
|
113
|
+
export function grid(src) {
|
|
114
|
+
if (!src || typeof src !== "object")
|
|
115
|
+
throw new Error("grid: give it a beats file's JSON or { bpm }");
|
|
116
|
+
/** @type {BeatsJson | null} */
|
|
117
|
+
const file = "beats" in src && Array.isArray(src.beats) ? src : null;
|
|
118
|
+
/** @type {number[]} */
|
|
119
|
+
let beats = [];
|
|
120
|
+
/** @type {number[]} */
|
|
121
|
+
let downbeats = [];
|
|
122
|
+
let beatsPerBar = 4;
|
|
123
|
+
let offset = 0;
|
|
124
|
+
let period = Number.NaN;
|
|
125
|
+
if (file) {
|
|
126
|
+
beats = file.beats.filter(finite);
|
|
127
|
+
downbeats = (file.downbeats ?? []).filter(finite);
|
|
128
|
+
if (file.meter?.beatsPerBar) beatsPerBar = file.meter.beatsPerBar;
|
|
129
|
+
const { bpm, periodS } = file.tempo ?? {};
|
|
130
|
+
if (finite(periodS)) period = periodS;
|
|
131
|
+
else if (finite(bpm) && bpm > 0) period = 60 / bpm;
|
|
132
|
+
const first = beats[0];
|
|
133
|
+
const last = beats[beats.length - 1];
|
|
134
|
+
if (!(period > 0) && first != null && last != null && beats.length >= 2)
|
|
135
|
+
period = (last - first) / (beats.length - 1);
|
|
136
|
+
if (!(period > 0))
|
|
137
|
+
throw new Error(
|
|
138
|
+
"grid: this beats file found no tempo — give a pulse of your own: grid({ bpm })",
|
|
139
|
+
);
|
|
140
|
+
offset = first ?? 0;
|
|
141
|
+
} else {
|
|
142
|
+
const p = /** @type {{ bpm: number, offset?: number, beatsPerBar?: number }} */ (src);
|
|
143
|
+
if (!(finite(p.bpm) && p.bpm > 0))
|
|
144
|
+
throw new Error(`grid: bpm is beats a minute, above 0 (got ${p.bpm})`);
|
|
145
|
+
period = 60 / p.bpm;
|
|
146
|
+
offset = p.offset ?? 0;
|
|
147
|
+
if (!finite(offset)) throw new Error(`grid: offset is the time of beat 0 (got ${p.offset})`);
|
|
148
|
+
beatsPerBar = p.beatsPerBar ?? 4;
|
|
149
|
+
}
|
|
150
|
+
if (!(Number.isInteger(beatsPerBar) && beatsPerBar > 0))
|
|
151
|
+
throw new Error(`grid: beatsPerBar is a whole number above 0 (got ${beatsPerBar})`);
|
|
152
|
+
const B = ruler(beats, period, offset);
|
|
153
|
+
// without downbeats, bar 0 starts on beat 0
|
|
154
|
+
const D = downbeats.length ? ruler(downbeats, period * beatsPerBar, 0) : null;
|
|
155
|
+
/** @param {number} n */
|
|
156
|
+
const bar = (n) => (D ? D.at(n) : B.at(n * beatsPerBar));
|
|
157
|
+
/** @param {number} t */
|
|
158
|
+
const barOf = (t) => (D ? D.indexOf(t) : B.indexOf(t) / beatsPerBar);
|
|
159
|
+
/** @type {unknown[]} */
|
|
160
|
+
const given = "onsets" in src && Array.isArray(src.onsets) ? src.onsets : [];
|
|
161
|
+
const onsets = given.filter(finite).sort((a, b) => a - b);
|
|
162
|
+
const sections = (file?.sections ?? []).map((x) => x.t).filter(finite);
|
|
163
|
+
const drops = (file?.drops ?? []).filter(finite);
|
|
164
|
+
|
|
165
|
+
/** the marks of a kind around t: the one at or before it and the one after
|
|
166
|
+
* @param {To} to @param {number} t @returns {[number, number] | null} */
|
|
167
|
+
const around = (to, t) => {
|
|
168
|
+
/** @param {number} i @param {(i: number) => number} at */
|
|
169
|
+
const pair = (i, at) =>
|
|
170
|
+
/** @type {[number, number]} */ ([at(Math.floor(i + 1e-9)), at(Math.floor(i + 1e-9) + 1)]);
|
|
171
|
+
switch (to) {
|
|
172
|
+
case "beat":
|
|
173
|
+
return pair(B.indexOf(t), B.at);
|
|
174
|
+
case "half":
|
|
175
|
+
return pair(B.indexOf(t) * 2, (i) => B.at(i / 2));
|
|
176
|
+
case "quarter":
|
|
177
|
+
return pair(B.indexOf(t) * 4, (i) => B.at(i / 4));
|
|
178
|
+
case "bar":
|
|
179
|
+
return pair(barOf(t), bar);
|
|
180
|
+
case "onset":
|
|
181
|
+
case "section":
|
|
182
|
+
case "drop": {
|
|
183
|
+
const xs = to === "onset" ? onsets : to === "section" ? sections : drops;
|
|
184
|
+
if (!xs.length) return null;
|
|
185
|
+
const k = floorIndex(xs, t);
|
|
186
|
+
return [xs[Math.max(0, k)] ?? Number.NaN, xs[Math.min(xs.length - 1, k + 1)] ?? Number.NaN];
|
|
187
|
+
}
|
|
188
|
+
default:
|
|
189
|
+
throw new Error(
|
|
190
|
+
`grid: "${to}" is not something to snap to — beat, half, quarter, bar, onset, section or drop`,
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
/** the nearest mark of a kind to t (default the nearest beat); null when the music has none of that kind
|
|
196
|
+
* @param {number} t @param {To} [to] */
|
|
197
|
+
const nearest = (t, to = "beat") => {
|
|
198
|
+
const p = around(to, t);
|
|
199
|
+
if (!p) return null;
|
|
200
|
+
const [a, b] = p;
|
|
201
|
+
return Math.abs(b - t) < Math.abs(t - a) ? b : a;
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
return {
|
|
205
|
+
/** seconds a beat */
|
|
206
|
+
period,
|
|
207
|
+
beatsPerBar,
|
|
208
|
+
/** when beat n falls (s) @param {number} n */
|
|
209
|
+
beat: (n) => B.at(n),
|
|
210
|
+
/** when bar n starts (s) @param {number} n */
|
|
211
|
+
bar,
|
|
212
|
+
/** the beat t falls on, counting from 0 (fractional between beats) @param {number} t */
|
|
213
|
+
beatOf: (t) => B.indexOf(t),
|
|
214
|
+
/** the bar t falls in, counting from 0 (fractional within it) @param {number} t */
|
|
215
|
+
barOf,
|
|
216
|
+
nearest,
|
|
217
|
+
/**
|
|
218
|
+
* t moved onto the nearest mark of a kind (default a beat). With `within`
|
|
219
|
+
* (s), only when one is that near; otherwise t as it was.
|
|
220
|
+
* @param {number} t
|
|
221
|
+
* @param {{ to?: To, within?: number }} [o]
|
|
222
|
+
*/
|
|
223
|
+
snap: (t, o = {}) => {
|
|
224
|
+
const to = o.to ?? "beat";
|
|
225
|
+
const v = nearest(t, to);
|
|
226
|
+
if (v == null || !finite(v)) return t;
|
|
227
|
+
return o.within != null && Math.abs(v - t) > o.within ? t : v;
|
|
228
|
+
},
|
|
229
|
+
/**
|
|
230
|
+
* Every mark of a kind (default the beats) in [a, b).
|
|
231
|
+
* @param {number} a @param {number} b @param {{ to?: To }} [o]
|
|
232
|
+
*/
|
|
233
|
+
between: (a, b, o = {}) => {
|
|
234
|
+
const to = o.to ?? "beat";
|
|
235
|
+
if (to === "onset" || to === "section" || to === "drop") {
|
|
236
|
+
const xs = to === "onset" ? onsets : to === "section" ? sections : drops;
|
|
237
|
+
return xs.filter((x) => x >= a && x < b);
|
|
238
|
+
}
|
|
239
|
+
const per = to === "half" ? 2 : to === "quarter" ? 4 : 1;
|
|
240
|
+
const index = to === "bar" ? barOf : (/** @type {number} */ t) => B.indexOf(t) * per;
|
|
241
|
+
const at = to === "bar" ? bar : (/** @type {number} */ i) => B.at(i / per);
|
|
242
|
+
/** @type {number[]} */
|
|
243
|
+
const out = [];
|
|
244
|
+
for (let i = Math.ceil(index(a) - 1e-9); ; i++) {
|
|
245
|
+
const t = at(i);
|
|
246
|
+
if (t >= b - 1e-9) break;
|
|
247
|
+
if (t >= a - 1e-9) out.push(t);
|
|
248
|
+
}
|
|
249
|
+
return out;
|
|
250
|
+
},
|
|
251
|
+
/** the music's own marks, as the beats file has them (empty from a pulse) */
|
|
252
|
+
beats,
|
|
253
|
+
downbeats,
|
|
254
|
+
onsets,
|
|
255
|
+
sections,
|
|
256
|
+
drops,
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/** @param {BoxLike} b @returns {Box} */
|
|
261
|
+
function boxOf(b) {
|
|
262
|
+
const r = /** @type {any} */ (b);
|
|
263
|
+
const box = { x: r.x, y: r.y, width: r.width ?? r.w, height: r.height ?? r.h };
|
|
264
|
+
if (![box.x, box.y, box.width, box.height].every(finite) || !(box.width > 0 && box.height > 0))
|
|
265
|
+
throw new Error(
|
|
266
|
+
`a box is { x, y, width, height } with a size above 0 (got ${JSON.stringify(b)})`,
|
|
267
|
+
);
|
|
268
|
+
return box;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* A match cut: the framing for the incoming shot that puts a subject where,
|
|
273
|
+
* and as big as, it was in the picture when the last shot left it. `from` is
|
|
274
|
+
* where it showed then, in picture px (through a camera: media.js
|
|
275
|
+
* throughCamera(box, cam, t)); `to` is its box in the incoming shot's layer;
|
|
276
|
+
* `view` the picture's size. Returns the view ({ cx, cy, w }) for camera.js
|
|
277
|
+
* — `cam.cut(v, t, { keepInside: false })`, since keeping inside the content
|
|
278
|
+
* may move it off the match — or apply it yourself: scale = view.width / w.
|
|
279
|
+
* `fit` says what "as big" means when the two boxes differ in shape: "area"
|
|
280
|
+
* (default; the same area), "width", "height", "contain" (inside the old
|
|
281
|
+
* box), "cover" (over it). Centres always meet.
|
|
282
|
+
* @param {BoxLike} from
|
|
283
|
+
* @param {BoxLike} to
|
|
284
|
+
* @param {{ width: number, height: number }} view
|
|
285
|
+
* @param {{ fit?: "area" | "width" | "height" | "contain" | "cover" }} [o]
|
|
286
|
+
* @returns {View}
|
|
287
|
+
*/
|
|
288
|
+
export function matchCut(from, to, view, o = {}) {
|
|
289
|
+
const a = boxOf(from);
|
|
290
|
+
const b = boxOf(to);
|
|
291
|
+
if (!(view && view.width > 0 && view.height > 0))
|
|
292
|
+
throw new Error("matchCut: view is the picture's { width, height }");
|
|
293
|
+
const sx = a.width / b.width;
|
|
294
|
+
const sy = a.height / b.height;
|
|
295
|
+
const fit = o.fit ?? "area";
|
|
296
|
+
const s =
|
|
297
|
+
fit === "width"
|
|
298
|
+
? sx
|
|
299
|
+
: fit === "height"
|
|
300
|
+
? sy
|
|
301
|
+
: fit === "contain"
|
|
302
|
+
? Math.min(sx, sy)
|
|
303
|
+
: fit === "cover"
|
|
304
|
+
? Math.max(sx, sy)
|
|
305
|
+
: fit === "area"
|
|
306
|
+
? Math.sqrt(sx * sy)
|
|
307
|
+
: Number.NaN;
|
|
308
|
+
if (!(s > 0))
|
|
309
|
+
throw new Error(
|
|
310
|
+
`matchCut: fit is "area", "width", "height", "contain" or "cover" (got ${fit})`,
|
|
311
|
+
);
|
|
312
|
+
// picture = (content − view's left/top edge) · s, centre onto centre
|
|
313
|
+
const w = view.width / s;
|
|
314
|
+
return {
|
|
315
|
+
cx: b.x + b.width / 2 + (view.width / 2 - (a.x + a.width / 2)) / s,
|
|
316
|
+
cy: b.y + b.height / 2 + (view.height / 2 - (a.y + a.height / 2)) / s,
|
|
317
|
+
w,
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Declare cuts on a timeline (kit/time.js): tl.event(t, "cut", …) for each, so
|
|
323
|
+
* `film render` lists them as the page's cuts in <film>.events.json and the
|
|
324
|
+
* score can hear them. Each is a time or { t, label?, x?, y?, force? }. With
|
|
325
|
+
* `grid`, each is first snapped onto it — to `to`, default the beat (`within`, as grid.snap).
|
|
326
|
+
* Returns the times declared, in order.
|
|
327
|
+
* @param {{ event: (at: number, kind: string, o?: object) => number }} tl
|
|
328
|
+
* @param {(number | { t: number, label?: string, x?: number, y?: number, force?: number })[]} list
|
|
329
|
+
* @param {{ grid?: ReturnType<typeof grid>, to?: To, within?: number }} [o]
|
|
330
|
+
*/
|
|
331
|
+
export function cuts(tl, list, o = {}) {
|
|
332
|
+
if (!tl || typeof tl.event !== "function")
|
|
333
|
+
throw new Error("cuts: give it the timeline (kit/time.js) to declare them on");
|
|
334
|
+
if (!Array.isArray(list)) throw new Error("cuts: give it a list of times");
|
|
335
|
+
return list
|
|
336
|
+
.map((c) => {
|
|
337
|
+
const { t, ...rest } = typeof c === "number" ? { t: c } : c;
|
|
338
|
+
if (!finite(t)) throw new Error(`cuts: ${JSON.stringify(c)} is not at a time`);
|
|
339
|
+
const at =
|
|
340
|
+
o.grid && o.to
|
|
341
|
+
? o.grid.snap(t, { to: o.to, within: o.within })
|
|
342
|
+
: o.grid
|
|
343
|
+
? o.grid.snap(t, { within: o.within })
|
|
344
|
+
: t;
|
|
345
|
+
return tl.event(at, "cut", rest);
|
|
346
|
+
})
|
|
347
|
+
.sort((a, b) => a - b);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
/** the words `density` reads, as beats between cuts (Infinity: no cut but the section's first) */
|
|
351
|
+
export const PACE = Object.freeze({
|
|
352
|
+
hold: Infinity,
|
|
353
|
+
calm: 8,
|
|
354
|
+
steady: 4,
|
|
355
|
+
pulse: 2,
|
|
356
|
+
burst: 1,
|
|
357
|
+
flurry: 0.5,
|
|
358
|
+
});
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* Cut times for a run of sections, on the grid — one way to turn "this part
|
|
362
|
+
* holds, this one bursts" into times; call it if it helps, change what it
|
|
363
|
+
* gives, or place every cut by hand. Each section is { from, to, intent }:
|
|
364
|
+
* `intent` a word (PACE: hold, calm 8 beats, steady 4, pulse 2, burst 1,
|
|
365
|
+
* flurry ½), a number of beats between cuts, or { every } — a number, or
|
|
366
|
+
* [first, last] to change pace across the section evenly in log (a build:
|
|
367
|
+
* [4, 0.5]). Every cut lands on the grid (to a quarter beat when the pace is
|
|
368
|
+
* under a beat, else a half), or with `on: "onset"` on the nearest onset
|
|
369
|
+
* within a quarter beat when there is one. A section's own start is a cut
|
|
370
|
+
* unless `start: false`. Returns the times, in order, each once.
|
|
371
|
+
* @param {ReturnType<typeof grid>} g
|
|
372
|
+
* @param {{ from: number, to: number, intent: keyof typeof PACE | number | { every: number | [number, number] }, on?: "grid" | "onset", start?: boolean }[]} sections
|
|
373
|
+
* @returns {number[]}
|
|
374
|
+
*/
|
|
375
|
+
export function density(g, sections) {
|
|
376
|
+
if (!g || typeof g.beatOf !== "function")
|
|
377
|
+
throw new Error("density: give it a grid (cut.js grid)");
|
|
378
|
+
/** @type {number[]} */
|
|
379
|
+
const out = [];
|
|
380
|
+
for (const s of sections) {
|
|
381
|
+
if (!(finite(s.from) && finite(s.to) && s.to > s.from))
|
|
382
|
+
throw new Error(
|
|
383
|
+
`density: a section runs from one time to a later one (got ${s.from}–${s.to})`,
|
|
384
|
+
);
|
|
385
|
+
const i = s.intent;
|
|
386
|
+
/** @type {[number, number]} */
|
|
387
|
+
let every;
|
|
388
|
+
if (typeof i === "string") {
|
|
389
|
+
if (!(i in PACE))
|
|
390
|
+
throw new Error(
|
|
391
|
+
`density: "${i}" is not one of ${Object.keys(PACE).join(", ")} — or give a number of beats`,
|
|
392
|
+
);
|
|
393
|
+
const v = PACE[/** @type {keyof typeof PACE} */ (i)];
|
|
394
|
+
every = [v, v];
|
|
395
|
+
} else if (typeof i === "number") every = [i, i];
|
|
396
|
+
else if (i && typeof i === "object" && "every" in i)
|
|
397
|
+
every = Array.isArray(i.every) ? [i.every[0], i.every[1]] : [i.every, i.every];
|
|
398
|
+
else
|
|
399
|
+
throw new Error(
|
|
400
|
+
`density: intent is a word, a number of beats, or { every } (got ${JSON.stringify(i)})`,
|
|
401
|
+
);
|
|
402
|
+
if (!every.every((v) => v > 0))
|
|
403
|
+
throw new Error(`density: beats between cuts are above 0 (got ${every})`);
|
|
404
|
+
const place = (/** @type {number} */ t, /** @type {number} */ pace) => {
|
|
405
|
+
const step = pace < 1 ? "quarter" : "half";
|
|
406
|
+
const onGrid = g.snap(t, { to: step });
|
|
407
|
+
if (s.on !== "onset") return onGrid;
|
|
408
|
+
return g.snap(onGrid, { to: "onset", within: g.period / 4 });
|
|
409
|
+
};
|
|
410
|
+
if (s.start !== false) out.push(s.from);
|
|
411
|
+
if (!Number.isFinite(every[0]) && !Number.isFinite(every[1])) continue;
|
|
412
|
+
let b = g.beatOf(s.from);
|
|
413
|
+
const span = s.to - s.from;
|
|
414
|
+
for (let guard = 0; guard < 10000; guard++) {
|
|
415
|
+
const t0 = g.beat(b);
|
|
416
|
+
const u = Math.max(0, Math.min(1, (t0 - s.from) / span));
|
|
417
|
+
const [e0, e1] = every;
|
|
418
|
+
const pace =
|
|
419
|
+
Number.isFinite(e0) && Number.isFinite(e1) ? e0 * (e1 / e0) ** u : Math.min(e0, e1);
|
|
420
|
+
b += pace;
|
|
421
|
+
const t = place(g.beat(b), pace);
|
|
422
|
+
if (t >= s.to - 1e-6) break;
|
|
423
|
+
if (t > s.from + 1e-6) out.push(t);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
return [...new Set(out.map((t) => Math.round(t * 1e6) / 1e6))].sort((a, b) => a - b);
|
|
427
|
+
}
|