@libraz/libsonare 1.7.2 → 1.8.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 (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 +7 -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 +874 -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 +502 -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 +134 -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 +4173 -1621
  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 +483 -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 +654 -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 +528 -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 +165 -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 +893 -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 +3945 -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 +340 -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 +164 -0
  179. package/dist/worklet/engine-mixer-facade.d.ts.map +1 -0
  180. package/dist/worklet/engine-node.d.ts +83 -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 +72 -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 +75 -0
  193. package/dist/worklet/engine-strips.d.ts.map +1 -0
  194. package/dist/worklet/engine-sync.d.ts +39 -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 +418 -0
  199. package/dist/worklet/engine.d.ts.map +1 -0
  200. package/dist/worklet/guards.d.ts +53 -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 +331 -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 +3200 -541
  215. package/dist/worklet.js.map +1 -1
  216. package/package.json +23 -12
  217. package/src/_effects_common.ts +47 -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 +101 -22
  226. package/src/effects_note_ops.ts +683 -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 +388 -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 +288 -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 +441 -32
  246. package/src/mastering_dynamics.ts +22 -11
  247. package/src/metering.ts +67 -24
  248. package/src/mixer.ts +251 -22
  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 +271 -271
  259. package/src/public_types.ts +122 -3
  260. package/src/public_types_acoustic.ts +112 -3
  261. package/src/public_types_mastering.ts +275 -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 +196 -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 +491 -5
  268. package/src/quick_analysis.ts +203 -26
  269. package/src/realtime_engine.ts +773 -34
  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 +1158 -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 +202 -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 +800 -32
  287. package/src/worklet/engine-node.ts +99 -29
  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 +332 -93
  291. package/src/worklet/engine-register.ts +32 -18
  292. package/src/worklet/engine-strips.ts +275 -9
  293. package/src/worklet/engine-sync.ts +20 -7
  294. package/src/worklet/engine.ts +394 -48
  295. package/src/worklet/guards.ts +195 -44
  296. package/src/worklet/messages.ts +229 -2
  297. package/src/worklet/mixer-processor.ts +117 -48
  298. package/src/worklet/playback-processor.ts +300 -0
  299. package/src/worklet/protocol.ts +82 -11
  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,15 +6,18 @@ import type {
6
6
  SonareEngineSyncMessage,
7
7
  SonareEngineTransportRequestMessage,
8
8
  SonareEngineTransportResponseMessage,
9
+ SonarePlaybackMessage,
9
10
  SonareRealtimeVoiceChangerMessage,
10
11
  SonareWorkletExternalMidiMessage,
11
12
  SonareWorkletMessage,
12
13
  } from './messages';
13
14
  import {
14
15
  isRecord,
16
+ SONARE_SCOPE_DEFAULT_BANDS,
15
17
  type SonareEngineCommandRecord,
16
18
  type SonareEngineTelemetryRecord,
17
19
  type SonareWorkletMeterSnapshot,
20
+ type SonareWorkletScopeSnapshot,
18
21
  } from './protocol';
19
22
 
20
23
  export function isWorkletMessage(value: unknown): value is SonareWorkletMessage {
@@ -32,52 +35,87 @@ export function isEngineCommandRecord(value: unknown): value is SonareEngineComm
32
35
  return isRecord(value) && typeof value.type === 'number';
33
36
  }
34
37
 
38
+ /**
39
+ * Every discriminant the worklet accepts on the control plane, derived from the
40
+ * `SonareEngineSyncMessage` union rather than restated as literals.
41
+ *
42
+ * The `Record<SonareEngineSyncMessage['type'], true>` annotation rejects a
43
+ * missing key and the object literal's excess-property check rejects a stale
44
+ * one, so a union member that never reaches this table is a compile error
45
+ * instead of a message the port drops in silence.
46
+ */
47
+ export const ENGINE_SYNC_MESSAGE_TYPES: Record<SonareEngineSyncMessage['type'], true> = {
48
+ destroy: true,
49
+ syncAutomation: true,
50
+ syncBuiltinInstrument: true,
51
+ syncBusStripDualPan: true,
52
+ syncBusStripEqBand: true,
53
+ syncBusStripInsertBypassed: true,
54
+ syncBusStripInsertParamByName: true,
55
+ syncBusStripPan: true,
56
+ syncBusStripPanLaw: true,
57
+ syncBusStripPanMode: true,
58
+ syncCapture: true,
59
+ syncClearMidiFx: true,
60
+ syncClearMidiInputSource: true,
61
+ syncClipPage: true,
62
+ syncClipPageClear: true,
63
+ syncClipPageCommit: true,
64
+ syncClipPageDestroy: true,
65
+ syncClipPagePrefetchFrames: true,
66
+ syncClipPageProvider: true,
67
+ syncClips: true,
68
+ syncClipsDelta: true,
69
+ syncExternalMidiClock: true,
70
+ syncLoadSoundFont: true,
71
+ syncMarkers: true,
72
+ syncMasterStripEqBand: true,
73
+ syncMasterStripInsertBypassed: true,
74
+ syncMasterStripInsertParamByName: true,
75
+ syncMetronome: true,
76
+ syncMidiCc: true,
77
+ syncMidiCcBinding: true,
78
+ syncMidiChannelPressure: true,
79
+ syncMidiClips: true,
80
+ syncMidiDestinationExternal: true,
81
+ syncMidiFx: true,
82
+ syncMidiInputChannelPressure: true,
83
+ syncMidiInputCc: true,
84
+ syncMidiInputNoteOff: true,
85
+ syncMidiInputNoteOn: true,
86
+ syncMidiInputPitchBend: true,
87
+ syncMidiInputPolyPressure: true,
88
+ syncMidiInputSource: true,
89
+ syncMidiNoteOff: true,
90
+ syncMidiNoteOn: true,
91
+ syncMidiPanic: true,
92
+ syncMidiPitchBend: true,
93
+ syncMidiPolyPressure: true,
94
+ syncMidiSysex: true,
95
+ syncMidiUmp: true,
96
+ syncMixer: true,
97
+ syncParameters: true,
98
+ syncSf2Instrument: true,
99
+ syncSynthInstrument: true,
100
+ syncTempo: true,
101
+ syncTrackStripChannelDelaySamples: true,
102
+ syncTrackStripDualPan: true,
103
+ syncTrackStripEqBand: true,
104
+ syncTrackStripInsertBypassed: true,
105
+ syncTrackStripInsertParamByName: true,
106
+ syncTrackStripPan: true,
107
+ syncTrackStripPanLaw: true,
108
+ syncTrackStripPanMode: true,
109
+ syncWarpVoiceCapacity: true,
110
+ };
111
+
112
+ // A Set rather than a property lookup on the table: an inherited member name
113
+ // ('constructor', 'toString') must not read as an accepted discriminant.
114
+ const engineSyncMessageTypes: ReadonlySet<string> = new Set(Object.keys(ENGINE_SYNC_MESSAGE_TYPES));
115
+
35
116
  export function isEngineSyncMessage(value: unknown): value is SonareEngineSyncMessage {
36
- if (!isRecord(value) || typeof value.type !== 'string') {
37
- return false;
38
- }
39
117
  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'
118
+ isRecord(value) && typeof value.type === 'string' && engineSyncMessageTypes.has(value.type)
81
119
  );
82
120
  }
