@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,134 @@
1
+ import { Session } from '../domain/Session';
2
+ import { Signal } from '../lib/Signal';
3
+ /**
4
+ * A directed connection between two nodes in the routing graph.
5
+ */
6
+ export interface GraphEdge {
7
+ /** Source track / bus ID. */
8
+ sourceId: string;
9
+ /** Target track / bus ID. */
10
+ targetId: string;
11
+ /** Output port name on the source. */
12
+ sourcePort: string;
13
+ /** Input port name on the target. */
14
+ targetPort: string;
15
+ /** Connection type. */
16
+ type: 'audio' | 'midi' | 'sidechain';
17
+ }
18
+ /**
19
+ * A node in the routing graph, representing a track, bus, aux, master,
20
+ * or send point in the signal chain.
21
+ */
22
+ export interface GraphNode {
23
+ id: string;
24
+ name: string;
25
+ type: 'track' | 'bus' | 'aux' | 'master' | 'send';
26
+ /** Total processing latency (in samples) introduced by this node. */
27
+ latency: number;
28
+ }
29
+ /**
30
+ * RoutingGraph provides high-level routing analysis for a DAW session.
31
+ *
32
+ * It models the signal flow as a directed graph where nodes are tracks /
33
+ * buses and edges are audio / MIDI / sidechain connections. The class
34
+ * exposes query methods (`feeds`, `signalSources`,
35
+ * `signalDestinations`) as well as topological sorting, cycle detection,
36
+ * and automatic latency compensation.
37
+ */
38
+ export declare class RoutingGraph {
39
+ private _nodes;
40
+ private _edges;
41
+ readonly graphChanged: Signal<void>;
42
+ /**
43
+ * Populate the graph from a live Session by inspecting its tracks,
44
+ * send buses, and master bus.
45
+ *
46
+ * All existing nodes / edges are cleared first.
47
+ */
48
+ buildFromSession(session: Session): void;
49
+ getNode(id: string): GraphNode | undefined;
50
+ getNodes(): GraphNode[];
51
+ getEdges(): GraphEdge[];
52
+ getEdgesFrom(nodeId: string): GraphEdge[];
53
+ getEdgesTo(nodeId: string): GraphEdge[];
54
+ addNode(node: GraphNode): void;
55
+ removeNode(id: string): void;
56
+ addEdge(edge: GraphEdge): void;
57
+ removeEdge(sourceId: string, targetId: string): void;
58
+ /**
59
+ * Does `sourceId` feed into `targetId` through any path?
60
+ * Uses BFS from source looking for target.
61
+ */
62
+ feeds(sourceId: string, targetId: string): boolean;
63
+ /**
64
+ * Is there a direct (single-hop) connection from source to target?
65
+ */
66
+ directFeeds(sourceId: string, targetId: string): boolean;
67
+ /**
68
+ * All upstream nodes that eventually feed into `nodeId`.
69
+ */
70
+ signalSources(nodeId: string): string[];
71
+ /**
72
+ * All downstream nodes that `nodeId` eventually feeds into.
73
+ */
74
+ signalDestinations(nodeId: string): string[];
75
+ /**
76
+ * Return node IDs in a valid processing order using Kahn's algorithm
77
+ * (topological sort). Sources are processed before their consumers.
78
+ *
79
+ * @throws {Error} If the graph contains a cycle.
80
+ */
81
+ getProcessingOrder(): string[];
82
+ /**
83
+ * Detect whether the graph contains any cycles using iterative DFS with
84
+ * a three-color marking scheme.
85
+ */
86
+ hasCycle(): boolean;
87
+ /**
88
+ * Compute total latency along the shortest signal path from `sourceId`
89
+ * to `targetId` by summing node latencies. Uses BFS to find the path.
90
+ *
91
+ * Returns -1 if no path exists.
92
+ */
93
+ getLatencyForPath(sourceId: string, targetId: string): number;
94
+ /**
95
+ * Compute the maximum latency across any path from a source node to
96
+ * the master (or any terminal node). This is the worst-case latency
97
+ * that must be compensated for.
98
+ */
99
+ getMaxLatency(): number;
100
+ /**
101
+ * Compute the per-node compensation delay so that all signal paths
102
+ * arrive time-aligned at the master / terminal nodes.
103
+ *
104
+ * For each node, the compensation delay is:
105
+ * maxPathLatency - pathLatencyThroughThisNode
106
+ *
107
+ * where `maxPathLatency` is the longest cumulative latency path in the
108
+ * entire graph.
109
+ */
110
+ computeCompensationDelays(): Map<string, number>;
111
+ /**
112
+ * Assign depth levels to each node for visualization (e.g. source
113
+ * tracks at level 0, buses at level 1, master at level 2).
114
+ *
115
+ * Uses BFS from source nodes (zero in-degree).
116
+ */
117
+ getLevels(): Map<string, number>;
118
+ /**
119
+ * Export the graph as a plain JSON structure for persistence or
120
+ * visualization.
121
+ */
122
+ toJSON(): {
123
+ nodes: GraphNode[];
124
+ edges: GraphEdge[];
125
+ };
126
+ /**
127
+ * Restore a RoutingGraph from a JSON snapshot.
128
+ */
129
+ static fromJSON(data: {
130
+ nodes: GraphNode[];
131
+ edges: GraphEdge[];
132
+ }): RoutingGraph;
133
+ }
134
+ //# sourceMappingURL=RoutingGraph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RoutingGraph.d.ts","sourceRoot":"","sources":["../../src/audio/RoutingGraph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAIvC;;GAEG;AACH,MAAM,WAAW,SAAS;IACtB,6BAA6B;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,6BAA6B;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,sCAAsC;IACtC,UAAU,EAAE,MAAM,CAAC;IACnB,qCAAqC;IACrC,UAAU,EAAE,MAAM,CAAC;IACnB,uBAAuB;IACvB,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,WAAW,CAAC;CACxC;AAED;;;GAGG;AACH,MAAM,WAAW,SAAS;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,OAAO,GAAG,KAAK,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;IAClD,qEAAqE;IACrE,OAAO,EAAE,MAAM,CAAC;CACnB;AAID;;;;;;;;GAQG;AACH,qBAAa,YAAY;IACrB,OAAO,CAAC,MAAM,CAAqC;IACnD,OAAO,CAAC,MAAM,CAAmB;IAEjC,SAAgB,YAAY,eAAsB;IAIlD;;;;;OAKG;IACH,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IA4FxC,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS;IAI1C,QAAQ,IAAI,SAAS,EAAE;IAIvB,QAAQ,IAAI,SAAS,EAAE;IAIvB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE;IAIzC,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE;IAMvC,OAAO,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI;IAK9B,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAQ5B,OAAO,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI;IAK9B,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI;IASpD;;;OAGG;IACH,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO;IAqBlD;;OAEG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO;IAMxD;;OAEG;IACH,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE;IAgBvC;;OAEG;IACH,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE;IAkB5C;;;;;OAKG;IACH,kBAAkB,IAAI,MAAM,EAAE;IAsD9B;;;OAGG;IACH,QAAQ,IAAI,OAAO;IAsDnB;;;;;OAKG;IACH,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM;IA6C7D;;;;OAIG;IACH,aAAa,IAAI,MAAM;IA+DvB;;;;;;;;;OASG;IACH,yBAAyB,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IA4EhD;;;;;OAKG;IACH,SAAS,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IA6ChC;;;OAGG;IACH,MAAM,IAAI;QAAE,KAAK,EAAE,SAAS,EAAE,CAAC;QAAC,KAAK,EAAE,SAAS,EAAE,CAAA;KAAE;IAOpD;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,SAAS,EAAE,CAAC;QAAC,KAAK,EAAE,SAAS,EAAE,CAAA;KAAE,GAAG,YAAY;CAQlF"}
@@ -0,0 +1,547 @@
1
+ import { TrackType } from '../domain/Track';
2
+ import { Signal } from '../lib/Signal';
3
+ // ─── RoutingGraph ─────────────────────────────────────────────────────────────
4
+ /**
5
+ * RoutingGraph provides high-level routing analysis for a DAW session.
6
+ *
7
+ * It models the signal flow as a directed graph where nodes are tracks /
8
+ * buses and edges are audio / MIDI / sidechain connections. The class
9
+ * exposes query methods (`feeds`, `signalSources`,
10
+ * `signalDestinations`) as well as topological sorting, cycle detection,
11
+ * and automatic latency compensation.
12
+ */
13
+ export class RoutingGraph {
14
+ constructor() {
15
+ this._nodes = new Map();
16
+ this._edges = [];
17
+ this.graphChanged = new Signal();
18
+ }
19
+ // ─── Build from session ──────────────────────────────────────────────
20
+ /**
21
+ * Populate the graph from a live Session by inspecting its tracks,
22
+ * send buses, and master bus.
23
+ *
24
+ * All existing nodes / edges are cleared first.
25
+ */
26
+ buildFromSession(session) {
27
+ this._nodes.clear();
28
+ this._edges = [];
29
+ // Add master bus node
30
+ this._nodes.set(session.masterBus.id, {
31
+ id: session.masterBus.id,
32
+ name: 'Master',
33
+ type: 'master',
34
+ latency: session.masterBus.getProcessorLatency(),
35
+ });
36
+ // Add track / bus nodes
37
+ for (const track of session.tracks) {
38
+ let nodeType;
39
+ switch (track.type) {
40
+ case TrackType.BUS:
41
+ nodeType = 'bus';
42
+ break;
43
+ case TrackType.AUX:
44
+ nodeType = 'aux';
45
+ break;
46
+ default:
47
+ nodeType = 'track';
48
+ break;
49
+ }
50
+ this._nodes.set(track.id, {
51
+ id: track.id,
52
+ name: track.name,
53
+ type: nodeType,
54
+ latency: track.route.getProcessorLatency(),
55
+ });
56
+ // Every track / bus feeds the master by default
57
+ const edgeType = track.type === TrackType.MIDI ? 'midi' : 'audio';
58
+ this._edges.push({
59
+ sourceId: track.id,
60
+ targetId: session.masterBus.id,
61
+ sourcePort: `${track.name} Out`,
62
+ targetPort: 'Master In',
63
+ type: edgeType,
64
+ });
65
+ }
66
+ // Add send bus connections
67
+ for (const send of session.sendBuses) {
68
+ // The send creates a connection from its source track to its
69
+ // destination. We model the send itself as a "send" node.
70
+ const sendNodeId = `send-${send.id}`;
71
+ this._nodes.set(sendNodeId, {
72
+ id: sendNodeId,
73
+ name: `Send (${send.id})`,
74
+ type: 'send',
75
+ latency: 0,
76
+ });
77
+ // Source track -> send node
78
+ this._edges.push({
79
+ sourceId: send.sourceTrackId,
80
+ targetId: sendNodeId,
81
+ sourcePort: 'Send Out',
82
+ targetPort: 'Send In',
83
+ type: 'audio',
84
+ });
85
+ // Send node -> destination (bus / track input IO)
86
+ // Locate the track/bus whose route.input.id matches destId
87
+ const destTrack = session.tracks.find(t => t.route.input.id === send.destId);
88
+ const destNodeId = destTrack
89
+ ? destTrack.id
90
+ : send.destId; // fallback to raw destId
91
+ if (this._nodes.has(destNodeId)) {
92
+ this._edges.push({
93
+ sourceId: sendNodeId,
94
+ targetId: destNodeId,
95
+ sourcePort: 'Send Out',
96
+ targetPort: 'Bus In',
97
+ type: 'audio',
98
+ });
99
+ }
100
+ }
101
+ this.graphChanged.emit();
102
+ }
103
+ // ─── Node / Edge accessors ───────────────────────────────────────────
104
+ getNode(id) {
105
+ return this._nodes.get(id);
106
+ }
107
+ getNodes() {
108
+ return Array.from(this._nodes.values());
109
+ }
110
+ getEdges() {
111
+ return [...this._edges];
112
+ }
113
+ getEdgesFrom(nodeId) {
114
+ return this._edges.filter(e => e.sourceId === nodeId);
115
+ }
116
+ getEdgesTo(nodeId) {
117
+ return this._edges.filter(e => e.targetId === nodeId);
118
+ }
119
+ // ─── Manual graph building ───────────────────────────────────────────
120
+ addNode(node) {
121
+ this._nodes.set(node.id, node);
122
+ this.graphChanged.emit();
123
+ }
124
+ removeNode(id) {
125
+ this._nodes.delete(id);
126
+ this._edges = this._edges.filter(e => e.sourceId !== id && e.targetId !== id);
127
+ this.graphChanged.emit();
128
+ }
129
+ addEdge(edge) {
130
+ this._edges.push(edge);
131
+ this.graphChanged.emit();
132
+ }
133
+ removeEdge(sourceId, targetId) {
134
+ this._edges = this._edges.filter(e => !(e.sourceId === sourceId && e.targetId === targetId));
135
+ this.graphChanged.emit();
136
+ }
137
+ // ─── Routing analysis ────────────────────────────────────────────────
138
+ /**
139
+ * Does `sourceId` feed into `targetId` through any path?
140
+ * Uses BFS from source looking for target.
141
+ */
142
+ feeds(sourceId, targetId) {
143
+ if (sourceId === targetId)
144
+ return false;
145
+ const visited = new Set();
146
+ const queue = [sourceId];
147
+ while (queue.length > 0) {
148
+ const current = queue.shift();
149
+ if (current === targetId)
150
+ return true;
151
+ if (visited.has(current))
152
+ continue;
153
+ visited.add(current);
154
+ for (const edge of this._edges) {
155
+ if (edge.sourceId === current && !visited.has(edge.targetId)) {
156
+ queue.push(edge.targetId);
157
+ }
158
+ }
159
+ }
160
+ return false;
161
+ }
162
+ /**
163
+ * Is there a direct (single-hop) connection from source to target?
164
+ */
165
+ directFeeds(sourceId, targetId) {
166
+ return this._edges.some(e => e.sourceId === sourceId && e.targetId === targetId);
167
+ }
168
+ /**
169
+ * All upstream nodes that eventually feed into `nodeId`.
170
+ */
171
+ signalSources(nodeId) {
172
+ const visited = new Set();
173
+ const queue = [nodeId];
174
+ while (queue.length > 0) {
175
+ const current = queue.shift();
176
+ for (const edge of this._edges) {
177
+ if (edge.targetId === current && !visited.has(edge.sourceId)) {
178
+ visited.add(edge.sourceId);
179
+ queue.push(edge.sourceId);
180
+ }
181
+ }
182
+ }
183
+ return Array.from(visited);
184
+ }
185
+ /**
186
+ * All downstream nodes that `nodeId` eventually feeds into.
187
+ */
188
+ signalDestinations(nodeId) {
189
+ const visited = new Set();
190
+ const queue = [nodeId];
191
+ while (queue.length > 0) {
192
+ const current = queue.shift();
193
+ for (const edge of this._edges) {
194
+ if (edge.sourceId === current && !visited.has(edge.targetId)) {
195
+ visited.add(edge.targetId);
196
+ queue.push(edge.targetId);
197
+ }
198
+ }
199
+ }
200
+ return Array.from(visited);
201
+ }
202
+ // ─── Topological operations ──────────────────────────────────────────
203
+ /**
204
+ * Return node IDs in a valid processing order using Kahn's algorithm
205
+ * (topological sort). Sources are processed before their consumers.
206
+ *
207
+ * @throws {Error} If the graph contains a cycle.
208
+ */
209
+ getProcessingOrder() {
210
+ var _a, _b, _c;
211
+ const nodeIds = Array.from(this._nodes.keys());
212
+ if (nodeIds.length === 0)
213
+ return [];
214
+ // Build adjacency lists
215
+ const inDegree = new Map();
216
+ const forwardAdj = new Map();
217
+ for (const id of nodeIds) {
218
+ inDegree.set(id, 0);
219
+ forwardAdj.set(id, []);
220
+ }
221
+ for (const edge of this._edges) {
222
+ if (!this._nodes.has(edge.sourceId) || !this._nodes.has(edge.targetId)) {
223
+ continue;
224
+ }
225
+ inDegree.set(edge.targetId, ((_a = inDegree.get(edge.targetId)) !== null && _a !== void 0 ? _a : 0) + 1);
226
+ forwardAdj.get(edge.sourceId).push(edge.targetId);
227
+ }
228
+ // Seed queue with zero in-degree nodes
229
+ const queue = [];
230
+ for (const [id, deg] of inDegree) {
231
+ if (deg === 0)
232
+ queue.push(id);
233
+ }
234
+ // Sort for deterministic output
235
+ queue.sort();
236
+ const sorted = [];
237
+ while (queue.length > 0) {
238
+ queue.sort();
239
+ const id = queue.shift();
240
+ sorted.push(id);
241
+ for (const depId of (_b = forwardAdj.get(id)) !== null && _b !== void 0 ? _b : []) {
242
+ const newDeg = ((_c = inDegree.get(depId)) !== null && _c !== void 0 ? _c : 1) - 1;
243
+ inDegree.set(depId, newDeg);
244
+ if (newDeg === 0)
245
+ queue.push(depId);
246
+ }
247
+ }
248
+ if (sorted.length !== nodeIds.length) {
249
+ throw new Error('RoutingGraph contains a cycle — topological sort is not possible');
250
+ }
251
+ return sorted;
252
+ }
253
+ /**
254
+ * Detect whether the graph contains any cycles using iterative DFS with
255
+ * a three-color marking scheme.
256
+ */
257
+ hasCycle() {
258
+ var _a;
259
+ const WHITE = 0;
260
+ const GRAY = 1;
261
+ const BLACK = 2;
262
+ const color = new Map();
263
+ for (const id of this._nodes.keys()) {
264
+ color.set(id, WHITE);
265
+ }
266
+ // Build forward adjacency for efficient traversal
267
+ const adj = new Map();
268
+ for (const id of this._nodes.keys()) {
269
+ adj.set(id, []);
270
+ }
271
+ for (const edge of this._edges) {
272
+ if (adj.has(edge.sourceId)) {
273
+ adj.get(edge.sourceId).push(edge.targetId);
274
+ }
275
+ }
276
+ for (const startId of this._nodes.keys()) {
277
+ if (color.get(startId) !== WHITE)
278
+ continue;
279
+ const stack = [[startId, false]];
280
+ while (stack.length > 0) {
281
+ const [nodeId, isBacktrack] = stack.pop();
282
+ if (isBacktrack) {
283
+ color.set(nodeId, BLACK);
284
+ continue;
285
+ }
286
+ const nodeColor = color.get(nodeId);
287
+ if (nodeColor === GRAY)
288
+ return true;
289
+ if (nodeColor === BLACK)
290
+ continue;
291
+ color.set(nodeId, GRAY);
292
+ stack.push([nodeId, true]);
293
+ for (const neighbor of (_a = adj.get(nodeId)) !== null && _a !== void 0 ? _a : []) {
294
+ const neighborColor = color.get(neighbor);
295
+ if (neighborColor === GRAY)
296
+ return true;
297
+ if (neighborColor === WHITE) {
298
+ stack.push([neighbor, false]);
299
+ }
300
+ }
301
+ }
302
+ }
303
+ return false;
304
+ }
305
+ /**
306
+ * Compute total latency along the shortest signal path from `sourceId`
307
+ * to `targetId` by summing node latencies. Uses BFS to find the path.
308
+ *
309
+ * Returns -1 if no path exists.
310
+ */
311
+ getLatencyForPath(sourceId, targetId) {
312
+ var _a, _b;
313
+ if (sourceId === targetId) {
314
+ const node = this._nodes.get(sourceId);
315
+ return node ? node.latency : 0;
316
+ }
317
+ const visited = new Set();
318
+ const queue = [
319
+ { nodeId: sourceId, latency: (_b = (_a = this._nodes.get(sourceId)) === null || _a === void 0 ? void 0 : _a.latency) !== null && _b !== void 0 ? _b : 0 },
320
+ ];
321
+ let result = -1;
322
+ while (queue.length > 0) {
323
+ const { nodeId, latency } = queue.shift();
324
+ if (nodeId === targetId) {
325
+ result = Math.max(result, latency);
326
+ continue;
327
+ }
328
+ if (visited.has(nodeId))
329
+ continue;
330
+ visited.add(nodeId);
331
+ for (const edge of this._edges) {
332
+ if (edge.sourceId === nodeId) {
333
+ const targetNode = this._nodes.get(edge.targetId);
334
+ const targetLatency = targetNode ? targetNode.latency : 0;
335
+ queue.push({
336
+ nodeId: edge.targetId,
337
+ latency: latency + targetLatency,
338
+ });
339
+ }
340
+ }
341
+ }
342
+ return result;
343
+ }
344
+ /**
345
+ * Compute the maximum latency across any path from a source node to
346
+ * the master (or any terminal node). This is the worst-case latency
347
+ * that must be compensated for.
348
+ */
349
+ getMaxLatency() {
350
+ var _a, _b, _c;
351
+ // Find terminal nodes (nodes with no outgoing edges)
352
+ const hasOutgoing = new Set();
353
+ for (const edge of this._edges) {
354
+ hasOutgoing.add(edge.sourceId);
355
+ }
356
+ const terminals = Array.from(this._nodes.keys()).filter(id => !hasOutgoing.has(id));
357
+ // Find source nodes (nodes with no incoming edges)
358
+ const hasIncoming = new Set();
359
+ for (const edge of this._edges) {
360
+ hasIncoming.add(edge.targetId);
361
+ }
362
+ const sources = Array.from(this._nodes.keys()).filter(id => !hasIncoming.has(id));
363
+ // Compute max latency over all source -> terminal paths
364
+ let maxLatency = 0;
365
+ for (const src of sources) {
366
+ for (const dst of terminals) {
367
+ const pathLatency = this.getLatencyForPath(src, dst);
368
+ if (pathLatency > maxLatency) {
369
+ maxLatency = pathLatency;
370
+ }
371
+ }
372
+ }
373
+ // If graph is a single connected component, also check by using
374
+ // longest-path via topological order for efficiency
375
+ try {
376
+ const order = this.getProcessingOrder();
377
+ const dist = new Map();
378
+ for (const id of order) {
379
+ dist.set(id, (_b = (_a = this._nodes.get(id)) === null || _a === void 0 ? void 0 : _a.latency) !== null && _b !== void 0 ? _b : 0);
380
+ }
381
+ for (const id of order) {
382
+ const currentDist = dist.get(id);
383
+ for (const edge of this._edges) {
384
+ if (edge.sourceId === id) {
385
+ const targetNode = this._nodes.get(edge.targetId);
386
+ const targetLatency = targetNode ? targetNode.latency : 0;
387
+ const newDist = currentDist + targetLatency;
388
+ if (newDist > ((_c = dist.get(edge.targetId)) !== null && _c !== void 0 ? _c : 0)) {
389
+ dist.set(edge.targetId, newDist);
390
+ }
391
+ }
392
+ }
393
+ }
394
+ for (const d of dist.values()) {
395
+ if (d > maxLatency)
396
+ maxLatency = d;
397
+ }
398
+ }
399
+ catch (_d) {
400
+ // Graph has a cycle — fall back to the BFS result above
401
+ }
402
+ return maxLatency;
403
+ }
404
+ // ─── Latency compensation ────────────────────────────────────────────
405
+ /**
406
+ * Compute the per-node compensation delay so that all signal paths
407
+ * arrive time-aligned at the master / terminal nodes.
408
+ *
409
+ * For each node, the compensation delay is:
410
+ * maxPathLatency - pathLatencyThroughThisNode
411
+ *
412
+ * where `maxPathLatency` is the longest cumulative latency path in the
413
+ * entire graph.
414
+ */
415
+ computeCompensationDelays() {
416
+ var _a, _b, _c, _d, _e, _f, _g;
417
+ const delays = new Map();
418
+ const maxLatency = this.getMaxLatency();
419
+ // For each node, compute its path latency from itself to any
420
+ // terminal (i.e. the remaining latency after this node).
421
+ // The compensation delay = maxLatency - (latency from source
422
+ // through this node to terminal).
423
+ //
424
+ // A simpler and more robust approach: compute the longest path
425
+ // from each node to any terminal, then compensation =
426
+ // maxLatency - longestDownstreamPath.
427
+ // Find terminal nodes
428
+ const hasOutgoing = new Set();
429
+ for (const edge of this._edges) {
430
+ hasOutgoing.add(edge.sourceId);
431
+ }
432
+ const terminals = Array.from(this._nodes.keys()).filter(id => !hasOutgoing.has(id));
433
+ // Use reverse topological order to compute longest downstream path
434
+ let order;
435
+ try {
436
+ order = this.getProcessingOrder();
437
+ }
438
+ catch (_h) {
439
+ // Cycle present — return zero compensation for all nodes
440
+ for (const id of this._nodes.keys()) {
441
+ delays.set(id, 0);
442
+ }
443
+ return delays;
444
+ }
445
+ // longestDown[id] = longest path from id to any terminal (inclusive)
446
+ const longestDown = new Map();
447
+ for (const id of this._nodes.keys()) {
448
+ longestDown.set(id, (_b = (_a = this._nodes.get(id)) === null || _a === void 0 ? void 0 : _a.latency) !== null && _b !== void 0 ? _b : 0);
449
+ }
450
+ // Build forward adjacency
451
+ const forwardAdj = new Map();
452
+ for (const id of this._nodes.keys()) {
453
+ forwardAdj.set(id, []);
454
+ }
455
+ for (const edge of this._edges) {
456
+ if (forwardAdj.has(edge.sourceId)) {
457
+ forwardAdj.get(edge.sourceId).push(edge.targetId);
458
+ }
459
+ }
460
+ // Process in reverse topological order
461
+ for (let i = order.length - 1; i >= 0; i--) {
462
+ const id = order[i];
463
+ const nodeLatency = (_d = (_c = this._nodes.get(id)) === null || _c === void 0 ? void 0 : _c.latency) !== null && _d !== void 0 ? _d : 0;
464
+ let maxDown = 0;
465
+ for (const neighbor of (_e = forwardAdj.get(id)) !== null && _e !== void 0 ? _e : []) {
466
+ const downLatency = (_f = longestDown.get(neighbor)) !== null && _f !== void 0 ? _f : 0;
467
+ if (downLatency > maxDown) {
468
+ maxDown = downLatency;
469
+ }
470
+ }
471
+ longestDown.set(id, nodeLatency + maxDown);
472
+ }
473
+ // Compensation delay = maxLatency - longestDownstreamPath
474
+ for (const id of this._nodes.keys()) {
475
+ const downstream = (_g = longestDown.get(id)) !== null && _g !== void 0 ? _g : 0;
476
+ delays.set(id, Math.max(0, maxLatency - downstream));
477
+ }
478
+ return delays;
479
+ }
480
+ // ─── Visualization helpers ───────────────────────────────────────────
481
+ /**
482
+ * Assign depth levels to each node for visualization (e.g. source
483
+ * tracks at level 0, buses at level 1, master at level 2).
484
+ *
485
+ * Uses BFS from source nodes (zero in-degree).
486
+ */
487
+ getLevels() {
488
+ var _a, _b, _c;
489
+ const levels = new Map();
490
+ // Build in-degree and forward adjacency
491
+ const inDegree = new Map();
492
+ const forwardAdj = new Map();
493
+ for (const id of this._nodes.keys()) {
494
+ inDegree.set(id, 0);
495
+ forwardAdj.set(id, []);
496
+ }
497
+ for (const edge of this._edges) {
498
+ if (!this._nodes.has(edge.sourceId) || !this._nodes.has(edge.targetId)) {
499
+ continue;
500
+ }
501
+ inDegree.set(edge.targetId, ((_a = inDegree.get(edge.targetId)) !== null && _a !== void 0 ? _a : 0) + 1);
502
+ forwardAdj.get(edge.sourceId).push(edge.targetId);
503
+ }
504
+ // BFS from source nodes
505
+ const queue = [];
506
+ for (const [id, deg] of inDegree) {
507
+ if (deg === 0) {
508
+ queue.push({ id, level: 0 });
509
+ levels.set(id, 0);
510
+ }
511
+ }
512
+ while (queue.length > 0) {
513
+ const { id, level } = queue.shift();
514
+ for (const neighbor of (_b = forwardAdj.get(id)) !== null && _b !== void 0 ? _b : []) {
515
+ const existingLevel = (_c = levels.get(neighbor)) !== null && _c !== void 0 ? _c : -1;
516
+ const newLevel = level + 1;
517
+ if (newLevel > existingLevel) {
518
+ levels.set(neighbor, newLevel);
519
+ queue.push({ id: neighbor, level: newLevel });
520
+ }
521
+ }
522
+ }
523
+ return levels;
524
+ }
525
+ /**
526
+ * Export the graph as a plain JSON structure for persistence or
527
+ * visualization.
528
+ */
529
+ toJSON() {
530
+ return {
531
+ nodes: Array.from(this._nodes.values()),
532
+ edges: [...this._edges],
533
+ };
534
+ }
535
+ /**
536
+ * Restore a RoutingGraph from a JSON snapshot.
537
+ */
538
+ static fromJSON(data) {
539
+ const graph = new RoutingGraph();
540
+ for (const node of data.nodes) {
541
+ graph._nodes.set(node.id, node);
542
+ }
543
+ graph._edges = [...data.edges];
544
+ return graph;
545
+ }
546
+ }
547
+ //# sourceMappingURL=RoutingGraph.js.map