hyperframes 0.8.207 → 0.8.209

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (225) hide show
  1. package/dist/{add-LXFWHBE3.js → add-VZKUIZEH.js} +17 -15
  2. package/dist/{agentPromptGenerator-D2E62ZP5.js → agentPromptGenerator-4NJ252MR.js} +6 -2
  3. package/dist/{animatedGifPrep-VBPJZKFT.js → animatedGifPrep-PN4G4YPJ.js} +10 -7
  4. package/dist/api.js +24 -20
  5. package/dist/{appHistory-HIBH6XZW.js → appHistory-OHYU5ZBQ.js} +3 -2
  6. package/dist/{asset-JX4RW3GO.js → asset-I4PHGE57.js} +2 -2
  7. package/dist/{assetCataloger-JKKOPBCF.js → assetCataloger-LRAUXQ46.js} +12 -8
  8. package/dist/{audio-OXQ3L6DW.js → audio-T7SAVYED.js} +424 -133
  9. package/dist/{auth-JAL7P7ZA.js → auth-GP6HTQT3.js} +4 -4
  10. package/dist/{autoUpdate-MRI2AICE.js → autoUpdate-Z6GFPZAG.js} +4 -4
  11. package/dist/{backgroundChecks-ORR46PBY.js → backgroundChecks-ZJ7JV52S.js} +5 -5
  12. package/dist/backgroundChecksWorker.js +5 -5
  13. package/dist/{batchRender-IFZYPGIW.js → batchRender-J3ETE23Y.js} +5 -4
  14. package/dist/{beats-UDLOEW6U.js → beats-WF4FJCM5.js} +25 -15
  15. package/dist/{benchmark-VTVDNKSO.js → benchmark-B7UPP4PQ.js} +10 -10
  16. package/dist/{browser-QJC4BL2Y.js → browser-SIUYD43U.js} +8 -8
  17. package/dist/{bundleWithLocalizedFonts-Z2JTBNDS.js → bundleWithLocalizedFonts-RRGFY3XV.js} +3 -3
  18. package/dist/{capture-2P4JERSX.js → capture-J3GLHUKI.js} +52 -17
  19. package/dist/{capture-GLM2ACPM.js → capture-VYS4PCCJ.js} +66 -39
  20. package/dist/{captureCompositionFrame-A2A5MGQB.js → captureCompositionFrame-SVLMPQYC.js} +16 -14
  21. package/dist/{captureFile-RPUEOZO6.js → captureFile-VIVGKFY4.js} +2 -1
  22. package/dist/{catalog-5ZLVUQVJ.js → catalog-DVBNR422.js} +17 -15
  23. package/dist/{catch-up-FRMVYJHZ.js → catch-up-OBPMV7KG.js} +9 -8
  24. package/dist/{check-WVY7SM7C.js → check-MEALXNZK.js} +47 -44
  25. package/dist/{checkAudio-PLEQY3SZ.js → checkAudio-RZ7WQYVN.js} +23 -13
  26. package/dist/{checkBrowser-XSZUA2DQ.js → checkBrowser-2LEQ2LSX.js} +39 -36
  27. package/dist/{chunk-526VSRZ4.js → chunk-3A4SB326.js} +6 -6
  28. package/dist/{chunk-GXUONASF.js → chunk-3PTZ2TD4.js} +25 -2
  29. package/dist/{chunk-JQ32262N.js → chunk-3PUXUIWB.js} +1 -1
  30. package/dist/chunk-3RATCY3W.js +205 -0
  31. package/dist/{chunk-MAUGXKSI.js → chunk-4BXEPVSA.js} +113 -20
  32. package/dist/{chunk-C6KE4AFW.js → chunk-56ANHX5U.js} +1 -1
  33. package/dist/{chunk-VBPNCOD7.js → chunk-5T4DP25D.js} +5 -3
  34. package/dist/{chunk-IBZHSU2J.js → chunk-66PNSZ7K.js} +1 -1
  35. package/dist/{chunk-WL263XM2.js → chunk-6PWQH77E.js} +1 -1
  36. package/dist/chunk-7VZEOCUY.js +98 -0
  37. package/dist/{chunk-VAVDAOUA.js → chunk-A7GDBL6D.js} +1 -1
  38. package/dist/{chunk-UAT2UMTP.js → chunk-AQTODJWP.js} +1 -1
  39. package/dist/{chunk-5KBMYSF2.js → chunk-BYPDKF36.js} +7 -2
  40. package/dist/{chunk-EG3B2VWK.js → chunk-CA3PXWN4.js} +16 -21
  41. package/dist/{chunk-FEO7YW7V.js → chunk-CBM4ZUVN.js} +6 -6
  42. package/dist/{chunk-6KCFVLO6.js → chunk-CIDCNE2D.js} +21 -5
  43. package/dist/{chunk-C53ZNJDZ.js → chunk-D2CE2J2A.js} +1 -1
  44. package/dist/chunk-D3MUHMFG.js +16 -0
  45. package/dist/{chunk-5PYRU5DT.js → chunk-D6T5BNSK.js} +18 -17
  46. package/dist/{chunk-PUIG6DHT.js → chunk-DR47DSOY.js} +7 -7
  47. package/dist/chunk-DROFHVQD.js +240 -0
  48. package/dist/{chunk-YJK6HOL5.js → chunk-DVIX7UPH.js} +2 -2
  49. package/dist/{chunk-QTWXVOZI.js → chunk-EA5FUMJN.js} +2 -2
  50. package/dist/{chunk-NWGXTUYS.js → chunk-EQBDKYXR.js} +3 -30
  51. package/dist/{chunk-4UMPIPCQ.js → chunk-ERUQ3S6D.js} +2 -2
  52. package/dist/{chunk-T2EUWCJE.js → chunk-EU7MVORF.js} +13 -1
  53. package/dist/{chunk-IW5P4KK7.js → chunk-EVYDKSML.js} +3 -3
  54. package/dist/{chunk-FVAI7AHF.js → chunk-F4O4G4ZW.js} +5 -5
  55. package/dist/{chunk-6KOHY5EP.js → chunk-FB5BXGGF.js} +17 -11
  56. package/dist/{chunk-HTIUNMTP.js → chunk-GDZA4ALG.js} +8 -2
  57. package/dist/{chunk-DJQZ7DEH.js → chunk-GQZHLF5P.js} +15 -15
  58. package/dist/{chunk-ZYGIDXAK.js → chunk-H7B526GH.js} +114 -65
  59. package/dist/{chunk-P2I4RLJE.js → chunk-HTZJNQYI.js} +1 -1
  60. package/dist/{chunk-I2TDHVFV.js → chunk-I3ICHLHV.js} +2 -2
  61. package/dist/{chunk-CVZO6TFE.js → chunk-IJPFVMIE.js} +11 -11
  62. package/dist/{chunk-LK6KPVX2.js → chunk-IQNS7O4W.js} +403 -290
  63. package/dist/{chunk-XDMZY3H7.js → chunk-J7A73K2B.js} +43 -35
  64. package/dist/{chunk-RPZNQV6D.js → chunk-JC6BAQOG.js} +4 -10
  65. package/dist/{chunk-HA3V4XAF.js → chunk-JJRMN2RV.js} +63 -200
  66. package/dist/{chunk-XMRA7CQG.js → chunk-KCLBO65Y.js} +1 -1
  67. package/dist/{chunk-QE4WRS3N.js → chunk-KGBFHYHX.js} +4 -4
  68. package/dist/{chunk-HM7SUIQD.js → chunk-KTWGVEN6.js} +3 -3
  69. package/dist/{chunk-7PJ3AJB2.js → chunk-L5XVBFUM.js} +1 -1
  70. package/dist/{chunk-NSC5A4IR.js → chunk-L7MGVFR4.js} +7 -2
  71. package/dist/{chunk-I3TYUQLB.js → chunk-LJ7H2A2C.js} +1 -1
  72. package/dist/{chunk-VH4PNYOS.js → chunk-LV4NWCJS.js} +2 -2
  73. package/dist/{chunk-ELP5QZWL.js → chunk-M4QZFUMW.js} +1 -1
  74. package/dist/{chunk-7RWUY3BJ.js → chunk-MI4V4HPE.js} +1 -1
  75. package/dist/{chunk-SXOD5J7T.js → chunk-MKALOCDV.js} +1 -1
  76. package/dist/{chunk-UKM3JYNB.js → chunk-MVNTJGDX.js} +3 -3
  77. package/dist/{chunk-PSX5SF2N.js → chunk-NEASABW6.js} +1 -1
  78. package/dist/{chunk-H3LQ5X6Q.js → chunk-NJZRXELC.js} +68 -34
  79. package/dist/{chunk-EOVYQ3IG.js → chunk-NQ2INEHX.js} +17 -17
  80. package/dist/{chunk-LCCYYTEK.js → chunk-NXNDHV26.js} +1 -1
  81. package/dist/{chunk-JKE24AG7.js → chunk-OK3QLJSF.js} +1 -1
  82. package/dist/{chunk-63DP5CB2.js → chunk-OML6HQQN.js} +4 -4
  83. package/dist/{chunk-UUOIH4RW.js → chunk-P2FSCR5B.js} +2 -2
  84. package/dist/{chunk-ZCJ5EGLU.js → chunk-P327BIJR.js} +66 -1
  85. package/dist/{chunk-HVOTYAS4.js → chunk-P3OKYRGA.js} +3 -3
  86. package/dist/{chunk-U32PA6DI.js → chunk-PYVYF64E.js} +1 -1
  87. package/dist/{chunk-EHFZEKQM.js → chunk-Q43YUROE.js} +1 -1
  88. package/dist/{chunk-CZUAX3BV.js → chunk-QIDN4ML5.js} +1 -1
  89. package/dist/{chunk-NHL5CMO2.js → chunk-QIKZ2HZJ.js} +3 -3
  90. package/dist/{chunk-IK4JY2LI.js → chunk-R52YM6ZK.js} +2 -2
  91. package/dist/{chunk-DML6BD4K.js → chunk-RAONLDN5.js} +2 -2
  92. package/dist/{chunk-MSHL6CF2.js → chunk-RJO4X3AA.js} +1 -1
  93. package/dist/{chunk-6IYIS2U7.js → chunk-RVG2JNDU.js} +2 -2
  94. package/dist/{chunk-UYPWH7PH.js → chunk-SE6S4SGZ.js} +13 -15
  95. package/dist/{chunk-NJNC2DQV.js → chunk-SNLXWCET.js} +105 -46
  96. package/dist/{chunk-TSTONNOD.js → chunk-SOXQXX2M.js} +2 -2
  97. package/dist/{chunk-EGRIVMCQ.js → chunk-SPMKVI6H.js} +2 -2
  98. package/dist/{chunk-PL36HK3U.js → chunk-SWHCYFEF.js} +27 -5
  99. package/dist/{chunk-ID766OZB.js → chunk-TF7YE7J5.js} +3 -3
  100. package/dist/{chunk-XAGBSYIQ.js → chunk-TSM67ADU.js} +1 -1
  101. package/dist/{chunk-KDHHPJOG.js → chunk-U5IZUWBW.js} +4 -4
  102. package/dist/{chunk-T4JGFCXU.js → chunk-V4VXWOIF.js} +4 -4
  103. package/dist/{chunk-6N65ZMC5.js → chunk-VYRJAQGC.js} +1 -1
  104. package/dist/{chunk-LXP6XWJL.js → chunk-W32DVMX3.js} +2 -2
  105. package/dist/{chunk-LPI7HX4G.js → chunk-WLVHSGVL.js} +2 -2
  106. package/dist/chunk-XCIHCPJK.js +106 -0
  107. package/dist/chunk-XFMO3BEN.js +71 -0
  108. package/dist/{chunk-XKW4Z7BU.js → chunk-Y2EVJBR6.js} +1 -1
  109. package/dist/{chunk-QZ2JQ6O4.js → chunk-YCGLT5B4.js} +3 -3
  110. package/dist/{chunk-5PCALX6G.js → chunk-YIFEK3UD.js} +1 -1
  111. package/dist/{chunk-ZF3R2IPC.js → chunk-YRO3PXWU.js} +2 -85
  112. package/dist/chunk-Z5J67X44.js +40 -0
  113. package/dist/{chunk-XULJBZ7K.js → chunk-Z67J3TTU.js} +5 -3
  114. package/dist/{chunk-7JAD4MEW.js → chunk-ZA5TNF4R.js} +1 -0
  115. package/dist/{chunk-6Z7XDUUJ.js → chunk-ZMIRSWN6.js} +1 -1
  116. package/dist/{chunk-IYZT62UR.js → chunk-ZPILPVYU.js} +2 -2
  117. package/dist/chunk-ZXTSUXSL.js +4870 -0
  118. package/dist/{clean-TL3IPJDN.js → clean-VWCYLOVI.js} +26 -22
  119. package/dist/cli.js +58 -58
  120. package/dist/{cloud-EYMRPJNY.js → cloud-HU3RXCVE.js} +4 -4
  121. package/dist/{cloudrun-TOJ36NLX.js → cloudrun-OST6QBYD.js} +6 -5
  122. package/dist/commands/layout-audit.browser.js +1 -0
  123. package/dist/{compare-MP5EOW4D.js → compare-U2MJWZAH.js} +38 -35
  124. package/dist/{compiler-NOPVLJ2S.js → compiler-DSP4MVEC.js} +5 -3
  125. package/dist/{component-ASACDCZK.js → component-EC5XU6KR.js} +3 -3
  126. package/dist/{compositions-WKNZJY34.js → compositions-AKYCTF4G.js} +16 -13
  127. package/dist/{contactSheet-YOBPATEM.js → contactSheet-RYAE7Y5D.js} +3 -2
  128. package/dist/{delete-DQTFHP3G.js → delete-Z5MOEZM2.js} +10 -9
  129. package/dist/{deploy-HHCFOUFM.js → deploy-Y4LFVYXT.js} +6 -6
  130. package/dist/{dist-L4Z4ZEYW.js → dist-73YTUT3W.js} +1 -1
  131. package/dist/{dist-NQEYA4ZX.js → dist-JJL4QUDL.js} +2 -2
  132. package/dist/docker/Dockerfile.render +1 -1
  133. package/dist/{doctor-JDM65CP7.js → doctor-7234U557.js} +18 -15
  134. package/dist/{events-RKRHRLJD.js → events-RUIZNTG3.js} +4 -4
  135. package/dist/{events-MBRNA3UF.js → events-SII53QYO.js} +5 -5
  136. package/dist/{feedback-LZWIWV5J.js → feedback-6CCDDQ36.js} +12 -12
  137. package/dist/{ffmpeg-4PZKSIGE.js → ffmpeg-C4VWK4M2.js} +12 -9
  138. package/dist/{figma-QFNYUT3F.js → figma-GAN63U5U.js} +3 -3
  139. package/dist/fontLocalizeCli.js +13 -10
  140. package/dist/{get-2B5ENJOH.js → get-RZGUHZB4.js} +10 -9
  141. package/dist/{gpuPolicy-E5FB2GFR.js → gpuPolicy-BGJRCLP4.js} +10 -7
  142. package/dist/{grade-compare-4GUAPJHE.js → grade-compare-XOBN52WV.js} +38 -35
  143. package/dist/{heifImagePrep-C2RYIEER.js → heifImagePrep-DCHSYGW7.js} +11 -8
  144. package/dist/{help-XGDAXV67.js → help-O2IV6PUC.js} +1 -1
  145. package/dist/{history-WNFF6HGU.js → history-GPTEM4UX.js} +11 -10
  146. package/dist/hyperframe.manifest.json +1 -1
  147. package/dist/hyperframe.runtime.iife.js +67 -67
  148. package/dist/hyperframes-player.global.js +3 -3
  149. package/dist/{info-BR2LKGJD.js → info-7Y3JPN7C.js} +9 -9
  150. package/dist/{init-P6UWPUY3.js → init-L6W5WG5K.js} +40 -34
  151. package/dist/{inspect-MSRPF7ZO.js → inspect-MQZANGQY.js} +37 -34
  152. package/dist/{installer-MPUQS3ZX.js → installer-DCIMLYB6.js} +4 -4
  153. package/dist/{keyframes-J6K66QTO.js → keyframes-WNJIKL4G.js} +8 -8
  154. package/dist/{lambda-LJ2OSWFJ.js → lambda-FEA4SSFK.js} +16 -13
  155. package/dist/{layout-CDY65XGA.js → layout-AUQAYDJU.js} +37 -34
  156. package/dist/{lint-CAUNBGPX.js → lint-A33IHYID.js} +9 -9
  157. package/dist/{lintProject-ZTSX3AWT.js → lintProject-KCN7MRBN.js} +1 -1
  158. package/dist/{list-33BYQNRZ.js → list-56JHCET6.js} +10 -9
  159. package/dist/localPage-V3HBGM3Z.js +27 -0
  160. package/dist/{login-5QMRKOHK.js → login-HUOM4GNP.js} +7 -7
  161. package/dist/{logout-JYFWWUGK.js → logout-3IID4KXD.js} +3 -3
  162. package/dist/{manager-3JOHHPVR.js → manager-SDRJOMPR.js} +13 -10
  163. package/dist/{manager-RMYSZ3KI.js → manager-Z7W4GQGF.js} +4 -4
  164. package/dist/{media-treatment-4WP22CFN.js → media-treatment-5TGZOD67.js} +27 -22
  165. package/dist/{models-HPWCHAZX.js → models-ABDX6TXI.js} +17 -14
  166. package/dist/{motionShot-I7GDIROQ.js → motionShot-AV2WRH2C.js} +20 -18
  167. package/dist/{normalize-audio-VTMXPSC7.js → normalize-audio-M7T25DST.js} +12 -9
  168. package/dist/{open-SAO7OQTT.js → open-IRNZY5XN.js} +17 -16
  169. package/dist/{parakeetRunner-ZYPBIA73.js → parakeetRunner-2EJUIMOJ.js} +21 -17
  170. package/dist/{pipeline-VNBMR6QU.js → pipeline-QGKOJKXS.js} +13 -10
  171. package/dist/{play-7VI6A7KN.js → play-2SQLHM5B.js} +26 -23
  172. package/dist/{policies-GHVXA5PE.js → policies-PKLD4UW5.js} +1 -1
  173. package/dist/{preflight-VWV7L45J.js → preflight-ZHXMG2SM.js} +14 -11
  174. package/dist/{present-CSJGYOFF.js → present-RERVL6R7.js} +21 -18
  175. package/dist/{preview-B246ZTVO.js → preview-S6RQOMHE.js} +28 -25
  176. package/dist/{producer-WJLFDVQJ.js → producer-DBRGH2FI.js} +1 -1
  177. package/dist/{projectConfig-OMR46ZWQ.js → projectConfig-TUMDULTL.js} +9 -8
  178. package/dist/{publication-AA7NNYET.js → publication-7VGXIFVZ.js} +2 -2
  179. package/dist/{publish-TJ4QVVSP.js → publish-KJB2AGHL.js} +18 -15
  180. package/dist/{refresh-USSFPJAU.js → refresh-3IRHJEQA.js} +3 -3
  181. package/dist/{remove-background-LQ2V7W7N.js → remove-background-EFWXPLS4.js} +14 -11
  182. package/dist/{render-AWEEPG3F.js → render-5O5ARP6C.js} +65 -62
  183. package/dist/{render-JLTNZ36U.js → render-7S6UBLOE.js} +50 -48
  184. package/dist/{render-E5QJG74D.js → render-HV6AA22W.js} +6 -5
  185. package/dist/{render-batch-U4T4VSCM.js → render-batch-7UEOULJJ.js} +7 -6
  186. package/dist/renderSetupWorker.js +6 -6
  187. package/dist/{resolver-GXCTUKPV.js → resolver-HFTEER5V.js} +4 -4
  188. package/dist/{screenshotCapture-X6OKIXCB.js → screenshotCapture-HOW4VSV6.js} +3 -2
  189. package/dist/{sherpa-4VZWVHWZ.js → sherpa-HSSM76FL.js} +20 -16
  190. package/dist/skills/hyperframes/SKILL.md +1 -1
  191. package/dist/skills/hyperframes/references/format.md +1 -0
  192. package/dist/skills/hyperframes-cli/references/beats.md +2 -0
  193. package/dist/skills/media-use/references/grading.md +2 -0
  194. package/dist/skills/media-use/references/local.md +1 -0
  195. package/dist/{skills-WUKR7SUE.js → skills-RQO5K6WL.js} +7 -7
  196. package/dist/{skillsUpdateCheck-YXRBY3JC.js → skillsUpdateCheck-S5WL2YLZ.js} +5 -5
  197. package/dist/{snapshot-Q7S2FTNG.js → snapshot-4RGI235E.js} +119 -66
  198. package/dist/{src-ZOXUSGAP.js → src-ALOV4D57.js} +26 -10
  199. package/dist/{src-CLAALR5W.js → src-D75YYW2M.js} +12 -9
  200. package/dist/{staticProjectServer-DQ7PIDPA.js → staticProjectServer-DIHWPJ6B.js} +21 -18
  201. package/dist/{status-LR7VXITS.js → status-DTP6ZYDU.js} +3 -3
  202. package/dist/studio/assets/{hyperframes-player-Cm5aBiKq.js → hyperframes-player-CMH8OeX2.js} +3 -3
  203. package/dist/studio/assets/{index-BF9YeBnC.js → index-DQam8zzE.js} +71 -71
  204. package/dist/studio/assets/{index-BrqAmMRt.js → index-DjHzuJGR.js} +1 -1
  205. package/dist/studio/index.html +1 -1
  206. package/dist/{studio-api-NUE227JM.js → studio-api-A2VSWTVF.js} +13 -10
  207. package/dist/{studioServer-HVOKP4VI.js → studioServer-PECYWZHS.js} +60 -57
  208. package/dist/{synthesize-QZHRXGRY.js → synthesize-RVE7IUOJ.js} +3 -2
  209. package/dist/{telemetry-IHU4HL3R.js → telemetry-6BPSGY5W.js} +2 -2
  210. package/dist/{telemetry-2Y5JXLDB.js → telemetry-YDGXGOLH.js} +5 -5
  211. package/dist/{timeline-WOQGXFRV.js → timeline-5WUEEKZ3.js} +27 -23
  212. package/dist/{tokens-T3OHTWUC.js → tokens-XVFZPIUZ.js} +2 -2
  213. package/dist/{transcribe-JZ3BO546.js → transcribe-QWDUIJWK.js} +26 -22
  214. package/dist/{transcribe-4U74P5TG.js → transcribe-TTJ6CDQT.js} +17 -13
  215. package/dist/{tts-AY4JO5NQ.js → tts-AGMCPQXE.js} +1 -1
  216. package/dist/{updateCheck-6EUAGAM4.js → updateCheck-P7STSJ6Q.js} +4 -4
  217. package/dist/{upgrade-55K6F4MP.js → upgrade-NEIZ3KVL.js} +4 -4
  218. package/dist/{urlDownloader-47JMOLNN.js → urlDownloader-ZZFNGZNG.js} +9 -6
  219. package/dist/{validate-QBJ3SBS4.js → validate-T2SLBOXG.js} +30 -27
  220. package/dist/{video-3ZAUNAR3.js → video-7OHSBSRT.js} +12 -8
  221. package/dist/warmCheck.js +47 -44
  222. package/package.json +1 -1
  223. package/dist/chunk-BDJIQZN2.js +0 -4830
  224. package/dist/chunk-DKPNNYBZ.js +0 -44
  225. package/dist/{destroy-SSPAKADI.js → destroy-CGAZIL2C.js} +4 -4
