@drop-ai/core 0.2.0 → 0.3.1

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 (513) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +734 -316
  3. package/dist/actions/ActionRegistry.d.ts.map +1 -1
  4. package/dist/actions/ActionRegistry.js +7 -2
  5. package/dist/actions/ActionRegistry.js.map +1 -1
  6. package/dist/actions/types.d.ts +7 -1
  7. package/dist/actions/types.d.ts.map +1 -1
  8. package/dist/analysis/AudioAnalyzer.d.ts +69 -0
  9. package/dist/analysis/AudioAnalyzer.d.ts.map +1 -0
  10. package/dist/analysis/AudioAnalyzer.js +567 -0
  11. package/dist/analysis/AudioAnalyzer.js.map +1 -0
  12. package/dist/audio/AudioEngine.d.ts +14 -1
  13. package/dist/audio/AudioEngine.d.ts.map +1 -1
  14. package/dist/audio/AudioEngine.js +115 -35
  15. package/dist/audio/AudioEngine.js.map +1 -1
  16. package/dist/audio/Auditioner.d.ts +102 -0
  17. package/dist/audio/Auditioner.d.ts.map +1 -0
  18. package/dist/audio/Auditioner.js +237 -0
  19. package/dist/audio/Auditioner.js.map +1 -0
  20. package/dist/audio/BWFMetadata.d.ts +114 -0
  21. package/dist/audio/BWFMetadata.d.ts.map +1 -0
  22. package/dist/audio/BWFMetadata.js +392 -0
  23. package/dist/audio/BWFMetadata.js.map +1 -0
  24. package/dist/audio/BufferPool.d.ts +0 -3
  25. package/dist/audio/BufferPool.d.ts.map +1 -1
  26. package/dist/audio/BufferPool.js +0 -3
  27. package/dist/audio/BufferPool.js.map +1 -1
  28. package/dist/audio/ChannelSplitter.d.ts +36 -0
  29. package/dist/audio/ChannelSplitter.d.ts.map +1 -0
  30. package/dist/audio/ChannelSplitter.js +81 -0
  31. package/dist/audio/ChannelSplitter.js.map +1 -0
  32. package/dist/audio/ExportAnalyzer.d.ts +38 -0
  33. package/dist/audio/ExportAnalyzer.d.ts.map +1 -0
  34. package/dist/audio/ExportAnalyzer.js +75 -0
  35. package/dist/audio/ExportAnalyzer.js.map +1 -0
  36. package/dist/audio/LufsNormalizer.d.ts +36 -0
  37. package/dist/audio/LufsNormalizer.d.ts.map +1 -0
  38. package/dist/audio/LufsNormalizer.js +216 -0
  39. package/dist/audio/LufsNormalizer.js.map +1 -0
  40. package/dist/audio/MeterUtils.d.ts +0 -2
  41. package/dist/audio/MeterUtils.d.ts.map +1 -1
  42. package/dist/audio/MeterUtils.js +0 -2
  43. package/dist/audio/MeterUtils.js.map +1 -1
  44. package/dist/audio/OfflineExporter.d.ts +1 -7
  45. package/dist/audio/OfflineExporter.d.ts.map +1 -1
  46. package/dist/audio/OfflineExporter.js +31 -11
  47. package/dist/audio/OfflineExporter.js.map +1 -1
  48. package/dist/audio/ProcessingGraph.d.ts +0 -1
  49. package/dist/audio/ProcessingGraph.d.ts.map +1 -1
  50. package/dist/audio/ProcessingGraph.js +0 -1
  51. package/dist/audio/ProcessingGraph.js.map +1 -1
  52. package/dist/audio/RoutingGraph.d.ts +134 -0
  53. package/dist/audio/RoutingGraph.d.ts.map +1 -0
  54. package/dist/audio/RoutingGraph.js +547 -0
  55. package/dist/audio/RoutingGraph.js.map +1 -0
  56. package/dist/audio/SampleRateConverter.d.ts +20 -0
  57. package/dist/audio/SampleRateConverter.d.ts.map +1 -0
  58. package/dist/audio/SampleRateConverter.js +83 -0
  59. package/dist/audio/SampleRateConverter.js.map +1 -0
  60. package/dist/audio/SilencePadding.d.ts +27 -0
  61. package/dist/audio/SilencePadding.d.ts.map +1 -0
  62. package/dist/audio/SilencePadding.js +84 -0
  63. package/dist/audio/SilencePadding.js.map +1 -0
  64. package/dist/audio/SourceCache.d.ts +13 -19
  65. package/dist/audio/SourceCache.d.ts.map +1 -1
  66. package/dist/audio/SourceCache.js +21 -36
  67. package/dist/audio/SourceCache.js.map +1 -1
  68. package/dist/audio/engine/Declick.d.ts +97 -0
  69. package/dist/audio/engine/Declick.d.ts.map +1 -0
  70. package/dist/audio/engine/Declick.js +203 -0
  71. package/dist/audio/engine/Declick.js.map +1 -0
  72. package/dist/audio/engine/DiskIO.d.ts +170 -0
  73. package/dist/audio/engine/DiskIO.d.ts.map +1 -0
  74. package/dist/audio/engine/DiskIO.js +382 -0
  75. package/dist/audio/engine/DiskIO.js.map +1 -0
  76. package/dist/audio/engine/LatencyCompensator.d.ts +46 -0
  77. package/dist/audio/engine/LatencyCompensator.d.ts.map +1 -0
  78. package/dist/audio/engine/LatencyCompensator.js +84 -0
  79. package/dist/audio/engine/LatencyCompensator.js.map +1 -0
  80. package/dist/audio/engine/MultiTrackRecorder.d.ts +144 -0
  81. package/dist/audio/engine/MultiTrackRecorder.d.ts.map +1 -0
  82. package/dist/audio/engine/MultiTrackRecorder.js +359 -0
  83. package/dist/audio/engine/MultiTrackRecorder.js.map +1 -0
  84. package/dist/audio/engine/PlaylistEngine.d.ts +1 -1
  85. package/dist/audio/engine/PlaylistEngine.d.ts.map +1 -1
  86. package/dist/audio/engine/PlaylistEngine.js +10 -3
  87. package/dist/audio/engine/PlaylistEngine.js.map +1 -1
  88. package/dist/audio/engine/PunchRecordManager.d.ts +111 -0
  89. package/dist/audio/engine/PunchRecordManager.d.ts.map +1 -0
  90. package/dist/audio/engine/PunchRecordManager.js +191 -0
  91. package/dist/audio/engine/PunchRecordManager.js.map +1 -0
  92. package/dist/audio/engine/RoutingGraph.d.ts +133 -0
  93. package/dist/audio/engine/RoutingGraph.d.ts.map +1 -0
  94. package/dist/audio/engine/RoutingGraph.js +436 -0
  95. package/dist/audio/engine/RoutingGraph.js.map +1 -0
  96. package/dist/audio/engine/SidechainRouter.d.ts +137 -0
  97. package/dist/audio/engine/SidechainRouter.d.ts.map +1 -0
  98. package/dist/audio/engine/SidechainRouter.js +290 -0
  99. package/dist/audio/engine/SidechainRouter.js.map +1 -0
  100. package/dist/audio/engine/XrunTracker.d.ts +71 -0
  101. package/dist/audio/engine/XrunTracker.d.ts.map +1 -0
  102. package/dist/audio/engine/XrunTracker.js +118 -0
  103. package/dist/audio/engine/XrunTracker.js.map +1 -0
  104. package/dist/audio/export/CDMarkerExporter.d.ts +60 -0
  105. package/dist/audio/export/CDMarkerExporter.d.ts.map +1 -0
  106. package/dist/audio/export/CDMarkerExporter.js +162 -0
  107. package/dist/audio/export/CDMarkerExporter.js.map +1 -0
  108. package/dist/audio/export/ExportGraphBuilder.d.ts +119 -0
  109. package/dist/audio/export/ExportGraphBuilder.d.ts.map +1 -0
  110. package/dist/audio/export/ExportGraphBuilder.js +520 -0
  111. package/dist/audio/export/ExportGraphBuilder.js.map +1 -0
  112. package/dist/audio/export/ExportPresetManager.d.ts +85 -0
  113. package/dist/audio/export/ExportPresetManager.d.ts.map +1 -0
  114. package/dist/audio/export/ExportPresetManager.js +304 -0
  115. package/dist/audio/export/ExportPresetManager.js.map +1 -0
  116. package/dist/automation/AutomationList.d.ts +0 -1
  117. package/dist/automation/AutomationList.d.ts.map +1 -1
  118. package/dist/automation/AutomationList.js +0 -1
  119. package/dist/automation/AutomationList.js.map +1 -1
  120. package/dist/automation/AutomationMode.d.ts +0 -1
  121. package/dist/automation/AutomationMode.d.ts.map +1 -1
  122. package/dist/automation/AutomationMode.js +0 -1
  123. package/dist/automation/AutomationMode.js.map +1 -1
  124. package/dist/commands/CommandHistory.d.ts +1 -4
  125. package/dist/commands/CommandHistory.d.ts.map +1 -1
  126. package/dist/commands/CommandHistory.js +6 -9
  127. package/dist/commands/CommandHistory.js.map +1 -1
  128. package/dist/commands/CommandRegistry.d.ts +1 -2
  129. package/dist/commands/CommandRegistry.d.ts.map +1 -1
  130. package/dist/commands/CommandRegistry.js +1 -2
  131. package/dist/commands/CommandRegistry.js.map +1 -1
  132. package/dist/commands/UndoTransaction.d.ts +0 -2
  133. package/dist/commands/UndoTransaction.d.ts.map +1 -1
  134. package/dist/commands/UndoTransaction.js +1 -3
  135. package/dist/commands/UndoTransaction.js.map +1 -1
  136. package/dist/commands/handlers/HistoryHandler.d.ts +5 -5
  137. package/dist/commands/handlers/HistoryHandler.js +10 -10
  138. package/dist/commands/handlers/HistoryHandler.js.map +1 -1
  139. package/dist/commands/handlers/MarkerHandler.d.ts +0 -1
  140. package/dist/commands/handlers/MarkerHandler.d.ts.map +1 -1
  141. package/dist/commands/handlers/MarkerHandler.js +0 -1
  142. package/dist/commands/handlers/MarkerHandler.js.map +1 -1
  143. package/dist/commands/handlers/RegionHandler.d.ts.map +1 -1
  144. package/dist/commands/handlers/RegionHandler.js +25 -1
  145. package/dist/commands/handlers/RegionHandler.js.map +1 -1
  146. package/dist/commands/handlers/TrackHandler.js +1 -1
  147. package/dist/commands/handlers/TrackHandler.js.map +1 -1
  148. package/dist/commands/impl/CopyRegionCommand.d.ts +0 -1
  149. package/dist/commands/impl/CopyRegionCommand.d.ts.map +1 -1
  150. package/dist/commands/impl/CopyRegionCommand.js +0 -1
  151. package/dist/commands/impl/CopyRegionCommand.js.map +1 -1
  152. package/dist/commands/impl/DuplicateRegionCommand.d.ts +0 -1
  153. package/dist/commands/impl/DuplicateRegionCommand.d.ts.map +1 -1
  154. package/dist/commands/impl/DuplicateRegionCommand.js +0 -1
  155. package/dist/commands/impl/DuplicateRegionCommand.js.map +1 -1
  156. package/dist/commands/impl/ExportCommand.d.ts +0 -1
  157. package/dist/commands/impl/ExportCommand.d.ts.map +1 -1
  158. package/dist/commands/impl/ExportCommand.js +0 -1
  159. package/dist/commands/impl/ExportCommand.js.map +1 -1
  160. package/dist/commands/impl/FreezeTrackCommand.d.ts +1 -1
  161. package/dist/commands/impl/FreezeTrackCommand.d.ts.map +1 -1
  162. package/dist/commands/impl/FreezeTrackCommand.js +38 -37
  163. package/dist/commands/impl/FreezeTrackCommand.js.map +1 -1
  164. package/dist/commands/impl/PasteRegionCommand.d.ts +0 -1
  165. package/dist/commands/impl/PasteRegionCommand.d.ts.map +1 -1
  166. package/dist/commands/impl/PasteRegionCommand.js +0 -1
  167. package/dist/commands/impl/PasteRegionCommand.js.map +1 -1
  168. package/dist/commands/impl/SaveSnapshotCommand.d.ts +1 -1
  169. package/dist/commands/impl/SaveSnapshotCommand.js +1 -1
  170. package/dist/commands/impl/SetLoopRangeCommand.d.ts +0 -1
  171. package/dist/commands/impl/SetLoopRangeCommand.d.ts.map +1 -1
  172. package/dist/commands/impl/SetLoopRangeCommand.js +0 -1
  173. package/dist/commands/impl/SetLoopRangeCommand.js.map +1 -1
  174. package/dist/commands/impl/SetPunchRangeCommand.d.ts +0 -1
  175. package/dist/commands/impl/SetPunchRangeCommand.d.ts.map +1 -1
  176. package/dist/commands/impl/SetPunchRangeCommand.js +0 -1
  177. package/dist/commands/impl/SetPunchRangeCommand.js.map +1 -1
  178. package/dist/commands/impl/SetRegionTimeDomainCommand.d.ts.map +1 -1
  179. package/dist/commands/impl/SetRegionTimeDomainCommand.js +3 -3
  180. package/dist/commands/impl/SetRegionTimeDomainCommand.js.map +1 -1
  181. package/dist/commands/impl/SplitAtPlayheadCommand.d.ts +0 -2
  182. package/dist/commands/impl/SplitAtPlayheadCommand.d.ts.map +1 -1
  183. package/dist/commands/impl/SplitAtPlayheadCommand.js +0 -2
  184. package/dist/commands/impl/SplitAtPlayheadCommand.js.map +1 -1
  185. package/dist/commands/impl/SplitRegionCommand.d.ts +0 -1
  186. package/dist/commands/impl/SplitRegionCommand.d.ts.map +1 -1
  187. package/dist/commands/impl/SplitRegionCommand.js +0 -1
  188. package/dist/commands/impl/SplitRegionCommand.js.map +1 -1
  189. package/dist/commands/impl/StripSilenceCommand.d.ts +0 -1
  190. package/dist/commands/impl/StripSilenceCommand.d.ts.map +1 -1
  191. package/dist/commands/impl/StripSilenceCommand.js +0 -1
  192. package/dist/commands/impl/StripSilenceCommand.js.map +1 -1
  193. package/dist/commands/impl/TimeStretchRegionCommand.d.ts +1 -2
  194. package/dist/commands/impl/TimeStretchRegionCommand.d.ts.map +1 -1
  195. package/dist/commands/impl/TimeStretchRegionCommand.js +1 -2
  196. package/dist/commands/impl/TimeStretchRegionCommand.js.map +1 -1
  197. package/dist/commands/impl/ToggleLoopCommand.d.ts +1 -0
  198. package/dist/commands/impl/ToggleLoopCommand.d.ts.map +1 -1
  199. package/dist/commands/impl/ToggleLoopCommand.js +10 -0
  200. package/dist/commands/impl/ToggleLoopCommand.js.map +1 -1
  201. package/dist/commands/impl/TrimRegionCommand.d.ts +14 -1
  202. package/dist/commands/impl/TrimRegionCommand.d.ts.map +1 -1
  203. package/dist/commands/impl/TrimRegionCommand.js +138 -33
  204. package/dist/commands/impl/TrimRegionCommand.js.map +1 -1
  205. package/dist/commands/impl/TrimRegionToPlayheadCommand.d.ts +26 -0
  206. package/dist/commands/impl/TrimRegionToPlayheadCommand.d.ts.map +1 -0
  207. package/dist/commands/impl/TrimRegionToPlayheadCommand.js +68 -0
  208. package/dist/commands/impl/TrimRegionToPlayheadCommand.js.map +1 -0
  209. package/dist/commands/impl/TrimRegionToRangeCommand.d.ts +27 -0
  210. package/dist/commands/impl/TrimRegionToRangeCommand.d.ts.map +1 -0
  211. package/dist/commands/impl/TrimRegionToRangeCommand.js +68 -0
  212. package/dist/commands/impl/TrimRegionToRangeCommand.js.map +1 -0
  213. package/dist/commands/impl/TrimToAdjacentRegionCommand.d.ts +26 -0
  214. package/dist/commands/impl/TrimToAdjacentRegionCommand.d.ts.map +1 -0
  215. package/dist/commands/impl/TrimToAdjacentRegionCommand.js +76 -0
  216. package/dist/commands/impl/TrimToAdjacentRegionCommand.js.map +1 -0
  217. package/dist/commands/types.d.ts +19 -0
  218. package/dist/commands/types.d.ts.map +1 -1
  219. package/dist/commands/types.js +21 -0
  220. package/dist/commands/types.js.map +1 -1
  221. package/dist/domain/ABComparison.d.ts +0 -1
  222. package/dist/domain/ABComparison.d.ts.map +1 -1
  223. package/dist/domain/ABComparison.js +0 -1
  224. package/dist/domain/ABComparison.js.map +1 -1
  225. package/dist/domain/CDMarker.d.ts +0 -1
  226. package/dist/domain/CDMarker.d.ts.map +1 -1
  227. package/dist/domain/CDMarker.js +0 -1
  228. package/dist/domain/CDMarker.js.map +1 -1
  229. package/dist/domain/ClockMode.d.ts +0 -1
  230. package/dist/domain/ClockMode.d.ts.map +1 -1
  231. package/dist/domain/ClockMode.js +0 -1
  232. package/dist/domain/ClockMode.js.map +1 -1
  233. package/dist/domain/Crossfade.d.ts +78 -0
  234. package/dist/domain/Crossfade.d.ts.map +1 -0
  235. package/dist/domain/Crossfade.js +216 -0
  236. package/dist/domain/Crossfade.js.map +1 -0
  237. package/dist/domain/DragManager.d.ts +0 -2
  238. package/dist/domain/DragManager.d.ts.map +1 -1
  239. package/dist/domain/DragManager.js +0 -2
  240. package/dist/domain/DragManager.js.map +1 -1
  241. package/dist/domain/EditMode.d.ts +0 -1
  242. package/dist/domain/EditMode.d.ts.map +1 -1
  243. package/dist/domain/EditMode.js +0 -1
  244. package/dist/domain/EditMode.js.map +1 -1
  245. package/dist/domain/ExportConfig.d.ts +98 -2
  246. package/dist/domain/ExportConfig.d.ts.map +1 -1
  247. package/dist/domain/ExportConfig.js +154 -2
  248. package/dist/domain/ExportConfig.js.map +1 -1
  249. package/dist/domain/ExportPreset.d.ts +60 -0
  250. package/dist/domain/ExportPreset.d.ts.map +1 -0
  251. package/dist/domain/ExportPreset.js +77 -0
  252. package/dist/domain/ExportPreset.js.map +1 -0
  253. package/dist/domain/ExportStatus.d.ts +0 -1
  254. package/dist/domain/ExportStatus.d.ts.map +1 -1
  255. package/dist/domain/ExportStatus.js +0 -1
  256. package/dist/domain/ExportStatus.js.map +1 -1
  257. package/dist/domain/GridSettings.d.ts +0 -3
  258. package/dist/domain/GridSettings.d.ts.map +1 -1
  259. package/dist/domain/GridSettings.js +0 -3
  260. package/dist/domain/GridSettings.js.map +1 -1
  261. package/dist/domain/ImportStatus.d.ts +40 -0
  262. package/dist/domain/ImportStatus.d.ts.map +1 -0
  263. package/dist/domain/ImportStatus.js +86 -0
  264. package/dist/domain/ImportStatus.js.map +1 -0
  265. package/dist/domain/Marker.d.ts +0 -1
  266. package/dist/domain/Marker.d.ts.map +1 -1
  267. package/dist/domain/Marker.js +0 -1
  268. package/dist/domain/Marker.js.map +1 -1
  269. package/dist/domain/MeterData.d.ts +0 -2
  270. package/dist/domain/MeterData.d.ts.map +1 -1
  271. package/dist/domain/MeterType.d.ts +0 -2
  272. package/dist/domain/MeterType.d.ts.map +1 -1
  273. package/dist/domain/MeterType.js +0 -2
  274. package/dist/domain/MeterType.js.map +1 -1
  275. package/dist/domain/MonitorMode.d.ts +0 -1
  276. package/dist/domain/MonitorMode.d.ts.map +1 -1
  277. package/dist/domain/MonitorMode.js +0 -1
  278. package/dist/domain/MonitorMode.js.map +1 -1
  279. package/dist/domain/MouseMode.d.ts +0 -1
  280. package/dist/domain/MouseMode.d.ts.map +1 -1
  281. package/dist/domain/MouseMode.js +0 -1
  282. package/dist/domain/MouseMode.js.map +1 -1
  283. package/dist/domain/OverlapType.d.ts +0 -2
  284. package/dist/domain/OverlapType.d.ts.map +1 -1
  285. package/dist/domain/OverlapType.js +0 -2
  286. package/dist/domain/OverlapType.js.map +1 -1
  287. package/dist/domain/Playlist.d.ts +72 -0
  288. package/dist/domain/Playlist.d.ts.map +1 -1
  289. package/dist/domain/Playlist.js +231 -6
  290. package/dist/domain/Playlist.js.map +1 -1
  291. package/dist/domain/Range.d.ts +0 -1
  292. package/dist/domain/Range.d.ts.map +1 -1
  293. package/dist/domain/Range.js +0 -1
  294. package/dist/domain/Range.js.map +1 -1
  295. package/dist/domain/RecordMode.d.ts +0 -1
  296. package/dist/domain/RecordMode.d.ts.map +1 -1
  297. package/dist/domain/RecordMode.js +0 -1
  298. package/dist/domain/RecordMode.js.map +1 -1
  299. package/dist/domain/Region.d.ts +76 -0
  300. package/dist/domain/Region.d.ts.map +1 -1
  301. package/dist/domain/Region.js +234 -1
  302. package/dist/domain/Region.js.map +1 -1
  303. package/dist/domain/RegionClipboard.d.ts +1 -3
  304. package/dist/domain/RegionClipboard.d.ts.map +1 -1
  305. package/dist/domain/RegionClipboard.js +1 -2
  306. package/dist/domain/RegionClipboard.js.map +1 -1
  307. package/dist/domain/Route.d.ts +43 -3
  308. package/dist/domain/Route.d.ts.map +1 -1
  309. package/dist/domain/Route.js +92 -6
  310. package/dist/domain/Route.js.map +1 -1
  311. package/dist/domain/RulerType.d.ts +0 -1
  312. package/dist/domain/RulerType.d.ts.map +1 -1
  313. package/dist/domain/RulerType.js +0 -1
  314. package/dist/domain/RulerType.js.map +1 -1
  315. package/dist/domain/SelectionHistory.d.ts +0 -3
  316. package/dist/domain/SelectionHistory.d.ts.map +1 -1
  317. package/dist/domain/SelectionHistory.js +0 -3
  318. package/dist/domain/SelectionHistory.js.map +1 -1
  319. package/dist/domain/SendBus.d.ts +0 -1
  320. package/dist/domain/SendBus.d.ts.map +1 -1
  321. package/dist/domain/SendBus.js +0 -1
  322. package/dist/domain/SendBus.js.map +1 -1
  323. package/dist/domain/Session.d.ts +31 -0
  324. package/dist/domain/Session.d.ts.map +1 -1
  325. package/dist/domain/Session.js +70 -0
  326. package/dist/domain/Session.js.map +1 -1
  327. package/dist/domain/SidechainConfig.d.ts +0 -1
  328. package/dist/domain/SidechainConfig.d.ts.map +1 -1
  329. package/dist/domain/SidechainConfig.js +0 -1
  330. package/dist/domain/SidechainConfig.js.map +1 -1
  331. package/dist/domain/Source.d.ts +145 -1
  332. package/dist/domain/Source.d.ts.map +1 -1
  333. package/dist/domain/Source.js +144 -1
  334. package/dist/domain/Source.js.map +1 -1
  335. package/dist/domain/Take.d.ts +0 -1
  336. package/dist/domain/Take.d.ts.map +1 -1
  337. package/dist/domain/Take.js +0 -1
  338. package/dist/domain/Take.js.map +1 -1
  339. package/dist/domain/ThawList.d.ts +36 -0
  340. package/dist/domain/ThawList.d.ts.map +1 -0
  341. package/dist/domain/ThawList.js +72 -0
  342. package/dist/domain/ThawList.js.map +1 -0
  343. package/dist/domain/Track.d.ts +93 -1
  344. package/dist/domain/Track.d.ts.map +1 -1
  345. package/dist/domain/Track.js +136 -0
  346. package/dist/domain/Track.js.map +1 -1
  347. package/dist/domain/TrackGroup.d.ts +0 -1
  348. package/dist/domain/TrackGroup.d.ts.map +1 -1
  349. package/dist/domain/TrackGroup.js +0 -1
  350. package/dist/domain/TrackGroup.js.map +1 -1
  351. package/dist/domain/TransportFSM.d.ts +0 -1
  352. package/dist/domain/TransportFSM.d.ts.map +1 -1
  353. package/dist/domain/TransportFSM.js +0 -1
  354. package/dist/domain/TransportFSM.js.map +1 -1
  355. package/dist/domain/TransportMode.d.ts +0 -1
  356. package/dist/domain/TransportMode.d.ts.map +1 -1
  357. package/dist/domain/TransportMode.js +0 -1
  358. package/dist/domain/TransportMode.js.map +1 -1
  359. package/dist/domain/TriggerBox.d.ts +121 -0
  360. package/dist/domain/TriggerBox.d.ts.map +1 -0
  361. package/dist/domain/TriggerBox.js +428 -0
  362. package/dist/domain/TriggerBox.js.map +1 -0
  363. package/dist/domain/VCATrack.d.ts +63 -2
  364. package/dist/domain/VCATrack.d.ts.map +1 -1
  365. package/dist/domain/VCATrack.js +127 -2
  366. package/dist/domain/VCATrack.js.map +1 -1
  367. package/dist/domain/VideoExportConfig.d.ts +116 -0
  368. package/dist/domain/VideoExportConfig.d.ts.map +1 -0
  369. package/dist/domain/VideoExportConfig.js +243 -0
  370. package/dist/domain/VideoExportConfig.js.map +1 -0
  371. package/dist/domain/VideoExportStatus.d.ts +89 -0
  372. package/dist/domain/VideoExportStatus.d.ts.map +1 -0
  373. package/dist/domain/VideoExportStatus.js +192 -0
  374. package/dist/domain/VideoExportStatus.js.map +1 -0
  375. package/dist/domain/VideoMetadata.d.ts +46 -0
  376. package/dist/domain/VideoMetadata.d.ts.map +1 -0
  377. package/dist/domain/VideoMetadata.js +2 -0
  378. package/dist/domain/VideoMetadata.js.map +1 -0
  379. package/dist/domain/ZoomFocus.d.ts +0 -1
  380. package/dist/domain/ZoomFocus.d.ts.map +1 -1
  381. package/dist/domain/ZoomFocus.js +0 -1
  382. package/dist/domain/ZoomFocus.js.map +1 -1
  383. package/dist/domain/index.d.ts +5 -0
  384. package/dist/domain/index.d.ts.map +1 -1
  385. package/dist/domain/index.js +5 -0
  386. package/dist/domain/index.js.map +1 -1
  387. package/dist/domain/temporal/TempoMap.d.ts +198 -2
  388. package/dist/domain/temporal/TempoMap.d.ts.map +1 -1
  389. package/dist/domain/temporal/TempoMap.js +464 -30
  390. package/dist/domain/temporal/TempoMap.js.map +1 -1
  391. package/dist/domain/temporal/types.d.ts +1 -1
  392. package/dist/domain/temporal/types.d.ts.map +1 -1
  393. package/dist/domain/temporal/types.js +1 -1
  394. package/dist/domain/temporal/types.js.map +1 -1
  395. package/dist/index.d.ts +43 -1
  396. package/dist/index.d.ts.map +1 -1
  397. package/dist/index.js +32 -1
  398. package/dist/index.js.map +1 -1
  399. package/dist/lib/Signal.d.ts +1 -1
  400. package/dist/lib/ThawList.d.ts +98 -0
  401. package/dist/lib/ThawList.d.ts.map +1 -0
  402. package/dist/lib/ThawList.js +151 -0
  403. package/dist/lib/ThawList.js.map +1 -0
  404. package/dist/midi/MidiFileParser.d.ts +32 -0
  405. package/dist/midi/MidiFileParser.d.ts.map +1 -0
  406. package/dist/midi/MidiFileParser.js +245 -0
  407. package/dist/midi/MidiFileParser.js.map +1 -0
  408. package/dist/midi/MidiFileWriter.d.ts +30 -0
  409. package/dist/midi/MidiFileWriter.d.ts.map +1 -0
  410. package/dist/midi/MidiFileWriter.js +159 -0
  411. package/dist/midi/MidiFileWriter.js.map +1 -0
  412. package/dist/midi/MidiImporter.d.ts +37 -0
  413. package/dist/midi/MidiImporter.d.ts.map +1 -0
  414. package/dist/midi/MidiImporter.js +62 -0
  415. package/dist/midi/MidiImporter.js.map +1 -0
  416. package/dist/plugins/PluginManager.js +2 -2
  417. package/dist/plugins/PluginManager.js.map +1 -1
  418. package/dist/plugins/PluginPresetManager.d.ts +86 -0
  419. package/dist/plugins/PluginPresetManager.d.ts.map +1 -0
  420. package/dist/plugins/PluginPresetManager.js +140 -0
  421. package/dist/plugins/PluginPresetManager.js.map +1 -0
  422. package/dist/plugins/impl/ExpanderPlugin.d.ts +1 -1
  423. package/dist/plugins/impl/ExpanderPlugin.js +1 -1
  424. package/dist/plugins/impl/ParametricEQPlugin.d.ts +1 -1
  425. package/dist/plugins/impl/ParametricEQPlugin.js +1 -1
  426. package/dist/processing/IO.d.ts +15 -1
  427. package/dist/processing/IO.d.ts.map +1 -1
  428. package/dist/processing/IO.js +29 -1
  429. package/dist/processing/IO.js.map +1 -1
  430. package/dist/processing/InternalSend.d.ts +102 -0
  431. package/dist/processing/InternalSend.d.ts.map +1 -0
  432. package/dist/processing/InternalSend.js +175 -0
  433. package/dist/processing/InternalSend.js.map +1 -0
  434. package/dist/processing/MeterDSP.d.ts +165 -0
  435. package/dist/processing/MeterDSP.d.ts.map +1 -0
  436. package/dist/processing/MeterDSP.js +753 -0
  437. package/dist/processing/MeterDSP.js.map +1 -0
  438. package/dist/processing/MeterProcessor.d.ts +0 -1
  439. package/dist/processing/MeterProcessor.d.ts.map +1 -1
  440. package/dist/processing/MeterProcessor.js +0 -1
  441. package/dist/processing/MeterProcessor.js.map +1 -1
  442. package/dist/processing/Panner.d.ts +144 -0
  443. package/dist/processing/Panner.d.ts.map +1 -0
  444. package/dist/processing/Panner.js +280 -0
  445. package/dist/processing/Panner.js.map +1 -0
  446. package/dist/processing/PluginInsert.d.ts +56 -1
  447. package/dist/processing/PluginInsert.d.ts.map +1 -1
  448. package/dist/processing/PluginInsert.js +180 -2
  449. package/dist/processing/PluginInsert.js.map +1 -1
  450. package/dist/processing/PolarityProcessor.d.ts +1 -1
  451. package/dist/processing/PolarityProcessor.js +1 -1
  452. package/dist/processing/Processor.d.ts +38 -0
  453. package/dist/processing/Processor.d.ts.map +1 -1
  454. package/dist/processing/Processor.js +60 -1
  455. package/dist/processing/Processor.js.map +1 -1
  456. package/dist/processing/SendProcessor.d.ts +0 -1
  457. package/dist/processing/SendProcessor.d.ts.map +1 -1
  458. package/dist/processing/SendProcessor.js +0 -1
  459. package/dist/processing/SendProcessor.js.map +1 -1
  460. package/dist/processing/SurroundPanner.d.ts +120 -0
  461. package/dist/processing/SurroundPanner.d.ts.map +1 -0
  462. package/dist/processing/SurroundPanner.js +374 -0
  463. package/dist/processing/SurroundPanner.js.map +1 -0
  464. package/dist/processing/TruePeakLimiter.d.ts +32 -0
  465. package/dist/processing/TruePeakLimiter.d.ts.map +1 -0
  466. package/dist/processing/TruePeakLimiter.js +142 -0
  467. package/dist/processing/TruePeakLimiter.js.map +1 -0
  468. package/dist/storage/ExportPresetStorage.d.ts +33 -0
  469. package/dist/storage/ExportPresetStorage.d.ts.map +1 -0
  470. package/dist/storage/ExportPresetStorage.js +121 -0
  471. package/dist/storage/ExportPresetStorage.js.map +1 -0
  472. package/dist/storage/SessionArchive.d.ts +73 -0
  473. package/dist/storage/SessionArchive.d.ts.map +1 -0
  474. package/dist/storage/SessionArchive.js +211 -0
  475. package/dist/storage/SessionArchive.js.map +1 -0
  476. package/dist/storage/SessionStorage.d.ts +1 -1
  477. package/dist/storage/SessionTemplate.d.ts +74 -5
  478. package/dist/storage/SessionTemplate.d.ts.map +1 -1
  479. package/dist/storage/SessionTemplate.js +247 -53
  480. package/dist/storage/SessionTemplate.js.map +1 -1
  481. package/dist/utils/BwfMetadataWriter.d.ts +41 -0
  482. package/dist/utils/BwfMetadataWriter.d.ts.map +1 -0
  483. package/dist/utils/BwfMetadataWriter.js +130 -0
  484. package/dist/utils/BwfMetadataWriter.js.map +1 -0
  485. package/dist/utils/DitherProcessor.d.ts +0 -1
  486. package/dist/utils/DitherProcessor.d.ts.map +1 -1
  487. package/dist/utils/DitherProcessor.js +0 -1
  488. package/dist/utils/DitherProcessor.js.map +1 -1
  489. package/dist/utils/FilenameTemplate.d.ts +39 -0
  490. package/dist/utils/FilenameTemplate.d.ts.map +1 -0
  491. package/dist/utils/FilenameTemplate.js +77 -0
  492. package/dist/utils/FilenameTemplate.js.map +1 -0
  493. package/dist/utils/FlacEncoder.d.ts +0 -1
  494. package/dist/utils/FlacEncoder.d.ts.map +1 -1
  495. package/dist/utils/FlacEncoder.js +0 -1
  496. package/dist/utils/FlacEncoder.js.map +1 -1
  497. package/dist/utils/Logger.d.ts +28 -0
  498. package/dist/utils/Logger.d.ts.map +1 -0
  499. package/dist/utils/Logger.js +46 -0
  500. package/dist/utils/Logger.js.map +1 -0
  501. package/dist/utils/Mp4ChapterGenerator.d.ts +16 -0
  502. package/dist/utils/Mp4ChapterGenerator.d.ts.map +1 -0
  503. package/dist/utils/Mp4ChapterGenerator.js +32 -0
  504. package/dist/utils/Mp4ChapterGenerator.js.map +1 -0
  505. package/dist/utils/OggEncoder.d.ts +19 -21
  506. package/dist/utils/OggEncoder.d.ts.map +1 -1
  507. package/dist/utils/OggEncoder.js +113 -51
  508. package/dist/utils/OggEncoder.js.map +1 -1
  509. package/dist/utils/TocGenerator.d.ts +16 -0
  510. package/dist/utils/TocGenerator.d.ts.map +1 -0
  511. package/dist/utils/TocGenerator.js +46 -0
  512. package/dist/utils/TocGenerator.js.map +1 -0
  513. package/package.json +7 -8
