@webmusic/kernel 0.1.0 → 0.4.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 (197) hide show
  1. package/LICENSE +202 -21
  2. package/NOTICE +2 -0
  3. package/README.md +138 -101
  4. package/dist/audio-context.cjs.map +1 -1
  5. package/dist/build-receipt.json +3 -3
  6. package/dist/chunk-27LH6QLZ.cjs +277 -0
  7. package/dist/chunk-27LH6QLZ.cjs.map +1 -0
  8. package/dist/chunk-3INDOVUC.cjs.map +1 -1
  9. package/dist/chunk-3RR2VIKA.js +393 -0
  10. package/dist/chunk-3RR2VIKA.js.map +1 -0
  11. package/dist/chunk-3YTKIKKX.cjs +378 -0
  12. package/dist/chunk-3YTKIKKX.cjs.map +1 -0
  13. package/dist/chunk-4RG4WQKC.js +360 -0
  14. package/dist/chunk-4RG4WQKC.js.map +1 -0
  15. package/dist/chunk-5AHVQXTF.cjs +620 -0
  16. package/dist/chunk-5AHVQXTF.cjs.map +1 -0
  17. package/dist/chunk-624KWJWZ.js +170 -0
  18. package/dist/chunk-624KWJWZ.js.map +1 -0
  19. package/dist/chunk-6HGFEKD3.cjs +851 -0
  20. package/dist/chunk-6HGFEKD3.cjs.map +1 -0
  21. package/dist/chunk-7ZTZZ5PN.cjs.map +1 -1
  22. package/dist/chunk-ALWV4P7D.js +726 -0
  23. package/dist/chunk-ALWV4P7D.js.map +1 -0
  24. package/dist/chunk-BADJJ6DV.cjs +143 -0
  25. package/dist/chunk-BADJJ6DV.cjs.map +1 -0
  26. package/dist/chunk-C3LMS36L.cjs +393 -0
  27. package/dist/chunk-C3LMS36L.cjs.map +1 -0
  28. package/dist/chunk-C3YWUZW3.cjs.map +1 -1
  29. package/dist/chunk-CR6OUWBJ.cjs +726 -0
  30. package/dist/chunk-CR6OUWBJ.cjs.map +1 -0
  31. package/dist/chunk-CYWDZLWC.js +2141 -0
  32. package/dist/chunk-CYWDZLWC.js.map +1 -0
  33. package/dist/chunk-DDOGX2D5.js +378 -0
  34. package/dist/chunk-DDOGX2D5.js.map +1 -0
  35. package/dist/chunk-DVN6E5U3.js +620 -0
  36. package/dist/chunk-DVN6E5U3.js.map +1 -0
  37. package/dist/chunk-EURMRU2S.js +208 -0
  38. package/dist/chunk-EURMRU2S.js.map +1 -0
  39. package/dist/chunk-EXDCK2VL.cjs +20 -0
  40. package/dist/chunk-EXDCK2VL.cjs.map +1 -0
  41. package/dist/chunk-G5EIUP52.js +114 -0
  42. package/dist/chunk-G5EIUP52.js.map +1 -0
  43. package/dist/chunk-GB4DGKLZ.js +143 -0
  44. package/dist/chunk-GB4DGKLZ.js.map +1 -0
  45. package/dist/chunk-GPOEAYOW.js +2147 -0
  46. package/dist/chunk-GPOEAYOW.js.map +1 -0
  47. package/dist/chunk-I4YMA5VM.cjs +120 -0
  48. package/dist/chunk-I4YMA5VM.cjs.map +1 -0
  49. package/dist/chunk-IVWHMDCB.cjs +4383 -0
  50. package/dist/chunk-IVWHMDCB.cjs.map +1 -0
  51. package/dist/chunk-JFCBJMA7.cjs +2147 -0
  52. package/dist/chunk-JFCBJMA7.cjs.map +1 -0
  53. package/dist/chunk-JLVSAZ3K.cjs +813 -0
  54. package/dist/chunk-JLVSAZ3K.cjs.map +1 -0
  55. package/dist/chunk-K7FYH6UG.cjs +208 -0
  56. package/dist/chunk-K7FYH6UG.cjs.map +1 -0
  57. package/dist/chunk-L4MYCETM.cjs +970 -0
  58. package/dist/chunk-L4MYCETM.cjs.map +1 -0
  59. package/dist/chunk-MNCMYNYL.js +970 -0
  60. package/dist/chunk-MNCMYNYL.js.map +1 -0
  61. package/dist/chunk-NT2BZ3QM.js +120 -0
  62. package/dist/chunk-NT2BZ3QM.js.map +1 -0
  63. package/dist/chunk-O7SA5GLC.js +277 -0
  64. package/dist/chunk-O7SA5GLC.js.map +1 -0
  65. package/dist/chunk-OCKAHITL.cjs +548 -0
  66. package/dist/chunk-OCKAHITL.cjs.map +1 -0
  67. package/dist/{chunk-HOKRTYPV.js → chunk-OPBHDUZK.js} +39 -1
  68. package/dist/chunk-OPBHDUZK.js.map +1 -0
  69. package/dist/chunk-OTXYWCLA.js +206 -0
  70. package/dist/chunk-OTXYWCLA.js.map +1 -0
  71. package/dist/chunk-P6ZA63J7.js +548 -0
  72. package/dist/chunk-P6ZA63J7.js.map +1 -0
  73. package/dist/chunk-QLF3BOST.js +20 -0
  74. package/dist/chunk-QLF3BOST.js.map +1 -0
  75. package/dist/chunk-RCWFRZDR.js +4383 -0
  76. package/dist/chunk-RCWFRZDR.js.map +1 -0
  77. package/dist/chunk-RZBLPM3L.cjs +206 -0
  78. package/dist/chunk-RZBLPM3L.cjs.map +1 -0
  79. package/dist/chunk-TA3TNJZU.cjs +360 -0
  80. package/dist/chunk-TA3TNJZU.cjs.map +1 -0
  81. package/dist/chunk-TZSRPTQL.cjs +2141 -0
  82. package/dist/chunk-TZSRPTQL.cjs.map +1 -0
  83. package/dist/chunk-UMTPJ76S.cjs.map +1 -1
  84. package/dist/chunk-UY77FXDW.js +813 -0
  85. package/dist/chunk-UY77FXDW.js.map +1 -0
  86. package/dist/chunk-VFU3S7OC.js +851 -0
  87. package/dist/chunk-VFU3S7OC.js.map +1 -0
  88. package/dist/chunk-VY6WWZSW.cjs.map +1 -1
  89. package/dist/chunk-WN5DZOVT.cjs +170 -0
  90. package/dist/chunk-WN5DZOVT.cjs.map +1 -0
  91. package/dist/{chunk-HZQX4J2J.cjs → chunk-WOPW6WLR.cjs} +40 -2
  92. package/dist/chunk-WOPW6WLR.cjs.map +1 -0
  93. package/dist/chunk-XBSIYUHM.cjs +114 -0
  94. package/dist/chunk-XBSIYUHM.cjs.map +1 -0
  95. package/dist/chunk-ZMU72HJS.cjs.map +1 -1
  96. package/dist/context-DSa0ymyN.d.cts +664 -0
  97. package/dist/context-DaxfAg3b.d.ts +664 -0
  98. package/dist/effect-chain-Cu03O5Y0.d.ts +91 -0
  99. package/dist/effect-chain-Do75T7uK.d.cts +91 -0
  100. package/dist/effect.cjs +16 -1
  101. package/dist/effect.cjs.map +1 -1
  102. package/dist/effect.d.cts +56 -14
  103. package/dist/effect.d.ts +56 -14
  104. package/dist/effect.js +16 -1
  105. package/dist/elements.cjs +37 -2
  106. package/dist/elements.cjs.map +1 -1
  107. package/dist/elements.d.cts +197 -8
  108. package/dist/elements.d.ts +197 -8
  109. package/dist/elements.js +36 -1
  110. package/dist/events.cjs.map +1 -1
  111. package/dist/index.cjs +556 -9
  112. package/dist/index.cjs.map +1 -1
  113. package/dist/index.d.cts +17 -5
  114. package/dist/index.d.ts +17 -5
  115. package/dist/index.js +567 -20
  116. package/dist/message.cjs +104 -0
  117. package/dist/message.cjs.map +1 -0
  118. package/dist/message.d.cts +738 -0
  119. package/dist/message.d.ts +738 -0
  120. package/dist/message.js +104 -0
  121. package/dist/meter.cjs +2 -2
  122. package/dist/meter.cjs.map +1 -1
  123. package/dist/meter.d.cts +9 -1
  124. package/dist/meter.d.ts +9 -1
  125. package/dist/meter.js +1 -1
  126. package/dist/module-control-C25BMtH7.d.ts +61 -0
  127. package/dist/module-control-yH6nTJM9.d.cts +61 -0
  128. package/dist/module-plugin-BnPmq1VP.d.ts +198 -0
  129. package/dist/module-plugin-CHb-5W0Y.d.cts +198 -0
  130. package/dist/module.cjs +263 -0
  131. package/dist/module.cjs.map +1 -0
  132. package/dist/module.d.cts +1112 -0
  133. package/dist/module.d.ts +1112 -0
  134. package/dist/module.js +263 -0
  135. package/dist/parameter-DwQzFmBR.d.cts +172 -0
  136. package/dist/parameter-DwQzFmBR.d.ts +172 -0
  137. package/dist/player.cjs.map +1 -1
  138. package/dist/processor-worklet.cjs +18 -0
  139. package/dist/processor-worklet.cjs.map +1 -0
  140. package/dist/processor-worklet.d.cts +166 -0
  141. package/dist/processor-worklet.d.ts +166 -0
  142. package/dist/processor-worklet.js +18 -0
  143. package/dist/processor-worklet.js.map +1 -0
  144. package/dist/processor.cjs +51 -0
  145. package/dist/processor.cjs.map +1 -0
  146. package/dist/processor.d.cts +397 -0
  147. package/dist/processor.d.ts +397 -0
  148. package/dist/processor.js +51 -0
  149. package/dist/processor.js.map +1 -0
  150. package/dist/project-types-BU4awMnL.d.ts +323 -0
  151. package/dist/project-types-DufCV8Ma.d.cts +323 -0
  152. package/dist/ring-C-i9N90a.d.cts +139 -0
  153. package/dist/ring-DkcMt2Eg.d.ts +139 -0
  154. package/dist/sequence.cjs +68 -0
  155. package/dist/sequence.cjs.map +1 -0
  156. package/dist/sequence.d.cts +303 -0
  157. package/dist/sequence.d.ts +303 -0
  158. package/dist/sequence.js +68 -0
  159. package/dist/sequence.js.map +1 -0
  160. package/dist/session.cjs +16 -0
  161. package/dist/session.cjs.map +1 -0
  162. package/dist/session.d.cts +407 -0
  163. package/dist/session.d.ts +407 -0
  164. package/dist/session.js +16 -0
  165. package/dist/session.js.map +1 -0
  166. package/dist/tick.cjs.map +1 -1
  167. package/dist/transport.cjs +50 -2
  168. package/dist/transport.cjs.map +1 -1
  169. package/dist/transport.d.cts +145 -1
  170. package/dist/transport.d.ts +145 -1
  171. package/dist/transport.js +51 -3
  172. package/dist/worker.cjs.map +1 -1
  173. package/package.json +62 -11
  174. package/dist/chunk-53YD73OY.js +0 -162
  175. package/dist/chunk-53YD73OY.js.map +0 -1
  176. package/dist/chunk-BR63OD53.cjs +0 -1
  177. package/dist/chunk-BR63OD53.cjs.map +0 -1
  178. package/dist/chunk-HOKRTYPV.js.map +0 -1
  179. package/dist/chunk-HZQX4J2J.cjs.map +0 -1
  180. package/dist/chunk-JNXB74G3.cjs +0 -987
  181. package/dist/chunk-JNXB74G3.cjs.map +0 -1
  182. package/dist/chunk-SM5YPDDI.cjs +0 -162
  183. package/dist/chunk-SM5YPDDI.cjs.map +0 -1
  184. package/dist/chunk-TEM2I2NN.js +0 -1
  185. package/dist/chunk-VVZX7DQ6.cjs +0 -254
  186. package/dist/chunk-VVZX7DQ6.cjs.map +0 -1
  187. package/dist/chunk-WNFGDB7B.js +0 -254
  188. package/dist/chunk-WNFGDB7B.js.map +0 -1
  189. package/dist/chunk-XBJBY4J5.js +0 -987
  190. package/dist/chunk-XBJBY4J5.js.map +0 -1
  191. package/dist/sync.cjs +0 -12
  192. package/dist/sync.cjs.map +0 -1
  193. package/dist/sync.d.cts +0 -304
  194. package/dist/sync.d.ts +0 -304
  195. package/dist/sync.js +0 -12
  196. /package/dist/{chunk-TEM2I2NN.js.map → message.js.map} +0 -0
  197. /package/dist/{sync.js.map → module.js.map} +0 -0
