hyperframes 0.8.211 → 0.8.213
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{add-WERDY37C.js → add-GRJ6BQMO.js} +14 -13
- package/dist/{agentPromptGenerator-SEAPWYY5.js → agentPromptGenerator-2HTUGEKK.js} +6 -6
- package/dist/{animatedGifPrep-LC43PROA.js → animatedGifPrep-7KPZBZXD.js} +6 -6
- package/dist/api.js +18 -18
- package/dist/{asset-IVDQNYHP.js → asset-YVIFFWCU.js} +5 -4
- package/dist/{assetCataloger-PPE7M2WM.js → assetCataloger-IZW7LPCT.js} +7 -7
- package/dist/{audio-IJ22GXO6.js → audio-X7274SUF.js} +316 -210
- package/dist/{auth-FZMDHX2H.js → auth-II6SIDJD.js} +4 -4
- package/dist/{autoUpdate-EO6SFALF.js → autoUpdate-WJIT74BG.js} +4 -2
- package/dist/{backgroundChecks-YW5VIAYF.js → backgroundChecks-NMKJAES7.js} +5 -3
- package/dist/backgroundChecksWorker.js +5 -3
- package/dist/{batchRender-OOXYNZOT.js → batchRender-I7GRY73M.js} +8 -7
- package/dist/{beats-X7GRQA4J.js → beats-6VXALJZT.js} +15 -14
- package/dist/{benchmark-JGGBMRZO.js → benchmark-RLIRA74V.js} +19 -17
- package/dist/{browser-FQ5JPTME.js → browser-7T3JMNTR.js} +12 -10
- package/dist/{bundleWithLocalizedFonts-XA73ZJ4S.js → bundleWithLocalizedFonts-C2LP6QZZ.js} +2 -2
- package/dist/{capture-GUVCA5JQ.js → capture-OZFDTN4A.js} +48 -18
- package/dist/{capture-KKVB3MKM.js → capture-V4HWHG7C.js} +13 -10
- package/dist/{captureCompositionFrame-LNKWWCXE.js → captureCompositionFrame-WZAVXCRQ.js} +14 -13
- package/dist/{catalog-LKJEMEOC.js → catalog-UFC7JS4T.js} +18 -17
- package/dist/{catch-up-FA6KWX4S.js → catch-up-YBNKJDWJ.js} +8 -7
- package/dist/{check-6GIDKL6S.js → check-ESQJHRGA.js} +42 -41
- package/dist/{checkAudio-H3AUFC4M.js → checkAudio-OIIBWFBF.js} +26 -11
- package/dist/{checkBrowser-YWWF63S6.js → checkBrowser-WAWL6TKX.js} +35 -34
- package/dist/{chunk-KSNIYQRB.js → chunk-26AQTUU4.js} +5 -7
- package/dist/{chunk-B2B4MN3R.js → chunk-2GS2RUVI.js} +2 -2
- package/dist/{chunk-WNDTMINP.js → chunk-2WELGDXU.js} +3 -3
- package/dist/{chunk-OE5EHGDG.js → chunk-3OYLHBQZ.js} +1 -1
- package/dist/{chunk-U46JEU26.js → chunk-4645UHJF.js} +1 -0
- package/dist/{chunk-FI7SSV73.js → chunk-46HYDDZ5.js} +1 -1
- package/dist/{chunk-YPNBEBQ6.js → chunk-4BXPCS5B.js} +26 -19
- package/dist/{chunk-ABBVDJMG.js → chunk-53VXGZ3L.js} +2 -2
- package/dist/{chunk-66KMYUNO.js → chunk-5ODMV7X6.js} +2 -2
- package/dist/{chunk-MMJAHBH2.js → chunk-5SKC4G26.js} +4 -1
- package/dist/{chunk-J2JG4XGP.js → chunk-5ZBMHUY2.js} +4 -0
- package/dist/{chunk-YRO3PXWU.js → chunk-6CGYINE7.js} +97 -2
- package/dist/{chunk-JMD5HDPB.js → chunk-6ZLDIMPL.js} +2 -2
- package/dist/{chunk-3R5MYOJN.js → chunk-76T7KAYD.js} +2 -2
- package/dist/{chunk-OOA6C4AG.js → chunk-7I5N36JA.js} +2 -2
- package/dist/{chunk-CNU65QE2.js → chunk-7JWRVKN4.js} +9 -5
- package/dist/{chunk-CJ5QZRY7.js → chunk-7KBS6ZLB.js} +2 -2
- package/dist/{chunk-T2L2GJ4C.js → chunk-7LOVQRUJ.js} +7 -7
- package/dist/{chunk-FBN5AQJL.js → chunk-7TWX4Y7I.js} +3 -3
- package/dist/{chunk-VBC3DQFS.js → chunk-AJ3QW6RX.js} +12 -5
- package/dist/{chunk-FIC3E7IM.js → chunk-BE6XXZAR.js} +9 -9
- package/dist/{chunk-5MCR5DA5.js → chunk-BVHNFPRF.js} +5 -5
- package/dist/{chunk-PKWZG642.js → chunk-CLA4XSBO.js} +3 -3
- package/dist/{chunk-DAXKGMJL.js → chunk-D3Q2TABU.js} +5 -5
- package/dist/{chunk-AIY2Y5UY.js → chunk-DJFEYX23.js} +5 -5
- package/dist/{chunk-FVY2XRX4.js → chunk-DKEZSH6M.js} +2 -2
- package/dist/{chunk-LALLQUSK.js → chunk-DP5LF7GF.js} +2 -0
- package/dist/{chunk-Q52ISCT4.js → chunk-DQ26IA5P.js} +1 -1
- package/dist/{chunk-3WL7WU6K.js → chunk-ENE4IKFX.js} +19 -20
- package/dist/{chunk-JZVUSRZ5.js → chunk-EQ66MVWZ.js} +1 -1
- package/dist/{chunk-VWG7OQKU.js → chunk-EQGKUPBJ.js} +4 -1
- package/dist/{chunk-KZBBY72Q.js → chunk-F4EX52FU.js} +1 -1
- package/dist/{chunk-4JWKC3GH.js → chunk-FGIMC5I4.js} +5 -5
- package/dist/{chunk-CGAUUUDL.js → chunk-FHO3FXTW.js} +3 -3
- package/dist/chunk-FJ646TIT.js +201 -0
- package/dist/{chunk-77KGX4A3.js → chunk-FKFGGAXN.js} +50 -8
- package/dist/{chunk-VUEWZXZG.js → chunk-G6HUXX3L.js} +1 -1
- package/dist/{chunk-5YHQBCWH.js → chunk-G6OKQMJI.js} +12 -2
- package/dist/{chunk-VGKQFZCC.js → chunk-GNSNCIHF.js} +14 -14
- package/dist/{chunk-SXJJTFV4.js → chunk-H3I2VLLL.js} +16 -4
- package/dist/{chunk-UYEZTK4U.js → chunk-HPTFD6MO.js} +10 -10
- package/dist/{chunk-5KOZRJR7.js → chunk-HWHPYCBZ.js} +1 -1
- package/dist/{chunk-22OGII5H.js → chunk-I3G45TWG.js} +1 -1
- package/dist/{chunk-DMIFCIG6.js → chunk-IHYWP4V5.js} +1 -1
- package/dist/{chunk-5LITFBMY.js → chunk-ISMOBMWF.js} +35 -24
- package/dist/{chunk-DDRCX7P2.js → chunk-KL2UJXCY.js} +2 -2
- package/dist/{chunk-KDDO3UYI.js → chunk-KSMCX5EP.js} +3 -3
- package/dist/{chunk-UI7X4L4M.js → chunk-KVFOQ3EM.js} +2137 -2100
- package/dist/{chunk-472C35EW.js → chunk-KY67MTBH.js} +1 -1
- package/dist/{chunk-DPYI2HRJ.js → chunk-L34IH4SH.js} +5 -5
- package/dist/{chunk-AHPGAESX.js → chunk-L72RQ45A.js} +1 -1
- package/dist/{chunk-YWPCMOX4.js → chunk-LALMFSLB.js} +5 -5
- package/dist/{chunk-4D46TX6Q.js → chunk-LGDRKQKL.js} +1 -1
- package/dist/{chunk-DWIMUPFK.js → chunk-LTQXIYNL.js} +2 -2
- package/dist/{chunk-Z2UZAY2Q.js → chunk-LYON3VGF.js} +2 -2
- package/dist/{chunk-AQMGYRX6.js → chunk-MBSESQED.js} +1 -1
- package/dist/{chunk-ZPXXWUQ3.js → chunk-MFC2PE7D.js} +30 -4
- package/dist/{chunk-6J2G57BB.js → chunk-N3MOQTRS.js} +7 -7
- package/dist/chunk-N3ZAIZF3.js +4870 -0
- package/dist/{chunk-JLGVBK5M.js → chunk-N4XNRHFM.js} +18 -4
- package/dist/{chunk-3NIESDKN.js → chunk-NGJS5H5E.js} +1 -1
- package/dist/{chunk-DJ3H6EW3.js → chunk-NP4G4WPP.js} +10 -9
- package/dist/{chunk-RQNFW6YC.js → chunk-O63A26XQ.js} +8 -3
- package/dist/{chunk-XNFDDVJS.js → chunk-ONMTNYGR.js} +4 -1
- package/dist/{chunk-SJK64HHG.js → chunk-OWV36OJP.js} +5 -2
- package/dist/{chunk-4EO7DNRJ.js → chunk-PAZ7WUYZ.js} +2 -2
- package/dist/{chunk-K43XLAQV.js → chunk-Q55JNFDV.js} +3 -3
- package/dist/{chunk-CZCRSS3U.js → chunk-QHWVCKC5.js} +1 -1
- package/dist/{chunk-ORXLO64X.js → chunk-S2HWGG5O.js} +1 -1
- package/dist/{chunk-5AKWJHRJ.js → chunk-S3ZWVEGQ.js} +1 -1
- package/dist/chunk-SJGE5I5F.js +131 -0
- package/dist/{chunk-GSXA4YLV.js → chunk-STK62RL7.js} +1 -1
- package/dist/{chunk-B4KGJHTE.js → chunk-SZOCI3JJ.js} +2 -2
- package/dist/{chunk-PICG2XRD.js → chunk-TCCCAEZD.js} +2 -2
- package/dist/{chunk-KF6I5WA7.js → chunk-TDNPJHEQ.js} +15 -18
- package/dist/{chunk-BGC5S3OZ.js → chunk-TLXK5A2N.js} +49 -36
- package/dist/{chunk-6EN2LWOM.js → chunk-TWCICOCI.js} +1 -1
- package/dist/{chunk-NEQIJUV2.js → chunk-UBDO4EHA.js} +10 -1
- package/dist/{chunk-2QAR7ZNY.js → chunk-V2H5UABS.js} +3 -3
- package/dist/{chunk-3LACB6HG.js → chunk-VTX27LET.js} +3 -3
- package/dist/{chunk-3JYKWNFR.js → chunk-VVDHSRKD.js} +1 -1
- package/dist/{chunk-2RQZQJHV.js → chunk-WSEPFRJV.js} +1 -1
- package/dist/{chunk-K3LLHG6I.js → chunk-XNY2KI2Z.js} +1 -1
- package/dist/{chunk-ZNSKOXFW.js → chunk-Z65ZQYBW.js} +3 -3
- package/dist/{chunk-QVHC77IF.js → chunk-Z7QHOT65.js} +2 -2
- package/dist/{chunk-LAR5VTCN.js → chunk-ZGG53XZX.js} +5 -5
- package/dist/{chunk-67JTGRNM.js → chunk-ZSRNM6LP.js} +1 -1
- package/dist/{chunk-IEVU4FXB.js → chunk-ZTCILR3V.js} +3 -3
- package/dist/{clean-SVEOBRPM.js → clean-XBQ54UZX.js} +22 -21
- package/dist/cli.js +151 -82
- package/dist/{cloud-ADFJGIEH.js → cloud-E2GUGXXL.js} +4 -4
- package/dist/{cloudrun-BNY7Q5RK.js → cloudrun-IAPFT66T.js} +23 -20
- package/dist/commands/layout-audit.browser.js +7 -10
- package/dist/{compare-QC3T22KV.js → compare-2VPIOCLV.js} +45 -46
- package/dist/{compiler-4ITKK4XI.js → compiler-3ED6KJYN.js} +3 -3
- package/dist/{component-CNZCB3RY.js → component-IH2KSDNM.js} +6 -5
- package/dist/{compositions-UO32IP6Z.js → compositions-MIMF2GM3.js} +14 -13
- package/dist/{delete-RWTOSI24.js → delete-5H5EYSYK.js} +13 -11
- package/dist/{deploy-OKWS53NP.js → deploy-DMQT34K2.js} +5 -5
- package/dist/{destroy-4RL5VOXQ.js → destroy-BQ5R7LUF.js} +3 -3
- package/dist/{deterministicFonts-LKAGUNE5.js → deterministicFonts-2ISM3LMW.js} +1 -1
- package/dist/{dist-AEE3QTRB.js → dist-ANQ2CIIO.js} +2 -2
- package/dist/{dist-NCI6JOJZ.js → dist-OKQM7BQ3.js} +3 -1
- package/dist/{docs-UMIA66EZ.js → docs-6EM6FDNI.js} +5 -4
- package/dist/{doctor-SIF72ESZ.js → doctor-MTRZJQZZ.js} +12 -10
- package/dist/{events-S3VUTFEG.js → events-2GNMM2YS.js} +5 -3
- package/dist/{events-34PIVLZQ.js → events-TBKM6B5H.js} +8 -5
- package/dist/{feedback-VS4LRXHW.js → feedback-6NNSKXQP.js} +20 -19
- package/dist/{ffmpeg-YVQOKNV6.js → ffmpeg-622QCJLB.js} +6 -6
- package/dist/{figma-AF4JKDBA.js → figma-TFHZ3N5A.js} +3 -3
- package/dist/fontLocalizeCli.js +11 -11
- package/dist/{get-UQGCS6Q4.js → get-P6RA7MAU.js} +8 -7
- package/dist/{gpuPolicy-Q4B3D6PW.js → gpuPolicy-CK2XDEAM.js} +6 -6
- package/dist/{grade-compare-G34673XC.js → grade-compare-LK6U7OJD.js} +47 -45
- package/dist/{heifImagePrep-XD4DGOUS.js → heifImagePrep-3OXKQUEZ.js} +7 -7
- package/dist/{help-3QSD26IC.js → help-YENCFXYK.js} +11 -7
- package/dist/{history-6DC24UCF.js → history-V3E4UCMY.js} +15 -12
- package/dist/hyperframe.manifest.json +1 -1
- package/dist/hyperframe.runtime.iife.js +64 -64
- package/dist/hyperframes-player.global.js +1 -1
- package/dist/{info-6JUHWWJK.js → info-ZGKQMX3Z.js} +11 -10
- package/dist/{init-2DPX6U3J.js → init-D6PJI2TA.js} +38 -37
- package/dist/{inspect-Z55YUSXC.js → inspect-UCHLILOX.js} +33 -32
- package/dist/{installer-XVKYJU7S.js → installer-CV2OKJFW.js} +4 -4
- package/dist/{keyframes-YHF4AQIL.js → keyframes-2IJTDJ7K.js} +10 -9
- package/dist/{lambda-JITTS37E.js → lambda-GKZBKWTK.js} +32 -30
- package/dist/{layout-V5NYJXIX.js → layout-KKPRCTME.js} +33 -32
- package/dist/{lint-V4WMO7YL.js → lint-NAC6M4NT.js} +18 -15
- package/dist/{lintProject-EM7Y2ZRB.js → lintProject-MSATZIK7.js} +1 -1
- package/dist/{list-W7UCIYKA.js → list-QRMXOTNB.js} +11 -10
- package/dist/{live-LAHBXVK2.js → live-WWPFZQ74.js} +33 -7
- package/dist/{localPage-BLQFFIDF.js → localPage-KMXALM7A.js} +6 -6
- package/dist/{login-IX3MOREU.js → login-GBN5ZMEA.js} +11 -11
- package/dist/{logout-46NLNY2K.js → logout-C6P6ERZ3.js} +5 -5
- package/dist/{manager-WJOWZNHM.js → manager-GPDDRQIW.js} +8 -8
- package/dist/{media-treatment-XBO6EXL4.js → media-treatment-4Q7G27JJ.js} +44 -34
- package/dist/{media-use-3RFKY7XJ.js → media-use-ZRHFRO46.js} +1 -1
- package/dist/{models-P3NSHDQS.js → models-7KJF4LYJ.js} +27 -20
- package/dist/{motionShot-D4QMLTQP.js → motionShot-DQAX2QTZ.js} +17 -16
- package/dist/{normalize-audio-Q4VUR3QJ.js → normalize-audio-K7VCJQYJ.js} +30 -19
- package/dist/{open-LGKX534P.js → open-ZSBVR3KC.js} +17 -16
- package/dist/{parakeetRunner-FAOQMPS6.js → parakeetRunner-XXZHJYKO.js} +12 -12
- package/dist/{pipeline-2YONKZYC.js → pipeline-KNLOS5CL.js} +11 -11
- package/dist/{play-PJOUIY55.js → play-GQWF7MU5.js} +32 -34
- package/dist/{policies-UPNRQ7IW.js → policies-J5BWAZHM.js} +11 -10
- package/dist/{preflight-3PPM7QBU.js → preflight-UMKQ5C5W.js} +7 -7
- package/dist/{present-323D6OE2.js → present-X7BPH35M.js} +28 -30
- package/dist/{preview-E42QP2KX.js → preview-5Q7HPEOF.js} +25 -24
- package/dist/{producer-MTMNLJSC.js → producer-IXOPGETH.js} +1 -1
- package/dist/{progress-LMQ2DXM4.js → progress-X3QFO3FE.js} +4 -4
- package/dist/{projectConfig-5QRVB5KY.js → projectConfig-YGI5AINR.js} +6 -6
- package/dist/{prompts-P3IT5H36.js → prompts-VAO7RDKX.js} +2 -2
- package/dist/{publication-AUZLFOG5.js → publication-ZSDCS2ST.js} +2 -2
- package/dist/{publish-H5P7UHRV.js → publish-S2IIRPFZ.js} +18 -18
- package/dist/{refresh-4XRQS3N6.js → refresh-IYRGLHG5.js} +5 -5
- package/dist/{remove-background-T2RV476S.js → remove-background-F2WFDCNM.js} +22 -18
- package/dist/{render-4XEB3XWI.js → render-CHRSSQNM.js} +60 -58
- package/dist/{render-3FRGIWES.js → render-NVHUPEDG.js} +28 -27
- package/dist/{render-GJH7446R.js → render-WYBQO4SR.js} +11 -10
- package/dist/{render-batch-77X5453X.js → render-batch-SDGA2643.js} +12 -11
- package/dist/renderSetupWorker.js +1 -1
- package/dist/{resolver-DIUNK525.js → resolver-3W2OPVGC.js} +4 -4
- package/dist/{sam-FHJ7IL7T.js → sam-QA7JT7IM.js} +2 -1
- package/dist/{sherpa-SUS3YSEP.js → sherpa-HCPAOYGA.js} +11 -11
- package/dist/{sites-V42IFVTK.js → sites-MTLVMYJ6.js} +2 -2
- package/dist/{skills-YCGSIOCE.js → skills-KOVM4OP5.js} +17 -13
- package/dist/{skillsUpdateCheck-VCQIZGOL.js → skillsUpdateCheck-ISMQFMPY.js} +5 -3
- package/dist/{snapshot-H6R5PWNS.js → snapshot-K7LVZDHG.js} +340 -107
- package/dist/{src-ED5VCIRC.js → src-FUMXFZYG.js} +10 -10
- package/dist/{src-HHDLJV4L.js → src-QEFKMRH7.js} +11 -5
- package/dist/{state-D5SYQFCB.js → state-6QHNNHDA.js} +2 -2
- package/dist/{staticProjectServer-VY7QG5XH.js → staticProjectServer-MF57NBIU.js} +18 -18
- package/dist/{status-GEZNVPII.js → status-SLILCDBZ.js} +12 -7
- package/dist/studio/assets/{hyperframes-player-CzrqgMUX.js → hyperframes-player-Bb6n05RB.js} +1 -1
- package/dist/studio/assets/{index-B3SPHPi1.js → index-DOtf09XR.js} +1 -1
- package/dist/studio/assets/{index-k4nVfS2D.js → index-pq574E5O.js} +119 -119
- package/dist/studio/index.html +1 -1
- package/dist/{studio-api-TR5RPX57.js → studio-api-Y4S3W7XE.js} +10 -10
- package/dist/{studioServer-4SZLLQOV.js → studioServer-5LUZQOQV.js} +53 -52
- package/dist/{synthesize-QALK5SQR.js → synthesize-FQML2LN2.js} +2 -2
- package/dist/{telemetry-KGY7G3UR.js → telemetry-NTO4FJFN.js} +5 -4
- package/dist/{telemetry-7HUKOQ6X.js → telemetry-TJMB5BTF.js} +6 -5
- package/dist/{timeline-CGIKWCQI.js → timeline-CU6CIWYL.js} +31 -27
- package/dist/{tokens-AZALDJEK.js → tokens-7P4N2FWN.js} +5 -4
- package/dist/{transcribe-CTF5EIXJ.js → transcribe-FZ7JK6QS.js} +28 -25
- package/dist/{transcribe-V6K5547L.js → transcribe-TFDEQFMG.js} +10 -10
- package/dist/{tts-C2HBLFKK.js → tts-K5HRN6NQ.js} +17 -13
- package/dist/{updateCheck-5I563YLB.js → updateCheck-HUDVZHVM.js} +4 -2
- package/dist/{upgrade-GRPVQE7Z.js → upgrade-KP4RQZKY.js} +7 -6
- package/dist/{urlDownloader-EP6Q4WES.js → urlDownloader-5SHSHWMB.js} +5 -5
- package/dist/{validate-TVCDSQS3.js → validate-VWX423M4.js} +27 -26
- package/dist/{video-CFEIRKAE.js → video-K4L2YFU2.js} +10 -10
- package/dist/warmCheck.js +44 -43
- package/package.json +1 -1
- package/dist/chunk-FWKZ3O52.js +0 -4870
- package/dist/chunk-WQ6ZXHFQ.js +0 -133
|
@@ -12,31 +12,33 @@ import {
|
|
|
12
12
|
} from "./chunk-6A45RKAK.js";
|
|
13
13
|
import {
|
|
14
14
|
describeProject
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-ZGG53XZX.js";
|
|
16
16
|
import "./chunk-LLMSX6V6.js";
|
|
17
17
|
import {
|
|
18
|
+
PITCH_RATE,
|
|
18
19
|
bandFramesOf,
|
|
19
20
|
envelope,
|
|
20
21
|
loudness,
|
|
21
22
|
medianInterval,
|
|
23
|
+
pitchTrack,
|
|
22
24
|
rhythm,
|
|
23
25
|
runLadder,
|
|
24
26
|
signalDuration,
|
|
25
27
|
signalProvider,
|
|
26
28
|
snapper,
|
|
27
29
|
tempoOf
|
|
28
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-6CGYINE7.js";
|
|
29
31
|
import {
|
|
30
32
|
ensureDOMParser
|
|
31
33
|
} from "./chunk-ZBAF6L74.js";
|
|
32
34
|
import {
|
|
33
35
|
refreshIfNeeded,
|
|
34
36
|
resolveCloudBaseUrl
|
|
35
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-VVDHSRKD.js";
|
|
36
38
|
import {
|
|
37
39
|
buildAuthHeaders,
|
|
38
40
|
tryResolveCredential
|
|
39
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-7TWX4Y7I.js";
|
|
40
42
|
import {
|
|
41
43
|
downloadToFile
|
|
42
44
|
} from "./chunk-NO6F7CLR.js";
|
|
@@ -49,34 +51,31 @@ import {
|
|
|
49
51
|
} from "./chunk-6MUI2H6P.js";
|
|
50
52
|
import {
|
|
51
53
|
resolveProject
|
|
52
|
-
} from "./chunk-
|
|
54
|
+
} from "./chunk-ZTCILR3V.js";
|
|
53
55
|
import "./chunk-CTZJSMGU.js";
|
|
54
|
-
import "./chunk-
|
|
55
|
-
import "./chunk-
|
|
56
|
+
import "./chunk-MBSESQED.js";
|
|
57
|
+
import "./chunk-5ZBMHUY2.js";
|
|
56
58
|
import "./chunk-A4ZTSQLW.js";
|
|
57
|
-
import "./chunk-
|
|
58
|
-
import "./chunk-
|
|
59
|
-
import "./chunk-
|
|
59
|
+
import "./chunk-H3I2VLLL.js";
|
|
60
|
+
import "./chunk-76T7KAYD.js";
|
|
61
|
+
import "./chunk-EQGKUPBJ.js";
|
|
60
62
|
import {
|
|
61
63
|
assertKnownFlags
|
|
62
|
-
} from "./chunk-
|
|
64
|
+
} from "./chunk-FKFGGAXN.js";
|
|
63
65
|
import {
|
|
64
66
|
defineCommand
|
|
65
67
|
} from "./chunk-DL4OD7IA.js";
|
|
66
68
|
import "./chunk-S3S4TGEH.js";
|
|
67
69
|
import "./chunk-54HJ63Q2.js";
|
|
68
|
-
import {
|
|
69
|
-
CliUsageError
|
|
70
|
-
} from "./chunk-LALLQUSK.js";
|
|
71
70
|
import "./chunk-2GICKZ3I.js";
|
|
72
|
-
import "./chunk-
|
|
71
|
+
import "./chunk-KVFOQ3EM.js";
|
|
73
72
|
import "./chunk-Z5J67X44.js";
|
|
74
73
|
import "./chunk-5S7W3TUO.js";
|
|
75
74
|
import "./chunk-D3MUHMFG.js";
|
|
76
|
-
import "./chunk-
|
|
75
|
+
import "./chunk-AJ3QW6RX.js";
|
|
77
76
|
import "./chunk-YWRUQ7XZ.js";
|
|
78
|
-
import "./chunk-
|
|
79
|
-
import "./chunk-
|
|
77
|
+
import "./chunk-KY67MTBH.js";
|
|
78
|
+
import "./chunk-N3ZAIZF3.js";
|
|
80
79
|
import "./chunk-VC76R6W2.js";
|
|
81
80
|
import "./chunk-OFQWTKPW.js";
|
|
82
81
|
import "./chunk-RQVDTPGD.js";
|
|
@@ -86,7 +85,7 @@ import "./chunk-FXMKHHPO.js";
|
|
|
86
85
|
import "./chunk-5766TK7Q.js";
|
|
87
86
|
import "./chunk-K4MJX7SR.js";
|
|
88
87
|
import "./chunk-WE42NVH7.js";
|
|
89
|
-
import "./chunk-
|
|
88
|
+
import "./chunk-4645UHJF.js";
|
|
90
89
|
import "./chunk-CZGHFATT.js";
|
|
91
90
|
import {
|
|
92
91
|
findFfBinary
|
|
@@ -105,12 +104,16 @@ import "./chunk-WC4MTXGN.js";
|
|
|
105
104
|
import "./chunk-32NEJ553.js";
|
|
106
105
|
import {
|
|
107
106
|
withMeta
|
|
108
|
-
} from "./chunk-
|
|
107
|
+
} from "./chunk-O63A26XQ.js";
|
|
109
108
|
import "./chunk-K4WIOZFP.js";
|
|
110
109
|
import "./chunk-ZCHULPJZ.js";
|
|
111
110
|
import "./chunk-ISN5GRYI.js";
|
|
111
|
+
import "./chunk-SJGE5I5F.js";
|
|
112
|
+
import {
|
|
113
|
+
CliUsageError
|
|
114
|
+
} from "./chunk-DP5LF7GF.js";
|
|
112
115
|
import "./chunk-J3RXEDR2.js";
|
|
113
|
-
import "./chunk-
|
|
116
|
+
import "./chunk-KL2UJXCY.js";
|
|
114
117
|
import "./chunk-E63BDV4Z.js";
|
|
115
118
|
import "./chunk-G7VEYUZ2.js";
|
|
116
119
|
import "./chunk-XT6MXC7A.js";
|
|
@@ -118,7 +121,7 @@ import "./chunk-7KDQAD2W.js";
|
|
|
118
121
|
import "./chunk-M2WBOQ2Q.js";
|
|
119
122
|
|
|
120
123
|
// src/commands/audio.ts
|
|
121
|
-
import { join as
|
|
124
|
+
import { join as join8, resolve as resolve2 } from "path";
|
|
122
125
|
|
|
123
126
|
// src/audio/analysis/providers/api.ts
|
|
124
127
|
import { randomUUID } from "crypto";
|
|
@@ -797,6 +800,10 @@ function targetOf(projectDir, row, query) {
|
|
|
797
800
|
window: {
|
|
798
801
|
from: fileTime(placement, from),
|
|
799
802
|
seconds: round4((to - from) * placement.playbackRate)
|
|
803
|
+
},
|
|
804
|
+
clip: {
|
|
805
|
+
from: placement.mediaStart,
|
|
806
|
+
seconds: round4((placement.end - placement.start) * placement.playbackRate)
|
|
800
807
|
}
|
|
801
808
|
};
|
|
802
809
|
}
|
|
@@ -923,8 +930,83 @@ function formatReport(report) {
|
|
|
923
930
|
|
|
924
931
|
// src/audio/analysis/run.ts
|
|
925
932
|
import { existsSync as existsSync3 } from "fs";
|
|
933
|
+
|
|
934
|
+
// src/audio/analysis/kindCache.ts
|
|
935
|
+
import { createHash as createHash2, randomUUID as randomUUID2 } from "crypto";
|
|
936
|
+
import { mkdirSync, readFileSync, renameSync, rmSync, statSync, writeFileSync } from "fs";
|
|
937
|
+
import { dirname as dirname2, join as join5 } from "path";
|
|
938
|
+
var CACHE_VERSION = 1;
|
|
939
|
+
var record = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
940
|
+
var finite = (value) => typeof value === "number" && Number.isFinite(value);
|
|
941
|
+
var probability = (value) => finite(value) && value >= 0 && value <= 1;
|
|
942
|
+
function isKindFeatures(value) {
|
|
943
|
+
return record(value) && finite(value.duration) && value.duration >= 0 && [value.regularity, value.syllables, value.sustain].every(probability) && (value.voiced === void 0 || probability(value.voiced));
|
|
944
|
+
}
|
|
945
|
+
function isKindGuess(value) {
|
|
946
|
+
return record(value) && typeof value.value === "string" && ["sfx", "music", "voice", "mixed"].includes(value.value) && probability(value.confidence) && isKindFeatures(value.features);
|
|
947
|
+
}
|
|
948
|
+
function kindSourceIdentity(path) {
|
|
949
|
+
const { size, mtimeMs, ctimeMs, ino } = statSync(path);
|
|
950
|
+
return JSON.stringify({ size, mtimeMs, ctimeMs, ino });
|
|
951
|
+
}
|
|
952
|
+
function kindCacheFile(dir, target, request, sampleRate, source = kindSourceIdentity(target.path)) {
|
|
953
|
+
const key = JSON.stringify({
|
|
954
|
+
version: CACHE_VERSION,
|
|
955
|
+
path: target.path,
|
|
956
|
+
source,
|
|
957
|
+
clip: target.clip,
|
|
958
|
+
sampleRate,
|
|
959
|
+
quality: request.quality,
|
|
960
|
+
provider: request.provider?.kind,
|
|
961
|
+
options: request.options?.kind
|
|
962
|
+
});
|
|
963
|
+
return join5(dir, `${createHash2("sha256").update(key).digest("hex")}.json`);
|
|
964
|
+
}
|
|
965
|
+
function readKindCache(file) {
|
|
966
|
+
if (file === null) return null;
|
|
967
|
+
let value;
|
|
968
|
+
try {
|
|
969
|
+
value = JSON.parse(readFileSync(file, "utf8"));
|
|
970
|
+
} catch {
|
|
971
|
+
return null;
|
|
972
|
+
}
|
|
973
|
+
if (!isKindGuess(value)) return null;
|
|
974
|
+
return {
|
|
975
|
+
analyzed: value.features.duration,
|
|
976
|
+
values: { kind: value },
|
|
977
|
+
provenance: { kind: "signal" },
|
|
978
|
+
ladder: { kind: [{ provider: "signal", outcome: "answered" }] },
|
|
979
|
+
warnings: []
|
|
980
|
+
};
|
|
981
|
+
}
|
|
982
|
+
function writeKindCache(file, value) {
|
|
983
|
+
const temporary = `${file}.${randomUUID2()}.tmp`;
|
|
984
|
+
try {
|
|
985
|
+
mkdirSync(dirname2(file), { recursive: true });
|
|
986
|
+
writeFileSync(temporary, JSON.stringify(value));
|
|
987
|
+
renameSync(temporary, file);
|
|
988
|
+
return null;
|
|
989
|
+
} catch {
|
|
990
|
+
return "kind could not be cached; another query will analyze the clip again";
|
|
991
|
+
} finally {
|
|
992
|
+
try {
|
|
993
|
+
rmSync(temporary, { force: true });
|
|
994
|
+
} catch {
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
function cacheKindAnalysis(file, analysis) {
|
|
999
|
+
if (analysis.provenance.kind !== "signal" || analysis.warnings.length || !isKindGuess(analysis.values.kind))
|
|
1000
|
+
return;
|
|
1001
|
+
const warning = writeKindCache(file, analysis.values.kind);
|
|
1002
|
+
if (warning) analysis.warnings.push(warning);
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
// src/audio/analysis/run.ts
|
|
926
1006
|
var round5 = (t) => Math.round(t * 1e3) / 1e3;
|
|
927
1007
|
var EDGE_CONTEXT_SECONDS = 0.1;
|
|
1008
|
+
var KIND_SAMPLE_RATE = 16e3;
|
|
1009
|
+
var KIND_DECODE_BYTES = 256 * 1024 * 1024;
|
|
928
1010
|
async function previewTarget(path, file, at, mediaStart = 0) {
|
|
929
1011
|
if (at === null) return { path, file, ref: null, kind: "file", placement: null };
|
|
930
1012
|
const stream = existsSync3(path) ? await probeAudio(path) : null;
|
|
@@ -998,16 +1080,81 @@ async function skippedPeak(target, kept, stream) {
|
|
|
998
1080
|
`the loudest part of ${target.file} is in the first ${round5(skipped)} s, which is skipped`
|
|
999
1081
|
];
|
|
1000
1082
|
}
|
|
1001
|
-
|
|
1083
|
+
function coversPart({ window, clip }) {
|
|
1084
|
+
return !!window && !!clip && (window.from > clip.from || window.from + window.seconds < clip.from + clip.seconds);
|
|
1085
|
+
}
|
|
1086
|
+
function clipKindRate(target, stream) {
|
|
1087
|
+
const seconds = Math.min(target.clip.seconds, Math.max(0, stream.duration - target.clip.from));
|
|
1088
|
+
const bytes = seconds * stream.sampleRate * stream.channels * 4;
|
|
1089
|
+
return bytes <= KIND_DECODE_BYTES ? stream.sampleRate : Math.min(stream.sampleRate, KIND_SAMPLE_RATE);
|
|
1090
|
+
}
|
|
1091
|
+
async function clipKindSignal(target, stream, sampleRate, windowSignal) {
|
|
1092
|
+
if (windowSignal) return windowSignal;
|
|
1093
|
+
const seconds = Math.min(target.clip.seconds, Math.max(0, stream.duration - target.clip.from));
|
|
1094
|
+
if (seconds * sampleRate * stream.channels * 4 > KIND_DECODE_BYTES)
|
|
1095
|
+
throw new Error("whole clip exceeds the kind analysis decode limit");
|
|
1096
|
+
return (await decodeAudio(target.path, target.clip, stream, { sampleRate }))?.signal;
|
|
1097
|
+
}
|
|
1098
|
+
async function clipKind(target, request, stream, cache, windowSignal) {
|
|
1099
|
+
const sampleRate = windowSignal ? stream.sampleRate : clipKindRate(target, stream);
|
|
1100
|
+
const file = cache ? kindCacheFile(cache.dir, target, request, sampleRate, cache.identity) : null;
|
|
1101
|
+
const cached = readKindCache(file);
|
|
1102
|
+
if (cached) return cached;
|
|
1103
|
+
const signal = await clipKindSignal(target, stream, sampleRate, windowSignal);
|
|
1104
|
+
if (!signal) return null;
|
|
1105
|
+
const analysis = await analyzeSignal(signal, {
|
|
1106
|
+
...request,
|
|
1107
|
+
capabilities: ["kind"],
|
|
1108
|
+
fileOffset: target.clip.from,
|
|
1109
|
+
context: windowSignal ? request.context : void 0
|
|
1110
|
+
});
|
|
1111
|
+
if (file && cache && file === kindCacheFile(cache.dir, target, request, sampleRate))
|
|
1112
|
+
cacheKindAnalysis(file, analysis);
|
|
1113
|
+
return analysis;
|
|
1114
|
+
}
|
|
1115
|
+
async function analyzeWindow(target, signal, request, stream, cache) {
|
|
1116
|
+
const kindApart = request.capabilities.includes("kind") && target.clip !== void 0;
|
|
1117
|
+
if (!kindApart) return analyzeSignal(signal, request);
|
|
1118
|
+
const analysis = await analyzeSignal(signal, {
|
|
1119
|
+
...request,
|
|
1120
|
+
capabilities: request.capabilities.filter((capability) => capability !== "kind")
|
|
1121
|
+
});
|
|
1122
|
+
let kind;
|
|
1123
|
+
try {
|
|
1124
|
+
kind = await clipKind(target, request, stream, cache, coversPart(target) ? void 0 : signal);
|
|
1125
|
+
if (!kind) throw new Error("no audio stream");
|
|
1126
|
+
} catch (error) {
|
|
1127
|
+
kind = await analyzeSignal(signal, { ...request, capabilities: ["kind"] });
|
|
1128
|
+
const reason = error instanceof Error ? error.message.split("\n")[0] : String(error);
|
|
1129
|
+
kind.warnings.push(
|
|
1130
|
+
`kind uses only the selected range: could not analyze the whole clip (${reason})`
|
|
1131
|
+
);
|
|
1132
|
+
}
|
|
1133
|
+
return {
|
|
1134
|
+
...analysis,
|
|
1135
|
+
values: { ...analysis.values, kind: kind.values.kind },
|
|
1136
|
+
provenance: { ...analysis.provenance, ...kind.provenance },
|
|
1137
|
+
ladder: { ...analysis.ladder, ...kind.ladder },
|
|
1138
|
+
warnings: [.../* @__PURE__ */ new Set([...analysis.warnings, ...kind.warnings])]
|
|
1139
|
+
};
|
|
1140
|
+
}
|
|
1141
|
+
async function analyzeTarget(target, request, full, cacheDir) {
|
|
1002
1142
|
const item = emptyItem(target);
|
|
1003
1143
|
const problem = unreadable(target);
|
|
1004
1144
|
if (problem) return { ...item, error: problem };
|
|
1005
1145
|
const stream = await probeAudio(target.path);
|
|
1006
1146
|
if (!stream) return { ...item, error: "no audio stream" };
|
|
1147
|
+
const cache = cacheDir ? { dir: cacheDir, identity: kindSourceIdentity(target.path) } : void 0;
|
|
1007
1148
|
const { from, read: read2, context } = decodeSpan(target, stream);
|
|
1008
1149
|
const decoded = await decodeAudio(target.path, read2, stream);
|
|
1009
1150
|
if (!decoded) return { ...item, error: "no audio stream" };
|
|
1010
|
-
const analysis = await
|
|
1151
|
+
const analysis = await analyzeWindow(
|
|
1152
|
+
target,
|
|
1153
|
+
decoded.signal,
|
|
1154
|
+
{ ...request, fileOffset: from, context },
|
|
1155
|
+
stream,
|
|
1156
|
+
cache
|
|
1157
|
+
);
|
|
1011
1158
|
return {
|
|
1012
1159
|
...item,
|
|
1013
1160
|
window: { from: round5(from), to: round5(from + analysis.analyzed) },
|
|
@@ -1027,11 +1174,11 @@ async function analyzeTarget(target, request, full) {
|
|
|
1027
1174
|
]
|
|
1028
1175
|
};
|
|
1029
1176
|
}
|
|
1030
|
-
async function analyzeTargets(targets, request, full = false) {
|
|
1177
|
+
async function analyzeTargets(targets, request, full = false, cacheDir) {
|
|
1031
1178
|
const items = [];
|
|
1032
1179
|
for (const target of targets) {
|
|
1033
1180
|
try {
|
|
1034
|
-
items.push(await analyzeTarget(target, request, full));
|
|
1181
|
+
items.push(await analyzeTarget(target, request, full, cacheDir));
|
|
1035
1182
|
} catch (error) {
|
|
1036
1183
|
const reason = error instanceof Error ? error.message.split("\n")[0] : String(error);
|
|
1037
1184
|
items.push({ ...emptyItem(target), error: `could not read: ${reason}` });
|
|
@@ -1040,119 +1187,7 @@ async function analyzeTargets(targets, request, full = false) {
|
|
|
1040
1187
|
return { version: 1, items };
|
|
1041
1188
|
}
|
|
1042
1189
|
|
|
1043
|
-
// src/audio/read/signal.ts
|
|
1044
|
-
var READ_RATE = 22050;
|
|
1045
|
-
var PITCH_RATE = 8e3;
|
|
1046
|
-
var SILENT_DB = -120;
|
|
1047
|
-
var ABSENT_DB = -55;
|
|
1048
|
-
async function decodeMono(path, sampleRate = READ_RATE) {
|
|
1049
|
-
const decoded = await decodeAudio(path, {}, void 0, { sampleRate, mono: true });
|
|
1050
|
-
if (!decoded) throw new Error(`${path} has no audio stream`);
|
|
1051
|
-
const samples = decoded.signal.channels[0];
|
|
1052
|
-
if (samples.some((sample) => !Number.isFinite(sample)))
|
|
1053
|
-
throw new Error(`${path} contains non-finite audio samples`);
|
|
1054
|
-
return samples;
|
|
1055
|
-
}
|
|
1056
|
-
var asSignal = (samples, sampleRate = READ_RATE) => ({
|
|
1057
|
-
sampleRate,
|
|
1058
|
-
channels: [samples]
|
|
1059
|
-
});
|
|
1060
|
-
function mixed(tracks) {
|
|
1061
|
-
const length = Math.max(0, ...tracks.map((t) => t.length));
|
|
1062
|
-
const sum = new Float32Array(length);
|
|
1063
|
-
for (const track2 of tracks) for (let i = 0; i < track2.length; i++) sum[i] += track2[i];
|
|
1064
|
-
return sum;
|
|
1065
|
-
}
|
|
1066
|
-
function levels(samples, sampleRate, hop, window = hop * 2) {
|
|
1067
|
-
const hopSamples = Math.max(1, hop * sampleRate);
|
|
1068
|
-
const half = Math.max(1, Math.round(window * sampleRate / 2));
|
|
1069
|
-
const squares = new Float64Array(samples.length + 1);
|
|
1070
|
-
for (let i = 0; i < samples.length; i++) squares[i + 1] = squares[i] + samples[i] ** 2;
|
|
1071
|
-
const frames = Math.ceil(samples.length / hopSamples);
|
|
1072
|
-
const out = new Float32Array(frames);
|
|
1073
|
-
for (let f = 0; f < frames; f++) {
|
|
1074
|
-
const center = Math.round(f * hopSamples);
|
|
1075
|
-
const a = Math.max(0, center - half);
|
|
1076
|
-
const b = Math.min(samples.length, center + half);
|
|
1077
|
-
const power = b > a ? (squares[b] - squares[a]) / (b - a) : 0;
|
|
1078
|
-
out[f] = power > 0 ? Math.max(SILENT_DB, 10 * Math.log10(power)) : SILENT_DB;
|
|
1079
|
-
}
|
|
1080
|
-
return out;
|
|
1081
|
-
}
|
|
1082
|
-
function levelWhileHeardDb(samples, sampleRate) {
|
|
1083
|
-
let sum = 0;
|
|
1084
|
-
let heard = 0;
|
|
1085
|
-
for (const db of levels(samples, sampleRate, 0.1, 0.4))
|
|
1086
|
-
if (db >= ABSENT_DB) {
|
|
1087
|
-
sum += 10 ** (db / 10);
|
|
1088
|
-
heard++;
|
|
1089
|
-
}
|
|
1090
|
-
return heard ? Math.round(10 * Math.log10(sum / heard)) : null;
|
|
1091
|
-
}
|
|
1092
|
-
function quantile(values, q) {
|
|
1093
|
-
if (!values.length) return NaN;
|
|
1094
|
-
const sorted = Float64Array.from(values).sort();
|
|
1095
|
-
return sorted[Math.min(sorted.length - 1, Math.max(0, Math.floor(q * (sorted.length - 1))))];
|
|
1096
|
-
}
|
|
1097
|
-
var median = (values) => quantile(values, 0.5);
|
|
1098
|
-
var round6 = (n, places = 2) => {
|
|
1099
|
-
const k = 10 ** places;
|
|
1100
|
-
return Math.round(n * k) / k;
|
|
1101
|
-
};
|
|
1102
|
-
function spanDb(samples, sampleRate, start, end) {
|
|
1103
|
-
const a = Math.max(0, Math.round(start * sampleRate));
|
|
1104
|
-
const b = Math.min(samples.length, Math.round(end * sampleRate));
|
|
1105
|
-
let sum = 0;
|
|
1106
|
-
for (let i = a; i < b; i++) sum += samples[i] ** 2;
|
|
1107
|
-
return b > a && sum > 0 ? Math.max(SILENT_DB, 10 * Math.log10(sum / (b - a))) : SILENT_DB;
|
|
1108
|
-
}
|
|
1109
|
-
|
|
1110
1190
|
// src/audio/read/pitch.ts
|
|
1111
|
-
var FRAME = 320;
|
|
1112
|
-
var HOP = 320;
|
|
1113
|
-
var LOW_HZ = 70;
|
|
1114
|
-
var HIGH_HZ = 500;
|
|
1115
|
-
var VOICED_DB = -35;
|
|
1116
|
-
var PERIODIC = 0.15;
|
|
1117
|
-
var MIN_LAG = Math.floor(PITCH_RATE / HIGH_HZ);
|
|
1118
|
-
var MAX_LAG = Math.ceil(PITCH_RATE / LOW_HZ);
|
|
1119
|
-
function voiced(pcm, start) {
|
|
1120
|
-
let energy = 0;
|
|
1121
|
-
for (let i = 0; i < FRAME; i++) energy += pcm[start + i] ** 2;
|
|
1122
|
-
return 10 * Math.log10(energy / FRAME + 1e-12) >= VOICED_DB;
|
|
1123
|
-
}
|
|
1124
|
-
function difference(pcm, start, tau) {
|
|
1125
|
-
let sum = 0;
|
|
1126
|
-
for (let i = 0; i < FRAME; i++) {
|
|
1127
|
-
const delta = pcm[start + i] - pcm[start + i + tau];
|
|
1128
|
-
sum += delta * delta;
|
|
1129
|
-
}
|
|
1130
|
-
return sum;
|
|
1131
|
-
}
|
|
1132
|
-
function periodOf(pcm, start, d) {
|
|
1133
|
-
let running = 0;
|
|
1134
|
-
let lag = -1;
|
|
1135
|
-
for (let tau = 1; tau <= MAX_LAG; tau++) {
|
|
1136
|
-
const sum = difference(pcm, start, tau);
|
|
1137
|
-
running += sum;
|
|
1138
|
-
d[tau] = running > 0 ? sum * tau / running : 1;
|
|
1139
|
-
if (lag === -1) {
|
|
1140
|
-
if (tau >= MIN_LAG && d[tau] < PERIODIC) lag = tau;
|
|
1141
|
-
} else if (d[tau] > d[tau - 1]) break;
|
|
1142
|
-
else if (d[tau] < d[lag]) lag = tau;
|
|
1143
|
-
}
|
|
1144
|
-
return lag;
|
|
1145
|
-
}
|
|
1146
|
-
function pitchTrack(pcm) {
|
|
1147
|
-
const out = [];
|
|
1148
|
-
const d = new Float64Array(MAX_LAG + 1);
|
|
1149
|
-
for (let start = 0; start + FRAME + MAX_LAG <= pcm.length; start += HOP) {
|
|
1150
|
-
if (!voiced(pcm, start)) continue;
|
|
1151
|
-
const lag = periodOf(pcm, start, d);
|
|
1152
|
-
if (lag > 0) out.push({ t: (start + FRAME / 2) / PITCH_RATE, hz: PITCH_RATE / lag });
|
|
1153
|
-
}
|
|
1154
|
-
return out;
|
|
1155
|
-
}
|
|
1156
1191
|
function within2(track2, start, end) {
|
|
1157
1192
|
let lo = 0;
|
|
1158
1193
|
let hi = track2.length;
|
|
@@ -1171,7 +1206,7 @@ var semitones = (a, b) => 12 * Math.log2(a / b);
|
|
|
1171
1206
|
var PITCH_NOTE_SEMITONES = 3;
|
|
1172
1207
|
var KIND_WIDTH = 8;
|
|
1173
1208
|
var QUIET_DB = -45;
|
|
1174
|
-
var
|
|
1209
|
+
var SILENT_DB = -55;
|
|
1175
1210
|
var LEVEL_DB = 0.5;
|
|
1176
1211
|
var s2 = (t) => t.toFixed(1);
|
|
1177
1212
|
var signed = (db) => `${db >= 0 ? "+" : ""}${db} dB`;
|
|
@@ -1254,7 +1289,7 @@ function pauseLine(pause, analysis) {
|
|
|
1254
1289
|
...analysis.music?.segments.filter((m) => inside(m.start, m.end)).map((m) => `music ${clip(m.start, m.end)}`) ?? [],
|
|
1255
1290
|
...analysis.ambience?.filter((a) => inside(a.start, a.end)).map((a) => `ambience ${clip(a.start, a.end)}`) ?? []
|
|
1256
1291
|
];
|
|
1257
|
-
if (!beds.length && pause.recordingDb >=
|
|
1292
|
+
if (!beds.length && pause.recordingDb >= SILENT_DB)
|
|
1258
1293
|
beds.push(`sound continues at ${dbfs(pause.recordingDb)}`);
|
|
1259
1294
|
const effects = effectsIn(
|
|
1260
1295
|
analysis.effects?.events.filter((e) => e.t >= pause.start && e.t < pause.end) ?? []
|
|
@@ -1327,19 +1362,85 @@ function formatRead(analysis, range) {
|
|
|
1327
1362
|
}
|
|
1328
1363
|
|
|
1329
1364
|
// src/audio/read/read.ts
|
|
1330
|
-
import { createHash as
|
|
1365
|
+
import { createHash as createHash3 } from "crypto";
|
|
1331
1366
|
import {
|
|
1332
1367
|
createReadStream,
|
|
1333
1368
|
existsSync as existsSync5,
|
|
1334
|
-
mkdirSync as
|
|
1335
|
-
readFileSync as
|
|
1336
|
-
renameSync,
|
|
1337
|
-
writeFileSync as
|
|
1369
|
+
mkdirSync as mkdirSync3,
|
|
1370
|
+
readFileSync as readFileSync3,
|
|
1371
|
+
renameSync as renameSync2,
|
|
1372
|
+
writeFileSync as writeFileSync3
|
|
1338
1373
|
} from "fs";
|
|
1339
|
-
import { basename, extname, join as
|
|
1374
|
+
import { basename, extname, join as join7 } from "path";
|
|
1375
|
+
|
|
1376
|
+
// src/audio/read/signal.ts
|
|
1377
|
+
var READ_RATE = 22050;
|
|
1378
|
+
var SILENT_DB2 = -120;
|
|
1379
|
+
var ABSENT_DB = -55;
|
|
1380
|
+
async function decodeMono(path, sampleRate = READ_RATE) {
|
|
1381
|
+
const decoded = await decodeAudio(path, {}, void 0, { sampleRate, mono: true });
|
|
1382
|
+
if (!decoded) throw new Error(`${path} has no audio stream`);
|
|
1383
|
+
const samples = decoded.signal.channels[0];
|
|
1384
|
+
if (samples.some((sample) => !Number.isFinite(sample)))
|
|
1385
|
+
throw new Error(`${path} contains non-finite audio samples`);
|
|
1386
|
+
return samples;
|
|
1387
|
+
}
|
|
1388
|
+
var asSignal = (samples, sampleRate = READ_RATE) => ({
|
|
1389
|
+
sampleRate,
|
|
1390
|
+
channels: [samples]
|
|
1391
|
+
});
|
|
1392
|
+
function mixed(tracks) {
|
|
1393
|
+
const length = Math.max(0, ...tracks.map((t) => t.length));
|
|
1394
|
+
const sum = new Float32Array(length);
|
|
1395
|
+
for (const track2 of tracks) for (let i = 0; i < track2.length; i++) sum[i] += track2[i];
|
|
1396
|
+
return sum;
|
|
1397
|
+
}
|
|
1398
|
+
function levels(samples, sampleRate, hop, window = hop * 2) {
|
|
1399
|
+
const hopSamples = Math.max(1, hop * sampleRate);
|
|
1400
|
+
const half = Math.max(1, Math.round(window * sampleRate / 2));
|
|
1401
|
+
const squares = new Float64Array(samples.length + 1);
|
|
1402
|
+
for (let i = 0; i < samples.length; i++) squares[i + 1] = squares[i] + samples[i] ** 2;
|
|
1403
|
+
const frames = Math.ceil(samples.length / hopSamples);
|
|
1404
|
+
const out = new Float32Array(frames);
|
|
1405
|
+
for (let f = 0; f < frames; f++) {
|
|
1406
|
+
const center = Math.round(f * hopSamples);
|
|
1407
|
+
const a = Math.max(0, center - half);
|
|
1408
|
+
const b = Math.min(samples.length, center + half);
|
|
1409
|
+
const power = b > a ? (squares[b] - squares[a]) / (b - a) : 0;
|
|
1410
|
+
out[f] = power > 0 ? Math.max(SILENT_DB2, 10 * Math.log10(power)) : SILENT_DB2;
|
|
1411
|
+
}
|
|
1412
|
+
return out;
|
|
1413
|
+
}
|
|
1414
|
+
function levelWhileHeardDb(samples, sampleRate) {
|
|
1415
|
+
let sum = 0;
|
|
1416
|
+
let heard = 0;
|
|
1417
|
+
for (const db of levels(samples, sampleRate, 0.1, 0.4))
|
|
1418
|
+
if (db >= ABSENT_DB) {
|
|
1419
|
+
sum += 10 ** (db / 10);
|
|
1420
|
+
heard++;
|
|
1421
|
+
}
|
|
1422
|
+
return heard ? Math.round(10 * Math.log10(sum / heard)) : null;
|
|
1423
|
+
}
|
|
1424
|
+
function quantile(values, q) {
|
|
1425
|
+
if (!values.length) return NaN;
|
|
1426
|
+
const sorted = Float64Array.from(values).sort();
|
|
1427
|
+
return sorted[Math.min(sorted.length - 1, Math.max(0, Math.floor(q * (sorted.length - 1))))];
|
|
1428
|
+
}
|
|
1429
|
+
var median = (values) => quantile(values, 0.5);
|
|
1430
|
+
var round6 = (n, places = 2) => {
|
|
1431
|
+
const k = 10 ** places;
|
|
1432
|
+
return Math.round(n * k) / k;
|
|
1433
|
+
};
|
|
1434
|
+
function spanDb(samples, sampleRate, start, end) {
|
|
1435
|
+
const a = Math.max(0, Math.round(start * sampleRate));
|
|
1436
|
+
const b = Math.min(samples.length, Math.round(end * sampleRate));
|
|
1437
|
+
let sum = 0;
|
|
1438
|
+
for (let i = a; i < b; i++) sum += samples[i] ** 2;
|
|
1439
|
+
return b > a && sum > 0 ? Math.max(SILENT_DB2, 10 * Math.log10(sum / (b - a))) : SILENT_DB2;
|
|
1440
|
+
}
|
|
1340
1441
|
|
|
1341
1442
|
// src/audio/read/effects.ts
|
|
1342
|
-
var
|
|
1443
|
+
var HOP = 0.01;
|
|
1343
1444
|
var FLOOR_FRAMES = 150;
|
|
1344
1445
|
var FLOOR_EVERY = 10;
|
|
1345
1446
|
var RISE_DB = 20;
|
|
@@ -1353,7 +1454,7 @@ var TRAIN_GAP = 0.2;
|
|
|
1353
1454
|
var BEAT_SLACK = 0.05;
|
|
1354
1455
|
var ON_BEAT_SHARE = 0.7;
|
|
1355
1456
|
var DRUM_GROUP_MIN = 8;
|
|
1356
|
-
var
|
|
1457
|
+
var LOW_HZ = 150;
|
|
1357
1458
|
var BAND_FPS = 100;
|
|
1358
1459
|
var SETTLE_FRAMES = 5;
|
|
1359
1460
|
var PEAK_SLACK = 0.05;
|
|
@@ -1376,14 +1477,14 @@ function floors(db) {
|
|
|
1376
1477
|
var BLOCK = 1e-3;
|
|
1377
1478
|
function refined(samples, sampleRate, frame2, floorDb) {
|
|
1378
1479
|
const block = Math.max(1, Math.round(BLOCK * sampleRate));
|
|
1379
|
-
const from = Math.max(0, Math.round((frame2 - 2) *
|
|
1380
|
-
const to = Math.min(samples.length, Math.round((frame2 + 2) *
|
|
1480
|
+
const from = Math.max(0, Math.round((frame2 - 2) * HOP * sampleRate));
|
|
1481
|
+
const to = Math.min(samples.length, Math.round((frame2 + 2) * HOP * sampleRate));
|
|
1381
1482
|
for (let a = from; a + block <= to; a += block) {
|
|
1382
1483
|
let power = 0;
|
|
1383
1484
|
for (let i = a; i < a + block; i++) power += samples[i] ** 2;
|
|
1384
1485
|
if (10 * Math.log10(power / block + 1e-12) >= floorDb + RISE_DB / 2) return a / sampleRate;
|
|
1385
1486
|
}
|
|
1386
|
-
return frame2 *
|
|
1487
|
+
return frame2 * HOP;
|
|
1387
1488
|
}
|
|
1388
1489
|
function onsetOf(db, f, base2, from) {
|
|
1389
1490
|
let onset = f;
|
|
@@ -1396,7 +1497,7 @@ function extent(db, f, floor, from) {
|
|
|
1396
1497
|
const onset = onsetOf(db, f, base2, from);
|
|
1397
1498
|
let peak = f;
|
|
1398
1499
|
let end = f;
|
|
1399
|
-
const last = Math.min(db.length - 1, f + LONGEST /
|
|
1500
|
+
const last = Math.min(db.length - 1, f + LONGEST / HOP);
|
|
1400
1501
|
for (let g = f; g <= last; g++) {
|
|
1401
1502
|
if (g >= f + SETTLE_FRAMES && startsAgain(db, g, f + 1, floor[g])) break;
|
|
1402
1503
|
if (db[g] > db[peak]) peak = g;
|
|
@@ -1423,7 +1524,7 @@ function detect(db, samples, sampleRate, skip) {
|
|
|
1423
1524
|
if (!startsHere(db, f, floor[f])) continue;
|
|
1424
1525
|
const { onset, peak, end } = extent(db, f, floor, from);
|
|
1425
1526
|
const t = refined(samples, sampleRate, onset, Math.max(floor[f], db[onset - 1] ?? -120));
|
|
1426
|
-
if (!skip(t)) found.push({ t, peak: peak *
|
|
1527
|
+
if (!skip(t)) found.push({ t, peak: peak * HOP, end: end * HOP, peakDb: db[peak] });
|
|
1427
1528
|
from = end + 1;
|
|
1428
1529
|
f = Math.max(end, onset + 8);
|
|
1429
1530
|
}
|
|
@@ -1450,7 +1551,7 @@ function shape(bands, from, to) {
|
|
|
1450
1551
|
function lowShare(power) {
|
|
1451
1552
|
const e = energies(power);
|
|
1452
1553
|
const total = e.reduce((a, b) => a + b, 0);
|
|
1453
|
-
const low = e.reduce((sum, p, k) => sum + (bandHz(k) <
|
|
1554
|
+
const low = e.reduce((sum, p, k) => sum + (bandHz(k) < LOW_HZ ? p : 0), 0);
|
|
1454
1555
|
return total > 0 ? low / total : 0;
|
|
1455
1556
|
}
|
|
1456
1557
|
function centroidHz(power) {
|
|
@@ -1553,9 +1654,9 @@ function majority(kinds) {
|
|
|
1553
1654
|
return [...counts].sort((a, b) => b[1] - a[1])[0][0];
|
|
1554
1655
|
}
|
|
1555
1656
|
function foundIn({ samples: source, heldBy = [] }, input, mixDb) {
|
|
1556
|
-
const db = source === input.mix ? mixDb : levels(source, input.sampleRate,
|
|
1657
|
+
const db = source === input.mix ? mixDb : levels(source, input.sampleRate, HOP);
|
|
1557
1658
|
const inSpeech = (t) => input.speech.some((s3) => t >= s3.start - SPEECH_SLACK && t < s3.end);
|
|
1558
|
-
const masked = (f) => f.peakDb < (mixDb[Math.round(f.peak /
|
|
1659
|
+
const masked = (f) => f.peakDb < (mixDb[Math.round(f.peak / HOP)] ?? -120) - MASKED_DB;
|
|
1559
1660
|
const held = (f) => heldBy.some((span) => f.t < span.end && f.peak >= span.start);
|
|
1560
1661
|
const found = detect(db, source, input.sampleRate, inSpeech).filter(
|
|
1561
1662
|
(f) => !masked(f) && !held(f)
|
|
@@ -1579,8 +1680,8 @@ function measured2(input, mixDb) {
|
|
|
1579
1680
|
return out;
|
|
1580
1681
|
}
|
|
1581
1682
|
function peakInMix(mixDb, m) {
|
|
1582
|
-
const a = Math.max(0, Math.round((m.peak - PEAK_SLACK) /
|
|
1583
|
-
const b = Math.min(mixDb.length - 1, Math.round((m.peak + PEAK_SLACK) /
|
|
1683
|
+
const a = Math.max(0, Math.round((m.peak - PEAK_SLACK) / HOP));
|
|
1684
|
+
const b = Math.min(mixDb.length - 1, Math.round((m.peak + PEAK_SLACK) / HOP));
|
|
1584
1685
|
let peak = -120;
|
|
1585
1686
|
for (let f = a; f <= b; f++) peak = Math.max(peak, mixDb[f]);
|
|
1586
1687
|
return peak;
|
|
@@ -1594,8 +1695,8 @@ function musicNear(input, m, segment) {
|
|
|
1594
1695
|
}
|
|
1595
1696
|
function levelsOf(input, mixDb, m) {
|
|
1596
1697
|
const peakDb = peakInMix(mixDb, m);
|
|
1597
|
-
const a = Math.max(0, Math.round((m.t - BEFORE) /
|
|
1598
|
-
const b = Math.max(a, Math.round((m.t - GAP) /
|
|
1698
|
+
const a = Math.max(0, Math.round((m.t - BEFORE) / HOP));
|
|
1699
|
+
const b = Math.max(a, Math.round((m.t - GAP) / HOP));
|
|
1599
1700
|
const beforeDb = b > a ? quantile(mixDb.subarray(a, b), 0.5) : -120;
|
|
1600
1701
|
const segment = input.music ? input.musicSegments?.find((span) => m.t >= span.start && m.t < span.end) : void 0;
|
|
1601
1702
|
const musicDb = segment ? musicNear(input, m, segment) : null;
|
|
@@ -1628,7 +1729,7 @@ function effectOf(m, group, kind, levels2) {
|
|
|
1628
1729
|
};
|
|
1629
1730
|
}
|
|
1630
1731
|
function findEffects(input) {
|
|
1631
|
-
const mixDb = levels(input.mix, input.sampleRate,
|
|
1732
|
+
const mixDb = levels(input.mix, input.sampleRate, HOP);
|
|
1632
1733
|
const sounds = measured2(input, mixDb);
|
|
1633
1734
|
const members = /* @__PURE__ */ new Map();
|
|
1634
1735
|
for (const m of sounds) members.set(m.group, [...members.get(m.group) ?? [], m]);
|
|
@@ -1657,7 +1758,7 @@ function findEffects(input) {
|
|
|
1657
1758
|
}
|
|
1658
1759
|
|
|
1659
1760
|
// src/audio/read/music.ts
|
|
1660
|
-
var
|
|
1761
|
+
var HOP2 = 0.1;
|
|
1661
1762
|
var CUT_DB = 25;
|
|
1662
1763
|
var RUNNING_FRAMES = 200;
|
|
1663
1764
|
var LEVEL_WINDOW = 0.4;
|
|
@@ -1689,8 +1790,8 @@ function joined(spans, tooShort2) {
|
|
|
1689
1790
|
return out;
|
|
1690
1791
|
}
|
|
1691
1792
|
function powerDb(db, start, end) {
|
|
1692
|
-
const a = Math.max(0, Math.round(start /
|
|
1693
|
-
const b = Math.min(db.length, Math.round(end /
|
|
1793
|
+
const a = Math.max(0, Math.round(start / HOP2));
|
|
1794
|
+
const b = Math.min(db.length, Math.round(end / HOP2));
|
|
1694
1795
|
let sum = 0;
|
|
1695
1796
|
for (let f = a; f < b; f++) sum += 10 ** (db[f] / 10);
|
|
1696
1797
|
return b > a ? 10 * Math.log10(sum / (b - a) || 1e-12) : Number.NEGATIVE_INFINITY;
|
|
@@ -1709,14 +1810,14 @@ function candidates(quiet, from, to, absorbed = tooShort) {
|
|
|
1709
1810
|
for (let f = from; f < to; f++) {
|
|
1710
1811
|
const isQuiet = quiet[f] === 1;
|
|
1711
1812
|
const last = spans[spans.length - 1];
|
|
1712
|
-
if (last && last.quiet === isQuiet) last.end = (f + 1) *
|
|
1713
|
-
else spans.push({ quiet: isQuiet, start: f *
|
|
1813
|
+
if (last && last.quiet === isQuiet) last.end = (f + 1) * HOP2;
|
|
1814
|
+
else spans.push({ quiet: isQuiet, start: f * HOP2, end: (f + 1) * HOP2 });
|
|
1714
1815
|
}
|
|
1715
1816
|
return joined(spans, absorbed);
|
|
1716
1817
|
}
|
|
1717
1818
|
function silencesIn(db, span) {
|
|
1718
|
-
const from = Math.round(span.start /
|
|
1719
|
-
const to = Math.min(db.length, Math.round(span.end /
|
|
1819
|
+
const from = Math.round(span.start / HOP2);
|
|
1820
|
+
const to = Math.min(db.length, Math.round(span.end / HOP2));
|
|
1720
1821
|
const absent = new Uint8Array(db.length);
|
|
1721
1822
|
for (let f = from; f < to; f++) absent[f] = db[f] < ABSENT_DB ? 1 : 0;
|
|
1722
1823
|
const shortSilence = (s3) => s3.quiet && s3.end - s3.start < LONGEST_REST;
|
|
@@ -1739,15 +1840,15 @@ function runs(db) {
|
|
|
1739
1840
|
const settled = joined(merged, (s3) => !s3.quiet && s3.end - s3.start < SHORTEST_SEGMENT);
|
|
1740
1841
|
return {
|
|
1741
1842
|
segments: settled.filter((s3) => !s3.quiet),
|
|
1742
|
-
breaks: settled.filter((s3) => s3.quiet && s3.start > 0 && s3.end < db.length *
|
|
1843
|
+
breaks: settled.filter((s3) => s3.quiet && s3.start > 0 && s3.end < db.length * HOP2)
|
|
1743
1844
|
};
|
|
1744
1845
|
}
|
|
1745
1846
|
function soundShare(fine, run) {
|
|
1746
|
-
const a = Math.round(run.start /
|
|
1747
|
-
const b = Math.min(fine.length, Math.round(run.end /
|
|
1847
|
+
const a = Math.round(run.start / HOP2);
|
|
1848
|
+
const b = Math.min(fine.length, Math.round(run.end / HOP2));
|
|
1748
1849
|
const heard = new Float64Array(b - a + 1);
|
|
1749
1850
|
for (let f = a; f < b; f++) heard[f - a + 1] = heard[f - a] + (fine[f] >= ABSENT_DB ? 1 : 0);
|
|
1750
|
-
const half = Math.round(DENSE_WINDOW / 2 /
|
|
1851
|
+
const half = Math.round(DENSE_WINDOW / 2 / HOP2);
|
|
1751
1852
|
const out = new Float32Array(b - a);
|
|
1752
1853
|
for (let f = a; f < b; f++) {
|
|
1753
1854
|
const lo = Math.max(a, f - half);
|
|
@@ -1757,9 +1858,9 @@ function soundShare(fine, run) {
|
|
|
1757
1858
|
return out;
|
|
1758
1859
|
}
|
|
1759
1860
|
function steadyEdges(fine, part) {
|
|
1760
|
-
const steady = Math.round(STEADY /
|
|
1761
|
-
const a = Math.round(part.start /
|
|
1762
|
-
const b = Math.min(fine.length, Math.round(part.end /
|
|
1861
|
+
const steady = Math.round(STEADY / HOP2);
|
|
1862
|
+
const a = Math.round(part.start / HOP2);
|
|
1863
|
+
const b = Math.min(fine.length, Math.round(part.end / HOP2));
|
|
1763
1864
|
const holds = (f) => {
|
|
1764
1865
|
for (let k = f; k < f + steady; k++) if (k >= b || fine[k] < ABSENT_DB) return false;
|
|
1765
1866
|
return true;
|
|
@@ -1768,18 +1869,18 @@ function steadyEdges(fine, part) {
|
|
|
1768
1869
|
while (start < b && !holds(start)) start++;
|
|
1769
1870
|
let end = b;
|
|
1770
1871
|
while (end > start && !holds(end - steady)) end--;
|
|
1771
|
-
return start < end ? { ...part, start: start *
|
|
1872
|
+
return start < end ? { ...part, start: start * HOP2, end: end * HOP2 } : part;
|
|
1772
1873
|
}
|
|
1773
1874
|
function sustainedParts(fine, run) {
|
|
1774
1875
|
if (run.end - run.start <= DENSE_WINDOW) {
|
|
1775
|
-
const a2 = Math.round(run.start /
|
|
1776
|
-
const b = Math.max(a2 + 1, Math.min(fine.length, Math.round(run.end /
|
|
1876
|
+
const a2 = Math.round(run.start / HOP2);
|
|
1877
|
+
const b = Math.max(a2 + 1, Math.min(fine.length, Math.round(run.end / HOP2)));
|
|
1777
1878
|
let heard = 0;
|
|
1778
1879
|
for (let f = a2; f < b; f++) if (fine[f] >= ABSENT_DB) heard++;
|
|
1779
1880
|
return heard / (b - a2) >= DENSE_SHARE ? [run] : [];
|
|
1780
1881
|
}
|
|
1781
1882
|
const dense = soundShare(fine, run);
|
|
1782
|
-
const a = Math.round(run.start /
|
|
1883
|
+
const a = Math.round(run.start / HOP2);
|
|
1783
1884
|
const sparse = new Uint8Array(fine.length);
|
|
1784
1885
|
dense.forEach((share, i) => sparse[a + i] = share < DENSE_SHARE ? 1 : 0);
|
|
1785
1886
|
return candidates(sparse, a, a + dense.length).filter((part) => !part.quiet).map((part) => steadyEdges(fine, part)).map(({ start, end }) => ({ start, end: Math.min(end, run.end) }));
|
|
@@ -1838,13 +1939,13 @@ function beatsInRun(signal, run) {
|
|
|
1838
1939
|
}
|
|
1839
1940
|
var sameTempo = (a, b) => a === null || b === null || Math.abs(a - b) / Math.max(a, b) <= SAME_TEMPO;
|
|
1840
1941
|
function fadeFrom(db, run) {
|
|
1841
|
-
const a = Math.floor(run.start /
|
|
1842
|
-
const b = Math.min(db.length, Math.floor(run.end /
|
|
1942
|
+
const a = Math.floor(run.start / HOP2);
|
|
1943
|
+
const b = Math.min(db.length, Math.floor(run.end / HOP2));
|
|
1843
1944
|
const body = median(db.subarray(a, b));
|
|
1844
1945
|
const last = db[b - 1] ?? body;
|
|
1845
1946
|
if (body - last < FADE_DB) return null;
|
|
1846
|
-
for (let f = Math.max(a, b - FADE_WINDOW /
|
|
1847
|
-
if (db[f] < body - 3) return round6(f *
|
|
1947
|
+
for (let f = Math.max(a, b - FADE_WINDOW / HOP2); f < b; f++)
|
|
1948
|
+
if (db[f] < body - 3) return round6(f * HOP2, 1);
|
|
1848
1949
|
return null;
|
|
1849
1950
|
}
|
|
1850
1951
|
var leading = (mix) => Object.entries(mix).filter(([, share]) => share >= LEADING_SHARE).sort((a, b) => b[1] - a[1]).map(([name]) => name);
|
|
@@ -1890,9 +1991,9 @@ function energyCurve(melodic, sampleRate, duration, musical) {
|
|
|
1890
1991
|
}
|
|
1891
1992
|
function readMusic(input) {
|
|
1892
1993
|
const melodic = mixed(Object.values(input.stems));
|
|
1893
|
-
const db = levels(melodic, input.sampleRate,
|
|
1994
|
+
const db = levels(melodic, input.sampleRate, HOP2, LEVEL_WINDOW);
|
|
1894
1995
|
const duration = melodic.length / input.sampleRate;
|
|
1895
|
-
const fine = levels(melodic, input.sampleRate,
|
|
1996
|
+
const fine = levels(melodic, input.sampleRate, HOP2, HOP2);
|
|
1896
1997
|
const { segments: whole, breaks } = runs(db);
|
|
1897
1998
|
for (const run of whole) run.end = Math.min(run.end, duration);
|
|
1898
1999
|
const found = whole.flatMap((run) => sustainedParts(fine, run));
|
|
@@ -1954,11 +2055,11 @@ function readMusic(input) {
|
|
|
1954
2055
|
}
|
|
1955
2056
|
|
|
1956
2057
|
// src/audio/read/stems.ts
|
|
1957
|
-
import { randomUUID as
|
|
1958
|
-
import { existsSync as existsSync4, mkdirSync, readFileSync, statSync, writeFileSync } from "fs";
|
|
2058
|
+
import { randomUUID as randomUUID3 } from "crypto";
|
|
2059
|
+
import { existsSync as existsSync4, mkdirSync as mkdirSync2, readFileSync as readFileSync2, statSync as statSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
1959
2060
|
import { mkdtemp as mkdtemp2, rm as rm2 } from "fs/promises";
|
|
1960
2061
|
import { tmpdir as tmpdir2 } from "os";
|
|
1961
|
-
import { join as
|
|
2062
|
+
import { join as join6 } from "path";
|
|
1962
2063
|
import { setTimeout as sleep } from "timers/promises";
|
|
1963
2064
|
var URL_ENV2 = "HYPERFRAMES_AUDIO_STEMS_URL";
|
|
1964
2065
|
var KEY_ENV2 = "HYPERFRAMES_AUDIO_API_KEY";
|
|
@@ -1975,11 +2076,11 @@ var stemsAccess = () => serviceAccess(
|
|
|
1975
2076
|
DEFAULT_TIMEOUT_MS2
|
|
1976
2077
|
);
|
|
1977
2078
|
function cachedStems(dir) {
|
|
1978
|
-
const done =
|
|
2079
|
+
const done = join6(dir, DONE);
|
|
1979
2080
|
if (!existsSync4(done)) return null;
|
|
1980
|
-
const names = JSON.parse(
|
|
2081
|
+
const names = JSON.parse(readFileSync2(done, "utf8"));
|
|
1981
2082
|
if (!STEM_NAMES.every((name) => typeof names[name] === "string")) return null;
|
|
1982
|
-
const paths = Object.fromEntries(STEM_NAMES.map((name) => [name,
|
|
2083
|
+
const paths = Object.fromEntries(STEM_NAMES.map((name) => [name, join6(dir, names[name])]));
|
|
1983
2084
|
return Object.values(paths).every((p) => existsSync4(p)) ? paths : null;
|
|
1984
2085
|
}
|
|
1985
2086
|
var StillRunning = class extends Error {
|
|
@@ -2004,7 +2105,7 @@ async function encoded(path, dir, signal) {
|
|
|
2004
2105
|
if (!ffmpeg) throw new Error("ffmpeg is required to separate stems; run: npx hyperframes doctor");
|
|
2005
2106
|
const audio = await probeAudio(path);
|
|
2006
2107
|
if (!audio) throw new Error("the recording has no audio track ffmpeg can decode");
|
|
2007
|
-
const out =
|
|
2108
|
+
const out = join6(dir, "upload.mp3");
|
|
2008
2109
|
await runFile(
|
|
2009
2110
|
ffmpeg,
|
|
2010
2111
|
[
|
|
@@ -2027,7 +2128,7 @@ async function separated(url, request, signal) {
|
|
|
2027
2128
|
}
|
|
2028
2129
|
async function fetchStems(path, dir, { url, headers, timeoutMs }) {
|
|
2029
2130
|
const signal = AbortSignal.timeout(timeoutMs);
|
|
2030
|
-
const scratch = await mkdtemp2(
|
|
2131
|
+
const scratch = await mkdtemp2(join6(tmpdir2(), "hf-stems-"));
|
|
2031
2132
|
try {
|
|
2032
2133
|
const mp3 = await encoded(path, scratch, signal);
|
|
2033
2134
|
const client = new HyperframesCloudClient({
|
|
@@ -2038,10 +2139,10 @@ async function fetchStems(path, dir, { url, headers, timeoutMs }) {
|
|
|
2038
2139
|
const asset = await uploadAssetViaDirectUpload({
|
|
2039
2140
|
client,
|
|
2040
2141
|
path: mp3,
|
|
2041
|
-
size:
|
|
2142
|
+
size: statSync2(mp3).size,
|
|
2042
2143
|
filename: "audio.mp3",
|
|
2043
2144
|
contentType: "audio/mpeg",
|
|
2044
|
-
idempotencyKey:
|
|
2145
|
+
idempotencyKey: randomUUID3(),
|
|
2045
2146
|
signal
|
|
2046
2147
|
});
|
|
2047
2148
|
const current = await separated(
|
|
@@ -2051,7 +2152,7 @@ async function fetchStems(path, dir, { url, headers, timeoutMs }) {
|
|
|
2051
2152
|
redirect: "error",
|
|
2052
2153
|
headers: {
|
|
2053
2154
|
...headers,
|
|
2054
|
-
"idempotency-key":
|
|
2155
|
+
"idempotency-key": randomUUID3(),
|
|
2055
2156
|
"content-type": "application/json"
|
|
2056
2157
|
},
|
|
2057
2158
|
body: JSON.stringify({ version: 1, audio: { type: "asset_id", asset_id: asset.asset_id } })
|
|
@@ -2068,16 +2169,16 @@ async function fetchStems(path, dir, { url, headers, timeoutMs }) {
|
|
|
2068
2169
|
throw new Error(
|
|
2069
2170
|
`the stems service returned an incomplete separation: missing ${missing.join(", ")}`
|
|
2070
2171
|
);
|
|
2071
|
-
|
|
2172
|
+
mkdirSync2(dir, { recursive: true });
|
|
2072
2173
|
const names = {};
|
|
2073
2174
|
for (const name of STEM_NAMES) {
|
|
2074
2175
|
const stem = stems.find((candidate) => candidate.name === name);
|
|
2075
2176
|
if (!stem) continue;
|
|
2076
2177
|
const file = `${name}.audio`;
|
|
2077
|
-
await downloadToFile(stem.url,
|
|
2178
|
+
await downloadToFile(stem.url, join6(dir, file), { signal });
|
|
2078
2179
|
names[name] = file;
|
|
2079
2180
|
}
|
|
2080
|
-
|
|
2181
|
+
writeFileSync2(join6(dir, DONE), JSON.stringify(names));
|
|
2081
2182
|
return cachedStems(dir);
|
|
2082
2183
|
} finally {
|
|
2083
2184
|
await rm2(scratch, { recursive: true, force: true });
|
|
@@ -2220,7 +2321,7 @@ function voiceFromActivity(vocals, sampleRate, track2, levelOf) {
|
|
|
2220
2321
|
|
|
2221
2322
|
// src/audio/read/read.ts
|
|
2222
2323
|
async function sha256(path) {
|
|
2223
|
-
const hash =
|
|
2324
|
+
const hash = createHash3("sha256");
|
|
2224
2325
|
for await (const chunk of createReadStream(path)) hash.update(chunk);
|
|
2225
2326
|
return hash.digest("hex");
|
|
2226
2327
|
}
|
|
@@ -2232,11 +2333,11 @@ function transcriptFor(path, given) {
|
|
|
2232
2333
|
function wordsOf(transcript) {
|
|
2233
2334
|
return loadTranscript(transcript).words.map(({ text, start, end }) => ({ text, start, end }));
|
|
2234
2335
|
}
|
|
2235
|
-
var fingerprint = (path) => path ?
|
|
2336
|
+
var fingerprint = (path) => path ? createHash3("sha256").update(readFileSync3(path)).digest("hex").slice(0, 16) : "none";
|
|
2236
2337
|
function writeAtomic(path, content) {
|
|
2237
2338
|
const temporary = `${path}.${process.pid}.tmp`;
|
|
2238
|
-
|
|
2239
|
-
|
|
2339
|
+
writeFileSync3(temporary, content);
|
|
2340
|
+
renameSync2(temporary, path);
|
|
2240
2341
|
}
|
|
2241
2342
|
async function stemsFor(path, dir, quality, warnings) {
|
|
2242
2343
|
const cached = cachedStems(dir);
|
|
@@ -2378,12 +2479,12 @@ async function readAudio(path, file, options) {
|
|
|
2378
2479
|
const transcript = transcriptFor(path, options.transcript);
|
|
2379
2480
|
const transcriptKey = fingerprint(transcript);
|
|
2380
2481
|
const stem = `${basename(file, extname(file)).replace(/[^\w.-]/g, "_")}-${sha.slice(0, 12)}`;
|
|
2381
|
-
|
|
2382
|
-
const jsonPath =
|
|
2383
|
-
const textPath =
|
|
2384
|
-
const stemDir =
|
|
2482
|
+
mkdirSync3(options.cacheDir, { recursive: true });
|
|
2483
|
+
const jsonPath = join7(options.cacheDir, `${stem}.json`);
|
|
2484
|
+
const textPath = join7(options.cacheDir, `${stem}.txt`);
|
|
2485
|
+
const stemDir = join7(options.cacheDir, "stems", sha.slice(0, 12));
|
|
2385
2486
|
if (existsSync5(jsonPath) && existsSync5(textPath)) {
|
|
2386
|
-
const entry = JSON.parse(
|
|
2487
|
+
const entry = JSON.parse(readFileSync3(jsonPath, "utf8"));
|
|
2387
2488
|
const stemsNowPossible = entry.analysis.separation === "mix" && quality === "best" && (cachedStems(stemDir) !== null || typeof await stemsAccess() !== "string");
|
|
2388
2489
|
if ((entry.analysis.separation !== "stems" || cachedStems(stemDir) !== null) && entry.analysis.version === READ_VERSION && entry.transcriptKey === transcriptKey && !stemsNowPossible)
|
|
2389
2490
|
return { analysis: entry.analysis, textPath, jsonPath, cached: true };
|
|
@@ -2524,7 +2625,7 @@ async function read(files, flags) {
|
|
|
2524
2625
|
const quality = readQuality(files, flags);
|
|
2525
2626
|
const range = pair("range", flags.range);
|
|
2526
2627
|
const result = await readAudio(resolve2(process.cwd(), files[0]), files[0], {
|
|
2527
|
-
cacheDir:
|
|
2628
|
+
cacheDir: join8(resolve2(flags.dir ?? process.cwd()), ".hyperframes", "read-audio"),
|
|
2528
2629
|
transcript: flags.transcript ? resolve2(process.cwd(), flags.transcript) : void 0,
|
|
2529
2630
|
quality
|
|
2530
2631
|
});
|
|
@@ -2610,7 +2711,12 @@ var audio_default = defineCommand({
|
|
|
2610
2711
|
const query = filmQuery(flags);
|
|
2611
2712
|
if (files.length && query) throw new CliUsageError("give files or a film query, not both");
|
|
2612
2713
|
const targets = files.length ? await fileTargets(files, flags) : await clipTargets(flags, query);
|
|
2613
|
-
const report = await analyzeTargets(
|
|
2714
|
+
const report = await analyzeTargets(
|
|
2715
|
+
targets,
|
|
2716
|
+
analyzeRequest(flags),
|
|
2717
|
+
Boolean(args.full),
|
|
2718
|
+
join8(resolve2(flags.dir ?? process.cwd()), ".hyperframes", "audio-kind")
|
|
2719
|
+
);
|
|
2614
2720
|
console.log(args.json ? JSON.stringify(withMeta(report)) : formatReport(report));
|
|
2615
2721
|
}
|
|
2616
2722
|
});
|