@libraz/libsonare 1.7.1 → 1.8.0

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 (303) hide show
  1. package/NOTICE +178 -0
  2. package/README.md +26 -170
  3. package/dist/_chain_config.d.ts +14 -0
  4. package/dist/_chain_config.d.ts.map +1 -0
  5. package/dist/_effects_common.d.ts +6 -0
  6. package/dist/_effects_common.d.ts.map +1 -0
  7. package/dist/_feature_validation.d.ts +8 -0
  8. package/dist/_feature_validation.d.ts.map +1 -0
  9. package/dist/_fft_options.d.ts +24 -0
  10. package/dist/_fft_options.d.ts.map +1 -0
  11. package/dist/align_take.d.ts +50 -0
  12. package/dist/align_take.d.ts.map +1 -0
  13. package/dist/analysis.d.ts +29 -5837
  14. package/dist/analysis.d.ts.map +1 -0
  15. package/dist/analysis.js +873 -722
  16. package/dist/analysis.js.map +1 -1
  17. package/dist/analysis_helpers.d.ts +9 -0
  18. package/dist/analysis_helpers.d.ts.map +1 -0
  19. package/dist/audio.d.ts +163 -0
  20. package/dist/audio.d.ts.map +1 -0
  21. package/dist/clip_page_streamer.d.ts +133 -0
  22. package/dist/clip_page_streamer.d.ts.map +1 -0
  23. package/dist/codes.d.ts +44 -0
  24. package/dist/codes.d.ts.map +1 -0
  25. package/dist/effects_mastering.d.ts +23 -0
  26. package/dist/effects_mastering.d.ts.map +1 -0
  27. package/dist/effects_note_ops.d.ts +477 -0
  28. package/dist/effects_note_ops.d.ts.map +1 -0
  29. package/dist/effects_percussive.d.ts +185 -0
  30. package/dist/effects_percussive.d.ts.map +1 -0
  31. package/dist/effects_separation.d.ts +65 -0
  32. package/dist/effects_separation.d.ts.map +1 -0
  33. package/dist/effects_spectral.d.ts +28 -0
  34. package/dist/effects_spectral.d.ts.map +1 -0
  35. package/dist/effects_timepitch.d.ts +129 -0
  36. package/dist/effects_timepitch.d.ts.map +1 -0
  37. package/dist/effects_voice_change.d.ts +53 -0
  38. package/dist/effects_voice_change.d.ts.map +1 -0
  39. package/dist/errors.d.ts +51 -0
  40. package/dist/errors.d.ts.map +1 -0
  41. package/dist/feature_core.d.ts +341 -0
  42. package/dist/feature_core.d.ts.map +1 -0
  43. package/dist/feature_decompose.d.ts +278 -0
  44. package/dist/feature_decompose.d.ts.map +1 -0
  45. package/dist/feature_inverse.d.ts +128 -0
  46. package/dist/feature_inverse.d.ts.map +1 -0
  47. package/dist/feature_loudness.d.ts +66 -0
  48. package/dist/feature_loudness.d.ts.map +1 -0
  49. package/dist/feature_music.d.ts +307 -0
  50. package/dist/feature_music.d.ts.map +1 -0
  51. package/dist/feature_pitch.d.ts +108 -0
  52. package/dist/feature_pitch.d.ts.map +1 -0
  53. package/dist/feature_resample.d.ts +16 -0
  54. package/dist/feature_resample.d.ts.map +1 -0
  55. package/dist/feature_spectral.d.ts +137 -0
  56. package/dist/feature_spectral.d.ts.map +1 -0
  57. package/dist/feature_spectrogram.d.ts +198 -0
  58. package/dist/feature_spectrogram.d.ts.map +1 -0
  59. package/dist/features.d.ts +10 -0
  60. package/dist/features.d.ts.map +1 -0
  61. package/dist/hrtf/default.shrf +0 -0
  62. package/dist/index.d.ts +74 -7329
  63. package/dist/index.d.ts.map +1 -0
  64. package/dist/index.js +3816 -1359
  65. package/dist/index.js.map +1 -1
  66. package/dist/instrument_types.d.ts +517 -0
  67. package/dist/instrument_types.d.ts.map +1 -0
  68. package/dist/live_audio.d.ts +35 -0
  69. package/dist/live_audio.d.ts.map +1 -0
  70. package/dist/mastering_chain.d.ts +213 -0
  71. package/dist/mastering_chain.d.ts.map +1 -0
  72. package/dist/mastering_core.d.ts +457 -0
  73. package/dist/mastering_core.d.ts.map +1 -0
  74. package/dist/mastering_dynamics.d.ts +80 -0
  75. package/dist/mastering_dynamics.d.ts.map +1 -0
  76. package/dist/metering.d.ts +287 -0
  77. package/dist/metering.d.ts.map +1 -0
  78. package/dist/mixer.d.ts +464 -0
  79. package/dist/mixer.d.ts.map +1 -0
  80. package/dist/mixing_assistant.d.ts +62 -0
  81. package/dist/mixing_assistant.d.ts.map +1 -0
  82. package/dist/mixing_oneshot.d.ts +40 -0
  83. package/dist/mixing_oneshot.d.ts.map +1 -0
  84. package/dist/module_state.d.ts +15 -0
  85. package/dist/module_state.d.ts.map +1 -0
  86. package/dist/opfs_clip_pages.d.ts +28 -0
  87. package/dist/opfs_clip_pages.d.ts.map +1 -0
  88. package/dist/playback_renderer.d.ts +128 -0
  89. package/dist/playback_renderer.d.ts.map +1 -0
  90. package/dist/polyphony.d.ts +202 -0
  91. package/dist/polyphony.d.ts.map +1 -0
  92. package/dist/project.d.ts +8 -0
  93. package/dist/project.d.ts.map +1 -0
  94. package/dist/project_class.d.ts +562 -0
  95. package/dist/project_class.d.ts.map +1 -0
  96. package/dist/project_internal.d.ts +194 -0
  97. package/dist/project_internal.d.ts.map +1 -0
  98. package/dist/project_synth.d.ts +74 -0
  99. package/dist/project_synth.d.ts.map +1 -0
  100. package/dist/project_types.d.ts +652 -0
  101. package/dist/project_types.d.ts.map +1 -0
  102. package/dist/public_types.d.ts +185 -0
  103. package/dist/public_types.d.ts.map +1 -0
  104. package/dist/public_types_acoustic.d.ts +215 -0
  105. package/dist/public_types_acoustic.d.ts.map +1 -0
  106. package/dist/public_types_mastering.d.ts +510 -0
  107. package/dist/public_types_mastering.d.ts.map +1 -0
  108. package/dist/public_types_mixing.d.ts +436 -0
  109. package/dist/public_types_mixing.d.ts.map +1 -0
  110. package/dist/public_types_music.d.ts +619 -0
  111. package/dist/public_types_music.d.ts.map +1 -0
  112. package/dist/public_types_playback.d.ts +164 -0
  113. package/dist/public_types_playback.d.ts.map +1 -0
  114. package/dist/public_types_realtime.d.ts +174 -0
  115. package/dist/public_types_realtime.d.ts.map +1 -0
  116. package/dist/public_types_repair.d.ts +424 -0
  117. package/dist/public_types_repair.d.ts.map +1 -0
  118. package/dist/public_types_spectral.d.ts +697 -0
  119. package/dist/public_types_spectral.d.ts.map +1 -0
  120. package/dist/quick_analysis.d.ts +445 -0
  121. package/dist/quick_analysis.d.ts.map +1 -0
  122. package/dist/realtime_engine.d.ts +850 -0
  123. package/dist/realtime_engine.d.ts.map +1 -0
  124. package/dist/realtime_voice_changer.d.ts +158 -0
  125. package/dist/realtime_voice_changer.d.ts.map +1 -0
  126. package/dist/repair_dereverb.d.ts +187 -0
  127. package/dist/repair_dereverb.d.ts.map +1 -0
  128. package/dist/repair_impulsive.d.ts +186 -0
  129. package/dist/repair_impulsive.d.ts.map +1 -0
  130. package/dist/repair_noise.d.ts +239 -0
  131. package/dist/repair_noise.d.ts.map +1 -0
  132. package/dist/repair_trim.d.ts +123 -0
  133. package/dist/repair_trim.d.ts.map +1 -0
  134. package/dist/sample_bank.d.ts +84 -0
  135. package/dist/sample_bank.d.ts.map +1 -0
  136. package/dist/scale.d.ts +10 -0
  137. package/dist/scale.d.ts.map +1 -0
  138. package/dist/schemas/mixer-scene.schema.json +393 -0
  139. package/dist/schemas/playback-renderer-config.schema.json +392 -0
  140. package/dist/sonare-analysis.d.ts +8 -0
  141. package/dist/sonare-analysis.js +2 -2
  142. package/dist/sonare-analysis.wasm +0 -0
  143. package/dist/sonare.d.ts +3909 -0
  144. package/dist/sonare.js +2 -2
  145. package/dist/sonare.wasm +0 -0
  146. package/dist/stream_analyzer.d.ts +163 -0
  147. package/dist/stream_analyzer.d.ts.map +1 -0
  148. package/dist/stream_types.d.ts +214 -0
  149. package/dist/stream_types.d.ts.map +1 -0
  150. package/dist/streaming_mixing.d.ts +6 -0
  151. package/dist/streaming_mixing.d.ts.map +1 -0
  152. package/dist/streaming_processors.d.ts +335 -0
  153. package/dist/streaming_processors.d.ts.map +1 -0
  154. package/dist/transcribe.d.ts +77 -0
  155. package/dist/transcribe.d.ts.map +1 -0
  156. package/dist/validation.d.ts +140 -0
  157. package/dist/validation.d.ts.map +1 -0
  158. package/dist/web_midi.d.ts +77 -0
  159. package/dist/web_midi.d.ts.map +1 -0
  160. package/dist/worker.d.ts +5 -48
  161. package/dist/worker.d.ts.map +1 -0
  162. package/dist/worker.js +94 -41
  163. package/dist/worker.js.map +1 -1
  164. package/dist/worker_client.d.ts +96 -0
  165. package/dist/worker_client.d.ts.map +1 -0
  166. package/dist/worker_protocol.d.ts +43 -0
  167. package/dist/worker_protocol.d.ts.map +1 -0
  168. package/dist/worklet/audio_types.d.ts +21 -0
  169. package/dist/worklet/audio_types.d.ts.map +1 -0
  170. package/dist/worklet/engine-automation.d.ts +29 -0
  171. package/dist/worklet/engine-automation.d.ts.map +1 -0
  172. package/dist/worklet/engine-capture-facade.d.ts +35 -0
  173. package/dist/worklet/engine-capture-facade.d.ts.map +1 -0
  174. package/dist/worklet/engine-clips.d.ts +23 -0
  175. package/dist/worklet/engine-clips.d.ts.map +1 -0
  176. package/dist/worklet/engine-markers.d.ts +40 -0
  177. package/dist/worklet/engine-markers.d.ts.map +1 -0
  178. package/dist/worklet/engine-mixer-facade.d.ts +128 -0
  179. package/dist/worklet/engine-mixer-facade.d.ts.map +1 -0
  180. package/dist/worklet/engine-node.d.ts +81 -0
  181. package/dist/worklet/engine-node.d.ts.map +1 -0
  182. package/dist/worklet/engine-offline.d.ts +81 -0
  183. package/dist/worklet/engine-offline.d.ts.map +1 -0
  184. package/dist/worklet/engine-options.d.ts +12 -0
  185. package/dist/worklet/engine-options.d.ts.map +1 -0
  186. package/dist/worklet/engine-parameter-facade.d.ts +106 -0
  187. package/dist/worklet/engine-parameter-facade.d.ts.map +1 -0
  188. package/dist/worklet/engine-processor.d.ts +68 -0
  189. package/dist/worklet/engine-processor.d.ts.map +1 -0
  190. package/dist/worklet/engine-register.d.ts +2 -0
  191. package/dist/worklet/engine-register.d.ts.map +1 -0
  192. package/dist/worklet/engine-strips.d.ts +73 -0
  193. package/dist/worklet/engine-strips.d.ts.map +1 -0
  194. package/dist/worklet/engine-sync.d.ts +37 -0
  195. package/dist/worklet/engine-sync.d.ts.map +1 -0
  196. package/dist/worklet/engine-tempo-facade.d.ts +48 -0
  197. package/dist/worklet/engine-tempo-facade.d.ts.map +1 -0
  198. package/dist/worklet/engine.d.ts +397 -0
  199. package/dist/worklet/engine.d.ts.map +1 -0
  200. package/dist/worklet/guards.d.ts +47 -0
  201. package/dist/worklet/guards.d.ts.map +1 -0
  202. package/dist/worklet/messages.d.ts +710 -0
  203. package/dist/worklet/messages.d.ts.map +1 -0
  204. package/dist/worklet/mixer-processor.d.ts +46 -0
  205. package/dist/worklet/mixer-processor.d.ts.map +1 -0
  206. package/dist/worklet/playback-processor.d.ts +62 -0
  207. package/dist/worklet/playback-processor.d.ts.map +1 -0
  208. package/dist/worklet/protocol.d.ts +323 -0
  209. package/dist/worklet/protocol.d.ts.map +1 -0
  210. package/dist/worklet/voice-changer-processor.d.ts +41 -0
  211. package/dist/worklet/voice-changer-processor.d.ts.map +1 -0
  212. package/dist/worklet.d.ts +16 -2142
  213. package/dist/worklet.d.ts.map +1 -0
  214. package/dist/worklet.js +2889 -466
  215. package/dist/worklet.js.map +1 -1
  216. package/package.json +23 -12
  217. package/src/_effects_common.ts +17 -0
  218. package/src/_feature_validation.ts +34 -0
  219. package/src/_fft_options.ts +39 -0
  220. package/src/align_take.ts +64 -0
  221. package/src/analysis.ts +56 -3
  222. package/src/analysis_helpers.ts +7 -0
  223. package/src/audio.ts +106 -3
  224. package/src/codes.ts +39 -2
  225. package/src/effects_mastering.ts +97 -22
  226. package/src/effects_note_ops.ts +635 -0
  227. package/src/effects_percussive.ts +217 -0
  228. package/src/effects_separation.ts +150 -0
  229. package/src/effects_spectral.ts +60 -0
  230. package/src/effects_timepitch.ts +377 -0
  231. package/src/errors.ts +23 -1
  232. package/src/feature_core.ts +127 -2
  233. package/src/feature_decompose.ts +633 -0
  234. package/src/feature_inverse.ts +454 -0
  235. package/src/feature_loudness.ts +125 -0
  236. package/src/feature_music.ts +107 -14
  237. package/src/feature_pitch.ts +96 -1
  238. package/src/feature_spectral.ts +16 -611
  239. package/src/feature_spectrogram.ts +63 -450
  240. package/src/features.ts +36 -22
  241. package/src/index.ts +285 -30
  242. package/src/instrument_types.ts +645 -0
  243. package/src/live_audio.ts +27 -1
  244. package/src/mastering_chain.ts +184 -0
  245. package/src/mastering_core.ts +346 -32
  246. package/src/mastering_dynamics.ts +22 -11
  247. package/src/metering.ts +67 -24
  248. package/src/mixer.ts +212 -3
  249. package/src/mixing_assistant.ts +138 -0
  250. package/src/mixing_oneshot.ts +10 -5
  251. package/src/module_state.ts +24 -2
  252. package/src/playback_renderer.ts +252 -0
  253. package/src/polyphony.ts +279 -0
  254. package/src/project.ts +64 -24
  255. package/src/project_class.ts +502 -29
  256. package/src/project_internal.ts +151 -42
  257. package/src/project_synth.ts +67 -1
  258. package/src/project_types.ts +302 -270
  259. package/src/public_types.ts +122 -3
  260. package/src/public_types_acoustic.ts +112 -3
  261. package/src/public_types_mastering.ts +254 -73
  262. package/src/public_types_mixing.ts +363 -1
  263. package/src/public_types_music.ts +312 -2
  264. package/src/public_types_playback.ts +195 -0
  265. package/src/public_types_realtime.ts +39 -7
  266. package/src/public_types_repair.ts +446 -0
  267. package/src/public_types_spectral.ts +487 -1
  268. package/src/quick_analysis.ts +203 -26
  269. package/src/realtime_engine.ts +750 -28
  270. package/src/realtime_voice_changer.ts +55 -1
  271. package/src/repair_dereverb.ts +299 -0
  272. package/src/repair_impulsive.ts +395 -0
  273. package/src/repair_noise.ts +425 -0
  274. package/src/repair_trim.ts +226 -0
  275. package/src/sample_bank.ts +113 -0
  276. package/src/sonare.js.d.ts +1125 -30
  277. package/src/stream_analyzer.ts +36 -4
  278. package/src/stream_types.ts +37 -0
  279. package/src/streaming_mixing.ts +1 -1
  280. package/src/streaming_processors.ts +212 -10
  281. package/src/transcribe.ts +89 -0
  282. package/src/validation.ts +285 -11
  283. package/src/web_midi.ts +1 -6
  284. package/src/worker.ts +18 -2
  285. package/src/worklet/audio_types.ts +37 -0
  286. package/src/worklet/engine-mixer-facade.ts +444 -10
  287. package/src/worklet/engine-node.ts +85 -28
  288. package/src/worklet/engine-offline.ts +14 -8
  289. package/src/worklet/engine-parameter-facade.ts +21 -0
  290. package/src/worklet/engine-processor.ts +307 -71
  291. package/src/worklet/engine-register.ts +32 -18
  292. package/src/worklet/engine-strips.ts +280 -9
  293. package/src/worklet/engine-sync.ts +14 -6
  294. package/src/worklet/engine.ts +365 -31
  295. package/src/worklet/guards.ts +140 -44
  296. package/src/worklet/messages.ts +239 -2
  297. package/src/worklet/mixer-processor.ts +109 -47
  298. package/src/worklet/playback-processor.ts +300 -0
  299. package/src/worklet/protocol.ts +53 -3
  300. package/src/worklet/voice-changer-processor.ts +17 -11
  301. package/src/worklet.ts +22 -0
  302. package/src/effects_transform.ts +0 -718
  303. package/src/mastering_repair.ts +0 -273