@@ -0,0 +1,397 @@
1
+ import { c as ProcessorDefinition, R as ResolvedProcessorDefinition, d as ProcessorRing } from './ring-C-i9N90a.cjs';
2
+ export { P as ProcessorAudioParamDescriptor, a as ProcessorAudioPort, b as ProcessorCapabilities, e as ProcessorSharedRingRequest, p as processorAudioParams, f as processorCapabilities, g as processorName, h as processorSignature, r as resolveProcessorDefinition } from './ring-C-i9N90a.cjs';
3
+ import { w as ModuleHandle, G as NoteInputPort, b as AudioInputPort, f as AudioOutputPort, h as ControlPort, x as ModulePort, N as NoteEvent, u as ModuleContext } from './context-DSa0ymyN.cjs';
4
+ import { i as ParamSurface } from './parameter-DwQzFmBR.cjs';
5
+ import { E as Effect } from './effect-chain-Do75T7uK.cjs';
6
+ import { x as ProjectPluginFactory } from './project-types-DufCV8Ma.cjs';
7
+ import './tick.cjs';
8
+ import './session.cjs';
9
+ import './transport.cjs';
10
+
11
+ /** Bumped when a message shape changes incompatibly; the two sides must match. */
12
+ declare const PROCESSOR_PROTOCOL_VERSION = 1;
13
+ /** `frame` of a note that plays as soon as possible: a live gesture with no scheduled time. */
14
+ declare const PROCESSOR_IMMEDIATE_FRAME = -1;
15
+ /** `processorOptions` handed to the processor's constructor. */
16
+ interface ProcessorNodeOptions {
17
+ readonly protocol: number;
18
+ /** The `id@version` the node was created for. */
19
+ readonly name: string;
20
+ /** Author-defined, structured-cloneable initial configuration. */
21
+ readonly config?: unknown;
22
+ /** The module compiled during preparation, when the source supplied `wasm`. */
23
+ readonly wasm?: WebAssembly.Module;
24
+ /** This node's shared ring, when the definition requests one and memory can be shared. */
25
+ readonly ring?: SharedArrayBuffer;
26
+ }
27
+ /** Author-defined configuration; never used for per-block control. */
28
+ interface ProcessorConfigMessage {
29
+ readonly type: 'config';
30
+ readonly data: unknown;
31
+ }
32
+ /**
33
+ * One gate change of one note occurrence, already converted for the audio
34
+ * thread: an absolute context frame instead of seconds, an integer occurrence
35
+ * instead of a string ID.
36
+ */
37
+ interface ProcessorNoteMessage {
38
+ readonly type: 'note';
39
+ readonly gate: 'on' | 'off' | 'cancel';
40
+ readonly occurrence: number;
41
+ readonly midi: number;
42
+ readonly cents: number;
43
+ /** Normalized 0–1. */
44
+ readonly velocity: number;
45
+ /**
46
+ * Absolute frame on the context's sample clock, or {@link PROCESSOR_IMMEDIATE_FRAME}
47
+ * for a live gesture that plays at the next block without counting as late.
48
+ */
49
+ readonly frame: number;
50
+ readonly epoch: number;
51
+ }
52
+ /** A Session anchor copied to the audio thread. The processor cannot write it. */
53
+ interface ProcessorTransportMessage {
54
+ readonly type: 'transport';
55
+ /** Absolute frame at which the Session position is `originSeconds`; before it the position holds. */
56
+ readonly originFrame: number;
57
+ /** Session seconds at `originFrame`. */
58
+ readonly originSeconds: number;
59
+ readonly rate: number;
60
+ readonly running: boolean;
61
+ readonly loop: Readonly<{
62
+ startSeconds: number;
63
+ endSeconds: number;
64
+ }> | null;
65
+ readonly epoch: number;
66
+ }
67
+ /**
68
+ * The Session invalidated its schedule (seek, pause, stop, loop or rate
69
+ * change): withdraw every queued scheduled onset and cancel every sounding
70
+ * scheduled note. Live gestures (immediate frame) are untouched.
71
+ */
72
+ interface ProcessorFlushMessage {
73
+ readonly type: 'flush';
74
+ readonly epoch: number;
75
+ }
76
+ /** The owner released the node: the processor stops at its next block instead of waiting for collection. */
77
+ interface ProcessorCloseMessage {
78
+ readonly type: 'close';
79
+ }
80
+ /** Everything the main thread can post to a processor. */
81
+ type ProcessorMessage = ProcessorConfigMessage | ProcessorNoteMessage | ProcessorTransportMessage | ProcessorFlushMessage | ProcessorCloseMessage;
82
+ /** The processor threw; Web Audio has stopped calling it. Sent once. */
83
+ interface ProcessorErrorReport {
84
+ readonly type: 'error';
85
+ readonly message: string;
86
+ }
87
+ /** Note events that arrived after their frame since the last report. Posted at most four times a second. */
88
+ interface ProcessorLateReport {
89
+ readonly type: 'late';
90
+ readonly count: number;
91
+ }
92
+ /** Author-defined observation, posted at a bounded rate. */
93
+ interface ProcessorDataReport {
94
+ readonly type: 'data';
95
+ readonly data: unknown;
96
+ }
97
+ /** Everything a processor can post to the main thread. */
98
+ type ProcessorReport = ProcessorErrorReport | ProcessorLateReport | ProcessorDataReport;
99
+
100
+ /** A WebAssembly binary: its URL, its bytes, or an already compiled module. */
101
+ type ProcessorWasmSource = string | URL | ArrayBuffer | ArrayBufferView | WebAssembly.Module;
102
+ /**
103
+ * Where a processor's code comes from. `module` is the URL of the author's
104
+ * worklet file, supplied by the application or its bundler; Kernel never
105
+ * guesses it. `register` is for applications that load worklets themselves
106
+ * and is called once per context. `wasm` is compiled on the main thread during
107
+ * preparation and handed to every node; each processor instantiates it with
108
+ * its own memory.
109
+ */
110
+ type ProcessorSource = {
111
+ readonly module: string | URL;
112
+ readonly wasm?: ProcessorWasmSource;
113
+ } | {
114
+ readonly register: (context: BaseAudioContext) => void | Promise<void>;
115
+ readonly wasm?: ProcessorWasmSource;
116
+ };
117
+ /** The context cannot host a processor: it has no `audioWorklet`. */
118
+ declare class ProcessorUnavailableError extends Error {
119
+ constructor(message?: string);
120
+ }
121
+ /**
122
+ * Load and register a processor in one audio context. Call it before creating
123
+ * nodes or editing an insert chain: graph edits stay synchronous, and all
124
+ * waiting happens here.
125
+ *
126
+ * - Repeated and concurrent calls for the same definition share one load.
127
+ * - A different definition under the same `id@version` rejects without loading.
128
+ * - A failed load is forgotten, so a retry is an explicit new call. It creates
129
+ * and resumes no context and leaves the existing graph untouched.
130
+ */
131
+ declare function prepareProcessor(context: BaseAudioContext, definition: ProcessorDefinition | ResolvedProcessorDefinition, source: ProcessorSource): Promise<void>;
132
+ /** Whether this exact definition finished preparing in this context. */
133
+ declare function isProcessorPrepared(context: BaseAudioContext, definition: ProcessorDefinition | ResolvedProcessorDefinition): boolean;
134
+
135
+ /** Builds the node; injectable for tests and for applications that wrap node creation. */
136
+ type ProcessorNodeFactory = (context: BaseAudioContext, name: string, options: AudioWorkletNodeOptions) => AudioWorkletNode;
137
+
138
+ interface ProcessorModuleOptions {
139
+ /** Module ID; immutable for the module's life and unique in its registry. */
140
+ readonly id: string;
141
+ /** Structured-cloneable value handed to the processor's `create` as `setup.config`. */
142
+ readonly config?: unknown;
143
+ /** Initial base values by parameter ID; omitted parameters start at their default. */
144
+ readonly params?: Readonly<Record<string, number>>;
145
+ /**
146
+ * `default` (the default) routes the first audio output through the
147
+ * context's admission or default destination. `none` leaves every output
148
+ * unrouted for explicit patching.
149
+ */
150
+ readonly route?: 'default' | 'none';
151
+ readonly createNode?: ProcessorNodeFactory;
152
+ /**
153
+ * Places a note event on the audio clock: audio-context seconds, `'now'` for
154
+ * a live gesture with no scheduled time, or undefined when the event's axis
155
+ * has no mapping (the event is rejected). The default accepts
156
+ * `audio-context-seconds` as is and plays `performance-seconds` gestures now.
157
+ */
158
+ readonly noteTime?: ProcessorNoteTime;
159
+ /**
160
+ * `context` (the default) borrows the scope's Session scheduling binding when
161
+ * the definition declares note input or transport; `none` ignores it. The
162
+ * Session must use this module's audio context as its reference clock.
163
+ */
164
+ readonly session?: 'context' | 'none';
165
+ /** Author-defined observations the processor posts through `setup.report`. */
166
+ readonly onReport?: (data: unknown) => void;
167
+ readonly onCleanupError?: (error: unknown) => void;
168
+ }
169
+ /** Where a note event falls on the audio clock; see {@link ProcessorModuleOptions.noteTime}. */
170
+ type ProcessorNoteTime = (event: NoteEvent) => number | 'now' | undefined;
171
+ /** Accepts scheduled `audio-context-seconds` notes and plays live `performance-seconds` gestures at once. */
172
+ declare const defaultProcessorNoteTime: ProcessorNoteTime;
173
+ /** `ready` until the processor fails (`error`) or the module is disposed (`detached`, terminal). */
174
+ type ProcessorModuleState = 'ready' | 'error' | 'detached';
175
+ /**
176
+ * An authored DSP processor as a module: one `AudioWorkletNode`, typed audio
177
+ * input and output ports, and a parameter surface whose handles drive the
178
+ * node's `AudioParam`s. The module owns its node, ports, parameter handles,
179
+ * route and registration; it borrows the context and never closes it.
180
+ *
181
+ * Create it with {@link createProcessorModule} after `prepareProcessor` has
182
+ * resolved in the same audio context.
183
+ */
184
+ declare class ProcessorModule implements ModuleHandle {
185
+ #private;
186
+ readonly id: string;
187
+ readonly definition: ResolvedProcessorDefinition;
188
+ readonly node: AudioWorkletNode;
189
+ readonly params: ParamSurface;
190
+ /** Declared processing latency, `latencySamples / sampleRate`; never measured. */
191
+ readonly latencySeconds: number;
192
+ /** The `notes` input when the definition declares note input. */
193
+ readonly notes?: NoteInputPort;
194
+ /** The reader side of the node's shared ring; absent unless the definition requests one and memory can be shared. */
195
+ get ring(): ProcessorRing | undefined;
196
+ /** @internal Use {@link createProcessorModule}. */
197
+ constructor(parts: {
198
+ id: string;
199
+ definition: ResolvedProcessorDefinition;
200
+ node: AudioWorkletNode;
201
+ params: ParamSurface;
202
+ latencySeconds: number;
203
+ inputs: readonly AudioInputPort[];
204
+ outputs: readonly AudioOutputPort[];
205
+ control?: ControlPort;
206
+ notes?: NoteInputPort;
207
+ cleanups: (() => void)[];
208
+ onCleanupError?: (error: unknown) => void;
209
+ });
210
+ get state(): ProcessorModuleState;
211
+ /** The processor's failure message while `state` is `error`. */
212
+ get error(): string | undefined;
213
+ /** Note changes the processor played after their frame, as reported so far. Zero means every note was on time. */
214
+ get lateNotes(): number;
215
+ /** Every port: audio inputs, `notes` with note input, audio outputs, then `params` when the definition has parameters. */
216
+ ports(): readonly ModulePort[];
217
+ /** An audio output by its definition ID. */
218
+ getPort(name: string): AudioOutputPort | undefined;
219
+ /** An audio input by its definition ID. */
220
+ getInput(name: string): AudioInputPort | undefined;
221
+ /** Post configuration to the processor's `message` callback. Not for per-block control; use parameters. */
222
+ configure(data: unknown): void;
223
+ /** Called after a state change and after a late-note report. */
224
+ subscribe(listener: () => void): () => void;
225
+ /**
226
+ * Release routes, registration, ports, parameter bindings and the node, in
227
+ * reverse order of acquisition. Continues after an individual failure and is
228
+ * safe to repeat. The audio context stays open.
229
+ */
230
+ dispose(): void;
231
+ /** @internal Processor failure; routes stay so the graph remains valid and silent on this branch. */
232
+ fail(message: string): void;
233
+ /** @internal Late-note report from the processor. */
234
+ late(count: number): void;
235
+ }
236
+ /**
237
+ * Create a processor module in `context`. The definition must already be
238
+ * prepared in the context's audio environment (`prepareProcessor` resolved);
239
+ * otherwise this throws without creating a node.
240
+ *
241
+ * Each audio input gets a stable entry node with the declared channel count,
242
+ * so producers are up- or down-mixed explicitly. Each output gets its own port.
243
+ * Parameters declared `audio-rate` or `control-rate` bind to the node's
244
+ * `AudioParam`s through their handles and accept modulation; other parameters
245
+ * write the `AudioParam` directly.
246
+ *
247
+ * With note input, the module exposes a `notes` input port. Each event is
248
+ * placed on the audio clock with `noteTime` and posted ahead of its frame; the
249
+ * processor plays it at that frame, or at the next block and counts it in
250
+ * {@link ProcessorModule.lateNotes} when it arrives too late. Disconnecting a
251
+ * producer or disposing the module cancels the notes it started.
252
+ *
253
+ * In a scope with a Session, a module with note input or transport borrows
254
+ * the Session's scheduling binding: when the Session invalidates its
255
+ * schedule (seek, pause, stop, loop or rate change), queued scheduled notes
256
+ * are withdrawn and sounding ones cancelled, while live gestures continue; a
257
+ * `transport` definition receives each anchor and reads the Session position
258
+ * in `block.transport`. Without a Session, `block.transport` reports stopped.
259
+ */
260
+ declare function createProcessorModule(context: ModuleContext, definition: ProcessorDefinition | ResolvedProcessorDefinition, options: ProcessorModuleOptions): ProcessorModule;
261
+
262
+ interface ProcessorEffectOptions {
263
+ /** Caption for controls; default: the definition ID. */
264
+ readonly label?: string;
265
+ /** Structured-cloneable value handed to every realization's `create`. */
266
+ readonly config?: unknown;
267
+ readonly createNode?: ProcessorNodeFactory;
268
+ /** A realization's processor failed; it is silent and stays in the chain. */
269
+ readonly onError?: (message: string) => void;
270
+ /** Author-defined observations from any realization. */
271
+ readonly onReport?: (data: unknown) => void;
272
+ }
273
+ /**
274
+ * A prepared processor as an insert `Effect` recipe for `InsertChain`, a
275
+ * Rack channel or a player's `.effect`. Each realization creates its own
276
+ * `AudioWorkletNode` and is both the slot's input and output: the chain feeds
277
+ * the first audio input and reads the first audio output. Further buses stay
278
+ * unconnected.
279
+ *
280
+ * `createAudioNodes` stays synchronous, so the processor must already be
281
+ * prepared in that context; otherwise it throws and the chain keeps its
282
+ * working graph. It never substitutes a bypass.
283
+ *
284
+ * The chain builds the parameter handles from the node's `AudioParam`s with
285
+ * the definition's descriptors, so `audio-rate` and `control-rate` parameters
286
+ * accept modulation and others are written directly.
287
+ */
288
+ declare function processorEffect(definition: ProcessorDefinition | ResolvedProcessorDefinition, options?: ProcessorEffectOptions): Effect;
289
+
290
+ interface ProcessorInstrumentOptions {
291
+ /**
292
+ * Borrowed handles for the declared parameters, for a surface that outlives
293
+ * one node (an adapter that reconnects). Each declared ID needs a handle with
294
+ * the same modulation. The instrument binds them to its node and releases
295
+ * only those bindings; the owner keeps them and calls `releaseAudio(context)`
296
+ * when it leaves the context. Absent, the instrument creates and owns handles.
297
+ */
298
+ readonly params?: ParamSurface;
299
+ /** Initial base values for owned handles. Ignored with borrowed `params`. */
300
+ readonly values?: Readonly<Record<string, number>>;
301
+ /** Structured-cloneable value handed to the processor's `create`. */
302
+ readonly config?: unknown;
303
+ readonly createNode?: ProcessorNodeFactory;
304
+ /** The processor failed: it is silent from now on. Called once. */
305
+ readonly onError?: (message: string) => void;
306
+ /** Note changes the processor played after their frame since the previous report. */
307
+ readonly onLateNotes?: (count: number) => void;
308
+ /** Author-defined observations from the processor. */
309
+ readonly onReport?: (data: unknown) => void;
310
+ }
311
+ /** `ready` until the processor fails (`error`) or the instrument is disposed (`detached`, terminal). */
312
+ type ProcessorInstrumentState = 'ready' | 'error' | 'detached';
313
+ /**
314
+ * A note-input processor played directly on the audio clock, for adapters
315
+ * whose callers already speak in AudioContext seconds and note occurrences,
316
+ * such as a synth backend. One `AudioWorkletNode`; `node` is its output, which
317
+ * the owner connects. No ports, registry or Session: a graph member uses
318
+ * `createProcessorModule` instead.
319
+ *
320
+ * Each `start` returns a new occurrence; `release` and `cancel` name it.
321
+ * A time at or before `currentTime` applies at the next block. A later
322
+ * `release` replaces one still queued, so a scheduled end can move earlier or
323
+ * later until it is reached; after that the note is already releasing.
324
+ * `cancel` before the onset withdraws the note so it never sounds.
325
+ */
326
+ declare class ProcessorInstrument {
327
+ #private;
328
+ readonly definition: ResolvedProcessorDefinition;
329
+ readonly node: AudioWorkletNode;
330
+ readonly params: ParamSurface;
331
+ /** @internal Use {@link createProcessorInstrument}. */
332
+ constructor(parts: {
333
+ audio: BaseAudioContext;
334
+ definition: ResolvedProcessorDefinition;
335
+ node: AudioWorkletNode;
336
+ params: ParamSurface;
337
+ cleanups: (() => void)[];
338
+ });
339
+ /** The reader side of the node's shared ring; absent unless the definition requests one and memory can be shared. */
340
+ get ring(): ProcessorRing | undefined;
341
+ get state(): ProcessorInstrumentState;
342
+ get error(): string | undefined;
343
+ /** Note changes played after their frame, as reported so far. */
344
+ get lateNotes(): number;
345
+ /** Start a note at `time` (AudioContext seconds) and return its occurrence. */
346
+ start(midi: number, velocity: number, time: number, cents?: number): number;
347
+ /** Release `occurrence` at `time`, replacing a release still queued. */
348
+ release(occurrence: number, time: number): void;
349
+ /** Stop `occurrence` at `time` without a release phase; before its onset, it never sounds. */
350
+ cancel(occurrence: number, time: number): void;
351
+ /**
352
+ * Stop the processor and release its node and parameter bindings, in
353
+ * reverse order of acquisition. Continues after an individual failure,
354
+ * rethrows the first, and is safe to repeat. The audio context stays open.
355
+ */
356
+ dispose(): void;
357
+ /** @internal */
358
+ fail(message: string): boolean;
359
+ /** @internal */
360
+ late(count: number): boolean;
361
+ }
362
+ /**
363
+ * Create a processor instrument in `audio`. The definition must declare
364
+ * `noteInput` and already be prepared in that context (`prepareProcessor`
365
+ * resolved); otherwise this throws without creating a node. Declared audio
366
+ * inputs stay unconnected; `block.transport`, if declared, reports stopped.
367
+ */
368
+ declare function createProcessorInstrument(audio: BaseAudioContext, definition: ProcessorDefinition | ResolvedProcessorDefinition, options?: ProcessorInstrumentOptions): ProcessorInstrument;
369
+
370
+ interface ProcessorPluginOptions {
371
+ /**
372
+ * Where to load the processor when a project restores it into a context
373
+ * where it is not yet prepared. Without it, the processor must already be
374
+ * prepared there; otherwise the module stays unresolved.
375
+ */
376
+ readonly source?: ProcessorSource;
377
+ readonly createNode?: ProcessorNodeFactory;
378
+ /** Author-defined observations from any instance, with its module ID. */
379
+ readonly onReport?: (moduleId: string, data: unknown) => void;
380
+ }
381
+ /**
382
+ * A project plugin for one processor definition, registered under the
383
+ * definition's `id` and `version`. Each module record becomes a processor
384
+ * module in its context: the record's `config` is handed to the processor's
385
+ * `create`, saved parameters restore through the module's parameter surface,
386
+ * the first output follows the context's default route, and notes and audio
387
+ * connect through its ports.
388
+ *
389
+ * When the processor cannot be prepared in the project's audio context — no
390
+ * `source` and not prepared, `AudioWorklet` unavailable, or the load fails —
391
+ * the module stays unresolved with the reason, and its record, parameters
392
+ * and connections are kept for the next restore. A project saved with a
393
+ * different processor version finds no plugin and stays unresolved too.
394
+ */
395
+ declare function processorPlugin(definition: ProcessorDefinition | ResolvedProcessorDefinition, options?: ProcessorPluginOptions): ProjectPluginFactory;
396
+
397
+ export { PROCESSOR_IMMEDIATE_FRAME, PROCESSOR_PROTOCOL_VERSION, type ProcessorCloseMessage, type ProcessorConfigMessage, type ProcessorDataReport, ProcessorDefinition, type ProcessorEffectOptions, type ProcessorErrorReport, type ProcessorFlushMessage, ProcessorInstrument, type ProcessorInstrumentOptions, type ProcessorInstrumentState, type ProcessorLateReport, type ProcessorMessage, ProcessorModule, type ProcessorModuleOptions, type ProcessorModuleState, type ProcessorNodeFactory, type ProcessorNodeOptions, type ProcessorNoteMessage, type ProcessorNoteTime, type ProcessorPluginOptions, type ProcessorReport, ProcessorRing, type ProcessorSource, type ProcessorTransportMessage, ProcessorUnavailableError, type ProcessorWasmSource, ResolvedProcessorDefinition, createProcessorInstrument, createProcessorModule, defaultProcessorNoteTime, isProcessorPrepared, prepareProcessor, processorEffect, processorPlugin };