83
121
 
@@ -225,6 +263,31 @@ export function isRealtimeVoiceChangerMessage(
225
263
  return value.type === 'setConfig' || value.type === 'reset' || value.type === 'destroy';
226
264
  }
227
265
 
266
+ const isOptionalNumber = (value: unknown): boolean =>
267
+ value === undefined || typeof value === 'number';
268
+
269
+ export function isPlaybackMessage(value: unknown): value is SonarePlaybackMessage {
270
+ if (!isRecord(value) || typeof value.type !== 'string') {
271
+ return false;
272
+ }
273
+ switch (value.type) {
274
+ case 'config':
275
+ return typeof value.config === 'string';
276
+ case 'orientation':
277
+ return (
278
+ typeof value.yaw === 'number' &&
279
+ isOptionalNumber(value.pitch) &&
280
+ isOptionalNumber(value.roll)
281
+ );
282
+ case 'reset':
283
+ case 'diagnostics':
284
+ case 'destroy':
285
+ return true;
286
+ default:
287
+ return false;
288
+ }
289
+ }
290
+
228
291
  export function isEngineTelemetryRecord(value: unknown): value is SonareEngineTelemetryRecord {
229
292
  return (
230
293
  isRecord(value) &&
@@ -270,6 +333,94 @@ export function isMeterSnapshot(value: unknown): value is SonareWorkletMeterSnap
270
333
  typeof value.rmsDbL === 'number' &&
271
334
  typeof value.rmsDbR === 'number' &&
272
335
  typeof value.correlation === 'number' &&
336
+ Number.isFinite(value.inputPeakDbL) &&
337
+ Number.isFinite(value.inputPeakDbR) &&
273
338
  (typeof value.targetId === 'number' || value.targetId === undefined)
274
339
  );
275
340
  }