@@ -6,6 +6,7 @@ import type {
6
6
  SonareEngineSyncMessage,
7
7
  SonareEngineTransportRequestMessage,
8
8
  SonareEngineTransportResponseMessage,
9
+ SonarePlaybackMessage,
9
10
  SonareRealtimeVoiceChangerMessage,
10
11
  SonareWorkletExternalMidiMessage,
11
12
  SonareWorkletMessage,
@@ -32,52 +33,87 @@ export function isEngineCommandRecord(value: unknown): value is SonareEngineComm
32
33
  return isRecord(value) && typeof value.type === 'number';
33
34
  }
34
35
 
36
+ /**
37
+ * Every discriminant the worklet accepts on the control plane, derived from the
38
+ * `SonareEngineSyncMessage` union rather than restated as literals.
39
+ *
40
+ * The `Record<SonareEngineSyncMessage['type'], true>` annotation rejects a
41
+ * missing key and the object literal's excess-property check rejects a stale
42
+ * one, so a union member that never reaches this table is a compile error
43
+ * instead of a message the port drops in silence.
44
+ */
45
+ export const ENGINE_SYNC_MESSAGE_TYPES: Record<SonareEngineSyncMessage['type'], true> = {
46
+ destroy: true,
47
+ syncAutomation: true,
48
+ syncBuiltinInstrument: true,
49
+ syncBusStripDualPan: true,
50
+ syncBusStripEqBand: true,
51
+ syncBusStripInsertBypassed: true,
52
+ syncBusStripInsertParamByName: true,
53
+ syncBusStripPan: true,
54
+ syncBusStripPanLaw: true,
55
+ syncBusStripPanMode: true,
56
+ syncCapture: true,
57
+ syncClearMidiFx: true,
58
+ syncClearMidiInputSource: true,
59
+ syncClipPage: true,
60
+ syncClipPageClear: true,
61
+ syncClipPageCommit: true,
62
+ syncClipPageDestroy: true,
63
+ syncClipPagePrefetchFrames: true,
64
+ syncClipPageProvider: true,
65
+ syncClips: true,
66
+ syncClipsDelta: true,
67
+ syncExternalMidiClock: true,
68
+ syncLoadSoundFont: true,
69
+ syncMarkers: true,
70
+ syncMasterStripEqBand: true,
71
+ syncMasterStripInsertBypassed: true,
72
+ syncMasterStripInsertParamByName: true,
73
+ syncMetronome: true,
74
+ syncMidiCc: true,
75
+ syncMidiCcBinding: true,
76
+ syncMidiChannelPressure: true,
77
+ syncMidiClips: true,
78
+ syncMidiDestinationExternal: true,
79
+ syncMidiFx: true,
80
+ syncMidiInputChannelPressure: true,
81
+ syncMidiInputCc: true,
82
+ syncMidiInputNoteOff: true,
83
+ syncMidiInputNoteOn: true,
84
+ syncMidiInputPitchBend: true,
85
+ syncMidiInputPolyPressure: true,
86
+ syncMidiInputSource: true,
87
+ syncMidiNoteOff: true,
88
+ syncMidiNoteOn: true,
89
+ syncMidiPanic: true,
90
+ syncMidiPitchBend: true,
91
+ syncMidiPolyPressure: true,
92
+ syncMidiSysex: true,
93
+ syncMidiUmp: true,
94
+ syncMixer: true,
95
+ syncParameters: true,
96
+ syncSf2Instrument: true,
97
+ syncSynthInstrument: true,
98
+ syncTempo: true,
99
+ syncTrackStripChannelDelaySamples: true,
100
+ syncTrackStripDualPan: true,
101
+ syncTrackStripEqBand: true,
102
+ syncTrackStripInsertBypassed: true,
103
+ syncTrackStripInsertParamByName: true,
104
+ syncTrackStripPan: true,
105
+ syncTrackStripPanLaw: true,
106
+ syncTrackStripPanMode: true,
107
+ syncWarpVoiceCapacity: true,
108
+ };
109
+
110
+ // A Set rather than a property lookup on the table: an inherited member name
111
+ // ('constructor', 'toString') must not read as an accepted discriminant.
112
+ const engineSyncMessageTypes: ReadonlySet<string> = new Set(Object.keys(ENGINE_SYNC_MESSAGE_TYPES));
113
+
35
114
  export function isEngineSyncMessage(value: unknown): value is SonareEngineSyncMessage {
36
- if (!isRecord(value) || typeof value.type !== 'string') {
37
- return false;
38
- }
39
115
  return (
40
- value.type === 'syncClips' ||
41
- value.type === 'syncClipsDelta' ||
42
- value.type === 'syncClipPageProvider' ||
43
- value.type === 'syncClipPage' ||
44
- value.type === 'syncClipPageClear' ||
45
- value.type === 'syncClipPageCommit' ||
46
- value.type === 'syncClipPageDestroy' ||
47
- value.type === 'syncMidiClips' ||
48
- value.type === 'syncMarkers' ||
49
- value.type === 'syncMetronome' ||
50
- value.type === 'syncAutomation' ||
51
- value.type === 'syncTempo' ||
52
- value.type === 'syncMixer' ||
53
- value.type === 'syncCapture' ||
54
- value.type === 'syncTrackStripEqBand' ||
55
- value.type === 'syncMasterStripEqBand' ||
56
- value.type === 'syncTrackStripInsertBypassed' ||
57
- value.type === 'syncMasterStripInsertBypassed' ||
58
- value.type === 'syncTrackStripInsertParamByName' ||
59
- value.type === 'syncMasterStripInsertParamByName' ||
60
- value.type === 'syncBusStripInsertParamByName' ||
61
- value.type === 'syncTrackStripPan' ||
62
- value.type === 'syncTrackStripPanLaw' ||
63
- value.type === 'syncTrackStripPanMode' ||
64
- value.type === 'syncTrackStripDualPan' ||
65
- value.type === 'syncTrackStripChannelDelaySamples' ||
66
- value.type === 'syncBuiltinInstrument' ||
67
- value.type === 'syncSynthInstrument' ||
68
- value.type === 'syncSf2Instrument' ||
69
- value.type === 'syncLoadSoundFont' ||
70
- value.type === 'syncMidiFx' ||
71
- value.type === 'syncClearMidiFx' ||
72
- value.type === 'syncMidiNoteOn' ||
73
- value.type === 'syncMidiNoteOff' ||
74
- value.type === 'syncMidiCc' ||
75
- value.type === 'syncMidiUmp' ||
76
- value.type === 'syncMidiSysex' ||
77
- value.type === 'syncMidiPanic' ||
78
- value.type === 'syncMidiDestinationExternal' ||
79
- value.type === 'syncExternalMidiClock' ||
80
- value.type === 'destroy'
116
+ isRecord(value) && typeof value.type === 'string' && engineSyncMessageTypes.has(value.type)
81
117
  );
82
118
  }
