@jadujoel/web-audio-clip-node 0.1.2 → 0.1.3

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 (310) hide show
  1. package/dist/audio/processor-code.d.ts +1 -1
  2. package/dist/audio/processor-code.js +1 -1
  3. package/dist/audio/processor-kernel.js +20 -6
  4. package/dist/audio/version.d.ts +1 -1
  5. package/dist/audio/version.js +1 -1
  6. package/dist/lib.bundle.js +3 -3
  7. package/dist/lib.bundle.js.map +3 -3
  8. package/dist/processor.js +2 -2
  9. package/dist/processor.js.map +3 -3
  10. package/examples/cdn-vanilla/README.md +1 -1
  11. package/examples/cdn-vanilla/index.html +2 -14
  12. package/examples/esm-bundler/README.md +3 -4
  13. package/examples/esm-bundler/bun.lock +15 -0
  14. package/examples/esm-bundler/index.html +1 -1
  15. package/examples/esm-bundler/{src/main.ts → main.ts} +2 -4
  16. package/examples/esm-bundler/package.json +3 -6
  17. package/package.json +1 -1
  18. package/examples/esm-bundler/node_modules/.package-lock.json +0 -1168
  19. package/examples/esm-bundler/node_modules/@esbuild/darwin-arm64/README.md +0 -3
  20. package/examples/esm-bundler/node_modules/@esbuild/darwin-arm64/bin/esbuild +0 -0
  21. package/examples/esm-bundler/node_modules/@esbuild/darwin-arm64/package.json +0 -20
  22. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/LICENSE +0 -21
  23. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/README.md +0 -91
  24. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/audio/ClipNode.d.ts +0 -86
  25. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/audio/ClipNode.js +0 -312
  26. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/audio/processor-code.d.ts +0 -1
  27. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/audio/processor-code.js +0 -2
  28. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/audio/processor-kernel.d.ts +0 -43
  29. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/audio/processor-kernel.js +0 -861
  30. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/audio/processor.d.ts +0 -1
  31. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/audio/processor.js +0 -80
  32. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/audio/types.d.ts +0 -192
  33. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/audio/types.js +0 -9
  34. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/audio/utils.d.ts +0 -22
  35. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/audio/utils.js +0 -128
  36. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/audio/version.d.ts +0 -1
  37. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/audio/version.js +0 -2
  38. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/audio/workletUrl.d.ts +0 -6
  39. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/audio/workletUrl.js +0 -17
  40. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/components/AudioControl.d.ts +0 -28
  41. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/components/AudioControl.js +0 -99
  42. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/components/ContextMenu.d.ts +0 -17
  43. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/components/ContextMenu.js +0 -73
  44. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/components/ControlSection.d.ts +0 -26
  45. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/components/ControlSection.js +0 -74
  46. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/components/DetuneControl.d.ts +0 -10
  47. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/components/DetuneControl.js +0 -44
  48. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/components/DisplayPanel.d.ts +0 -14
  49. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/components/DisplayPanel.js +0 -6
  50. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/components/FilterControl.d.ts +0 -12
  51. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/components/FilterControl.js +0 -48
  52. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/components/GainControl.d.ts +0 -10
  53. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/components/GainControl.js +0 -44
  54. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/components/PanControl.d.ts +0 -10
  55. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/components/PanControl.js +0 -50
  56. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/components/PlaybackRateControl.d.ts +0 -10
  57. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/components/PlaybackRateControl.js +0 -44
  58. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/components/PlayheadSlider.d.ts +0 -13
  59. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/components/PlayheadSlider.js +0 -20
  60. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/components/SnappableSlider.d.ts +0 -18
  61. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/components/SnappableSlider.js +0 -174
  62. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/components/TransportButtons.d.ts +0 -14
  63. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/components/TransportButtons.js +0 -9
  64. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/controls/controlDefs.d.ts +0 -31
  65. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/controls/controlDefs.js +0 -211
  66. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/controls/formatValueText.d.ts +0 -2
  67. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/controls/formatValueText.js +0 -80
  68. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/controls/linkedControlPairs.d.ts +0 -20
  69. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/controls/linkedControlPairs.js +0 -51
  70. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/data/cache.d.ts +0 -1
  71. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/data/cache.js +0 -17
  72. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/data/fileStore.d.ts +0 -6
  73. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/data/fileStore.js +0 -39
  74. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/hooks/useClipNode.d.ts +0 -31
  75. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/hooks/useClipNode.js +0 -338
  76. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/lib-react.d.ts +0 -15
  77. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/lib-react.js +0 -17
  78. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/lib.d.ts +0 -16
  79. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/lib.js +0 -16
  80. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/processor.js +0 -4
  81. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/processor.js.map +0 -12
  82. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/store/clipStore.d.ts +0 -63
  83. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/store/clipStore.js +0 -71
  84. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/dist/styles.css +0 -739
  85. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/examples/README.md +0 -10
  86. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/examples/cdn-vanilla/README.md +0 -13
  87. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/examples/cdn-vanilla/index.html +0 -61
  88. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/examples/esm-bundler/README.md +0 -8
  89. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/examples/esm-bundler/index.html +0 -12
  90. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/examples/esm-bundler/package.json +0 -15
  91. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/examples/esm-bundler/src/main.ts +0 -43
  92. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/examples/react/README.md +0 -10
  93. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/examples/react/index.html +0 -12
  94. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/examples/react/package.json +0 -21
  95. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/examples/react/src/App.tsx +0 -20
  96. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/examples/react/src/main.tsx +0 -9
  97. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/examples/react/vite.config.ts +0 -6
  98. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/examples/self-hosted/README.md +0 -11
  99. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/examples/self-hosted/index.html +0 -12
  100. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/examples/self-hosted/package.json +0 -16
  101. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/examples/self-hosted/public/.gitkeep +0 -1
  102. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/examples/self-hosted/src/main.ts +0 -46
  103. package/examples/esm-bundler/node_modules/@jadujoel/web-audio-clip-node/package.json +0 -88
  104. package/examples/esm-bundler/node_modules/@rollup/rollup-darwin-arm64/README.md +0 -3
  105. package/examples/esm-bundler/node_modules/@rollup/rollup-darwin-arm64/package.json +0 -22
  106. package/examples/esm-bundler/node_modules/@rollup/rollup-darwin-arm64/rollup.darwin-arm64.node +0 -0
  107. package/examples/esm-bundler/node_modules/@types/estree/LICENSE +0 -21
  108. package/examples/esm-bundler/node_modules/@types/estree/README.md +0 -15
  109. package/examples/esm-bundler/node_modules/@types/estree/flow.d.ts +0 -167
  110. package/examples/esm-bundler/node_modules/@types/estree/index.d.ts +0 -694
  111. package/examples/esm-bundler/node_modules/@types/estree/package.json +0 -27
  112. package/examples/esm-bundler/node_modules/esbuild/LICENSE.md +0 -21
  113. package/examples/esm-bundler/node_modules/esbuild/README.md +0 -3
  114. package/examples/esm-bundler/node_modules/esbuild/bin/esbuild +0 -0
  115. package/examples/esm-bundler/node_modules/esbuild/install.js +0 -289
  116. package/examples/esm-bundler/node_modules/esbuild/lib/main.d.ts +0 -716
  117. package/examples/esm-bundler/node_modules/esbuild/lib/main.js +0 -2242
  118. package/examples/esm-bundler/node_modules/esbuild/package.json +0 -49
  119. package/examples/esm-bundler/node_modules/fdir/LICENSE +0 -7
  120. package/examples/esm-bundler/node_modules/fdir/README.md +0 -91
  121. package/examples/esm-bundler/node_modules/fdir/dist/index.cjs +0 -588
  122. package/examples/esm-bundler/node_modules/fdir/dist/index.d.cts +0 -155
  123. package/examples/esm-bundler/node_modules/fdir/dist/index.d.mts +0 -155
  124. package/examples/esm-bundler/node_modules/fdir/dist/index.mjs +0 -570
  125. package/examples/esm-bundler/node_modules/fdir/package.json +0 -103
  126. package/examples/esm-bundler/node_modules/nanoid/LICENSE +0 -20
  127. package/examples/esm-bundler/node_modules/nanoid/README.md +0 -39
  128. package/examples/esm-bundler/node_modules/nanoid/async/index.browser.cjs +0 -69
  129. package/examples/esm-bundler/node_modules/nanoid/async/index.browser.js +0 -34
  130. package/examples/esm-bundler/node_modules/nanoid/async/index.cjs +0 -71
  131. package/examples/esm-bundler/node_modules/nanoid/async/index.d.ts +0 -56
  132. package/examples/esm-bundler/node_modules/nanoid/async/index.js +0 -35
  133. package/examples/esm-bundler/node_modules/nanoid/async/index.native.js +0 -26
  134. package/examples/esm-bundler/node_modules/nanoid/async/package.json +0 -12
  135. package/examples/esm-bundler/node_modules/nanoid/bin/nanoid.cjs +0 -55
  136. package/examples/esm-bundler/node_modules/nanoid/index.browser.cjs +0 -72
  137. package/examples/esm-bundler/node_modules/nanoid/index.browser.js +0 -34
  138. package/examples/esm-bundler/node_modules/nanoid/index.cjs +0 -85
  139. package/examples/esm-bundler/node_modules/nanoid/index.d.cts +0 -91
  140. package/examples/esm-bundler/node_modules/nanoid/index.d.ts +0 -91
  141. package/examples/esm-bundler/node_modules/nanoid/index.js +0 -45
  142. package/examples/esm-bundler/node_modules/nanoid/nanoid.js +0 -1
  143. package/examples/esm-bundler/node_modules/nanoid/non-secure/index.cjs +0 -34
  144. package/examples/esm-bundler/node_modules/nanoid/non-secure/index.d.ts +0 -33
  145. package/examples/esm-bundler/node_modules/nanoid/non-secure/index.js +0 -21
  146. package/examples/esm-bundler/node_modules/nanoid/non-secure/package.json +0 -6
  147. package/examples/esm-bundler/node_modules/nanoid/package.json +0 -89
  148. package/examples/esm-bundler/node_modules/nanoid/url-alphabet/index.cjs +0 -7
  149. package/examples/esm-bundler/node_modules/nanoid/url-alphabet/index.js +0 -3
  150. package/examples/esm-bundler/node_modules/nanoid/url-alphabet/package.json +0 -6
  151. package/examples/esm-bundler/node_modules/picocolors/LICENSE +0 -15
  152. package/examples/esm-bundler/node_modules/picocolors/README.md +0 -21
  153. package/examples/esm-bundler/node_modules/picocolors/package.json +0 -25
  154. package/examples/esm-bundler/node_modules/picocolors/picocolors.browser.js +0 -4
  155. package/examples/esm-bundler/node_modules/picocolors/picocolors.d.ts +0 -5
  156. package/examples/esm-bundler/node_modules/picocolors/picocolors.js +0 -75
  157. package/examples/esm-bundler/node_modules/picocolors/types.d.ts +0 -51
  158. package/examples/esm-bundler/node_modules/picomatch/LICENSE +0 -21
  159. package/examples/esm-bundler/node_modules/picomatch/README.md +0 -749
  160. package/examples/esm-bundler/node_modules/picomatch/index.js +0 -17
  161. package/examples/esm-bundler/node_modules/picomatch/lib/constants.js +0 -184
  162. package/examples/esm-bundler/node_modules/picomatch/lib/parse.js +0 -1386
  163. package/examples/esm-bundler/node_modules/picomatch/lib/picomatch.js +0 -349
  164. package/examples/esm-bundler/node_modules/picomatch/lib/scan.js +0 -391
  165. package/examples/esm-bundler/node_modules/picomatch/lib/utils.js +0 -72
  166. package/examples/esm-bundler/node_modules/picomatch/package.json +0 -82
  167. package/examples/esm-bundler/node_modules/picomatch/posix.js +0 -3
  168. package/examples/esm-bundler/node_modules/postcss/LICENSE +0 -20
  169. package/examples/esm-bundler/node_modules/postcss/README.md +0 -28
  170. package/examples/esm-bundler/node_modules/postcss/lib/at-rule.d.ts +0 -139
  171. package/examples/esm-bundler/node_modules/postcss/lib/at-rule.js +0 -25
  172. package/examples/esm-bundler/node_modules/postcss/lib/comment.d.ts +0 -67
  173. package/examples/esm-bundler/node_modules/postcss/lib/comment.js +0 -13
  174. package/examples/esm-bundler/node_modules/postcss/lib/container.d.ts +0 -478
  175. package/examples/esm-bundler/node_modules/postcss/lib/container.js +0 -447
  176. package/examples/esm-bundler/node_modules/postcss/lib/css-syntax-error.d.ts +0 -247
  177. package/examples/esm-bundler/node_modules/postcss/lib/css-syntax-error.js +0 -133
  178. package/examples/esm-bundler/node_modules/postcss/lib/declaration.d.ts +0 -150
  179. package/examples/esm-bundler/node_modules/postcss/lib/declaration.js +0 -24
  180. package/examples/esm-bundler/node_modules/postcss/lib/document.d.ts +0 -68
  181. package/examples/esm-bundler/node_modules/postcss/lib/document.js +0 -33
  182. package/examples/esm-bundler/node_modules/postcss/lib/fromJSON.d.ts +0 -9
  183. package/examples/esm-bundler/node_modules/postcss/lib/fromJSON.js +0 -54
  184. package/examples/esm-bundler/node_modules/postcss/lib/input.d.ts +0 -226
  185. package/examples/esm-bundler/node_modules/postcss/lib/input.js +0 -273
  186. package/examples/esm-bundler/node_modules/postcss/lib/lazy-result.d.ts +0 -189
  187. package/examples/esm-bundler/node_modules/postcss/lib/lazy-result.js +0 -550
  188. package/examples/esm-bundler/node_modules/postcss/lib/list.d.ts +0 -60
  189. package/examples/esm-bundler/node_modules/postcss/lib/list.js +0 -58
  190. package/examples/esm-bundler/node_modules/postcss/lib/map-generator.js +0 -376
  191. package/examples/esm-bundler/node_modules/postcss/lib/no-work-result.d.ts +0 -45
  192. package/examples/esm-bundler/node_modules/postcss/lib/no-work-result.js +0 -137
  193. package/examples/esm-bundler/node_modules/postcss/lib/node.d.ts +0 -555
  194. package/examples/esm-bundler/node_modules/postcss/lib/node.js +0 -449
  195. package/examples/esm-bundler/node_modules/postcss/lib/parse.d.ts +0 -9
  196. package/examples/esm-bundler/node_modules/postcss/lib/parse.js +0 -42
  197. package/examples/esm-bundler/node_modules/postcss/lib/parser.js +0 -611
  198. package/examples/esm-bundler/node_modules/postcss/lib/postcss.d.mts +0 -66
  199. package/examples/esm-bundler/node_modules/postcss/lib/postcss.d.ts +0 -456
  200. package/examples/esm-bundler/node_modules/postcss/lib/postcss.js +0 -101
  201. package/examples/esm-bundler/node_modules/postcss/lib/postcss.mjs +0 -30
  202. package/examples/esm-bundler/node_modules/postcss/lib/previous-map.d.ts +0 -80
  203. package/examples/esm-bundler/node_modules/postcss/lib/previous-map.js +0 -145
  204. package/examples/esm-bundler/node_modules/postcss/lib/processor.d.ts +0 -114
  205. package/examples/esm-bundler/node_modules/postcss/lib/processor.js +0 -67
  206. package/examples/esm-bundler/node_modules/postcss/lib/result.d.ts +0 -204
  207. package/examples/esm-bundler/node_modules/postcss/lib/result.js +0 -42
  208. package/examples/esm-bundler/node_modules/postcss/lib/root.d.ts +0 -86
  209. package/examples/esm-bundler/node_modules/postcss/lib/root.js +0 -61
  210. package/examples/esm-bundler/node_modules/postcss/lib/rule.d.ts +0 -126
  211. package/examples/esm-bundler/node_modules/postcss/lib/rule.js +0 -27
  212. package/examples/esm-bundler/node_modules/postcss/lib/stringifier.d.ts +0 -45
  213. package/examples/esm-bundler/node_modules/postcss/lib/stringifier.js +0 -353
  214. package/examples/esm-bundler/node_modules/postcss/lib/stringify.d.ts +0 -9
  215. package/examples/esm-bundler/node_modules/postcss/lib/stringify.js +0 -11
  216. package/examples/esm-bundler/node_modules/postcss/lib/symbols.js +0 -5
  217. package/examples/esm-bundler/node_modules/postcss/lib/terminal-highlight.js +0 -70
  218. package/examples/esm-bundler/node_modules/postcss/lib/tokenize.js +0 -266
  219. package/examples/esm-bundler/node_modules/postcss/lib/warn-once.js +0 -13
  220. package/examples/esm-bundler/node_modules/postcss/lib/warning.d.ts +0 -146
  221. package/examples/esm-bundler/node_modules/postcss/lib/warning.js +0 -37
  222. package/examples/esm-bundler/node_modules/postcss/package.json +0 -88
  223. package/examples/esm-bundler/node_modules/rollup/LICENSE.md +0 -679
  224. package/examples/esm-bundler/node_modules/rollup/README.md +0 -134
  225. package/examples/esm-bundler/node_modules/rollup/dist/bin/rollup +0 -1912
  226. package/examples/esm-bundler/node_modules/rollup/dist/es/getLogFilter.js +0 -64
  227. package/examples/esm-bundler/node_modules/rollup/dist/es/package.json +0 -1
  228. package/examples/esm-bundler/node_modules/rollup/dist/es/parseAst.js +0 -12
  229. package/examples/esm-bundler/node_modules/rollup/dist/es/rollup.js +0 -17
  230. package/examples/esm-bundler/node_modules/rollup/dist/es/shared/node-entry.js +0 -24463
  231. package/examples/esm-bundler/node_modules/rollup/dist/es/shared/parseAst.js +0 -2124
  232. package/examples/esm-bundler/node_modules/rollup/dist/es/shared/watch.js +0 -9909
  233. package/examples/esm-bundler/node_modules/rollup/dist/getLogFilter.d.ts +0 -5
  234. package/examples/esm-bundler/node_modules/rollup/dist/getLogFilter.js +0 -69
  235. package/examples/esm-bundler/node_modules/rollup/dist/loadConfigFile.d.ts +0 -20
  236. package/examples/esm-bundler/node_modules/rollup/dist/loadConfigFile.js +0 -29
  237. package/examples/esm-bundler/node_modules/rollup/dist/native.js +0 -161
  238. package/examples/esm-bundler/node_modules/rollup/dist/parseAst.d.ts +0 -4
  239. package/examples/esm-bundler/node_modules/rollup/dist/parseAst.js +0 -22
  240. package/examples/esm-bundler/node_modules/rollup/dist/rollup.d.ts +0 -1225
  241. package/examples/esm-bundler/node_modules/rollup/dist/rollup.js +0 -127
  242. package/examples/esm-bundler/node_modules/rollup/dist/shared/fsevents-importer.js +0 -37
  243. package/examples/esm-bundler/node_modules/rollup/dist/shared/index.js +0 -9615
  244. package/examples/esm-bundler/node_modules/rollup/dist/shared/loadConfigFile.js +0 -572
  245. package/examples/esm-bundler/node_modules/rollup/dist/shared/parseAst.js +0 -2361
  246. package/examples/esm-bundler/node_modules/rollup/dist/shared/rollup.js +0 -24385
  247. package/examples/esm-bundler/node_modules/rollup/dist/shared/watch-cli.js +0 -542
  248. package/examples/esm-bundler/node_modules/rollup/dist/shared/watch.js +0 -324
  249. package/examples/esm-bundler/node_modules/rollup/package.json +0 -289
  250. package/examples/esm-bundler/node_modules/source-map-js/LICENSE +0 -28
  251. package/examples/esm-bundler/node_modules/source-map-js/README.md +0 -765
  252. package/examples/esm-bundler/node_modules/source-map-js/lib/array-set.js +0 -121
  253. package/examples/esm-bundler/node_modules/source-map-js/lib/base64-vlq.js +0 -140
  254. package/examples/esm-bundler/node_modules/source-map-js/lib/base64.js +0 -67
  255. package/examples/esm-bundler/node_modules/source-map-js/lib/binary-search.js +0 -111
  256. package/examples/esm-bundler/node_modules/source-map-js/lib/mapping-list.js +0 -79
  257. package/examples/esm-bundler/node_modules/source-map-js/lib/quick-sort.js +0 -132
  258. package/examples/esm-bundler/node_modules/source-map-js/lib/source-map-consumer.d.ts +0 -1
  259. package/examples/esm-bundler/node_modules/source-map-js/lib/source-map-consumer.js +0 -1188
  260. package/examples/esm-bundler/node_modules/source-map-js/lib/source-map-generator.d.ts +0 -1
  261. package/examples/esm-bundler/node_modules/source-map-js/lib/source-map-generator.js +0 -444
  262. package/examples/esm-bundler/node_modules/source-map-js/lib/source-node.d.ts +0 -1
  263. package/examples/esm-bundler/node_modules/source-map-js/lib/source-node.js +0 -413
  264. package/examples/esm-bundler/node_modules/source-map-js/lib/util.js +0 -594
  265. package/examples/esm-bundler/node_modules/source-map-js/package.json +0 -71
  266. package/examples/esm-bundler/node_modules/source-map-js/source-map.d.ts +0 -104
  267. package/examples/esm-bundler/node_modules/source-map-js/source-map.js +0 -8
  268. package/examples/esm-bundler/node_modules/tinyglobby/LICENSE +0 -21
  269. package/examples/esm-bundler/node_modules/tinyglobby/README.md +0 -25
  270. package/examples/esm-bundler/node_modules/tinyglobby/dist/index.cjs +0 -334
  271. package/examples/esm-bundler/node_modules/tinyglobby/dist/index.d.cts +0 -148
  272. package/examples/esm-bundler/node_modules/tinyglobby/dist/index.d.mts +0 -148
  273. package/examples/esm-bundler/node_modules/tinyglobby/dist/index.mjs +0 -306
  274. package/examples/esm-bundler/node_modules/tinyglobby/package.json +0 -73
  275. package/examples/esm-bundler/node_modules/vite/LICENSE.md +0 -2406
  276. package/examples/esm-bundler/node_modules/vite/README.md +0 -20
  277. package/examples/esm-bundler/node_modules/vite/bin/openChrome.applescript +0 -95
  278. package/examples/esm-bundler/node_modules/vite/bin/vite.js +0 -79
  279. package/examples/esm-bundler/node_modules/vite/client.d.ts +0 -279
  280. package/examples/esm-bundler/node_modules/vite/dist/client/client.mjs +0 -1134
  281. package/examples/esm-bundler/node_modules/vite/dist/client/env.mjs +0 -24
  282. package/examples/esm-bundler/node_modules/vite/dist/node/chunks/dep-3RmXg9uo.js +0 -553
  283. package/examples/esm-bundler/node_modules/vite/dist/node/chunks/dep-4-IQbZQm.js +0 -822
  284. package/examples/esm-bundler/node_modules/vite/dist/node/chunks/dep-CvfTChi5.js +0 -8218
  285. package/examples/esm-bundler/node_modules/vite/dist/node/chunks/dep-Dq2t6Dq0.js +0 -49565
  286. package/examples/esm-bundler/node_modules/vite/dist/node/chunks/dep-lpEPC2f9.js +0 -7113
  287. package/examples/esm-bundler/node_modules/vite/dist/node/cli.js +0 -949
  288. package/examples/esm-bundler/node_modules/vite/dist/node/constants.js +0 -149
  289. package/examples/esm-bundler/node_modules/vite/dist/node/index.d.ts +0 -4227
  290. package/examples/esm-bundler/node_modules/vite/dist/node/index.js +0 -194
  291. package/examples/esm-bundler/node_modules/vite/dist/node/module-runner.d.ts +0 -290
  292. package/examples/esm-bundler/node_modules/vite/dist/node/module-runner.js +0 -1311
  293. package/examples/esm-bundler/node_modules/vite/dist/node/moduleRunnerTransport.d-DJ_mE5sf.d.ts +0 -87
  294. package/examples/esm-bundler/node_modules/vite/dist/node-cjs/publicUtils.cjs +0 -3987
  295. package/examples/esm-bundler/node_modules/vite/index.cjs +0 -96
  296. package/examples/esm-bundler/node_modules/vite/index.d.cts +0 -6
  297. package/examples/esm-bundler/node_modules/vite/misc/false.js +0 -1
  298. package/examples/esm-bundler/node_modules/vite/misc/true.js +0 -1
  299. package/examples/esm-bundler/node_modules/vite/package.json +0 -204
  300. package/examples/esm-bundler/node_modules/vite/types/customEvent.d.ts +0 -45
  301. package/examples/esm-bundler/node_modules/vite/types/hmrPayload.d.ts +0 -74
  302. package/examples/esm-bundler/node_modules/vite/types/hot.d.ts +0 -39
  303. package/examples/esm-bundler/node_modules/vite/types/import-meta.d.ts +0 -5
  304. package/examples/esm-bundler/node_modules/vite/types/importGlob.d.ts +0 -75
  305. package/examples/esm-bundler/node_modules/vite/types/importMeta.d.ts +0 -31
  306. package/examples/esm-bundler/node_modules/vite/types/internal/cssPreprocessorOptions.d.ts +0 -63
  307. package/examples/esm-bundler/node_modules/vite/types/internal/lightningcssOptions.d.ts +0 -18
  308. package/examples/esm-bundler/node_modules/vite/types/metadata.d.ts +0 -35
  309. package/examples/esm-bundler/node_modules/vite/types/package.json +0 -4
  310. package/examples/esm-bundler/package-lock.json +0 -1127