341
+
342
+ export const SONARE_SCOPE_MAX_BANDS = 64;
343
+ export const SONARE_SCOPE_MAX_POINTS = 32;
344
+
345
+ function isPlainFloat32Array(
346
+ value: unknown,
347
+ maxLength: number,
348
+ evenLength = false,
349
+ ): value is Float32Array {
350
+ if (
351
+ !(value instanceof Float32Array) ||
352
+ typeof ArrayBuffer === 'undefined' ||
353
+ !(value.buffer instanceof ArrayBuffer) ||
354
+ value.length > maxLength ||
355
+ (evenLength && value.length % 2 !== 0)
356
+ ) {
357
+ return false;
358
+ }
359
+ for (const sample of value) {
360
+ if (!Number.isFinite(sample)) {
361
+ return false;
362
+ }
363
+ }
364
+ return true;
365
+ }
366
+
367
+ /** Validates the bounded postMessage representation of a scope snapshot. */
368
+ export function isScopeSnapshot(value: unknown): value is SonareWorkletScopeSnapshot {
369
+ return (
370
+ isRecord(value) &&
371
+ value.type === 'scope' &&
372
+ typeof value.targetId === 'number' &&
373
+ Number.isSafeInteger(value.targetId) &&
374
+ value.targetId >= 0 &&
375
+ value.targetId <= 0xffff_ffff &&
376
+ typeof value.frame === 'number' &&
377
+ Number.isSafeInteger(value.frame) &&
378
+ value.frame >= 0 &&
379
+ isPlainFloat32Array(value.bands, SONARE_SCOPE_MAX_BANDS) &&
380
+ value.bands.length > 0 &&
381
+ isPlainFloat32Array(value.points, SONARE_SCOPE_MAX_POINTS * 2, true)
382
+ );
383
+ }
384
+
385
+ /**
386
+ * Resolves an integer option, refusing anything the field's own domain cannot
387
+ * hold instead of rounding it into range.
388
+ *
389
+ * Rounding hands the caller a working object configured with a value they never
390
+ * asked for, and nothing downstream can tell that apart from the value they
391
+ * meant. A ceiling, where one exists, stays with the layer that owns it.
392
+ */
393
+ export function requireIntegerOption(
394
+ value: number | undefined,
395
+ fallback: number,
396
+ name: string,
397
+ minimum: number,
398
+ ): number {
399
+ const resolved = value ?? fallback;
400
+ if (!Number.isSafeInteger(resolved) || resolved < minimum) {
401
+ throw new RangeError(`${name} must be an integer of at least ${minimum}`);
402
+ }
403
+ return resolved;
404
+ }
405
+
406
+ /** Resolves scope bands and applies the native tap's fixed 64-band ceiling. */
407
+ export function resolveScopeBandCount(
408
+ value: number | undefined,
409
+ fallback = SONARE_SCOPE_DEFAULT_BANDS,
410
+ ): number {
411
+ return Math.min(requireIntegerOption(value, fallback, 'scopeBands', 1), SONARE_SCOPE_MAX_BANDS);
412
+ }
413
+
414
+ /** As {@link requireIntegerOption}, for a field whose domain admits either sign. */
415
+ export function requireInteger(value: number | undefined, fallback: number, name: string): number {
416
+ const resolved = value ?? fallback;
417
+ if (!Number.isSafeInteger(resolved)) {
418
+ throw new RangeError(`${name} must be an integer`);
419
+ }
420
+ return resolved;
421
+ }
422
+
423
+ /** Resolves the channel count every worklet entry point accepts on its options. */
424
+ export function requireChannelCount(channelCount: number | undefined, fallback: number): number {
425
+ return requireIntegerOption(channelCount, fallback, 'channelCount', 1);
426
+ }
@@ -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';
@@ -19,6 +21,7 @@ import type {
19
21
  SonareEngineCommandRecord,
20
22
  SonareEngineTelemetryRecord,
21
23
  SonareWorkletMeterSnapshot,
24
+ SonareWorkletScopeSnapshot,
22
25
  SonareWorkletSpectrumSnapshot,
23
26
  } from './protocol';