83
119
 
@@ -225,6 +261,31 @@ export function isRealtimeVoiceChangerMessage(
225
261
  return value.type === 'setConfig' || value.type === 'reset' || value.type === 'destroy';
226
262
  }
227
263
 
264
+ const isOptionalNumber = (value: unknown): boolean =>
265
+ value === undefined || typeof value === 'number';
266
+
267
+ export function isPlaybackMessage(value: unknown): value is SonarePlaybackMessage {
268
+ if (!isRecord(value) || typeof value.type !== 'string') {
269
+ return false;
270
+ }
271
+ switch (value.type) {
272
+ case 'config':
273
+ return typeof value.config === 'string';
274
+ case 'orientation':
275
+ return (
276
+ typeof value.yaw === 'number' &&
277
+ isOptionalNumber(value.pitch) &&
278
+ isOptionalNumber(value.roll)
279
+ );
280
+ case 'reset':
281
+ case 'diagnostics':
282
+ case 'destroy':
283
+ return true;
284
+ default:
285
+ return false;
286
+ }
287
+ }
288
+
228
289
  export function isEngineTelemetryRecord(value: unknown): value is SonareEngineTelemetryRecord {
229
290
  return (
230
291
  isRecord(value) &&
@@ -273,3 +334,38 @@ export function isMeterSnapshot(value: unknown): value is SonareWorkletMeterSnap
273
334
  (typeof value.targetId === 'number' || value.targetId === undefined)
274
335
  );
275
336
  }