@@ -0,0 +1,382 @@
1
+ import { Declicker, DeclickAmp } from './Declick';
2
+ /** Default chunk size: 64k samples (~1.5s at 44100 Hz) */
3
+ const DEFAULT_CHUNK_SIZE = 65536;
4
+ /** Default peak buffer size for GUI visualization */
5
+ const DEFAULT_PEAK_BUFFER_SIZE = 1024;
6
+ /**
7
+ * DiskReader - Manages buffered playback I/O.
8
+ * Provides chunk-based reading with loop handling.
9
+ */
10
+ export class DiskReader {
11
+ /**
12
+ * @param channelCount - Number of audio channels (e.g. 2 for stereo)
13
+ * @param chunkSize - Size of the internal playback buffer per channel (default 64k)
14
+ */
15
+ constructor(channelCount, chunkSize) {
16
+ this._readPosition = 0;
17
+ this._writeOffset = 0; // How many valid samples are in _buffer
18
+ this._loopStart = -1;
19
+ this._loopEnd = -1;
20
+ this._declicker = null;
21
+ this._channelCount = channelCount;
22
+ this._chunkSize = chunkSize !== null && chunkSize !== void 0 ? chunkSize : DEFAULT_CHUNK_SIZE;
23
+ this._buffer = [];
24
+ for (let ch = 0; ch < channelCount; ch++) {
25
+ this._buffer.push(new Float32Array(this._chunkSize));
26
+ }
27
+ }
28
+ /**
29
+ * Set loop boundaries for loop playback.
30
+ * When reading reaches loopEnd, it wraps back to loopStart.
31
+ * Optionally enables a declicker for smooth loop transitions.
32
+ * @param start - Loop start frame (in source coordinates)
33
+ * @param end - Loop end frame (in source coordinates)
34
+ */
35
+ setLoop(start, end) {
36
+ this._loopStart = start;
37
+ this._loopEnd = end;
38
+ // Create a declicker for the loop boundary (~128 samples)
39
+ this._declicker = new Declicker(128);
40
+ }
41
+ /**
42
+ * Remove loop boundaries.
43
+ */
44
+ clearLoop() {
45
+ this._loopStart = -1;
46
+ this._loopEnd = -1;
47
+ this._declicker = null;
48
+ }
49
+ /**
50
+ * Fill the internal buffer from a source starting at the given frame.
51
+ * Handles loop wrapping if a loop is set.
52
+ * @param source - The audio buffer source to read from
53
+ * @param startFrame - The frame position in the source to start reading from
54
+ * @returns The number of frames actually read
55
+ */
56
+ async refill(source, startFrame) {
57
+ const srcLength = source.length;
58
+ const channels = Math.min(this._channelCount, source.numberOfChannels);
59
+ let framesRead = 0;
60
+ let srcPos = startFrame;
61
+ const hasLoop = this._loopStart >= 0 && this._loopEnd > this._loopStart;
62
+ // Clear buffers
63
+ for (let ch = 0; ch < this._channelCount; ch++) {
64
+ this._buffer[ch].fill(0);
65
+ }
66
+ while (framesRead < this._chunkSize) {
67
+ // Clamp source position
68
+ if (srcPos >= srcLength) {
69
+ if (hasLoop) {
70
+ srcPos = this._loopStart;
71
+ }
72
+ else {
73
+ break; // End of source, no loop
74
+ }
75
+ }
76
+ // Determine how many frames we can read in this segment
77
+ let framesToRead = this._chunkSize - framesRead;
78
+ // Don't read past source end
79
+ framesToRead = Math.min(framesToRead, srcLength - srcPos);
80
+ // Don't read past loop end
81
+ if (hasLoop && srcPos < this._loopEnd) {
82
+ framesToRead = Math.min(framesToRead, this._loopEnd - srcPos);
83
+ }
84
+ if (framesToRead <= 0)
85
+ break;
86
+ // Copy from source into internal buffer
87
+ for (let ch = 0; ch < channels; ch++) {
88
+ const srcData = source.getChannelData(ch);
89
+ const destData = this._buffer[ch];
90
+ for (let i = 0; i < framesToRead; i++) {
91
+ destData[framesRead + i] = srcData[srcPos + i];
92
+ }
93
+ }
94
+ framesRead += framesToRead;
95
+ srcPos += framesToRead;
96
+ // Handle loop wrap
97
+ if (hasLoop && srcPos >= this._loopEnd) {
98
+ // Apply crossfade at the loop boundary if declicker is available
99
+ if (this._declicker && framesRead > 0) {
100
+ const fadeLen = this._declicker.getLength();
101
+ const fadeStart = framesRead - Math.min(fadeLen, framesToRead);
102
+ if (fadeStart >= 0) {
103
+ for (let ch = 0; ch < channels; ch++) {
104
+ this._declicker.applyFadeOut(this._buffer[ch], fadeStart);
105
+ }
106
+ }
107
+ }
108
+ srcPos = this._loopStart;
109
+ }
110
+ }
111
+ this._writeOffset = framesRead;
112
+ this._readPosition = 0;
113
+ return framesRead;
114
+ }
115
+ /**
116
+ * Read samples from the internal buffer into output arrays.
117
+ * @param output - Per-channel output arrays to write into
118
+ * @param offset - Offset into the output arrays
119
+ * @param count - Number of frames to read
120
+ * @returns Number of frames actually read
121
+ */
122
+ read(output, offset, count) {
123
+ const available = this._writeOffset - this._readPosition;
124
+ const framesToRead = Math.min(count, available);
125
+ if (framesToRead <= 0)
126
+ return 0;
127
+ const channels = Math.min(this._channelCount, output.length);
128
+ for (let ch = 0; ch < channels; ch++) {
129
+ const src = this._buffer[ch];
130
+ const dest = output[ch];
131
+ for (let i = 0; i < framesToRead; i++) {
132
+ dest[offset + i] = src[this._readPosition + i];
133
+ }
134
+ }
135
+ this._readPosition += framesToRead;
136
+ return framesToRead;
137
+ }
138
+ /**
139
+ * Seek to a specific frame position within the buffer.
140
+ * Note: This only adjusts the internal read pointer; you may need to refill().
141
+ */
142
+ seek(frame) {
143
+ this._readPosition = 0;
144
+ this._writeOffset = 0;
145
+ // The caller should refill after seeking
146
+ }
147
+ /**
148
+ * Get current read position within the internal buffer.
149
+ */
150
+ getPosition() {
151
+ return this._readPosition;
152
+ }
153
+ /**
154
+ * Check if the internal buffer needs a refill (more than half consumed).
155
+ */
156
+ needsRefill() {
157
+ return this._readPosition >= this._writeOffset / 2;
158
+ }
159
+ /**
160
+ * Get the percentage of the buffer that still contains unread data.
161
+ * Useful for monitoring playback buffer health.
162
+ */
163
+ getBufferLoadPercent() {
164
+ if (this._writeOffset === 0)
165
+ return 0;
166
+ const remaining = this._writeOffset - this._readPosition;
167
+ return (remaining / this._chunkSize) * 100;
168
+ }
169
+ }
170
+ /**
171
+ * DiskWriter - Manages buffered recording I/O.
172
+ * Captures audio with alignment and xrun tracking.
173
+ */
174
+ export class DiskWriter {
175
+ /**
176
+ * @param channelCount - Number of audio channels
177
+ * @param sampleRate - Audio sample rate (for DeclickAmp ramp calculation)
178
+ * @param xrunTracker - Shared xrun tracker instance
179
+ */
180
+ constructor(channelCount, sampleRate, xrunTracker) {
181
+ this._writePosition = 0;
182
+ this._captureStart = -1;
183
+ this._captureEnd = -1;
184
+ this._isRecording = false;
185
+ this._peakWritePos = 0;
186
+ this._alignmentStyle = 'capture_time';
187
+ this._channelCount = channelCount;
188
+ this._xrunTracker = xrunTracker;
189
+ this._declickAmp = new DeclickAmp(sampleRate);
190
+ this._bufferSize = DiskWriter.INITIAL_BUFFER_FRAMES;
191
+ // Allocate per-channel capture buffers
192
+ this._buffer = [];
193
+ for (let ch = 0; ch < channelCount; ch++) {
194
+ this._buffer.push(new Float32Array(this._bufferSize));
195
+ }
196
+ // Peak buffer for GUI visualization
197
+ this._peakBuffer = [];
198
+ for (let ch = 0; ch < channelCount; ch++) {
199
+ this._peakBuffer.push(new Float32Array(DEFAULT_PEAK_BUFFER_SIZE));
200
+ }
201
+ }
202
+ /**
203
+ * Prepare for recording. Resets buffers and sets the capture start frame.
204
+ * @param startFrame - The session frame at which recording will begin
205
+ */
206
+ prepareRecord(startFrame) {
207
+ this._captureStart = startFrame;
208
+ this._captureEnd = -1;
209
+ this._writePosition = 0;
210
+ this._peakWritePos = 0;
211
+ // Clear buffers
212
+ for (let ch = 0; ch < this._channelCount; ch++) {
213
+ this._buffer[ch].fill(0);
214
+ this._peakBuffer[ch].fill(0);
215
+ }
216
+ // Reset declick: start at gain 0, will ramp up when recording starts
217
+ this._declickAmp.reset(0.0);
218
+ this._declickAmp.setTarget(1.0);
219
+ }
220
+ /**
221
+ * Start recording. Activates capture and begins the fade-in ramp.
222
+ */
223
+ startRecord() {
224
+ this._isRecording = true;
225
+ this._declickAmp.setTarget(1.0);
226
+ }
227
+ /**
228
+ * Stop recording. Begins fade-out ramp and marks the capture end.
229
+ * @returns The capture end frame in session coordinates
230
+ */
231
+ stopRecord() {
232
+ this._isRecording = false;
233
+ this._declickAmp.setTarget(0.0);
234
+ this._captureEnd = this._captureStart + this._writePosition;
235
+ return this._captureEnd;
236
+ }
237
+ /**
238
+ * Write incoming audio samples to the capture buffer.
239
+ * Applies declick ramp and tracks peak data for GUI.
240
+ * Reports an xrun if the buffer overflows.
241
+ * @param input - Per-channel input arrays
242
+ * @param offset - Offset into the input arrays
243
+ * @param count - Number of frames to write
244
+ */
245
+ write(input, offset, count) {
246
+ if (!this._isRecording && !this._declickAmp.isRamping())
247
+ return;
248
+ // Check for buffer overflow
249
+ if (this._writePosition + count > this._bufferSize) {
250
+ // Grow the buffer (double it)
251
+ this._growBuffer();
252
+ // If still not enough (shouldn't happen), report xrun
253
+ if (this._writePosition + count > this._bufferSize) {
254
+ this._xrunTracker.reportXrun(this._captureStart + this._writePosition, 'overrun', count);
255
+ return;
256
+ }
257
+ }
258
+ const channels = Math.min(this._channelCount, input.length);
259
+ // Copy input data into capture buffer
260
+ for (let ch = 0; ch < channels; ch++) {
261
+ const src = input[ch];
262
+ const dest = this._buffer[ch];
263
+ for (let i = 0; i < count; i++) {
264
+ dest[this._writePosition + i] = src[offset + i];
265
+ }
266
+ }
267
+ // Apply declick ramp to the just-written segment
268
+ const segmentBuffers = this._buffer;
269
+ this._declickAmp.applyToBuffers(segmentBuffers, this._writePosition, count);
270
+ // Update peak data for GUI visualization
271
+ this._updatePeaks(channels, count);
272
+ this._writePosition += count;
273
+ }
274
+ /**
275
+ * Get the captured audio as trimmed Float32Arrays (one per channel).
276
+ */
277
+ getCapturedAudio() {
278
+ const result = [];
279
+ for (let ch = 0; ch < this._channelCount; ch++) {
280
+ result.push(this._buffer[ch].slice(0, this._writePosition));
281
+ }
282
+ return result;
283
+ }
284
+ /**
285
+ * Get the capture range in session frame coordinates.
286
+ */
287
+ getCaptureRange() {
288
+ return {
289
+ start: this._captureStart,
290
+ end: this._captureEnd >= 0
291
+ ? this._captureEnd
292
+ : this._captureStart + this._writePosition,
293
+ };
294
+ }
295
+ /**
296
+ * Get peak data for GUI real-time visualization during recording.
297
+ * Returns per-channel arrays of peak values.
298
+ */
299
+ getPeakData() {
300
+ const result = [];
301
+ for (let ch = 0; ch < this._channelCount; ch++) {
302
+ result.push(this._peakBuffer[ch].slice(0, this._peakWritePos));
303
+ }
304
+ return result;
305
+ }
306
+ /**
307
+ * Reset peak data (e.g. when the GUI display scrolls).
308
+ */
309
+ resetPeakData() {
310
+ this._peakWritePos = 0;
311
+ for (let ch = 0; ch < this._channelCount; ch++) {
312
+ this._peakBuffer[ch].fill(0);
313
+ }
314
+ }
315
+ /**
316
+ * Set the alignment style for the captured recording.
317
+ * - 'existing_material': Align to existing material on the track (snap to beat/region boundaries)
318
+ * - 'capture_time': Align to the exact time the audio was captured (default)
319
+ */
320
+ setAlignment(style) {
321
+ this._alignmentStyle = style;
322
+ }
323
+ /**
324
+ * Check if currently recording.
325
+ */
326
+ isRecording() {
327
+ return this._isRecording;
328
+ }
329
+ /**
330
+ * Get the number of frames captured so far.
331
+ */
332
+ getCapturedFrames() {
333
+ return this._writePosition;
334
+ }
335
+ // ─── Private helpers ────────────────────────────────────────────────────
336
+ /**
337
+ * Grow the capture buffer by doubling its size.
338
+ */
339
+ _growBuffer() {
340
+ const newSize = this._bufferSize * 2;
341
+ for (let ch = 0; ch < this._channelCount; ch++) {
342
+ const newBuf = new Float32Array(newSize);
343
+ newBuf.set(this._buffer[ch]);
344
+ this._buffer[ch] = newBuf;
345
+ }
346
+ this._bufferSize = newSize;
347
+ }
348
+ /**
349
+ * Update the peak buffer with the maximum absolute sample values
350
+ * from the most recently written segment. Each peak entry represents
351
+ * a chunk of recorded samples, downsampled for efficient GUI rendering.
352
+ */
353
+ _updatePeaks(channels, count) {
354
+ // Each peak entry covers a fixed number of source samples
355
+ const samplesPerPeak = 512;
356
+ const startSample = this._writePosition;
357
+ const endSample = startSample + count;
358
+ for (let pos = startSample; pos < endSample; pos += samplesPerPeak) {
359
+ const blockEnd = Math.min(pos + samplesPerPeak, endSample);
360
+ for (let ch = 0; ch < channels; ch++) {
361
+ let peak = 0;
362
+ const buf = this._buffer[ch];
363
+ for (let i = pos; i < blockEnd; i++) {
364
+ const abs = Math.abs(buf[i]);
365
+ if (abs > peak)
366
+ peak = abs;
367
+ }
368
+ // Grow peak buffer if needed
369
+ if (this._peakWritePos >= this._peakBuffer[ch].length) {
370
+ const newPeakBuf = new Float32Array(this._peakBuffer[ch].length * 2);
371
+ newPeakBuf.set(this._peakBuffer[ch]);
372
+ this._peakBuffer[ch] = newPeakBuf;
373
+ }
374
+ this._peakBuffer[ch][this._peakWritePos] = peak;
375
+ }
376
+ this._peakWritePos++;
377
+ }
378
+ }
379
+ }
380
+ /** Initial capture buffer size: 10 minutes at 48kHz stereo */
381
+ DiskWriter.INITIAL_BUFFER_FRAMES = 48000 * 60 * 10;
382
+ //# sourceMappingURL=DiskIO.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DiskIO.js","sourceRoot":"","sources":["../../../src/audio/engine/DiskIO.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAclD,0DAA0D;AAC1D,MAAM,kBAAkB,GAAG,KAAK,CAAC;AAEjC,qDAAqD;AACrD,MAAM,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AAK,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,QAAQ,EAAE,CAAC,EAAE,EAAE,CAAC;oBAClC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;oBAC7B,IAAI,GAAG,GAAG,IAAI;wBAAE,IAAI,GAAG,GAAG,CAAC;gBAC/B,CAAC;gBAED,6BAA6B;gBAC7B,IAAI,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;oBACpD,MAAM,UAAU,GAAG,IAAI,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;oBACrE,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC;oBACrC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC;gBACtC,CAAC;gBAED,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC;YACpD,CAAC;YAED,IAAI,CAAC,aAAa,EAAE,CAAC;QACzB,CAAC;IACL,CAAC;;AAxOD,8DAA8D;AACtC,gCAAqB,GAAG,KAAK,GAAG,EAAE,GAAG,EAAE,AAAlB,CAAmB"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * LatencyCompensator
3
+ *
4
+ * A per-channel ring-buffer delay line used to time-align audio routes.
5
+ * When one route has higher processing latency than another, the lower-
6
+ * latency route gets a LatencyCompensator inserted with the appropriate
7
+ * delay so that both routes arrive at the summing point in phase.
8
+ */
9
+ export declare class LatencyCompensator {
10
+ private _delaySamples;
11
+ private _buffer;
12
+ private _writePos;
13
+ private _channels;
14
+ private _maxDelay;
15
+ constructor(channels?: number, maxDelay?: number);
16
+ /** Current delay in samples. */
17
+ get delaySamples(): number;
18
+ /**
19
+ * Set the compensation delay.
20
+ * @param samples Delay in samples (clamped to 0 .. maxDelay - 1).
21
+ */
22
+ setDelay(samples: number): void;
23
+ /**
24
+ * Process a block of audio through the delay buffer.
25
+ *
26
+ * For each sample in the block the method writes the input into the ring
27
+ * buffer at `_writePos` and reads the output from `_writePos - delay`
28
+ * (wrapped). This introduces an exact `_delaySamples` latency.
29
+ *
30
+ * If `_delaySamples` is 0 the input is copied directly to the output
31
+ * with no ring-buffer overhead.
32
+ *
33
+ * @param input Per-channel input arrays (length >= blockSize each).
34
+ * @param output Per-channel output arrays (length >= blockSize each).
35
+ * May alias the same arrays as `input`.
36
+ * @param blockSize Number of samples to process.
37
+ */
38
+ process(input: Float32Array[], output: Float32Array[], blockSize: number): void;
39
+ /**
40
+ * Reset all ring buffers to silence and rewind the write pointer.
41
+ * Call after a transport locate or when the delay amount changes to
42
+ * avoid stale audio leaking through.
43
+ */
44
+ reset(): void;
45
+ }
46
+ //# sourceMappingURL=LatencyCompensator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LatencyCompensator.d.ts","sourceRoot":"","sources":["../../../src/audio/engine/LatencyCompensator.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,qBAAa,kBAAkB;IAC3B,OAAO,CAAC,aAAa,CAAa;IAClC,OAAO,CAAC,OAAO,CAAiB;IAChC,OAAO,CAAC,SAAS,CAAa;IAC9B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,SAAS,CAAS;gBAEd,QAAQ,GAAE,MAAU,EAAE,QAAQ,GAAE,MAAa;IAWzD,gCAAgC;IAChC,IAAI,YAAY,IAAI,MAAM,CAEzB;IAED;;;OAGG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAI/B;;;;;;;;;;;;;;OAcG;IACH,OAAO,CAAC,KAAK,EAAE,YAAY,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI;IA8B/E;;;;OAIG;IACH,KAAK,IAAI,IAAI;CAMhB"}
@@ -0,0 +1,84 @@
1
+ /**
2
+ * LatencyCompensator
3
+ *
4
+ * A per-channel ring-buffer delay line used to time-align audio routes.
5
+ * When one route has higher processing latency than another, the lower-
6
+ * latency route gets a LatencyCompensator inserted with the appropriate
7
+ * delay so that both routes arrive at the summing point in phase.
8
+ */
9
+ export class LatencyCompensator {
10
+ constructor(channels = 2, maxDelay = 8192) {
11
+ this._delaySamples = 0;
12
+ this._writePos = 0;
13
+ this._channels = channels;
14
+ this._maxDelay = maxDelay;
15
+ // Allocate one ring buffer per channel.
16
+ this._buffer = [];
17
+ for (let ch = 0; ch < channels; ch++) {
18
+ this._buffer.push(new Float32Array(maxDelay));
19
+ }
20
+ }
21
+ /** Current delay in samples. */
22
+ get delaySamples() {
23
+ return this._delaySamples;
24
+ }
25
+ /**
26
+ * Set the compensation delay.
27
+ * @param samples Delay in samples (clamped to 0 .. maxDelay - 1).
28
+ */
29
+ setDelay(samples) {
30
+ this._delaySamples = Math.max(0, Math.min(samples, this._maxDelay - 1));
31
+ }
32
+ /**
33
+ * Process a block of audio through the delay buffer.
34
+ *
35
+ * For each sample in the block the method writes the input into the ring
36
+ * buffer at `_writePos` and reads the output from `_writePos - delay`
37
+ * (wrapped). This introduces an exact `_delaySamples` latency.
38
+ *
39
+ * If `_delaySamples` is 0 the input is copied directly to the output
40
+ * with no ring-buffer overhead.
41
+ *
42
+ * @param input Per-channel input arrays (length >= blockSize each).
43
+ * @param output Per-channel output arrays (length >= blockSize each).
44
+ * May alias the same arrays as `input`.
45
+ * @param blockSize Number of samples to process.
46
+ */
47
+ process(input, output, blockSize) {
48
+ const delay = this._delaySamples;
49
+ // Fast path: no delay — straight copy.
50
+ if (delay === 0) {
51
+ for (let ch = 0; ch < this._channels; ch++) {
52
+ if (input[ch] !== output[ch]) {
53
+ output[ch].set(input[ch].subarray(0, blockSize));
54
+ }
55
+ }
56
+ return;
57
+ }
58
+ const maxDelay = this._maxDelay;
59
+ for (let i = 0; i < blockSize; i++) {
60
+ const wp = this._writePos;
61
+ // Read position: wrap around if negative.
62
+ let rp = wp - delay;
63
+ if (rp < 0)
64
+ rp += maxDelay;
65
+ for (let ch = 0; ch < this._channels; ch++) {
66
+ this._buffer[ch][wp] = input[ch][i];
67
+ output[ch][i] = this._buffer[ch][rp];
68
+ }
69
+ this._writePos = (wp + 1) % maxDelay;
70
+ }
71
+ }
72
+ /**
73
+ * Reset all ring buffers to silence and rewind the write pointer.
74
+ * Call after a transport locate or when the delay amount changes to
75
+ * avoid stale audio leaking through.
76
+ */
77
+ reset() {
78
+ this._writePos = 0;
79
+ for (let ch = 0; ch < this._channels; ch++) {
80
+ this._buffer[ch].fill(0);
81
+ }
82
+ }
83
+ }
84
+ //# sourceMappingURL=LatencyCompensator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LatencyCompensator.js","sourceRoot":"","sources":["../../../src/audio/engine/LatencyCompensator.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,OAAO,kBAAkB;IAO3B,YAAY,WAAmB,CAAC,EAAE,WAAmB,IAAI;QANjD,kBAAa,GAAW,CAAC,CAAC;QAE1B,cAAS,GAAW,CAAC,CAAC;QAK1B,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAE1B,wCAAwC;QACxC,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;QAClB,KAAK,IAAI,EAAE,GAAG,CAAC,EAAE,EAAE,GAAG,QAAQ,EAAE,EAAE,EAAE,EAAE,CAAC;YACnC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC;QAClD,CAAC;IACL,CAAC;IAED,gCAAgC;IAChC,IAAI,YAAY;QACZ,OAAO,IAAI,CAAC,aAAa,CAAC;IAC9B,CAAC;IAED;;;OAGG;IACH,QAAQ,CAAC,OAAe;QACp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