@libraz/libsonare 1.7.2 → 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 -203
  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 -5840
  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 -7431
  63. package/dist/index.d.ts.map +1 -0
  64. package/dist/index.js +3758 -1362
  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 -2515
  213. package/dist/worklet.d.ts.map +1 -0
  214. package/dist/worklet.js +2763 -501
  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 +282 -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 +61 -24
  255. package/src/project_class.ts +450 -27
  256. package/src/project_internal.ts +149 -42
  257. package/src/project_synth.ts +67 -1
  258. package/src/project_types.ts +268 -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 +711 -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 +1122 -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 +194 -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 +78 -26
  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 +272 -83
  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 +227 -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 +17 -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';
@@ -102,6 +104,87 @@ export type SonareRealtimeVoiceChangerMessage =
102
104
  | SonareRealtimeVoiceChangerResetMessage
103
105
  | SonareRealtimeVoiceChangerDestroyMessage;
104
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
+
105
188
  export interface SonareRealtimeEngineNodeCapabilities {
106
189
  mode: 'sab' | 'postMessage';
107
190
  runtimeTarget: 'embind';
@@ -193,7 +276,13 @@ export interface SonareWorkletExternalMidiMessage {
193
276
  /** A control-plane sync message that the worklet rejected without crashing. */
194
277
  export interface SonareEngineSyncErrorMessage {
195
278
  type: 'syncError';
196
- 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>);
197
286
  message: string;
198
287
  }
199
288
 
@@ -296,6 +385,27 @@ export interface SonareEngineSyncClipPageMessage {
296
385
  channels: Float32Array[];
297
386
  }
298
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
+
299
409
  /** Evicts one page after the main-thread sliding window advances. */
300
410
  export interface SonareEngineSyncClipPageClearMessage {
301
411
  type: 'syncClipPageClear';
@@ -368,15 +478,57 @@ export interface SonareEngineSyncTempoMessage {
368
478
  timeSignatureSegments?: EngineTimeSignatureSegment[];
369
479
  }
370
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
+
371
503
  export interface SonareEngineSyncMixerMessage {
372
504
  type: 'syncMixer';
505
+ /** Apply only supplied sidechain bindings; preserve current mixer topology. */
506
+ sidechainDelta?: boolean;
373
507
  lanes: EngineTrackLane[];
374
508
  buses?: EngineBus[];
375
509
  trackStrips?: Array<{ trackId: number; sceneJson: string }>;
376
510
  busStrips?: Array<{ busId: number; sceneJson: string }>;
377
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
+ >;
378
518
  /** Lane insert sidechain bindings (replayed after lanes/strips). */
379
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 }>;
380
532
  }
381
533
 
382
534
  export interface SonareEngineSyncCaptureMessage {
@@ -401,6 +553,13 @@ export interface SonareEngineSyncMasterStripEqBandMessage {
401
553
  bandJson: string;
402
554
  }
403
555
 
556
+ export interface SonareEngineSyncBusStripEqBandMessage {
557
+ type: 'syncBusStripEqBand';
558
+ busId: number;
559
+ bandIndex: number;
560
+ bandJson: string;
561
+ }
562
+
404
563
  export interface SonareEngineSyncTrackStripInsertBypassedMessage {
405
564
  type: 'syncTrackStripInsertBypassed';
406
565
  trackId: number;
@@ -439,6 +598,14 @@ export interface SonareEngineSyncBusStripInsertParamByNameMessage {
439
598
  value: number;
440
599
  }
441
600
 
601
+ export interface SonareEngineSyncBusStripInsertBypassedMessage {
602
+ type: 'syncBusStripInsertBypassed';
603
+ busId: number;
604
+ insertIndex: number;
605
+ bypassed: boolean;
606
+ resetOnBypass: boolean;
607
+ }
608
+
442
609
  export interface SonareEngineSyncTrackStripPanMessage {
443
610
  type: 'syncTrackStripPan';
444
611
  trackId: number;
@@ -464,6 +631,31 @@ export interface SonareEngineSyncTrackStripDualPanMessage {
464
631
  rightPan: number;
465
632
  }
466
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
+
467
659
  export interface SonareEngineSyncTrackStripChannelDelaySamplesMessage {
468
660
  type: 'syncTrackStripChannelDelaySamples';
469
661
  trackId: number;
@@ -490,6 +682,8 @@ export interface SonareEngineSyncSf2InstrumentMessage {
490
682
  gain?: number;
491
683
  polyphony?: number;
492
684
  preferModelForModeledFamilies?: boolean;
685
+ clearBankRig?: boolean;
686
+ gsEfxRealization?: 'modern' | 'classic';
493
687
  };
494
688
  }
495
689
 
@@ -532,6 +726,22 @@ export interface SonareEngineSyncMidiUmpMessage {
532
726
  renderFrame: number;
533
727
  }
534
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
+
535
745
  export interface SonareEngineSyncMidiSysexMessage {
536
746
  type: 'syncMidiSysex';
537
747
  destinationId: number;
@@ -570,7 +780,13 @@ export interface SonareEngineSyncMidiCcBindingMessage {
570
780
  }
571
781
 
572
782
  export interface SonareEngineSyncMidiInputEventMessage {
573
- type: 'syncMidiInputNoteOn' | 'syncMidiInputNoteOff' | 'syncMidiInputCc';
783
+ type:
784
+ | 'syncMidiInputNoteOn'
785
+ | 'syncMidiInputNoteOff'
786
+ | 'syncMidiInputCc'
787
+ | 'syncMidiInputPitchBend'
788
+ | 'syncMidiInputChannelPressure'
789
+ | 'syncMidiInputPolyPressure';
574
790
  group: number;
575
791
  channel: number;
576
792
  data0: number;
@@ -596,6 +812,8 @@ export type SonareEngineSyncMessage =
596
812
  | SonareEngineSyncClipPageProviderMessage
597
813
  | SonareEngineSyncClipPageMessage
598
814
  | SonareEngineSyncClipPageClearMessage
815
+ | SonareEngineSyncClipPagePrefetchFramesMessage
816
+ | SonareEngineSyncWarpVoiceCapacityMessage
599
817
  | SonareEngineSyncClipPageCommitMessage
600
818
  | SonareEngineSyncClipPageDestroyMessage
601
819
  | SonareEngineSyncMidiClipsMessage
@@ -608,15 +826,21 @@ export type SonareEngineSyncMessage =
608
826
  | SonareEngineSyncCaptureMessage
609
827
  | SonareEngineSyncTrackStripEqBandMessage
610
828
  | SonareEngineSyncMasterStripEqBandMessage
829
+ | SonareEngineSyncBusStripEqBandMessage
611
830
  | SonareEngineSyncTrackStripInsertBypassedMessage
612
831
  | SonareEngineSyncMasterStripInsertBypassedMessage
613
832
  | SonareEngineSyncTrackStripInsertParamByNameMessage
614
833
  | SonareEngineSyncMasterStripInsertParamByNameMessage
615
834
  | SonareEngineSyncBusStripInsertParamByNameMessage
835
+ | SonareEngineSyncBusStripInsertBypassedMessage
616
836
  | SonareEngineSyncTrackStripPanMessage
617
837
  | SonareEngineSyncTrackStripPanLawMessage
618
838
  | SonareEngineSyncTrackStripPanModeMessage
619
839
  | SonareEngineSyncTrackStripDualPanMessage
840
+ | SonareEngineSyncBusStripPanMessage
841
+ | SonareEngineSyncBusStripPanLawMessage
842
+ | SonareEngineSyncBusStripPanModeMessage
843
+ | SonareEngineSyncBusStripDualPanMessage
620
844
  | SonareEngineSyncTrackStripChannelDelaySamplesMessage
621
845
  | SonareEngineSyncBuiltinInstrumentMessage
622
846
  | SonareEngineSyncSynthInstrumentMessage
@@ -626,6 +850,7 @@ export type SonareEngineSyncMessage =
626
850
  | SonareEngineSyncMidiNoteMessage
627
851
  | SonareEngineSyncMidiCcMessage
628
852
  | SonareEngineSyncMidiUmpMessage
853
+ | SonareEngineSyncMidiExpressionMessage
629
854
  | SonareEngineSyncMidiSysexMessage
630
855
  | SonareEngineSyncMidiPanicMessage
631
856
  | SonareEngineSyncMidiDestinationExternalMessage