@@ -12,51 +12,54 @@ import {
12
12
  } from "./chunk-6A45RKAK.js";
13
13
  import {
14
14
  describeProject
15
- } from "./chunk-FVAI7AHF.js";
15
+ } from "./chunk-F4O4G4ZW.js";
16
16
  import "./chunk-LLMSX6V6.js";
17
17
  import {
18
18
  bandFramesOf,
19
- decodeAudio,
20
19
  envelope,
20
+ loudness,
21
21
  medianInterval,
22
- probeAudio,
23
22
  rhythm,
24
23
  runLadder,
25
24
  signalDuration,
26
25
  signalProvider,
27
26
  snapper,
28
27
  tempoOf
29
- } from "./chunk-ZF3R2IPC.js";
28
+ } from "./chunk-YRO3PXWU.js";
30
29
  import {
31
30
  ensureDOMParser
32
31
  } from "./chunk-ZBAF6L74.js";
33
32
  import {
34
33
  refreshIfNeeded,
35
34
  resolveCloudBaseUrl
36
- } from "./chunk-6N65ZMC5.js";
35
+ } from "./chunk-VYRJAQGC.js";
37
36
  import {
38
37
  buildAuthHeaders,
39
38
  tryResolveCredential
40
- } from "./chunk-ELP5QZWL.js";
39
+ } from "./chunk-M4QZFUMW.js";
41
40
  import {
42
41
  downloadToFile
43
- } from "./chunk-CZUAX3BV.js";
42
+ } from "./chunk-QIDN4ML5.js";
43
+ import {
44
+ decodeAudio,
45
+ probeAudio
46
+ } from "./chunk-7VZEOCUY.js";
44
47
  import {
45
48
  loadTranscript
46
49
  } from "./chunk-6MUI2H6P.js";