package/dist/processor.js CHANGED
@@ -1,4 +1,4 @@
1
- var z={Initial:0,Started:1,Stopped:2,Paused:3,Scheduled:4,Ended:5,Disposed:6};var y=128;function i(V=[]){let A=V[0]?.length??0,F=A>0;return{totalLength:F?A:null,committedLength:F?A:0,streamEnded:F,streaming:!1,writtenSpans:F?[{startSample:0,endSample:A}]:[],pendingWrites:[],lowWaterThreshold:y*4,lowWaterNotified:!1,lastUnderrunSample:null}}function M0(V){return V[0]?.length??0}function o(V){return V.streamBuffer.totalLength??M0(V.buffer)}function G0(V,A){return Array.from({length:V},()=>new Float32Array(A))}function E0(V,A){let F=[...V,A].sort((Q,J)=>Q.startSample-J.startSample),T=[];for(let Q of F){let J=T[T.length-1];if(!J||Q.startSample>J.endSample){T.push({...Q});continue}J.endSample=Math.max(J.endSample,Q.endSample)}return T}function I0(V){let A=0;for(let F of V){if(F.startSample>A)break;A=Math.max(A,F.endSample)}return A}function w0(V,A){if(V.committedLength-Math.floor(A)>=V.lowWaterThreshold)V.lowWaterNotified=!1}function R0(V,A,F){let T=M0(V.buffer),Q=V.buffer.length;if(T>=F&&Q>=A)return;let J=Math.max(T,F),U=Math.max(Q,A),Y=G0(U,J);for(let X=0;X<Q;X++)Y[X].set(V.buffer[X].subarray(0,T));if(V.buffer=Y,V.streamBuffer.totalLength==null||V.streamBuffer.totalLength<J)V.streamBuffer.totalLength=J}function B0(V,A){let F=Math.max(Math.floor(A.startSample),0),T=A.channelData[0]?.length??0,Q=A.totalLength??null,J=Math.max(F+T,Q??0);R0(V,Math.max(A.channelData.length,V.buffer.length,1),J);for(let U=0;U<A.channelData.length;U++)V.buffer[U].set(A.channelData[U],F);if(Q!=null)V.streamBuffer.totalLength=Q;if(T>0)V.streamBuffer.writtenSpans=E0(V.streamBuffer.writtenSpans,{startSample:F,endSample:F+T}),V.streamBuffer.committedLength=I0(V.streamBuffer.writtenSpans);if(A.streamEnded===!0)V.streamBuffer.streamEnded=!0;w0(V.streamBuffer,V.playhead)}function _0(V){if(V.streamBuffer.pendingWrites.length===0)return;for(let A of V.streamBuffer.pendingWrites)B0(V,A);V.streamBuffer.pendingWrites=[]}function y0(V,A){V.buffer=A,V.streamBuffer=i(A)}function v0(V={},A){let{buffer:F=[],streamBuffer:T=i(F),duration:Q=-1,loop:J=!1,loopStart:U=0,loopEnd:Y=(F[0]?.length??0)/A,loopCrossfade:X=0,playhead:k=0,offset:H=0,startWhen:$=0,stopWhen:j=0,pauseWhen:P=0,resumeWhen:C=0,playedSamples:N=0,state:K=z.Initial,timesLooped:w=0,fadeInDuration:v=0,fadeOutDuration:Z=0,enableFadeIn:E=v>0,enableFadeOut:O=Z>0,enableLoopStart:R=!0,enableLoopEnd:h=!0,enableLoopCrossfade:b=X>0,enableHighpass:c=!0,enableLowpass:g=!0,enableGain:s=!0,enablePan:r=!0,enableDetune:t=!0,enablePlaybackRate:p=!0}=V;return{buffer:F,streamBuffer:T,loop:J,loopStart:U,loopEnd:Y,loopCrossfade:X,duration:Q,playhead:k,offset:H,startWhen:$,stopWhen:j,pauseWhen:P,resumeWhen:C,playedSamples:N,state:K,timesLooped:w,fadeInDuration:v,fadeOutDuration:Z,enableFadeIn:E,enableFadeOut:O,enableLoopStart:R,enableLoopEnd:h,enableHighpass:c,enableLowpass:g,enableGain:s,enablePan:r,enableDetune:t,enablePlaybackRate:p,enableLoopCrossfade:b}}function b0(V,A){return o(V)/A}function n(V,A){let F=b0(V,A);if(F<=0){V.loopStart=0,V.loopEnd=0;return}if(!Number.isFinite(V.loopStart)||V.loopStart<0)V.loopStart=0;if(V.loopStart>=F)V.loopStart=0;if(!Number.isFinite(V.loopEnd)||V.loopEnd<=V.loopStart||V.loopEnd>F)V.loopEnd=F}function e(V,A,F){if(A===void 0)return V.offset=0,0;if(A<0)return e(V,o(V)+A,F);if(A>(o(V)||1)-1)return e(V,o(V)%A,F);let T=Math.floor(A*F);return V.offset=T,T}function L0(V){let{playhead:A,bufferLength:F,loop:T,loopStartSamples:Q,loopEndSamples:J}=V,U=128;if(!T&&A+128>F)U=Math.max(F-A,0);let Y=Array(U);if(!T){for(let $=0,j=A;$<U;$++,j++)Y[$]=j;let H=A+U;return{playhead:H,indexes:Y,looped:!1,ended:H>=F}}let X=A,k=!1;for(let H=0;H<U;H++,X++){if(X>=J)X=Q+(X-J),k=!0;Y[H]=X}return{indexes:Y,looped:k,ended:!1,playhead:X}}function x0(V){let{playhead:A,bufferLength:F,loop:T,loopStartSamples:Q,loopEndSamples:J,playbackRates:U}=V,Y=128;if(!T&&A+128>F)Y=Math.max(F-A,0);let X=Array(Y),k=A,H=!1;if(T){for(let $=0;$<Y;$++){X[$]=Math.min(Math.max(Math.floor(k),0),F-1);let j=U[$]??U[0]??1;if(k+=j,j>=0&&(k>J||k>F))k=Q,H=!0;else if(j<0&&(k<Q||k<0))k=J,H=!0}return{playhead:k,indexes:X,looped:H,ended:!1}}for(let $=0;$<Y;$++)X[$]=Math.min(Math.max(Math.floor(k),0),F-1),k+=U[$]??U[0]??1;return{playhead:k,indexes:X,looped:!1,ended:k>=F||k<0}}function m0(V,A,F){for(let T=0;T<F.length;T++)for(let Q=0;Q<V.length;Q++)V[Q][T]=A[Q][F[T]];for(let T=F.length;T<V[0].length;T++)for(let Q=0;Q<V.length;Q++)V[Q][T]=0}function d(V){for(let A=0;A<V.length;A++)for(let F=0;F<V[A].length;F++)V[A][F]=0}function S0(V){let A=new Float32Array(V[0].length);for(let F=0;F<V[0].length;F++)A[F]=V[0][F];V.push(A)}function H0(V,A){for(let F=A.length;F<V.length;F++)A[F]=new Float32Array(V[F].length);for(let F=0;F<V.length;F++)for(let T=0;T<V[F].length;T++)A[F][T]=V[F][T]}function c0(V){let A=0;for(let F=0;F<V.length;F++)for(let T=0;T<V[F].length;T++)if(Number.isNaN(V[F][T]))A++,V[F][T]=0;return A}function V0(){return[{x_1:0,x_2:0,y_1:0,y_2:0},{x_1:0,x_2:0,y_1:0,y_2:0}]}function g0(V,A){if(A.length===1){let T=A[0];if(T===1)return;for(let Q of V)for(let J=0;J<Q.length;J++)Q[J]*=T;return}let F=A[0];for(let T of V)for(let Q=0;Q<T.length;Q++)F=A[Q]??F,T[Q]*=F}function d0(V,A){let F=A[0];for(let T=0;T<V[0].length;T++){F=A[T]??F;let Q=F<=0?1:1-F,J=F>=0?1:1+F;V[0][T]*=Q,V[1][T]*=J}}function h0(V,A,F,T){for(let Q=0;Q<V.length;Q++){let J=V[Q],{x_1:U,x_2:Y,y_1:X,y_2:k}=T[Q]??{x_1:0,x_2:0,y_1:0,y_2:0};if(A.length===1){let H=A[0];if(H>=20000)return;let $=2*Math.PI*H/F,j=Math.sin($)/2,P=(1-Math.cos($))/2,C=1-Math.cos($),N=(1-Math.cos($))/2,K=1+j,w=-2*Math.cos($),v=1-j,Z=P/K,E=C/K,O=N/K,R=w/K,h=v/K;for(let b=0;b<J.length;b++){let c=J[b],g=Z*c+E*U+O*Y-R*X-h*k;Y=U,U=c,k=X,X=g,J[b]=g}}else{let H=A[0];for(let $=0;$<J.length;$++){let j=A[$]??H,P=2*Math.PI*j/F,C=Math.sin(P)/2,N=(1-Math.cos(P))/2,K=1-Math.cos(P),w=(1-Math.cos(P))/2,v=1+C,Z=-2*Math.cos(P),E=1-C,O=J[$],R=N/v*O+K/v*U+w/v*Y-Z/v*X-E/v*k;Y=U,U=O,k=X,X=R,J[$]=R}}T[Q]={x_1:U,x_2:Y,y_1:X,y_2:k}}}function l0(V,A,F,T){for(let Q=0;Q<V.length;Q++){let J=V[Q],{x_1:U,x_2:Y,y_1:X,y_2:k}=T[Q]??{x_1:0,x_2:0,y_1:0,y_2:0};if(A.length===1){let H=A[0];if(H<=20)return;let $=2*Math.PI*H/F,j=Math.sin($)/2,P=(1+Math.cos($))/2,C=-(1+Math.cos($)),N=(1+Math.cos($))/2,K=1+j,w=-2*Math.cos($),v=1-j;for(let Z=0;Z<J.length;Z++){let E=J[Z],O=P/K*E+C/K*U+N/K*Y-w/K*X-v/K*k;Y=U,U=E,k=X,X=O,J[Z]=O}}else{let H=A[0];for(let $=0;$<J.length;$++){let j=A[$]??H,P=2*Math.PI*j/F,C=Math.sin(P)/2,N=(1+Math.cos(P))/2,K=-(1+Math.cos(P)),w=(1+Math.cos(P))/2,v=1+C,Z=-2*Math.cos(P),E=1-C,O=J[$],R=N/v*O+K/v*U+w/v*Y-Z/v*X-E/v*k;Y=U,U=O,k=X,X=R,J[$]=R}}T[Q]={x_1:U,x_2:Y,y_1:X,y_2:k}}}function z0(V,A,F,T){let{type:Q,data:J}=A;switch(Q){case"buffer":return y0(V,J),n(V,T),[];case"bufferInit":{let U=J;return V.buffer=G0(U.channels,U.totalLength),V.streamBuffer={...i(),totalLength:U.totalLength,streamEnded:!1,streaming:U.streaming??!0},n(V,T),[]}case"bufferRange":return V.streamBuffer.pendingWrites.push(J),[];case"bufferEnd":{let U=J;if(U?.totalLength!=null)V.streamBuffer.totalLength=U.totalLength;return V.streamBuffer.streamEnded=!0,[]}case"bufferReset":return V.buffer=[],V.streamBuffer=i(),n(V,T),[];case"start":V.timesLooped=0;{let U=J;if(V.duration=U?.duration??-1,V.duration===-1)V.duration=V.loop?Number.MAX_SAFE_INTEGER:(V.buffer[0]?.length??0)/T;e(V,U?.offset,T),n(V,T),V.playhead=V.offset,V.startWhen=U?.when??F,V.stopWhen=V.startWhen+V.duration,V.playedSamples=0,V.state=z.Scheduled}return[{type:"scheduled"}];case"stop":if(V.state===z.Ended||V.state===z.Initial)return[];return V.stopWhen=J??V.stopWhen,V.state=z.Stopped,[{type:"stopped"}];case"pause":return V.state=z.Paused,V.pauseWhen=J??F,[{type:"paused"}];case"resume":return V.state=z.Started,V.startWhen=J??F,[{type:"resume"}];case"dispose":return V.state=z.Disposed,V.buffer=[],V.streamBuffer=i(),[{type:"disposed"}];case"loop":{let U=J,Y=V.state;if(U&&(Y===z.Scheduled||Y===z.Started))V.stopWhen=Number.MAX_SAFE_INTEGER,V.duration=Number.MAX_SAFE_INTEGER;if(V.loop=U,U)n(V,T);return[]}case"loopStart":return V.loopStart=J,[];case"loopEnd":return V.loopEnd=J,[];case"loopCrossfade":return V.loopCrossfade=J,[];case"playhead":return V.playhead=Math.floor(J),[];case"fadeIn":return V.fadeInDuration=J,[];case"fadeOut":return V.fadeOutDuration=J,[];case"toggleGain":return V.enableGain=J??!V.enableGain,[];case"togglePan":return V.enablePan=J??!V.enablePan,[];case"toggleLowpass":return V.enableLowpass=J??!V.enableLowpass,[];case"toggleHighpass":return V.enableHighpass=J??!V.enableHighpass,[];case"toggleDetune":return V.enableDetune=J??!V.enableDetune,[];case"togglePlaybackRate":return V.enablePlaybackRate=J??!V.enablePlaybackRate,[];case"toggleFadeIn":return V.enableFadeIn=J??!V.enableFadeIn,[];case"toggleFadeOut":return V.enableFadeOut=J??!V.enableFadeOut,[];case"toggleLoopStart":return V.enableLoopStart=J??!V.enableLoopStart,[];case"toggleLoopEnd":return V.enableLoopEnd=J??!V.enableLoopEnd,[];case"toggleLoopCrossfade":return V.enableLoopCrossfade=J??!V.enableLoopCrossfade,[];case"logState":return[]}return[]}function j0(V,A,F,T,Q){let J=[],U=V.state;if(U===z.Disposed)return{keepAlive:!1,messages:J};if(_0(V),U===z.Initial)return{keepAlive:!0,messages:J};if(U===z.Ended)return d(A[0]),{keepAlive:!0,messages:J};if(U===z.Scheduled)if(T.currentTime>=V.startWhen)U=V.state=z.Started,J.push({type:"started"});else return d(A[0]),{keepAlive:!0,messages:J};else if(U===z.Paused){if(T.currentTime>V.pauseWhen)return d(A[0]),{keepAlive:!0,messages:J}}if(T.currentTime>V.stopWhen)return d(A[0]),V.state=z.Ended,J.push({type:"ended"}),V.playedSamples=0,{keepAlive:!0,messages:J};let Y=A[0],X=o(V);if(X===0)return d(Y),{keepAlive:!0,messages:J};let{playbackRate:k,detune:H,lowpass:$,highpass:j,gain:P,pan:C}=F,{buffer:N,loopStart:K,loopEnd:w,loopCrossfade:v,stopWhen:Z,playedSamples:E,enableLowpass:O,enableHighpass:R,enableGain:h,enablePan:b,enableDetune:c,enableFadeOut:g,enableFadeIn:s,enableLoopStart:r,enableLoopEnd:t,enableLoopCrossfade:p,playhead:D,fadeInDuration:A0,fadeOutDuration:F0}=V,K0=V.streamBuffer.streaming&&V.streamBuffer.committedLength<X,T0=V.loop&&!K0,l=Math.min(N.length,Y.length),W0=V.duration*T.sampleRate,Z0=Math.floor(T.sampleRate*v),q0=Math.max(X-y,0),L=r?Math.min(Math.floor(K*T.sampleRate),q0):0,x=t?Math.min(Math.floor(w*T.sampleRate),X):X,N0=x-L,J0=c&&H.length>0&&H[0]!==0,u=k;if(J0){let M=Math.max(k.length,H.length,y);u=new Float32Array(M);for(let W=0;W<M;W++){let I=k[W]??k[k.length-1],G=H[W]??H[H.length-1];u[W]=I*2**(G/1200)}}let Q0=V.enablePlaybackRate||J0,O0=Q0&&u.length>0&&u.every((M)=>M===0);if(V.streamBuffer.streaming&&!V.streamBuffer.streamEnded&&!V.streamBuffer.lowWaterNotified&&V.streamBuffer.committedLength-Math.floor(D)<V.streamBuffer.lowWaterThreshold)J.push({type:"bufferLowWater",data:{playhead:Math.floor(D),committedLength:V.streamBuffer.committedLength}}),V.streamBuffer.lowWaterNotified=!0;if(O0){d(Y);for(let M=1;M<A.length;M++)H0(Y,A[M]);return{keepAlive:!0,messages:J}}let U0={bufferLength:X,loop:T0,playhead:D,loopStartSamples:L,loopEndSamples:x,durationSamples:W0,playbackRates:u},{indexes:a,ended:X0,looped:Y0,playhead:$0}=Q0?x0(U0):L0(U0),f=a.find((M)=>M>=V.streamBuffer.committedLength&&M<X);if(f!==void 0&&!V.streamBuffer.streamEnded&&V.streamBuffer.lastUnderrunSample!==f)J.push({type:"bufferUnderrun",data:{playhead:Math.floor(D),committedLength:V.streamBuffer.committedLength,requestedSample:f}}),V.streamBuffer.lastUnderrunSample=f;else if(f===void 0)V.streamBuffer.lastUnderrunSample=null;m0(Y,N,a);let m=Math.min(Math.floor(v*T.sampleRate),N0),D0=T0&&D>L&&D<x,C0=p&&Z0>0&&X>y;if(D0&&C0){{let M=L+m;if(m>0&&D>L&&D<M){let W=D-L,I=Math.min(Math.floor(M-D),y);for(let G=0;G<I;G++){let B=(W+G)/m,S=Math.cos(Math.PI*B/2),q=Math.floor(x-m+W+G);if(q>=0&&q<X)for(let _=0;_<l;_++)Y[_][G]+=N[_][q]*S}}}{let M=x-m;if(m>0&&D>M&&D<x){let W=D-M,I=Math.min(Math.floor(x-D),y);for(let G=0;G<I;G++){let B=(W+G)/m,S=Math.sin(Math.PI*B/2),q=Math.floor(L+W+G);if(q>=0&&q<X)for(let _=0;_<l;_++)Y[_][G]+=N[_][q]*S}}}}if(s&&A0>0){let M=Math.floor(A0*T.sampleRate),W=M-E;if(W>0){let I=Math.min(W,y);for(let G=0;G<I;G++){let B=(E+G)/M,S=B*B*B;for(let q=0;q<l;q++)Y[q][G]*=S}}}if(g&&F0>0){let M=Math.floor(F0*T.sampleRate),W=Math.floor(T.sampleRate*(Z-T.currentTime));if(W<M+y)for(let I=0;I<y;I++){let G=W-I;if(G>=M)continue;let B=G<=0?0:G/M,S=B*B*B;for(let q=0;q<l;q++)Y[q][I]*=S}}if(O)h0(Y,$,T.sampleRate,Q.lowpass);if(R)l0(Y,j,T.sampleRate,Q.highpass);if(h)g0(Y,P);if(l===1)S0(Y);if(b)d0(Y,C);if(Y0)V.timesLooped++,J.push({type:"looped",data:V.timesLooped});if(X0)V.state=z.Ended,J.push({type:"ended"});V.playedSamples+=a.length,V.playhead=$0;let k0=c0(Y);if(k0>0)return console.log({numNans:k0,indexes:a,playhead:$0,ended:X0,looped:Y0,sourceLength:X}),{keepAlive:!0,messages:J};for(let M=1;M<A.length;M++)H0(Y,A[M]);return{keepAlive:!0,messages:J}}class P0 extends AudioWorkletProcessor{static get parameterDescriptors(){return[{name:"playbackRate",automationRate:"a-rate",defaultValue:1},{name:"detune",automationRate:"a-rate",defaultValue:0},{name:"gain",automationRate:"a-rate",defaultValue:1,minValue:0},{name:"pan",automationRate:"a-rate",defaultValue:0},{name:"highpass",automationRate:"a-rate",defaultValue:20,minValue:20,maxValue:20000},{name:"lowpass",automationRate:"a-rate",defaultValue:20000,minValue:20,maxValue:20000}]}properties;filterState={lowpass:V0(),highpass:V0()};lastFrameTime=0;constructor(V){super(V);this.properties=v0(V?.processorOptions,sampleRate),this.port.onmessage=(A)=>{let F=z0(this.properties,A.data,currentTime,sampleRate);for(let T of F)this.port.postMessage(T);if(this.properties.state===z.Disposed)this.port.close()}}process(V,A,F){try{let T=j0(this.properties,A,F,{currentTime,currentFrame,sampleRate},this.filterState);for(let J of T.messages)this.port.postMessage(J);let Q=currentTime-this.lastFrameTime;return this.lastFrameTime=currentTime,this.port.postMessage({type:"frame",data:[currentTime,currentFrame,Math.floor(this.properties.playhead),Q*1000]}),T.keepAlive}catch(T){return console.log(T),!0}}}registerProcessor("ClipProcessor",P0);
1
+ var z={Initial:0,Started:1,Stopped:2,Paused:3,Scheduled:4,Ended:5,Disposed:6};var y=128;function i(V=[]){let A=V[0]?.length??0,T=A>0;return{totalLength:T?A:null,committedLength:T?A:0,streamEnded:T,streaming:!1,writtenSpans:T?[{startSample:0,endSample:A}]:[],pendingWrites:[],lowWaterThreshold:y*4,lowWaterNotified:!1,lastUnderrunSample:null}}function M0(V){return V[0]?.length??0}function o(V){return V.streamBuffer.totalLength??M0(V.buffer)}function G0(V,A){return Array.from({length:V},()=>new Float32Array(A))}function E0(V,A){let T=[...V,A].sort((Q,F)=>Q.startSample-F.startSample),J=[];for(let Q of T){let F=J[J.length-1];if(!F||Q.startSample>F.endSample){J.push({...Q});continue}F.endSample=Math.max(F.endSample,Q.endSample)}return J}function I0(V){let A=0;for(let T of V){if(T.startSample>A)break;A=Math.max(A,T.endSample)}return A}function w0(V,A){if(V.committedLength-Math.floor(A)>=V.lowWaterThreshold)V.lowWaterNotified=!1}function R0(V,A,T){let J=M0(V.buffer),Q=V.buffer.length;if(J>=T&&Q>=A)return;let F=Math.max(J,T),U=Math.max(Q,A),Y=G0(U,F);for(let X=0;X<Q;X++)Y[X].set(V.buffer[X].subarray(0,J));if(V.buffer=Y,V.streamBuffer.totalLength==null||V.streamBuffer.totalLength<F)V.streamBuffer.totalLength=F}function B0(V,A){let T=Math.max(Math.floor(A.startSample),0),J=A.channelData[0]?.length??0,Q=A.totalLength??null,F=Math.max(T+J,Q??0);R0(V,Math.max(A.channelData.length,V.buffer.length,1),F);for(let U=0;U<A.channelData.length;U++)V.buffer[U].set(A.channelData[U],T);if(Q!=null)V.streamBuffer.totalLength=Q;if(J>0)V.streamBuffer.writtenSpans=E0(V.streamBuffer.writtenSpans,{startSample:T,endSample:T+J}),V.streamBuffer.committedLength=I0(V.streamBuffer.writtenSpans);if(A.streamEnded===!0)V.streamBuffer.streamEnded=!0;w0(V.streamBuffer,V.playhead)}function _0(V){if(V.streamBuffer.pendingWrites.length===0)return;for(let A of V.streamBuffer.pendingWrites)B0(V,A);V.streamBuffer.pendingWrites=[]}function y0(V,A){V.buffer=A,V.streamBuffer=i(A)}function v0(V={},A){let{buffer:T=[],streamBuffer:J=i(T),duration:Q=-1,loop:F=!1,loopStart:U=0,loopEnd:Y=(T[0]?.length??0)/A,loopCrossfade:X=0,playhead:k=0,offset:H=0,startWhen:$=0,stopWhen:j=0,pauseWhen:P=0,resumeWhen:C=0,playedSamples:N=0,state:K=z.Initial,timesLooped:w=0,fadeInDuration:v=0,fadeOutDuration:Z=0,enableFadeIn:E=v>0,enableFadeOut:O=Z>0,enableLoopStart:R=!0,enableLoopEnd:h=!0,enableLoopCrossfade:b=X>0,enableHighpass:c=!0,enableLowpass:g=!0,enableGain:s=!0,enablePan:r=!0,enableDetune:t=!0,enablePlaybackRate:p=!0}=V;return{buffer:T,streamBuffer:J,loop:F,loopStart:U,loopEnd:Y,loopCrossfade:X,duration:Q,playhead:k,offset:H,startWhen:$,stopWhen:j,pauseWhen:P,resumeWhen:C,playedSamples:N,state:K,timesLooped:w,fadeInDuration:v,fadeOutDuration:Z,enableFadeIn:E,enableFadeOut:O,enableLoopStart:R,enableLoopEnd:h,enableHighpass:c,enableLowpass:g,enableGain:s,enablePan:r,enableDetune:t,enablePlaybackRate:p,enableLoopCrossfade:b}}function b0(V,A){return o(V)/A}function n(V,A){let T=b0(V,A);if(T<=0){V.loopStart=0,V.loopEnd=0;return}if(!Number.isFinite(V.loopStart)||V.loopStart<0)V.loopStart=0;if(V.loopStart>=T)V.loopStart=0;if(!Number.isFinite(V.loopEnd)||V.loopEnd<=V.loopStart||V.loopEnd>T)V.loopEnd=T}function e(V,A,T){if(A===void 0)return V.offset=0,0;if(A<0)return e(V,o(V)+A,T);if(A>(o(V)||1)-1)return e(V,o(V)%A,T);let J=Math.floor(A*T);return V.offset=J,J}function L0(V){let{playhead:A,bufferLength:T,loop:J,loopStartSamples:Q,loopEndSamples:F}=V,U=128;if(!J&&A+128>T)U=Math.max(T-A,0);let Y=Array(U);if(!J){for(let $=0,j=A;$<U;$++,j++)Y[$]=j;let H=A+U;return{playhead:H,indexes:Y,looped:!1,ended:H>=T}}let X=A,k=!1;for(let H=0;H<U;H++,X++){if(X>=F)X=Q+(X-F),k=!0;Y[H]=X}return{indexes:Y,looped:k,ended:!1,playhead:X}}function x0(V){let{playhead:A,bufferLength:T,loop:J,loopStartSamples:Q,loopEndSamples:F,playbackRates:U}=V,Y=128;if(!J&&A+128>T)Y=Math.max(T-A,0);let X=Array(Y),k=A,H=!1;if(J){for(let $=0;$<Y;$++){X[$]=Math.min(Math.max(Math.floor(k),0),T-1);let j=U[$]??U[0]??1;if(k+=j,j>=0&&(k>F||k>T))k=Q,H=!0;else if(j<0&&(k<Q||k<0))k=F,H=!0}return{playhead:k,indexes:X,looped:H,ended:!1}}for(let $=0;$<Y;$++)X[$]=Math.min(Math.max(Math.floor(k),0),T-1),k+=U[$]??U[0]??1;return{playhead:k,indexes:X,looped:!1,ended:k>=T||k<0}}function m0(V,A,T){let J=Math.min(V.length,A.length);for(let Q=0;Q<T.length;Q++)for(let F=0;F<J;F++)V[F][Q]=A[F][T[Q]];for(let Q=J;Q<V.length;Q++)for(let F=0;F<V[Q].length;F++)V[Q][F]=0;for(let Q=T.length;Q<V[0].length;Q++)for(let F=0;F<J;F++)V[F][Q]=0}function d(V){for(let A=0;A<V.length;A++)for(let T=0;T<V[A].length;T++)V[A][T]=0}function S0(V){if(V.length>=2)for(let A=0;A<V[0].length;A++)V[1][A]=V[0][A];else{let A=new Float32Array(V[0].length);for(let T=0;T<V[0].length;T++)A[T]=V[0][T];V.push(A)}}function H0(V,A){for(let T=A.length;T<V.length;T++)A[T]=new Float32Array(V[T].length);for(let T=0;T<V.length;T++)for(let J=0;J<V[T].length;J++)A[T][J]=V[T][J]}function c0(V){let A=0;for(let T=0;T<V.length;T++)for(let J=0;J<V[T].length;J++)if(Number.isNaN(V[T][J]))A++,V[T][J]=0;return A}function V0(){return[{x_1:0,x_2:0,y_1:0,y_2:0},{x_1:0,x_2:0,y_1:0,y_2:0}]}function g0(V,A){if(A.length===1){let J=A[0];if(J===1)return;for(let Q of V)for(let F=0;F<Q.length;F++)Q[F]*=J;return}let T=A[0];for(let J of V)for(let Q=0;Q<J.length;Q++)T=A[Q]??T,J[Q]*=T}function d0(V,A){let T=A[0];for(let J=0;J<V[0].length;J++){T=A[J]??T;let Q=T<=0?1:1-T,F=T>=0?1:1+T;V[0][J]*=Q,V[1][J]*=F}}function h0(V,A,T,J){for(let Q=0;Q<V.length;Q++){let F=V[Q],{x_1:U,x_2:Y,y_1:X,y_2:k}=J[Q]??{x_1:0,x_2:0,y_1:0,y_2:0};if(A.length===1){let H=A[0];if(H>=20000)return;let $=2*Math.PI*H/T,j=Math.sin($)/2,P=(1-Math.cos($))/2,C=1-Math.cos($),N=(1-Math.cos($))/2,K=1+j,w=-2*Math.cos($),v=1-j,Z=P/K,E=C/K,O=N/K,R=w/K,h=v/K;for(let b=0;b<F.length;b++){let c=F[b],g=Z*c+E*U+O*Y-R*X-h*k;Y=U,U=c,k=X,X=g,F[b]=g}}else{let H=A[0];for(let $=0;$<F.length;$++){let j=A[$]??H,P=2*Math.PI*j/T,C=Math.sin(P)/2,N=(1-Math.cos(P))/2,K=1-Math.cos(P),w=(1-Math.cos(P))/2,v=1+C,Z=-2*Math.cos(P),E=1-C,O=F[$],R=N/v*O+K/v*U+w/v*Y-Z/v*X-E/v*k;Y=U,U=O,k=X,X=R,F[$]=R}}J[Q]={x_1:U,x_2:Y,y_1:X,y_2:k}}}function u0(V,A,T,J){for(let Q=0;Q<V.length;Q++){let F=V[Q],{x_1:U,x_2:Y,y_1:X,y_2:k}=J[Q]??{x_1:0,x_2:0,y_1:0,y_2:0};if(A.length===1){let H=A[0];if(H<=20)return;let $=2*Math.PI*H/T,j=Math.sin($)/2,P=(1+Math.cos($))/2,C=-(1+Math.cos($)),N=(1+Math.cos($))/2,K=1+j,w=-2*Math.cos($),v=1-j;for(let Z=0;Z<F.length;Z++){let E=F[Z],O=P/K*E+C/K*U+N/K*Y-w/K*X-v/K*k;Y=U,U=E,k=X,X=O,F[Z]=O}}else{let H=A[0];for(let $=0;$<F.length;$++){let j=A[$]??H,P=2*Math.PI*j/T,C=Math.sin(P)/2,N=(1+Math.cos(P))/2,K=-(1+Math.cos(P)),w=(1+Math.cos(P))/2,v=1+C,Z=-2*Math.cos(P),E=1-C,O=F[$],R=N/v*O+K/v*U+w/v*Y-Z/v*X-E/v*k;Y=U,U=O,k=X,X=R,F[$]=R}}J[Q]={x_1:U,x_2:Y,y_1:X,y_2:k}}}function z0(V,A,T,J){let{type:Q,data:F}=A;switch(Q){case"buffer":return y0(V,F),n(V,J),[];case"bufferInit":{let U=F;return V.buffer=G0(U.channels,U.totalLength),V.streamBuffer={...i(),totalLength:U.totalLength,streamEnded:!1,streaming:U.streaming??!0},n(V,J),[]}case"bufferRange":return V.streamBuffer.pendingWrites.push(F),[];case"bufferEnd":{let U=F;if(U?.totalLength!=null)V.streamBuffer.totalLength=U.totalLength;return V.streamBuffer.streamEnded=!0,[]}case"bufferReset":return V.buffer=[],V.streamBuffer=i(),n(V,J),[];case"start":V.timesLooped=0;{let U=F;if(V.duration=U?.duration??-1,V.duration===-1)V.duration=V.loop?Number.MAX_SAFE_INTEGER:(V.buffer[0]?.length??0)/J;e(V,U?.offset,J),n(V,J),V.playhead=V.offset,V.startWhen=U?.when??T,V.stopWhen=V.startWhen+V.duration,V.playedSamples=0,V.state=z.Scheduled}return[{type:"scheduled"}];case"stop":if(V.state===z.Ended||V.state===z.Initial)return[];return V.stopWhen=F??V.stopWhen,V.state=z.Stopped,[{type:"stopped"}];case"pause":return V.state=z.Paused,V.pauseWhen=F??T,[{type:"paused"}];case"resume":return V.state=z.Started,V.startWhen=F??T,[{type:"resume"}];case"dispose":return V.state=z.Disposed,V.buffer=[],V.streamBuffer=i(),[{type:"disposed"}];case"loop":{let U=F,Y=V.state;if(U&&(Y===z.Scheduled||Y===z.Started))V.stopWhen=Number.MAX_SAFE_INTEGER,V.duration=Number.MAX_SAFE_INTEGER;if(V.loop=U,U)n(V,J);return[]}case"loopStart":return V.loopStart=F,[];case"loopEnd":return V.loopEnd=F,[];case"loopCrossfade":return V.loopCrossfade=F,[];case"playhead":return V.playhead=Math.floor(F),[];case"fadeIn":return V.fadeInDuration=F,[];case"fadeOut":return V.fadeOutDuration=F,[];case"toggleGain":return V.enableGain=F??!V.enableGain,[];case"togglePan":return V.enablePan=F??!V.enablePan,[];case"toggleLowpass":return V.enableLowpass=F??!V.enableLowpass,[];case"toggleHighpass":return V.enableHighpass=F??!V.enableHighpass,[];case"toggleDetune":return V.enableDetune=F??!V.enableDetune,[];case"togglePlaybackRate":return V.enablePlaybackRate=F??!V.enablePlaybackRate,[];case"toggleFadeIn":return V.enableFadeIn=F??!V.enableFadeIn,[];case"toggleFadeOut":return V.enableFadeOut=F??!V.enableFadeOut,[];case"toggleLoopStart":return V.enableLoopStart=F??!V.enableLoopStart,[];case"toggleLoopEnd":return V.enableLoopEnd=F??!V.enableLoopEnd,[];case"toggleLoopCrossfade":return V.enableLoopCrossfade=F??!V.enableLoopCrossfade,[];case"logState":return[]}return[]}function j0(V,A,T,J,Q){let F=[],U=V.state;if(U===z.Disposed)return{keepAlive:!1,messages:F};if(_0(V),U===z.Initial)return{keepAlive:!0,messages:F};if(U===z.Ended)return d(A[0]),{keepAlive:!0,messages:F};if(U===z.Scheduled)if(J.currentTime>=V.startWhen)U=V.state=z.Started,F.push({type:"started"});else return d(A[0]),{keepAlive:!0,messages:F};else if(U===z.Paused){if(J.currentTime>V.pauseWhen)return d(A[0]),{keepAlive:!0,messages:F}}if(J.currentTime>V.stopWhen)return d(A[0]),V.state=z.Ended,F.push({type:"ended"}),V.playedSamples=0,{keepAlive:!0,messages:F};let Y=A[0],X=o(V);if(X===0)return d(Y),{keepAlive:!0,messages:F};let{playbackRate:k,detune:H,lowpass:$,highpass:j,gain:P,pan:C}=T,{buffer:N,loopStart:K,loopEnd:w,loopCrossfade:v,stopWhen:Z,playedSamples:E,enableLowpass:O,enableHighpass:R,enableGain:h,enablePan:b,enableDetune:c,enableFadeOut:g,enableFadeIn:s,enableLoopStart:r,enableLoopEnd:t,enableLoopCrossfade:p,playhead:D,fadeInDuration:A0,fadeOutDuration:F0}=V,K0=V.streamBuffer.streaming&&V.streamBuffer.committedLength<X,T0=V.loop&&!K0,u=Math.min(N.length,Y.length),W0=V.duration*J.sampleRate,Z0=Math.floor(J.sampleRate*v),q0=Math.max(X-y,0),L=r?Math.min(Math.floor(K*J.sampleRate),q0):0,x=t?Math.min(Math.floor(w*J.sampleRate),X):X,N0=x-L,J0=c&&H.length>0&&H[0]!==0,l=k;if(J0){let M=Math.max(k.length,H.length,y);l=new Float32Array(M);for(let W=0;W<M;W++){let I=k[W]??k[k.length-1],G=H[W]??H[H.length-1];l[W]=I*2**(G/1200)}}let Q0=V.enablePlaybackRate||J0,O0=Q0&&l.length>0&&l.every((M)=>M===0);if(V.streamBuffer.streaming&&!V.streamBuffer.streamEnded&&!V.streamBuffer.lowWaterNotified&&V.streamBuffer.committedLength-Math.floor(D)<V.streamBuffer.lowWaterThreshold)F.push({type:"bufferLowWater",data:{playhead:Math.floor(D),committedLength:V.streamBuffer.committedLength}}),V.streamBuffer.lowWaterNotified=!0;if(O0){d(Y);for(let M=1;M<A.length;M++)H0(Y,A[M]);return{keepAlive:!0,messages:F}}let U0={bufferLength:X,loop:T0,playhead:D,loopStartSamples:L,loopEndSamples:x,durationSamples:W0,playbackRates:l},{indexes:a,ended:X0,looped:Y0,playhead:$0}=Q0?x0(U0):L0(U0),f=a.find((M)=>M>=V.streamBuffer.committedLength&&M<X);if(f!==void 0&&!V.streamBuffer.streamEnded&&V.streamBuffer.lastUnderrunSample!==f)F.push({type:"bufferUnderrun",data:{playhead:Math.floor(D),committedLength:V.streamBuffer.committedLength,requestedSample:f}}),V.streamBuffer.lastUnderrunSample=f;else if(f===void 0)V.streamBuffer.lastUnderrunSample=null;m0(Y,N,a);let m=Math.min(Math.floor(v*J.sampleRate),N0),D0=T0&&D>L&&D<x,C0=p&&Z0>0&&X>y;if(D0&&C0){{let M=L+m;if(m>0&&D>L&&D<M){let W=D-L,I=Math.min(Math.floor(M-D),y);for(let G=0;G<I;G++){let B=(W+G)/m,S=Math.cos(Math.PI*B/2),q=Math.floor(x-m+W+G);if(q>=0&&q<X)for(let _=0;_<u;_++)Y[_][G]+=N[_][q]*S}}}{let M=x-m;if(m>0&&D>M&&D<x){let W=D-M,I=Math.min(Math.floor(x-D),y);for(let G=0;G<I;G++){let B=(W+G)/m,S=Math.sin(Math.PI*B/2),q=Math.floor(L+W+G);if(q>=0&&q<X)for(let _=0;_<u;_++)Y[_][G]+=N[_][q]*S}}}}if(s&&A0>0){let M=Math.floor(A0*J.sampleRate),W=M-E;if(W>0){let I=Math.min(W,y);for(let G=0;G<I;G++){let B=(E+G)/M,S=B*B*B;for(let q=0;q<u;q++)Y[q][G]*=S}}}if(g&&F0>0){let M=Math.floor(F0*J.sampleRate),W=Math.floor(J.sampleRate*(Z-J.currentTime));if(W<M+y)for(let I=0;I<y;I++){let G=W-I;if(G>=M)continue;let B=G<=0?0:G/M,S=B*B*B;for(let q=0;q<u;q++)Y[q][I]*=S}}if(O)h0(Y,$,J.sampleRate,Q.lowpass);if(R)u0(Y,j,J.sampleRate,Q.highpass);if(h)g0(Y,P);if(u===1)S0(Y);if(b)d0(Y,C);if(Y0)V.timesLooped++,F.push({type:"looped",data:V.timesLooped});if(X0)V.state=z.Ended,F.push({type:"ended"});V.playedSamples+=a.length,V.playhead=$0;let k0=c0(Y);if(k0>0)return console.log({numNans:k0,indexes:a,playhead:$0,ended:X0,looped:Y0,sourceLength:X}),{keepAlive:!0,messages:F};for(let M=1;M<A.length;M++)H0(Y,A[M]);return{keepAlive:!0,messages:F}}class P0 extends AudioWorkletProcessor{static get parameterDescriptors(){return[{name:"playbackRate",automationRate:"a-rate",defaultValue:1},{name:"detune",automationRate:"a-rate",defaultValue:0},{name:"gain",automationRate:"a-rate",defaultValue:1,minValue:0},{name:"pan",automationRate:"a-rate",defaultValue:0},{name:"highpass",automationRate:"a-rate",defaultValue:20,minValue:20,maxValue:20000},{name:"lowpass",automationRate:"a-rate",defaultValue:20000,minValue:20,maxValue:20000}]}properties;filterState={lowpass:V0(),highpass:V0()};lastFrameTime=0;constructor(V){super(V);this.properties=v0(V?.processorOptions,sampleRate),this.port.onmessage=(A)=>{let T=z0(this.properties,A.data,currentTime,sampleRate);for(let J of T)this.port.postMessage(J);if(this.properties.state===z.Disposed)this.port.close()}}process(V,A,T){try{let J=j0(this.properties,A,T,{currentTime,currentFrame,sampleRate},this.filterState);for(let F of J.messages)this.port.postMessage(F);let Q=currentTime-this.lastFrameTime;return this.lastFrameTime=currentTime,this.port.postMessage({type:"frame",data:[currentTime,currentFrame,Math.floor(this.properties.playhead),Q*1000]}),J.keepAlive}catch(J){return console.log(J),!0}}}registerProcessor("ClipProcessor",P0);
2
2
 