24
27
 
@@ -102,6 +105,87 @@ export type SonareRealtimeVoiceChangerMessage =
102
105
  | SonareRealtimeVoiceChangerResetMessage
103
106
  | SonareRealtimeVoiceChangerDestroyMessage;
104
107
 
108
+ export interface SonarePlaybackWorkletProcessorOptions {
109
+ /** Renderer configuration; parsed once, in the processor constructor. Default `{}`. */
110
+ config?: PlaybackRendererConfig | string;
111
+ /**
112
+ * SHRF v1 bytes, required for a headphones target (e.g. the package asset
113
+ * `./hrtf/default.shrf`). Copied into the renderer at construction.
114
+ */
115
+ hrtf?: ArrayBuffer | Uint8Array;
116
+ /** Largest render quantum the processor accepts. Default 128. */
117
+ maxBlockSize?: number;
118
+ /** Defaults to the AudioWorkletGlobalScope `sampleRate`, then 48000. */
119
+ sampleRate?: number;
120
+ }
121
+
122
+ export interface SonarePlaybackNodeOptions extends SonarePlaybackWorkletProcessorOptions {
123
+ processorName?: string;
124
+ nodeFactory?: (
125
+ context: BaseAudioContext,
126
+ processorName: string,
127
+ options: AudioWorkletNodeOptions,
128
+ ) => AudioWorkletNode;
129
+ }
130
+
131
+ export interface SonarePlaybackConfigMessage {
132
+ type: 'config';
133
+ /** A complete configuration document, serialized on the main thread. */
134
+ config: string;
135
+ }
136
+
137
+ export interface SonarePlaybackOrientationMessage {
138
+ type: 'orientation';
139
+ /** Degrees; see `PlaybackRenderer.setHeadOrientation`. */
140
+ yaw: number;
141
+ pitch?: number;
142
+ roll?: number;
143
+ }
144
+
145
+ /** Clears the pipeline after a seek; the handler runs between render quanta. */
146
+ export interface SonarePlaybackResetMessage {
147
+ type: 'reset';
148
+ }
149
+
150
+ /** Requests a {@link SonarePlaybackDiagnosticsReplyMessage}. */
151
+ export interface SonarePlaybackDiagnosticsRequestMessage {
152
+ type: 'diagnostics';
153
+ }
154
+
155
+ export interface SonarePlaybackDestroyMessage {
156
+ type: 'destroy';
157
+ }
158
+
159
+ export type SonarePlaybackMessage =
160
+ | SonarePlaybackConfigMessage
161
+ | SonarePlaybackOrientationMessage
162
+ | SonarePlaybackResetMessage
163
+ | SonarePlaybackDiagnosticsRequestMessage
164
+ | SonarePlaybackDestroyMessage;
165
+
166
+ /** The renderer's diagnostics plus the worklet's own block counter. */
167
+ export interface SonarePlaybackWorkletDiagnostics extends PlaybackDiagnostics {
168
+ /**
169
+ * Render quanta whose input channel count the renderer does not accept
170
+ * (not 1, 2, 6 or 8 under `"auto"`; not the fixed layout's count otherwise).
171
+ * Each was rendered as silence on the active input layout, so the timeline
172
+ * still advanced.
173
+ */
174
+ unsupported_input_blocks: number;
175
+ }
176
+
177
+ export interface SonarePlaybackDiagnosticsReplyMessage {
178
+ type: 'diagnostics';
179
+ diagnostics: SonarePlaybackWorkletDiagnostics;
180
+ }
181
+
182
+ /** Posted when a control message is refused (e.g. a changed prepare key). */
183
+ export interface SonarePlaybackErrorMessage {
184
+ type: 'error';
185
+ request: SonarePlaybackMessage['type'];
186
+ message: string;
187
+ }
188
+
105
189
  export interface SonareRealtimeEngineNodeCapabilities {
106
190
  mode: 'sab' | 'postMessage';
107
191
  runtimeTarget: 'embind';
@@ -193,12 +277,19 @@ export interface SonareWorkletExternalMidiMessage {
193
277
  /** A control-plane sync message that the worklet rejected without crashing. */
194
278
  export interface SonareEngineSyncErrorMessage {
195
279
  type: 'syncError';
196
- syncType: SonareEngineSyncMessage['type'];
280
+ /**
281
+ * Discriminant of the rejected sync. Usually a known member, but a
282
+ * `sync`-prefixed type this build does not recognize is reported here too
283
+ * rather than dropped, so the set is open. `Record<never, never>` keeps the
284
+ * known members as editor completions instead of collapsing to `string`.
285
+ */
286
+ syncType: SonareEngineSyncMessage['type'] | (string & Record<never, never>);
197
287
  message: string;
198
288
  }
199
289
 
200
290
  export type SonareWorkletTransportMessage =
201
291
  | SonareWorkletMeterSnapshot
292
+ | SonareWorkletScopeSnapshot
202
293
  | SonareWorkletSpectrumSnapshot
203
294
  | SonareWorkletExternalMidiMessage
204
295
  | SonareEngineClipPageRequestMessage
@@ -296,6 +387,27 @@ export interface SonareEngineSyncClipPageMessage {
296
387
  channels: Float32Array[];
297
388
  }
298
389
 
390
+ /**
391
+ * Sets the worklet engine's clip-page look-ahead window in timeline frames, so
392
+ * the audio thread reports the pages it is about to read before it reads them.
393
+ * 0 disables the look-ahead.
394
+ */
395
+ export interface SonareEngineSyncClipPagePrefetchFramesMessage {
396
+ type: 'syncClipPagePrefetchFrames';
397
+ frames: number;
398
+ }
399
+
400
+ /**
401
+ * Sets the worklet engine's concurrent time-stretch voice capacity. The
402
+ * capacity was already validated (and applied to the offline engine) by the
403
+ * caller, so the worklet side just mirrors the accepted value; the pool
404
+ * rebuild itself happens on the audio thread, at the next block boundary.
405
+ */
406
+ export interface SonareEngineSyncWarpVoiceCapacityMessage {
407
+ type: 'syncWarpVoiceCapacity';
408
+ voices: number;
409
+ }
410
+
299
411
  /** Evicts one page after the main-thread sliding window advances. */
300
412
  export interface SonareEngineSyncClipPageClearMessage {
301
413
  type: 'syncClipPageClear';
@@ -368,15 +480,57 @@ export interface SonareEngineSyncTempoMessage {
368
480
  timeSignatureSegments?: EngineTimeSignatureSegment[];
369
481
  }
370
482
 
483
+ export type SonareEngineSyncMixerInsertParamOverride =
484
+ | {
485
+ kind: 'track';
486
+ trackId: number;
487
+ insertIndex: number;
488
+ paramName: string;
489
+ value: number;
490
+ }
491
+ | {
492
+ kind: 'bus';
493
+ busId: number;
494
+ insertIndex: number;
495
+ paramName: string;
496
+ value: number;
497
+ }
498
+ | {
499
+ kind: 'master';
500
+ insertIndex: number;
501
+ paramName: string;
502
+ value: number;
503
+ };
504
+
371
505
  export interface SonareEngineSyncMixerMessage {
372
506
  type: 'syncMixer';
507
+ /** Apply only supplied sidechain bindings; preserve current mixer topology. */
508
+ sidechainDelta?: boolean;
373
509
  lanes: EngineTrackLane[];
374
510
  buses?: EngineBus[];
375
511
  trackStrips?: Array<{ trackId: number; sceneJson: string }>;
376
512
  busStrips?: Array<{ busId: number; sceneJson: string }>;
377
513
  masterStripJson?: string;
514
+ /** Retained by-name insert values, applied after strip and sidechain replay. */
515
+ insertParamOverrides?: SonareEngineSyncMixerInsertParamOverride[];
516
+ /** Strips whose manual insert bases are cleared after the strip replay, before insertParamOverrides. */
517
+ insertBaseResets?: Array<
518
+ { kind: 'track'; trackId: number } | { kind: 'bus'; busId: number } | { kind: 'master' }
519
+ >;
378
520
  /** Lane insert sidechain bindings (replayed after lanes/strips). */
379
521
  laneSidechains?: Array<{ trackId: number; insertIndex: number; sourceTrackId: number }>;
522
+ /**
523
+ * Bus insert sidechain bindings (replayed after lanes/buses/strips).
524
+ * `sourceKind` is a `SonareSidechainSourceKind` ordinal (0 track / 1 bus).
525
+ */
526
+ busSidechains?: Array<{
527
+ busId: number;
528
+ insertIndex: number;
529
+ sourceKind: number;
530
+ sourceId: number;
531
+ }>;
532
+ /** Master strip insert sidechain bindings. Same `sourceKind` convention. */
533
+ masterSidechains?: Array<{ insertIndex: number; sourceKind: number; sourceId: number }>;
380
534
  }
381
535
 
382
536
  export interface SonareEngineSyncCaptureMessage {
@@ -401,6 +555,13 @@ export interface SonareEngineSyncMasterStripEqBandMessage {
401
555
  bandJson: string;
402
556
  }
403
557
 
558
+ export interface SonareEngineSyncBusStripEqBandMessage {
559
+ type: 'syncBusStripEqBand';
560
+ busId: number;
561
+ bandIndex: number;
562
+ bandJson: string;
563
+ }
564
+
404
565
  export interface SonareEngineSyncTrackStripInsertBypassedMessage {
405
566
  type: 'syncTrackStripInsertBypassed';
406
567
  trackId: number;
@@ -439,6 +600,14 @@ export interface SonareEngineSyncBusStripInsertParamByNameMessage {
439
600
  value: number;
440
601
  }
441
602
 
603
+ export interface SonareEngineSyncBusStripInsertBypassedMessage {
604
+ type: 'syncBusStripInsertBypassed';
605
+ busId: number;
606
+ insertIndex: number;
607
+ bypassed: boolean;
608
+ resetOnBypass: boolean;
609
+ }
610
+
442
611
  export interface SonareEngineSyncTrackStripPanMessage {
443
612
  type: 'syncTrackStripPan';
444
613
  trackId: number;
@@ -464,6 +633,31 @@ export interface SonareEngineSyncTrackStripDualPanMessage {
464
633
  rightPan: number;
465
634
  }
466
635
 
636
+ export interface SonareEngineSyncBusStripPanMessage {
637
+ type: 'syncBusStripPan';
638
+ busId: number;
639
+ pan: number;
640
+ }
641
+
642
+ export interface SonareEngineSyncBusStripPanLawMessage {
643
+ type: 'syncBusStripPanLaw';
644
+ busId: number;
645
+ panLaw: number;
646
+ }
647
+
648
+ export interface SonareEngineSyncBusStripPanModeMessage {
649
+ type: 'syncBusStripPanMode';
650
+ busId: number;
651
+ panMode: number;
652
+ }
653
+
654
+ export interface SonareEngineSyncBusStripDualPanMessage {
655
+ type: 'syncBusStripDualPan';
656
+ busId: number;
657
+ leftPan: number;
658
+ rightPan: number;
659
+ }
660
+
467
661
  export interface SonareEngineSyncTrackStripChannelDelaySamplesMessage {
468
662
  type: 'syncTrackStripChannelDelaySamples';
469
663
  trackId: number;
@@ -490,6 +684,8 @@ export interface SonareEngineSyncSf2InstrumentMessage {
490
684
  gain?: number;
491
685
  polyphony?: number;
492
686
  preferModelForModeledFamilies?: boolean;
687
+ clearBankRig?: boolean;
688
+ gsEfxRealization?: 'modern' | 'classic';
493
689
  };
494
690
  }
495
691
 
@@ -532,6 +728,22 @@ export interface SonareEngineSyncMidiUmpMessage {
532
728
  renderFrame: number;
533
729
  }
534
730
 
731
+ /**
732
+ * One of the three per-note expression dimensions, addressed to a destination.
733
+ * `data0`/`data1` carry the dimension's own payload the way the live-input
734
+ * message beside this one does: bend14 / 0, pressure / 0, or note / pressure.
735
+ * A bend is 14-bit, which is why these do not ride the 7-bit CC message.
736
+ */
737
+ export interface SonareEngineSyncMidiExpressionMessage {
738
+ type: 'syncMidiPitchBend' | 'syncMidiChannelPressure' | 'syncMidiPolyPressure';
739
+ destinationId: number;
740
+ group: number;
741
+ channel: number;
742
+ data0: number;
743
+ data1: number;
744
+ renderFrame: number;
745
+ }
746
+
535
747
  export interface SonareEngineSyncMidiSysexMessage {
536
748
  type: 'syncMidiSysex';
537
749
  destinationId: number;
@@ -570,7 +782,13 @@ export interface SonareEngineSyncMidiCcBindingMessage {
570
782
  }
571
783
 
572
784
  export interface SonareEngineSyncMidiInputEventMessage {
573
- type: 'syncMidiInputNoteOn' | 'syncMidiInputNoteOff' | 'syncMidiInputCc';
785
+ type:
786
+ | 'syncMidiInputNoteOn'
787
+ | 'syncMidiInputNoteOff'
788
+ | 'syncMidiInputCc'
789
+ | 'syncMidiInputPitchBend'
790
+ | 'syncMidiInputChannelPressure'
791
+ | 'syncMidiInputPolyPressure';
574
792
  group: number;
575
793
  channel: number;
576
794
  data0: number;
@@ -596,6 +814,8 @@ export type SonareEngineSyncMessage =
596
814
  | SonareEngineSyncClipPageProviderMessage
597
815
  | SonareEngineSyncClipPageMessage
598
816
  | SonareEngineSyncClipPageClearMessage
817
+ | SonareEngineSyncClipPagePrefetchFramesMessage
818
+ | SonareEngineSyncWarpVoiceCapacityMessage
599
819
  | SonareEngineSyncClipPageCommitMessage
600
820
  | SonareEngineSyncClipPageDestroyMessage
601
821
  | SonareEngineSyncMidiClipsMessage
@@ -608,15 +828,21 @@ export type SonareEngineSyncMessage =
608
828
  | SonareEngineSyncCaptureMessage
609
829
  | SonareEngineSyncTrackStripEqBandMessage
610
830
  | SonareEngineSyncMasterStripEqBandMessage
831
+ | SonareEngineSyncBusStripEqBandMessage
611
832
  | SonareEngineSyncTrackStripInsertBypassedMessage
612
833
  | SonareEngineSyncMasterStripInsertBypassedMessage
613
834
  | SonareEngineSyncTrackStripInsertParamByNameMessage
614
835
  | SonareEngineSyncMasterStripInsertParamByNameMessage
615
836
  | SonareEngineSyncBusStripInsertParamByNameMessage
837
+ | SonareEngineSyncBusStripInsertBypassedMessage
616
838
  | SonareEngineSyncTrackStripPanMessage
617
839
  | SonareEngineSyncTrackStripPanLawMessage
618
840
  | SonareEngineSyncTrackStripPanModeMessage
619
841
  | SonareEngineSyncTrackStripDualPanMessage
842
+ | SonareEngineSyncBusStripPanMessage
843
+ | SonareEngineSyncBusStripPanLawMessage
844
+ | SonareEngineSyncBusStripPanModeMessage
845
+ | SonareEngineSyncBusStripDualPanMessage
620
846
  | SonareEngineSyncTrackStripChannelDelaySamplesMessage
621
847
  | SonareEngineSyncBuiltinInstrumentMessage
622
848
  | SonareEngineSyncSynthInstrumentMessage
@@ -626,6 +852,7 @@ export type SonareEngineSyncMessage =
626
852
  | SonareEngineSyncMidiNoteMessage
627
853
  | SonareEngineSyncMidiCcMessage
628
854
  | SonareEngineSyncMidiUmpMessage
855
+ | SonareEngineSyncMidiExpressionMessage
629
856
  | SonareEngineSyncMidiSysexMessage
630
857
  | SonareEngineSyncMidiPanicMessage
631
858
  | SonareEngineSyncMidiDestinationExternalMessage