47
50
  import {
48
51
  resolveProject
49
- } from "./chunk-XAGBSYIQ.js";
52
+ } from "./chunk-TSM67ADU.js";
50
53
  import "./chunk-VQB7G5BM.js";
51
- import "./chunk-7PJ3AJB2.js";
54
+ import "./chunk-L5XVBFUM.js";
52
55
  import "./chunk-K2FLNJVB.js";
53
- import "./chunk-EOVYQ3IG.js";
54
- import "./chunk-NSC5A4IR.js";
55
- import "./chunk-QTWXVOZI.js";
56
+ import "./chunk-NQ2INEHX.js";
57
+ import "./chunk-L7MGVFR4.js";
58
+ import "./chunk-EA5FUMJN.js";
56
59
  import "./chunk-VWG7OQKU.js";
57
60
  import {
58
61
  assertKnownFlags
59
- } from "./chunk-HTIUNMTP.js";
62
+ } from "./chunk-GDZA4ALG.js";
60
63
  import {
61
64
  defineCommand
62
65
  } from "./chunk-S3S4TGEH.js";
@@ -65,11 +68,14 @@ import {
65
68
  CliUsageError
66
69
  } from "./chunk-JVBRJMOP.js";
67
70
  import "./chunk-ZTZA4UWZ.js";
68
- import "./chunk-LK6KPVX2.js";
71
+ import "./chunk-IQNS7O4W.js";
72
+ import "./chunk-Z5J67X44.js";
69
73
  import "./chunk-5S7W3TUO.js";
70
- import "./chunk-RPZNQV6D.js";
71
- import "./chunk-7RWUY3BJ.js";
72
- import "./chunk-BDJIQZN2.js";
74
+ import "./chunk-D3MUHMFG.js";
75
+ import "./chunk-JC6BAQOG.js";
76
+ import "./chunk-XCIHCPJK.js";
77
+ import "./chunk-MI4V4HPE.js";
78
+ import "./chunk-ZXTSUXSL.js";
73
79
  import "./chunk-VC76R6W2.js";
74
80
  import "./chunk-OFQWTKPW.js";
75
81
  import "./chunk-RQVDTPGD.js";
@@ -79,8 +85,8 @@ import "./chunk-FXMKHHPO.js";
79
85
  import "./chunk-QSFWGZG6.js";
80
86
  import "./chunk-XT6MXC7A.js";
81
87
  import "./chunk-K4MJX7SR.js";
82
- import "./chunk-4UMPIPCQ.js";
83
- import "./chunk-ZCJ5EGLU.js";
88
+ import "./chunk-ERUQ3S6D.js";
89
+ import "./chunk-P327BIJR.js";
84
90
  import "./chunk-CZGHFATT.js";
85
91
  import {
86
92
  findFfBinary
@@ -99,13 +105,13 @@ import "./chunk-WC4MTXGN.js";
99
105
  import "./chunk-UIOZIIB7.js";
100
106
  import {
101
107
  withMeta
102
- } from "./chunk-EGRIVMCQ.js";
108
+ } from "./chunk-SPMKVI6H.js";
103
109
  import "./chunk-K4WIOZFP.js";
104
- import "./chunk-PSX5SF2N.js";
110
+ import "./chunk-NEASABW6.js";
105
111
  import "./chunk-WERLJGIC.js";
106
112
  import "./chunk-ISN5GRYI.js";
107
- import "./chunk-DML6BD4K.js";
108
- import "./chunk-T2EUWCJE.js";
113
+ import "./chunk-RAONLDN5.js";
114
+ import "./chunk-EU7MVORF.js";
109
115
  import "./chunk-M2WBOQ2Q.js";
110
116
 
111
117
  // src/commands/audio.ts
@@ -834,11 +840,11 @@ function hitsLine(onsets, at) {
834
840
  const more = onsets.events.length - shown.length;
835
841
  return ` hits ${shown.join(" ")}${more > 0 ? ` +${more}` : ""}`;
836
842
  }