3
- //# debugId=5101232AAE128B1064756E2164756E21
3
+ //# debugId=E1A630180247A19C64756E2164756E21
4
4
  //# sourceMappingURL=processor.js.map
@@ -3,10 +3,10 @@
3
3
  "sources": ["../src/audio/types.ts", "../src/audio/processor-kernel.ts", "../src/audio/processor.ts"],
4
4
  "sourcesContent": [
5
5
  "export const State = {\n\tInitial: 0,\n\tStarted: 1,\n\tStopped: 2,\n\tPaused: 3,\n\tScheduled: 4,\n\tEnded: 5,\n\tDisposed: 6,\n} as const;\n\nexport type ClipProcessorState = (typeof State)[keyof typeof State];\n\nexport interface ClipProcessorOptions {\n\tbuffer?: Float32Array[];\n\tstreamBuffer?: StreamBufferState;\n\tloop?: boolean;\n\tloopStart?: number;\n\tloopEnd?: number;\n\tloopCrossfade?: number;\n\toffset?: number;\n\tduration?: number;\n\tplayhead?: number;\n\tstate?: ClipProcessorState;\n\tstartWhen?: number;\n\tstopWhen?: number;\n\tpauseWhen?: number;\n\tresumeWhen?: number;\n\tplayedSamples?: number;\n\ttimesLooped?: number;\n\tfadeInDuration?: number;\n\tfadeOutDuration?: number;\n\tenableFadeIn?: boolean;\n\tenableFadeOut?: boolean;\n\tenableLoopStart?: boolean;\n\tenableLoopEnd?: boolean;\n\tenableLoopCrossfade?: boolean;\n\tenableGain?: boolean;\n\tenablePan?: boolean;\n\tenableHighpass?: boolean;\n\tenableLowpass?: boolean;\n\tenableDetune?: boolean;\n\tenablePlaybackRate?: boolean;\n}\n\nexport interface ClipWorkletOptions extends AudioWorkletNodeOptions {\n\tprocessorOptions?: ClipProcessorOptions;\n}\n\nexport type ClipNodeState =\n\t| \"initial\"\n\t| \"scheduled\"\n\t| \"started\"\n\t| \"stopped\"\n\t| \"paused\"\n\t| \"resumed\"\n\t| \"ended\"\n\t| \"disposed\";\n\nexport type FrameData = readonly [\n\tcurrentTime: number,\n\tcurrentFrame: number,\n\tplayhead: number,\n\ttimeTaken: number,\n];\n\nexport type ClipProcessorToggleMessageType =\n\t| \"toggleFadeIn\"\n\t| \"toggleFadeOut\"\n\t| \"toggleLoopStart\"\n\t| \"toggleLoopEnd\"\n\t| \"toggleLoopCrossfade\"\n\t| \"toggleGain\"\n\t| \"togglePan\"\n\t| \"toggleHighpass\"\n\t| \"toggleLowpass\"\n\t| \"toggleDetune\"\n\t| \"togglePlaybackRate\";\n\n// ---------------------------------------------------------------------------\n// Processor message types (moved from processor.ts)\n// ---------------------------------------------------------------------------\n\nexport interface ClipProcessorOnmessageEvent {\n\treadonly data: ClipProcessorMessageRx;\n}\n\nexport type ClipProcessorOnmessage = (ev: ClipProcessorOnmessageEvent) => void;\n\nexport interface ProcessorWorkletOptions extends AudioWorkletNodeOptions {\n\treadonly processorOptions?: ClipProcessorOptions;\n}\n\nexport interface ClipProcessorStateMap {\n\treadonly Initial: 0;\n\treadonly Started: 1;\n\treadonly Stopped: 2;\n\treadonly Paused: 3;\n\treadonly Scheduled: 4;\n\treadonly Ended: 5;\n\treadonly Disposed: 6;\n}\n\nexport type ClipProcessorMessageRx =\n\t| ClipProcessorBufferMessageRx\n\t| ClipProcessorBufferInitMessageRx\n\t| ClipProcessorBufferRangeMessageRx\n\t| ClipProcessorBufferEndMessageRx\n\t| ClipProcessorBufferResetMessageRx\n\t| ClipProcessorStartMessageRx\n\t| ClipProcessorStopMessageRx\n\t| ClipProcessorPauseMessageRx\n\t| ClipProcessorResumeMessageRx\n\t| ClipProcessorDisposeMessageRx\n\t| ClipProcessorLoopMessageRx\n\t| ClipProcessorLoopStartMessageRx\n\t| ClipProcessorLoopEndMessageRx\n\t| ClipProcessorPlayheadMessageRx\n\t| ClipProcessorFadeInMessageRx\n\t| ClipProcessorFadeOutMessageRx\n\t| ClipProcessorLoopCrossfadeMessageRx\n\t| ClipProcessorToggleMessageRx\n\t| ClipProcessorLogStateMessageRx;\n\nexport type ClipProcessorMessageType =\n\t| \"buffer\"\n\t| \"bufferInit\"\n\t| \"bufferRange\"\n\t| \"bufferEnd\"\n\t| \"bufferReset\"\n\t| \"start\"\n\t| \"stop\"\n\t| \"pause\"\n\t| \"resume\"\n\t| \"dispose\"\n\t| \"loop\"\n\t| \"loopStart\"\n\t| \"loopEnd\"\n\t| \"playhead\"\n\t| \"playbackRate\"\n\t| \"offset\"\n\t| \"fadeIn\"\n\t| \"fadeOut\"\n\t| \"loopCrossfade\"\n\t| ClipProcessorToggleMessageType\n\t| \"logState\";\n\nexport interface ClipProcessorLogStateMessageRx {\n\treadonly type: \"logState\";\n\treadonly data?: never;\n}\n\nexport interface ClipProcessorToggleMessageRx {\n\treadonly type: ClipProcessorToggleMessageType;\n\treadonly data?: boolean;\n}\n\nexport interface ClipProcessorBufferMessageRx {\n\treadonly type: \"buffer\";\n\treadonly data: Float32Array[];\n}\n\nexport interface StreamBufferSpan {\n\tstartSample: number;\n\tendSample: number;\n}\n\nexport interface BufferRangeWrite {\n\treadonly startSample: number;\n\treadonly channelData: Float32Array[];\n\treadonly totalLength?: number | null;\n\treadonly streamEnded?: boolean;\n}\n\nexport interface StreamBufferState {\n\ttotalLength: number | null;\n\tcommittedLength: number;\n\tstreamEnded: boolean;\n\tstreaming: boolean;\n\twrittenSpans: StreamBufferSpan[];\n\tpendingWrites: BufferRangeWrite[];\n\tlowWaterThreshold: number;\n\tlowWaterNotified: boolean;\n\tlastUnderrunSample: number | null;\n}\n\nexport interface ClipProcessorBufferInitMessageRx {\n\treadonly type: \"bufferInit\";\n\treadonly data: {\n\t\treadonly channels: number;\n\t\treadonly totalLength: number;\n\t\treadonly streaming?: boolean;\n\t};\n}\n\nexport interface ClipProcessorBufferRangeMessageRx {\n\treadonly type: \"bufferRange\";\n\treadonly data: BufferRangeWrite;\n}\n\nexport interface ClipProcessorBufferEndMessageRx {\n\treadonly type: \"bufferEnd\";\n\treadonly data?: {\n\t\treadonly totalLength?: number;\n\t};\n}\n\nexport interface ClipProcessorBufferResetMessageRx {\n\treadonly type: \"bufferReset\";\n\treadonly data?: never;\n}\n\nexport interface ClipProcessorStartMessageRx {\n\treadonly type: \"start\";\n\treadonly data?: {\n\t\treadonly duration?: number;\n\t\treadonly offset?: number;\n\t\treadonly when?: number;\n\t};\n}\n\nexport interface ClipProcessorStopMessageRx {\n\treadonly type: \"stop\";\n\treadonly data?: number;\n}\n\nexport interface ClipProcessorPauseMessageRx {\n\treadonly type: \"pause\";\n\treadonly data?: number;\n}\n\nexport interface ClipProcessorResumeMessageRx {\n\treadonly type: \"resume\";\n\treadonly data?: number;\n}\n\nexport interface ClipProcessorDisposeMessageRx {\n\treadonly type: \"dispose\";\n\treadonly data?: never;\n}\n\nexport interface ClipProcessorLoopMessageRx {\n\treadonly type: \"loop\";\n\treadonly data: boolean;\n}\n\nexport interface ClipProcessorLoopStartMessageRx {\n\treadonly type: \"loopStart\";\n\treadonly data: number;\n}\n\nexport interface ClipProcessorLoopEndMessageRx {\n\treadonly type: \"loopEnd\";\n\treadonly data: number;\n}\n\nexport interface ClipProcessorPlayheadMessageRx {\n\treadonly type: \"playhead\";\n\treadonly data: number;\n}\n\nexport interface ClipProcessorFadeInMessageRx {\n\treadonly type: \"fadeIn\";\n\treadonly data: number;\n}\n\nexport interface ClipProcessorFadeOutMessageRx {\n\treadonly type: \"fadeOut\";\n\treadonly data: number;\n}\n\nexport interface ClipProcessorLoopCrossfadeMessageRx {\n\treadonly type: \"loopCrossfade\";\n\treadonly data: number;\n}\n\n// ---------------------------------------------------------------------------\n// Block parameters (used by kernel)\n// ---------------------------------------------------------------------------\n\nexport interface BlockParameters {\n\treadonly playhead: number;\n\treadonly durationSamples: number;\n\treadonly loop: boolean;\n\treadonly loopStartSamples: number;\n\treadonly loopEndSamples: number;\n\treadonly bufferLength: number;\n\treadonly playbackRates: Float32Array;\n}\n\nexport interface BlockReturnState {\n\treadonly playhead: number;\n\treadonly ended: boolean;\n\treadonly looped: boolean;\n\treadonly indexes: number[];\n}\n",
6
- "// processor-kernel.ts — Pure DSP logic, state machine, all filters\n// NO AudioWorklet or platform dependencies. Fully testable.\n\nimport {\n\ttype BlockParameters,\n\ttype BlockReturnState,\n\ttype BufferRangeWrite,\n\ttype ClipProcessorOptions,\n\tState,\n\ttype StreamBufferSpan,\n\ttype StreamBufferState,\n} from \"./types\";\n\n// ---------------------------------------------------------------------------\n// Constants\n// ---------------------------------------------------------------------------\n\nexport const SAMPLE_BLOCK_SIZE = 128;\n\nfunction createStreamBufferState(\n\tbuffer: Float32Array[] = [],\n): StreamBufferState {\n\tconst totalLength = buffer[0]?.length ?? 0;\n\tconst hasBuffer = totalLength > 0;\n\treturn {\n\t\ttotalLength: hasBuffer ? totalLength : null,\n\t\tcommittedLength: hasBuffer ? totalLength : 0,\n\t\tstreamEnded: hasBuffer,\n\t\tstreaming: false,\n\t\twrittenSpans: hasBuffer ? [{ startSample: 0, endSample: totalLength }] : [],\n\t\tpendingWrites: [],\n\t\tlowWaterThreshold: SAMPLE_BLOCK_SIZE * 4,\n\t\tlowWaterNotified: false,\n\t\tlastUnderrunSample: null,\n\t};\n}\n\nfunction getBufferLength(buffer: Float32Array[]): number {\n\treturn buffer[0]?.length ?? 0;\n}\n\nfunction getLogicalBufferLength(\n\tproperties: Required<ClipProcessorOptions>,\n): number {\n\treturn (\n\t\tproperties.streamBuffer.totalLength ?? getBufferLength(properties.buffer)\n\t);\n}\n\nfunction createSilentBuffer(channels: number, length: number): Float32Array[] {\n\treturn Array.from({ length: channels }, () => new Float32Array(length));\n}\n\nfunction mergeWrittenSpan(\n\tspans: StreamBufferSpan[],\n\tnextSpan: StreamBufferSpan,\n): StreamBufferSpan[] {\n\tconst merged = [...spans, nextSpan].sort(\n\t\t(a, b) => a.startSample - b.startSample,\n\t);\n\tconst result: StreamBufferSpan[] = [];\n\tfor (const span of merged) {\n\t\tconst previous = result[result.length - 1];\n\t\tif (!previous || span.startSample > previous.endSample) {\n\t\t\tresult.push({ ...span });\n\t\t\tcontinue;\n\t\t}\n\t\tprevious.endSample = Math.max(previous.endSample, span.endSample);\n\t}\n\treturn result;\n}\n\nfunction getCommittedLength(spans: StreamBufferSpan[]): number {\n\tlet committedLength = 0;\n\tfor (const span of spans) {\n\t\tif (span.startSample > committedLength) break;\n\t\tcommittedLength = Math.max(committedLength, span.endSample);\n\t}\n\treturn committedLength;\n}\n\nfunction resetLowWaterState(\n\tstreamBuffer: StreamBufferState,\n\tplayhead: number,\n): void {\n\tif (\n\t\tstreamBuffer.committedLength - Math.floor(playhead) >=\n\t\tstreamBuffer.lowWaterThreshold\n\t) {\n\t\tstreamBuffer.lowWaterNotified = false;\n\t}\n}\n\nfunction ensureBufferCapacity(\n\tproperties: Required<ClipProcessorOptions>,\n\trequiredChannels: number,\n\trequiredLength: number,\n): void {\n\tconst currentLength = getBufferLength(properties.buffer);\n\tconst currentChannels = properties.buffer.length;\n\tif (currentLength >= requiredLength && currentChannels >= requiredChannels) {\n\t\treturn;\n\t}\n\n\tconst nextLength = Math.max(currentLength, requiredLength);\n\tconst nextChannels = Math.max(currentChannels, requiredChannels);\n\tconst nextBuffer = createSilentBuffer(nextChannels, nextLength);\n\tfor (let ch = 0; ch < currentChannels; ch++) {\n\t\tnextBuffer[ch].set(properties.buffer[ch].subarray(0, currentLength));\n\t}\n\tproperties.buffer = nextBuffer;\n\tif (\n\t\tproperties.streamBuffer.totalLength == null ||\n\t\tproperties.streamBuffer.totalLength < nextLength\n\t) {\n\t\tproperties.streamBuffer.totalLength = nextLength;\n\t}\n}\n\nfunction applyBufferRangeWrite(\n\tproperties: Required<ClipProcessorOptions>,\n\twrite: BufferRangeWrite,\n): void {\n\tconst startSample = Math.max(Math.floor(write.startSample), 0);\n\tconst writeLength = write.channelData[0]?.length ?? 0;\n\tconst requestedTotalLength = write.totalLength ?? null;\n\tconst requiredLength = Math.max(\n\t\tstartSample + writeLength,\n\t\trequestedTotalLength ?? 0,\n\t);\n\tensureBufferCapacity(\n\t\tproperties,\n\t\tMath.max(write.channelData.length, properties.buffer.length, 1),\n\t\trequiredLength,\n\t);\n\n\tfor (let ch = 0; ch < write.channelData.length; ch++) {\n\t\tproperties.buffer[ch].set(write.channelData[ch], startSample);\n\t}\n\n\tif (requestedTotalLength != null) {\n\t\tproperties.streamBuffer.totalLength = requestedTotalLength;\n\t}\n\tif (writeLength > 0) {\n\t\tproperties.streamBuffer.writtenSpans = mergeWrittenSpan(\n\t\t\tproperties.streamBuffer.writtenSpans,\n\t\t\t{ startSample, endSample: startSample + writeLength },\n\t\t);\n\t\tproperties.streamBuffer.committedLength = getCommittedLength(\n\t\t\tproperties.streamBuffer.writtenSpans,\n\t\t);\n\t}\n\tif (write.streamEnded === true) {\n\t\tproperties.streamBuffer.streamEnded = true;\n\t}\n\tresetLowWaterState(properties.streamBuffer, properties.playhead);\n}\n\nfunction applyPendingBufferWrites(\n\tproperties: Required<ClipProcessorOptions>,\n): void {\n\tif (properties.streamBuffer.pendingWrites.length === 0) {\n\t\treturn;\n\t}\n\tfor (const write of properties.streamBuffer.pendingWrites) {\n\t\tapplyBufferRangeWrite(properties, write);\n\t}\n\tproperties.streamBuffer.pendingWrites = [];\n}\n\nfunction setWholeBuffer(\n\tproperties: Required<ClipProcessorOptions>,\n\tbuffer: Float32Array[],\n): void {\n\tproperties.buffer = buffer;\n\tproperties.streamBuffer = createStreamBufferState(buffer);\n}\n\n// ---------------------------------------------------------------------------\n// Properties & offset\n// ---------------------------------------------------------------------------\n\nexport function getProperties(\n\topts: ClipProcessorOptions = {},\n\tsampleRate: number,\n): Required<ClipProcessorOptions> {\n\tconst {\n\t\tbuffer = [],\n\t\tstreamBuffer = createStreamBufferState(buffer),\n\t\tduration = -1,\n\t\tloop = false,\n\t\tloopStart = 0,\n\t\tloopEnd = (buffer[0]?.length ?? 0) / sampleRate,\n\t\tloopCrossfade = 0,\n\t\tplayhead = 0,\n\t\toffset = 0,\n\t\tstartWhen = 0,\n\t\tstopWhen = 0,\n\t\tpauseWhen = 0,\n\t\tresumeWhen = 0,\n\t\tplayedSamples = 0,\n\t\tstate = State.Initial,\n\t\ttimesLooped = 0,\n\t\tfadeInDuration = 0,\n\t\tfadeOutDuration = 0,\n\t\tenableFadeIn = fadeInDuration > 0,\n\t\tenableFadeOut = fadeOutDuration > 0,\n\t\tenableLoopStart = true,\n\t\tenableLoopEnd = true,\n\t\tenableLoopCrossfade = loopCrossfade > 0,\n\t\tenableHighpass = true,\n\t\tenableLowpass = true,\n\t\tenableGain = true,\n\t\tenablePan = true,\n\t\tenableDetune = true,\n\t\tenablePlaybackRate = true,\n\t} = opts;\n\n\treturn {\n\t\tbuffer,\n\t\tstreamBuffer,\n\t\tloop,\n\t\tloopStart,\n\t\tloopEnd,\n\t\tloopCrossfade,\n\t\tduration,\n\t\tplayhead,\n\t\toffset,\n\t\tstartWhen,\n\t\tstopWhen,\n\t\tpauseWhen,\n\t\tresumeWhen,\n\t\tplayedSamples,\n\t\tstate,\n\t\ttimesLooped,\n\t\tfadeInDuration,\n\t\tfadeOutDuration,\n\t\tenableFadeIn,\n\t\tenableFadeOut,\n\t\tenableLoopStart,\n\t\tenableLoopEnd,\n\t\tenableHighpass,\n\t\tenableLowpass,\n\t\tenableGain,\n\t\tenablePan,\n\t\tenableDetune,\n\t\tenablePlaybackRate,\n\t\tenableLoopCrossfade,\n\t};\n}\n\nfunction getBufferDurationSeconds(\n\tproperties: Required<ClipProcessorOptions>,\n\tsampleRate: number,\n): number {\n\treturn getLogicalBufferLength(properties) / sampleRate;\n}\n\nfunction normalizeLoopBounds(\n\tproperties: Required<ClipProcessorOptions>,\n\tsampleRate: number,\n): void {\n\tconst bufferDuration = getBufferDurationSeconds(properties, sampleRate);\n\tif (bufferDuration <= 0) {\n\t\tproperties.loopStart = 0;\n\t\tproperties.loopEnd = 0;\n\t\treturn;\n\t}\n\n\tif (!Number.isFinite(properties.loopStart) || properties.loopStart < 0) {\n\t\tproperties.loopStart = 0;\n\t}\n\tif (properties.loopStart >= bufferDuration) {\n\t\tproperties.loopStart = 0;\n\t}\n\tif (\n\t\t!Number.isFinite(properties.loopEnd) ||\n\t\tproperties.loopEnd <= properties.loopStart ||\n\t\tproperties.loopEnd > bufferDuration\n\t) {\n\t\tproperties.loopEnd = bufferDuration;\n\t}\n}\n\nexport function setOffset(\n\tproperties: Required<ClipProcessorOptions>,\n\toffset: number | undefined,\n\tsampleRate: number,\n): number {\n\tif (offset === undefined) {\n\t\tproperties.offset = 0;\n\t\treturn 0;\n\t}\n\tif (offset < 0) {\n\t\treturn setOffset(\n\t\t\tproperties,\n\t\t\tgetLogicalBufferLength(properties) + offset,\n\t\t\tsampleRate,\n\t\t);\n\t}\n\tif (offset > (getLogicalBufferLength(properties) || 1) - 1) {\n\t\treturn setOffset(\n\t\t\tproperties,\n\t\t\tgetLogicalBufferLength(properties) % offset,\n\t\t\tsampleRate,\n\t\t);\n\t}\n\tconst offs = Math.floor(offset * sampleRate);\n\tproperties.offset = offs;\n\treturn offs;\n}\n\n// ---------------------------------------------------------------------------\n// Index calculation\n// ---------------------------------------------------------------------------\n\nexport function findIndexesNormal(p: BlockParameters): BlockReturnState {\n\tconst { playhead, bufferLength, loop, loopStartSamples, loopEndSamples } = p;\n\tlet length = 128;\n\tif (!loop && playhead + 128 > bufferLength) {\n\t\tlength = Math.max(bufferLength - playhead, 0);\n\t}\n\tconst indexes: number[] = new Array(length);\n\n\tif (!loop) {\n\t\tfor (let i = 0, head = playhead; i < length; i++, head++) {\n\t\t\tindexes[i] = head;\n\t\t}\n\t\tconst nextPlayhead = playhead + length;\n\t\treturn {\n\t\t\tplayhead: nextPlayhead,\n\t\t\tindexes,\n\t\t\tlooped: false,\n\t\t\tended: nextPlayhead >= bufferLength,\n\t\t};\n\t}\n\n\tlet head = playhead;\n\tlet looped = false;\n\tfor (let i = 0; i < length; i++, head++) {\n\t\tif (head >= loopEndSamples) {\n\t\t\thead = loopStartSamples + (head - loopEndSamples);\n\t\t\tlooped = true;\n\t\t}\n\t\tindexes[i] = head;\n\t}\n\treturn { indexes, looped, ended: false, playhead: head };\n}\n\nexport function findIndexesWithPlaybackRates(\n\tp: BlockParameters,\n): BlockReturnState {\n\tconst {\n\t\tplayhead,\n\t\tbufferLength,\n\t\tloop,\n\t\tloopStartSamples,\n\t\tloopEndSamples,\n\t\tplaybackRates,\n\t} = p;\n\tlet length = 128;\n\tif (!loop && playhead + 128 > bufferLength) {\n\t\tlength = Math.max(bufferLength - playhead, 0);\n\t}\n\tconst indexes: number[] = new Array(length);\n\tlet head = playhead;\n\tlet looped = false;\n\n\tif (loop) {\n\t\tfor (let i = 0; i < length; i++) {\n\t\t\tindexes[i] = Math.min(Math.max(Math.floor(head), 0), bufferLength - 1);\n\t\t\tconst rate = playbackRates[i] ?? playbackRates[0] ?? 1;\n\t\t\thead += rate;\n\t\t\tif (rate >= 0 && (head > loopEndSamples || head > bufferLength)) {\n\t\t\t\thead = loopStartSamples;\n\t\t\t\tlooped = true;\n\t\t\t} else if (rate < 0 && (head < loopStartSamples || head < 0)) {\n\t\t\t\thead = loopEndSamples;\n\t\t\t\tlooped = true;\n\t\t\t}\n\t\t}\n\t\treturn { playhead: head, indexes, looped, ended: false };\n\t}\n\n\tfor (let i = 0; i < length; i++) {\n\t\tindexes[i] = Math.min(Math.max(Math.floor(head), 0), bufferLength - 1);\n\t\thead += playbackRates[i] ?? playbackRates[0] ?? 1;\n\t}\n\treturn {\n\t\tplayhead: head,\n\t\tindexes,\n\t\tlooped: false,\n\t\tended: head >= bufferLength || head < 0,\n\t};\n}\n\n// ---------------------------------------------------------------------------\n// Buffer operations\n// ---------------------------------------------------------------------------\n\nexport function fill(\n\ttarget: Float32Array[],\n\tsource: Float32Array[],\n\tindexes: number[],\n): void {\n\tfor (let i = 0; i < indexes.length; i++) {\n\t\tfor (let ch = 0; ch < target.length; ch++) {\n\t\t\ttarget[ch][i] = source[ch][indexes[i]];\n\t\t}\n\t}\n\tfor (let i = indexes.length; i < target[0].length; i++) {\n\t\tfor (let ch = 0; ch < target.length; ch++) {\n\t\t\ttarget[ch][i] = 0;\n\t\t}\n\t}\n}\n\nexport function fillWithSilence(buffer: Float32Array[]): void {\n\tfor (let ch = 0; ch < buffer.length; ch++) {\n\t\tfor (let j = 0; j < buffer[ch].length; j++) {\n\t\t\tbuffer[ch][j] = 0;\n\t\t}\n\t}\n}\n\nexport function monoToStereo(signal: Float32Array[]): void {\n\tconst r = new Float32Array(signal[0].length);\n\tfor (let i = 0; i < signal[0].length; i++) {\n\t\tr[i] = signal[0][i];\n\t}\n\tsignal.push(r);\n}\n\nexport function copy(source: Float32Array[], target: Float32Array[]): void {\n\tfor (let i = target.length; i < source.length; i++) {\n\t\ttarget[i] = new Float32Array(source[i].length);\n\t}\n\tfor (let ch = 0; ch < source.length; ch++) {\n\t\tfor (let i = 0; i < source[ch].length; i++) {\n\t\t\ttarget[ch][i] = source[ch][i];\n\t\t}\n\t}\n}\n\nexport function checkNans(output: Float32Array[]): number {\n\tlet numNans = 0;\n\tfor (let ch = 0; ch < output.length; ch++) {\n\t\tfor (let j = 0; j < output[ch].length; j++) {\n\t\t\tif (Number.isNaN(output[ch][j])) {\n\t\t\t\tnumNans++;\n\t\t\t\toutput[ch][j] = 0;\n\t\t\t}\n\t\t}\n\t}\n\treturn numNans;\n}\n\n// ---------------------------------------------------------------------------\n// Filters\n// ---------------------------------------------------------------------------\n\nexport interface BiquadState {\n\tx_1: number;\n\tx_2: number;\n\ty_1: number;\n\ty_2: number;\n}\n\nexport function createFilterState(): BiquadState[] {\n\treturn [\n\t\t{ x_1: 0, x_2: 0, y_1: 0, y_2: 0 },\n\t\t{ x_1: 0, x_2: 0, y_1: 0, y_2: 0 },\n\t];\n}\n\nexport function gainFilter(arr: Float32Array[], gains: Float32Array): void {\n\tif (gains.length === 1) {\n\t\tconst g = gains[0];\n\t\tif (g === 1) return;\n\t\tfor (const ch of arr) {\n\t\t\tfor (let i = 0; i < ch.length; i++) ch[i] *= g;\n\t\t}\n\t\treturn;\n\t}\n\tlet g = gains[0];\n\tfor (const ch of arr) {\n\t\tfor (let i = 0; i < ch.length; i++) {\n\t\t\tg = gains[i] ?? g;\n\t\t\tch[i] *= g;\n\t\t}\n\t}\n}\n\nexport function panFilter(signal: Float32Array[], pans: Float32Array): void {\n\tlet pan = pans[0];\n\tfor (let i = 0; i < signal[0].length; i++) {\n\t\tpan = pans[i] ?? pan;\n\t\tconst leftGain = pan <= 0 ? 1 : 1 - pan;\n\t\tconst rightGain = pan >= 0 ? 1 : 1 + pan;\n\t\tsignal[0][i] *= leftGain;\n\t\tsignal[1][i] *= rightGain;\n\t}\n}\n\nexport function lowpassFilter(\n\tbuffer: Float32Array[],\n\tcutoffs: Float32Array,\n\tsampleRate: number,\n\tstates: BiquadState[],\n): void {\n\tfor (let channel = 0; channel < buffer.length; channel++) {\n\t\tconst arr = buffer[channel];\n\t\tlet { x_1, x_2, y_1, y_2 } = states[channel] ?? {\n\t\t\tx_1: 0,\n\t\t\tx_2: 0,\n\t\t\ty_1: 0,\n\t\t\ty_2: 0,\n\t\t};\n\t\tif (cutoffs.length === 1) {\n\t\t\tconst cutoff = cutoffs[0];\n\t\t\tif (cutoff >= 20000) return;\n\t\t\tconst w0 = (2 * Math.PI * cutoff) / sampleRate;\n\t\t\tconst alpha = Math.sin(w0) / 2;\n\t\t\tconst b0 = (1 - Math.cos(w0)) / 2;\n\t\t\tconst b1 = 1 - Math.cos(w0);\n\t\t\tconst b2 = (1 - Math.cos(w0)) / 2;\n\t\t\tconst a0 = 1 + alpha;\n\t\t\tconst a1 = -2 * Math.cos(w0);\n\t\t\tconst a2 = 1 - alpha;\n\t\t\tconst h0 = b0 / a0,\n\t\t\t\th1 = b1 / a0,\n\t\t\t\th2 = b2 / a0,\n\t\t\t\th3 = a1 / a0,\n\t\t\t\th4 = a2 / a0;\n\t\t\tfor (let i = 0; i < arr.length; i++) {\n\t\t\t\tconst x = arr[i];\n\t\t\t\tconst y = h0 * x + h1 * x_1 + h2 * x_2 - h3 * y_1 - h4 * y_2;\n\t\t\t\tx_2 = x_1;\n\t\t\t\tx_1 = x;\n\t\t\t\ty_2 = y_1;\n\t\t\t\ty_1 = y;\n\t\t\t\tarr[i] = y;\n\t\t\t}\n\t\t} else {\n\t\t\tconst prevCutoff = cutoffs[0];\n\t\t\tfor (let i = 0; i < arr.length; i++) {\n\t\t\t\tconst cutoff = cutoffs[i] ?? prevCutoff;\n\t\t\t\tconst w0 = (2 * Math.PI * cutoff) / sampleRate;\n\t\t\t\tconst alpha = Math.sin(w0) / 2;\n\t\t\t\tconst b0 = (1 - Math.cos(w0)) / 2;\n\t\t\t\tconst b1 = 1 - Math.cos(w0);\n\t\t\t\tconst b2 = (1 - Math.cos(w0)) / 2;\n\t\t\t\tconst a0 = 1 + alpha;\n\t\t\t\tconst a1 = -2 * Math.cos(w0);\n\t\t\t\tconst a2 = 1 - alpha;\n\t\t\t\tconst x = arr[i];\n\t\t\t\tconst y =\n\t\t\t\t\t(b0 / a0) * x +\n\t\t\t\t\t(b1 / a0) * x_1 +\n\t\t\t\t\t(b2 / a0) * x_2 -\n\t\t\t\t\t(a1 / a0) * y_1 -\n\t\t\t\t\t(a2 / a0) * y_2;\n\t\t\t\tx_2 = x_1;\n\t\t\t\tx_1 = x;\n\t\t\t\ty_2 = y_1;\n\t\t\t\ty_1 = y;\n\t\t\t\tarr[i] = y;\n\t\t\t}\n\t\t}\n\t\tstates[channel] = { x_1, x_2, y_1, y_2 };\n\t}\n}\n\nexport function highpassFilter(\n\tbuffer: Float32Array[],\n\tcutoffs: Float32Array,\n\tsampleRate: number,\n\tstates: BiquadState[],\n): void {\n\tfor (let channel = 0; channel < buffer.length; channel++) {\n\t\tconst arr = buffer[channel];\n\t\tlet { x_1, x_2, y_1, y_2 } = states[channel] ?? {\n\t\t\tx_1: 0,\n\t\t\tx_2: 0,\n\t\t\ty_1: 0,\n\t\t\ty_2: 0,\n\t\t};\n\t\tif (cutoffs.length === 1) {\n\t\t\tconst cutoff = cutoffs[0];\n\t\t\tif (cutoff <= 20) return;\n\t\t\tconst w0 = (2 * Math.PI * cutoff) / sampleRate;\n\t\t\tconst alpha = Math.sin(w0) / 2;\n\t\t\tconst b0 = (1 + Math.cos(w0)) / 2;\n\t\t\tconst b1 = -(1 + Math.cos(w0));\n\t\t\tconst b2 = (1 + Math.cos(w0)) / 2;\n\t\t\tconst a0 = 1 + alpha;\n\t\t\tconst a1 = -2 * Math.cos(w0);\n\t\t\tconst a2 = 1 - alpha;\n\t\t\tfor (let i = 0; i < arr.length; i++) {\n\t\t\t\tconst x = arr[i];\n\t\t\t\tconst y =\n\t\t\t\t\t(b0 / a0) * x +\n\t\t\t\t\t(b1 / a0) * x_1 +\n\t\t\t\t\t(b2 / a0) * x_2 -\n\t\t\t\t\t(a1 / a0) * y_1 -\n\t\t\t\t\t(a2 / a0) * y_2;\n\t\t\t\tx_2 = x_1;\n\t\t\t\tx_1 = x;\n\t\t\t\ty_2 = y_1;\n\t\t\t\ty_1 = y;\n\t\t\t\tarr[i] = y;\n\t\t\t}\n\t\t} else {\n\t\t\tconst prevCutoff = cutoffs[0];\n\t\t\tfor (let i = 0; i < arr.length; i++) {\n\t\t\t\tconst cutoff = cutoffs[i] ?? prevCutoff;\n\t\t\t\tconst w0 = (2 * Math.PI * cutoff) / sampleRate;\n\t\t\t\tconst alpha = Math.sin(w0) / 2;\n\t\t\t\tconst b0 = (1 + Math.cos(w0)) / 2;\n\t\t\t\tconst b1 = -(1 + Math.cos(w0));\n\t\t\t\tconst b2 = (1 + Math.cos(w0)) / 2;\n\t\t\t\tconst a0 = 1 + alpha;\n\t\t\t\tconst a1 = -2 * Math.cos(w0);\n\t\t\t\tconst a2 = 1 - alpha;\n\t\t\t\tconst x = arr[i];\n\t\t\t\tconst y =\n\t\t\t\t\t(b0 / a0) * x +\n\t\t\t\t\t(b1 / a0) * x_1 +\n\t\t\t\t\t(b2 / a0) * x_2 -\n\t\t\t\t\t(a1 / a0) * y_1 -\n\t\t\t\t\t(a2 / a0) * y_2;\n\t\t\t\tx_2 = x_1;\n\t\t\t\tx_1 = x;\n\t\t\t\ty_2 = y_1;\n\t\t\t\ty_1 = y;\n\t\t\t\tarr[i] = y;\n\t\t\t}\n\t\t}\n\t\tstates[channel] = { x_1, x_2, y_1, y_2 };\n\t}\n}\n\n// ---------------------------------------------------------------------------\n// Message handler\n// ---------------------------------------------------------------------------\n\nexport interface OutboundMessage {\n\ttype: string;\n\tdata?: unknown;\n}\n\nexport function handleProcessorMessage(\n\tproperties: Required<ClipProcessorOptions>,\n\tmessage: { type: string; data?: unknown },\n\tcurrentTime: number,\n\tsampleRate: number,\n): OutboundMessage[] {\n\tconst { type, data } = message;\n\tswitch (type) {\n\t\tcase \"buffer\":\n\t\t\tsetWholeBuffer(properties, data as Float32Array[]);\n\t\t\tnormalizeLoopBounds(properties, sampleRate);\n\t\t\treturn [];\n\t\tcase \"bufferInit\": {\n\t\t\tconst init = data as {\n\t\t\t\tchannels: number;\n\t\t\t\ttotalLength: number;\n\t\t\t\tstreaming?: boolean;\n\t\t\t};\n\t\t\tproperties.buffer = createSilentBuffer(init.channels, init.totalLength);\n\t\t\tproperties.streamBuffer = {\n\t\t\t\t...createStreamBufferState(),\n\t\t\t\ttotalLength: init.totalLength,\n\t\t\t\tstreamEnded: false,\n\t\t\t\tstreaming: init.streaming ?? true,\n\t\t\t};\n\t\t\tnormalizeLoopBounds(properties, sampleRate);\n\t\t\treturn [];\n\t\t}\n\t\tcase \"bufferRange\":\n\t\t\tproperties.streamBuffer.pendingWrites.push(data as BufferRangeWrite);\n\t\t\treturn [];\n\t\tcase \"bufferEnd\": {\n\t\t\tconst endData = data as { totalLength?: number } | undefined;\n\t\t\tif (endData?.totalLength != null) {\n\t\t\t\tproperties.streamBuffer.totalLength = endData.totalLength;\n\t\t\t}\n\t\t\tproperties.streamBuffer.streamEnded = true;\n\t\t\treturn [];\n\t\t}\n\t\tcase \"bufferReset\":\n\t\t\tproperties.buffer = [];\n\t\t\tproperties.streamBuffer = createStreamBufferState();\n\t\t\tnormalizeLoopBounds(properties, sampleRate);\n\t\t\treturn [];\n\t\tcase \"start\":\n\t\t\tproperties.timesLooped = 0;\n\t\t\t{\n\t\t\t\tconst d = data as\n\t\t\t\t\t| { duration?: number; offset?: number; when?: number }\n\t\t\t\t\t| undefined;\n\t\t\t\tproperties.duration = d?.duration ?? -1;\n\t\t\t\tif (properties.duration === -1) {\n\t\t\t\t\tproperties.duration = properties.loop\n\t\t\t\t\t\t? Number.MAX_SAFE_INTEGER\n\t\t\t\t\t\t: (properties.buffer[0]?.length ?? 0) / sampleRate;\n\t\t\t\t}\n\t\t\t\tsetOffset(properties, d?.offset, sampleRate);\n\t\t\t\tnormalizeLoopBounds(properties, sampleRate);\n\t\t\t\tproperties.playhead = properties.offset;\n\t\t\t\tproperties.startWhen = d?.when ?? currentTime;\n\t\t\t\tproperties.stopWhen = properties.startWhen + properties.duration;\n\t\t\t\tproperties.playedSamples = 0;\n\t\t\t\tproperties.state = State.Scheduled;\n\t\t\t}\n\t\t\treturn [{ type: \"scheduled\" }];\n\t\tcase \"stop\":\n\t\t\tif (\n\t\t\t\tproperties.state === State.Ended ||\n\t\t\t\tproperties.state === State.Initial\n\t\t\t)\n\t\t\t\treturn [];\n\t\t\tproperties.stopWhen = (data as number | undefined) ?? properties.stopWhen;\n\t\t\tproperties.state = State.Stopped;\n\t\t\treturn [{ type: \"stopped\" }];\n\t\tcase \"pause\":\n\t\t\tproperties.state = State.Paused;\n\t\t\tproperties.pauseWhen = (data as number | undefined) ?? currentTime;\n\t\t\treturn [{ type: \"paused\" }];\n\t\tcase \"resume\":\n\t\t\tproperties.state = State.Started;\n\t\t\tproperties.startWhen = (data as number | undefined) ?? currentTime;\n\t\t\treturn [{ type: \"resume\" }];\n\t\tcase \"dispose\":\n\t\t\tproperties.state = State.Disposed;\n\t\t\tproperties.buffer = [];\n\t\t\tproperties.streamBuffer = createStreamBufferState();\n\t\t\treturn [{ type: \"disposed\" }];\n\t\tcase \"loop\": {\n\t\t\tconst loop = data as boolean;\n\t\t\tconst st = properties.state;\n\t\t\tif (loop && (st === State.Scheduled || st === State.Started)) {\n\t\t\t\tproperties.stopWhen = Number.MAX_SAFE_INTEGER;\n\t\t\t\tproperties.duration = Number.MAX_SAFE_INTEGER;\n\t\t\t}\n\t\t\tproperties.loop = loop;\n\t\t\tif (loop) {\n\t\t\t\tnormalizeLoopBounds(properties, sampleRate);\n\t\t\t}\n\t\t\treturn [];\n\t\t}\n\t\tcase \"loopStart\":\n\t\t\tproperties.loopStart = data as number;\n\t\t\treturn [];\n\t\tcase \"loopEnd\":\n\t\t\tproperties.loopEnd = data as number;\n\t\t\treturn [];\n\t\tcase \"loopCrossfade\":\n\t\t\tproperties.loopCrossfade = data as number;\n\t\t\treturn [];\n\t\tcase \"playhead\":\n\t\t\tproperties.playhead = Math.floor(data as number);\n\t\t\treturn [];\n\t\tcase \"fadeIn\":\n\t\t\tproperties.fadeInDuration = data as number;\n\t\t\treturn [];\n\t\tcase \"fadeOut\":\n\t\t\tproperties.fadeOutDuration = data as number;\n\t\t\treturn [];\n\t\tcase \"toggleGain\":\n\t\t\tproperties.enableGain =\n\t\t\t\t(data as boolean | undefined) ?? !properties.enableGain;\n\t\t\treturn [];\n\t\tcase \"togglePan\":\n\t\t\tproperties.enablePan =\n\t\t\t\t(data as boolean | undefined) ?? !properties.enablePan;\n\t\t\treturn [];\n\t\tcase \"toggleLowpass\":\n\t\t\tproperties.enableLowpass =\n\t\t\t\t(data as boolean | undefined) ?? !properties.enableLowpass;\n\t\t\treturn [];\n\t\tcase \"toggleHighpass\":\n\t\t\tproperties.enableHighpass =\n\t\t\t\t(data as boolean | undefined) ?? !properties.enableHighpass;\n\t\t\treturn [];\n\t\tcase \"toggleDetune\":\n\t\t\tproperties.enableDetune =\n\t\t\t\t(data as boolean | undefined) ?? !properties.enableDetune;\n\t\t\treturn [];\n\t\tcase \"togglePlaybackRate\":\n\t\t\tproperties.enablePlaybackRate =\n\t\t\t\t(data as boolean | undefined) ?? !properties.enablePlaybackRate;\n\t\t\treturn [];\n\t\tcase \"toggleFadeIn\":\n\t\t\tproperties.enableFadeIn =\n\t\t\t\t(data as boolean | undefined) ?? !properties.enableFadeIn;\n\t\t\treturn [];\n\t\tcase \"toggleFadeOut\":\n\t\t\tproperties.enableFadeOut =\n\t\t\t\t(data as boolean | undefined) ?? !properties.enableFadeOut;\n\t\t\treturn [];\n\t\tcase \"toggleLoopStart\":\n\t\t\tproperties.enableLoopStart =\n\t\t\t\t(data as boolean | undefined) ?? !properties.enableLoopStart;\n\t\t\treturn [];\n\t\tcase \"toggleLoopEnd\":\n\t\t\tproperties.enableLoopEnd =\n\t\t\t\t(data as boolean | undefined) ?? !properties.enableLoopEnd;\n\t\t\treturn [];\n\t\tcase \"toggleLoopCrossfade\":\n\t\t\tproperties.enableLoopCrossfade =\n\t\t\t\t(data as boolean | undefined) ?? !properties.enableLoopCrossfade;\n\t\t\treturn [];\n\t\tcase \"logState\":\n\t\t\treturn [];\n\t}\n\treturn [];\n}\n\n// ---------------------------------------------------------------------------\n// Process block\n// ---------------------------------------------------------------------------\n\nexport interface ProcessContext {\n\tcurrentTime: number;\n\tcurrentFrame: number;\n\tsampleRate: number;\n}\n\nexport interface ProcessResult {\n\tkeepAlive: boolean;\n\tmessages: OutboundMessage[];\n}\n\nexport function processBlock(\n\tprops: Required<ClipProcessorOptions>,\n\toutputs: Float32Array[][],\n\tparameters: Record<string, Float32Array>,\n\tctx: ProcessContext,\n\tfilterState: { lowpass: BiquadState[]; highpass: BiquadState[] },\n): ProcessResult {\n\tconst messages: OutboundMessage[] = [];\n\tlet state = props.state;\n\tif (state === State.Disposed) return { keepAlive: false, messages };\n\n\tapplyPendingBufferWrites(props);\n\n\tif (state === State.Initial) return { keepAlive: true, messages };\n\n\tif (state === State.Ended) {\n\t\tfillWithSilence(outputs[0]);\n\t\treturn { keepAlive: true, messages };\n\t}\n\n\tif (state === State.Scheduled) {\n\t\tif (ctx.currentTime >= props.startWhen) {\n\t\t\tstate = props.state = State.Started;\n\t\t\tmessages.push({ type: \"started\" });\n\t\t} else {\n\t\t\tfillWithSilence(outputs[0]);\n\t\t\treturn { keepAlive: true, messages };\n\t\t}\n\t} else if (state === State.Paused) {\n\t\tif (ctx.currentTime > props.pauseWhen) {\n\t\t\tfillWithSilence(outputs[0]);\n\t\t\treturn { keepAlive: true, messages };\n\t\t}\n\t}\n\n\tif (ctx.currentTime > props.stopWhen) {\n\t\tfillWithSilence(outputs[0]);\n\t\tprops.state = State.Ended;\n\t\tmessages.push({ type: \"ended\" });\n\t\tprops.playedSamples = 0;\n\t\treturn { keepAlive: true, messages };\n\t}\n\n\tconst output0 = outputs[0];\n\tconst sourceLength = getLogicalBufferLength(props);\n\tif (sourceLength === 0) {\n\t\tfillWithSilence(output0);\n\t\treturn { keepAlive: true, messages };\n\t}\n\n\tconst {\n\t\tplaybackRate: playbackRates,\n\t\tdetune: detunes,\n\t\tlowpass,\n\t\thighpass,\n\t\tgain: gains,\n\t\tpan: pans,\n\t} = parameters;\n\n\tconst {\n\t\tbuffer,\n\t\tloopStart,\n\t\tloopEnd,\n\t\tloopCrossfade,\n\t\tstopWhen,\n\t\tplayedSamples,\n\t\tenableLowpass,\n\t\tenableHighpass,\n\t\tenableGain,\n\t\tenablePan,\n\t\tenableDetune,\n\t\tenableFadeOut,\n\t\tenableFadeIn,\n\t\tenableLoopStart,\n\t\tenableLoopEnd,\n\t\tenableLoopCrossfade,\n\t\tplayhead,\n\t\tfadeInDuration,\n\t\tfadeOutDuration,\n\t} = props;\n\tconst hasIncompleteStream =\n\t\tprops.streamBuffer.streaming &&\n\t\tprops.streamBuffer.committedLength < sourceLength;\n\tconst loop = props.loop && !hasIncompleteStream;\n\n\tconst nc = Math.min(buffer.length, output0.length);\n\tconst durationSamples = props.duration * ctx.sampleRate;\n\n\tconst loopCrossfadeSamples = Math.floor(ctx.sampleRate * loopCrossfade);\n\tconst maxLoopStartSample = Math.max(sourceLength - SAMPLE_BLOCK_SIZE, 0);\n\tconst loopStartSamples = enableLoopStart\n\t\t? Math.min(Math.floor(loopStart * ctx.sampleRate), maxLoopStartSample)\n\t\t: 0;\n\tconst loopEndSamples = enableLoopEnd\n\t\t? Math.min(Math.floor(loopEnd * ctx.sampleRate), sourceLength)\n\t\t: sourceLength;\n\tconst loopLengthSamples = loopEndSamples - loopStartSamples;\n\n\t// Apply detune to playback rates: effectiveRate = rate * 2^(detune/1200)\n\tconst needsDetune = enableDetune && detunes.length > 0 && detunes[0] !== 0;\n\tlet effectiveRates = playbackRates;\n\tif (needsDetune) {\n\t\tconst len = Math.max(\n\t\t\tplaybackRates.length,\n\t\t\tdetunes.length,\n\t\t\tSAMPLE_BLOCK_SIZE,\n\t\t);\n\t\teffectiveRates = new Float32Array(len);\n\t\tfor (let i = 0; i < len; i++) {\n\t\t\tconst rate = playbackRates[i] ?? playbackRates[playbackRates.length - 1];\n\t\t\tconst cents = detunes[i] ?? detunes[detunes.length - 1];\n\t\t\teffectiveRates[i] = rate * 2 ** (cents / 1200);\n\t\t}\n\t}\n\n\tconst useRateIndexing = props.enablePlaybackRate || needsDetune;\n\tconst isZeroRateBlock =\n\t\tuseRateIndexing &&\n\t\teffectiveRates.length > 0 &&\n\t\teffectiveRates.every((rate) => rate === 0);\n\n\tif (\n\t\tprops.streamBuffer.streaming &&\n\t\t!props.streamBuffer.streamEnded &&\n\t\t!props.streamBuffer.lowWaterNotified &&\n\t\tprops.streamBuffer.committedLength - Math.floor(playhead) <\n\t\t\tprops.streamBuffer.lowWaterThreshold\n\t) {\n\t\tmessages.push({\n\t\t\ttype: \"bufferLowWater\",\n\t\t\tdata: {\n\t\t\t\tplayhead: Math.floor(playhead),\n\t\t\t\tcommittedLength: props.streamBuffer.committedLength,\n\t\t\t},\n\t\t});\n\t\tprops.streamBuffer.lowWaterNotified = true;\n\t}\n\n\tif (isZeroRateBlock) {\n\t\tfillWithSilence(output0);\n\t\tfor (let i = 1; i < outputs.length; i++) {\n\t\t\tcopy(output0, outputs[i]);\n\t\t}\n\t\treturn { keepAlive: true, messages };\n\t}\n\n\tconst blockParams: BlockParameters = {\n\t\tbufferLength: sourceLength,\n\t\tloop,\n\t\tplayhead,\n\t\tloopStartSamples,\n\t\tloopEndSamples,\n\t\tdurationSamples,\n\t\tplaybackRates: effectiveRates,\n\t};\n\n\tconst {\n\t\tindexes,\n\t\tended,\n\t\tlooped,\n\t\tplayhead: updatedPlayhead,\n\t} = useRateIndexing\n\t\t? findIndexesWithPlaybackRates(blockParams)\n\t\t: findIndexesNormal(blockParams);\n\n\tconst underrunSample = indexes.find(\n\t\t(index) =>\n\t\t\tindex >= props.streamBuffer.committedLength && index < sourceLength,\n\t);\n\tif (\n\t\tunderrunSample !== undefined &&\n\t\t!props.streamBuffer.streamEnded &&\n\t\tprops.streamBuffer.lastUnderrunSample !== underrunSample\n\t) {\n\t\tmessages.push({\n\t\t\ttype: \"bufferUnderrun\",\n\t\t\tdata: {\n\t\t\t\tplayhead: Math.floor(playhead),\n\t\t\t\tcommittedLength: props.streamBuffer.committedLength,\n\t\t\t\trequestedSample: underrunSample,\n\t\t\t},\n\t\t});\n\t\tprops.streamBuffer.lastUnderrunSample = underrunSample;\n\t} else if (underrunSample === undefined) {\n\t\tprops.streamBuffer.lastUnderrunSample = null;\n\t}\n\n\tfill(output0, buffer, indexes);\n\n\t// --- Loop crossfade ---\n\tconst xfadeNumSamples = Math.min(\n\t\tMath.floor(loopCrossfade * ctx.sampleRate),\n\t\tloopLengthSamples,\n\t);\n\tconst isWithinLoopRange =\n\t\tloop && playhead > loopStartSamples && playhead < loopEndSamples;\n\tconst needsCrossfade =\n\t\tenableLoopCrossfade &&\n\t\tloopCrossfadeSamples > 0 &&\n\t\tsourceLength > SAMPLE_BLOCK_SIZE;\n\n\tif (isWithinLoopRange && needsCrossfade) {\n\t\t// Crossfade out at loop start: fade out tail of previous loop iteration.\n\t\t// Source: reads from END of loop (loopEnd - xfade to loopEnd).\n\t\t{\n\t\t\tconst endIndex = loopStartSamples + xfadeNumSamples;\n\t\t\tif (\n\t\t\t\txfadeNumSamples > 0 &&\n\t\t\t\tplayhead > loopStartSamples &&\n\t\t\t\tplayhead < endIndex\n\t\t\t) {\n\t\t\t\tconst elapsed = playhead - loopStartSamples;\n\t\t\t\tconst n = Math.min(Math.floor(endIndex - playhead), SAMPLE_BLOCK_SIZE);\n\t\t\t\tfor (let i = 0; i < n; i++) {\n\t\t\t\t\tconst position = (elapsed + i) / xfadeNumSamples;\n\t\t\t\t\tconst g = Math.cos((Math.PI * position) / 2);\n\t\t\t\t\tconst srcIdx = Math.floor(\n\t\t\t\t\t\tloopEndSamples - xfadeNumSamples + elapsed + i,\n\t\t\t\t\t);\n\t\t\t\t\tif (srcIdx >= 0 && srcIdx < sourceLength) {\n\t\t\t\t\t\tfor (let ch = 0; ch < nc; ch++) {\n\t\t\t\t\t\t\toutput0[ch][i] += buffer[ch][srcIdx] * g;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Crossfade in approaching loop end: fade in head of next loop iteration.\n\t\t// Source: reads from START of loop (loopStart to loopStart + xfade).\n\t\t{\n\t\t\tconst startIndex = loopEndSamples - xfadeNumSamples;\n\t\t\tif (\n\t\t\t\txfadeNumSamples > 0 &&\n\t\t\t\tplayhead > startIndex &&\n\t\t\t\tplayhead < loopEndSamples\n\t\t\t) {\n\t\t\t\tconst elapsed = playhead - startIndex;\n\t\t\t\tconst n = Math.min(\n\t\t\t\t\tMath.floor(loopEndSamples - playhead),\n\t\t\t\t\tSAMPLE_BLOCK_SIZE,\n\t\t\t\t);\n\t\t\t\tfor (let i = 0; i < n; i++) {\n\t\t\t\t\tconst position = (elapsed + i) / xfadeNumSamples;\n\t\t\t\t\tconst g = Math.sin((Math.PI * position) / 2);\n\t\t\t\t\tconst srcIdx = Math.floor(loopStartSamples + elapsed + i);\n\t\t\t\t\tif (srcIdx >= 0 && srcIdx < sourceLength) {\n\t\t\t\t\t\tfor (let ch = 0; ch < nc; ch++) {\n\t\t\t\t\t\t\toutput0[ch][i] += buffer[ch][srcIdx] * g;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// --- Fade in ---\n\tif (enableFadeIn && fadeInDuration > 0) {\n\t\tconst fadeInSamples = Math.floor(fadeInDuration * ctx.sampleRate);\n\t\tconst remaining = fadeInSamples - playedSamples;\n\t\tif (remaining > 0) {\n\t\t\tconst n = Math.min(remaining, SAMPLE_BLOCK_SIZE);\n\t\t\tfor (let i = 0; i < n; i++) {\n\t\t\t\tconst t = (playedSamples + i) / fadeInSamples;\n\t\t\t\tconst g = t * t * t; // cubic: slow start, fast finish\n\t\t\t\tfor (let ch = 0; ch < nc; ch++) {\n\t\t\t\t\toutput0[ch][i] *= g;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// --- Fade out ---\n\tif (enableFadeOut && fadeOutDuration > 0) {\n\t\tconst fadeOutSamples = Math.floor(fadeOutDuration * ctx.sampleRate);\n\t\tconst remainingSamples = Math.floor(\n\t\t\tctx.sampleRate * (stopWhen - ctx.currentTime),\n\t\t);\n\t\tif (remainingSamples < fadeOutSamples + SAMPLE_BLOCK_SIZE) {\n\t\t\tfor (let i = 0; i < SAMPLE_BLOCK_SIZE; i++) {\n\t\t\t\tconst sampleRemaining = remainingSamples - i;\n\t\t\t\tif (sampleRemaining >= fadeOutSamples) continue; // not yet in fade zone\n\t\t\t\tconst t = sampleRemaining <= 0 ? 0 : sampleRemaining / fadeOutSamples;\n\t\t\t\tconst g = t * t * t; // cubic fade-out: fast drop, slow tail\n\t\t\t\tfor (let ch = 0; ch < nc; ch++) {\n\t\t\t\t\toutput0[ch][i] *= g;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// --- Filters ---\n\tif (enableLowpass)\n\t\tlowpassFilter(output0, lowpass, ctx.sampleRate, filterState.lowpass);\n\tif (enableHighpass)\n\t\thighpassFilter(output0, highpass, ctx.sampleRate, filterState.highpass);\n\tif (enableGain) gainFilter(output0, gains);\n\tif (nc === 1) monoToStereo(output0);\n\tif (enablePan) panFilter(output0, pans);\n\n\tif (looped) {\n\t\tprops.timesLooped++;\n\t\tmessages.push({ type: \"looped\", data: props.timesLooped });\n\t}\n\tif (ended) {\n\t\tprops.state = State.Ended;\n\t\tmessages.push({ type: \"ended\" });\n\t}\n\n\tprops.playedSamples += indexes.length;\n\tprops.playhead = updatedPlayhead;\n\n\tconst numNans = checkNans(output0);\n\tif (numNans > 0) {\n\t\tconsole.log({\n\t\t\tnumNans,\n\t\t\tindexes,\n\t\t\tplayhead: updatedPlayhead,\n\t\t\tended,\n\t\t\tlooped,\n\t\t\tsourceLength,\n\t\t});\n\t\treturn { keepAlive: true, messages };\n\t}\n\n\tfor (let i = 1; i < outputs.length; i++) {\n\t\tcopy(output0, outputs[i]);\n\t}\n\treturn { keepAlive: true, messages };\n}\n",
6
+ "// processor-kernel.ts — Pure DSP logic, state machine, all filters\n// NO AudioWorklet or platform dependencies. Fully testable.\n\nimport {\n\ttype BlockParameters,\n\ttype BlockReturnState,\n\ttype BufferRangeWrite,\n\ttype ClipProcessorOptions,\n\tState,\n\ttype StreamBufferSpan,\n\ttype StreamBufferState,\n} from \"./types\";\n\n// ---------------------------------------------------------------------------\n// Constants\n// ---------------------------------------------------------------------------\n\nexport const SAMPLE_BLOCK_SIZE = 128;\n\nfunction createStreamBufferState(\n\tbuffer: Float32Array[] = [],\n): StreamBufferState {\n\tconst totalLength = buffer[0]?.length ?? 0;\n\tconst hasBuffer = totalLength > 0;\n\treturn {\n\t\ttotalLength: hasBuffer ? totalLength : null,\n\t\tcommittedLength: hasBuffer ? totalLength : 0,\n\t\tstreamEnded: hasBuffer,\n\t\tstreaming: false,\n\t\twrittenSpans: hasBuffer ? [{ startSample: 0, endSample: totalLength }] : [],\n\t\tpendingWrites: [],\n\t\tlowWaterThreshold: SAMPLE_BLOCK_SIZE * 4,\n\t\tlowWaterNotified: false,\n\t\tlastUnderrunSample: null,\n\t};\n}\n\nfunction getBufferLength(buffer: Float32Array[]): number {\n\treturn buffer[0]?.length ?? 0;\n}\n\nfunction getLogicalBufferLength(\n\tproperties: Required<ClipProcessorOptions>,\n): number {\n\treturn (\n\t\tproperties.streamBuffer.totalLength ?? getBufferLength(properties.buffer)\n\t);\n}\n\nfunction createSilentBuffer(channels: number, length: number): Float32Array[] {\n\treturn Array.from({ length: channels }, () => new Float32Array(length));\n}\n\nfunction mergeWrittenSpan(\n\tspans: StreamBufferSpan[],\n\tnextSpan: StreamBufferSpan,\n): StreamBufferSpan[] {\n\tconst merged = [...spans, nextSpan].sort(\n\t\t(a, b) => a.startSample - b.startSample,\n\t);\n\tconst result: StreamBufferSpan[] = [];\n\tfor (const span of merged) {\n\t\tconst previous = result[result.length - 1];\n\t\tif (!previous || span.startSample > previous.endSample) {\n\t\t\tresult.push({ ...span });\n\t\t\tcontinue;\n\t\t}\n\t\tprevious.endSample = Math.max(previous.endSample, span.endSample);\n\t}\n\treturn result;\n}\n\nfunction getCommittedLength(spans: StreamBufferSpan[]): number {\n\tlet committedLength = 0;\n\tfor (const span of spans) {\n\t\tif (span.startSample > committedLength) break;\n\t\tcommittedLength = Math.max(committedLength, span.endSample);\n\t}\n\treturn committedLength;\n}\n\nfunction resetLowWaterState(\n\tstreamBuffer: StreamBufferState,\n\tplayhead: number,\n): void {\n\tif (\n\t\tstreamBuffer.committedLength - Math.floor(playhead) >=\n\t\tstreamBuffer.lowWaterThreshold\n\t) {\n\t\tstreamBuffer.lowWaterNotified = false;\n\t}\n}\n\nfunction ensureBufferCapacity(\n\tproperties: Required<ClipProcessorOptions>,\n\trequiredChannels: number,\n\trequiredLength: number,\n): void {\n\tconst currentLength = getBufferLength(properties.buffer);\n\tconst currentChannels = properties.buffer.length;\n\tif (currentLength >= requiredLength && currentChannels >= requiredChannels) {\n\t\treturn;\n\t}\n\n\tconst nextLength = Math.max(currentLength, requiredLength);\n\tconst nextChannels = Math.max(currentChannels, requiredChannels);\n\tconst nextBuffer = createSilentBuffer(nextChannels, nextLength);\n\tfor (let ch = 0; ch < currentChannels; ch++) {\n\t\tnextBuffer[ch].set(properties.buffer[ch].subarray(0, currentLength));\n\t}\n\tproperties.buffer = nextBuffer;\n\tif (\n\t\tproperties.streamBuffer.totalLength == null ||\n\t\tproperties.streamBuffer.totalLength < nextLength\n\t) {\n\t\tproperties.streamBuffer.totalLength = nextLength;\n\t}\n}\n\nfunction applyBufferRangeWrite(\n\tproperties: Required<ClipProcessorOptions>,\n\twrite: BufferRangeWrite,\n): void {\n\tconst startSample = Math.max(Math.floor(write.startSample), 0);\n\tconst writeLength = write.channelData[0]?.length ?? 0;\n\tconst requestedTotalLength = write.totalLength ?? null;\n\tconst requiredLength = Math.max(\n\t\tstartSample + writeLength,\n\t\trequestedTotalLength ?? 0,\n\t);\n\tensureBufferCapacity(\n\t\tproperties,\n\t\tMath.max(write.channelData.length, properties.buffer.length, 1),\n\t\trequiredLength,\n\t);\n\n\tfor (let ch = 0; ch < write.channelData.length; ch++) {\n\t\tproperties.buffer[ch].set(write.channelData[ch], startSample);\n\t}\n\n\tif (requestedTotalLength != null) {\n\t\tproperties.streamBuffer.totalLength = requestedTotalLength;\n\t}\n\tif (writeLength > 0) {\n\t\tproperties.streamBuffer.writtenSpans = mergeWrittenSpan(\n\t\t\tproperties.streamBuffer.writtenSpans,\n\t\t\t{ startSample, endSample: startSample + writeLength },\n\t\t);\n\t\tproperties.streamBuffer.committedLength = getCommittedLength(\n\t\t\tproperties.streamBuffer.writtenSpans,\n\t\t);\n\t}\n\tif (write.streamEnded === true) {\n\t\tproperties.streamBuffer.streamEnded = true;\n\t}\n\tresetLowWaterState(properties.streamBuffer, properties.playhead);\n}\n\nfunction applyPendingBufferWrites(\n\tproperties: Required<ClipProcessorOptions>,\n): void {\n\tif (properties.streamBuffer.pendingWrites.length === 0) {\n\t\treturn;\n\t}\n\tfor (const write of properties.streamBuffer.pendingWrites) {\n\t\tapplyBufferRangeWrite(properties, write);\n\t}\n\tproperties.streamBuffer.pendingWrites = [];\n}\n\nfunction setWholeBuffer(\n\tproperties: Required<ClipProcessorOptions>,\n\tbuffer: Float32Array[],\n): void {\n\tproperties.buffer = buffer;\n\tproperties.streamBuffer = createStreamBufferState(buffer);\n}\n\n// ---------------------------------------------------------------------------\n// Properties & offset\n// ---------------------------------------------------------------------------\n\nexport function getProperties(\n\topts: ClipProcessorOptions = {},\n\tsampleRate: number,\n): Required<ClipProcessorOptions> {\n\tconst {\n\t\tbuffer = [],\n\t\tstreamBuffer = createStreamBufferState(buffer),\n\t\tduration = -1,\n\t\tloop = false,\n\t\tloopStart = 0,\n\t\tloopEnd = (buffer[0]?.length ?? 0) / sampleRate,\n\t\tloopCrossfade = 0,\n\t\tplayhead = 0,\n\t\toffset = 0,\n\t\tstartWhen = 0,\n\t\tstopWhen = 0,\n\t\tpauseWhen = 0,\n\t\tresumeWhen = 0,\n\t\tplayedSamples = 0,\n\t\tstate = State.Initial,\n\t\ttimesLooped = 0,\n\t\tfadeInDuration = 0,\n\t\tfadeOutDuration = 0,\n\t\tenableFadeIn = fadeInDuration > 0,\n\t\tenableFadeOut = fadeOutDuration > 0,\n\t\tenableLoopStart = true,\n\t\tenableLoopEnd = true,\n\t\tenableLoopCrossfade = loopCrossfade > 0,\n\t\tenableHighpass = true,\n\t\tenableLowpass = true,\n\t\tenableGain = true,\n\t\tenablePan = true,\n\t\tenableDetune = true,\n\t\tenablePlaybackRate = true,\n\t} = opts;\n\n\treturn {\n\t\tbuffer,\n\t\tstreamBuffer,\n\t\tloop,\n\t\tloopStart,\n\t\tloopEnd,\n\t\tloopCrossfade,\n\t\tduration,\n\t\tplayhead,\n\t\toffset,\n\t\tstartWhen,\n\t\tstopWhen,\n\t\tpauseWhen,\n\t\tresumeWhen,\n\t\tplayedSamples,\n\t\tstate,\n\t\ttimesLooped,\n\t\tfadeInDuration,\n\t\tfadeOutDuration,\n\t\tenableFadeIn,\n\t\tenableFadeOut,\n\t\tenableLoopStart,\n\t\tenableLoopEnd,\n\t\tenableHighpass,\n\t\tenableLowpass,\n\t\tenableGain,\n\t\tenablePan,\n\t\tenableDetune,\n\t\tenablePlaybackRate,\n\t\tenableLoopCrossfade,\n\t};\n}\n\nfunction getBufferDurationSeconds(\n\tproperties: Required<ClipProcessorOptions>,\n\tsampleRate: number,\n): number {\n\treturn getLogicalBufferLength(properties) / sampleRate;\n}\n\nfunction normalizeLoopBounds(\n\tproperties: Required<ClipProcessorOptions>,\n\tsampleRate: number,\n): void {\n\tconst bufferDuration = getBufferDurationSeconds(properties, sampleRate);\n\tif (bufferDuration <= 0) {\n\t\tproperties.loopStart = 0;\n\t\tproperties.loopEnd = 0;\n\t\treturn;\n\t}\n\n\tif (!Number.isFinite(properties.loopStart) || properties.loopStart < 0) {\n\t\tproperties.loopStart = 0;\n\t}\n\tif (properties.loopStart >= bufferDuration) {\n\t\tproperties.loopStart = 0;\n\t}\n\tif (\n\t\t!Number.isFinite(properties.loopEnd) ||\n\t\tproperties.loopEnd <= properties.loopStart ||\n\t\tproperties.loopEnd > bufferDuration\n\t) {\n\t\tproperties.loopEnd = bufferDuration;\n\t}\n}\n\nexport function setOffset(\n\tproperties: Required<ClipProcessorOptions>,\n\toffset: number | undefined,\n\tsampleRate: number,\n): number {\n\tif (offset === undefined) {\n\t\tproperties.offset = 0;\n\t\treturn 0;\n\t}\n\tif (offset < 0) {\n\t\treturn setOffset(\n\t\t\tproperties,\n\t\t\tgetLogicalBufferLength(properties) + offset,\n\t\t\tsampleRate,\n\t\t);\n\t}\n\tif (offset > (getLogicalBufferLength(properties) || 1) - 1) {\n\t\treturn setOffset(\n\t\t\tproperties,\n\t\t\tgetLogicalBufferLength(properties) % offset,\n\t\t\tsampleRate,\n\t\t);\n\t}\n\tconst offs = Math.floor(offset * sampleRate);\n\tproperties.offset = offs;\n\treturn offs;\n}\n\n// ---------------------------------------------------------------------------\n// Index calculation\n// ---------------------------------------------------------------------------\n\nexport function findIndexesNormal(p: BlockParameters): BlockReturnState {\n\tconst { playhead, bufferLength, loop, loopStartSamples, loopEndSamples } = p;\n\tlet length = 128;\n\tif (!loop && playhead + 128 > bufferLength) {\n\t\tlength = Math.max(bufferLength - playhead, 0);\n\t}\n\tconst indexes: number[] = new Array(length);\n\n\tif (!loop) {\n\t\tfor (let i = 0, head = playhead; i < length; i++, head++) {\n\t\t\tindexes[i] = head;\n\t\t}\n\t\tconst nextPlayhead = playhead + length;\n\t\treturn {\n\t\t\tplayhead: nextPlayhead,\n\t\t\tindexes,\n\t\t\tlooped: false,\n\t\t\tended: nextPlayhead >= bufferLength,\n\t\t};\n\t}\n\n\tlet head = playhead;\n\tlet looped = false;\n\tfor (let i = 0; i < length; i++, head++) {\n\t\tif (head >= loopEndSamples) {\n\t\t\thead = loopStartSamples + (head - loopEndSamples);\n\t\t\tlooped = true;\n\t\t}\n\t\tindexes[i] = head;\n\t}\n\treturn { indexes, looped, ended: false, playhead: head };\n}\n\nexport function findIndexesWithPlaybackRates(\n\tp: BlockParameters,\n): BlockReturnState {\n\tconst {\n\t\tplayhead,\n\t\tbufferLength,\n\t\tloop,\n\t\tloopStartSamples,\n\t\tloopEndSamples,\n\t\tplaybackRates,\n\t} = p;\n\tlet length = 128;\n\tif (!loop && playhead + 128 > bufferLength) {\n\t\tlength = Math.max(bufferLength - playhead, 0);\n\t}\n\tconst indexes: number[] = new Array(length);\n\tlet head = playhead;\n\tlet looped = false;\n\n\tif (loop) {\n\t\tfor (let i = 0; i < length; i++) {\n\t\t\tindexes[i] = Math.min(Math.max(Math.floor(head), 0), bufferLength - 1);\n\t\t\tconst rate = playbackRates[i] ?? playbackRates[0] ?? 1;\n\t\t\thead += rate;\n\t\t\tif (rate >= 0 && (head > loopEndSamples || head > bufferLength)) {\n\t\t\t\thead = loopStartSamples;\n\t\t\t\tlooped = true;\n\t\t\t} else if (rate < 0 && (head < loopStartSamples || head < 0)) {\n\t\t\t\thead = loopEndSamples;\n\t\t\t\tlooped = true;\n\t\t\t}\n\t\t}\n\t\treturn { playhead: head, indexes, looped, ended: false };\n\t}\n\n\tfor (let i = 0; i < length; i++) {\n\t\tindexes[i] = Math.min(Math.max(Math.floor(head), 0), bufferLength - 1);\n\t\thead += playbackRates[i] ?? playbackRates[0] ?? 1;\n\t}\n\treturn {\n\t\tplayhead: head,\n\t\tindexes,\n\t\tlooped: false,\n\t\tended: head >= bufferLength || head < 0,\n\t};\n}\n\n// ---------------------------------------------------------------------------\n// Buffer operations\n// ---------------------------------------------------------------------------\n\nexport function fill(\n\ttarget: Float32Array[],\n\tsource: Float32Array[],\n\tindexes: number[],\n): void {\n\tconst nc = Math.min(target.length, source.length);\n\tfor (let i = 0; i < indexes.length; i++) {\n\t\tfor (let ch = 0; ch < nc; ch++) {\n\t\t\ttarget[ch][i] = source[ch][indexes[i]];\n\t\t}\n\t}\n\tfor (let ch = nc; ch < target.length; ch++) {\n\t\tfor (let i = 0; i < target[ch].length; i++) {\n\t\t\ttarget[ch][i] = 0;\n\t\t}\n\t}\n\tfor (let i = indexes.length; i < target[0].length; i++) {\n\t\tfor (let ch = 0; ch < nc; ch++) {\n\t\t\ttarget[ch][i] = 0;\n\t\t}\n\t}\n}\n\nexport function fillWithSilence(buffer: Float32Array[]): void {\n\tfor (let ch = 0; ch < buffer.length; ch++) {\n\t\tfor (let j = 0; j < buffer[ch].length; j++) {\n\t\t\tbuffer[ch][j] = 0;\n\t\t}\n\t}\n}\n\nexport function monoToStereo(signal: Float32Array[]): void {\n\tif (signal.length >= 2) {\n\t\t// Output already has a second channel — copy mono data into it\n\t\tfor (let i = 0; i < signal[0].length; i++) {\n\t\t\tsignal[1][i] = signal[0][i];\n\t\t}\n\t} else {\n\t\tconst r = new Float32Array(signal[0].length);\n\t\tfor (let i = 0; i < signal[0].length; i++) {\n\t\t\tr[i] = signal[0][i];\n\t\t}\n\t\tsignal.push(r);\n\t}\n}\n\nexport function copy(source: Float32Array[], target: Float32Array[]): void {\n\tfor (let i = target.length; i < source.length; i++) {\n\t\ttarget[i] = new Float32Array(source[i].length);\n\t}\n\tfor (let ch = 0; ch < source.length; ch++) {\n\t\tfor (let i = 0; i < source[ch].length; i++) {\n\t\t\ttarget[ch][i] = source[ch][i];\n\t\t}\n\t}\n}\n\nexport function checkNans(output: Float32Array[]): number {\n\tlet numNans = 0;\n\tfor (let ch = 0; ch < output.length; ch++) {\n\t\tfor (let j = 0; j < output[ch].length; j++) {\n\t\t\tif (Number.isNaN(output[ch][j])) {\n\t\t\t\tnumNans++;\n\t\t\t\toutput[ch][j] = 0;\n\t\t\t}\n\t\t}\n\t}\n\treturn numNans;\n}\n\n// ---------------------------------------------------------------------------\n// Filters\n// ---------------------------------------------------------------------------\n\nexport interface BiquadState {\n\tx_1: number;\n\tx_2: number;\n\ty_1: number;\n\ty_2: number;\n}\n\nexport function createFilterState(): BiquadState[] {\n\treturn [\n\t\t{ x_1: 0, x_2: 0, y_1: 0, y_2: 0 },\n\t\t{ x_1: 0, x_2: 0, y_1: 0, y_2: 0 },\n\t];\n}\n\nexport function gainFilter(arr: Float32Array[], gains: Float32Array): void {\n\tif (gains.length === 1) {\n\t\tconst g = gains[0];\n\t\tif (g === 1) return;\n\t\tfor (const ch of arr) {\n\t\t\tfor (let i = 0; i < ch.length; i++) ch[i] *= g;\n\t\t}\n\t\treturn;\n\t}\n\tlet g = gains[0];\n\tfor (const ch of arr) {\n\t\tfor (let i = 0; i < ch.length; i++) {\n\t\t\tg = gains[i] ?? g;\n\t\t\tch[i] *= g;\n\t\t}\n\t}\n}\n\nexport function panFilter(signal: Float32Array[], pans: Float32Array): void {\n\tlet pan = pans[0];\n\tfor (let i = 0; i < signal[0].length; i++) {\n\t\tpan = pans[i] ?? pan;\n\t\tconst leftGain = pan <= 0 ? 1 : 1 - pan;\n\t\tconst rightGain = pan >= 0 ? 1 : 1 + pan;\n\t\tsignal[0][i] *= leftGain;\n\t\tsignal[1][i] *= rightGain;\n\t}\n}\n\nexport function lowpassFilter(\n\tbuffer: Float32Array[],\n\tcutoffs: Float32Array,\n\tsampleRate: number,\n\tstates: BiquadState[],\n): void {\n\tfor (let channel = 0; channel < buffer.length; channel++) {\n\t\tconst arr = buffer[channel];\n\t\tlet { x_1, x_2, y_1, y_2 } = states[channel] ?? {\n\t\t\tx_1: 0,\n\t\t\tx_2: 0,\n\t\t\ty_1: 0,\n\t\t\ty_2: 0,\n\t\t};\n\t\tif (cutoffs.length === 1) {\n\t\t\tconst cutoff = cutoffs[0];\n\t\t\tif (cutoff >= 20000) return;\n\t\t\tconst w0 = (2 * Math.PI * cutoff) / sampleRate;\n\t\t\tconst alpha = Math.sin(w0) / 2;\n\t\t\tconst b0 = (1 - Math.cos(w0)) / 2;\n\t\t\tconst b1 = 1 - Math.cos(w0);\n\t\t\tconst b2 = (1 - Math.cos(w0)) / 2;\n\t\t\tconst a0 = 1 + alpha;\n\t\t\tconst a1 = -2 * Math.cos(w0);\n\t\t\tconst a2 = 1 - alpha;\n\t\t\tconst h0 = b0 / a0,\n\t\t\t\th1 = b1 / a0,\n\t\t\t\th2 = b2 / a0,\n\t\t\t\th3 = a1 / a0,\n\t\t\t\th4 = a2 / a0;\n\t\t\tfor (let i = 0; i < arr.length; i++) {\n\t\t\t\tconst x = arr[i];\n\t\t\t\tconst y = h0 * x + h1 * x_1 + h2 * x_2 - h3 * y_1 - h4 * y_2;\n\t\t\t\tx_2 = x_1;\n\t\t\t\tx_1 = x;\n\t\t\t\ty_2 = y_1;\n\t\t\t\ty_1 = y;\n\t\t\t\tarr[i] = y;\n\t\t\t}\n\t\t} else {\n\t\t\tconst prevCutoff = cutoffs[0];\n\t\t\tfor (let i = 0; i < arr.length; i++) {\n\t\t\t\tconst cutoff = cutoffs[i] ?? prevCutoff;\n\t\t\t\tconst w0 = (2 * Math.PI * cutoff) / sampleRate;\n\t\t\t\tconst alpha = Math.sin(w0) / 2;\n\t\t\t\tconst b0 = (1 - Math.cos(w0)) / 2;\n\t\t\t\tconst b1 = 1 - Math.cos(w0);\n\t\t\t\tconst b2 = (1 - Math.cos(w0)) / 2;\n\t\t\t\tconst a0 = 1 + alpha;\n\t\t\t\tconst a1 = -2 * Math.cos(w0);\n\t\t\t\tconst a2 = 1 - alpha;\n\t\t\t\tconst x = arr[i];\n\t\t\t\tconst y =\n\t\t\t\t\t(b0 / a0) * x +\n\t\t\t\t\t(b1 / a0) * x_1 +\n\t\t\t\t\t(b2 / a0) * x_2 -\n\t\t\t\t\t(a1 / a0) * y_1 -\n\t\t\t\t\t(a2 / a0) * y_2;\n\t\t\t\tx_2 = x_1;\n\t\t\t\tx_1 = x;\n\t\t\t\ty_2 = y_1;\n\t\t\t\ty_1 = y;\n\t\t\t\tarr[i] = y;\n\t\t\t}\n\t\t}\n\t\tstates[channel] = { x_1, x_2, y_1, y_2 };\n\t}\n}\n\nexport function highpassFilter(\n\tbuffer: Float32Array[],\n\tcutoffs: Float32Array,\n\tsampleRate: number,\n\tstates: BiquadState[],\n): void {\n\tfor (let channel = 0; channel < buffer.length; channel++) {\n\t\tconst arr = buffer[channel];\n\t\tlet { x_1, x_2, y_1, y_2 } = states[channel] ?? {\n\t\t\tx_1: 0,\n\t\t\tx_2: 0,\n\t\t\ty_1: 0,\n\t\t\ty_2: 0,\n\t\t};\n\t\tif (cutoffs.length === 1) {\n\t\t\tconst cutoff = cutoffs[0];\n\t\t\tif (cutoff <= 20) return;\n\t\t\tconst w0 = (2 * Math.PI * cutoff) / sampleRate;\n\t\t\tconst alpha = Math.sin(w0) / 2;\n\t\t\tconst b0 = (1 + Math.cos(w0)) / 2;\n\t\t\tconst b1 = -(1 + Math.cos(w0));\n\t\t\tconst b2 = (1 + Math.cos(w0)) / 2;\n\t\t\tconst a0 = 1 + alpha;\n\t\t\tconst a1 = -2 * Math.cos(w0);\n\t\t\tconst a2 = 1 - alpha;\n\t\t\tfor (let i = 0; i < arr.length; i++) {\n\t\t\t\tconst x = arr[i];\n\t\t\t\tconst y =\n\t\t\t\t\t(b0 / a0) * x +\n\t\t\t\t\t(b1 / a0) * x_1 +\n\t\t\t\t\t(b2 / a0) * x_2 -\n\t\t\t\t\t(a1 / a0) * y_1 -\n\t\t\t\t\t(a2 / a0) * y_2;\n\t\t\t\tx_2 = x_1;\n\t\t\t\tx_1 = x;\n\t\t\t\ty_2 = y_1;\n\t\t\t\ty_1 = y;\n\t\t\t\tarr[i] = y;\n\t\t\t}\n\t\t} else {\n\t\t\tconst prevCutoff = cutoffs[0];\n\t\t\tfor (let i = 0; i < arr.length; i++) {\n\t\t\t\tconst cutoff = cutoffs[i] ?? prevCutoff;\n\t\t\t\tconst w0 = (2 * Math.PI * cutoff) / sampleRate;\n\t\t\t\tconst alpha = Math.sin(w0) / 2;\n\t\t\t\tconst b0 = (1 + Math.cos(w0)) / 2;\n\t\t\t\tconst b1 = -(1 + Math.cos(w0));\n\t\t\t\tconst b2 = (1 + Math.cos(w0)) / 2;\n\t\t\t\tconst a0 = 1 + alpha;\n\t\t\t\tconst a1 = -2 * Math.cos(w0);\n\t\t\t\tconst a2 = 1 - alpha;\n\t\t\t\tconst x = arr[i];\n\t\t\t\tconst y =\n\t\t\t\t\t(b0 / a0) * x +\n\t\t\t\t\t(b1 / a0) * x_1 +\n\t\t\t\t\t(b2 / a0) * x_2 -\n\t\t\t\t\t(a1 / a0) * y_1 -\n\t\t\t\t\t(a2 / a0) * y_2;\n\t\t\t\tx_2 = x_1;\n\t\t\t\tx_1 = x;\n\t\t\t\ty_2 = y_1;\n\t\t\t\ty_1 = y;\n\t\t\t\tarr[i] = y;\n\t\t\t}\n\t\t}\n\t\tstates[channel] = { x_1, x_2, y_1, y_2 };\n\t}\n}\n\n// ---------------------------------------------------------------------------\n// Message handler\n// ---------------------------------------------------------------------------\n\nexport interface OutboundMessage {\n\ttype: string;\n\tdata?: unknown;\n}\n\nexport function handleProcessorMessage(\n\tproperties: Required<ClipProcessorOptions>,\n\tmessage: { type: string; data?: unknown },\n\tcurrentTime: number,\n\tsampleRate: number,\n): OutboundMessage[] {\n\tconst { type, data } = message;\n\tswitch (type) {\n\t\tcase \"buffer\":\n\t\t\tsetWholeBuffer(properties, data as Float32Array[]);\n\t\t\tnormalizeLoopBounds(properties, sampleRate);\n\t\t\treturn [];\n\t\tcase \"bufferInit\": {\n\t\t\tconst init = data as {\n\t\t\t\tchannels: number;\n\t\t\t\ttotalLength: number;\n\t\t\t\tstreaming?: boolean;\n\t\t\t};\n\t\t\tproperties.buffer = createSilentBuffer(init.channels, init.totalLength);\n\t\t\tproperties.streamBuffer = {\n\t\t\t\t...createStreamBufferState(),\n\t\t\t\ttotalLength: init.totalLength,\n\t\t\t\tstreamEnded: false,\n\t\t\t\tstreaming: init.streaming ?? true,\n\t\t\t};\n\t\t\tnormalizeLoopBounds(properties, sampleRate);\n\t\t\treturn [];\n\t\t}\n\t\tcase \"bufferRange\":\n\t\t\tproperties.streamBuffer.pendingWrites.push(data as BufferRangeWrite);\n\t\t\treturn [];\n\t\tcase \"bufferEnd\": {\n\t\t\tconst endData = data as { totalLength?: number } | undefined;\n\t\t\tif (endData?.totalLength != null) {\n\t\t\t\tproperties.streamBuffer.totalLength = endData.totalLength;\n\t\t\t}\n\t\t\tproperties.streamBuffer.streamEnded = true;\n\t\t\treturn [];\n\t\t}\n\t\tcase \"bufferReset\":\n\t\t\tproperties.buffer = [];\n\t\t\tproperties.streamBuffer = createStreamBufferState();\n\t\t\tnormalizeLoopBounds(properties, sampleRate);\n\t\t\treturn [];\n\t\tcase \"start\":\n\t\t\tproperties.timesLooped = 0;\n\t\t\t{\n\t\t\t\tconst d = data as\n\t\t\t\t\t| { duration?: number; offset?: number; when?: number }\n\t\t\t\t\t| undefined;\n\t\t\t\tproperties.duration = d?.duration ?? -1;\n\t\t\t\tif (properties.duration === -1) {\n\t\t\t\t\tproperties.duration = properties.loop\n\t\t\t\t\t\t? Number.MAX_SAFE_INTEGER\n\t\t\t\t\t\t: (properties.buffer[0]?.length ?? 0) / sampleRate;\n\t\t\t\t}\n\t\t\t\tsetOffset(properties, d?.offset, sampleRate);\n\t\t\t\tnormalizeLoopBounds(properties, sampleRate);\n\t\t\t\tproperties.playhead = properties.offset;\n\t\t\t\tproperties.startWhen = d?.when ?? currentTime;\n\t\t\t\tproperties.stopWhen = properties.startWhen + properties.duration;\n\t\t\t\tproperties.playedSamples = 0;\n\t\t\t\tproperties.state = State.Scheduled;\n\t\t\t}\n\t\t\treturn [{ type: \"scheduled\" }];\n\t\tcase \"stop\":\n\t\t\tif (\n\t\t\t\tproperties.state === State.Ended ||\n\t\t\t\tproperties.state === State.Initial\n\t\t\t)\n\t\t\t\treturn [];\n\t\t\tproperties.stopWhen = (data as number | undefined) ?? properties.stopWhen;\n\t\t\tproperties.state = State.Stopped;\n\t\t\treturn [{ type: \"stopped\" }];\n\t\tcase \"pause\":\n\t\t\tproperties.state = State.Paused;\n\t\t\tproperties.pauseWhen = (data as number | undefined) ?? currentTime;\n\t\t\treturn [{ type: \"paused\" }];\n\t\tcase \"resume\":\n\t\t\tproperties.state = State.Started;\n\t\t\tproperties.startWhen = (data as number | undefined) ?? currentTime;\n\t\t\treturn [{ type: \"resume\" }];\n\t\tcase \"dispose\":\n\t\t\tproperties.state = State.Disposed;\n\t\t\tproperties.buffer = [];\n\t\t\tproperties.streamBuffer = createStreamBufferState();\n\t\t\treturn [{ type: \"disposed\" }];\n\t\tcase \"loop\": {\n\t\t\tconst loop = data as boolean;\n\t\t\tconst st = properties.state;\n\t\t\tif (loop && (st === State.Scheduled || st === State.Started)) {\n\t\t\t\tproperties.stopWhen = Number.MAX_SAFE_INTEGER;\n\t\t\t\tproperties.duration = Number.MAX_SAFE_INTEGER;\n\t\t\t}\n\t\t\tproperties.loop = loop;\n\t\t\tif (loop) {\n\t\t\t\tnormalizeLoopBounds(properties, sampleRate);\n\t\t\t}\n\t\t\treturn [];\n\t\t}\n\t\tcase \"loopStart\":\n\t\t\tproperties.loopStart = data as number;\n\t\t\treturn [];\n\t\tcase \"loopEnd\":\n\t\t\tproperties.loopEnd = data as number;\n\t\t\treturn [];\n\t\tcase \"loopCrossfade\":\n\t\t\tproperties.loopCrossfade = data as number;\n\t\t\treturn [];\n\t\tcase \"playhead\":\n\t\t\tproperties.playhead = Math.floor(data as number);\n\t\t\treturn [];\n\t\tcase \"fadeIn\":\n\t\t\tproperties.fadeInDuration = data as number;\n\t\t\treturn [];\n\t\tcase \"fadeOut\":\n\t\t\tproperties.fadeOutDuration = data as number;\n\t\t\treturn [];\n\t\tcase \"toggleGain\":\n\t\t\tproperties.enableGain =\n\t\t\t\t(data as boolean | undefined) ?? !properties.enableGain;\n\t\t\treturn [];\n\t\tcase \"togglePan\":\n\t\t\tproperties.enablePan =\n\t\t\t\t(data as boolean | undefined) ?? !properties.enablePan;\n\t\t\treturn [];\n\t\tcase \"toggleLowpass\":\n\t\t\tproperties.enableLowpass =\n\t\t\t\t(data as boolean | undefined) ?? !properties.enableLowpass;\n\t\t\treturn [];\n\t\tcase \"toggleHighpass\":\n\t\t\tproperties.enableHighpass =\n\t\t\t\t(data as boolean | undefined) ?? !properties.enableHighpass;\n\t\t\treturn [];\n\t\tcase \"toggleDetune\":\n\t\t\tproperties.enableDetune =\n\t\t\t\t(data as boolean | undefined) ?? !properties.enableDetune;\n\t\t\treturn [];\n\t\tcase \"togglePlaybackRate\":\n\t\t\tproperties.enablePlaybackRate =\n\t\t\t\t(data as boolean | undefined) ?? !properties.enablePlaybackRate;\n\t\t\treturn [];\n\t\tcase \"toggleFadeIn\":\n\t\t\tproperties.enableFadeIn =\n\t\t\t\t(data as boolean | undefined) ?? !properties.enableFadeIn;\n\t\t\treturn [];\n\t\tcase \"toggleFadeOut\":\n\t\t\tproperties.enableFadeOut =\n\t\t\t\t(data as boolean | undefined) ?? !properties.enableFadeOut;\n\t\t\treturn [];\n\t\tcase \"toggleLoopStart\":\n\t\t\tproperties.enableLoopStart =\n\t\t\t\t(data as boolean | undefined) ?? !properties.enableLoopStart;\n\t\t\treturn [];\n\t\tcase \"toggleLoopEnd\":\n\t\t\tproperties.enableLoopEnd =\n\t\t\t\t(data as boolean | undefined) ?? !properties.enableLoopEnd;\n\t\t\treturn [];\n\t\tcase \"toggleLoopCrossfade\":\n\t\t\tproperties.enableLoopCrossfade =\n\t\t\t\t(data as boolean | undefined) ?? !properties.enableLoopCrossfade;\n\t\t\treturn [];\n\t\tcase \"logState\":\n\t\t\treturn [];\n\t}\n\treturn [];\n}\n\n// ---------------------------------------------------------------------------\n// Process block\n// ---------------------------------------------------------------------------\n\nexport interface ProcessContext {\n\tcurrentTime: number;\n\tcurrentFrame: number;\n\tsampleRate: number;\n}\n\nexport interface ProcessResult {\n\tkeepAlive: boolean;\n\tmessages: OutboundMessage[];\n}\n\nexport function processBlock(\n\tprops: Required<ClipProcessorOptions>,\n\toutputs: Float32Array[][],\n\tparameters: Record<string, Float32Array>,\n\tctx: ProcessContext,\n\tfilterState: { lowpass: BiquadState[]; highpass: BiquadState[] },\n): ProcessResult {\n\tconst messages: OutboundMessage[] = [];\n\tlet state = props.state;\n\tif (state === State.Disposed) return { keepAlive: false, messages };\n\n\tapplyPendingBufferWrites(props);\n\n\tif (state === State.Initial) return { keepAlive: true, messages };\n\n\tif (state === State.Ended) {\n\t\tfillWithSilence(outputs[0]);\n\t\treturn { keepAlive: true, messages };\n\t}\n\n\tif (state === State.Scheduled) {\n\t\tif (ctx.currentTime >= props.startWhen) {\n\t\t\tstate = props.state = State.Started;\n\t\t\tmessages.push({ type: \"started\" });\n\t\t} else {\n\t\t\tfillWithSilence(outputs[0]);\n\t\t\treturn { keepAlive: true, messages };\n\t\t}\n\t} else if (state === State.Paused) {\n\t\tif (ctx.currentTime > props.pauseWhen) {\n\t\t\tfillWithSilence(outputs[0]);\n\t\t\treturn { keepAlive: true, messages };\n\t\t}\n\t}\n\n\tif (ctx.currentTime > props.stopWhen) {\n\t\tfillWithSilence(outputs[0]);\n\t\tprops.state = State.Ended;\n\t\tmessages.push({ type: \"ended\" });\n\t\tprops.playedSamples = 0;\n\t\treturn { keepAlive: true, messages };\n\t}\n\n\tconst output0 = outputs[0];\n\tconst sourceLength = getLogicalBufferLength(props);\n\tif (sourceLength === 0) {\n\t\tfillWithSilence(output0);\n\t\treturn { keepAlive: true, messages };\n\t}\n\n\tconst {\n\t\tplaybackRate: playbackRates,\n\t\tdetune: detunes,\n\t\tlowpass,\n\t\thighpass,\n\t\tgain: gains,\n\t\tpan: pans,\n\t} = parameters;\n\n\tconst {\n\t\tbuffer,\n\t\tloopStart,\n\t\tloopEnd,\n\t\tloopCrossfade,\n\t\tstopWhen,\n\t\tplayedSamples,\n\t\tenableLowpass,\n\t\tenableHighpass,\n\t\tenableGain,\n\t\tenablePan,\n\t\tenableDetune,\n\t\tenableFadeOut,\n\t\tenableFadeIn,\n\t\tenableLoopStart,\n\t\tenableLoopEnd,\n\t\tenableLoopCrossfade,\n\t\tplayhead,\n\t\tfadeInDuration,\n\t\tfadeOutDuration,\n\t} = props;\n\tconst hasIncompleteStream =\n\t\tprops.streamBuffer.streaming &&\n\t\tprops.streamBuffer.committedLength < sourceLength;\n\tconst loop = props.loop && !hasIncompleteStream;\n\n\tconst nc = Math.min(buffer.length, output0.length);\n\tconst durationSamples = props.duration * ctx.sampleRate;\n\n\tconst loopCrossfadeSamples = Math.floor(ctx.sampleRate * loopCrossfade);\n\tconst maxLoopStartSample = Math.max(sourceLength - SAMPLE_BLOCK_SIZE, 0);\n\tconst loopStartSamples = enableLoopStart\n\t\t? Math.min(Math.floor(loopStart * ctx.sampleRate), maxLoopStartSample)\n\t\t: 0;\n\tconst loopEndSamples = enableLoopEnd\n\t\t? Math.min(Math.floor(loopEnd * ctx.sampleRate), sourceLength)\n\t\t: sourceLength;\n\tconst loopLengthSamples = loopEndSamples - loopStartSamples;\n\n\t// Apply detune to playback rates: effectiveRate = rate * 2^(detune/1200)\n\tconst needsDetune = enableDetune && detunes.length > 0 && detunes[0] !== 0;\n\tlet effectiveRates = playbackRates;\n\tif (needsDetune) {\n\t\tconst len = Math.max(\n\t\t\tplaybackRates.length,\n\t\t\tdetunes.length,\n\t\t\tSAMPLE_BLOCK_SIZE,\n\t\t);\n\t\teffectiveRates = new Float32Array(len);\n\t\tfor (let i = 0; i < len; i++) {\n\t\t\tconst rate = playbackRates[i] ?? playbackRates[playbackRates.length - 1];\n\t\t\tconst cents = detunes[i] ?? detunes[detunes.length - 1];\n\t\t\teffectiveRates[i] = rate * 2 ** (cents / 1200);\n\t\t}\n\t}\n\n\tconst useRateIndexing = props.enablePlaybackRate || needsDetune;\n\tconst isZeroRateBlock =\n\t\tuseRateIndexing &&\n\t\teffectiveRates.length > 0 &&\n\t\teffectiveRates.every((rate) => rate === 0);\n\n\tif (\n\t\tprops.streamBuffer.streaming &&\n\t\t!props.streamBuffer.streamEnded &&\n\t\t!props.streamBuffer.lowWaterNotified &&\n\t\tprops.streamBuffer.committedLength - Math.floor(playhead) <\n\t\t\tprops.streamBuffer.lowWaterThreshold\n\t) {\n\t\tmessages.push({\n\t\t\ttype: \"bufferLowWater\",\n\t\t\tdata: {\n\t\t\t\tplayhead: Math.floor(playhead),\n\t\t\t\tcommittedLength: props.streamBuffer.committedLength,\n\t\t\t},\n\t\t});\n\t\tprops.streamBuffer.lowWaterNotified = true;\n\t}\n\n\tif (isZeroRateBlock) {\n\t\tfillWithSilence(output0);\n\t\tfor (let i = 1; i < outputs.length; i++) {\n\t\t\tcopy(output0, outputs[i]);\n\t\t}\n\t\treturn { keepAlive: true, messages };\n\t}\n\n\tconst blockParams: BlockParameters = {\n\t\tbufferLength: sourceLength,\n\t\tloop,\n\t\tplayhead,\n\t\tloopStartSamples,\n\t\tloopEndSamples,\n\t\tdurationSamples,\n\t\tplaybackRates: effectiveRates,\n\t};\n\n\tconst {\n\t\tindexes,\n\t\tended,\n\t\tlooped,\n\t\tplayhead: updatedPlayhead,\n\t} = useRateIndexing\n\t\t? findIndexesWithPlaybackRates(blockParams)\n\t\t: findIndexesNormal(blockParams);\n\n\tconst underrunSample = indexes.find(\n\t\t(index) =>\n\t\t\tindex >= props.streamBuffer.committedLength && index < sourceLength,\n\t);\n\tif (\n\t\tunderrunSample !== undefined &&\n\t\t!props.streamBuffer.streamEnded &&\n\t\tprops.streamBuffer.lastUnderrunSample !== underrunSample\n\t) {\n\t\tmessages.push({\n\t\t\ttype: \"bufferUnderrun\",\n\t\t\tdata: {\n\t\t\t\tplayhead: Math.floor(playhead),\n\t\t\t\tcommittedLength: props.streamBuffer.committedLength,\n\t\t\t\trequestedSample: underrunSample,\n\t\t\t},\n\t\t});\n\t\tprops.streamBuffer.lastUnderrunSample = underrunSample;\n\t} else if (underrunSample === undefined) {\n\t\tprops.streamBuffer.lastUnderrunSample = null;\n\t}\n\n\tfill(output0, buffer, indexes);\n\n\t// --- Loop crossfade ---\n\tconst xfadeNumSamples = Math.min(\n\t\tMath.floor(loopCrossfade * ctx.sampleRate),\n\t\tloopLengthSamples,\n\t);\n\tconst isWithinLoopRange =\n\t\tloop && playhead > loopStartSamples && playhead < loopEndSamples;\n\tconst needsCrossfade =\n\t\tenableLoopCrossfade &&\n\t\tloopCrossfadeSamples > 0 &&\n\t\tsourceLength > SAMPLE_BLOCK_SIZE;\n\n\tif (isWithinLoopRange && needsCrossfade) {\n\t\t// Crossfade out at loop start: fade out tail of previous loop iteration.\n\t\t// Source: reads from END of loop (loopEnd - xfade to loopEnd).\n\t\t{\n\t\t\tconst endIndex = loopStartSamples + xfadeNumSamples;\n\t\t\tif (\n\t\t\t\txfadeNumSamples > 0 &&\n\t\t\t\tplayhead > loopStartSamples &&\n\t\t\t\tplayhead < endIndex\n\t\t\t) {\n\t\t\t\tconst elapsed = playhead - loopStartSamples;\n\t\t\t\tconst n = Math.min(Math.floor(endIndex - playhead), SAMPLE_BLOCK_SIZE);\n\t\t\t\tfor (let i = 0; i < n; i++) {\n\t\t\t\t\tconst position = (elapsed + i) / xfadeNumSamples;\n\t\t\t\t\tconst g = Math.cos((Math.PI * position) / 2);\n\t\t\t\t\tconst srcIdx = Math.floor(\n\t\t\t\t\t\tloopEndSamples - xfadeNumSamples + elapsed + i,\n\t\t\t\t\t);\n\t\t\t\t\tif (srcIdx >= 0 && srcIdx < sourceLength) {\n\t\t\t\t\t\tfor (let ch = 0; ch < nc; ch++) {\n\t\t\t\t\t\t\toutput0[ch][i] += buffer[ch][srcIdx] * g;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Crossfade in approaching loop end: fade in head of next loop iteration.\n\t\t// Source: reads from START of loop (loopStart to loopStart + xfade).\n\t\t{\n\t\t\tconst startIndex = loopEndSamples - xfadeNumSamples;\n\t\t\tif (\n\t\t\t\txfadeNumSamples > 0 &&\n\t\t\t\tplayhead > startIndex &&\n\t\t\t\tplayhead < loopEndSamples\n\t\t\t) {\n\t\t\t\tconst elapsed = playhead - startIndex;\n\t\t\t\tconst n = Math.min(\n\t\t\t\t\tMath.floor(loopEndSamples - playhead),\n\t\t\t\t\tSAMPLE_BLOCK_SIZE,\n\t\t\t\t);\n\t\t\t\tfor (let i = 0; i < n; i++) {\n\t\t\t\t\tconst position = (elapsed + i) / xfadeNumSamples;\n\t\t\t\t\tconst g = Math.sin((Math.PI * position) / 2);\n\t\t\t\t\tconst srcIdx = Math.floor(loopStartSamples + elapsed + i);\n\t\t\t\t\tif (srcIdx >= 0 && srcIdx < sourceLength) {\n\t\t\t\t\t\tfor (let ch = 0; ch < nc; ch++) {\n\t\t\t\t\t\t\toutput0[ch][i] += buffer[ch][srcIdx] * g;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// --- Fade in ---\n\tif (enableFadeIn && fadeInDuration > 0) {\n\t\tconst fadeInSamples = Math.floor(fadeInDuration * ctx.sampleRate);\n\t\tconst remaining = fadeInSamples - playedSamples;\n\t\tif (remaining > 0) {\n\t\t\tconst n = Math.min(remaining, SAMPLE_BLOCK_SIZE);\n\t\t\tfor (let i = 0; i < n; i++) {\n\t\t\t\tconst t = (playedSamples + i) / fadeInSamples;\n\t\t\t\tconst g = t * t * t; // cubic: slow start, fast finish\n\t\t\t\tfor (let ch = 0; ch < nc; ch++) {\n\t\t\t\t\toutput0[ch][i] *= g;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// --- Fade out ---\n\tif (enableFadeOut && fadeOutDuration > 0) {\n\t\tconst fadeOutSamples = Math.floor(fadeOutDuration * ctx.sampleRate);\n\t\tconst remainingSamples = Math.floor(\n\t\t\tctx.sampleRate * (stopWhen - ctx.currentTime),\n\t\t);\n\t\tif (remainingSamples < fadeOutSamples + SAMPLE_BLOCK_SIZE) {\n\t\t\tfor (let i = 0; i < SAMPLE_BLOCK_SIZE; i++) {\n\t\t\t\tconst sampleRemaining = remainingSamples - i;\n\t\t\t\tif (sampleRemaining >= fadeOutSamples) continue; // not yet in fade zone\n\t\t\t\tconst t = sampleRemaining <= 0 ? 0 : sampleRemaining / fadeOutSamples;\n\t\t\t\tconst g = t * t * t; // cubic fade-out: fast drop, slow tail\n\t\t\t\tfor (let ch = 0; ch < nc; ch++) {\n\t\t\t\t\toutput0[ch][i] *= g;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// --- Filters ---\n\tif (enableLowpass)\n\t\tlowpassFilter(output0, lowpass, ctx.sampleRate, filterState.lowpass);\n\tif (enableHighpass)\n\t\thighpassFilter(output0, highpass, ctx.sampleRate, filterState.highpass);\n\tif (enableGain) gainFilter(output0, gains);\n\tif (nc === 1) monoToStereo(output0);\n\tif (enablePan) panFilter(output0, pans);\n\n\tif (looped) {\n\t\tprops.timesLooped++;\n\t\tmessages.push({ type: \"looped\", data: props.timesLooped });\n\t}\n\tif (ended) {\n\t\tprops.state = State.Ended;\n\t\tmessages.push({ type: \"ended\" });\n\t}\n\n\tprops.playedSamples += indexes.length;\n\tprops.playhead = updatedPlayhead;\n\n\tconst numNans = checkNans(output0);\n\tif (numNans > 0) {\n\t\tconsole.log({\n\t\t\tnumNans,\n\t\t\tindexes,\n\t\t\tplayhead: updatedPlayhead,\n\t\t\tended,\n\t\t\tlooped,\n\t\t\tsourceLength,\n\t\t});\n\t\treturn { keepAlive: true, messages };\n\t}\n\n\tfor (let i = 1; i < outputs.length; i++) {\n\t\tcopy(output0, outputs[i]);\n\t}\n\treturn { keepAlive: true, messages };\n}\n",
7
7
  "// AudioWorklet processor — runs in AudioWorkletGlobalScope\n// Bundled separately and served at /processor.js\n// This is a thin shell — all DSP logic lives in processor-kernel.ts\n\ndeclare const currentTime: number;\ndeclare const currentFrame: number;\ndeclare const sampleRate: number;\ndeclare class AudioWorkletProcessor {\n\treadonly port: MessagePort;\n\tconstructor(options?: AudioWorkletNodeOptions);\n\tprocess(\n\t\tinputs: Float32Array[][],\n\t\toutputs: Float32Array[][],\n\t\tparameters: Record<string, Float32Array>,\n\t): boolean;\n}\n\ndeclare function registerProcessor(\n\tname: string,\n\tctor: new (options?: AudioWorkletNodeOptions) => AudioWorkletProcessor,\n): void;\n\nimport {\n\tcreateFilterState,\n\tgetProperties,\n\thandleProcessorMessage,\n\tprocessBlock,\n} from \"./processor-kernel\";\nimport type { ClipProcessorOptions, ProcessorWorkletOptions } from \"./types\";\nimport { State } from \"./types\";\n\nclass ClipProcessor extends AudioWorkletProcessor {\n\tstatic get parameterDescriptors() {\n\t\treturn [\n\t\t\t{\n\t\t\t\tname: \"playbackRate\",\n\t\t\t\tautomationRate: \"a-rate\" as const,\n\t\t\t\tdefaultValue: 1.0,\n\t\t\t},\n\t\t\t{ name: \"detune\", automationRate: \"a-rate\" as const, defaultValue: 0 },\n\t\t\t{\n\t\t\t\tname: \"gain\",\n\t\t\t\tautomationRate: \"a-rate\" as const,\n\t\t\t\tdefaultValue: 1,\n\t\t\t\tminValue: 0,\n\t\t\t},\n\t\t\t{ name: \"pan\", automationRate: \"a-rate\" as const, defaultValue: 0 },\n\t\t\t{\n\t\t\t\tname: \"highpass\",\n\t\t\t\tautomationRate: \"a-rate\" as const,\n\t\t\t\tdefaultValue: 20,\n\t\t\t\tminValue: 20,\n\t\t\t\tmaxValue: 20000,\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: \"lowpass\",\n\t\t\t\tautomationRate: \"a-rate\" as const,\n\t\t\t\tdefaultValue: 20000,\n\t\t\t\tminValue: 20,\n\t\t\t\tmaxValue: 20000,\n\t\t\t},\n\t\t];\n\t}\n\n\tproperties: Required<ClipProcessorOptions>;\n\tprivate filterState = {\n\t\tlowpass: createFilterState(),\n\t\thighpass: createFilterState(),\n\t};\n\tprivate lastFrameTime = 0;\n\n\tconstructor(options?: ProcessorWorkletOptions) {\n\t\tsuper(options);\n\t\tthis.properties = getProperties(options?.processorOptions, sampleRate);\n\t\tthis.port.onmessage = (ev: MessageEvent) => {\n\t\t\tconst messages = handleProcessorMessage(\n\t\t\t\tthis.properties,\n\t\t\t\tev.data,\n\t\t\t\tcurrentTime,\n\t\t\t\tsampleRate,\n\t\t\t);\n\t\t\tfor (const msg of messages) this.port.postMessage(msg);\n\t\t\tif (this.properties.state === State.Disposed) this.port.close();\n\t\t};\n\t}\n\n\tprocess(\n\t\t_inputs: Float32Array[][],\n\t\toutputs: Float32Array[][],\n\t\tparameters: Record<string, Float32Array>,\n\t): boolean {\n\t\ttry {\n\t\t\tconst result = processBlock(\n\t\t\t\tthis.properties,\n\t\t\t\toutputs,\n\t\t\t\tparameters,\n\t\t\t\t{ currentTime, currentFrame, sampleRate },\n\t\t\t\tthis.filterState,\n\t\t\t);\n\t\t\tfor (const msg of result.messages) this.port.postMessage(msg);\n\n\t\t\t// Frame reporting\n\t\t\tconst timeTaken = currentTime - this.lastFrameTime;\n\t\t\tthis.lastFrameTime = currentTime;\n\t\t\tthis.port.postMessage({\n\t\t\t\ttype: \"frame\",\n\t\t\t\tdata: [\n\t\t\t\t\tcurrentTime,\n\t\t\t\t\tcurrentFrame,\n\t\t\t\t\tMath.floor(this.properties.playhead),\n\t\t\t\t\ttimeTaken * 1000,\n\t\t\t\t],\n\t\t\t});\n\n\t\t\treturn result.keepAlive;\n\t\t} catch (e) {\n\t\t\tconsole.log(e);\n\t\t\treturn true;\n\t\t}\n\t}\n}\n\nregisterProcessor(\"ClipProcessor\", ClipProcessor);\n"
8
8
  ],