337
+
338
+ /**
339
+ * Resolves an integer option, refusing anything the field's own domain cannot
340
+ * hold instead of rounding it into range.
341
+ *
342
+ * Rounding hands the caller a working object configured with a value they never
343
+ * asked for, and nothing downstream can tell that apart from the value they
344
+ * meant. A ceiling, where one exists, stays with the layer that owns it.
345
+ */
346
+ export function requireIntegerOption(
347
+ value: number | undefined,
348
+ fallback: number,
349
+ name: string,
350
+ minimum: number,
351
+ ): number {
352
+ const resolved = value ?? fallback;
353
+ if (!Number.isSafeInteger(resolved) || resolved < minimum) {
354
+ throw new RangeError(`${name} must be an integer of at least ${minimum}`);
355
+ }
356
+ return resolved;
357
+ }
358
+
359
+ /** As {@link requireIntegerOption}, for a field whose domain admits either sign. */
360
+ export function requireInteger(value: number | undefined, fallback: number, name: string): number {
361
+ const resolved = value ?? fallback;
362
+ if (!Number.isSafeInteger(resolved)) {
363
+ throw new RangeError(`${name} must be an integer`);
364
+ }
365
+ return resolved;
366
+ }
367
+
368
+ /** Resolves the channel count every worklet entry point accepts on its options. */
369
+ export function requireChannelCount(channelCount: number | undefined, fallback: number): number {
370
+ return requireIntegerOption(channelCount, fallback, 'channelCount', 1);
371
+ }
@@ -11,6 +11,8 @@ import type {
11
11
  EngineTimeSignatureSegment,
12
12
  EngineTrackLane,
13
13
  EngineTransportState,
14
+ PlaybackDiagnostics,
15
+ PlaybackRendererConfig,
14
16
  RealtimeVoiceChangerConfigInput,
15
17
  RealtimeVoiceChangerPodConfig,
16
18
  } from '../index';