837
- function loudnessLine(loudness, at) {
838
- const lufs = loudness.lufsIntegrated === null ? "below gate" : `${loudness.lufsIntegrated} LUFS`;
839
- const { count, firstAt } = loudness.clipping;
843
+ function loudnessLine(loudness2, at) {
844
+ const lufs2 = loudness2.lufsIntegrated === null ? "below gate" : `${loudness2.lufsIntegrated} LUFS`;
845
+ const { count, firstAt } = loudness2.clipping;
840
846
  const clip = count && firstAt !== null ? `, clips ${count}\xD7 from ${at(firstAt)}` : "";
841
- return ` loudness ${lufs}, true peak ${loudness.truePeakDb} dBTP${clip}`;
847
+ return ` loudness ${lufs2}, true peak ${loudness2.truePeakDb} dBTP${clip}`;
842
848
  }
843
849
  function silenceLine(silence, at) {
844
850
  return silence.length ? ` silent ${silence.map((g) => `${at(g.start)}\u2013${at(g.end)}`).join(" ")}` : null;
@@ -1035,10 +1041,14 @@ async function analyzeTargets(targets, request, full = false) {
1035
1041
  var READ_RATE = 22050;
1036
1042
  var PITCH_RATE = 8e3;
1037
1043
  var SILENT_DB = -120;
1044
+ var ABSENT_DB = -55;
1038
1045
  async function decodeMono(path, sampleRate = READ_RATE) {
1039
1046
  const decoded = await decodeAudio(path, {}, void 0, { sampleRate, mono: true });
1040
1047
  if (!decoded) throw new Error(`${path} has no audio stream`);
1041
- return decoded.signal.channels[0];
1048
+ const samples = decoded.signal.channels[0];
1049
+ if (samples.some((sample) => !Number.isFinite(sample)))
1050
+ throw new Error(`${path} contains non-finite audio samples`);
1051
+ return samples;
1042
1052
  }
1043
1053
  var asSignal = (samples, sampleRate = READ_RATE) => ({
1044
1054
  sampleRate,
@@ -1066,6 +1076,16 @@ function levels(samples, sampleRate, hop, window = hop * 2) {
1066
1076
  }
1067
1077
  return out;
1068
1078
  }
1079
+ function levelWhileHeardDb(samples, sampleRate) {
1080
+ let sum = 0;
1081
+ let heard = 0;
1082
+ for (const db of levels(samples, sampleRate, 0.1, 0.4))
1083
+ if (db >= ABSENT_DB) {
1084
+ sum += 10 ** (db / 10);
1085
+ heard++;
1086
+ }
1087
+ return heard ? Math.round(10 * Math.log10(sum / heard)) : null;
1088
+ }
1069
1089
  function quantile(values, q) {
1070
1090
  if (!values.length) return NaN;
1071
1091
  const sorted = Float64Array.from(values).sort();
@@ -1076,6 +1096,13 @@ var round6 = (n, places = 2) => {
1076
1096
  const k = 10 ** places;
1077
1097
  return Math.round(n * k) / k;
1078
1098
  };
1099
+ function spanDb(samples, sampleRate, start, end) {
1100
+ const a = Math.max(0, Math.round(start * sampleRate));
1101
+ const b = Math.min(samples.length, Math.round(end * sampleRate));
1102
+ let sum = 0;
1103
+ for (let i = a; i < b; i++) sum += samples[i] ** 2;
1104
+ return b > a && sum > 0 ? Math.max(SILENT_DB, 10 * Math.log10(sum / (b - a))) : SILENT_DB;
1105
+ }
1079
1106
 
1080
1107
  // src/audio/read/pitch.ts
1081
1108
  var FRAME = 320;
@@ -1139,12 +1166,27 @@ var semitones = (a, b) => 12 * Math.log2(a / b);
1139
1166
 
1140
1167
  // src/audio/read/format.ts
1141
1168
  var PITCH_NOTE_SEMITONES = 3;
1142
- var KIND_WIDTH = 7;
1169
+ var KIND_WIDTH = 8;
1170
+ var QUIET_DB = -45;
1171
+ var SILENT_DB2 = -55;
1172
+ var LEVEL_DB = 0.5;
1143
1173
  var s2 = (t) => t.toFixed(1);
1144
1174
  var signed = (db) => `${db >= 0 ? "+" : ""}${db} dB`;
1175
+ var dbfs = (db) => `${db} dBFS`;
1176
+ var lufs = (db) => `${Math.round(db)} LUFS`;
1145
1177
  function when(line) {
1146
1178
  return line.end === null ? s2(line.start) : `${s2(line.start)}\u2013${s2(line.end)}`;
1147
1179
  }
1180
+ function marginOf({ voiceLufs, musicLufs }) {
1181
+ const margin = voiceLufs - musicLufs;
1182
+ const apart = Math.max(1, Math.abs(Math.round(voiceLufs) - Math.round(musicLufs)));
1183
+ const verdict = Math.abs(margin) < LEVEL_DB ? "level with each other" : margin > 0 ? `voice ${apart} dB over music` : `music ${apart} dB over voice`;
1184
+ return `voice ${lufs(voiceLufs)}, music ${lufs(musicLufs)}: ${verdict}`;
1185
+ }
1186
+ function closing(sentence) {
1187
+ const parts = sentence.ending && sentence.ending !== "level" ? [`${sentence.ending} end`] : [];
1188
+ return sentence.againstMusic ? [...parts, marginOf(sentence.againstMusic)] : parts;
1189
+ }
1148
1190
  function voiceLine(sentence, voice) {
1149
1191
  const { unit, meanRate, medianPitchHz } = voice;
1150
1192
  const parts = [sentence.text === null ? "(no transcript)" : `"${sentence.text}"`];
@@ -1152,23 +1194,25 @@ function voiceLine(sentence, voice) {
1152
1194
  parts.push(`${sentence.rate} ${unit}/s${meanRate !== null ? ` (mean ${meanRate})` : ""}`);
1153
1195
  if (sentence.pitchHz !== null && medianPitchHz !== null && Math.abs(semitones(sentence.pitchHz, medianPitchHz)) >= PITCH_NOTE_SEMITONES)
1154
1196
  parts.push(`pitch ${sentence.pitchHz} Hz (median ${medianPitchHz})`);
1155
- if (sentence.ending && sentence.ending !== "level") parts.push(`${sentence.ending} end`);
1197
+ parts.push(...closing(sentence));
1156
1198
  return { start: sentence.start, end: sentence.end, kind: "voice", text: parts.join(" ") };
1157
1199
  }
1158
1200
  function placeOf(t, pauses) {
1159
1201
  const pause = pauses.find((p) => t >= p.start && t < p.end);
1160
1202
  return pause ? `${(t - pause.start).toFixed(1)} s into the pause` : null;
1161
1203
  }
1162
- function standing(effect, musicRead) {
1163
- if (effect.overMusicDb !== null) return `${signed(effect.overMusicDb)} over music`;
1164
- return musicRead ? "while the music is out" : `${signed(effect.riseDb)} over what played before`;
1204
+ function standing(effect) {
1205
+ const peak = `peak ${dbfs(effect.peakDb)}`;
1206
+ if (effect.overMusicDb !== null) return `${peak}, ${signed(effect.overMusicDb)} over music`;
1207
+ if (effect.riseDb === null) return `${peak}, out of silence`;
1208
+ return `${peak}, ${signed(effect.riseDb)} over what played before`;
1165
1209
  }
1166
- function effectLine(effect, pauses, musicRead) {
1210
+ function effectLine(effect, pauses) {
1167
1211
  const parts = [
1168
1212
  `${effect.kind}${effect.count > 1 ? ` \xD7${effect.count}` : ""} (${effect.group}): ${effect.band}`,
1169
1213
  `attack ${effect.attackMs} ms`,
1170
1214
  `tail ${effect.tail.toFixed(1)} s`,
1171
- standing(effect, musicRead)
1215
+ standing(effect)
1172
1216
  ];
1173
1217
  const place = placeOf(effect.t, pauses);
1174
1218
  if (place) parts.push(place);
@@ -1176,64 +1220,100 @@ function effectLine(effect, pauses, musicRead) {
1176
1220
  }
1177
1221
  var ENTRY = {
1178
1222
  start: "",
1179
- new: ", first appearance after a break",
1180
- resumes: ", resumes after a break",
1223
+ new: ", first appearance",
1224
+ resumes: ", resumes",
1181
1225
  returns: ", returns"
1182
1226
  };
1183
1227
  function musicLine(segment, analysis) {
1184
1228
  const piece = analysis.music.pieces.find((p) => p.id === segment.piece);
1185
1229
  const about = [piece.instruments.join(", "), segment.bpm ? `${segment.bpm} BPM` : null].filter(Boolean).join(" \xB7 ");
1230
+ const afterBreak = (segment.entry === "new" || segment.entry === "resumes") && analysis.music.breaks.some((gap) => gap.end === segment.start) ? " after a break" : "";
1186
1231
  const fade = segment.fadeFrom !== null ? `, fades from ${s2(segment.fadeFrom)}` : "";
1187
1232
  return {
1188
1233
  start: segment.start,
1189
1234
  end: segment.end,
1190
1235
  kind: "music",
1191
- text: `piece ${piece.id}${about ? ` (${about})` : ""}${ENTRY[segment.entry]}${fade}`
1236
+ text: `piece ${piece.id}${about ? ` (${about})` : ""}${ENTRY[segment.entry]}${afterBreak}${fade}`
1237
+ };
1238
+ }
1239
+ function effectsIn(events) {
1240
+ if (!events.length) return null;
1241
+ const counts = /* @__PURE__ */ new Map();
1242
+ for (const e of events) counts.set(e.kind, (counts.get(e.kind) ?? 0) + e.count);
1243
+ const kinds = [...counts].map(([kind, n]) => n > 1 ? `${kind} \xD7${n}` : kind).join(", ");
1244
+ const total = events.reduce((n, e) => n + e.count, 0);
1245
+ return `${total} ${total === 1 ? "effect" : "effects"} (${kinds})`;
1246
+ }
1247
+ function pauseLine(pause, analysis) {
1248
+ const inside = (start, end) => start < pause.end && end > pause.start;
1249
+ const clip = (start, end) => `${s2(Math.max(start, pause.start))}\u2013${s2(Math.min(end, pause.end))}`;
1250
+ const beds = [
1251
+ ...analysis.music?.segments.filter((m) => inside(m.start, m.end)).map((m) => `music ${clip(m.start, m.end)}`) ?? [],
1252
+ ...analysis.ambience?.filter((a) => inside(a.start, a.end)).map((a) => `ambience ${clip(a.start, a.end)}`) ?? []
1253
+ ];
1254
+ if (!beds.length && pause.recordingDb >= SILENT_DB2)
1255
+ beds.push(`sound continues at ${dbfs(pause.recordingDb)}`);
1256
+ const effects = effectsIn(
1257
+ analysis.effects?.events.filter((e) => e.t >= pause.start && e.t < pause.end) ?? []
1258
+ );
1259
+ const heard = [...effects ? [effects] : [], ...beds];
1260
+ const length = `${(pause.end - pause.start).toFixed(1)} s`;
1261
+ const text = heard.length ? `${length}; during it: ${heard.join(", ")}` : `${length}, silent`;
1262
+ return { start: pause.start, end: pause.end, kind: "pause", text };
1263
+ }
1264
+ function ambienceLine(ambience) {
1265
+ const level = `${ambience.db} dBFS`;
1266
+ return {
1267
+ start: ambience.start,
1268
+ end: ambience.end,
1269
+ kind: "ambience",
1270
+ text: ambience.db < QUIET_DB ? `quiet, ${level}` : level
1192
1271
  };
1193
1272
  }
1194
1273
  function overlaps(line, range) {
1195
1274
  if (!range) return true;
1196
1275
  return line.start < range[1] && (line.end ?? line.start) >= range[0];
1197
1276
  }
1277
+ function separation(analysis) {
1278
+ if (analysis.separation !== "stems") return "not separated";
1279
+ const heard = analysis.stems.map((stem) => `${stem.name} ${stem.db} dB`).join(", ");
1280
+ return `stems: ${heard || "all silent"}`;
1281
+ }
1282
+ function voiceSummary(voice) {
1283
+ const rate = voice.meanRate !== null ? `mean ${voice.meanRate} ${voice.unit}/s` : null;
1284
+ const pitch = voice.medianPitchHz !== null ? `median pitch ${voice.medianPitchHz} Hz` : null;
1285
+ return `voice: ${voice.sentences.length} lines, ${voice.pauses.length} pauses${[rate, pitch].filter(Boolean).map((p) => `, ${p}`).join("")}`;
1286
+ }
1287
+ function effectsSummary(effects) {
1288
+ const top = effects.groups.slice(0, 6).map((g) => `${g.id} ${g.kind} \xD7${g.count}`).join(", ");
1289
+ return `effects: ${effects.events.length} in ${effects.groups.length} sounds${top ? ` (${top})` : ""}${effects.drumHits ? `; ${effects.drumHits} drum hits on the beat left out` : ""}`;
1290
+ }
1291
+ var musicSummary = (music) => music.pieces.length ? `music: ${music.pieces.length} pieces, ${music.breaks.length} breaks` : "music: none";
1198
1292
  function header(analysis) {
1199
- const { voice, effects, music } = analysis;
1200
- const separated2 = analysis.separation === "stems" ? `stems: ${analysis.stems.join(", ")}` : "not separated";
1201
- const lines = [`${analysis.file} \xB7 ${s2(analysis.duration)} s \xB7 ${separated2}`];
1202
- if (voice) {
1203
- const rate = voice.meanRate !== null ? `mean ${voice.meanRate} ${voice.unit}/s` : null;
1204
- const pitch = voice.medianPitchHz !== null ? `median pitch ${voice.medianPitchHz} Hz` : null;
1205
- lines.push(
1206
- `voice: ${voice.sentences.length} lines, ${voice.pauses.length} pauses${[rate, pitch].filter(Boolean).map((p) => `, ${p}`).join("")}`
1207
- );
1208
- }
1209
- if (effects) {
1210
- const top = effects.groups.slice(0, 6).map((g) => `${g.id} ${g.kind} \xD7${g.count}`).join(", ");
1211
- lines.push(
1212
- `effects: ${effects.events.length} in ${effects.groups.length} sounds${top ? ` (${top})` : ""}${effects.drumHits ? `; ${effects.drumHits} drum hits on the beat left out` : ""}`
1213
- );
1214
- }
1215
- if (music) lines.push(`music: ${music.pieces.length} pieces, ${music.breaks.length} breaks`);
1216
- return lines;
1293
+ const { voice, effects, music, ambience } = analysis;
1294
+ return [
1295
+ `${analysis.file} \xB7 ${s2(analysis.duration)} s \xB7 ${separation(analysis)}`,
1296
+ voice && voiceSummary(voice),
1297
+ effects && effectsSummary(effects),
1298
+ music && musicSummary(music),
1299
+ ambience?.length && `ambience: ${ambience.length} stretches`
1300
+ ].filter((line) => typeof line === "string");
1217
1301
  }
1218
1302
  function formatRead(analysis, range) {
1219
1303
  const { voice, effects } = analysis;
1220
1304
  const pauses = voice?.pauses ?? [];
1221
1305
  const lines = [
1222
1306
  ...voice?.sentences.map((x) => voiceLine(x, voice)) ?? [],
1223
- ...pauses.map((p) => ({
1224
- start: p.start,
1225
- end: p.end,
1226
- kind: "pause",
1227
- text: `${(p.end - p.start).toFixed(1)} s`
1228
- })),
1229
- ...effects?.events.map((e) => effectLine(e, pauses, analysis.music !== null)) ?? [],
1307
+ ...pauses.map((p) => pauseLine(p, analysis)),
1308
+ ...effects?.events.map((e) => effectLine(e, pauses)) ?? [],
1230
1309
  ...analysis.music?.segments.map((m) => musicLine(m, analysis)) ?? [],
1231
1310
  ...analysis.music?.breaks.map((b) => ({
1232
1311
  start: b.start,
1233
1312
  end: b.end,
1234
1313
  kind: "music",
1235
1314
  text: `break ${(b.end - b.start).toFixed(1)} s`
1236
- })) ?? []
1315
+ })) ?? [],
1316
+ ...analysis.ambience?.map(ambienceLine) ?? []
1237
1317
  ].filter((line) => overlaps(line, range)).sort((a, b) => a.start - b.start || (a.end ?? a.start) - (b.end ?? b.start));
1238
1318
  const width = Math.max(0, ...lines.map((l) => when(l).length));
1239
1319
  const body = lines.map((l) => `${when(l).padEnd(width)} ${l.kind.padEnd(KIND_WIDTH)} ${l.text}`);
@@ -1263,7 +1343,6 @@ var RISE_DB = 20;
1263
1343
  var STEP_DB = 6;
1264
1344
  var AUDIBLE_DB = -60;
1265
1345
  var MASKED_DB = 20;
1266
- var MUSIC_OUT_DB = -60;
1267
1346
  var TAIL_DB = 30;
1268
1347
  var LONGEST = 4;
1269
1348
  var SAME_SOUND = 0.95;
@@ -1273,6 +1352,14 @@ var ON_BEAT_SHARE = 0.7;
1273
1352
  var DRUM_GROUP_MIN = 8;
1274
1353
  var LOW_HZ2 = 150;
1275
1354
  var BAND_FPS = 100;
1355
+ var SETTLE_FRAMES = 5;
1356
+ var PEAK_SLACK = 0.05;
1357
+ var BEFORE = 0.5;
1358
+ var MUSIC_BEFORE = 1;
1359
+ var GAP = 0.03;
1360
+ var SHORTEST_REFERENCE = 0.2;
1361
+ var SAME_ONSET = 0.03;
1362
+ var SPEECH_SLACK = 0.1;
1276
1363
  function floors(db) {
1277
1364
  const out = new Float32Array(db.length);
1278
1365
  let current = db[0] ?? -120;
@@ -1295,19 +1382,31 @@ function refined(samples, sampleRate, frame2, floorDb) {
1295
1382
  }
1296
1383
  return frame2 * HOP2;
1297
1384
  }
1298
- function extent(db, f, floor) {
1385
+ function onsetOf(db, f, base2, from) {
1299
1386
  let onset = f;
1300
- while (onset > Math.max(0, f - 50) && db[onset - 1] > floor + STEP_DB) onset--;
1387
+ while (onset > Math.max(from, f - 50) && db[onset - 1] > base2 + STEP_DB && db[onset - 1] < db[onset])
1388
+ onset--;
1389
+ return onset;
1390
+ }
1391
+ function extent(db, f, floor, from) {
1392
+ const base2 = floor[f];
1393
+ const onset = onsetOf(db, f, base2, from);
1301
1394
  let peak = f;
1302
1395
  let end = f;
1303
1396
  const last = Math.min(db.length - 1, f + LONGEST / HOP2);
1304
1397
  for (let g = f; g <= last; g++) {
1398
+ if (g >= f + SETTLE_FRAMES && startsAgain(db, g, f + 1, floor[g])) break;
1305
1399
  if (db[g] > db[peak]) peak = g;
1306
1400
  end = g;
1307
- if (g > peak && (db[g] < db[peak] - TAIL_DB || db[g] < floor + 3)) break;
1401
+ if (g > peak && (db[g] < db[peak] - TAIL_DB || db[g] < base2 + 3)) break;
1308
1402
  }
1309
1403
  return { onset, peak, end };
1310
1404
  }
1405
+ function startsAgain(db, g, from, floor) {
1406
+ let before = Infinity;
1407
+ for (let k = Math.max(from, g - SETTLE_FRAMES); k < g; k++) before = Math.min(before, db[k]);
1408
+ return db[g] - floor >= RISE_DB / 2 && db[g] - before >= STEP_DB;
1409
+ }
1311
1410
  function startsHere(db, f, floor) {
1312
1411
  const level = db[f];
1313
1412
  if (level < AUDIBLE_DB || level - floor < RISE_DB) return false;
@@ -1316,18 +1415,13 @@ function startsHere(db, f, floor) {
1316
1415
  function detect(db, samples, sampleRate, skip) {
1317
1416
  const floor = floors(db);
1318
1417
  const found = [];
1418
+ let from = 0;
1319
1419
  for (let f = 5; f < db.length; f++) {
1320
1420
  if (!startsHere(db, f, floor[f])) continue;
1321
- const { onset, peak, end } = extent(db, f, floor[f]);
1322
- const t = refined(samples, sampleRate, onset, floor[f]);
1323
- if (!skip(t))
1324
- found.push({
1325
- t,
1326
- peak: peak * HOP2,
1327
- end: end * HOP2,
1328
- peakDb: db[peak],
1329
- riseDb: db[peak] - floor[f]
1330
- });
1421
+ const { onset, peak, end } = extent(db, f, floor, from);
1422
+ const t = refined(samples, sampleRate, onset, Math.max(floor[f], db[onset - 1] ?? -120));
1423
+ if (!skip(t)) found.push({ t, peak: peak * HOP2, end: end * HOP2, peakDb: db[peak] });
1424
+ from = end + 1;
1331
1425
  f = Math.max(end, onset + 8);
1332
1426
  }
1333
1427
  return found;
@@ -1455,23 +1549,59 @@ function majority(kinds) {
1455
1549
  for (const k of kinds) counts.set(k, (counts.get(k) ?? 0) + 1);
1456
1550
  return [...counts].sort((a, b) => b[1] - a[1])[0][0];
1457
1551
  }
1458
- function measured2(input) {
1459
- const db = levels(input.source, input.sampleRate, HOP2);
1460
- const inSpeech = (t) => input.speech.some((s3) => t >= s3.start && t < s3.end);
1461
- const heardDb = input.heard ? levels(input.heard, input.sampleRate, HOP2, 0.5) : null;
1462
- const masked = (f) => {
1463
- const level = heardDb?.[Math.round(f.peak / HOP2)];
1464
- return level !== void 0 && f.peakDb < level - MASKED_DB;
1465
- };
1466
- const found = detect(db, input.source, input.sampleRate, inSpeech).filter((f) => !masked(f));
1467
- const bands = found.length ? bandFramesOf(asSignal(input.source, input.sampleRate)).bands : [];
1468
- const out = found.map((f) => {
1552
+ function foundIn({ samples: source, heldBy = [] }, input, mixDb) {
1553
+ const db = source === input.mix ? mixDb : levels(source, input.sampleRate, HOP2);
1554
+ const inSpeech = (t) => input.speech.some((s3) => t >= s3.start - SPEECH_SLACK && t < s3.end);
1555
+ const masked = (f) => f.peakDb < (mixDb[Math.round(f.peak / HOP2)] ?? -120) - MASKED_DB;
1556
+ const held = (f) => heldBy.some((span) => f.t < span.end && f.peak >= span.start);
1557
+ const found = detect(db, source, input.sampleRate, inSpeech).filter(
1558
+ (f) => !masked(f) && !held(f)
1559
+ );
1560
+ const bands = found.length ? bandFramesOf(asSignal(source, input.sampleRate)).bands : [];
1561
+ return found.map((f) => {
1469
1562
  const power = shape(bands, f.t, Math.min(f.end, f.t + 0.4));
1470
- return { ...f, ...kindOf(f, power), print: printOf(power), group: -1 };
1563
+ return { ...f, ...kindOf(f, power), print: printOf(power) };
1471
1564
  });
1565
+ }
1566
+ function measured2(input, mixDb) {
1567
+ const all = input.sources.flatMap((source) => foundIn(source, input, mixDb)).sort((a, b) => a.t - b.t);
1568
+ const out = [];
1569
+ for (const sound of all) {
1570
+ const previous = out[out.length - 1];
1571
+ if (previous && sound.t - previous.t < SAME_ONSET) {
1572
+ if (sound.peakDb > previous.peakDb) out[out.length - 1] = { ...sound, group: -1 };
1573
+ } else out.push({ ...sound, group: -1 });
1574
+ }
1472
1575
  grouped(out);
1473
1576
  return out;
1474
1577
  }
1578
+ function peakInMix(mixDb, m) {
1579
+ const a = Math.max(0, Math.round((m.peak - PEAK_SLACK) / HOP2));
1580
+ const b = Math.min(mixDb.length - 1, Math.round((m.peak + PEAK_SLACK) / HOP2));
1581
+ let peak = -120;
1582
+ for (let f = a; f <= b; f++) peak = Math.max(peak, mixDb[f]);
1583
+ return peak;
1584
+ }
1585
+ function musicNear(input, m, segment) {
1586
+ const { music, sampleRate } = input;
1587
+ const before = Math.max(segment.start, m.t - MUSIC_BEFORE);
1588
+ if (m.t - GAP - before >= SHORTEST_REFERENCE)
1589
+ return spanDb(music, sampleRate, before, m.t - GAP);
1590
+ return spanDb(music, sampleRate, m.end + GAP, Math.min(segment.end, m.end + MUSIC_BEFORE));
1591
+ }
1592
+ function levelsOf(input, mixDb, m) {
1593
+ const peakDb = peakInMix(mixDb, m);
1594
+ const a = Math.max(0, Math.round((m.t - BEFORE) / HOP2));
1595
+ const b = Math.max(a, Math.round((m.t - GAP) / HOP2));
1596
+ const beforeDb = b > a ? quantile(mixDb.subarray(a, b), 0.5) : -120;
1597
+ const segment = input.music ? input.musicSegments?.find((span) => m.t >= span.start && m.t < span.end) : void 0;
1598
+ const musicDb = segment ? musicNear(input, m, segment) : null;
1599
+ return {
1600
+ peakDb: Math.round(peakDb),
1601
+ riseDb: beforeDb < ABSENT_DB ? null : Math.round(peakDb - beforeDb),
1602
+ overMusicDb: musicDb !== null && musicDb >= ABSENT_DB ? Math.round(peakDb - musicDb) : null
1603
+ };
1604
+ }
1475
1605
  function drumGroups(members, beats) {
1476
1606
  const drums = /* @__PURE__ */ new Set();
1477
1607
  if (!beats.length) return drums;
@@ -1481,9 +1611,7 @@ function drumGroups(members, beats) {
1481
1611
  }
1482
1612
  return drums;
1483
1613
  }
1484
- function effectOf(m, group, kind, musicDb) {
1485
- const musicLevel = musicDb?.[Math.round(m.peak / HOP2)];
1486
- const musicPlays = musicLevel !== void 0 && musicLevel > MUSIC_OUT_DB;
1614
+ function effectOf(m, group, kind, levels2) {
1487
1615
  return {
1488
1616
  t: round6(m.t),
1489
1617
  end: round6(m.end),
@@ -1492,13 +1620,13 @@ function effectOf(m, group, kind, musicDb) {
1492
1620
  band: m.band,
1493
1621
  attackMs: Math.round((m.peak - m.t) * 1e3),
1494
1622
  tail: round6(m.end - m.peak),
1495
- riseDb: Math.round(m.riseDb),
1496
- overMusicDb: musicPlays ? Math.round(m.peakDb - musicLevel) : null,
1623
+ ...levels2,
1497
1624
  count: 1
1498
1625
  };
1499
1626
  }
1500
1627
  function findEffects(input) {
1501
- const sounds = measured2(input);
1628
+ const mixDb = levels(input.mix, input.sampleRate, HOP2);
1629
+ const sounds = measured2(input, mixDb);
1502
1630
  const members = /* @__PURE__ */ new Map();
1503
1631
  for (const m of sounds) members.set(m.group, [...members.get(m.group) ?? [], m]);
1504
1632
  const drums = drumGroups(members, input.beats);
@@ -1510,7 +1638,6 @@ function findEffects(input) {
1510
1638
  count: list.length
1511
1639
  }));
1512
1640
  const kindOfGroup = new Map(groups.map((g) => [g.id, g.kind]));
1513
- const musicDb = input.music ? levels(input.music, input.sampleRate, HOP2, 0.5) : null;
1514
1641
  const events = [];
1515
1642
  for (const m of sounds) {
1516
1643
  if (drums.has(m.group)) continue;
@@ -1519,7 +1646,8 @@ function findEffects(input) {
1519
1646
  if (previous?.group === group && m.t - previous.end <= TRAIN_GAP) {
1520
1647
  previous.end = round6(m.end);
1521
1648
  previous.count++;
1522
- } else events.push(effectOf(m, group, kindOfGroup.get(group) ?? m.kind, musicDb));
1649
+ } else
1650
+ events.push(effectOf(m, group, kindOfGroup.get(group) ?? m.kind, levelsOf(input, mixDb, m)));
1523
1651
  }
1524
1652
  const drumHits = [...drums].reduce((n, id) => n + members.get(id).length, 0);
1525
1653
  return { events, groups, drumHits };
@@ -1527,7 +1655,6 @@ function findEffects(input) {
1527
1655
 
1528
1656
  // src/audio/read/music.ts
1529
1657
  var HOP3 = 0.1;
1530
- var ABSENT_DB = -55;
1531
1658
  var CUT_DB = 25;
1532
1659
  var RUNNING_FRAMES = 200;
1533
1660
  var LEVEL_WINDOW = 0.4;
@@ -1545,6 +1672,10 @@ var FADE_DB = 10;
1545
1672
  var FADE_WINDOW = 3;
1546
1673
  var ENERGY_WINDOW = 30;
1547
1674
  var LEADING_SHARE = 0.2;
1675
+ var TONAL_SHARE = 0.4;
1676
+ var DENSE_WINDOW = 2;
1677
+ var DENSE_SHARE = 0.5;
1678
+ var STEADY = 0.5;
1548
1679
  function joined(spans, tooShort2) {
1549
1680
  const out = [];
1550
1681
  for (const span of spans) {
@@ -1608,6 +1739,48 @@ function runs(db) {
1608
1739
  breaks: settled.filter((s3) => s3.quiet && s3.start > 0 && s3.end < db.length * HOP3)
1609
1740
  };
1610
1741
  }
1742
+ function soundShare(fine, run) {
1743
+ const a = Math.round(run.start / HOP3);
1744
+ const b = Math.min(fine.length, Math.round(run.end / HOP3));
1745
+ const heard = new Float64Array(b - a + 1);
1746
+ for (let f = a; f < b; f++) heard[f - a + 1] = heard[f - a] + (fine[f] >= ABSENT_DB ? 1 : 0);
1747
+ const half = Math.round(DENSE_WINDOW / 2 / HOP3);
1748
+ const out = new Float32Array(b - a);
1749
+ for (let f = a; f < b; f++) {
1750
+ const lo = Math.max(a, f - half);
1751
+ const hi = Math.min(b, f + half + 1);
1752
+ out[f - a] = (heard[hi - a] - heard[lo - a]) / (hi - lo);
1753
+ }
1754
+ return out;
1755
+ }
1756
+ function steadyEdges(fine, part) {
1757
+ const steady = Math.round(STEADY / HOP3);
1758
+ const a = Math.round(part.start / HOP3);
1759
+ const b = Math.min(fine.length, Math.round(part.end / HOP3));
1760
+ const holds = (f) => {
1761
+ for (let k = f; k < f + steady; k++) if (k >= b || fine[k] < ABSENT_DB) return false;
1762
+ return true;
1763
+ };
1764
+ let start = a;
1765
+ while (start < b && !holds(start)) start++;
1766
+ let end = b;
1767
+ while (end > start && !holds(end - steady)) end--;
1768
+ return start < end ? { ...part, start: start * HOP3, end: end * HOP3 } : part;
1769
+ }
1770
+ function sustainedParts(fine, run) {
1771
+ if (run.end - run.start <= DENSE_WINDOW) {
1772
+ const a2 = Math.round(run.start / HOP3);
1773
+ const b = Math.max(a2 + 1, Math.min(fine.length, Math.round(run.end / HOP3)));
1774
+ let heard = 0;
1775
+ for (let f = a2; f < b; f++) if (fine[f] >= ABSENT_DB) heard++;
1776
+ return heard / (b - a2) >= DENSE_SHARE ? [run] : [];
1777
+ }
1778
+ const dense = soundShare(fine, run);
1779
+ const a = Math.round(run.start / HOP3);
1780
+ const sparse = new Uint8Array(fine.length);
1781
+ dense.forEach((share, i) => sparse[a + i] = share < DENSE_SHARE ? 1 : 0);
1782
+ 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) }));
1783
+ }
1611
1784
  function chromaOf(chroma, fps, run) {
1612
1785
  const a = Math.floor(run.start * fps);
1613
1786
  const b = Math.max(a + 1, Math.min(chroma.length, Math.ceil(run.end * fps)));
@@ -1616,6 +1789,17 @@ function chromaOf(chroma, fps, run) {
1616
1789
  const norm = Math.hypot(...sum);
1617
1790
  return norm ? sum.map((v) => v / norm) : sum;
1618
1791
  }
1792
+ function medianTopThreePitchShare(chroma, fps, run) {
1793
+ const a = Math.floor(run.start * fps);
1794
+ const b = Math.min(chroma.length, Math.ceil(run.end * fps));
1795
+ const held = [];
1796
+ for (let f = a; f < b; f++) {
1797
+ const sorted = [...chroma[f]].sort((x, y) => y - x);
1798
+ const total = sorted.reduce((n, v) => n + v, 0);
1799
+ if (total > 0) held.push((sorted[0] + sorted[1] + sorted[2]) / total);
1800
+ }
1801
+ return median(held);
1802
+ }
1619
1803
  var dot = (a, b) => a.reduce((n, v, k) => n + v * b[k], 0);
1620
1804
  function energyOf(samples, sampleRate, run) {
1621
1805
  const a = Math.floor(run.start * sampleRate);
@@ -1639,6 +1823,16 @@ function bpmOf(beats, run) {
1639
1823
  const interval = inside.length >= 4 ? medianInterval(inside) : null;
1640
1824
  return interval ? Math.round(60 / interval) : null;
1641
1825
  }
1826
+ function beatsInRun(signal, run) {
1827
+ const samples = signal.channels[0];
1828
+ if (run.start === 0 && run.end === samples.length / signal.sampleRate)
1829
+ return rhythm(signal).beats.times;
1830
+ const excerpt2 = samples.subarray(
1831
+ Math.floor(run.start * signal.sampleRate),
1832
+ Math.ceil(run.end * signal.sampleRate)
1833
+ );
1834
+ return rhythm(asSignal(excerpt2, signal.sampleRate)).beats.times;
1835
+ }
1642
1836
  var sameTempo = (a, b) => a === null || b === null || Math.abs(a - b) / Math.max(a, b) <= SAME_TEMPO;
1643
1837
  function fadeFrom(db, run) {
1644
1838
  const a = Math.floor(run.start / HOP3);
@@ -1650,6 +1844,8 @@ function fadeFrom(db, run) {
1650
1844
  if (db[f] < body - 3) return round6(f * HOP3, 1);
1651
1845
  return null;
1652
1846
  }
1847
+ var leading = (mix) => Object.entries(mix).filter(([, share]) => share >= LEADING_SHARE).sort((a, b) => b[1] - a[1]).map(([name]) => name);
1848
+ var isMusic = (heard) => heard.bpm !== null || heard.tonality >= TONAL_SHARE || leading(heard.mix).length > 1;
1653
1849
  var alike = (p, heard, piece, mix) => dot(p.print, heard.print) >= piece && mixDistance(p.mix, heard.mix) <= mix && sameTempo(p.bpm, heard.bpm);
1654
1850
  function pieceOf(pieces, previous, heard) {
1655
1851
  const last = previous && pieces.find((p) => p.id === previous.piece);
@@ -1660,21 +1856,30 @@ function pieceOf(pieces, previous, heard) {
1660
1856
  function newPiece(id, heard) {
1661
1857
  return {
1662
1858
  id,
1663
- instruments: Object.entries(heard.mix).filter(([, share]) => share >= LEADING_SHARE).sort((a, b) => b[1] - a[1]).map(([name]) => name),
1859
+ instruments: leading(heard.mix),
1664
1860
  bpm: heard.bpm,
1665
1861
  firstAt: round6(heard.run.start),
1666
1862
  print: heard.print,
1667
1863
  mix: heard.mix
1668
1864
  };
1669
1865
  }
1670
- function energyCurve(melodic, sampleRate, duration) {
1866
+ function liesBetweenMusic(found, gap, musical) {
1867
+ const after = found.findIndex((run) => run.start >= gap.end);
1868
+ return after > 0 && musical.has(found[after - 1]) && musical.has(found[after]);
1869
+ }
1870
+ function energyCurve(melodic, sampleRate, duration, musical) {
1671
1871
  const energy = [];
1672
1872
  for (let start = 0; start < duration; start += ENERGY_WINDOW) {
1673
1873
  const end = Math.min(duration, start + ENERGY_WINDOW);
1674
- const power = energyOf(melodic, sampleRate, { start, end });
1874
+ const overlaps2 = [...musical].map((run) => ({ start: Math.max(start, run.start), end: Math.min(end, run.end) })).filter((run) => run.end > run.start);
1875
+ if (!overlaps2.length) continue;
1876
+ const power = overlaps2.reduce(
1877
+ (sum, run) => sum + energyOf(melodic, sampleRate, run) * (run.end - run.start),
1878
+ 0
1879
+ ) / (end - start);
1675
1880
  energy.push({
1676
1881
  start,
1677
- end: round6(end),
1882
+ end: Math.min(round6(end), round6(duration, 3)),
1678
1883
  db: power > 0 ? Math.round(10 * Math.log10(power)) : -120
1679
1884
  });
1680
1885
  }
@@ -1683,20 +1888,38 @@ function energyCurve(melodic, sampleRate, duration) {
1683
1888
  function readMusic(input) {
1684
1889
  const melodic = mixed(Object.values(input.stems));
1685
1890
  const db = levels(melodic, input.sampleRate, HOP3, LEVEL_WINDOW);
1686
- const { segments: found, breaks } = runs(db);
1891
+ const duration = melodic.length / input.sampleRate;
1892
+ const fine = levels(melodic, input.sampleRate, HOP3, HOP3);
1893
+ const { segments: whole, breaks } = runs(db);
1894
+ for (const run of whole) run.end = Math.min(run.end, duration);
1895
+ const found = whole.flatMap((run) => sustainedParts(fine, run));
1687
1896
  const frames = bandFramesOf(asSignal(melodic, input.sampleRate));
1688
- const beats = rhythm(
1689
- asSignal(input.drums ? mixed([melodic, input.drums]) : melodic, input.sampleRate)
1690
- ).beats.times;
1897
+ const rhythmic = asSignal(
1898
+ input.drums ? mixed([melodic, input.drums]) : melodic,
1899
+ input.sampleRate
1900
+ );
1901
+ const beats = rhythm(rhythmic).beats.times;
1691
1902
  const pieces = [];
1692
1903
  const segments = [];
1904
+ const ambience = [];
1905
+ const musical = /* @__PURE__ */ new Set();
1693
1906
  for (const run of found) {
1694
1907
  const heard = {
1695
1908
  run,
1696
1909
  print: chromaOf(frames.chroma, frames.chromaFps, run),
1697
1910
  mix: shares(input, run),
1698
- bpm: bpmOf(beats, run)
1911
+ bpm: bpmOf(beatsInRun(rhythmic, run), { start: 0, end: run.end - run.start }),
1912
+ tonality: medianTopThreePitchShare(frames.chroma, frames.chromaFps, run)
1699
1913
  };
1914
+ if (!isMusic(heard)) {
1915
+ ambience.push({
1916
+ start: round6(run.start),
1917
+ end: Math.min(round6(run.end), round6(duration, 3)),
1918
+ db: Math.round(10 * Math.log10(Math.max(1e-12, energyOf(melodic, input.sampleRate, run))))
1919
+ });
1920
+ continue;
1921
+ }
1922
+ musical.add(run);
1700
1923
  const previous = segments[segments.length - 1];
1701
1924
  let piece = pieceOf(pieces, previous, heard);
1702
1925
  let entry;
@@ -1708,7 +1931,7 @@ function readMusic(input) {
1708
1931
  }
1709
1932
  segments.push({
1710
1933
  start: round6(run.start),
1711
- end: round6(run.end),
1934
+ end: Math.min(round6(run.end), round6(duration, 3)),
1712
1935
  piece: piece.id,
1713
1936
  entry,
1714
1937
  bpm: heard.bpm,
@@ -1719,9 +1942,10 @@ function readMusic(input) {
1719
1942
  music: {
1720
1943
  segments,
1721
1944
  pieces: pieces.map(({ print: _print, mix: _mix, ...piece }) => piece),
1722
- breaks: breaks.map((b) => ({ start: round6(b.start), end: round6(b.end) })),
1723
- energy: energyCurve(melodic, input.sampleRate, db.length * HOP3)
1945
+ breaks: breaks.filter((b) => liesBetweenMusic(found, b, musical)).map((b) => ({ start: round6(b.start), end: round6(b.end) })),
1946
+ energy: energyCurve(melodic, input.sampleRate, duration, musical)
1724
1947
  },
1948
+ ambience,
1725
1949
  beats
1726
1950
  };
1727
1951
  }
@@ -1775,10 +1999,15 @@ async function job(response) {
1775
1999
  async function encoded(path, dir, signal) {
1776
2000
  const ffmpeg = findFfBinary("ffmpeg", { configuredMustExist: true });
1777
2001
  if (!ffmpeg) throw new Error("ffmpeg is required to separate stems; run: npx hyperframes doctor");
2002
+ const audio = await probeAudio(path);
2003
+ if (!audio) throw new Error("the recording has no audio track ffmpeg can decode");
1778
2004
  const out = join5(dir, "upload.mp3");
1779
2005
  await runFile(
1780
2006
  ffmpeg,
1781
- ["-v", "error", "-y", "-i", path, "-vn", "-ac", "2", "-ar", "44100", "-b:a", "192k", out],
2007
+ [
2008
+ ...["-v", "error", "-y", "-i", path, "-map", `0:a:${audio.audioStream}`],
2009
+ ...["-vn", "-ac", "2", "-ar", "44100", "-b:a", "192k", out]
2010
+ ],
1782
2011
  { windowsHide: true, maxBuffer: 8 * 1024 * 1024, signal }
1783
2012
  );
1784
2013
  return out;
@@ -1853,7 +2082,7 @@ async function fetchStems(path, dir, { url, headers, timeoutMs }) {
1853
2082
  }
1854
2083
 
1855
2084
  // src/audio/read/types.ts
1856
- var READ_VERSION = 2;
2085
+ var READ_VERSION = 4;
1857
2086
 
1858
2087
  // src/audio/read/voice.ts
1859
2088
  var SENTENCE_END = /[。!?!?…;;.]["'”’」』)]*$/;
@@ -1916,7 +2145,7 @@ function summary(sentences, pauses, track2) {
1916
2145
  medianPitchHz: track2.length ? Math.round(median(track2.map((p) => p.hz))) : null
1917
2146
  };
1918
2147
  }
1919
- function voiceFromWords(words, track2) {
2148
+ function voiceFromWords(words, track2, levelOf) {
1920
2149
  const ordered = words.filter((w) => w.end > w.start).sort((a, b) => a.start - b.start);
1921
2150
  const unit = rateUnit(ordered);
1922
2151
  const sentences = sentenceGroups(ordered).map((group) => {
@@ -1929,20 +2158,23 @@ function voiceFromWords(words, track2) {
1929
2158
  text: joined2(group, unit),
1930
2159
  rate: count && end > start ? round6(count / (end - start), 1) : null,
1931
2160
  pitchHz: pitchOf(track2, start, end),
1932
- ending: ending(track2, start, end)
2161
+ ending: ending(track2, start, end),
2162
+ againstMusic: null
1933
2163
  };
1934
2164
  });
1935
2165
  const pauses = [];
1936
2166
  for (let i = 1; i < ordered.length; i++) {
1937
2167
  const gap = ordered[i].start - ordered[i - 1].end;
1938
- if (gap >= PAUSE_SECONDS)
1939
- pauses.push({ start: round6(ordered[i - 1].end), end: round6(ordered[i].start) });
2168
+ if (gap >= PAUSE_SECONDS) {
2169
+ const span = { start: round6(ordered[i - 1].end), end: round6(ordered[i].start) };
2170
+ pauses.push({ ...span, recordingDb: Math.round(levelOf(span)) });
2171
+ }
1940
2172
  }
1941
2173
  return { source: "transcript", unit, ...summary(sentences, pauses, track2) };
1942
2174
  }
1943
2175
  var ACTIVITY_HOP = 0.05;
1944
2176
  var SHORTEST_SPEECH = 0.3;
1945
- function voiceFromActivity(vocals, sampleRate, track2) {
2177
+ function voiceFromActivity(vocals, sampleRate, track2, levelOf) {
1946
2178
  const db = levels(vocals, sampleRate, ACTIVITY_HOP);
1947
2179
  const threshold = Math.max(-45, quantile(db, 0.9) - 30);
1948
2180
  const spans = [];
@@ -1972,10 +2204,14 @@ function voiceFromActivity(vocals, sampleRate, track2) {
1972
2204
  text: null,
1973
2205
  rate: null,
1974
2206
  pitchHz: pitchOf(track2, s3.start, s3.end),
1975
- ending: ending(track2, s3.start, s3.end)
2207
+ ending: ending(track2, s3.start, s3.end),
2208
+ againstMusic: null
1976
2209
  })
1977
2210
  );
1978
- const pauses = spans.slice(1).map((s3, i) => ({ start: round6(spans[i].end), end: round6(s3.start) }));
2211
+ const pauses = spans.slice(1).map((s3, i) => {
2212
+ const span = { start: round6(spans[i].end), end: round6(s3.start) };
2213
+ return { ...span, recordingDb: Math.round(levelOf(span)) };
2214
+ });
1979
2215
  return { source: "activity", unit: "chars", ...summary(sentences, pauses, track2) };
1980
2216
  }
1981
2217
 
@@ -2020,22 +2256,74 @@ async function stemsFor(path, dir, quality, warnings) {
2020
2256
  return null;
2021
2257
  }
2022
2258
  }
2023
- async function fromStems(path, stemPaths) {
2259
+ function heardStems(tracks) {
2260
+ return Object.entries(tracks).map(([name, samples]) => ({ name, db: levelWhileHeardDb(samples, READ_RATE) })).filter((stem) => stem.db !== null).sort((a, b) => b.db - a.db || a.name.localeCompare(b.name));
2261
+ }
2262
+ async function decodedStems(stemPaths) {
2024
2263
  const pitched = {};
2025
2264
  for (const [name, stemPath] of Object.entries(stemPaths))
2026
2265
  if (name !== VOICE_STEM && name !== DRUM_STEM) pitched[name] = await decodeMono(stemPath);
2027
2266
  const drums = stemPaths[DRUM_STEM] ? await decodeMono(stemPaths[DRUM_STEM]) : null;
2267
+ return { pitched, drums };
2268
+ }
2269
+ var present = (tracks) => tracks.filter((t) => t !== null);
2270
+ function musicOf(pitched, drums, bed) {
2271
+ return bed ? readMusic({ stems: pitched, drums, sampleRate: READ_RATE }) : { music: null, ambience: null, beats: [] };
2272
+ }
2273
+ function separatedStems(stemPaths, pitched, drums, vocals) {
2274
+ return heardStems({
2275
+ ...pitched,
2276
+ ...drums ? { [DRUM_STEM]: drums } : {},
2277
+ ...stemPaths[VOICE_STEM] ? { [VOICE_STEM]: vocals } : {}
2278
+ });
2279
+ }
2280
+ var recording = (path, separated2, voiceSamples) => separated2 ? decodeMono(path) : Promise.resolve(voiceSamples);
2281
+ function excerpt(samples, spans) {
2282
+ const parts = spans.map(
2283
+ (span) => samples.subarray(Math.round(span.start * READ_RATE), Math.round(span.end * READ_RATE))
2284
+ );
2285
+ const out = new Float32Array(parts.reduce((n, p) => n + p.length, 0));
2286
+ let at = 0;
2287
+ for (const part of parts) {
2288
+ out.set(part, at);
2289
+ at += part.length;
2290
+ }
2291
+ return out;
2292
+ }
2293
+ function againstMusic(voice, vocals, music, segments) {
2294
+ const sentences = voice.sentences.map((sentence) => {
2295
+ const under = segments.map((m) => ({
2296
+ start: Math.max(m.start, sentence.start),
2297
+ end: Math.min(m.end, sentence.end)
2298
+ })).filter((span) => span.end > span.start);
2299
+ if (!under.length) return sentence;
2300
+ const voiceLufs = loudness(asSignal(excerpt(vocals, under))).lufsIntegrated;
2301
+ const musicLufs = loudness(asSignal(excerpt(music, under))).lufsIntegrated;
2302
+ return voiceLufs === null || musicLufs === null ? sentence : { ...sentence, againstMusic: { voiceLufs, musicLufs } };
2303
+ });
2304
+ return { ...voice, sentences };
2305
+ }
2306
+ async function fromStems(stemPaths, voice, vocals, mix) {
2307
+ const { pitched, drums } = await decodedStems(stemPaths);
2028
2308
  const bed = Object.keys(pitched).length ? mixed(Object.values(pitched)) : null;
2029
- const { music, beats } = bed ? readMusic({ stems: pitched, drums, sampleRate: READ_RATE }) : { music: null, beats: [] };
2309
+ const { music, ambience, beats } = musicOf(pitched, drums, bed);
2310
+ const segments = music?.segments ?? [];
2311
+ const everythingElse = mixed(present([bed, drums]));
2030
2312
  const effects = findEffects({
2031
- source: drums ?? bed ?? new Float32Array(0),
2313
+ sources: [
2314
+ ...drums ? [{ samples: drums }] : [],
2315
+ ...bed ? [{ samples: bed, heldBy: [...segments, ...ambience ?? []] }] : []
2316
+ ],
2032
2317
  sampleRate: READ_RATE,
2033
- music: bed,
2034
- heard: await decodeMono(path),
2318
+ mix,
2319
+ music: bed && everythingElse,
2320
+ musicSegments: segments,
2035
2321
  beats,
2036
2322
  speech: []
2037
2323
  });
2038
- return { effects, music };
2324
+ const stems = separatedStems(stemPaths, pitched, drums, vocals);
2325
+ const read2 = music ? againstMusic(voice, vocals, everythingElse, music.segments) : voice;
2326
+ return { voice: read2, stems, effects, music, ambience };
2039
2327
  }
2040
2328
  var transcribeHint = (file) => `run hyperframes transcribe ${file} and pass --transcript`;
2041
2329
  async function analyze(path, file, sha, transcript, stemDir, quality) {
@@ -2049,23 +2337,26 @@ async function analyze(path, file, sha, transcript, stemDir, quality) {
2049
2337
  warnings.push(
2050
2338
  `no transcript and no stems: voice and effects are not read, because the mix alone does not tell speech from music; ${transcribeHint(file)}`
2051
2339
  );
2052
- return { ...about, voice: null, effects: null, music: null, warnings };
2340
+ return { ...about, voice: null, effects: null, music: null, ambience: null, warnings };
2053
2341
  }
2054
2342
  if (!words.length)
2055
2343
  warnings.push(`no transcript: voice lines carry no words; ${transcribeHint(file)}`);
2056
2344
  const pitch = pitchTrack(await decodeMono(voicePath, PITCH_RATE));
2057
- const voice = words.length ? voiceFromWords(words, pitch) : voiceFromActivity(voiceSamples, READ_RATE, pitch);
2058
- if (stemPaths) return { ...about, voice, ...await fromStems(path, stemPaths), warnings };
2345
+ const mix = await recording(path, stemPaths !== null, voiceSamples);
2346
+ const levelOf = (span) => spanDb(mix, READ_RATE, span.start, span.end);
2347
+ const voice = words.length ? voiceFromWords(words, pitch, levelOf) : voiceFromActivity(voiceSamples, READ_RATE, pitch, levelOf);
2348
+ if (stemPaths)
2349
+ return { ...about, ...await fromStems(stemPaths, voice, voiceSamples, mix), warnings };
2059
2350
  warnings.push("without stems, effects under speech are not found and music is not read");
2060
2351
  const effects = findEffects({
2061
- source: voiceSamples,
2352
+ sources: [{ samples: voiceSamples }],
2062
2353
  sampleRate: READ_RATE,
2354
+ mix,
2063
2355
  music: null,
2064
- heard: null,
2065
2356
  beats: [],
2066
2357
  speech: voice.sentences
2067
2358
  });
2068
- return { ...about, voice, effects, music: null, warnings };
2359
+ return { ...about, voice, effects, music: null, ambience: null, warnings };
2069
2360
  }
2070
2361
  function base(file, sha, duration, stemPaths, transcript) {
2071
2362
  return {
@@ -2074,7 +2365,7 @@ function base(file, sha, duration, stemPaths, transcript) {
2074
2365
  sha256: sha,
2075
2366
  duration,
2076
2367
  separation: stemPaths ? "stems" : "mix",
2077
- stems: stemPaths ? Object.keys(stemPaths).sort() : [],
2368
+ stems: [],
2078
2369
  transcript: transcript ? basename(transcript) : null
2079
2370
  };
2080
2371
  }