9
- "mappings": "AAAO,IAAM,EA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GAAc,GAAS,iBAAkB,UAAU,EACrE,KAAK,KAAK,UAAY,CAAC,IAAqB,CAC3C,IAAM,EAAW,GAChB,KAAK,WACL,EAAG,KACH,YACA,UACD,EACA,QAAW,KAAO,EAAU,KAAK,KAAK,YAAY,CAAG,EACrD,GAAI,KAAK,WAAW,QAAU,EAAM,SAAU,KAAK,KAAK,MAAM,GAIhE,OAAO,CACN,EACA,EACA,EACU,CACV,GAAI,CACH,IAAM,EAAS,GACd,KAAK,WACL,EACA,EACA,CAAE,YAAa,aAAc,UAAW,EACxC,KAAK,WACN,EACA,QAAW,KAAO,EAAO,SAAU,KAAK,KAAK,YAAY,CAAG,EAG5D,IAAM,EAAY,YAAc,KAAK,cAYrC,OAXA,KAAK,cAAgB,YACrB,KAAK,KAAK,YAAY,CACrB,KAAM,QACN,KAAM,CACL,YACA,aACA,KAAK,MAAM,KAAK,WAAW,QAAQ,EACnC,EAAY,IACb,CACD,CAAC,EAEM,EAAO,UACb,MAAO,EAAG,CAEX,OADA,QAAQ,IAAI,CAAC,EACN,IAGV,CAEA,kBAAkB,gBAAiB,EAAa",
10
+ "debugId": "E1A630180247A19C64756E2164756E21",
11
11
  "names": []