@@ -67,6 +69,13 @@ export interface SonareRealtimeEngineWorkletProcessorOptions {
67
69
  /** Lock-free worklet-to-main-thread MIDI-1 output ring. */
68
70
  externalMidiSharedBuffer?: SharedArrayBuffer;
69
71
  externalMidiRingCapacity?: number;
72
+ /**
73
+ * Route the PFL/AFL cue bus to the processor's SECOND output instead of
74
+ * folding it into the program output. Off by default, so an existing
75
+ * single-output host keeps its current mix sample for sample. The node must
76
+ * be constructed with two outputs for the cue to be audible.
77
+ */
78
+ cueOutput?: boolean;
70
79
  }
71
80
 
72
81
  export interface SonareRealtimeVoiceChangerWorkletProcessorOptions {
@@ -95,6 +104,87 @@ export type SonareRealtimeVoiceChangerMessage =
95
104
  | SonareRealtimeVoiceChangerResetMessage
96
105
  | SonareRealtimeVoiceChangerDestroyMessage;
97
106
 
107
+ export interface SonarePlaybackWorkletProcessorOptions {
108
+ /** Renderer configuration; parsed once, in the processor constructor. Default `{}`. */
109
+ config?: PlaybackRendererConfig | string;
110
+ /**
111
+ * SHRF v1 bytes, required for a headphones target (e.g. the package asset
112
+ * `./hrtf/default.shrf`). Copied into the renderer at construction.
113
+ */
114
+ hrtf?: ArrayBuffer | Uint8Array;
115
+ /** Largest render quantum the processor accepts. Default 128. */
116
+ maxBlockSize?: number;
117
+ /** Defaults to the AudioWorkletGlobalScope `sampleRate`, then 48000. */
118
+ sampleRate?: number;
119
+ }
120
+
121
+ export interface SonarePlaybackNodeOptions extends SonarePlaybackWorkletProcessorOptions {
122
+ processorName?: string;
123
+ nodeFactory?: (
124
+ context: BaseAudioContext,
125
+ processorName: string,
126
+ options: AudioWorkletNodeOptions,
127
+ ) => AudioWorkletNode;
128
+ }
129
+
130
+ export interface SonarePlaybackConfigMessage {
131
+ type: 'config';
132
+ /** A complete configuration document, serialized on the main thread. */
133
+ config: string;
134
+ }
135
+
136
+ export interface SonarePlaybackOrientationMessage {
137
+ type: 'orientation';
138
+ /** Degrees; see `PlaybackRenderer.setHeadOrientation`. */
139
+ yaw: number;
140
+ pitch?: number;
141
+ roll?: number;
142
+ }
143
+
144
+ /** Clears the pipeline after a seek; the handler runs between render quanta. */
145
+ export interface SonarePlaybackResetMessage {
146
+ type: 'reset';
147
+ }
148
+
149
+ /** Requests a {@link SonarePlaybackDiagnosticsReplyMessage}. */
150
+ export interface SonarePlaybackDiagnosticsRequestMessage {
151
+ type: 'diagnostics';
152
+ }
153
+
154
+ export interface SonarePlaybackDestroyMessage {
155
+ type: 'destroy';
156
+ }
157
+
158
+ export type SonarePlaybackMessage =
159
+ | SonarePlaybackConfigMessage
160
+ | SonarePlaybackOrientationMessage
161
+ | SonarePlaybackResetMessage
162
+ | SonarePlaybackDiagnosticsRequestMessage
163
+ | SonarePlaybackDestroyMessage;
164
+
165
+ /** The renderer's diagnostics plus the worklet's own block counter. */
166
+ export interface SonarePlaybackWorkletDiagnostics extends PlaybackDiagnostics {
167
+ /**
168
+ * Render quanta whose input channel count the renderer does not accept
169
+ * (not 1, 2, 6 or 8 under `"auto"`; not the fixed layout's count otherwise).
170
+ * Each was rendered as silence on the active input layout, so the timeline
171
+ * still advanced.
172
+ */
173
+ unsupported_input_blocks: number;
174
+ }
175
+
176
+ export interface SonarePlaybackDiagnosticsReplyMessage {
177
+ type: 'diagnostics';
178
+ diagnostics: SonarePlaybackWorkletDiagnostics;
179
+ }
180
+
181
+ /** Posted when a control message is refused (e.g. a changed prepare key). */
182
+ export interface SonarePlaybackErrorMessage {
183
+ type: 'error';
184
+ request: SonarePlaybackMessage['type'];
185
+ message: string;
186
+ }
187
+
98
188
  export interface SonareRealtimeEngineNodeCapabilities {
99
189
  mode: 'sab' | 'postMessage';
100
190
  runtimeTarget: 'embind';
@@ -105,6 +195,11 @@ export interface SonareRealtimeEngineNodeCapabilities {
105
195
  clipPageRequestsRealtimeSafe: boolean;
106
196
  /** True when external MIDI uses the SAB output ring rather than postMessage. */
107
197
  externalMidiRealtimeSafe: boolean;
198
+ /**
199
+ * True when the node carries a second output fed by the PFL/AFL cue bus. When
200
+ * false the cue is folded into the program output, as it always was.
201
+ */
202
+ cueOutput: boolean;
108
203
  engineAbiVersion?: number;
109
204
  expectedEngineAbiVersion?: number;
110
205
  abiCompatible?: boolean;
@@ -181,7 +276,13 @@ export interface SonareWorkletExternalMidiMessage {
181
276
  /** A control-plane sync message that the worklet rejected without crashing. */
182
277
  export interface SonareEngineSyncErrorMessage {
183
278
  type: 'syncError';
184
- syncType: SonareEngineSyncMessage['type'];
279
+ /**
280
+ * Discriminant of the rejected sync. Usually a known member, but a
281
+ * `sync`-prefixed type this build does not recognize is reported here too
282
+ * rather than dropped, so the set is open. `Record<never, never>` keeps the
283
+ * known members as editor completions instead of collapsing to `string`.
284
+ */
285
+ syncType: SonareEngineSyncMessage['type'] | (string & Record<never, never>);
185
286
  message: string;
186
287
  }
187
288
 
@@ -284,6 +385,27 @@ export interface SonareEngineSyncClipPageMessage {
284
385
  channels: Float32Array[];
285
386
  }
286
387
 
388
+ /**
389
+ * Sets the worklet engine's clip-page look-ahead window in timeline frames, so
390
+ * the audio thread reports the pages it is about to read before it reads them.
391
+ * 0 disables the look-ahead.
392
+ */
393
+ export interface SonareEngineSyncClipPagePrefetchFramesMessage {
394
+ type: 'syncClipPagePrefetchFrames';
395
+ frames: number;
396
+ }
397
+
398
+ /**
399
+ * Sets the worklet engine's concurrent time-stretch voice capacity. The
400
+ * capacity was already validated (and applied to the offline engine) by the
401
+ * caller, so the worklet side just mirrors the accepted value; the pool
402
+ * rebuild itself happens on the audio thread, at the next block boundary.
403
+ */
404
+ export interface SonareEngineSyncWarpVoiceCapacityMessage {
405
+ type: 'syncWarpVoiceCapacity';
406
+ voices: number;
407
+ }
408
+
287
409
  /** Evicts one page after the main-thread sliding window advances. */
288
410
  export interface SonareEngineSyncClipPageClearMessage {
289
411
  type: 'syncClipPageClear';
@@ -356,15 +478,57 @@ export interface SonareEngineSyncTempoMessage {
356
478
  timeSignatureSegments?: EngineTimeSignatureSegment[];
357
479
  }
358
480
 
481
+ export type SonareEngineSyncMixerInsertParamOverride =
482
+ | {
483
+ kind: 'track';
484
+ trackId: number;
485
+ insertIndex: number;
486
+ paramName: string;
487
+ value: number;
488
+ }
489
+ | {
490
+ kind: 'bus';
491
+ busId: number;
492
+ insertIndex: number;
493
+ paramName: string;
494
+ value: number;
495
+ }
496
+ | {
497
+ kind: 'master';
498
+ insertIndex: number;
499
+ paramName: string;
500
+ value: number;
501
+ };
502
+
359
503
  export interface SonareEngineSyncMixerMessage {
360
504
  type: 'syncMixer';
505
+ /** Apply only supplied sidechain bindings; preserve current mixer topology. */
506
+ sidechainDelta?: boolean;
361
507
  lanes: EngineTrackLane[];
362
508
  buses?: EngineBus[];
363
509
  trackStrips?: Array<{ trackId: number; sceneJson: string }>;
364
510
  busStrips?: Array<{ busId: number; sceneJson: string }>;
365
511
  masterStripJson?: string;
512
+ /** Retained by-name insert values, applied after strip and sidechain replay. */
513
+ insertParamOverrides?: SonareEngineSyncMixerInsertParamOverride[];
514
+ /** Explicit full strip replacements that must reset retained insert state. */
515
+ forceInsertResets?: Array<
516
+ { kind: 'track'; trackId: number } | { kind: 'bus'; busId: number } | { kind: 'master' }
517
+ >;
366
518
  /** Lane insert sidechain bindings (replayed after lanes/strips). */
367
519
  laneSidechains?: Array<{ trackId: number; insertIndex: number; sourceTrackId: number }>;
520
+ /**
521
+ * Bus insert sidechain bindings (replayed after lanes/buses/strips).
522
+ * `sourceKind` is a `SonareSidechainSourceKind` ordinal (0 track / 1 bus).
523
+ */
524
+ busSidechains?: Array<{
525
+ busId: number;
526
+ insertIndex: number;
527
+ sourceKind: number;
528
+ sourceId: number;
529
+ }>;
530
+ /** Master strip insert sidechain bindings. Same `sourceKind` convention. */
531
+ masterSidechains?: Array<{ insertIndex: number; sourceKind: number; sourceId: number }>;
368
532
  }
369
533
 
370
534
  export interface SonareEngineSyncCaptureMessage {
@@ -389,6 +553,13 @@ export interface SonareEngineSyncMasterStripEqBandMessage {
389
553
  bandJson: string;
390
554
  }
391
555
 
556
+ export interface SonareEngineSyncBusStripEqBandMessage {
557
+ type: 'syncBusStripEqBand';
558
+ busId: number;
559
+ bandIndex: number;
560
+ bandJson: string;
561
+ }
562
+
392
563
  export interface SonareEngineSyncTrackStripInsertBypassedMessage {
393
564
  type: 'syncTrackStripInsertBypassed';
394
565
  trackId: number;
@@ -427,6 +598,14 @@ export interface SonareEngineSyncBusStripInsertParamByNameMessage {
427
598
  value: number;
428
599
  }
429
600
 
601
+ export interface SonareEngineSyncBusStripInsertBypassedMessage {
602
+ type: 'syncBusStripInsertBypassed';
603
+ busId: number;
604
+ insertIndex: number;
605
+ bypassed: boolean;
606
+ resetOnBypass: boolean;
607
+ }
608
+
430
609
  export interface SonareEngineSyncTrackStripPanMessage {
431
610
  type: 'syncTrackStripPan';
432
611
  trackId: number;
@@ -452,6 +631,31 @@ export interface SonareEngineSyncTrackStripDualPanMessage {
452
631
  rightPan: number;
453
632
  }
454
633
 
634
+ export interface SonareEngineSyncBusStripPanMessage {
635
+ type: 'syncBusStripPan';
636
+ busId: number;
637
+ pan: number;
638
+ }
639
+
640
+ export interface SonareEngineSyncBusStripPanLawMessage {
641
+ type: 'syncBusStripPanLaw';
642
+ busId: number;
643
+ panLaw: number;
644
+ }
645
+
646
+ export interface SonareEngineSyncBusStripPanModeMessage {
647
+ type: 'syncBusStripPanMode';
648
+ busId: number;
649
+ panMode: number;
650
+ }
651
+
652
+ export interface SonareEngineSyncBusStripDualPanMessage {
653
+ type: 'syncBusStripDualPan';
654
+ busId: number;
655
+ leftPan: number;
656
+ rightPan: number;
657
+ }
658
+
455
659
  export interface SonareEngineSyncTrackStripChannelDelaySamplesMessage {
456
660
  type: 'syncTrackStripChannelDelaySamples';
457
661
  trackId: number;
@@ -478,6 +682,8 @@ export interface SonareEngineSyncSf2InstrumentMessage {
478
682
  gain?: number;
479
683
  polyphony?: number;
480
684
  preferModelForModeledFamilies?: boolean;
685
+ clearBankRig?: boolean;
686
+ gsEfxRealization?: 'modern' | 'classic';
481
687
  };
482
688
  }
483
689
 
@@ -520,6 +726,22 @@ export interface SonareEngineSyncMidiUmpMessage {
520
726
  renderFrame: number;
521
727
  }
522
728
 
729
+ /**
730
+ * One of the three per-note expression dimensions, addressed to a destination.
731
+ * `data0`/`data1` carry the dimension's own payload the way the live-input
732
+ * message beside this one does: bend14 / 0, pressure / 0, or note / pressure.
733
+ * A bend is 14-bit, which is why these do not ride the 7-bit CC message.
734
+ */
735
+ export interface SonareEngineSyncMidiExpressionMessage {
736
+ type: 'syncMidiPitchBend' | 'syncMidiChannelPressure' | 'syncMidiPolyPressure';
737
+ destinationId: number;
738
+ group: number;
739
+ channel: number;
740
+ data0: number;
741
+ data1: number;
742
+ renderFrame: number;
743
+ }
744
+
523
745
  export interface SonareEngineSyncMidiSysexMessage {
524
746
  type: 'syncMidiSysex';
525
747
  destinationId: number;
@@ -558,7 +780,13 @@ export interface SonareEngineSyncMidiCcBindingMessage {
558
780
  }
559
781
 
560
782
  export interface SonareEngineSyncMidiInputEventMessage {
561
- type: 'syncMidiInputNoteOn' | 'syncMidiInputNoteOff' | 'syncMidiInputCc';
783
+ type:
784
+ | 'syncMidiInputNoteOn'
785
+ | 'syncMidiInputNoteOff'
786
+ | 'syncMidiInputCc'
787
+ | 'syncMidiInputPitchBend'
788
+ | 'syncMidiInputChannelPressure'
789
+ | 'syncMidiInputPolyPressure';
562
790
  group: number;
563
791
  channel: number;
564
792
  data0: number;
@@ -584,6 +812,8 @@ export type SonareEngineSyncMessage =
584
812
  | SonareEngineSyncClipPageProviderMessage
585
813
  | SonareEngineSyncClipPageMessage
586
814
  | SonareEngineSyncClipPageClearMessage
815
+ | SonareEngineSyncClipPagePrefetchFramesMessage
816
+ | SonareEngineSyncWarpVoiceCapacityMessage
587
817
  | SonareEngineSyncClipPageCommitMessage
588
818
  | SonareEngineSyncClipPageDestroyMessage
589
819
  | SonareEngineSyncMidiClipsMessage
@@ -596,15 +826,21 @@ export type SonareEngineSyncMessage =
596
826
  | SonareEngineSyncCaptureMessage
597
827
  | SonareEngineSyncTrackStripEqBandMessage
598
828
  | SonareEngineSyncMasterStripEqBandMessage
829
+ | SonareEngineSyncBusStripEqBandMessage
599
830
  | SonareEngineSyncTrackStripInsertBypassedMessage
600
831
  | SonareEngineSyncMasterStripInsertBypassedMessage
601
832
  | SonareEngineSyncTrackStripInsertParamByNameMessage
602
833
  | SonareEngineSyncMasterStripInsertParamByNameMessage
603
834
  | SonareEngineSyncBusStripInsertParamByNameMessage
835
+ | SonareEngineSyncBusStripInsertBypassedMessage
604
836
  | SonareEngineSyncTrackStripPanMessage
605
837
  | SonareEngineSyncTrackStripPanLawMessage
606
838
  | SonareEngineSyncTrackStripPanModeMessage
607
839
  | SonareEngineSyncTrackStripDualPanMessage
840
+ | SonareEngineSyncBusStripPanMessage
841
+ | SonareEngineSyncBusStripPanLawMessage
842
+ | SonareEngineSyncBusStripPanModeMessage
843
+ | SonareEngineSyncBusStripDualPanMessage
608
844
  | SonareEngineSyncTrackStripChannelDelaySamplesMessage
609
845
  | SonareEngineSyncBuiltinInstrumentMessage
610
846
  | SonareEngineSyncSynthInstrumentMessage
@@ -614,6 +850,7 @@ export type SonareEngineSyncMessage =
614
850
  | SonareEngineSyncMidiNoteMessage
615
851
  | SonareEngineSyncMidiCcMessage
616
852
  | SonareEngineSyncMidiUmpMessage
853
+ | SonareEngineSyncMidiExpressionMessage
617
854
  | SonareEngineSyncMidiSysexMessage
618
855
  | SonareEngineSyncMidiPanicMessage
619
856
  | SonareEngineSyncMidiDestinationExternalMessage