hyperframes 0.8.181 → 0.8.184
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/bin/hyperframes.mjs +3 -1
- package/dist/{add-AWQ2EGBU.js → add-5ZTD3MUZ.js} +22 -22
- package/dist/{animatedGifPrep-SENXJ7TN.js → animatedGifPrep-AGASIWVA.js} +14 -13
- package/dist/api.js +29 -28
- package/dist/{asset-XBH3MN3Y.js → asset-LSTEMPIB.js} +3 -3
- package/dist/{assetCataloger-KH4X2CRO.js → assetCataloger-BKBMNL3A.js} +16 -13
- package/dist/{audio-Q7I473UN.js → audio-KGK44XE4.js} +31 -30
- package/dist/{auth-I7CBTEUS.js → auth-MJWKYK77.js} +4 -4
- package/dist/{autoUpdate-KY5TLSN7.js → autoUpdate-2GGDKYR2.js} +2 -2
- package/dist/{backgroundChecks-4Q3VVK5W.js → backgroundChecks-7GRX5VQY.js} +3 -3
- package/dist/backgroundChecksWorker.js +3 -3
- package/dist/{batchRender-3AYDQRBI.js → batchRender-BCV2LELR.js} +7 -7
- package/dist/{beats-P4LENNVT.js → beats-7BCFRBAL.js} +12 -12
- package/dist/{benchmark-AXOAECN3.js → benchmark-2R6CN5MQ.js} +24 -24
- package/dist/{browser-XZKB5HGJ.js → browser-6AFGOI7G.js} +20 -20
- package/dist/{bundleWithLocalizedFonts-2WCR57IN.js → bundleWithLocalizedFonts-2EGPA5ZO.js} +2 -2
- package/dist/{capture-NWARHRHR.js → capture-HA2UHLIU.js} +8 -5
- package/dist/{capture-4RN4APDF.js → capture-HOIAW6MO.js} +50 -41
- package/dist/{captureCompositionFrame-QOF5BRF4.js → captureCompositionFrame-4236FVWJ.js} +22 -20
- package/dist/{captureTimeout-K2JNVVCI.js → captureTimeout-RIMG6IYH.js} +1 -1
- package/dist/{catalog-CRPOPVD5.js → catalog-A6CZAWW4.js} +42 -42
- package/dist/{catch-up-MHWGUQ42.js → catch-up-TNA4DJOA.js} +15 -15
- package/dist/check-5E5U2EQZ.js +117 -0
- package/dist/checkBrowser-FNINXBMZ.js +118 -0
- package/dist/{chunk-OJTDUF4W.js → chunk-2PVE4WS2.js} +1 -1
- package/dist/{checkBrowser-VES2NF3K.js → chunk-2ULXZ4PG.js} +187 -114
- package/dist/{chunk-WITHUCCB.js → chunk-2XA7KXQO.js} +2 -2
- package/dist/{chunk-HODBPO4A.js → chunk-3MDJIWOV.js} +626 -328
- package/dist/{chunk-JBCU6NR5.js → chunk-3QVMJ7GX.js} +56 -55
- package/dist/{chunk-OR5WCFWZ.js → chunk-3TXNNBI2.js} +2 -2
- package/dist/{chunk-IZM562YJ.js → chunk-4KKKBEP3.js} +4 -4
- package/dist/{chunk-XEWHUPFS.js → chunk-4N4P3ZWL.js} +2 -2
- package/dist/{chunk-537IYAEE.js → chunk-4UMPIPCQ.js} +9 -1
- package/dist/{chunk-J4L5TPLS.js → chunk-5UDRPPN2.js} +48 -6
- package/dist/{chunk-L3YOGIPG.js → chunk-66LREXGS.js} +1 -1
- package/dist/{chunk-6I7V6Q7F.js → chunk-74JMKLVU.js} +103 -20
- package/dist/{chunk-3PULCIY5.js → chunk-7HJALUIO.js} +5 -5
- package/dist/{chunk-GZVP4TWN.js → chunk-7JAD4MEW.js} +1 -1
- package/dist/{chunk-NAMGMP3R.js → chunk-7KVVNF7B.js} +1 -1
- package/dist/{chunk-TO6JNTML.js → chunk-7MB2ZAQF.js} +13 -8
- package/dist/{chunk-55IG255C.js → chunk-7NRI7HYX.js} +1 -1
- package/dist/{chunk-VAJIPSN6.js → chunk-ABZYYUUH.js} +1 -1
- package/dist/{chunk-GK2FIKIQ.js → chunk-ADDHW2FS.js} +214 -37
- package/dist/{chunk-ZUOSILUE.js → chunk-BCHSTE7U.js} +1 -1
- package/dist/{chunk-AOWDVB2T.js → chunk-CXABAXB3.js} +1 -1
- package/dist/{chunk-E24HSMZV.js → chunk-CYBXXSC4.js} +65 -14
- package/dist/{chunk-NZZYJOMJ.js → chunk-CZUAX3BV.js} +6 -5
- package/dist/{chunk-GV5R5B7Q.js → chunk-DGECWPTL.js} +1 -1
- package/dist/{chunk-BRHI7EIA.js → chunk-DKPNNYBZ.js} +4 -0
- package/dist/{chunk-UIDZRCBG.js → chunk-DWUGKEHR.js} +1 -1
- package/dist/{chunk-D3ZWBHZP.js → chunk-DYAPHNV6.js} +3 -2
- package/dist/{chunk-T7UHTUUE.js → chunk-E32ZQ2WO.js} +9 -9
- package/dist/{chunk-RGHQID2E.js → chunk-EHSBBBR2.js} +5 -3
- package/dist/{chunk-DJJ7SK4F.js → chunk-EM7C7H7S.js} +8 -8
- package/dist/{chunk-XSRUVMXK.js → chunk-ES426XRJ.js} +4 -4
- package/dist/chunk-FG4BBFZI.js +122 -0
- package/dist/{chunk-JMFJI26U.js → chunk-FGJEUV4S.js} +2 -2
- package/dist/{check-DJCUOUDI.js → chunk-GDEV42FA.js} +198 -142
- package/dist/{chunk-RXQHSGAQ.js → chunk-HR23IKLZ.js} +2 -2
- package/dist/{chunk-KMAAOHLO.js → chunk-HRPWRZGF.js} +1 -1
- package/dist/{chunk-UPFUC4DB.js → chunk-HTIUNMTP.js} +1 -1
- package/dist/{chunk-V2UNZ7QP.js → chunk-ICJEAFPD.js} +25 -14
- package/dist/{chunk-EOADENKV.js → chunk-IWTNTUPQ.js} +16 -14
- package/dist/chunk-IZCW2NKT.js +29 -0
- package/dist/{chunk-XFCLWWL3.js → chunk-J36JVBLR.js} +11 -4
- package/dist/{chunk-LBQFLUIY.js → chunk-J3QM7AHP.js} +9 -49
- package/dist/{chunk-DUN63LHY.js → chunk-JB6ARMQS.js} +2 -2
- package/dist/{chunk-5E5EYPZO.js → chunk-JIUTXKWA.js} +7 -7
- package/dist/{chunk-YJDB4FLT.js → chunk-JQYJXUJW.js} +1 -1
- package/dist/{chunk-PBN6GBJE.js → chunk-JVBRJMOP.js} +14 -1
- package/dist/{chunk-RHWJKSGH.js → chunk-KANNRHY7.js} +1 -1
- package/dist/{chunk-IL3GTCQY.js → chunk-KN46TGHV.js} +72 -140
- package/dist/{chunk-OFY6JTZC.js → chunk-LLC4CS6I.js} +2 -2
- package/dist/{chunk-OJDXABUF.js → chunk-LRGYPXHF.js} +2 -2
- package/dist/{chunk-GNE57O7U.js → chunk-MFAETWIF.js} +1 -1
- package/dist/{chunk-32GKETR7.js → chunk-MMQ52NIZ.js} +74 -0
- package/dist/chunk-MOEGCMKI.js +180 -0
- package/dist/{chunk-E6RPWJVC.js → chunk-NAUKCKCJ.js} +5 -1
- package/dist/{chunk-B4VT6YU2.js → chunk-OLZENUPI.js} +50 -7
- package/dist/{chunk-H4YZZ2VQ.js → chunk-PFD25NAC.js} +1 -1
- package/dist/{chunk-XH262OWN.js → chunk-PFYWVUHA.js} +1 -1
- package/dist/{chunk-S3RYRF3W.js → chunk-PSKEKWVU.js} +1 -1
- package/dist/{chunk-N5SXQCJL.js → chunk-Q33P4EAC.js} +3 -3
- package/dist/{chunk-3DKN5WKL.js → chunk-QH3T4WI2.js} +77 -6
- package/dist/{chunk-O5AE7HOP.js → chunk-QL2PNIXC.js} +37 -33
- package/dist/{chunk-WUUCEFL5.js → chunk-R2BFTECP.js} +5 -5
- package/dist/chunk-R2SQBPMH.js +3805 -0
- package/dist/{chunk-YPBIAONI.js → chunk-RGXVEYHI.js} +230 -162
- package/dist/{chunk-YMS6CJCD.js → chunk-SAX7HQ5E.js} +1 -1
- package/dist/{chunk-KIO3R4QN.js → chunk-SN7KI5JA.js} +27 -14
- package/dist/{chunk-4USWWI2Y.js → chunk-TE427YID.js} +2 -2
- package/dist/{chunk-ICMXC3MI.js → chunk-U6RXZNZE.js} +31 -18
- package/dist/{chunk-X7CCSMRR.js → chunk-UJKUB2LH.js} +16 -16
- package/dist/{chunk-K26FR4SM.js → chunk-UKOTVJFV.js} +12 -12
- package/dist/{chunk-4OT3FWVV.js → chunk-UNNXFKVG.js} +2 -2
- package/dist/{chunk-PF7OWVTL.js → chunk-VDM3FEDP.js} +2 -2
- package/dist/{chunk-Y5GY6Y7A.js → chunk-VNVQGDPC.js} +2 -2
- package/dist/{chunk-22QHO26F.js → chunk-W64L7IFS.js} +1 -1
- package/dist/{chunk-Y2RXRPL2.js → chunk-WHPN2TIT.js} +5 -5
- package/dist/{chunk-65WIUIHL.js → chunk-WTFUDNW2.js} +7 -15
- package/dist/{chunk-3XDOGSRD.js → chunk-X3CG5YQA.js} +3 -3
- package/dist/{chunk-UZOZ2W2E.js → chunk-XGHHVYC7.js} +96 -34
- package/dist/{chunk-4IEH6EAC.js → chunk-YALM6XN4.js} +203 -58
- package/dist/{chunk-B6JLCPT3.js → chunk-YOZPQCSR.js} +6 -6
- package/dist/{chunk-5JMZLQT6.js → chunk-YWHCXIMD.js} +16 -16
- package/dist/{chunk-UVEQLDKB.js → chunk-YWNJTZGN.js} +3 -2
- package/dist/{chunk-WUQUR33W.js → chunk-ZOCHDXDG.js} +1 -1
- package/dist/{chunk-IWTRHPTP.js → chunk-ZRHO6YMM.js} +8 -8
- package/dist/{clean-GJNDVVDI.js → clean-HGASSMWI.js} +41 -40
- package/dist/cli.js +68 -64
- package/dist/{cloud-JCWNMKXC.js → cloud-JPDVNXHN.js} +4 -4
- package/dist/{cloudrun-2BKGY53X.js → cloudrun-AMMGSDRP.js} +8 -8
- package/dist/commands/layout-audit.browser.js +15 -4
- package/dist/commands/motion-signature.browser.js +52 -0
- package/dist/{compare-XWM7FAYM.js → compare-LHHVHUN3.js} +51 -47
- package/dist/{compiler-U3W6CJW7.js → compiler-Q3N6QXMT.js} +6 -6
- package/dist/{component-CBRAE325.js → component-D72J32Q7.js} +4 -4
- package/dist/{compositions-EZYJEHQ3.js → compositions-UQRJ5ROG.js} +29 -29
- package/dist/{contactSheet-27SRU7A4.js → contactSheet-CAGMKI3E.js} +3 -1
- package/dist/{delete-JWWMOITI.js → delete-P42VIDDA.js} +9 -9
- package/dist/{deploy-UGOV76OH.js → deploy-WZTH57O4.js} +11 -11
- package/dist/{destroy-QBLMYDBF.js → destroy-4B5HW5FH.js} +5 -5
- package/dist/{deterministicFonts-L7YEEFGI.js → deterministicFonts-VQ5UBMXY.js} +2 -2
- package/dist/{dist-VO7OXOFK.js → dist-DYS24AMA.js} +5 -5
- package/dist/{dist-2FMTAVGL.js → dist-SENYPQGW.js} +4 -4
- package/dist/{docs-MPOM3PHH.js → docs-UEWLIP6D.js} +1 -1
- package/dist/{doctor-XSKSZRR7.js → doctor-KEJIG2SK.js} +28 -27
- package/dist/{events-RGS4MAH4.js → events-CYKSNR7N.js} +6 -6
- package/dist/{events-AIZODZMP.js → events-UZXFQPMT.js} +9 -9
- package/dist/{feedback-GE3VDZOH.js → feedback-LXNQF7CA.js} +35 -35
- package/dist/{ffmpeg-SCXZTR6X.js → ffmpeg-BYHON577.js} +16 -15
- package/dist/{figma-3R4XST4Y.js → figma-EIQ35PS6.js} +3 -3
- package/dist/fontLocalizeCli.js +24 -23
- package/dist/{get-4FKJP6IM.js → get-CC2YL7QO.js} +9 -9
- package/dist/{gpuPolicy-4NNXESM7.js → gpuPolicy-VFSACUQV.js} +14 -13
- package/dist/{grade-compare-FAYVPXUR.js → grade-compare-TUQL7IV2.js} +56 -50
- package/dist/{help-C3UQMYXK.js → help-ROROO5K6.js} +1 -1
- package/dist/{history-LDGQ2IZJ.js → history-PNELYLXX.js} +15 -15
- package/dist/hyperframe.manifest.json +1 -1
- package/dist/hyperframe.runtime.iife.js +59 -59
- package/dist/hyperframes-player.global.js +8 -3
- package/dist/{info-KMXFLD3Q.js → info-4FZTH6AS.js} +20 -20
- package/dist/{init-D7GYHSX5.js → init-I43GHHVP.js} +69 -68
- package/dist/{inspect-CUKWHCGS.js → inspect-IT4TYIZ3.js} +46 -44
- package/dist/{installer-EPRSH6QI.js → installer-CWOJVK5K.js} +7 -7
- package/dist/{keyframes-XCUPHBW3.js → keyframes-3FBOGVD4.js} +16 -16
- package/dist/{lambda-IMORFJHN.js → lambda-H3V32I7M.js} +15 -15
- package/dist/{layout-JD2IOBMS.js → layout-BZ5LYJ5C.js} +46 -44
- package/dist/{lint-FHLER36Y.js → lint-ZTNSGP2S.js} +23 -23
- package/dist/{lintProject-ARKJXDQF.js → lintProject-C2ONSH2U.js} +4 -4
- package/dist/{list-MGCFG5MA.js → list-XM4GWJYY.js} +10 -10
- package/dist/{login-QX6M4UTR.js → login-H6HYKMWX.js} +7 -7
- package/dist/{logout-DKJANASY.js → logout-DDC4QLVK.js} +3 -3
- package/dist/{manager-IETAVBZS.js → manager-TWVDSJXO.js} +17 -16
- package/dist/{manager-V2QCCPOJ.js → manager-UHWEKPXC.js} +8 -3
- package/dist/{media-treatment-MDAQRITV.js → media-treatment-N7MY5NXB.js} +34 -33
- package/dist/{media-use-4XXGABIL.js → media-use-JBN57JE3.js} +1 -1
- package/dist/{models-NZAOSI5A.js → models-WEMIMYBD.js} +25 -24
- package/dist/{motionShot-6ZDUM2K4.js → motionShot-RHICTVPU.js} +29 -26
- package/dist/{normalize-audio-7PRYX6QM.js → normalize-audio-ZFUZCJE3.js} +12 -12
- package/dist/{open-I254NY5J.js → open-IBJ4FL3G.js} +24 -24
- package/dist/{parakeetRunner-TL3TOGUS.js → parakeetRunner-XXO4WSLR.js} +26 -25
- package/dist/{pipeline-YPERVOQM.js → pipeline-6ML3LUVK.js} +19 -18
- package/dist/{play-MYI7BYKS.js → play-RV4NAVF5.js} +40 -38
- package/dist/{policies-5NTZOHJA.js → policies-XXNGXWHV.js} +1 -1
- package/dist/{preflight-HRCSZ52D.js → preflight-R3DEFMLA.js} +19 -18
- package/dist/{present-WYXQDV4Q.js → present-5TBJGE6B.js} +34 -33
- package/dist/{preview-535HTWQO.js → preview-FLKZ5CXJ.js} +56 -55
- package/dist/{producer-C76CRJ5O.js → producer-7XYSPVKH.js} +1 -1
- package/dist/{progress-I37JB7R4.js → progress-NHJIHAAG.js} +2 -2
- package/dist/{projectConfig-5QCNTGQT.js → projectConfig-TBU2VWZX.js} +9 -9
- package/dist/{publication-2QT7VVE2.js → publication-CWWUJYJ5.js} +5 -5
- package/dist/{publish-53EBL7OO.js → publish-FSNE4FEB.js} +28 -27
- package/dist/{refresh-MGCVWX56.js → refresh-RXTOPRBB.js} +3 -3
- package/dist/{remove-background-OBYHMPD4.js → remove-background-MDFWRWCT.js} +32 -31
- package/dist/render-DBGQZAZT.js +1516 -0
- package/dist/{render-3MELF6Y3.js → render-F4JQ553X.js} +102 -96
- package/dist/{render-75CRB3BW.js → render-LWZKXCLY.js} +8 -8
- package/dist/{render-batch-CEVWUYBP.js → render-batch-PU7NMLIJ.js} +8 -8
- package/dist/renderSetupWorker.js +12 -9
- package/dist/{resolver-4ICE2AT6.js → resolver-RUBGFXPC.js} +7 -7
- package/dist/{screenshotCapture-HXEZ3TNJ.js → screenshotCapture-UBY6TT75.js} +33 -6
- package/dist/{sherpa-L4UACXT3.js → sherpa-X2TBNO6P.js} +25 -24
- package/dist/{sites-3ZBYB5X4.js → sites-MAVH57MO.js} +2 -2
- package/dist/skills/hyperframes/references/review-loop.md +1 -1
- package/dist/{skills-DXTQPCAO.js → skills-WHKMWO2D.js} +17 -17
- package/dist/{skillsUpdateCheck-ULXRGLDU.js → skillsUpdateCheck-XQGZGJJG.js} +3 -3
- package/dist/{snapshot-PWFHQU5E.js → snapshot-M4NUUSNU.js} +73 -71
- package/dist/{src-RDSWHMJS.js → src-4UYM2K3S.js} +34 -26
- package/dist/{src-S7NVL5VF.js → src-6MSC62U2.js} +23 -19
- package/dist/{state-KAXGHF77.js → state-ORRPOLMQ.js} +2 -2
- package/dist/{staticProjectServer-GYPUQGI7.js → staticProjectServer-ERDTFP45.js} +21 -20
- package/dist/{status-BV7QAUQD.js → status-CM7IQTU2.js} +6 -6
- package/dist/studio/assets/{hyperframes-player-DcD3NXpX.js → hyperframes-player-DEncBxR7.js} +7 -2
- package/dist/studio/assets/{index-CFrZAwKo.js → index-BABXr78Q.js} +4 -4
- package/dist/studio/assets/{index-BIDKYk0h.js → index-Cc22mgvY.js} +1 -1
- package/dist/studio/index.html +1 -1
- package/dist/{studio-api-IXGX5ZFI.js → studio-api-SAKD3VKC.js} +18 -17
- package/dist/{studioServer-LA5Z7RSS.js → studioServer-IRI7EVOM.js} +91 -84
- package/dist/{telemetry-STEMAMAX.js → telemetry-F4XADVAF.js} +10 -10
- package/dist/{telemetry-CQYHCCPL.js → telemetry-QG5AANZ4.js} +1 -1
- package/dist/{timeline-KLD24EN6.js → timeline-5I444RRE.js} +42 -41
- package/dist/{tokens-ICLORAA4.js → tokens-LRRYM35A.js} +3 -3
- package/dist/{transcribe-A6IKK7VS.js → transcribe-44XDFNVU.js} +48 -47
- package/dist/{transcribe-CTHZLRXF.js → transcribe-WHYHWAB2.js} +20 -19
- package/dist/{tts-EDK3QS7M.js → tts-A2WILYGN.js} +6 -6
- package/dist/{updateCheck-FHCAAAXA.js → updateCheck-7CPH3CAZ.js} +2 -2
- package/dist/{upgrade-7EV4F2R7.js → upgrade-WW4GQ2RI.js} +3 -3
- package/dist/{urlDownloader-MIMGVASJ.js → urlDownloader-OHLLP45A.js} +13 -12
- package/dist/{validate-LZF46W3V.js → validate-VNCDH2LW.js} +40 -38
- package/dist/{video-ZC47NFOL.js → video-5OHTLL2D.js} +17 -14
- package/dist/warmCheck.js +228 -0
- package/dist/warmCheckClient.js +139 -0
- package/package.json +4 -2
- package/dist/chunk-BAZ5LCR3.js +0 -3805
- package/dist/hyperframe-runtime.js +0 -1125
- package/dist/render-5BXTEEG7.js +0 -719
- package/dist/{synthesize-I2C24XJ5.js → synthesize-PKTB5ATG.js} +1 -1
|
@@ -5,12 +5,9 @@ var require = __hf_createRequire(import.meta.url);
|
|
|
5
5
|
var __filename = __hf_fileURLToPath(import.meta.url);
|
|
6
6
|
var __dirname = __hf_dirname(__filename);
|
|
7
7
|
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
getSystemTotalMb,
|
|
12
|
-
isLowMemorySystem
|
|
13
|
-
} from "./chunk-W2LGJSEN.js";
|
|
8
|
+
alphaDecoderFor,
|
|
9
|
+
videoStreamHasAlpha
|
|
10
|
+
} from "./chunk-IZCW2NKT.js";
|
|
14
11
|
import {
|
|
15
12
|
DISTRIBUTED_FPS,
|
|
16
13
|
MEDIA_VISUAL_STYLE_PROPERTIES,
|
|
@@ -29,13 +26,14 @@ import {
|
|
|
29
26
|
renderFrameIdForRenderId,
|
|
30
27
|
resolveAuthoredTimingWindow,
|
|
31
28
|
toFps
|
|
32
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-J3QM7AHP.js";
|
|
33
30
|
import {
|
|
34
31
|
AUDIO_GROUP_RENDER_ID_ATTR,
|
|
35
32
|
COLOR_GRADING_SOURCE_HIDDEN_ATTR,
|
|
36
33
|
COMPOSITION_SOURCE_URL,
|
|
37
34
|
HF_AUDIO_AUTOMATION_ATTR,
|
|
38
35
|
HF_AUDIO_FX_ATTR,
|
|
36
|
+
HF_COLOR_GRADING_ATTR,
|
|
39
37
|
HF_COLOR_GRADING_CANVAS_ID_PREFIX,
|
|
40
38
|
MEDIA_DURATION_CLAMP_EPSILON_SECONDS,
|
|
41
39
|
MEDIA_RENDER_ID_ATTR,
|
|
@@ -58,7 +56,7 @@ import {
|
|
|
58
56
|
shiftRateLane,
|
|
59
57
|
sourceTimeAt,
|
|
60
58
|
timeAtSourceTime
|
|
61
|
-
} from "./chunk-
|
|
59
|
+
} from "./chunk-R2SQBPMH.js";
|
|
62
60
|
import {
|
|
63
61
|
clampAudioGain,
|
|
64
62
|
isAudibleVideoElement
|
|
@@ -68,31 +66,38 @@ import {
|
|
|
68
66
|
redactUrlQueryStrings
|
|
69
67
|
} from "./chunk-634HSJ3J.js";
|
|
70
68
|
import {
|
|
69
|
+
browserPathFromEnv,
|
|
71
70
|
chromeMajorCeiling,
|
|
72
71
|
compareBrowserVersionsDescending,
|
|
73
72
|
exceedsChromeCeiling,
|
|
74
73
|
isManagedChromeDir,
|
|
75
74
|
pickSharedShell
|
|
76
|
-
} from "./chunk-
|
|
75
|
+
} from "./chunk-4UMPIPCQ.js";
|
|
77
76
|
import {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
} from "./chunk-6BNTGNGD.js";
|
|
77
|
+
resolveReferencedStart
|
|
78
|
+
} from "./chunk-ADDHW2FS.js";
|
|
81
79
|
import {
|
|
82
80
|
FFMPEG_PATH_ENV,
|
|
83
81
|
FFPROBE_PATH_ENV,
|
|
84
82
|
findFfBinary
|
|
85
83
|
} from "./chunk-VAS6HQX3.js";
|
|
86
84
|
import {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
} from "./chunk-
|
|
85
|
+
isWithinProjectRoot,
|
|
86
|
+
resolveProjectRelativeSrc
|
|
87
|
+
} from "./chunk-6BNTGNGD.js";
|
|
90
88
|
import {
|
|
91
89
|
isPathInside
|
|
92
90
|
} from "./chunk-BSQ7XANM.js";
|
|
93
91
|
import {
|
|
94
92
|
parseHTML
|
|
95
93
|
} from "./chunk-SDYDNHEE.js";
|
|
94
|
+
import {
|
|
95
|
+
LOW_MEMORY_TOTAL_MB_THRESHOLD,
|
|
96
|
+
describeWslGpuAccess,
|
|
97
|
+
detectWsl,
|
|
98
|
+
getSystemTotalMb,
|
|
99
|
+
isLowMemorySystem
|
|
100
|
+
} from "./chunk-W2LGJSEN.js";
|
|
96
101
|
|
|
97
102
|
// ../engine/src/config.ts
|
|
98
103
|
import { tmpdir } from "os";
|
|
@@ -421,7 +426,6 @@ function resolveConfig(overrides) {
|
|
|
421
426
|
"PRODUCER_LARGE_RENDER_THRESHOLD",
|
|
422
427
|
DEFAULT_CONFIG.largeRenderThreshold
|
|
423
428
|
),
|
|
424
|
-
chromePath: env("PRODUCER_HEADLESS_SHELL_PATH"),
|
|
425
429
|
disableGpu: envBool("PRODUCER_DISABLE_GPU", DEFAULT_CONFIG.disableGpu),
|
|
426
430
|
browserGpuMode: envBrowserGpuMode(),
|
|
427
431
|
allowSoftwareWebGpu: envBool(
|
|
@@ -1013,23 +1017,14 @@ function resolveHeadlessShellPath(config) {
|
|
|
1013
1017
|
if (config?.chromePath) {
|
|
1014
1018
|
return config.chromePath;
|
|
1015
1019
|
}
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
if (!existsSync(
|
|
1020
|
+
const fromEnv = browserPathFromEnv();
|
|
1021
|
+
if (fromEnv) {
|
|
1022
|
+
if (!existsSync(fromEnv.path)) {
|
|
1019
1023
|
throw new Error(
|
|
1020
|
-
`[BrowserManager] Chrome binary not found at
|
|
1024
|
+
`[BrowserManager] Chrome binary not found at ${fromEnv.name}="${fromEnv.path}". Run \`hyperframes browser ensure\` to re-download.`
|
|
1021
1025
|
);
|
|
1022
1026
|
}
|
|
1023
|
-
return
|
|
1024
|
-
}
|
|
1025
|
-
if (process.env.HYPERFRAMES_BROWSER_PATH) {
|
|
1026
|
-
const envPath = process.env.HYPERFRAMES_BROWSER_PATH;
|
|
1027
|
-
if (!existsSync(envPath)) {
|
|
1028
|
-
throw new Error(
|
|
1029
|
-
`[BrowserManager] Chrome binary not found at HYPERFRAMES_BROWSER_PATH="${envPath}". Run \`hyperframes browser ensure\` to re-download.`
|
|
1030
|
-
);
|
|
1031
|
-
}
|
|
1032
|
-
return envPath;
|
|
1027
|
+
return fromEnv.path;
|
|
1033
1028
|
}
|
|
1034
1029
|
const ours = join2(homedir(), ".cache", "hyperframes", "chrome", "chrome-headless-shell");
|
|
1035
1030
|
const shared = join2(homedir(), ".cache", "puppeteer", "chrome-headless-shell");
|
|
@@ -1689,9 +1684,6 @@ identically under Docker. Consider:
|
|
|
1689
1684
|
}
|
|
1690
1685
|
|
|
1691
1686
|
// ../engine/src/services/frameCapture.ts
|
|
1692
|
-
import {
|
|
1693
|
-
CDPSession
|
|
1694
|
-
} from "puppeteer-core";
|
|
1695
1687
|
import { existsSync as existsSync3, mkdirSync, writeFileSync } from "fs";
|
|
1696
1688
|
import { join as join3 } from "path";
|
|
1697
1689
|
|
|
@@ -5413,6 +5405,7 @@ async function constructCaptureSession(input) {
|
|
|
5413
5405
|
const page = await browser.newPage();
|
|
5414
5406
|
onPageCreated(page);
|
|
5415
5407
|
const frame = page.mainFrame();
|
|
5408
|
+
const { CDPSession } = await import("puppeteer-core");
|
|
5416
5409
|
if ("client" in frame && frame.client instanceof CDPSession) {
|
|
5417
5410
|
await frame.client.send("Network.enable", {
|
|
5418
5411
|
maxTotalBufferSize: 32 * 1024 * 1024,
|
|
@@ -5772,6 +5765,22 @@ async function pollImagesReady(page, timeoutMs, intervalMs = 100) {
|
|
|
5772
5765
|
}
|
|
5773
5766
|
return check();
|
|
5774
5767
|
}
|
|
5768
|
+
async function waitForImagesReady(page, timeoutMs, onUnloaded) {
|
|
5769
|
+
const ready = await pollImagesReady(page, timeoutMs);
|
|
5770
|
+
if (!ready) {
|
|
5771
|
+
onUnloaded(
|
|
5772
|
+
await page.evaluate(
|
|
5773
|
+
() => Array.from(document.querySelectorAll("img")).filter((img) => {
|
|
5774
|
+
const src = img.getAttribute("src") || "";
|
|
5775
|
+
if (!src || src.startsWith("data:")) return false;
|
|
5776
|
+
return !(img.complete && img.naturalWidth > 0);
|
|
5777
|
+
}).map((img) => img.src || img.getAttribute("src") || "(no src)").join(", ")
|
|
5778
|
+
)
|
|
5779
|
+
);
|
|
5780
|
+
}
|
|
5781
|
+
await decodeAllImages(page);
|
|
5782
|
+
return ready;
|
|
5783
|
+
}
|
|
5775
5784
|
async function collectMediaReadinessWarnings(page, skipIds, timeoutMs) {
|
|
5776
5785
|
const snapshot = await page.evaluate((skipIdList) => {
|
|
5777
5786
|
const skipped = new Set(skipIdList);
|
|
@@ -6099,23 +6108,13 @@ async function initializeSession(session) {
|
|
|
6099
6108
|
const skipVideoIds = session.options.skipReadinessVideoIds ?? [];
|
|
6100
6109
|
const [videosReady] = await Promise.all([
|
|
6101
6110
|
pollVideosReady(page, skipVideoIds, pageReadyTimeout),
|
|
6102
|
-
|
|
6103
|
-
|
|
6104
|
-
|
|
6105
|
-
|
|
6106
|
-
|
|
6107
|
-
|
|
6108
|
-
|
|
6109
|
-
return !(ie.complete && ie.naturalWidth > 0);
|
|
6110
|
-
}).map((img) => img.src || img.getAttribute("src") || "(no src)").join(", ");
|
|
6111
|
-
});
|
|
6112
|
-
console.warn(
|
|
6113
|
-
`[FrameCapture] Some image elements did not load within ${pageReadyTimeout}ms: ${failedImages}. Continuing render. Affected images may appear blank/missing in early frames.`
|
|
6114
|
-
);
|
|
6115
|
-
}
|
|
6116
|
-
await decodeAllImages(page);
|
|
6117
|
-
return ready;
|
|
6118
|
-
}),
|
|
6111
|
+
waitForImagesReady(
|
|
6112
|
+
page,
|
|
6113
|
+
pageReadyTimeout,
|
|
6114
|
+
(failedImages) => console.warn(
|
|
6115
|
+
`[FrameCapture] Some image elements did not load within ${pageReadyTimeout}ms: ${failedImages}. Continuing render. Affected images may appear blank/missing in early frames.`
|
|
6116
|
+
)
|
|
6117
|
+
),
|
|
6119
6118
|
page.evaluate(`document.fonts?.ready`),
|
|
6120
6119
|
waitForOptionalTailwindReady(page, pageReadyTimeout)
|
|
6121
6120
|
]);
|
|
@@ -6205,23 +6204,13 @@ async function initializeSession(session) {
|
|
|
6205
6204
|
const bfSkipVideoIds = session.options.skipReadinessVideoIds ?? [];
|
|
6206
6205
|
const [bfVideosReady] = await Promise.all([
|
|
6207
6206
|
pollVideosReady(page, bfSkipVideoIds, pageReadyTimeout),
|
|
6208
|
-
|
|
6209
|
-
|
|
6210
|
-
|
|
6211
|
-
|
|
6212
|
-
|
|
6213
|
-
|
|
6214
|
-
|
|
6215
|
-
return !(ie.complete && ie.naturalWidth > 0);
|
|
6216
|
-
}).map((img) => img.src || img.getAttribute("src") || "(no src)").join(", ");
|
|
6217
|
-
});
|
|
6218
|
-
console.warn(
|
|
6219
|
-
`[FrameCapture] Some image elements did not load within ${pageReadyTimeout}ms: ${failedImages}. Continuing render. Affected images may appear blank/missing in early frames.`
|
|
6220
|
-
);
|
|
6221
|
-
}
|
|
6222
|
-
await decodeAllImages(page);
|
|
6223
|
-
return ready;
|
|
6224
|
-
}),
|
|
6207
|
+
waitForImagesReady(
|
|
6208
|
+
page,
|
|
6209
|
+
pageReadyTimeout,
|
|
6210
|
+
(failedImages) => console.warn(
|
|
6211
|
+
`[FrameCapture] Some image elements did not load within ${pageReadyTimeout}ms: ${failedImages}. Continuing render. Affected images may appear blank/missing in early frames.`
|
|
6212
|
+
)
|
|
6213
|
+
),
|
|
6225
6214
|
page.evaluate(`document.fonts?.ready`),
|
|
6226
6215
|
waitForOptionalTailwindReady(page, pageReadyTimeout)
|
|
6227
6216
|
]);
|
|
@@ -8524,9 +8513,6 @@ function extractPngMetadataFromBuffer(buf) {
|
|
|
8524
8513
|
}
|
|
8525
8514
|
return width > 0 && height > 0 ? { width, height, colorSpace: colorSpaceFromCicp } : null;
|
|
8526
8515
|
}
|
|
8527
|
-
function pixelFormatHasAlpha(pixelFormat) {
|
|
8528
|
-
return /^(?:yuva|rgba|argb|bgra|abgr|gbrap|ya|ayuv)/i.test(pixelFormat);
|
|
8529
|
-
}
|
|
8530
8516
|
function extractStillImageMetadata(filePath) {
|
|
8531
8517
|
try {
|
|
8532
8518
|
return extractPngMetadataFromBuffer(readFileSync(filePath));
|
|
@@ -8611,8 +8597,7 @@ async function extractMediaMetadata(filePath) {
|
|
|
8611
8597
|
};
|
|
8612
8598
|
const colorSpace = merged.colorTransfer || merged.colorPrimaries || merged.colorSpace ? merged : null;
|
|
8613
8599
|
const pixelFormat = videoStream.pix_fmt || "";
|
|
8614
|
-
const
|
|
8615
|
-
const hasAlpha = pixelFormatHasAlpha(pixelFormat) || alphaMode === "1";
|
|
8600
|
+
const hasAlpha = videoStreamHasAlpha(videoStream);
|
|
8616
8601
|
const containerDuration = output?.format.duration ? parseFloat(output.format.duration) : 0;
|
|
8617
8602
|
const streamDuration = videoStream.duration ? parseFloat(videoStream.duration) : 0;
|
|
8618
8603
|
const parsedStreamStart = videoStream.start_time ? parseFloat(videoStream.start_time) : 0;
|
|
@@ -9054,7 +9039,7 @@ function buildEncoderArgs(options, inputArgs, outputPath, gpuEncoder = null) {
|
|
|
9054
9039
|
);
|
|
9055
9040
|
options = { ...options, hdr: void 0 };
|
|
9056
9041
|
}
|
|
9057
|
-
const args = [...inputArgs, "-r", fpsToFfmpegArg(fps)];
|
|
9042
|
+
const args = ["-xerror", ...inputArgs, "-r", fpsToFfmpegArg(fps)];
|
|
9058
9043
|
const shouldUseGpu = useGpu && gpuEncoder !== null;
|
|
9059
9044
|
if (codec === "h264" || codec === "h265") {
|
|
9060
9045
|
if (shouldUseGpu) {
|
|
@@ -9207,6 +9192,18 @@ function buildEncoderArgs(options, inputArgs, outputPath, gpuEncoder = null) {
|
|
|
9207
9192
|
return args;
|
|
9208
9193
|
}
|
|
9209
9194
|
var framesReader = (onFrames) => onFrames && ffmpegStatsReader(({ frames }) => frames !== void 0 && onFrames(frames));
|
|
9195
|
+
function frameReadFailure(stderr, framePattern, startNumber, framesRead, frameCount) {
|
|
9196
|
+
const lines = stderr.match(/^.*(?:Error during demuxing|Could not open file).*$/gm) ?? [];
|
|
9197
|
+
const readError = [...new Set(lines.map((line) => line.trim()))].join("; ");
|
|
9198
|
+
if (!readError) return "";
|
|
9199
|
+
const name = framePattern.replace(
|
|
9200
|
+
/%0(\d+)d/,
|
|
9201
|
+
(_, width) => String(startNumber + framesRead).padStart(Number(width), "0")
|
|
9202
|
+
);
|
|
9203
|
+
const at = framesRead < frameCount ? ` at ${name} (${framesRead} of ${frameCount} read)` : "";
|
|
9204
|
+
return `[FFmpeg] could not read a frame${at}: ${readError}
|
|
9205
|
+
`;
|
|
9206
|
+
}
|
|
9210
9207
|
var secondsReader = (onSeconds) => onSeconds && ffmpegStatsReader(({ seconds }) => seconds !== void 0 && onSeconds(seconds));
|
|
9211
9208
|
async function encodeFramesFromDir(framesDir, framePattern, outputPath, options, signal, config, onFramesEncoded) {
|
|
9212
9209
|
const startTime = Date.now();
|
|
@@ -9232,10 +9229,14 @@ async function encodeFramesFromDir(framesDir, framePattern, outputPath, options,
|
|
|
9232
9229
|
const inputArgs = ["-framerate", fpsToFfmpegArg(options.fps), "-i", inputPath];
|
|
9233
9230
|
const args = buildEncoderArgs(options, inputArgs, outputPath, gpuEncoder);
|
|
9234
9231
|
const encodeTimeout = config?.ffmpegEncodeTimeout ?? DEFAULT_CONFIG.ffmpegEncodeTimeout;
|
|
9232
|
+
let framesRead = 0;
|
|
9235
9233
|
const result = await runFfmpeg(args, {
|
|
9236
9234
|
signal,
|
|
9237
9235
|
timeout: encodeTimeout,
|
|
9238
|
-
onStderr: framesReader(
|
|
9236
|
+
onStderr: framesReader((frames) => {
|
|
9237
|
+
framesRead = frames;
|
|
9238
|
+
onFramesEncoded?.(frames);
|
|
9239
|
+
})
|
|
9239
9240
|
});
|
|
9240
9241
|
if (result.terminationReason === "abort") {
|
|
9241
9242
|
return {
|
|
@@ -9255,7 +9256,7 @@ async function encodeFramesFromDir(framesDir, framePattern, outputPath, options,
|
|
|
9255
9256
|
framesEncoded: 0,
|
|
9256
9257
|
fileSize: 0,
|
|
9257
9258
|
error: appendEncodeTimeoutMessage(
|
|
9258
|
-
formatFfmpegError(result.exitCode, result.stderr),
|
|
9259
|
+
frameReadFailure(result.stderr, framePattern, 0, framesRead, frameCount) + formatFfmpegError(result.exitCode, result.stderr),
|
|
9259
9260
|
result.terminationReason === "deadline",
|
|
9260
9261
|
encodeTimeout
|
|
9261
9262
|
),
|
|
@@ -9356,17 +9357,25 @@ async function encodeFramesChunkedConcat(framesDir, framePattern, outputPath, op
|
|
|
9356
9357
|
if (options.useGpu) gpuEncoder = await getCachedGpuEncoder();
|
|
9357
9358
|
const args = buildEncoderArgs(options, inputArgs, chunkPath, gpuEncoder);
|
|
9358
9359
|
const encodeTimeout = config?.ffmpegEncodeTimeout ?? DEFAULT_CONFIG.ffmpegEncodeTimeout;
|
|
9360
|
+
let framesRead = 0;
|
|
9359
9361
|
const processResult = await runFfmpeg(args, {
|
|
9360
9362
|
signal,
|
|
9361
9363
|
timeout: encodeTimeout,
|
|
9362
|
-
onStderr: framesReader(
|
|
9363
|
-
|
|
9364
|
-
|
|
9364
|
+
onStderr: framesReader((frames) => {
|
|
9365
|
+
framesRead = frames;
|
|
9366
|
+
onFramesEncoded?.(startNumber + frames);
|
|
9367
|
+
})
|
|
9365
9368
|
});
|
|
9366
9369
|
const chunkResult = {
|
|
9367
9370
|
success: processResult.success,
|
|
9368
9371
|
error: processResult.success ? void 0 : appendEncodeTimeoutMessage(
|
|
9369
|
-
|
|
9372
|
+
frameReadFailure(
|
|
9373
|
+
processResult.stderr,
|
|
9374
|
+
framePattern,
|
|
9375
|
+
startNumber,
|
|
9376
|
+
framesRead,
|
|
9377
|
+
framesInChunk
|
|
9378
|
+
) + `Chunk ${i} encode failed: ${processResult.stderr.slice(-400)}`,
|
|
9370
9379
|
processResult.terminationReason === "deadline",
|
|
9371
9380
|
encodeTimeout
|
|
9372
9381
|
)
|
|
@@ -10131,52 +10140,6 @@ function createConcurrencyLimit(limit) {
|
|
|
10131
10140
|
};
|
|
10132
10141
|
}
|
|
10133
10142
|
|
|
10134
|
-
// ../engine/src/services/referenceResolver.ts
|
|
10135
|
-
function findReferenceTargetEl(doc, refId) {
|
|
10136
|
-
return doc.getElementById(refId) ?? doc.querySelector(`[data-composition-id="${refId}"]`);
|
|
10137
|
-
}
|
|
10138
|
-
function resolveReferencedStart(doc, el, startCache, visiting) {
|
|
10139
|
-
const cached = startCache.get(el);
|
|
10140
|
-
if (cached !== void 0) return cached;
|
|
10141
|
-
if (visiting.has(el)) return 0;
|
|
10142
|
-
visiting.add(el);
|
|
10143
|
-
try {
|
|
10144
|
-
const expression = parseStartExpression(el.getAttribute("data-start"));
|
|
10145
|
-
if (!expression) {
|
|
10146
|
-
startCache.set(el, 0);
|
|
10147
|
-
return 0;
|
|
10148
|
-
}
|
|
10149
|
-
if (expression.kind === "absolute") {
|
|
10150
|
-
const value = Math.max(0, expression.value);
|
|
10151
|
-
startCache.set(el, value);
|
|
10152
|
-
return value;
|
|
10153
|
-
}
|
|
10154
|
-
const target = findReferenceTargetEl(doc, expression.refId);
|
|
10155
|
-
if (!target) {
|
|
10156
|
-
startCache.set(el, 0);
|
|
10157
|
-
return 0;
|
|
10158
|
-
}
|
|
10159
|
-
const targetStart = resolveReferencedStart(doc, target, startCache, visiting);
|
|
10160
|
-
const targetDuration = resolveReferencedDuration(doc, target, startCache, visiting);
|
|
10161
|
-
const resolved = targetDuration != null && targetDuration > 0 ? Math.max(0, targetStart + targetDuration + expression.offset) : Math.max(0, targetStart + expression.offset);
|
|
10162
|
-
startCache.set(el, resolved);
|
|
10163
|
-
return resolved;
|
|
10164
|
-
} finally {
|
|
10165
|
-
visiting.delete(el);
|
|
10166
|
-
}
|
|
10167
|
-
}
|
|
10168
|
-
function resolveReferencedDuration(doc, el, startCache, visiting) {
|
|
10169
|
-
const durationAttr = parseNumeric(el.getAttribute("data-duration"));
|
|
10170
|
-
if (durationAttr != null && durationAttr > 0) return durationAttr;
|
|
10171
|
-
const endAttr = parseNumeric(el.getAttribute("data-end"));
|
|
10172
|
-
if (endAttr != null) {
|
|
10173
|
-
const start = resolveReferencedStart(doc, el, startCache, visiting);
|
|
10174
|
-
const delta = endAttr - start;
|
|
10175
|
-
if (Number.isFinite(delta) && delta > 0) return delta;
|
|
10176
|
-
}
|
|
10177
|
-
return null;
|
|
10178
|
-
}
|
|
10179
|
-
|
|
10180
10143
|
// ../engine/src/services/mediaTimelineWindow.ts
|
|
10181
10144
|
function isKnownInactiveTimelineWindow(element, resolvedStart) {
|
|
10182
10145
|
const duration = parseStrictFiniteTimingNumber(element.getAttribute("data-duration"));
|
|
@@ -11611,6 +11574,12 @@ var SDR_TO_HDR_COLORSPACE_FILTER = "colorspace=all=bt2020:iall=bt709:range=tv";
|
|
|
11611
11574
|
var HDR_TO_SDR_ZSCALE_TRANSFORM_KEY = "hdr2sdr-hable-srgb";
|
|
11612
11575
|
var HDR_TO_SDR_VIDEOTOOLBOX_TRANSFORM_KEY = "hdr2sdr-videotoolbox-hdr";
|
|
11613
11576
|
var SDR_CANVAS_PASSTHROUGH_FILTER = "setparams=color_primaries=bt709:color_trc=iec61966-2-1";
|
|
11577
|
+
function halveToCoverScaleFilter(box) {
|
|
11578
|
+
const fit = `max(${Math.ceil(box.width)}/iw\\,${Math.ceil(box.height)}/ih)`;
|
|
11579
|
+
const halvings = `floor(log(1/${fit})/log(2))`;
|
|
11580
|
+
const side = (dim) => `if(lt(${fit}\\,0.5)\\,2*ceil(${dim}/pow(2\\,${halvings})/2)\\,${dim})`;
|
|
11581
|
+
return `scale=w=${side("iw")}:h=${side("ih")}:flags=area+accurate_rnd`;
|
|
11582
|
+
}
|
|
11614
11583
|
var SDR_JPEG_AS_BT601_FULL_RANGE_FILTER = "scale=flags=neighbor+accurate_rnd,format=gbrp,scale=out_color_matrix=bt601:out_range=pc:flags=neighbor,format=yuv420p";
|
|
11615
11584
|
var warnedMissingZscale = false;
|
|
11616
11585
|
async function toneMapsWithZscale() {
|
|
@@ -12124,7 +12093,10 @@ async function extractVideoFramesRangeUnredacted(videoPath, videoId, startTime,
|
|
|
12124
12093
|
...isHdr ? [] : chromeGuessForUntaggedMatrix(metadata),
|
|
12125
12094
|
SDR_CANVAS_PASSTHROUGH_FILTER
|
|
12126
12095
|
);
|
|
12127
|
-
if (format === "jpg")
|
|
12096
|
+
if (format === "jpg") {
|
|
12097
|
+
if (options.shownBox) vfFilters.push(halveToCoverScaleFilter(options.shownBox));
|
|
12098
|
+
vfFilters.push(SDR_JPEG_AS_BT601_FULL_RANGE_FILTER);
|
|
12099
|
+
}
|
|
12128
12100
|
}
|
|
12129
12101
|
const encodeArgs = ["-q:v", format === "jpg" ? String(Math.ceil((100 - quality) / 3)) : "0"];
|
|
12130
12102
|
if (format === "png") encodeArgs.push("-compression_level", "1");
|
|
@@ -12424,10 +12396,7 @@ function codecMayHaveAlpha(codec) {
|
|
|
12424
12396
|
return ALPHA_CAPABLE_CODECS.has((codec ?? "").toLowerCase());
|
|
12425
12397
|
}
|
|
12426
12398
|
function decoderForCodec(codec) {
|
|
12427
|
-
|
|
12428
|
-
if (c === "vp9") return "libvpx-vp9";
|
|
12429
|
-
if (c === "vp8") return "libvpx";
|
|
12430
|
-
return c;
|
|
12399
|
+
return alphaDecoderFor(codec) ?? (codec ?? "").toLowerCase();
|
|
12431
12400
|
}
|
|
12432
12401
|
function resolveFrameFormat(metadata, requested) {
|
|
12433
12402
|
if (metadata.hasAlpha || codecMayHaveAlpha(metadata.videoCodec)) return "png";
|
|
@@ -13532,6 +13501,52 @@ async function setVideoElementsVisibility(page, videoIds, visible) {
|
|
|
13532
13501
|
visible
|
|
13533
13502
|
);
|
|
13534
13503
|
}
|
|
13504
|
+
async function measureVideoShownBoxes(page, videoIds, times) {
|
|
13505
|
+
if (videoIds.length === 0 || times.length === 0) return /* @__PURE__ */ new Map();
|
|
13506
|
+
const boxes = await page.evaluate(
|
|
13507
|
+
async (ids, seekTimes, gradingAttr, gradingCanvasPrefix) => {
|
|
13508
|
+
const hf = window.__hf;
|
|
13509
|
+
if (typeof hf?.seek !== "function") return [];
|
|
13510
|
+
const waitForSeek = window.__hfWaitForSeekCompletion;
|
|
13511
|
+
const largest = /* @__PURE__ */ new Map();
|
|
13512
|
+
const fullSize = /* @__PURE__ */ new Set();
|
|
13513
|
+
const keepsFullSize = (video) => {
|
|
13514
|
+
if (video.hasAttribute(gradingAttr)) return true;
|
|
13515
|
+
const fit = window.getComputedStyle(video).objectFit;
|
|
13516
|
+
return fit === "none" || fit === "scale-down";
|
|
13517
|
+
};
|
|
13518
|
+
const measure = (id) => {
|
|
13519
|
+
const video = window.__hfMediaEl?.(id) ?? document.getElementById(id);
|
|
13520
|
+
if (!video || keepsFullSize(video)) {
|
|
13521
|
+
fullSize.add(id);
|
|
13522
|
+
return;
|
|
13523
|
+
}
|
|
13524
|
+
const rect = video.getBoundingClientRect();
|
|
13525
|
+
const box = largest.get(id) ?? { width: 0, height: 0 };
|
|
13526
|
+
box.width = Math.max(box.width, rect.width * window.devicePixelRatio);
|
|
13527
|
+
box.height = Math.max(box.height, rect.height * window.devicePixelRatio);
|
|
13528
|
+
largest.set(id, box);
|
|
13529
|
+
};
|
|
13530
|
+
const pageHasCanvas = () => Array.from(document.querySelectorAll("canvas")).some(
|
|
13531
|
+
(canvas) => !canvas.id.startsWith(gradingCanvasPrefix)
|
|
13532
|
+
);
|
|
13533
|
+
for (const t of seekTimes) {
|
|
13534
|
+
hf.seek(t);
|
|
13535
|
+
await waitForSeek?.();
|
|
13536
|
+
if (pageHasCanvas()) return [];
|
|
13537
|
+
for (const id of ids) measure(id);
|
|
13538
|
+
}
|
|
13539
|
+
return Array.from(largest).filter(
|
|
13540
|
+
([id, box]) => !fullSize.has(id) && box.width > 0 && box.height > 0
|
|
13541
|
+
);
|
|
13542
|
+
},
|
|
13543
|
+
[...videoIds],
|
|
13544
|
+
[...times],
|
|
13545
|
+
HF_COLOR_GRADING_ATTR,
|
|
13546
|
+
HF_COLOR_GRADING_CANVAS_ID_PREFIX
|
|
13547
|
+
);
|
|
13548
|
+
return new Map(boxes);
|
|
13549
|
+
}
|
|
13535
13550
|
async function queryVideoElementBounds(page, videoIds) {
|
|
13536
13551
|
if (videoIds.length === 0) return [];
|
|
13537
13552
|
return page.evaluate((ids) => {
|
|
@@ -13792,7 +13807,16 @@ async function queryElementStacking(page, nativeHdrIds) {
|
|
|
13792
13807
|
}
|
|
13793
13808
|
|
|
13794
13809
|
// ../engine/src/services/audioMixer.ts
|
|
13795
|
-
import {
|
|
13810
|
+
import {
|
|
13811
|
+
closeSync as closeSync4,
|
|
13812
|
+
existsSync as existsSync11,
|
|
13813
|
+
mkdirSync as mkdirSync7,
|
|
13814
|
+
mkdtempSync as mkdtempSync7,
|
|
13815
|
+
openSync as openSync4,
|
|
13816
|
+
renameSync as renameSync3,
|
|
13817
|
+
rmSync as rmSync8,
|
|
13818
|
+
writeFileSync as writeFileSync7
|
|
13819
|
+
} from "fs";
|
|
13796
13820
|
import { join as join14, dirname as dirname7, isAbsolute, relative } from "path";
|
|
13797
13821
|
|
|
13798
13822
|
// ../engine/src/utils/notMediaPayload.ts
|
|
@@ -13937,18 +13961,18 @@ function planSegments(totalDuration, count) {
|
|
|
13937
13961
|
const cuts = Array.from({ length: count + 1 }, (_, k) => Math.round(k * packets / count));
|
|
13938
13962
|
return cuts.slice(0, -1).map((cut, k) => {
|
|
13939
13963
|
const next = cuts[k + 1];
|
|
13940
|
-
const firstFrame =
|
|
13941
|
-
const end = k === count - 1 ? "" :
|
|
13942
|
-
const trim = `atrim=start_sample=${firstFrame * FRAME_SAMPLES}${end}`;
|
|
13964
|
+
const firstFrame = cut - PRE_ROLL_FRAMES;
|
|
13965
|
+
const end = k === count - 1 ? "" : `end_sample=${(next + POST_ROLL_FRAMES) * FRAME_SAMPLES}`;
|
|
13966
|
+
const trim = firstFrame < 0 ? `${end && `atrim=${end},`}adelay=delays=${-firstFrame * FRAME_SAMPLES}S:all=1` : `atrim=start_sample=${firstFrame * FRAME_SAMPLES}${end && `:${end}`}`;
|
|
13943
13967
|
return { trim, keepFrom: cut - firstFrame, keepTo: next - firstFrame };
|
|
13944
13968
|
});
|
|
13945
13969
|
}
|
|
13946
|
-
async function encodeAac(input, outputPath, totalDuration, {
|
|
13947
|
-
|
|
13948
|
-
|
|
13949
|
-
|
|
13950
|
-
|
|
13951
|
-
|
|
13970
|
+
async function encodeAac(input, outputPath, totalDuration, {
|
|
13971
|
+
signal,
|
|
13972
|
+
timeout,
|
|
13973
|
+
filter,
|
|
13974
|
+
segments: count = aacSegmentCount(totalDuration)
|
|
13975
|
+
}) {
|
|
13952
13976
|
const dir = mkdtempSync4(join11(dirname5(outputPath), ".aac-segments-"));
|
|
13953
13977
|
try {
|
|
13954
13978
|
const segments = planSegments(totalDuration, count).map((segment, k) => ({
|
|
@@ -13957,10 +13981,23 @@ async function encodeAac(input, outputPath, totalDuration, { signal, timeout })
|
|
|
13957
13981
|
}));
|
|
13958
13982
|
const results = await Promise.all(
|
|
13959
13983
|
segments.map(
|
|
13960
|
-
({ trim, path }) => runFfmpeg(
|
|
13961
|
-
|
|
13962
|
-
|
|
13963
|
-
|
|
13984
|
+
({ trim, path }) => runFfmpeg(
|
|
13985
|
+
[
|
|
13986
|
+
"-i",
|
|
13987
|
+
input,
|
|
13988
|
+
"-af",
|
|
13989
|
+
[filter, `aresample=${SAMPLE_RATE}`, trim].filter(Boolean).join(","),
|
|
13990
|
+
...AAC_ARGS,
|
|
13991
|
+
"-f",
|
|
13992
|
+
"adts",
|
|
13993
|
+
"-y",
|
|
13994
|
+
path
|
|
13995
|
+
],
|
|
13996
|
+
{
|
|
13997
|
+
signal,
|
|
13998
|
+
timeout
|
|
13999
|
+
}
|
|
14000
|
+
)
|
|
13964
14001
|
)
|
|
13965
14002
|
);
|
|
13966
14003
|
const failed = results.find((result) => !result.success);
|
|
@@ -14471,7 +14508,7 @@ import { join as join13 } from "path";
|
|
|
14471
14508
|
import { pathToFileURL } from "url";
|
|
14472
14509
|
|
|
14473
14510
|
// ../core/dist/generated/audio-fx-runtime-inline.js
|
|
14474
|
-
var AUDIO_FX_RUNTIME_IIFE = '"use strict";(()=>{var we="data-fx-chain",Tt=we.slice(5),W=1,F=(e="frequency",t="Frequency",n=1e3,o=20,a=2e4)=>({kind:"number",key:e,label:t,unit:"Hz",min:o,max:a,step:1,default:n,scale:"log",automatable:!0}),C=(e=.707,t="Bandwidth: higher is narrower.")=>({kind:"number",key:"q",label:"Q",unit:"",min:.1,max:20,step:.01,default:e,scale:"log",automatable:!0,hint:t}),R=(e=-40,t=40,n=0)=>({kind:"number",key:"gain",label:"Gain",unit:"dB",min:e,max:t,step:.1,default:n,automatable:!0}),K={kind:"enum",key:"poles",label:"Slope",options:[{value:"1",label:"6 dB/oct"},{value:"2",label:"12 dB/oct"}],default:"2",hint:"Two poles is the usual biquad; one pole is gentler."},z=[{id:"gain",label:"Gain",group:"dynamics",description:"Raise or lower the whole signal. Automate it to duck under something else.",params:[R(-60,12,0)],web:"gain-node"},{id:"peaking",label:"Peaking EQ",group:"filter",description:"Boost or cut a band, leaving everything either side alone.",params:[F("frequency","Frequency",1e3),R(-40,40,0),C(1)],web:"biquad-peaking"},{id:"lowshelf",label:"Low Shelf",group:"filter",description:"Lift or drop everything below the corner frequency.",params:[F("frequency","Frequency",200,20,2e3),R(-40,40,0)],web:"biquad-lowshelf"},{id:"highshelf",label:"High Shelf",group:"filter",description:"Lift or drop everything above the corner frequency.",params:[F("frequency","Frequency",4e3,500,2e4),R(-40,40,0)],web:"biquad-highshelf"},{id:"highpass",label:"High-pass",group:"filter",description:"Remove low frequencies: the usual fix for rumble on a voice.",params:[F("frequency","Cutoff",300,20,2e4),C(.707),K],web:"biquad-highpass"},{id:"lowpass",label:"Low-pass",group:"filter",description:"Remove high frequencies, which darkens or muffles a track.",params:[F("frequency","Cutoff",8e3,100,2e4),C(.707),K],web:"biquad-lowpass"},{id:"compressor",label:"Compressor",group:"dynamics",description:"Pull loud parts down so the quiet ones can come up.",params:[{kind:"number",key:"threshold",label:"Threshold",unit:"dB",min:-60,max:0,step:.5,default:-24,hint:"Level above which the compressor starts working."},{kind:"number",key:"ratio",label:"Ratio",unit:":1",min:1,max:20,step:.1,default:4},{kind:"number",key:"attack",label:"Attack",unit:"ms",min:.01,max:2e3,step:.1,default:20,scale:"log"},{kind:"number",key:"release",label:"Release",unit:"ms",min:.01,max:9e3,step:1,default:250,scale:"log"},{kind:"number",key:"knee",label:"Knee",unit:"",min:1,max:8,step:.01,default:2.83,hint:"1 is a hard corner; higher eases into it."},{kind:"number",key:"makeup",label:"Makeup",unit:"dB",min:0,max:36,step:.1,default:0},{kind:"number",key:"mix",label:"Mix",unit:"",min:0,max:1,step:.01,default:1,hint:"Below 1 blends the dry signal back in."}],web:"worklet-compressor"},{id:"limiter",label:"Limiter",group:"dynamics",description:"Peak limiter that follows the signal\'s level. It has no lookahead, so a fast peak or an inter-sample peak can pass the ceiling; use the true-peak limiter for a delivery limit.",params:[{kind:"number",key:"limit",label:"Ceiling",unit:"dB",min:-24,max:0,step:.1,default:-1},{kind:"number",key:"attack",label:"Attack",unit:"ms",min:.1,max:80,step:.1,default:5},{kind:"number",key:"release",label:"Release",unit:"ms",min:1,max:8e3,step:1,default:50,scale:"log"},{kind:"number",key:"level_out",label:"Output",unit:"dB",min:-24,max:24,step:.1,default:0}],web:"worklet-limiter"},{id:"truepeak",label:"True-peak limiter",group:"dynamics",description:"Lookahead limiter that holds a 4x estimate of the inter-sample peak at a dBTP ceiling; full-band noise can land up to about 1.7 dB above it. Adds lookahead plus about 0.3 ms of latency.",params:[{kind:"number",key:"ceiling",label:"Ceiling",unit:"dBTP",min:-24,max:0,step:.1,default:-1,hint:"Target true peak, measured on a 4x oversampled signal. Dense full-band sound can end up to about 1.7 dB above it."},{kind:"number",key:"lookahead",label:"Lookahead",unit:"ms",min:.5,max:10,step:.1,default:3,hint:"How far ahead the gain starts falling. Longer is smoother and adds the same latency."},{kind:"number",key:"release",label:"Release",unit:"ms",min:10,max:2e3,step:1,default:80,scale:"log"}],web:"worklet-truepeak"},{id:"gate",label:"Noise Gate",group:"dynamics",description:"Silence the track when it drops below the threshold.",params:[{kind:"number",key:"threshold",label:"Threshold",unit:"dB",min:-80,max:0,step:.5,default:-35},{kind:"number",key:"range",label:"Range",unit:"dB",min:-80,max:0,step:.5,default:-24,hint:"How far down the gate pulls when closed."},{kind:"number",key:"ratio",label:"Ratio",unit:":1",min:1,max:20,step:.1,default:10},{kind:"number",key:"attack",label:"Attack",unit:"ms",min:.01,max:9e3,step:.1,default:1,scale:"log"},{kind:"number",key:"release",label:"Release",unit:"ms",min:.01,max:9e3,step:1,default:100,scale:"log"},{kind:"number",key:"knee",label:"Knee",unit:"",min:1,max:8,step:.01,default:2.83}],web:"worklet-gate"},{id:"saturate",label:"Saturation",group:"nonlinear",description:"Soft-clip the waveform for warmth or outright distortion.",params:[{kind:"enum",key:"type",label:"Curve",options:[{value:"tanh",label:"Tanh"},{value:"atan",label:"Arctan"},{value:"cubic",label:"Cubic"},{value:"exp",label:"Exponential"},{value:"alg",label:"Algebraic"},{value:"quintic",label:"Quintic"},{value:"sin",label:"Sine"},{value:"erf",label:"Error function"},{value:"hard",label:"Hard clip"}],default:"tanh"},{kind:"number",key:"threshold",label:"Threshold",unit:"dB",min:-40,max:0,step:.1,default:-6},{kind:"number",key:"output",automatable:!0,label:"Output",unit:"dB",min:-24,max:24,step:.1,default:0},{kind:"number",key:"oversample",label:"Oversample",unit:"x",min:1,max:8,step:1,default:4,hint:"Higher costs more but keeps aliasing down."}],web:"waveshaper"},{id:"bitcrush",label:"Bitcrush",group:"nonlinear",description:"Drop bit depth and sample rate for a lo-fi, digital sound.",params:[{kind:"number",key:"bits",label:"Bit depth",unit:"bit",min:1,max:32,step:.1,default:8},{kind:"number",key:"samples",label:"Sample hold",unit:"x",min:1,max:250,step:1,default:1,hint:"Repeats each sample N times, a crude downsample."},{kind:"number",key:"mix",label:"Mix",unit:"",min:0,max:1,step:.01,default:1}],web:"worklet-bitcrush"},{id:"pitchshift",label:"Pitch shift",group:"time",description:"Shifts pitch up or down without changing playback speed. Adds ~50 ms of latency.",params:[{kind:"number",key:"semitones",label:"Semitones",unit:"st",min:-12,max:12,step:1,default:0},{kind:"number",key:"mix",label:"Mix",unit:"",min:0,max:1,step:.01,default:1}],web:"worklet-pitchshift"},{id:"delay",label:"Delay",group:"time",description:"Repeating echoes behind the dry signal.",params:[{kind:"number",key:"time",automatable:!0,label:"Time",unit:"ms",min:1,max:5e3,step:1,default:250,scale:"log"},{kind:"number",key:"feedback",automatable:!0,label:"Feedback",unit:"",min:.01,max:.95,step:.01,default:.35},{kind:"number",key:"mix",automatable:!0,label:"Mix",unit:"",min:0,max:1,step:.01,default:.4}],web:"delay-feedback"},{id:"chorus",label:"Chorus",group:"time",description:"Detuned copies of the signal for width and thickness.",params:[{kind:"number",key:"delay",automatable:!0,label:"Delay",unit:"ms",min:1,max:100,step:.1,default:7},{kind:"number",key:"depth",automatable:!0,label:"Depth",unit:"ms",min:0,max:10,step:.01,default:2},{kind:"number",key:"speed",automatable:!0,label:"Rate",unit:"Hz",min:.01,max:10,step:.01,default:1},{kind:"number",key:"mix",automatable:!0,label:"Mix",unit:"",min:0,max:1,step:.01,default:.5}],web:"chorus-lfo"},{id:"phaser",label:"Phaser",group:"time",description:"Sweeping notches moving through the spectrum.",params:[{kind:"number",key:"in_gain",automatable:!0,label:"Input",unit:"",min:0,max:1,step:.01,default:.4},{kind:"number",key:"out_gain",automatable:!0,label:"Output",unit:"",min:0,max:2,step:.01,default:.74},{kind:"number",key:"delay",label:"Delay",unit:"ms",min:.1,max:5,step:.1,default:3},{kind:"number",key:"decay",label:"Decay",unit:"",min:0,max:.99,step:.01,default:.4},{kind:"number",key:"speed",automatable:!0,label:"Rate",unit:"Hz",min:.1,max:2,step:.01,default:.5},{kind:"enum",key:"type",label:"Waveform",options:[{value:"0",label:"Triangular"},{value:"1",label:"Sinusoidal"}],default:"0"}],web:"allpass-phaser"},{id:"reverb",label:"Reverb",group:"time",description:"Room tail. Both ends convolve the same generated impulse, so preview matches render.",params:[{kind:"number",key:"size",label:"Room size",unit:"",min:.05,max:1,step:.01,default:.7},{kind:"number",key:"damping",label:"Damping",unit:"",min:0,max:1,step:.01,default:.5,hint:"Higher rolls the top off the tail faster."},{kind:"number",key:"wet",automatable:!0,label:"Wet",unit:"",min:0,max:1,step:.01,default:.35},{kind:"number",key:"dry",automatable:!0,label:"Dry",unit:"",min:0,max:1,step:.01,default:.7}],web:"convolver"}],L=new Map(z.map(e=>[e.id,e]));function P(e){return L.get(e)}var Ft=z.map(e=>e.id);function y(e,t){let n=L.get(e);if(!n)return{};let o={};for(let a of n.params){let r=t?.[a.key];if(a.kind==="enum"){let s=a.options.some(u=>u.value===r);o[a.key]=s?r:a.default;continue}let i=typeof r=="number"?r:typeof r=="string"&&r.trim()!==""?Number(r):Number.NaN;o[a.key]=Number.isFinite(i)?Math.min(a.max,Math.max(a.min,i)):a.default}return o}var x=class extends Error{constructor(t){super(t),this.name="AudioFxChainError"}};function J(e){let t;try{t=JSON.parse(e)}catch(a){throw new x(`Chain file is not valid JSON: ${a.message}`)}if(typeof t!="object"||t===null)throw new x("Chain file must be a JSON object.");let n=t;if(n.version!==W)throw new x(`Unsupported chain version: ${String(n.version)}`);if(!Array.isArray(n.nodes))throw new x("Chain file is missing a `nodes` array.");let o=n.nodes.map(ve);return{version:W,nodes:o}}function w(e){return e.nodes.filter(t=>t.enabled!==!1)}function ve(e,t){if(typeof e!="object"||e===null)throw new x(`Node ${t} is not an object.`);let n=e;if(typeof n.type!="string"||!L.has(n.type))throw new x(`Node ${t} has unknown effect type: ${String(n.type)}`);return Te({type:n.type,id:E(n.id),fromCarve:Y(n.fromCarve),fromPreset:E(n.fromPreset),label:E(n.label),fromEq:E(n.fromEq),fromLeveller:Y(n.fromLeveller),presetAmount:Me(n.presetAmount),enabled:n.enabled!==!1,params:y(n.type,n.params??void 0)})}function E(e){return typeof e=="string"&&e?e:void 0}function Y(e){return e===!0?!0:void 0}function Me(e){if(!(typeof e!="number"||!Number.isFinite(e)))return Math.min(1,Math.max(0,e))}function Te(e){for(let t of Object.keys(e))e[t]===void 0&&delete e[t];return e}function Fe(e,t){return Math.max(1,Math.round(e*t/1e3))}function Q(e,t){return Fe(e,t)+16}var Z=`\nconst TP_OS = 4;\nconst TP_HALF = 64;\nconst TP_BRANCH = 33;\nconst TP_DELAY = 16;\n\nfunction besselI0(x) {\n let sum = 1, term = 1;\n for (let k = 1; k < 40; k++) {\n term *= (x / (2 * k)) * (x / (2 * k));\n sum += term;\n }\n return sum;\n}\n\n/** Kaiser-windowed sinc, one array per polyphase branch, newest tap first. */\nfunction tpBranches() {\n const beta = 6;\n const norm = besselI0(beta);\n const branches = [];\n for (let p = 0; p < TP_OS; p++) {\n const taps = new Float64Array(TP_BRANCH);\n let sum = 0;\n for (let j = 0; j < TP_BRANCH; j++) {\n const k = p + TP_OS * j;\n if (k > 2 * TP_HALF) continue;\n const t = (k - TP_HALF) / TP_OS;\n const sinc = t === 0 ? 1 : Math.sin(Math.PI * t) / (Math.PI * t);\n const r = (k - TP_HALF) / TP_HALF;\n taps[j] = sinc * (besselI0(beta * Math.sqrt(Math.max(0, 1 - r * r))) / norm);\n sum += taps[j];\n }\n // Unity gain at DC on every branch, so a steady level reads as itself.\n for (let j = 0; j < TP_BRANCH; j++) taps[j] /= sum;\n branches.push(taps);\n }\n return branches;\n}\n\nclass HfTruePeak extends AudioWorkletProcessor {\n constructor(o) {\n super();\n this.p = o.processorOptions || {};\n this.look = Math.max(1, Math.round((this.p.lookahead ?? 3) * sampleRate / 1000));\n this.delayLen = this.look + TP_DELAY;\n this.branches = tpBranches();\n this.setLevels();\n this.clear();\n this.port.onmessage = (e) => {\n if (e.data && e.data.__hfDispose) { this.dead = true; return; }\n if (e.data && e.data.__hfReset) { this.clear(); return; }\n this.p = { ...this.p, ...e.data };\n this.setLevels();\n };\n }\n /** Back to the state of a fresh processor: no audio in the delay line, no gain reduction. */\n clear() {\n this.ch = [];\n this.rel = 1;\n this.dqIdx = new Int32Array(this.look + 2);\n this.dqVal = new Float64Array(this.look + 2);\n this.dqHead = 0;\n this.dqTail = 0;\n this.t = 0;\n this.avgRing = new Float64Array(this.look + 1).fill(1);\n this.avgPos = 0;\n this.avgSum = this.look + 1;\n }\n setLevels() {\n this.ceiling = Math.pow(10, (this.p.ceiling ?? -1) / 20);\n this.relCoef = 1 - Math.exp(-1 / (sampleRate * Math.max(1e-4, (this.p.release ?? 80) / 1000)));\n }\n channel(c) {\n if (!this.ch[c]) {\n this.ch[c] = {\n delay: new Float32Array(this.delayLen),\n w: 0,\n hist: new Float32Array(TP_BRANCH * 2),\n pos: 0,\n };\n }\n return this.ch[c];\n }\n /** Largest interpolated magnitude across channels for the newest sample. */\n peak(chans, inputs, n) {\n let peak = 0;\n for (let c = 0; c < chans; c++) {\n const s = this.channel(c);\n const x = inputs[c][n];\n s.pos = (s.pos + 1) % TP_BRANCH;\n s.hist[s.pos] = x;\n s.hist[s.pos + TP_BRANCH] = x;\n const base = s.pos + TP_BRANCH;\n for (let p = 0; p < TP_OS; p++) {\n const taps = this.branches[p];\n let acc = 0;\n for (let j = 0; j < TP_BRANCH; j++) acc += taps[j] * s.hist[base - j];\n const a = acc < 0 ? -acc : acc;\n if (a > peak) peak = a;\n }\n }\n return peak;\n }\n /** Windowed minimum of the required gain over the last look + 1 values. */\n windowMin(v) {\n const cap = this.dqIdx.length;\n while (this.dqTail !== this.dqHead && this.dqVal[(this.dqTail + cap - 1) % cap] >= v) {\n this.dqTail = (this.dqTail + cap - 1) % cap;\n }\n this.dqIdx[this.dqTail] = this.t;\n this.dqVal[this.dqTail] = v;\n this.dqTail = (this.dqTail + 1) % cap;\n while (this.dqIdx[this.dqHead] <= this.t - (this.look + 1)) {\n this.dqHead = (this.dqHead + 1) % cap;\n }\n this.t++;\n return this.dqVal[this.dqHead];\n }\n process(inputs, outputs) {\n if (this.dead) return false;\n const i = inputs[0], o = outputs[0];\n if (!i || !i.length) return true;\n const chans = i.length;\n const frames = i[0].length;\n for (let n = 0; n < frames; n++) {\n const peak = this.peak(chans, i, n);\n const need = peak > this.ceiling ? this.ceiling / peak : 1;\n const m = this.windowMin(need);\n this.avgSum += m - this.avgRing[this.avgPos];\n this.avgRing[this.avgPos] = m;\n this.avgPos = (this.avgPos + 1) % this.avgRing.length;\n const target = Math.min(1, this.avgSum / this.avgRing.length);\n const released = this.rel + (1 - this.rel) * this.relCoef;\n this.rel = released < target ? released : target;\n if (target >= 1 && this.rel > 0.9999999) this.rel = 1;\n for (let c = 0; c < chans; c++) {\n const s = this.channel(c);\n o[c][n] = s.delay[s.w] * this.rel;\n s.delay[s.w] = i[c][n];\n s.w = (s.w + 1) % this.delayLen;\n }\n }\n return true;\n }\n}\nregisterProcessor("hf-truepeak", HfTruePeak);\n`;var Pe=`\nconst dbToLin = (db) => Math.pow(10, db / 20);\n\n/**\n * One-pole envelope followers, one per channel.\n *\n * Per channel matters: the followers advance once per sample, so a single shared\n * follower stepped once per channel per sample. On stereo that ran a 20 ms attack\n * as 10 ms, and gave the right channel a gain computed from an envelope that had\n * already traversed the left, so the two channels ducked by different amounts\n * from the same input and the image pumped.\n */\nclass EnvBank {\n constructor(attackMs, releaseMs) { this.set(attackMs, releaseMs); this.values = []; }\n set(attackMs, releaseMs) {\n this.a = Math.exp(-1 / (sampleRate * Math.max(1e-5, attackMs / 1000)));\n this.r = Math.exp(-1 / (sampleRate * Math.max(1e-5, releaseMs / 1000)));\n }\n push(ch, x) {\n const prev = this.values[ch] ?? 0;\n const m = Math.abs(x);\n const c = m > prev ? this.a : this.r;\n const next = m + c * (prev - m);\n this.values[ch] = next;\n return next;\n }\n}\n\n/** Soft-knee gain computer in dB, matching acompressor\'s shape. */\nfunction kneeGain(envDb, thresholdDb, ratio, kneeDb) {\n const over = envDb - thresholdDb;\n if (kneeDb > 0 && over > -kneeDb && over < kneeDb) {\n const t = (over + kneeDb) / (2 * kneeDb);\n return -((1 - 1 / ratio) * kneeDb * t * t);\n }\n return over > 0 ? -(over * (1 - 1 / ratio)) : 0;\n}\n\n// log10/exp per sample is the single most expensive thing a dynamics processor\n// can do on the audio thread, and every sample below the knee needs neither:\n// its gain is exactly unity. Comparing envelopes in the linear domain lets the\n// quiet majority of samples skip the transcendentals entirely.\nconst LN10_OVER_20 = Math.LN10 / 20;\nconst dbToLinFast = (db) => Math.exp(db * LN10_OVER_20);\n\nclass HfCompressor extends AudioWorkletProcessor {\n constructor(o) {\n super();\n this.p = o.processorOptions || {};\n this.env = new EnvBank(this.p.attack ?? 20, this.p.release ?? 250);\n this.port.onmessage = (e) => {\n if (e.data && e.data.__hfDispose) { this.dead = true; return; }\n this.p = { ...this.p, ...e.data };\n this.env.set(this.p.attack ?? 20, this.p.release ?? 250);\n };\n }\n process(inputs, outputs) {\n if (this.dead) return false;\n const i = inputs[0], o = outputs[0];\n if (!i || !i.length) return true;\n const p = this.p;\n const makeup = dbToLin(p.makeup ?? 0);\n const mix = p.mix ?? 1;\n // Knee is expressed as a ratio in FFmpeg; convert to dB width.\n const kneeDb = 20 * Math.log10(Math.max(1.0001, p.knee ?? 2.83));\n const thresholdDb = p.threshold ?? -24;\n const ratio = p.ratio ?? 4;\n // Below this the gain computer returns unity, so the sample needs no\n // logarithm at all.\n const kneeStartLin = dbToLin(thresholdDb - kneeDb);\n const dry = 1 - mix;\n for (let ch = 0; ch < i.length; ch++) {\n const inp = i[ch], out = o[ch];\n for (let n = 0; n < inp.length; n++) {\n const x = inp[n];\n // Per-channel follower, and the sub-knee shortcut: below the knee the\n // gain is exactly unity, so the sample needs no logarithm at all.\n const env = this.env.push(ch, x);\n if (env <= kneeStartLin) {\n out[n] = x * makeup * mix + x * dry;\n continue;\n }\n const envDb = 20 * Math.log10(env);\n const g = dbToLinFast(kneeGain(envDb, thresholdDb, ratio, kneeDb));\n out[n] = x * g * makeup * mix + x * dry;\n }\n }\n return true;\n }\n}\nregisterProcessor("hf-compressor", HfCompressor);\n\nclass HfLimiter extends AudioWorkletProcessor {\n constructor(o) {\n super();\n this.p = o.processorOptions || {};\n this.env = new EnvBank(this.p.attack ?? 5, this.p.release ?? 50);\n this.port.onmessage = (e) => {\n if (e.data && e.data.__hfDispose) { this.dead = true; return; }\n this.p = { ...this.p, ...e.data };\n this.env.set(this.p.attack ?? 5, this.p.release ?? 50);\n };\n }\n process(inputs, outputs) {\n if (this.dead) return false;\n const i = inputs[0], o = outputs[0];\n if (!i || !i.length) return true;\n const ceiling = dbToLin(this.p.limit ?? -1);\n const outGain = dbToLin(this.p.level_out ?? 0);\n for (let ch = 0; ch < i.length; ch++) {\n const inp = i[ch], out = o[ch];\n for (let n = 0; n < inp.length; n++) {\n const x = inp[n];\n const env = this.env.push(ch, x);\n // Only ever attenuate: a limiter that can raise level is a compressor.\n const g = env > ceiling ? ceiling / env : 1;\n out[n] = x * g * outGain;\n }\n }\n return true;\n }\n}\nregisterProcessor("hf-limiter", HfLimiter);\n\nclass HfGate extends AudioWorkletProcessor {\n constructor(o) {\n super();\n this.p = o.processorOptions || {};\n this.env = new EnvBank(this.p.attack ?? 1, this.p.release ?? 100);\n this.gains = [];\n this.port.onmessage = (e) => {\n if (e.data && e.data.__hfDispose) { this.dead = true; return; }\n this.p = { ...this.p, ...e.data };\n this.env.set(this.p.attack ?? 1, this.p.release ?? 100);\n };\n }\n process(inputs, outputs) {\n if (this.dead) return false;\n const i = inputs[0], o = outputs[0];\n if (!i || !i.length) return true;\n const p = this.p;\n const threshold = dbToLin(p.threshold ?? -35);\n const floor = dbToLin(p.range ?? -24);\n const ratio = p.ratio ?? 10;\n // Knee is declared in the registry as a ratio, like the compressor\'s; a\n // hard threshold ignored it and chattered on material sitting right at the\n // gate point.\n const kneeDb = 20 * Math.log10(Math.max(1.0001, p.knee ?? 2.83));\n const kneeLin = dbToLin((p.threshold ?? -35) + kneeDb);\n for (let ch = 0; ch < i.length; ch++) {\n const inp = i[ch], out = o[ch];\n for (let n = 0; n < inp.length; n++) {\n const x = inp[n];\n const env = this.env.push(ch, x);\n let target = 1;\n // Above the threshold the gate is fully open; skip the pow entirely.\n if (env < threshold) {\n const under = env > 1e-9 ? threshold / env : 1e9;\n target = Math.max(floor, 1 / Math.pow(under, ratio - 1));\n if (!isFinite(target)) target = floor;\n }\n // Smooth toward the target so the gate does not click on every sample.\n const held = this.gains[ch] ?? 1;\n const c = target < held ? this.env.r : this.env.a;\n const smoothed = target + c * (held - target);\n this.gains[ch] = smoothed;\n out[n] = x * smoothed;\n }\n }\n return true;\n }\n}\nregisterProcessor("hf-gate", HfGate);\n\nclass HfBitcrush extends AudioWorkletProcessor {\n constructor(o) {\n super();\n this.p = o.processorOptions || {};\n this.holds = [];\n this.held = [];\n this.start = Math.round((this.p.__hfElapsed ?? 0) * sampleRate);\n this.port.onmessage = (e) => {\n if (e.data && e.data.__hfDispose) { this.dead = true; return; }\n this.p = { ...this.p, ...e.data };\n };\n }\n process(inputs, outputs) {\n if (this.dead) return false;\n const i = inputs[0], o = outputs[0];\n if (!i || !i.length) return true;\n const p = this.p;\n const levels = Math.pow(2, (p.bits ?? 8) - 1);\n const step = Math.max(1, Math.round(p.samples ?? 1));\n const mix = p.mix ?? 1;\n for (let ch = 0; ch < i.length; ch++) {\n const inp = i[ch], out = o[ch];\n // Primed from the input: a counter seeded mid-hold would otherwise play 0 until it wraps.\n if (this.held[ch] === undefined) this.held[ch] = Math.round(inp[0] * levels) / levels;\n // The hold counter runs from the file\'s first sample, so a node built part-way in starts where it would be.\n if (this.holds[ch] === undefined) this.holds[ch] = this.start % step;\n for (let n = 0; n < inp.length; n++) {\n // Per channel: advancing one shared counter only on the last channel\n // left every earlier channel either unheld or frozen for a whole\n // 128-sample quantum, clicking once a block.\n if (this.holds[ch] === 0) this.held[ch] = Math.round(inp[n] * levels) / levels;\n out[n] = this.held[ch] * mix + inp[n] * (1 - mix);\n this.holds[ch] = (this.holds[ch] + 1) % step;\n }\n }\n return true;\n }\n}\nregisterProcessor("hf-bitcrush", HfBitcrush);\n\n/** Linear-interpolated read, \\`delaySamples\\` behind the write head. */\nfunction readTap(ring, write, delaySamples) {\n const len = ring.length;\n const pos = (write - 1 - delaySamples + len) % len;\n const i0 = Math.floor(pos);\n const frac = pos - i0;\n const i1 = (i0 + 1) % len;\n return ring[i0] * (1 - frac) + ring[i1] * frac;\n}\n\n/** Equal-power-ish crossfade, zero at a tap\'s reset point, which hides the splice. */\nfunction xfade(phase) {\n return Math.sin(Math.PI * phase);\n}\n\n/**\n * Dual-tap granular delay line: two read taps 180\\xB0 apart in a 100 ms grain,\n * each sweeping at a speed relative to the write head that shifts pitch\n * without changing duration. One tap is always fading in as the other fades\n * out, which hides the splice each tap makes when it wraps.\n *\n * write/phase are block-level state, advanced once per SAMPLE across all\n * channels together (not once per channel). Advancing them inside the\n * per-channel loop would move the tap 2x/4x too fast on a stereo/quad input.\n */\nclass HfPitchshift extends AudioWorkletProcessor {\n constructor(o) {\n super();\n this.p = o.processorOptions || {};\n this.grain = Math.round(sampleRate * 0.1);\n this.buf = [];\n this.write = 0;\n // The taps sweep at a constant rate from the start of the file, so a node built\n // part-way in joins the sweep where it would already be.\n const ratio0 = Math.pow(2, Math.max(-12, Math.min(12, this.p.semitones ?? 0)) / 12);\n const turns = (this.p.__hfElapsed ?? 0) * sampleRate * ((1 - ratio0) / this.grain);\n this.phase = turns - Math.floor(turns);\n // Samples written so far, capped at one grain. The taps read up to a grain\n // behind the write head, so until this fills they would read the ring\'s\n // zeros, so the head of every clip came out attenuated or silent.\n this.filled = 0;\n // How much of the wet (pitch-shifted) path is currently in the output, and\n // where it is heading. Crossing between dry and wet is a ~50 ms jump in the\n // signal, so it is RAMPED rather than switched: a hard swap either way is a\n // click. Ramping in both directions is also what lets a node return to true\n // bypass at semitones 0. A one-way latch left preview stuck with the delay\n // that the render, building a fresh node from the attribute, does not have.\n this.wet = 0;\n this.wetTarget = 0;\n // ~15 ms one-pole, short enough to feel immediate on a slider drag and long\n // enough that the splice is inaudible.\n this.wetCoef = Math.exp(-1 / (sampleRate * 0.015));\n this.port.onmessage = (e) => {\n if (e.data && e.data.__hfDispose) { this.dead = true; return; }\n this.p = { ...this.p, ...e.data };\n };\n }\n process(inputs, outputs) {\n if (this.dead) return false;\n const i = inputs[0], o = outputs[0];\n if (!i || !i.length) return true;\n const p = this.p;\n const semitones = Math.max(-12, Math.min(12, p.semitones ?? 0));\n const mix = Math.max(0, Math.min(1, p.mix ?? 1));\n const grain = this.grain;\n const ringLen = grain * 2;\n const n = i[0] ? i[0].length : 0;\n for (let ch = 0; ch < i.length; ch++) {\n if (!this.buf[ch]) this.buf[ch] = new Float32Array(ringLen);\n }\n\n // Nothing to shift, or mixed fully out. The grain delay is ~grain/2\n // whatever the ratio, so at semitones=0 this degenerated into a pure 50 ms\n // delay of the signal, while the copy for that exact setting reads\n // "Unchanged pitch".\n this.wetTarget = semitones === 0 ? 0 : mix;\n\n // Fully dry AND settled: take the cheap transparent path. The ring keeps\n // filling, so a later shift does not start cold.\n if (this.wetTarget === 0 && this.wet < 1e-4) {\n this.wet = 0;\n let w = this.write;\n for (let s = 0; s < n; s++) {\n for (let ch = 0; ch < i.length; ch++) {\n const x = i[ch][s];\n this.buf[ch][w] = x;\n o[ch][s] = x;\n }\n w = (w + 1) % ringLen;\n }\n this.write = w;\n this.filled = Math.min(grain, this.filled + n);\n return true;\n }\n\n const ratio = Math.pow(2, semitones / 12);\n const inc = (1 - ratio) / grain;\n let write = this.write, phase = this.phase, filled = this.filled, wetNow = this.wet;\n const target = this.wetTarget, coef = this.wetCoef;\n for (let s = 0; s < n; s++) {\n phase += inc;\n phase -= Math.floor(phase);\n const phaseB = (phase + 0.5) % 1;\n const gA = xfade(phase), gB = xfade(phaseB);\n // Ramp the wet path in as the ring fills rather than reading zeros:\n // 100 ms of unshifted audio at the head of a clip beats 50 ms of silence.\n const warm = filled >= grain ? 1 : filled / grain;\n wetNow = target + coef * (wetNow - target);\n const wetMix = wetNow * warm;\n for (let ch = 0; ch < i.length; ch++) {\n const ring = this.buf[ch];\n const inp = i[ch], out = o[ch];\n const x = inp[s];\n ring[write] = x;\n const wet =\n readTap(ring, write, phase * grain) * gA + readTap(ring, write, phaseB * grain) * gB;\n out[s] = x * (1 - wetMix) + wet * wetMix;\n }\n write = (write + 1) % ringLen;\n if (filled < grain) filled++;\n }\n this.write = write;\n this.phase = phase;\n this.filled = filled;\n this.wet = wetNow;\n return true;\n }\n}\nregisterProcessor("hf-pitchshift", HfPitchshift);\n`+Z,S=new WeakMap;var He=new WeakSet;function O(e){let t=S.get(e);return t||(t=(async()=>{if(!e.audioWorklet)throw new Error("AudioWorklet is unavailable: the page needs a secure context (https, localhost or file://)");let n=`data:text/javascript;base64,${btoa(String.fromCharCode(...new TextEncoder().encode(Pe)))}`;await e.audioWorklet.addModule(n),He.add(e)})().catch(n=>{throw S.delete(e),n}),S.set(e,t)),t}function _e(e,t,n){let o=.6+Math.max(0,Math.min(1,t))*2.6,a=Math.max(1,Math.floor(e*o)),r=new Float32Array(a),i=Math.round(t*1e3)*2654435761+Math.round(n*1e3)*40503>>>0,s=()=>(i=i*1664525+1013904223>>>0,i/4294967295*2-1),u=Math.max(.001,1-Math.max(0,Math.min(1,n))),l=0,m=0;for(let c=0;c<a;c++){l+=u*(s()-l);let b=l*Math.pow(1-c/a,2.5);r[c]=b,m+=b*b}let p=Math.sqrt(m);if(p>0)for(let c=0;c<a;c++)r[c]=(r[c]??0)/p;return r}var f=e=>typeof e=="number"?e:Number(e??0),B=e=>e/1e3;function ae(e,t,n,o){let a=Math.max(1,Math.round(e.sampleRate)),r=e.createBuffer(1,a,e.sampleRate),i=r.getChannelData(0);for(let l=0;l<a;l++){let m=l/a;i[l]=t==="sine"?Math.sin(2*Math.PI*m):4*Math.abs((m+.75)%1-.5)-1}let s=e.createBufferSource();s.buffer=r,s.loop=!0,s.playbackRate.value=n;let u=(o*n%1+1)%1*(a/e.sampleRate);return s.start(typeof e.currentTime=="number"?e.currentTime:0,u),s}function oe(e){try{e.stop()}catch{}e.disconnect()}function I(e,t){return[{param:e},{param:t,map:n=>1-n}]}function re(e,t,n){e.gain.value=n,t.gain.value=1-n}function q(e,t,n){return{input:e,output:e,update:t,automation:n,dispose:()=>e.disconnect()}}var Ne=new Set(["peaking","highpass","lowpass"]),ee=e=>Math.pow(10,e/20),Re=(e,t)=>{let n=e.createGain(),o=a=>{n.gain.value=ee(f(a.gain))};return o(t),q(n,o,{gain:[{param:n.gain,map:ee}]})};function H(e,t){return(n,o)=>{let a=n.createBiquadFilter();a.type=e;let r=i=>{a.frequency.value=f(i.frequency),i.q!==void 0&&(a.Q.value=f(i.q)),t&&(a.gain.value=f(i.gain))};return r(o),q(a,r,{frequency:[{param:a.frequency}],...Ne.has(e)?{q:[{param:a.Q}]}:{},...t?{gain:[{param:a.gain}]}:{}})}}function Ee(e){return(t,n)=>{let o=Math.tan(Math.PI*f(n.frequency)/t.sampleRate),a=e==="highpass"?t.createIIRFilter([1/(1+o),-1/(1+o)],[1,(o-1)/(o+1)]):t.createIIRFilter([o/(1+o),o/(1+o)],[1,(o-1)/(o+1)]);return q(a,()=>{})}}function M(e,t=!1){return(n,o,a)=>{let r=new AudioWorkletNode(n,e,{processorOptions:{...o,__hfElapsed:a}});return{input:r,output:r,update:i=>r.port.postMessage({...i}),...t?{reset:()=>r.port.postMessage({__hfReset:!0})}:{},dispose:()=>{r.port.postMessage({__hfDispose:!0}),r.disconnect()}}}}var De={tanh:Math.tanh,atan:e=>2/Math.PI*Math.atan(Math.PI/2*e),cubic:e=>Math.abs(e)>=1?Math.sign(e):e-e**3/3,exp:e=>Math.sign(e)*(1-Math.exp(-Math.abs(e))),alg:e=>e/Math.sqrt(1+e*e),quintic:e=>Math.abs(e)>=1?Math.sign(e):e-e**5/5,sin:e=>Math.abs(e)>=1?Math.sign(e):Math.sin(Math.PI/2*e),erf:e=>Math.tanh(1.20211*e),hard:e=>Math.max(-1,Math.min(1,e))},Ce=(e,t)=>{let n=e.createWaveShaper(),o=e.createGain(),a=e.createGain();o.connect(n).connect(a);let r=i=>{let s=De[String(i.type)]??Math.tanh,u=Math.pow(10,f(i.threshold)/20),l=8192,m=new Float32Array(l);for(let p=0;p<l;p++){let c=p/(l-1)*2-1;m[p]=s(c/Math.max(1e-6,u))*u}n.curve=m,n.oversample=f(i.oversample)>=4?"4x":f(i.oversample)>=2?"2x":"none",a.gain.value=Math.pow(10,f(i.output)/20)};return r(t),{input:o,output:a,update:r,automation:{output:[{param:a.gain,map:i=>Math.pow(10,i/20)}]},dispose:()=>{o.disconnect(),n.disconnect(),a.disconnect()}}},Le=(e,t)=>{let n=e.createGain(),o=e.createGain(),a=e.createDelay(5),r=e.createGain(),i=e.createGain(),s=e.createGain();n.connect(a),a.connect(r),r.connect(a),a.connect(i).connect(o),n.connect(s).connect(o);let u=l=>{a.delayTime.value=Math.min(5,f(l.time)/1e3),r.gain.value=f(l.feedback),re(i,s,f(l.mix))};return u(t),{input:n,output:o,update:u,automation:{time:[{param:a.delayTime,map:l=>Math.min(5,B(l))}],feedback:[{param:r.gain}],mix:I(i.gain,s.gain)},dispose:()=>[n,o,a,r,i,s].forEach(l=>l.disconnect())}},Se=(e,t,n)=>{let o=e.createGain(),a=e.createGain(),r=e.createDelay(.5),i=ae(e,"sine",f(t.speed),n),s=e.createGain(),u=e.createGain(),l=e.createGain();i.connect(s).connect(r.delayTime),o.connect(r).connect(u).connect(a),o.connect(l).connect(a);let m=p=>{r.delayTime.value=f(p.delay)/1e3,s.gain.value=f(p.depth)/1e3,i.playbackRate.value=f(p.speed),re(u,l,f(p.mix))};return m(t),{input:o,output:a,update:m,automation:{delay:[{param:r.delayTime,map:B}],depth:[{param:s.gain,map:B}],speed:[{param:i.playbackRate}],mix:I(u.gain,l.gain)},dispose:()=>{oe(i),[o,a,r,s,u,l].forEach(p=>p.disconnect())}}},Oe=6,Be=(e,t,n)=>{let o=e.createGain(),a=e.createGain(),r=e.createGain(),i=e.createGain(),s=ae(e,String(t.type)==="1"?"sine":"triangle",f(t.speed),n),u=e.createGain(),l=e.createGain(),m=e.createGain(),p=[];o.connect(r);let c=r;for(let d=0;d<Oe;d++){let h=e.createBiquadFilter();h.type="allpass",h.Q.value=.7071,u.connect(h.frequency),c.connect(h),c=h,p.push(h)}s.connect(u),c.connect(l).connect(i),r.connect(m).connect(i),i.connect(a);let b=d=>{let h=1e3/Math.max(.1,f(d.delay));for(let g of p)g.frequency.value=h;u.gain.value=h*f(d.decay),s.playbackRate.value=f(d.speed),r.gain.value=f(d.in_gain),i.gain.value=f(d.out_gain),l.gain.value=1,m.gain.value=1};return b(t),{input:o,output:a,update:b,automation:{speed:[{param:s.playbackRate}],in_gain:[{param:r.gain}],out_gain:[{param:i.gain}]},dispose:()=>{oe(s),[o,a,r,i,u,l,m,...p].forEach(d=>d.disconnect())}}},Ie=(e,t)=>{let n=e.createGain(),o=e.createGain(),a=e.createConvolver(),r=e.createGain(),i=e.createGain();a.normalize=!1,n.connect(a).connect(r).connect(o),n.connect(i).connect(o);let s="",u=l=>{let m=`${f(l.size)}:${f(l.damping)}`;if(m!==s){let p=_e(e.sampleRate,f(l.size),f(l.damping)),c=e.createBuffer(1,p.length,e.sampleRate);c.getChannelData(0).set(p),a.buffer=c,s=m}r.gain.value=f(l.wet),i.gain.value=f(l.dry)};return u(t),{input:n,output:o,update:u,automation:{wet:[{param:r.gain}],dry:[{param:i.gain}]},dispose:()=>[n,o,a,r,i].forEach(l=>l.disconnect())}},qe={"gain-node":Re,"biquad-peaking":H("peaking",!0),"biquad-lowshelf":H("lowshelf",!0),"biquad-highshelf":H("highshelf",!0),"biquad-highpass":H("highpass",!1),"biquad-lowpass":H("lowpass",!1),"worklet-compressor":M("hf-compressor"),"worklet-limiter":M("hf-limiter"),"worklet-truepeak":M("hf-truepeak",!0),"worklet-gate":M("hf-gate"),"worklet-bitcrush":M("hf-bitcrush"),"worklet-pitchshift":M("hf-pitchshift"),waveshaper:Ce,"delay-feedback":Le,"chorus-lfo":Se,"allpass-phaser":Be,convolver:Ie};function ie(e){return e.nodes.some(t=>P(t.type)?.web.startsWith("worklet-")??!1)}function Ge(e,t,n,o=0){let a=P(t);if(!a)throw new Error(`Unknown effect type: ${t}`);let r=y(t,n);if((t==="highpass"||t==="lowpass")&&String(r.poles)==="1")return Ee(t)(e,r,o);let i=qe[a.web];if(!i)throw new Error(`No Web Audio builder for ${a.web}`);return i(e,r,o)}function te(e){let t=[];for(let n of e){let o=n.fromPreset,a=t.at(-1);if(a&&a.preset===o)a.nodes.push(n);else{let r=typeof n.presetAmount=="number"?n.presetAmount:1;t.push({...o?{preset:o}:{},amount:Math.min(1,Math.max(0,r)),nodes:[n]})}}return t}function ne(e){return w(e).map(t=>{let n=y(t.type,t.params),o=n.poles!==void 0?`:${n.poles}`:"",a=String(n.poles)==="1"?`@${n.frequency}`:"",r=t.type==="phaser"?`~${n.type}`:"",i=t.fromPreset?`%${t.fromPreset}`:"",s=t.type==="truepeak"?`^${n.lookahead}`:"";return`${t.type}${o}${a}${r}${s}${i}`}).join("|")}function se(e,t,n=0){var p;let o=e.createGain(),a=e.createGain(),r=[],i=[],s=te(w(t)),u=o;for(let c of s){let b=null;if(c.preset){let d=e.createGain(),h=e.createGain(),g=e.createGain(),T=e.createGain();g.gain.value=c.amount,h.gain.value=1-c.amount,u.connect(d),d.connect(h).connect(T),b={entry:d,wet:g,dry:h,join:T},u=d}for(let d of c.nodes){let h=Ge(e,d.type,d.params??{},n);u.connect(h.input),u=h.output,r.push({...d.id?{id:d.id}:{},type:d.type,handle:h})}b&&c.preset&&(u.connect(b.wet).connect(b.join),i.push({id:c.preset,...b}),u=b.join)}u.connect(a);let l=ne(t),m={};for(let c of i)(m[p=c.id]??(m[p]=[])).push(...I(c.wet.gain,c.dry.gain));return{input:o,output:a,presets:m,nodes:r,update(c){if(ne(c)!==l)return!1;w(c).forEach((d,h)=>{let g=r[h];g&&(g.handle.update(y(d.type,d.params)),d.id===void 0?delete g.id:g.id=d.id)});let b=0;for(let d of te(w(c))){if(!d.preset)continue;let h=i[b++];!h||h.id!==d.preset||(h.wet.gain.value=d.amount,h.dry.gain.value=1-d.amount)}return!0},reset(){for(let{handle:c}of r)c.reset?.()},dispose(){for(let{handle:c}of r)c.dispose();for(let{entry:c,wet:b,dry:d,join:h}of i)c.disconnect(),b.disconnect(),d.disconnect(),h.disconnect();o.disconnect(),a.disconnect()}}}function Ue(e){return 10**(e/20)}var ue=Ue(12);var G=.1,U=10;var Ve="data-automation",Ut=Ve.slice(5),D=1,$e=512,A=class extends Error{constructor(t){super(t),this.name="AudioAutomationError"}},V="volume",le="rate";function N(e){if(e===V)return{kind:"volume"};if(e===le)return{kind:"rate"};let t=e.split(".");if(t.length===3&&t[0]==="fx"&&t[1]===je){let a=t[2];return a?{kind:"preset",presetId:a}:null}if(t.length!==3||t[0]!=="fx")return null;let[,n,o]=t;return!n||!o?null:{kind:"fx",nodeId:n,param:o}}function ce(e,t){return`fx.${e}.${t}`}var je="preset";var Xe={min:0,max:1,step:.01,unit:"",label:"Amount",scale:"linear",default:1},de={min:0,max:ue,step:.01,unit:"",label:"Volume",scale:"linear",default:1},me={min:G,max:U,step:.05,unit:"x",label:"Speed",scale:"log",default:1};function $(e,t){let n=N(e);if(!n)return null;if(n.kind==="volume")return de;if(n.kind==="rate")return me;if(n.kind==="preset")return t?.nodes.some(s=>s.fromPreset===n.presetId)?{...Xe,label:`${n.presetId} \\xB7 Amount`}:null;let o=t?.nodes.find(i=>i.id===n.nodeId);if(!o)return null;let a=P(o.type),r=a?.params.find(i=>i.key===n.param);return!r||r.kind!=="number"?null:{min:r.min,max:r.max,step:r.step,unit:r.unit,label:`${a?.label??o.type} \\xB7 ${r.label}`,scale:r.scale==="log"&&r.min>0?"log":"linear",default:r.default}}function _(e){if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="string"&&e.trim()!==""){let t=Number(e);return Number.isFinite(t)?t:null}return null}function We(e){let t=_(e);return t===null||t===0?0:Math.min(1,Math.max(-1,t))}function pe(e,t){let n=_(e),o=_(t);if(n===null||o===null)return null;let a=s=>Math.min(.999,Math.max(.001,s)),r=a(n),i=a(o);return Math.abs(r-i)<1e-6?null:{x:r,y:i}}function Ke(e){let t=We(e?.curve),n=pe(e?.viaX,e?.viaY);return{...t?{curve:t}:{},...n?{viaX:n.x,viaY:n.y}:{}}}function Ye(e,t){let n=_(e?.t),o=_(e?.v);if(n===null||o===null)return null;let a=t?Math.min(t.max,Math.max(t.min,o)):o;return{t:Math.max(0,n),v:a,...Ke(e)}}function he(e,t){let n=e.map(a=>Ye(a,t)).filter(a=>a!==null).sort((a,r)=>a.t-r.t),o=[];for(let a of n)o.length>0&&o[o.length-1].t===a.t?o[o.length-1]=a:o.push(a);return o.slice(0,$e)}function ze(e){let t=[];for(let n of e.lanes){if(!N(n.target))continue;let o=n.target===V?de:n.target===le?me:null,a=he(n.points??[],o);a.length>0&&t.push({target:n.target,points:a})}return{version:D,lanes:t}}function fe(e,t){let n=[];for(let o of e.lanes){let a=$(o.target,t);if(!a)continue;let r=he(o.points,a);r.length>0&&n.push({target:o.target,points:r})}return{version:D,lanes:n}}function be(e){let t;try{t=JSON.parse(e)}catch(a){throw new A(`Automation is not valid JSON: ${a.message}`)}if(typeof t!="object"||t===null)throw new A("Automation must be a JSON object.");let n=t;if(n.version!==D)throw new A(`Unsupported automation version: ${String(n.version)}`);if(!Array.isArray(n.lanes))throw new A("Automation is missing a `lanes` array.");let o=n.lanes.map((a,r)=>{if(typeof a!="object"||a===null)throw new A(`Lane ${r} is not an object.`);let i=a;if(typeof i.target!="string"||!N(i.target))throw new A(`Lane ${r} has an unreadable target: ${String(i.target)}`);if(!Array.isArray(i.points))throw new A(`Lane ${r} is missing a \\`points\\` array.`);return{target:i.target,points:i.points}});return ze({version:D,lanes:o})}function Je(e,t){return t?Math.pow(e,Math.pow(2,2*t)):e}function Qe(e,t){let n=e-.5,o=t-.5,a=.999,r=1e6,i=n>0?n/(a-e):n<0?-n/(e-(1-a)):0,s=o>0?o/(a-t):o<0?-o/(t-(1-a)):0,u=Math.min(r,Math.max(1,i,s));return{cx:e+n/u,cy:t+o/u,w:u}}function Ze(e,t,n){let{cx:o,cy:a,w:r}=Qe(t,n),i=2-2*r,s=e*i-1+2*r*o,u=-e*i-2*r*o,l=et(s,u,e),m=1-l,p=m*m+2*r*l*m+l*l;return p>0?(2*r*a*l*m+l*l)/p:e}function et(e,t,n){if(Math.abs(e)<1e-12)return Math.abs(t)<1e-12?n:-n/t;let o=Math.sqrt(Math.max(0,t*t-4*e*n)),a=(-t+o)/(2*e),r=(-t-o)/(2*e),i=s=>s>=-1e-9&&s<=1+1e-9;return i(a)?Math.min(1,Math.max(0,a)):i(r)?Math.min(1,Math.max(0,r)):n}function tt(e,t){let n=pe(t.viaX,t.viaY);return n?Ze(Math.min(1,Math.max(0,e)),n.x,n.y):Je(e,t.curve)}function nt(e,t,n,o){return o==="log"&&e>0&&t>0?Math.exp(Math.log(e)+(Math.log(t)-Math.log(e))*n):e+(t-e)*n}function j(e,t,n="linear"){let o=e.points;if(o.length===0)return 0;let a=o[0];if(t<=a.t)return a.v;let r=o[o.length-1];if(t>=r.t)return r.v;let i=0,s=o.length-1;for(;s-i>1;){let p=i+s>>1;o[p].t<=t?i=p:s=p}let u=o[i],l=o[s],m=l.t-u.t;return m<=0?l.v:nt(u.v,l.v,tt((t-u.t)/m,u),n)}function ge(e){return e.points.length<=1||e.points.every(t=>t.v===e.points[0].v)}function Ae(e,t,n,o,a="linear"){let r=Math.max(2,Math.floor(o)),i=new Float32Array(r),s=n-t;for(let u=0;u<r;u+=1)i[u]=j(e,t+s*u/(r-1),a);return i}var at=100,ot=8,rt=4096,X=e=>e;function it(e,t,n){return!(!!e.curve||e.viaX!==void 0&&e.viaY!==void 0)&&t==="linear"&&!n}function st(e){let t=Math.ceil(e*at);return Math.min(rt,Math.max(ot,t))}function ut(e,t,n,o,a){let{scheduledAt:r,elapsed:i,rate:s}=o,u=a??X,l=v=>r+(v-i)/s,m=e.points[t],p=e.points[t+1],c=l(p.t);if(c<=r)return null;let b=Math.max(r,l(m.t)),d=c-b;if(d<=0)return null;if(it(m,n,a))return{kind:"ramp",time:c,value:u(p.v)};let h=st(d),g=Ae(e,Math.max(m.t,i),p.t,h,n),T=new Float32Array(h);for(let v=0;v<h;v+=1)T[v]=u(g[v]??0);return{kind:"curve",time:b,duration:d,values:T}}function lt(e,t,n,o){let a=[];for(let i=0;i+1<e.points.length;i+=1){let s=ut(e,i,t,n,o);s&&a.push(s)}let r=a[0];return r?.kind==="curve"&&r.time<=n.scheduledAt||a.unshift({kind:"set",time:n.scheduledAt,value:(o??X)(j(e,n.elapsed,t))}),a}function ct(e,t){for(let n of t)if(n.kind==="set")e.setValueAtTime(n.value,n.time);else if(n.kind==="ramp")e.linearRampToValueAtTime(n.value,n.time);else try{e.setValueCurveAtTime(n.values,n.time,n.duration)}catch{let o=n.values[n.values.length-1]??0;e.linearRampToValueAtTime(o,n.time+n.duration)}}function dt(e){for(let t of e)t.param.cancelScheduledValues(0)}function mt(e,t,n,o){if(t.points.length!==0)for(let a of e){if(dt([a]),ge(t)){let r=(a.map??X)(t.points[0].v);a.param.setValueAtTime(r,o.scheduledAt);continue}ct(a.param,lt(t,n,o,a.map))}}function xe(e,t,n,o,a){let r=new Map(n.filter(s=>s.id).map(s=>[s.id,s.handle])),i=[];for(let s of e.lanes){let u=N(s.target);if(!u)continue;let l=u.kind==="preset"?a?.[u.presetId]:u.kind==="fx"?r.get(u.nodeId)?.automation?.[u.param]:void 0;if(!l||l.length===0)continue;let m=$(s.target,t);m&&(mt(l,s,m.scale,o),i.push(...l))}return i}var pt=5,ht=.001;function k(e,t,n){let o=Number(y(e.type,e.params)[t]??0);if(!e.id||!n)return Number.isFinite(o)?o:0;let a=n.lanes.find(r=>r.target===ce(e.id??"",t));return!a||a.points.length===0?Number.isFinite(o)?o:0:a.points.reduce((r,i)=>Math.max(r,i.v),-1/0)}function ft(e,t){let n=Math.min(5,e/1e3);if(n<=0)return 0;let o=Math.max(0,Math.min(.999,t));return o<=0?n:Math.ceil(Math.log(ht)/Math.log(o))*n}function bt(e){return .6+Math.max(0,Math.min(1,e))*2.6}function gt(e,t){return k(e,"wet",t)>0?bt(k(e,"size",t)):0}function At(e,t){return k(e,"mix",t)>0?ft(k(e,"time",t),k(e,"feedback",t)):0}function xt(e,t){return k(e,"mix",t)>0?k(e,"delay",t)/1e3:0}function yt(e,t){return k(e,"mix",t)>0?.2:0}function kt(e,t){if(e.enabled===!1)return 0;switch(e.type){case"reverb":return gt(e,t);case"delay":return At(e,t);case"chorus":return xt(e,t);case"pitchshift":return yt(e,t);default:return 0}}function ye(e,t){let n=e.nodes.reduce((o,a)=>o+kt(a,t),0);return Math.min(pt,n)}function ke(e,t){return w(e).filter(n=>n.type==="truepeak").reduce((n,o)=>{let{lookahead:a}=y(o.type,o.params);return n+Q(Number(a),t)},0)}function wt(e,t,n,o,a){let r=e.createBuffer(n,o,a);for(let i=0;i<n;i++){let s=t[i];s&&r.getChannelData(i).set(s)}return r}function vt(e,t){let n=[];for(let o=0;o<e.numberOfChannels;o++)n.push(new Float32Array(e.getChannelData(o).subarray(t)));return n}async function Mt(e,t,n,o,a=0){let r=J(n),i=Math.max(1,e.length),s=e[0]?.length??0;if(s===0)return e;let u=o?fe(be(o),r):null,l=Math.ceil(ye(r,u??void 0)*t),m=ke(r,t),p=s+l+m,c=new OfflineAudioContext(i,p,t);ie(r)&&await O(c);let b=c.createBufferSource();b.buffer=wt(c,e,i,p,t);let d=se(c,r,a);return u&&xe(u,r,d.nodes,{scheduledAt:0,elapsed:0,rate:1},d.presets),b.connect(d.input),d.output.connect(c.destination),b.start(),vt(await c.startRendering(),m)}window.__HF_AUDIO_FX={render:Mt};})();\n';
|
|
14511
|
+
var AUDIO_FX_RUNTIME_IIFE = '"use strict";(()=>{var we="data-fx-chain",Ft=we.slice(5),W=1,F=(e="frequency",t="Frequency",n=1e3,o=20,a=2e4)=>({kind:"number",key:e,label:t,unit:"Hz",min:o,max:a,step:1,default:n,scale:"log",automatable:!0}),C=(e=.707,t="Bandwidth: higher is narrower.")=>({kind:"number",key:"q",label:"Q",unit:"",min:.1,max:20,step:.01,default:e,scale:"log",automatable:!0,hint:t}),N=(e=-40,t=40,n=0)=>({kind:"number",key:"gain",label:"Gain",unit:"dB",min:e,max:t,step:.1,default:n,automatable:!0}),K={kind:"enum",key:"poles",label:"Slope",options:[{value:"1",label:"6 dB/oct"},{value:"2",label:"12 dB/oct"}],default:"2",hint:"Two poles is the usual biquad; one pole is gentler."},z=[{id:"gain",label:"Gain",group:"dynamics",description:"Raise or lower the whole signal. Automate it to duck under something else.",params:[N(-60,12,0)],web:"gain-node"},{id:"peaking",label:"Peaking EQ",group:"filter",description:"Boost or cut a band, leaving everything either side alone.",params:[F("frequency","Frequency",1e3),N(-40,40,0),C(1)],web:"biquad-peaking"},{id:"lowshelf",label:"Low Shelf",group:"filter",description:"Lift or drop everything below the corner frequency.",params:[F("frequency","Frequency",200,20,2e3),N(-40,40,0)],web:"biquad-lowshelf"},{id:"highshelf",label:"High Shelf",group:"filter",description:"Lift or drop everything above the corner frequency.",params:[F("frequency","Frequency",4e3,500,2e4),N(-40,40,0)],web:"biquad-highshelf"},{id:"highpass",label:"High-pass",group:"filter",description:"Remove low frequencies: the usual fix for rumble on a voice.",params:[F("frequency","Cutoff",300,20,2e4),C(.707),K],web:"biquad-highpass"},{id:"lowpass",label:"Low-pass",group:"filter",description:"Remove high frequencies, which darkens or muffles a track.",params:[F("frequency","Cutoff",8e3,100,2e4),C(.707),K],web:"biquad-lowpass"},{id:"compressor",label:"Compressor",group:"dynamics",description:"Pull loud parts down so the quiet ones can come up.",params:[{kind:"number",key:"threshold",label:"Threshold",unit:"dB",min:-60,max:0,step:.5,default:-24,hint:"Level above which the compressor starts working."},{kind:"number",key:"ratio",label:"Ratio",unit:":1",min:1,max:20,step:.1,default:4},{kind:"number",key:"attack",label:"Attack",unit:"ms",min:.01,max:2e3,step:.1,default:20,scale:"log"},{kind:"number",key:"release",label:"Release",unit:"ms",min:.01,max:9e3,step:1,default:250,scale:"log"},{kind:"number",key:"knee",label:"Knee",unit:"",min:1,max:8,step:.01,default:2.83,hint:"1 is a hard corner; higher eases into it."},{kind:"number",key:"makeup",label:"Makeup",unit:"dB",min:0,max:36,step:.1,default:0},{kind:"number",key:"mix",label:"Mix",unit:"",min:0,max:1,step:.01,default:1,hint:"Below 1 blends the dry signal back in."}],web:"worklet-compressor"},{id:"limiter",label:"Limiter",group:"dynamics",description:"Peak limiter that follows the signal\'s level. It has no lookahead, so a fast peak or an inter-sample peak can pass the ceiling; use the true-peak limiter for a delivery limit.",params:[{kind:"number",key:"limit",label:"Ceiling",unit:"dB",min:-24,max:0,step:.1,default:-1},{kind:"number",key:"attack",label:"Attack",unit:"ms",min:.1,max:80,step:.1,default:5},{kind:"number",key:"release",label:"Release",unit:"ms",min:1,max:8e3,step:1,default:50,scale:"log"},{kind:"number",key:"level_out",label:"Output",unit:"dB",min:-24,max:24,step:.1,default:0}],web:"worklet-limiter"},{id:"truepeak",label:"True-peak limiter",group:"dynamics",description:"Lookahead limiter that holds a 4x estimate of the inter-sample peak at a dBTP ceiling; full-band noise can land up to about 1.7 dB above it. Adds lookahead plus about 0.3 ms of latency.",params:[{kind:"number",key:"ceiling",label:"Ceiling",unit:"dBTP",min:-24,max:0,step:.1,default:-1,hint:"Target true peak, measured on a 4x oversampled signal. Dense full-band sound can end up to about 1.7 dB above it."},{kind:"number",key:"lookahead",label:"Lookahead",unit:"ms",min:.5,max:10,step:.1,default:3,hint:"How far ahead the gain starts falling. Longer is smoother and adds the same latency."},{kind:"number",key:"release",label:"Release",unit:"ms",min:10,max:2e3,step:1,default:80,scale:"log"}],web:"worklet-truepeak"},{id:"gate",label:"Noise Gate",group:"dynamics",description:"Silence the track when it drops below the threshold.",params:[{kind:"number",key:"threshold",label:"Threshold",unit:"dB",min:-80,max:0,step:.5,default:-35},{kind:"number",key:"range",label:"Range",unit:"dB",min:-80,max:0,step:.5,default:-24,hint:"How far down the gate pulls when closed."},{kind:"number",key:"ratio",label:"Ratio",unit:":1",min:1,max:20,step:.1,default:10},{kind:"number",key:"attack",label:"Attack",unit:"ms",min:.01,max:9e3,step:.1,default:1,scale:"log"},{kind:"number",key:"release",label:"Release",unit:"ms",min:.01,max:9e3,step:1,default:100,scale:"log"},{kind:"number",key:"knee",label:"Knee",unit:"",min:1,max:8,step:.01,default:2.83}],web:"worklet-gate"},{id:"saturate",label:"Saturation",group:"nonlinear",description:"Soft-clip the waveform for warmth or outright distortion.",params:[{kind:"enum",key:"type",label:"Curve",options:[{value:"tanh",label:"Tanh"},{value:"atan",label:"Arctan"},{value:"cubic",label:"Cubic"},{value:"exp",label:"Exponential"},{value:"alg",label:"Algebraic"},{value:"quintic",label:"Quintic"},{value:"sin",label:"Sine"},{value:"erf",label:"Error function"},{value:"hard",label:"Hard clip"}],default:"tanh"},{kind:"number",key:"threshold",label:"Threshold",unit:"dB",min:-40,max:0,step:.1,default:-6},{kind:"number",key:"output",automatable:!0,label:"Output",unit:"dB",min:-24,max:24,step:.1,default:0},{kind:"number",key:"oversample",label:"Oversample",unit:"x",min:1,max:8,step:1,default:4,hint:"Higher costs more but keeps aliasing down."}],web:"waveshaper"},{id:"bitcrush",label:"Bitcrush",group:"nonlinear",description:"Drop bit depth and sample rate for a lo-fi, digital sound.",params:[{kind:"number",key:"bits",label:"Bit depth",unit:"bit",min:1,max:32,step:.1,default:8},{kind:"number",key:"samples",label:"Sample hold",unit:"x",min:1,max:250,step:1,default:1,hint:"Repeats each sample N times, a crude downsample."},{kind:"number",key:"mix",label:"Mix",unit:"",min:0,max:1,step:.01,default:1}],web:"worklet-bitcrush"},{id:"pitchshift",label:"Pitch shift",group:"time",description:"Shifts pitch up or down without changing playback speed. Adds ~50 ms of latency.",params:[{kind:"number",key:"semitones",label:"Semitones",unit:"st",min:-12,max:12,step:1,default:0},{kind:"number",key:"mix",label:"Mix",unit:"",min:0,max:1,step:.01,default:1}],web:"worklet-pitchshift"},{id:"delay",label:"Delay",group:"time",description:"Repeating echoes behind the dry signal.",params:[{kind:"number",key:"time",automatable:!0,label:"Time",unit:"ms",min:1,max:5e3,step:1,default:250,scale:"log"},{kind:"number",key:"feedback",automatable:!0,label:"Feedback",unit:"",min:.01,max:.95,step:.01,default:.35},{kind:"number",key:"mix",automatable:!0,label:"Mix",unit:"",min:0,max:1,step:.01,default:.4}],web:"delay-feedback"},{id:"chorus",label:"Chorus",group:"time",description:"Detuned copies of the signal for width and thickness.",params:[{kind:"number",key:"delay",automatable:!0,label:"Delay",unit:"ms",min:1,max:100,step:.1,default:7},{kind:"number",key:"depth",automatable:!0,label:"Depth",unit:"ms",min:0,max:10,step:.01,default:2},{kind:"number",key:"speed",automatable:!0,label:"Rate",unit:"Hz",min:.01,max:10,step:.01,default:1},{kind:"number",key:"mix",automatable:!0,label:"Mix",unit:"",min:0,max:1,step:.01,default:.5}],web:"chorus-lfo"},{id:"phaser",label:"Phaser",group:"time",description:"Sweeping notches moving through the spectrum.",params:[{kind:"number",key:"in_gain",automatable:!0,label:"Input",unit:"",min:0,max:1,step:.01,default:.4},{kind:"number",key:"out_gain",automatable:!0,label:"Output",unit:"",min:0,max:2,step:.01,default:.74},{kind:"number",key:"delay",label:"Delay",unit:"ms",min:.1,max:5,step:.1,default:3},{kind:"number",key:"decay",label:"Decay",unit:"",min:0,max:.99,step:.01,default:.4},{kind:"number",key:"speed",automatable:!0,label:"Rate",unit:"Hz",min:.1,max:2,step:.01,default:.5},{kind:"enum",key:"type",label:"Waveform",options:[{value:"0",label:"Triangular"},{value:"1",label:"Sinusoidal"}],default:"0"}],web:"allpass-phaser"},{id:"reverb",label:"Reverb",group:"time",description:"Room tail. Both ends convolve the same generated impulse, so preview matches render.",params:[{kind:"number",key:"size",label:"Room size",unit:"",min:.05,max:1,step:.01,default:.7},{kind:"number",key:"damping",label:"Damping",unit:"",min:0,max:1,step:.01,default:.5,hint:"Higher rolls the top off the tail faster."},{kind:"number",key:"wet",automatable:!0,label:"Wet",unit:"",min:0,max:1,step:.01,default:.35},{kind:"number",key:"dry",automatable:!0,label:"Dry",unit:"",min:0,max:1,step:.01,default:.7}],web:"convolver"}],S=new Map(z.map(e=>[e.id,e]));function P(e){return S.get(e)}var Pt=z.map(e=>e.id);function y(e,t){let n=S.get(e);if(!n)return{};let o={};for(let a of n.params){let r=t?.[a.key];if(a.kind==="enum"){let s=a.options.some(u=>u.value===r);o[a.key]=s?r:a.default;continue}let i=typeof r=="number"?r:typeof r=="string"&&r.trim()!==""?Number(r):Number.NaN;o[a.key]=Number.isFinite(i)?Math.min(a.max,Math.max(a.min,i)):a.default}return o}var x=class extends Error{constructor(t){super(t),this.name="AudioFxChainError"}};function J(e){let t;try{t=JSON.parse(e)}catch(a){throw new x(`Chain file is not valid JSON: ${a.message}`)}if(typeof t!="object"||t===null)throw new x("Chain file must be a JSON object.");let n=t;if(n.version!==W)throw new x(`Unsupported chain version: ${String(n.version)}`);if(!Array.isArray(n.nodes))throw new x("Chain file is missing a `nodes` array.");let o=n.nodes.map(ve);return{version:W,nodes:o}}function w(e){return e.nodes.filter(t=>t.enabled!==!1)}function ve(e,t){if(typeof e!="object"||e===null)throw new x(`Node ${t} is not an object.`);let n=e;if(typeof n.type!="string"||!S.has(n.type))throw new x(`Node ${t} has unknown effect type: ${String(n.type)}`);return Te({type:n.type,id:E(n.id),fromCarve:Y(n.fromCarve),fromPreset:E(n.fromPreset),label:E(n.label),fromEq:E(n.fromEq),fromLeveller:Y(n.fromLeveller),presetAmount:Me(n.presetAmount),enabled:n.enabled!==!1,params:y(n.type,n.params??void 0)})}function E(e){return typeof e=="string"&&e?e:void 0}function Y(e){return e===!0?!0:void 0}function Me(e){if(!(typeof e!="number"||!Number.isFinite(e)))return Math.min(1,Math.max(0,e))}function Te(e){for(let t of Object.keys(e))e[t]===void 0&&delete e[t];return e}function Fe(e,t){return Math.max(1,Math.round(e*t/1e3))}function Q(e,t){return Fe(e,t)+16}var Z=`\nconst TP_OS = 4;\nconst TP_HALF = 64;\nconst TP_BRANCH = 33;\nconst TP_DELAY = 16;\n\nfunction besselI0(x) {\n let sum = 1, term = 1;\n for (let k = 1; k < 40; k++) {\n term *= (x / (2 * k)) * (x / (2 * k));\n sum += term;\n }\n return sum;\n}\n\n/** Kaiser-windowed sinc, one array per polyphase branch, newest tap first. */\nfunction tpBranches() {\n const beta = 6;\n const norm = besselI0(beta);\n const branches = [];\n for (let p = 0; p < TP_OS; p++) {\n const taps = new Float64Array(TP_BRANCH);\n let sum = 0;\n for (let j = 0; j < TP_BRANCH; j++) {\n const k = p + TP_OS * j;\n if (k > 2 * TP_HALF) continue;\n const t = (k - TP_HALF) / TP_OS;\n const sinc = t === 0 ? 1 : Math.sin(Math.PI * t) / (Math.PI * t);\n const r = (k - TP_HALF) / TP_HALF;\n taps[j] = sinc * (besselI0(beta * Math.sqrt(Math.max(0, 1 - r * r))) / norm);\n sum += taps[j];\n }\n // Unity gain at DC on every branch, so a steady level reads as itself.\n for (let j = 0; j < TP_BRANCH; j++) taps[j] /= sum;\n branches.push(taps);\n }\n return branches;\n}\n\nclass HfTruePeak extends AudioWorkletProcessor {\n constructor(o) {\n super();\n this.p = o.processorOptions || {};\n this.look = Math.max(1, Math.round((this.p.lookahead ?? 3) * sampleRate / 1000));\n this.delayLen = this.look + TP_DELAY;\n this.branches = tpBranches();\n this.setLevels();\n this.clear();\n this.port.onmessage = (e) => {\n if (e.data && e.data.__hfDispose) { this.dead = true; return; }\n if (e.data && e.data.__hfReset) { this.clear(); return; }\n this.p = { ...this.p, ...e.data };\n this.setLevels();\n };\n }\n /** Back to the state of a fresh processor: no audio in the delay line, no gain reduction. */\n clear() {\n this.ch = [];\n this.rel = 1;\n this.dqIdx = new Int32Array(this.look + 2);\n this.dqVal = new Float64Array(this.look + 2);\n this.dqHead = 0;\n this.dqTail = 0;\n this.t = 0;\n this.avgRing = new Float64Array(this.look + 1).fill(1);\n this.avgPos = 0;\n this.avgSum = this.look + 1;\n }\n setLevels() {\n this.ceiling = Math.pow(10, (this.p.ceiling ?? -1) / 20);\n this.relCoef = 1 - Math.exp(-1 / (sampleRate * Math.max(1e-4, (this.p.release ?? 80) / 1000)));\n }\n channel(c) {\n if (!this.ch[c]) {\n this.ch[c] = {\n delay: new Float32Array(this.delayLen),\n w: 0,\n hist: new Float32Array(TP_BRANCH * 2),\n pos: 0,\n };\n }\n return this.ch[c];\n }\n /** Largest interpolated magnitude across channels for the newest sample. */\n peak(chans, inputs, n) {\n let peak = 0;\n for (let c = 0; c < chans; c++) {\n const s = this.channel(c);\n const x = inputs[c][n];\n s.pos = (s.pos + 1) % TP_BRANCH;\n s.hist[s.pos] = x;\n s.hist[s.pos + TP_BRANCH] = x;\n const base = s.pos + TP_BRANCH;\n for (let p = 0; p < TP_OS; p++) {\n const taps = this.branches[p];\n let acc = 0;\n for (let j = 0; j < TP_BRANCH; j++) acc += taps[j] * s.hist[base - j];\n const a = acc < 0 ? -acc : acc;\n if (a > peak) peak = a;\n }\n }\n return peak;\n }\n /** Windowed minimum of the required gain over the last look + 1 values. */\n windowMin(v) {\n const cap = this.dqIdx.length;\n while (this.dqTail !== this.dqHead && this.dqVal[(this.dqTail + cap - 1) % cap] >= v) {\n this.dqTail = (this.dqTail + cap - 1) % cap;\n }\n this.dqIdx[this.dqTail] = this.t;\n this.dqVal[this.dqTail] = v;\n this.dqTail = (this.dqTail + 1) % cap;\n while (this.dqIdx[this.dqHead] <= this.t - (this.look + 1)) {\n this.dqHead = (this.dqHead + 1) % cap;\n }\n this.t++;\n return this.dqVal[this.dqHead];\n }\n process(inputs, outputs) {\n if (this.dead) return false;\n const i = inputs[0], o = outputs[0];\n if (!i || !i.length) return true;\n const chans = i.length;\n const frames = i[0].length;\n for (let n = 0; n < frames; n++) {\n const peak = this.peak(chans, i, n);\n const need = peak > this.ceiling ? this.ceiling / peak : 1;\n const m = this.windowMin(need);\n this.avgSum += m - this.avgRing[this.avgPos];\n this.avgRing[this.avgPos] = m;\n this.avgPos = (this.avgPos + 1) % this.avgRing.length;\n const target = Math.min(1, this.avgSum / this.avgRing.length);\n const released = this.rel + (1 - this.rel) * this.relCoef;\n this.rel = released < target ? released : target;\n if (target >= 1 && this.rel > 0.9999999) this.rel = 1;\n for (let c = 0; c < chans; c++) {\n const s = this.channel(c);\n o[c][n] = s.delay[s.w] * this.rel;\n s.delay[s.w] = i[c][n];\n s.w = (s.w + 1) % this.delayLen;\n }\n }\n return true;\n }\n}\nregisterProcessor("hf-truepeak", HfTruePeak);\n`;var Pe=`\nconst dbToLin = (db) => Math.pow(10, db / 20);\n\n/**\n * One-pole envelope followers, one per channel.\n *\n * Per channel matters: the followers advance once per sample, so a single shared\n * follower stepped once per channel per sample. On stereo that ran a 20 ms attack\n * as 10 ms, and gave the right channel a gain computed from an envelope that had\n * already traversed the left, so the two channels ducked by different amounts\n * from the same input and the image pumped.\n */\nclass EnvBank {\n constructor(attackMs, releaseMs) { this.set(attackMs, releaseMs); this.values = []; }\n set(attackMs, releaseMs) {\n this.a = Math.exp(-1 / (sampleRate * Math.max(1e-5, attackMs / 1000)));\n this.r = Math.exp(-1 / (sampleRate * Math.max(1e-5, releaseMs / 1000)));\n }\n push(ch, x) {\n const prev = this.values[ch] ?? 0;\n const m = Math.abs(x);\n const c = m > prev ? this.a : this.r;\n const next = m + c * (prev - m);\n this.values[ch] = next;\n return next;\n }\n}\n\n/** Soft-knee gain computer in dB, matching acompressor\'s shape. */\nfunction kneeGain(envDb, thresholdDb, ratio, kneeDb) {\n const over = envDb - thresholdDb;\n if (kneeDb > 0 && over > -kneeDb && over < kneeDb) {\n const t = (over + kneeDb) / (2 * kneeDb);\n return -((1 - 1 / ratio) * kneeDb * t * t);\n }\n return over > 0 ? -(over * (1 - 1 / ratio)) : 0;\n}\n\n// log10/exp per sample is the single most expensive thing a dynamics processor\n// can do on the audio thread, and every sample below the knee needs neither:\n// its gain is exactly unity. Comparing envelopes in the linear domain lets the\n// quiet majority of samples skip the transcendentals entirely.\nconst LN10_OVER_20 = Math.LN10 / 20;\nconst dbToLinFast = (db) => Math.exp(db * LN10_OVER_20);\n\nclass HfCompressor extends AudioWorkletProcessor {\n constructor(o) {\n super();\n this.p = o.processorOptions || {};\n this.env = new EnvBank(this.p.attack ?? 20, this.p.release ?? 250);\n this.port.onmessage = (e) => {\n if (e.data && e.data.__hfDispose) { this.dead = true; return; }\n this.p = { ...this.p, ...e.data };\n this.env.set(this.p.attack ?? 20, this.p.release ?? 250);\n };\n }\n process(inputs, outputs) {\n if (this.dead) return false;\n const i = inputs[0], o = outputs[0];\n if (!i || !i.length) return true;\n const p = this.p;\n const makeup = dbToLin(p.makeup ?? 0);\n const mix = p.mix ?? 1;\n // Knee is expressed as a ratio in FFmpeg; convert to dB width.\n const kneeDb = 20 * Math.log10(Math.max(1.0001, p.knee ?? 2.83));\n const thresholdDb = p.threshold ?? -24;\n const ratio = p.ratio ?? 4;\n // Below this the gain computer returns unity, so the sample needs no\n // logarithm at all.\n const kneeStartLin = dbToLin(thresholdDb - kneeDb);\n const dry = 1 - mix;\n for (let ch = 0; ch < i.length; ch++) {\n const inp = i[ch], out = o[ch];\n for (let n = 0; n < inp.length; n++) {\n const x = inp[n];\n // Per-channel follower, and the sub-knee shortcut: below the knee the\n // gain is exactly unity, so the sample needs no logarithm at all.\n const env = this.env.push(ch, x);\n if (env <= kneeStartLin) {\n out[n] = x * makeup * mix + x * dry;\n continue;\n }\n const envDb = 20 * Math.log10(env);\n const g = dbToLinFast(kneeGain(envDb, thresholdDb, ratio, kneeDb));\n out[n] = x * g * makeup * mix + x * dry;\n }\n }\n return true;\n }\n}\nregisterProcessor("hf-compressor", HfCompressor);\n\nclass HfLimiter extends AudioWorkletProcessor {\n constructor(o) {\n super();\n this.p = o.processorOptions || {};\n this.env = new EnvBank(this.p.attack ?? 5, this.p.release ?? 50);\n this.port.onmessage = (e) => {\n if (e.data && e.data.__hfDispose) { this.dead = true; return; }\n this.p = { ...this.p, ...e.data };\n this.env.set(this.p.attack ?? 5, this.p.release ?? 50);\n };\n }\n process(inputs, outputs) {\n if (this.dead) return false;\n const i = inputs[0], o = outputs[0];\n if (!i || !i.length) return true;\n const ceiling = dbToLin(this.p.limit ?? -1);\n const outGain = dbToLin(this.p.level_out ?? 0);\n for (let ch = 0; ch < i.length; ch++) {\n const inp = i[ch], out = o[ch];\n for (let n = 0; n < inp.length; n++) {\n const x = inp[n];\n const env = this.env.push(ch, x);\n // Only ever attenuate: a limiter that can raise level is a compressor.\n const g = env > ceiling ? ceiling / env : 1;\n out[n] = x * g * outGain;\n }\n }\n return true;\n }\n}\nregisterProcessor("hf-limiter", HfLimiter);\n\nclass HfGate extends AudioWorkletProcessor {\n constructor(o) {\n super();\n this.p = o.processorOptions || {};\n this.env = new EnvBank(this.p.attack ?? 1, this.p.release ?? 100);\n this.gains = [];\n this.port.onmessage = (e) => {\n if (e.data && e.data.__hfDispose) { this.dead = true; return; }\n this.p = { ...this.p, ...e.data };\n this.env.set(this.p.attack ?? 1, this.p.release ?? 100);\n };\n }\n process(inputs, outputs) {\n if (this.dead) return false;\n const i = inputs[0], o = outputs[0];\n if (!i || !i.length) return true;\n const p = this.p;\n const threshold = dbToLin(p.threshold ?? -35);\n const floor = dbToLin(p.range ?? -24);\n const ratio = p.ratio ?? 10;\n // Knee is declared in the registry as a ratio, like the compressor\'s; a\n // hard threshold ignored it and chattered on material sitting right at the\n // gate point.\n const kneeDb = 20 * Math.log10(Math.max(1.0001, p.knee ?? 2.83));\n const kneeLin = dbToLin((p.threshold ?? -35) + kneeDb);\n for (let ch = 0; ch < i.length; ch++) {\n const inp = i[ch], out = o[ch];\n for (let n = 0; n < inp.length; n++) {\n const x = inp[n];\n const env = this.env.push(ch, x);\n let target = 1;\n // Above the threshold the gate is fully open; skip the pow entirely.\n if (env < threshold) {\n const under = env > 1e-9 ? threshold / env : 1e9;\n target = Math.max(floor, 1 / Math.pow(under, ratio - 1));\n if (!isFinite(target)) target = floor;\n }\n // Smooth toward the target so the gate does not click on every sample.\n const held = this.gains[ch] ?? 1;\n const c = target < held ? this.env.r : this.env.a;\n const smoothed = target + c * (held - target);\n this.gains[ch] = smoothed;\n out[n] = x * smoothed;\n }\n }\n return true;\n }\n}\nregisterProcessor("hf-gate", HfGate);\n\nclass HfBitcrush extends AudioWorkletProcessor {\n constructor(o) {\n super();\n this.p = o.processorOptions || {};\n this.holds = [];\n this.held = [];\n this.start = Math.round((this.p.__hfElapsed ?? 0) * sampleRate);\n this.port.onmessage = (e) => {\n if (e.data && e.data.__hfDispose) { this.dead = true; return; }\n this.p = { ...this.p, ...e.data };\n };\n }\n process(inputs, outputs) {\n if (this.dead) return false;\n const i = inputs[0], o = outputs[0];\n if (!i || !i.length) return true;\n const p = this.p;\n const levels = Math.pow(2, (p.bits ?? 8) - 1);\n const step = Math.max(1, Math.round(p.samples ?? 1));\n const mix = p.mix ?? 1;\n for (let ch = 0; ch < i.length; ch++) {\n const inp = i[ch], out = o[ch];\n // Primed from the input: a counter seeded mid-hold would otherwise play 0 until it wraps.\n if (this.held[ch] === undefined) this.held[ch] = Math.round(inp[0] * levels) / levels;\n // The hold counter runs from the file\'s first sample, so a node built part-way in starts where it would be.\n if (this.holds[ch] === undefined) this.holds[ch] = this.start % step;\n for (let n = 0; n < inp.length; n++) {\n // Per channel: advancing one shared counter only on the last channel\n // left every earlier channel either unheld or frozen for a whole\n // 128-sample quantum, clicking once a block.\n if (this.holds[ch] === 0) this.held[ch] = Math.round(inp[n] * levels) / levels;\n out[n] = this.held[ch] * mix + inp[n] * (1 - mix);\n this.holds[ch] = (this.holds[ch] + 1) % step;\n }\n }\n return true;\n }\n}\nregisterProcessor("hf-bitcrush", HfBitcrush);\n\n/** Linear-interpolated read, \\`delaySamples\\` behind the write head. */\nfunction readTap(ring, write, delaySamples) {\n const len = ring.length;\n const pos = (write - 1 - delaySamples + len) % len;\n const i0 = Math.floor(pos);\n const frac = pos - i0;\n const i1 = (i0 + 1) % len;\n return ring[i0] * (1 - frac) + ring[i1] * frac;\n}\n\n/** Equal-power-ish crossfade, zero at a tap\'s reset point, which hides the splice. */\nfunction xfade(phase) {\n return Math.sin(Math.PI * phase);\n}\n\n/**\n * Dual-tap granular delay line: two read taps 180\\xB0 apart in a 100 ms grain,\n * each sweeping at a speed relative to the write head that shifts pitch\n * without changing duration. One tap is always fading in as the other fades\n * out, which hides the splice each tap makes when it wraps.\n *\n * write/phase are block-level state, advanced once per SAMPLE across all\n * channels together (not once per channel). Advancing them inside the\n * per-channel loop would move the tap 2x/4x too fast on a stereo/quad input.\n */\nclass HfPitchshift extends AudioWorkletProcessor {\n constructor(o) {\n super();\n this.p = o.processorOptions || {};\n this.grain = Math.round(sampleRate * 0.1);\n this.buf = [];\n this.write = 0;\n // The taps sweep at a constant rate from the start of the file, so a node built\n // part-way in joins the sweep where it would already be.\n const ratio0 = Math.pow(2, Math.max(-12, Math.min(12, this.p.semitones ?? 0)) / 12);\n const turns = (this.p.__hfElapsed ?? 0) * sampleRate * ((1 - ratio0) / this.grain);\n this.phase = turns - Math.floor(turns);\n // Samples written so far, capped at one grain. The taps read up to a grain\n // behind the write head, so until this fills they would read the ring\'s\n // zeros, so the head of every clip came out attenuated or silent.\n this.filled = 0;\n // How much of the wet (pitch-shifted) path is currently in the output, and\n // where it is heading. Crossing between dry and wet is a ~50 ms jump in the\n // signal, so it is RAMPED rather than switched: a hard swap either way is a\n // click. Ramping in both directions is also what lets a node return to true\n // bypass at semitones 0. A one-way latch left preview stuck with the delay\n // that the render, building a fresh node from the attribute, does not have.\n this.wet = 0;\n this.wetTarget = 0;\n // ~15 ms one-pole, short enough to feel immediate on a slider drag and long\n // enough that the splice is inaudible.\n this.wetCoef = Math.exp(-1 / (sampleRate * 0.015));\n this.port.onmessage = (e) => {\n if (e.data && e.data.__hfDispose) { this.dead = true; return; }\n this.p = { ...this.p, ...e.data };\n };\n }\n process(inputs, outputs) {\n if (this.dead) return false;\n const i = inputs[0], o = outputs[0];\n if (!i || !i.length) return true;\n const p = this.p;\n const semitones = Math.max(-12, Math.min(12, p.semitones ?? 0));\n const mix = Math.max(0, Math.min(1, p.mix ?? 1));\n const grain = this.grain;\n const ringLen = grain * 2;\n const n = i[0] ? i[0].length : 0;\n for (let ch = 0; ch < i.length; ch++) {\n if (!this.buf[ch]) this.buf[ch] = new Float32Array(ringLen);\n }\n\n // Nothing to shift, or mixed fully out. The grain delay is ~grain/2\n // whatever the ratio, so at semitones=0 this degenerated into a pure 50 ms\n // delay of the signal, while the copy for that exact setting reads\n // "Unchanged pitch".\n this.wetTarget = semitones === 0 ? 0 : mix;\n\n // Fully dry AND settled: take the cheap transparent path. The ring keeps\n // filling, so a later shift does not start cold.\n if (this.wetTarget === 0 && this.wet < 1e-4) {\n this.wet = 0;\n let w = this.write;\n for (let s = 0; s < n; s++) {\n for (let ch = 0; ch < i.length; ch++) {\n const x = i[ch][s];\n this.buf[ch][w] = x;\n o[ch][s] = x;\n }\n w = (w + 1) % ringLen;\n }\n this.write = w;\n this.filled = Math.min(grain, this.filled + n);\n return true;\n }\n\n const ratio = Math.pow(2, semitones / 12);\n const inc = (1 - ratio) / grain;\n let write = this.write, phase = this.phase, filled = this.filled, wetNow = this.wet;\n const target = this.wetTarget, coef = this.wetCoef;\n for (let s = 0; s < n; s++) {\n phase += inc;\n phase -= Math.floor(phase);\n const phaseB = (phase + 0.5) % 1;\n const gA = xfade(phase), gB = xfade(phaseB);\n // Ramp the wet path in as the ring fills rather than reading zeros:\n // 100 ms of unshifted audio at the head of a clip beats 50 ms of silence.\n const warm = filled >= grain ? 1 : filled / grain;\n wetNow = target + coef * (wetNow - target);\n const wetMix = wetNow * warm;\n for (let ch = 0; ch < i.length; ch++) {\n const ring = this.buf[ch];\n const inp = i[ch], out = o[ch];\n const x = inp[s];\n ring[write] = x;\n const wet =\n readTap(ring, write, phase * grain) * gA + readTap(ring, write, phaseB * grain) * gB;\n out[s] = x * (1 - wetMix) + wet * wetMix;\n }\n write = (write + 1) % ringLen;\n if (filled < grain) filled++;\n }\n this.write = write;\n this.phase = phase;\n this.filled = filled;\n this.wet = wetNow;\n return true;\n }\n}\nregisterProcessor("hf-pitchshift", HfPitchshift);\n`+Z,L=new WeakMap;var He=new WeakSet;function O(e){let t=L.get(e);return t||(t=(async()=>{if(!e.audioWorklet)throw new Error("AudioWorklet is unavailable: the page needs a secure context (https, localhost or file://)");let n=`data:text/javascript;base64,${btoa(String.fromCharCode(...new TextEncoder().encode(Pe)))}`;await e.audioWorklet.addModule(n),He.add(e)})().catch(n=>{throw L.delete(e),n}),L.set(e,t)),t}function _e(e,t,n){let o=.6+Math.max(0,Math.min(1,t))*2.6,a=Math.max(1,Math.floor(e*o)),r=new Float32Array(a),i=Math.round(t*1e3)*2654435761+Math.round(n*1e3)*40503>>>0,s=()=>(i=i*1664525+1013904223>>>0,i/4294967295*2-1),u=Math.max(.001,1-Math.max(0,Math.min(1,n))),l=0,m=0;for(let c=0;c<a;c++){l+=u*(s()-l);let b=l*Math.pow(1-c/a,2.5);r[c]=b,m+=b*b}let p=Math.sqrt(m);if(p>0)for(let c=0;c<a;c++)r[c]=(r[c]??0)/p;return r}var f=e=>typeof e=="number"?e:Number(e??0),B=e=>e/1e3;function ae(e,t,n,o){let a=Math.max(1,Math.round(e.sampleRate)),r=e.createBuffer(1,a,e.sampleRate),i=r.getChannelData(0);for(let l=0;l<a;l++){let m=l/a;i[l]=t==="sine"?Math.sin(2*Math.PI*m):4*Math.abs((m+.75)%1-.5)-1}let s=e.createBufferSource();s.buffer=r,s.loop=!0,s.playbackRate.value=n;let u=(o*n%1+1)%1*(a/e.sampleRate);return s.start(typeof e.currentTime=="number"?e.currentTime:0,u),s}function oe(e){try{e.stop()}catch{}e.disconnect()}function I(e,t){return[{param:e},{param:t,map:n=>1-n}]}function re(e,t,n){e.gain.value=n,t.gain.value=1-n}function q(e,t,n){return{input:e,output:e,update:t,automation:n,dispose:()=>e.disconnect()}}var Re=new Set(["peaking","highpass","lowpass"]),ee=e=>Math.pow(10,e/20),Ne=(e,t)=>{let n=e.createGain(),o=a=>{n.gain.value=ee(f(a.gain))};return o(t),q(n,o,{gain:[{param:n.gain,map:ee}]})};function H(e,t){return(n,o)=>{let a=n.createBiquadFilter();a.type=e;let r=i=>{a.frequency.value=f(i.frequency),i.q!==void 0&&(a.Q.value=f(i.q)),t&&(a.gain.value=f(i.gain))};return r(o),q(a,r,{frequency:[{param:a.frequency}],...Re.has(e)?{q:[{param:a.Q}]}:{},...t?{gain:[{param:a.gain}]}:{}})}}function Ee(e){return(t,n)=>{let o=Math.tan(Math.PI*f(n.frequency)/t.sampleRate),a=e==="highpass"?t.createIIRFilter([1/(1+o),-1/(1+o)],[1,(o-1)/(o+1)]):t.createIIRFilter([o/(1+o),o/(1+o)],[1,(o-1)/(o+1)]);return q(a,()=>{})}}function M(e,t=!1){return(n,o,a)=>{let r=new AudioWorkletNode(n,e,{processorOptions:{...o,__hfElapsed:a}});return{input:r,output:r,update:i=>r.port.postMessage({...i}),...t?{reset:()=>r.port.postMessage({__hfReset:!0})}:{},dispose:()=>{r.port.postMessage({__hfDispose:!0}),r.disconnect()}}}}var De={tanh:Math.tanh,atan:e=>2/Math.PI*Math.atan(Math.PI/2*e),cubic:e=>Math.abs(e)>=1?Math.sign(e):e-e**3/3,exp:e=>Math.sign(e)*(1-Math.exp(-Math.abs(e))),alg:e=>e/Math.sqrt(1+e*e),quintic:e=>Math.abs(e)>=1?Math.sign(e):e-e**5/5,sin:e=>Math.abs(e)>=1?Math.sign(e):Math.sin(Math.PI/2*e),erf:e=>Math.tanh(1.20211*e),hard:e=>Math.max(-1,Math.min(1,e))},Ce=(e,t)=>{let n=e.createWaveShaper(),o=e.createGain(),a=e.createGain();o.connect(n).connect(a);let r=i=>{let s=De[String(i.type)]??Math.tanh,u=Math.pow(10,f(i.threshold)/20),l=8192,m=new Float32Array(l);for(let p=0;p<l;p++){let c=p/(l-1)*2-1;m[p]=s(c/Math.max(1e-6,u))*u}n.curve=m,n.oversample=f(i.oversample)>=4?"4x":f(i.oversample)>=2?"2x":"none",a.gain.value=Math.pow(10,f(i.output)/20)};return r(t),{input:o,output:a,update:r,automation:{output:[{param:a.gain,map:i=>Math.pow(10,i/20)}]},dispose:()=>{o.disconnect(),n.disconnect(),a.disconnect()}}},Se=(e,t)=>{let n=e.createGain(),o=e.createGain(),a=e.createDelay(5),r=e.createGain(),i=e.createGain(),s=e.createGain();n.connect(a),a.connect(r),r.connect(a),a.connect(i).connect(o),n.connect(s).connect(o);let u=l=>{a.delayTime.value=Math.min(5,f(l.time)/1e3),r.gain.value=f(l.feedback),re(i,s,f(l.mix))};return u(t),{input:n,output:o,update:u,automation:{time:[{param:a.delayTime,map:l=>Math.min(5,B(l))}],feedback:[{param:r.gain}],mix:I(i.gain,s.gain)},dispose:()=>[n,o,a,r,i,s].forEach(l=>l.disconnect())}},Le=(e,t,n)=>{let o=e.createGain(),a=e.createGain(),r=e.createDelay(.5),i=ae(e,"sine",f(t.speed),n),s=e.createGain(),u=e.createGain(),l=e.createGain();i.connect(s).connect(r.delayTime),o.connect(r).connect(u).connect(a),o.connect(l).connect(a);let m=p=>{r.delayTime.value=f(p.delay)/1e3,s.gain.value=f(p.depth)/1e3,i.playbackRate.value=f(p.speed),re(u,l,f(p.mix))};return m(t),{input:o,output:a,update:m,automation:{delay:[{param:r.delayTime,map:B}],depth:[{param:s.gain,map:B}],speed:[{param:i.playbackRate}],mix:I(u.gain,l.gain)},dispose:()=>{oe(i),[o,a,r,s,u,l].forEach(p=>p.disconnect())}}},Oe=6,Be=(e,t,n)=>{let o=e.createGain(),a=e.createGain(),r=e.createGain(),i=e.createGain(),s=ae(e,String(t.type)==="1"?"sine":"triangle",f(t.speed),n),u=e.createGain(),l=e.createGain(),m=e.createGain(),p=[];o.connect(r);let c=r;for(let d=0;d<Oe;d++){let h=e.createBiquadFilter();h.type="allpass",h.Q.value=.7071,u.connect(h.frequency),c.connect(h),c=h,p.push(h)}s.connect(u),c.connect(l).connect(i),r.connect(m).connect(i),i.connect(a);let b=d=>{let h=1e3/Math.max(.1,f(d.delay));for(let g of p)g.frequency.value=h;u.gain.value=h*f(d.decay),s.playbackRate.value=f(d.speed),r.gain.value=f(d.in_gain),i.gain.value=f(d.out_gain),l.gain.value=1,m.gain.value=1};return b(t),{input:o,output:a,update:b,automation:{speed:[{param:s.playbackRate}],in_gain:[{param:r.gain}],out_gain:[{param:i.gain}]},dispose:()=>{oe(s),[o,a,r,i,u,l,m,...p].forEach(d=>d.disconnect())}}},Ie=(e,t)=>{let n=e.createGain(),o=e.createGain(),a=e.createConvolver(),r=e.createGain(),i=e.createGain();a.normalize=!1,n.connect(a).connect(r).connect(o),n.connect(i).connect(o);let s="",u=l=>{let m=`${f(l.size)}:${f(l.damping)}`;if(m!==s){let p=_e(e.sampleRate,f(l.size),f(l.damping)),c=e.createBuffer(1,p.length,e.sampleRate);c.getChannelData(0).set(p),a.buffer=c,s=m}r.gain.value=f(l.wet),i.gain.value=f(l.dry)};return u(t),{input:n,output:o,update:u,automation:{wet:[{param:r.gain}],dry:[{param:i.gain}]},dispose:()=>[n,o,a,r,i].forEach(l=>l.disconnect())}},qe={"gain-node":Ne,"biquad-peaking":H("peaking",!0),"biquad-lowshelf":H("lowshelf",!0),"biquad-highshelf":H("highshelf",!0),"biquad-highpass":H("highpass",!1),"biquad-lowpass":H("lowpass",!1),"worklet-compressor":M("hf-compressor"),"worklet-limiter":M("hf-limiter"),"worklet-truepeak":M("hf-truepeak",!0),"worklet-gate":M("hf-gate"),"worklet-bitcrush":M("hf-bitcrush"),"worklet-pitchshift":M("hf-pitchshift"),waveshaper:Ce,"delay-feedback":Se,"chorus-lfo":Le,"allpass-phaser":Be,convolver:Ie};function ie(e){return e.nodes.some(t=>P(t.type)?.web.startsWith("worklet-")??!1)}function Ge(e,t,n,o=0){let a=P(t);if(!a)throw new Error(`Unknown effect type: ${t}`);let r=y(t,n);if((t==="highpass"||t==="lowpass")&&String(r.poles)==="1")return Ee(t)(e,r,o);let i=qe[a.web];if(!i)throw new Error(`No Web Audio builder for ${a.web}`);return i(e,r,o)}function te(e){let t=[];for(let n of e){let o=n.fromPreset,a=t.at(-1);if(a&&a.preset===o)a.nodes.push(n);else{let r=typeof n.presetAmount=="number"?n.presetAmount:1;t.push({...o?{preset:o}:{},amount:Math.min(1,Math.max(0,r)),nodes:[n]})}}return t}function ne(e){return w(e).map(t=>{let n=y(t.type,t.params),o=n.poles!==void 0?`:${n.poles}`:"",a=String(n.poles)==="1"?`@${n.frequency}`:"",r=t.type==="phaser"?`~${n.type}`:"",i=t.fromPreset?`%${t.fromPreset}`:"",s=t.type==="truepeak"?`^${n.lookahead}`:"";return`${t.type}${o}${a}${r}${s}${i}`}).join("|")}function se(e,t,n=0){var p;let o=e.createGain(),a=e.createGain(),r=[],i=[],s=te(w(t)),u=o;for(let c of s){let b=null;if(c.preset){let d=e.createGain(),h=e.createGain(),g=e.createGain(),T=e.createGain();g.gain.value=c.amount,h.gain.value=1-c.amount,u.connect(d),d.connect(h).connect(T),b={entry:d,wet:g,dry:h,join:T},u=d}for(let d of c.nodes){let h=Ge(e,d.type,d.params??{},n);u.connect(h.input),u=h.output,r.push({...d.id?{id:d.id}:{},type:d.type,handle:h})}b&&c.preset&&(u.connect(b.wet).connect(b.join),i.push({id:c.preset,...b}),u=b.join)}u.connect(a);let l=ne(t),m={};for(let c of i)(m[p=c.id]??(m[p]=[])).push(...I(c.wet.gain,c.dry.gain));return{input:o,output:a,presets:m,nodes:r,update(c){if(ne(c)!==l)return!1;w(c).forEach((d,h)=>{let g=r[h];g&&(g.handle.update(y(d.type,d.params)),d.id===void 0?delete g.id:g.id=d.id)});let b=0;for(let d of te(w(c))){if(!d.preset)continue;let h=i[b++];!h||h.id!==d.preset||(h.wet.gain.value=d.amount,h.dry.gain.value=1-d.amount)}return!0},reset(){for(let{handle:c}of r)c.reset?.()},dispose(){for(let{handle:c}of r)c.dispose();for(let{entry:c,wet:b,dry:d,join:h}of i)c.disconnect(),b.disconnect(),d.disconnect(),h.disconnect();o.disconnect(),a.disconnect()}}}function Ue(e){return 10**(e/20)}var ue=Ue(12);var G=.1,U=10;var Ve="data-automation",Vt=Ve.slice(5),D=1,$e=512,A=class extends Error{constructor(t){super(t),this.name="AudioAutomationError"}},V="volume",le="rate";function R(e){if(e===V)return{kind:"volume"};if(e===le)return{kind:"rate"};let t=e.split(".");if(t.length===3&&t[0]==="fx"&&t[1]===je){let a=t[2];return a?{kind:"preset",presetId:a}:null}if(t.length!==3||t[0]!=="fx")return null;let[,n,o]=t;return!n||!o?null:{kind:"fx",nodeId:n,param:o}}function ce(e,t){return`fx.${e}.${t}`}var je="preset";var Xe={min:0,max:1,step:.01,unit:"",label:"Amount",scale:"linear",default:1},de={min:0,max:ue,step:.01,unit:"",label:"Volume",scale:"linear",default:1},me={min:G,max:U,step:.05,unit:"x",label:"Speed",scale:"log",default:1};function $(e,t){let n=R(e);if(!n)return null;if(n.kind==="volume")return de;if(n.kind==="rate")return me;if(n.kind==="preset")return t?.nodes.some(s=>s.fromPreset===n.presetId)?{...Xe,label:`${n.presetId} \\xB7 Amount`}:null;let o=t?.nodes.find(i=>i.id===n.nodeId);if(!o)return null;let a=P(o.type),r=a?.params.find(i=>i.key===n.param);return!r||r.kind!=="number"?null:{min:r.min,max:r.max,step:r.step,unit:r.unit,label:`${a?.label??o.type} \\xB7 ${r.label}`,scale:r.scale==="log"&&r.min>0?"log":"linear",default:r.default}}function _(e){if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="string"&&e.trim()!==""){let t=Number(e);return Number.isFinite(t)?t:null}return null}function We(e){let t=_(e);return t===null||t===0?0:Math.min(1,Math.max(-1,t))}function pe(e,t){let n=_(e),o=_(t);if(n===null||o===null)return null;let a=s=>Math.min(.999,Math.max(.001,s)),r=a(n),i=a(o);return Math.abs(r-i)<1e-6?null:{x:r,y:i}}function Ke(e){let t=We(e?.curve),n=pe(e?.viaX,e?.viaY);return{...t?{curve:t}:{},...n?{viaX:n.x,viaY:n.y}:{}}}function Ye(e,t){let n=_(e?.t),o=_(e?.v);if(n===null||o===null)return null;let a=t?Math.min(t.max,Math.max(t.min,o)):o;return{t:Math.max(0,n),v:a,...Ke(e)}}function he(e,t){let n=e.map(a=>Ye(a,t)).filter(a=>a!==null).sort((a,r)=>a.t-r.t),o=[];for(let a of n)o.length>0&&o[o.length-1].t===a.t?o[o.length-1]=a:o.push(a);return o.slice(0,$e)}function ze(e){let t=[];for(let n of e.lanes){if(!R(n.target))continue;let o=n.target===V?de:n.target===le?me:null,a=he(n.points??[],o);a.length>0&&t.push({target:n.target,points:a})}return{version:D,lanes:t}}function fe(e,t){let n=[];for(let o of e.lanes){let a=$(o.target,t);if(!a)continue;let r=he(o.points,a);r.length>0&&n.push({target:o.target,points:r})}return{version:D,lanes:n}}function be(e){let t;try{t=JSON.parse(e)}catch(a){throw new A(`Automation is not valid JSON: ${a.message}`)}if(typeof t!="object"||t===null)throw new A("Automation must be a JSON object.");let n=t;if(n.version!==D)throw new A(`Unsupported automation version: ${String(n.version)}`);if(!Array.isArray(n.lanes))throw new A("Automation is missing a `lanes` array.");let o=n.lanes.map((a,r)=>{if(typeof a!="object"||a===null)throw new A(`Lane ${r} is not an object.`);let i=a;if(typeof i.target!="string"||!R(i.target))throw new A(`Lane ${r} has an unreadable target: ${String(i.target)}`);if(!Array.isArray(i.points))throw new A(`Lane ${r} is missing a \\`points\\` array.`);return{target:i.target,points:i.points}});return ze({version:D,lanes:o})}function Je(e,t){return t?Math.pow(e,Math.pow(2,2*t)):e}function Qe(e,t){let n=e-.5,o=t-.5,a=.999,r=1e6,i=n>0?n/(a-e):n<0?-n/(e-(1-a)):0,s=o>0?o/(a-t):o<0?-o/(t-(1-a)):0,u=Math.min(r,Math.max(1,i,s));return{cx:e+n/u,cy:t+o/u,w:u}}function Ze(e,t,n){let{cx:o,cy:a,w:r}=Qe(t,n),i=2-2*r,s=e*i-1+2*r*o,u=-e*i-2*r*o,l=et(s,u,e),m=1-l,p=m*m+2*r*l*m+l*l;return p>0?(2*r*a*l*m+l*l)/p:e}function et(e,t,n){if(Math.abs(e)<1e-12)return Math.abs(t)<1e-12?n:-n/t;let o=Math.sqrt(Math.max(0,t*t-4*e*n)),a=(-t+o)/(2*e),r=(-t-o)/(2*e),i=s=>s>=-1e-9&&s<=1+1e-9;return i(a)?Math.min(1,Math.max(0,a)):i(r)?Math.min(1,Math.max(0,r)):n}function tt(e,t){let n=pe(t.viaX,t.viaY);return n?Ze(Math.min(1,Math.max(0,e)),n.x,n.y):Je(e,t.curve)}function nt(e,t,n,o){return o==="log"&&e>0&&t>0?Math.exp(Math.log(e)+(Math.log(t)-Math.log(e))*n):e+(t-e)*n}function j(e,t,n="linear"){let o=e.points;if(o.length===0)return 0;let a=o[0];if(t<=a.t)return a.v;let r=o[o.length-1];if(t>=r.t)return r.v;let i=0,s=o.length-1;for(;s-i>1;){let p=i+s>>1;o[p].t<=t?i=p:s=p}let u=o[i],l=o[s],m=l.t-u.t;return m<=0?l.v:nt(u.v,l.v,tt((t-u.t)/m,u),n)}function ge(e){return e.points.length<=1||e.points.every(t=>t.v===e.points[0].v)}function Ae(e,t,n,o,a="linear"){let r=Math.max(2,Math.floor(o)),i=new Float32Array(r),s=n-t;for(let u=0;u<r;u+=1)i[u]=j(e,t+s*u/(r-1),a);return i}var at=100,ot=8,rt=4096,X=e=>e;function it(e,t,n){return!(!!e.curve||e.viaX!==void 0&&e.viaY!==void 0)&&t==="linear"&&!n}function st(e){let t=Math.ceil(e*at);return Math.min(rt,Math.max(ot,t))}function ut(e,t,n,o,a){let{scheduledAt:r,elapsed:i,rate:s}=o,u=a??X,l=v=>r+(v-i)/s,m=e.points[t],p=e.points[t+1],c=l(p.t);if(c<=r)return null;let b=Math.max(r,l(m.t)),d=c-b;if(d<=0)return null;if(it(m,n,a))return{kind:"ramp",time:c,value:u(p.v)};let h=st(d),g=Ae(e,Math.max(m.t,i),p.t,h,n),T=new Float32Array(h);for(let v=0;v<h;v+=1)T[v]=u(g[v]??0);return{kind:"curve",time:b,duration:d,values:T}}function lt(e,t,n,o){let a=[];for(let i=0;i+1<e.points.length;i+=1){let s=ut(e,i,t,n,o);s&&a.push(s)}let r=a[0];return r?.kind==="curve"&&r.time<=n.scheduledAt||a.unshift({kind:"set",time:n.scheduledAt,value:(o??X)(j(e,n.elapsed,t))}),a}function ct(e,t){e.cancelScheduledValues(0);for(let n of t)n.kind==="set"?e.setValueAtTime(n.value,n.time):n.kind==="ramp"?e.linearRampToValueAtTime(n.value,n.time):(e.setValueAtTime(n.values[0]??0,n.time),e.linearRampToValueAtTime(n.values[n.values.length-1]??0,n.time+n.duration))}function dt(e,t){for(let n of t)if(n.kind==="set")e.setValueAtTime(n.value,n.time);else if(n.kind==="ramp")e.linearRampToValueAtTime(n.value,n.time);else try{e.setValueCurveAtTime(n.values,n.time,n.duration)}catch{ct(e,t);return}}function mt(e){for(let t of e)t.param.cancelScheduledValues(0)}function pt(e,t,n,o){if(t.points.length!==0)for(let a of e){if(mt([a]),ge(t)){let r=(a.map??X)(t.points[0].v);a.param.setValueAtTime(r,o.scheduledAt);continue}dt(a.param,lt(t,n,o,a.map))}}function xe(e,t,n,o,a){let r=new Map(n.filter(s=>s.id).map(s=>[s.id,s.handle])),i=[];for(let s of e.lanes){let u=R(s.target);if(!u)continue;let l=u.kind==="preset"?a?.[u.presetId]:u.kind==="fx"?r.get(u.nodeId)?.automation?.[u.param]:void 0;if(!l||l.length===0)continue;let m=$(s.target,t);m&&(pt(l,s,m.scale,o),i.push(...l))}return i}var ht=5,ft=.001;function k(e,t,n){let o=Number(y(e.type,e.params)[t]??0);if(!e.id||!n)return Number.isFinite(o)?o:0;let a=n.lanes.find(r=>r.target===ce(e.id??"",t));return!a||a.points.length===0?Number.isFinite(o)?o:0:a.points.reduce((r,i)=>Math.max(r,i.v),-1/0)}function bt(e,t){let n=Math.min(5,e/1e3);if(n<=0)return 0;let o=Math.max(0,Math.min(.999,t));return o<=0?n:Math.ceil(Math.log(ft)/Math.log(o))*n}function gt(e){return .6+Math.max(0,Math.min(1,e))*2.6}function At(e,t){return k(e,"wet",t)>0?gt(k(e,"size",t)):0}function xt(e,t){return k(e,"mix",t)>0?bt(k(e,"time",t),k(e,"feedback",t)):0}function yt(e,t){return k(e,"mix",t)>0?k(e,"delay",t)/1e3:0}function kt(e,t){return k(e,"mix",t)>0?.2:0}function wt(e,t){if(e.enabled===!1)return 0;switch(e.type){case"reverb":return At(e,t);case"delay":return xt(e,t);case"chorus":return yt(e,t);case"pitchshift":return kt(e,t);default:return 0}}function ye(e,t){let n=e.nodes.reduce((o,a)=>o+wt(a,t),0);return Math.min(ht,n)}function ke(e,t){return w(e).filter(n=>n.type==="truepeak").reduce((n,o)=>{let{lookahead:a}=y(o.type,o.params);return n+Q(Number(a),t)},0)}function vt(e,t,n,o,a){let r=e.createBuffer(n,o,a);for(let i=0;i<n;i++){let s=t[i];s&&r.getChannelData(i).set(s)}return r}function Mt(e,t){let n=[];for(let o=0;o<e.numberOfChannels;o++)n.push(new Float32Array(e.getChannelData(o).subarray(t)));return n}async function Tt(e,t,n,o,a=0){let r=J(n),i=Math.max(1,e.length),s=e[0]?.length??0;if(s===0)return e;let u=o?fe(be(o),r):null,l=Math.ceil(ye(r,u??void 0)*t),m=ke(r,t),p=s+l+m,c=new OfflineAudioContext(i,p,t);ie(r)&&await O(c);let b=c.createBufferSource();b.buffer=vt(c,e,i,p,t);let d=se(c,r,a);return u&&xe(u,r,d.nodes,{scheduledAt:0,elapsed:0,rate:1},d.presets),b.connect(d.input),d.output.connect(c.destination),b.start(),Mt(await c.startRendering(),m)}window.__HF_AUDIO_FX={render:Tt};})();\n';
|
|
14475
14512
|
function getAudioFxRuntimeScript() {
|
|
14476
14513
|
return AUDIO_FX_RUNTIME_IIFE;
|
|
14477
14514
|
}
|
|
@@ -15273,13 +15310,18 @@ function parseAudioElements(html) {
|
|
|
15273
15310
|
}
|
|
15274
15311
|
return elements;
|
|
15275
15312
|
}
|
|
15313
|
+
var FAIL_ON_READ_ERROR_INSTEAD_OF_ENDING_THERE = ["-xerror"];
|
|
15276
15314
|
async function extractAudioSegment(srcPath, outputPath, stage, mediaStart, duration, playbackRate = 1, signal, config) {
|
|
15277
15315
|
const ffmpegProcessTimeout = config?.ffmpegProcessTimeout ?? DEFAULT_CONFIG.ffmpegProcessTimeout;
|
|
15278
15316
|
const outputDir = dirname7(outputPath);
|
|
15279
15317
|
if (!existsSync11(outputDir)) mkdirSync7(outputDir, { recursive: true });
|
|
15280
15318
|
const normalizedPlaybackRate = normalizeRateSpec(playbackRate);
|
|
15281
15319
|
const sourceDuration = sourceTimeAt(normalizedPlaybackRate, duration);
|
|
15282
|
-
const
|
|
15320
|
+
const readsUrl = isHttpUrl(srcPath);
|
|
15321
|
+
const metadata = readsUrl ? await extractAudioMetadata(srcPath, { signal }).catch((error) => {
|
|
15322
|
+
if (signal?.aborted) throw error;
|
|
15323
|
+
return extractAudioMetadata(srcPath, { signal });
|
|
15324
|
+
}) : await extractAudioMetadata(srcPath).catch(() => null);
|
|
15283
15325
|
const inputSeek = mediaStart >= (metadata?.latestStreamLeadSeconds ?? 0);
|
|
15284
15326
|
const start = formatFilterNumber(mediaStart);
|
|
15285
15327
|
const timestampTrim = inputSeek ? null : `atrim=start=${start}:end=${formatFilterNumber(mediaStart + sourceDuration)},asetpts=PTS-${start}/TB,aresample=async=1:first_pts=0`;
|
|
@@ -15289,7 +15331,13 @@ async function extractAudioSegment(srcPath, outputPath, stage, mediaStart, durat
|
|
|
15289
15331
|
duration,
|
|
15290
15332
|
timestampTrim
|
|
15291
15333
|
);
|
|
15292
|
-
const args =
|
|
15334
|
+
const args = [
|
|
15335
|
+
...readsUrl ? FAIL_ON_READ_ERROR_INSTEAD_OF_ENDING_THERE : [],
|
|
15336
|
+
...urlInputArgs(srcPath),
|
|
15337
|
+
...inputSeek ? ["-ss", String(mediaStart), "-t", String(sourceDuration)] : [],
|
|
15338
|
+
"-i",
|
|
15339
|
+
srcPath
|
|
15340
|
+
];
|
|
15293
15341
|
args.push("-vn", "-acodec", "pcm_s16le", "-ar", "48000", ...outputArgs);
|
|
15294
15342
|
if (normalizedPlaybackRate !== 1) args.push("-t", String(duration));
|
|
15295
15343
|
args.push("-y", outputPath);
|
|
@@ -15310,7 +15358,11 @@ async function extractAudioSegment(srcPath, outputPath, stage, mediaStart, durat
|
|
|
15310
15358
|
failure: failure2
|
|
15311
15359
|
};
|
|
15312
15360
|
}
|
|
15313
|
-
|
|
15361
|
+
let failure = result.success ? void 0 : ffmpegFailure(stage, result);
|
|
15362
|
+
const probedLinkFailedToRead = readsUrl && (failure?.reason === "invalid_media" || failure?.reason === "ffmpeg_failed");
|
|
15363
|
+
if (failure && probedLinkFailedToRead) {
|
|
15364
|
+
failure = { ...failure, reason: "download_failed", owner: "system", retryable: true };
|
|
15365
|
+
}
|
|
15314
15366
|
return {
|
|
15315
15367
|
success: result.success,
|
|
15316
15368
|
outputPath,
|
|
@@ -15361,7 +15413,7 @@ async function generateSilence(outputPath, duration, signal, config) {
|
|
|
15361
15413
|
failure
|
|
15362
15414
|
};
|
|
15363
15415
|
}
|
|
15364
|
-
async function mixAudioTracks(tracks, outputPath, totalDuration, signal, config
|
|
15416
|
+
async function mixAudioTracks(tracks, outputPath, totalDuration, signal, config) {
|
|
15365
15417
|
const ffmpegProcessTimeout = config?.ffmpegProcessTimeout ?? DEFAULT_CONFIG.ffmpegProcessTimeout;
|
|
15366
15418
|
const masterOutputGain = config?.audioGain ?? DEFAULT_CONFIG.audioGain;
|
|
15367
15419
|
if (tracks.length === 0) {
|
|
@@ -15406,7 +15458,10 @@ async function mixAudioTracks(tracks, outputPath, totalDuration, signal, config,
|
|
|
15406
15458
|
scriptPath,
|
|
15407
15459
|
"-map",
|
|
15408
15460
|
"[out]",
|
|
15409
|
-
|
|
15461
|
+
"-acodec",
|
|
15462
|
+
"pcm_f32le",
|
|
15463
|
+
"-ar",
|
|
15464
|
+
"48000",
|
|
15410
15465
|
"-t",
|
|
15411
15466
|
String(totalDuration),
|
|
15412
15467
|
"-y",
|
|
@@ -15566,7 +15621,7 @@ async function mixGroupMembers(memberTracks, outputPath, totalDuration, signal,
|
|
|
15566
15621
|
}
|
|
15567
15622
|
async function mixThroughFloatSum(tracks, masterChain, outputPath, workDir, totalDuration, signal, config) {
|
|
15568
15623
|
const sumPath = join14(workDir, "master-sum.wav");
|
|
15569
|
-
const sum = await mixAudioTracks(tracks, sumPath, totalDuration, signal, config
|
|
15624
|
+
const sum = await mixAudioTracks(tracks, sumPath, totalDuration, signal, config);
|
|
15570
15625
|
if (!sum.success) return { ...sum, outputPath };
|
|
15571
15626
|
const encoderInput = masterChain ? (await applyAudioFxChain(sumPath, masterChain, join14(workDir, "master-fx.wav"), {
|
|
15572
15627
|
trackId: "master",
|
|
@@ -15587,6 +15642,7 @@ async function mixThroughFloatSum(tracks, masterChain, outputPath, workDir, tota
|
|
|
15587
15642
|
failures: [failure]
|
|
15588
15643
|
};
|
|
15589
15644
|
}
|
|
15645
|
+
if (config?.keepEncoderInputAt) renameSync3(encoderInput, config.keepEncoderInputAt);
|
|
15590
15646
|
return { ...sum, outputPath, durationMs: sum.durationMs + encoded.durationMs };
|
|
15591
15647
|
}
|
|
15592
15648
|
async function processCompositionAudio(elements, baseDir, workDir, outputPath, totalDuration, signal, config, compiledDir) {
|
|
@@ -15618,11 +15674,16 @@ async function processCompositionAudio(elements, baseDir, workDir, outputPath, t
|
|
|
15618
15674
|
}
|
|
15619
15675
|
try {
|
|
15620
15676
|
let srcPath = element.src;
|
|
15677
|
+
let readInPlace = false;
|
|
15621
15678
|
if (!isHttpUrl(srcPath)) {
|
|
15622
15679
|
srcPath = resolveProjectRelativeSrc(element.src, baseDir, compiledDir);
|
|
15623
|
-
|
|
15680
|
+
const remoteUrl = config?.urlByAbsentLocalPath?.get(srcPath);
|
|
15681
|
+
if (remoteUrl) {
|
|
15682
|
+
srcPath = remoteUrl;
|
|
15683
|
+
readInPlace = true;
|
|
15684
|
+
}
|
|
15624
15685
|
}
|
|
15625
|
-
if (isHttpUrl(srcPath)) {
|
|
15686
|
+
if (isHttpUrl(srcPath) && !readInPlace) {
|
|
15626
15687
|
try {
|
|
15627
15688
|
srcPath = await downloadToTemp(
|
|
15628
15689
|
srcPath,
|
|
@@ -15639,7 +15700,7 @@ async function processCompositionAudio(elements, baseDir, workDir, outputPath, t
|
|
|
15639
15700
|
return;
|
|
15640
15701
|
}
|
|
15641
15702
|
}
|
|
15642
|
-
if (!existsSync11(srcPath)) {
|
|
15703
|
+
if (!readInPlace && !existsSync11(srcPath)) {
|
|
15643
15704
|
failures.push({
|
|
15644
15705
|
stage: "source",
|
|
15645
15706
|
reason: "source_not_found",
|
|
@@ -15666,7 +15727,10 @@ async function processCompositionAudio(elements, baseDir, workDir, outputPath, t
|
|
|
15666
15727
|
if (element.end - element.start <= 0) {
|
|
15667
15728
|
let metadata;
|
|
15668
15729
|
try {
|
|
15669
|
-
metadata = await extractAudioMetadata(
|
|
15730
|
+
metadata = await extractAudioMetadata(
|
|
15731
|
+
srcPath,
|
|
15732
|
+
readInPlace ? { signal: effectiveSignal } : void 0
|
|
15733
|
+
);
|
|
15670
15734
|
} catch (err) {
|
|
15671
15735
|
failures.push(
|
|
15672
15736
|
probeFailure(err instanceof Error ? err.message : String(err), element.id)
|
|
@@ -15957,7 +16021,7 @@ async function processCompositionAudio(elements, baseDir, workDir, outputPath, t
|
|
|
15957
16021
|
if (failures.length > 0) return bail();
|
|
15958
16022
|
let mixResult;
|
|
15959
16023
|
try {
|
|
15960
|
-
mixResult =
|
|
16024
|
+
mixResult = tracks.length > 0 ? await mixThroughFloatSum(
|
|
15961
16025
|
tracks,
|
|
15962
16026
|
masterChain,
|
|
15963
16027
|
outputPath,
|
|
@@ -16357,6 +16421,7 @@ async function captureFrameRange(session, task, captureOptions, signal, onFrameC
|
|
|
16357
16421
|
if (signal?.aborted) throw new Error("Parallel worker cancelled");
|
|
16358
16422
|
const time = i * captureOptions.fps.den / captureOptions.fps.num;
|
|
16359
16423
|
const fileFrameIdx = i - outputOffset;
|
|
16424
|
+
let landedFrame;
|
|
16360
16425
|
if (onFrameBuffer) {
|
|
16361
16426
|
const { buffer } = await runCaptureOperation(
|
|
16362
16427
|
"frame_capture",
|
|
@@ -16365,14 +16430,15 @@ async function captureFrameRange(session, task, captureOptions, signal, onFrameC
|
|
|
16365
16430
|
);
|
|
16366
16431
|
await onFrameBuffer(i, buffer, session);
|
|
16367
16432
|
} else {
|
|
16368
|
-
await runCaptureOperation(
|
|
16433
|
+
const { path } = await runCaptureOperation(
|
|
16369
16434
|
"frame_capture",
|
|
16370
16435
|
i,
|
|
16371
16436
|
() => captureFrame(session, fileFrameIdx, time)
|
|
16372
16437
|
);
|
|
16438
|
+
landedFrame = { index: fileFrameIdx, path };
|
|
16373
16439
|
}
|
|
16374
16440
|
framesCaptured++;
|
|
16375
|
-
if (onFrameCaptured) onFrameCaptured(task.workerId, i);
|
|
16441
|
+
if (onFrameCaptured) onFrameCaptured(task.workerId, i, landedFrame);
|
|
16376
16442
|
}
|
|
16377
16443
|
return framesCaptured;
|
|
16378
16444
|
}
|
|
@@ -16593,7 +16659,7 @@ async function executeParallelCapture(serverUrl, workDir, tasks, captureOptions,
|
|
|
16593
16659
|
const workerProgress = /* @__PURE__ */ new Map();
|
|
16594
16660
|
const workerPhases = /* @__PURE__ */ new Map();
|
|
16595
16661
|
for (const task of tasks) workerProgress.set(task.workerId, 0);
|
|
16596
|
-
const onFrameCaptured = (workerId, _frameIndex) => {
|
|
16662
|
+
const onFrameCaptured = (workerId, _frameIndex, landedFrame) => {
|
|
16597
16663
|
const current = workerProgress.get(workerId) || 0;
|
|
16598
16664
|
workerProgress.set(workerId, current + 1);
|
|
16599
16665
|
if (onProgress) {
|
|
@@ -16602,7 +16668,8 @@ async function executeParallelCapture(serverUrl, workDir, tasks, captureOptions,
|
|
|
16602
16668
|
totalFrames,
|
|
16603
16669
|
capturedFrames,
|
|
16604
16670
|
activeWorkers: tasks.length,
|
|
16605
|
-
workerProgress: new Map(workerProgress)
|
|
16671
|
+
workerProgress: new Map(workerProgress),
|
|
16672
|
+
...landedFrame && { landedFrame }
|
|
16606
16673
|
});
|
|
16607
16674
|
}
|
|
16608
16675
|
};
|
|
@@ -17190,6 +17257,7 @@ export {
|
|
|
17190
17257
|
deriveBeginFrameProbeTimeTicks,
|
|
17191
17258
|
completeDeferredDrawElementInit,
|
|
17192
17259
|
createCaptureSession,
|
|
17260
|
+
waitForImagesReady,
|
|
17193
17261
|
VfxFailureError,
|
|
17194
17262
|
initializeSession,
|
|
17195
17263
|
captureFrame,
|
|
@@ -17252,8 +17320,6 @@ export {
|
|
|
17252
17320
|
spawnStreamingEncoder,
|
|
17253
17321
|
HF_AUDIO_GROUP_TAG,
|
|
17254
17322
|
HF_AUDIO_GROUP_ATTR,
|
|
17255
|
-
resolveReferencedStart,
|
|
17256
|
-
resolveReferencedDuration,
|
|
17257
17323
|
safeDownloadUrlIdentity,
|
|
17258
17324
|
writeUrlDownloadTelemetry,
|
|
17259
17325
|
isBlockedNetworkHost,
|
|
@@ -17290,6 +17356,7 @@ export {
|
|
|
17290
17356
|
createVideoFrameInjector,
|
|
17291
17357
|
hideVideoElements,
|
|
17292
17358
|
showVideoElements,
|
|
17359
|
+
measureVideoShownBoxes,
|
|
17293
17360
|
queryVideoElementBounds,
|
|
17294
17361
|
queryElementStacking,
|
|
17295
17362
|
NOT_MEDIA_PAYLOAD,
|
|
@@ -17298,6 +17365,7 @@ export {
|
|
|
17298
17365
|
isNotMediaPayload,
|
|
17299
17366
|
assertMediaPayload,
|
|
17300
17367
|
aacSegmentCount,
|
|
17368
|
+
encodeAac,
|
|
17301
17369
|
audioFailureDiagnostics,
|
|
17302
17370
|
MIXED_AUDIO_FILENAME,
|
|
17303
17371
|
parseMasterFxChain,
|