12
12
  }
@@ -9,5 +9,5 @@ Everything is loaded from [jsDelivr](https://www.jsdelivr.com/).
9
9
  > imports.
10
10
 
11
11
  ```sh
12
- npx serve .
12
+ bun index.html
13
13
  ```
@@ -15,15 +15,6 @@
15
15
  <button id="play" type="button">▶ Play</button>
16
16
  <button id="stop" type="button">■ Stop</button>
17
17
  <p id="status">Click Play to start (loads a sample tone).</p>
18
-
19
- <script>
20
- if (location.protocol === "file:") {
21
- document.getElementById("status").textContent =
22
- "⚠ This page must be served over HTTP. Run: npx serve .";
23
- document.getElementById("play").disabled = true;
24
- }
25
- </script>
26
-
27
18
  <script type="module">
28
19
  // Import the bundled library from the CDN (single file, no module resolution needed)
29
20
  import { ClipNode, getProcessorCdnUrl } from "https://cdn.jsdelivr.net/npm/@jadujoel/web-audio-clip-node/dist/lib.bundle.js";
@@ -46,11 +37,8 @@
46
37
  document.getElementById("play").addEventListener("click", async () => {
47
38
  if (!ctx) {
48
39
  ctx = new AudioContext();
49
- const processorUrl = getProcessorCdnUrl("0.1.1");
50
- await ctx.audioWorklet.addModule(processorUrl);
51
- clip = new ClipNode(ctx, {
52
- processorOptions: { sampleRate: ctx.sampleRate },
53
- });
40
+ await ctx.audioWorklet.addModule("https://cdn.jsdelivr.net/npm/@jadujoel/web-audio-clip-node/dist/processor.js");
41
+ clip = new ClipNode(ctx);
54
42
  clip.connect(ctx.destination);
55
43
  clip.buffer = createToneBuffer(ctx);
56
44
  }
@@ -1,8 +1,7 @@
1
- # ESM Bundler Example (Vite + TypeScript)
1
+ # ESM Bundler Example (Bun + TypeScript)
2
2
 
3
- Uses `npm install` + Vite. The processor is loaded via `getProcessorBlobUrl()` (embedded, zero-config).
3
+ The processor is loaded via `getProcessorBlobUrl()` (embedded, zero-config).
4
4
 
5
5
  ```sh
6
- npm install
7
- npm run dev
6
+ bun run dev
8
7
  ```
@@ -0,0 +1,15 @@
1
+ {
2
+ "lockfileVersion": 1,
3
+ "configVersion": 0,
4
+ "workspaces": {
5
+ "": {
6
+ "name": "esm-bundler-example",
7
+ "dependencies": {
8
+ "@jadujoel/web-audio-clip-node": "^0.1.2",
9
+ },
10
+ },
11
+ },
12
+ "packages": {
13
+ "@jadujoel/web-audio-clip-node": ["@jadujoel/web-audio-clip-node@0.1.2", "", { "peerDependencies": { "react": ">=18", "react-dom": ">=18", "zustand": ">=4" }, "optionalPeers": ["react", "react-dom", "zustand"] }, "sha512-u9r9AYcGul3QYtBwBvc//ZoR7xvigU85Tt4MZ13TTNJE4/s9NAIuOjTOOt/mfkzqa3+Sv+K2QF+3b/dSqYZM5A=="],
14
+ }
15
+ }
@@ -7,6 +7,6 @@
7
7
  </head>
8
8
  <body>
9
9
  <div id="app"></div>
10
- <script type="module" src="./src/main.ts"></script>
10
+ <script type="module" src="./main.ts"></script>
11
11
  </body>
12
12
  </html>
@@ -2,7 +2,7 @@ import { ClipNode, getProcessorBlobUrl } from "@jadujoel/web-audio-clip-node";
2
2
 
3
3
  const app = document.getElementById("app")!;
4
4
  app.innerHTML = `
5
- <h1>ClipNode – Vite + TypeScript</h1>
5
+ <h1>ClipNode</h1>
6
6
  <button id="play">▶ Play</button>
7
7
  <button id="stop">■ Stop</button>
8
8
  <p id="status">Click Play to start.</p>
@@ -25,9 +25,7 @@ document.getElementById("play")!.addEventListener("click", async () => {
25
25
  if (!ctx) {
26
26
  ctx = new AudioContext();
27
27
  await ctx.audioWorklet.addModule(getProcessorBlobUrl());
28
- clip = new ClipNode(ctx, {
29
- processorOptions: { sampleRate: ctx.sampleRate },
30
- });
28
+ clip = new ClipNode(ctx);
31
29
  clip.connect(ctx.destination);
32
30
  clip.buffer = createToneBuffer(ctx);
33
31
  }
@@ -3,13 +3,10 @@
3
3
  "private": true,
4
4
  "type": "module",
5
5
  "scripts": {
6
- "dev": "vite",
7
- "build": "vite build"
6
+ "dev": "bun index.html",
7
+ "build": "bun build ./src/main.ts --outdir=dist --minify"
8
8
  },
9
9
  "dependencies": {
10
- "@jadujoel/web-audio-clip-node": "^0.1.1"
11
- },
12
- "devDependencies": {
13
- "vite": "^6"
10
+ "@jadujoel/web-audio-clip-node": "^0.1.2"
14
11
  }
15
12
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jadujoel/web-audio-clip-node",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "type": "module",
5
5
  "description": "Full-featured AudioWorklet clip player with playback rate, detune, gain, pan, filters, looping, fades, crossfade, and streaming buffer support. React components included.",
6
6
  "keywords": [