@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,166 @@
1
+ import { R as ResolvedProcessorDefinition, d as ProcessorRing, c as ProcessorDefinition } from './ring-C-i9N90a.cjs';
2
+ import './parameter-DwQzFmBR.cjs';
3
+
4
+ /**
5
+ * One render quantum. The object and its arrays are reused between calls:
6
+ * read and write them only inside `process`, and never keep a reference.
7
+ */
8
+ interface ProcessorBlock {
9
+ /** `inputs[port][channel]`; a disconnected port has no channels. */
10
+ inputs: readonly (readonly Float32Array[])[];
11
+ /** `outputs[port][channel]`, zero-filled before each call. */
12
+ outputs: readonly (readonly Float32Array[])[];
13
+ /**
14
+ * `params[id]` holds one value for a k-rate parameter, or for an a-rate
15
+ * parameter that is constant in this block, and one value per frame
16
+ * otherwise. Automation and connected modulators are already summed in.
17
+ */
18
+ params: Readonly<Record<string, Float32Array>>;
19
+ /** Absolute frame of the block's first sample; `frame / sampleRate` is audio reference time. */
20
+ frame: number;
21
+ sampleRate: number;
22
+ /** The Session transport at the block's first frame, when the definition declares `transport`. */
23
+ transport?: ProcessorTransport;
24
+ }
25
+ /**
26
+ * The Session transport as the audio thread sees it, derived each block from
27
+ * the last anchor the module posted. Reused between calls; read-only.
28
+ */
29
+ interface ProcessorTransport {
30
+ /** False while paused, stopped, invalidated or before a scheduled start. */
31
+ playing: boolean;
32
+ /** Session seconds at the block's first frame, folded into the loop when one is set. */
33
+ position: number;
34
+ rate: number;
35
+ loop: Readonly<{
36
+ startSeconds: number;
37
+ endSeconds: number;
38
+ }> | null;
39
+ /** The Session's scheduling epoch; it changes whenever earlier timing became invalid. */
40
+ epoch: number;
41
+ }
42
+ /**
43
+ * One gate change of one note occurrence, delivered just before the `process`
44
+ * call of the block it falls in. The object is reused: copy what you keep.
45
+ */
46
+ interface ProcessorNoteEvent {
47
+ gate: 'on' | 'off' | 'cancel';
48
+ /** Small integer, stable while the note is held; `off` and `cancel` name the `on` they end. */
49
+ occurrence: number;
50
+ midi: number;
51
+ cents: number;
52
+ /** Normalized 0–1. */
53
+ velocity: number;
54
+ /** Frame within the coming block (0 to block length − 1) at which the change applies. */
55
+ frameOffset: number;
56
+ epoch: number;
57
+ }
58
+ /** What `create` receives. Allocate every buffer, table and voice here. */
59
+ interface ProcessorSetup {
60
+ readonly definition: ResolvedProcessorDefinition;
61
+ readonly sampleRate: number;
62
+ /** The `config` the module was created with, if any. */
63
+ readonly config: unknown;
64
+ /** Post an author-defined observation to the main thread. Not for per-block use. */
65
+ report(data: unknown): void;
66
+ /**
67
+ * The compiled module from `source.wasm`, if any. Instantiate it here with
68
+ * `new WebAssembly.Instance(setup.wasm, imports)`; the instance and its
69
+ * memory belong to this processor.
70
+ */
71
+ readonly wasm?: WebAssembly.Module;
72
+ /**
73
+ * The writer side of this node's shared ring, when the definition requests
74
+ * one and the page can share memory. Absent otherwise: a processor whose
75
+ * ring is optional must work without it. `write` never blocks or allocates.
76
+ */
77
+ readonly ring?: ProcessorRing;
78
+ }
79
+ /**
80
+ * The author's DSP. `process` and `note` run on the audio thread once per
81
+ * render quantum: they must not allocate, create closures or strings, or post
82
+ * messages.
83
+ */
84
+ interface ProcessorImplementation<State> {
85
+ create(setup: ProcessorSetup): State;
86
+ process(state: State, block: ProcessorBlock): void;
87
+ /**
88
+ * Required when the definition declares `noteInput`. Called in time order
89
+ * for every note change in the coming block, before `process`. `cancel`
90
+ * means stop at once, without a release phase.
91
+ */
92
+ note?(state: State, event: ProcessorNoteEvent): void;
93
+ /** Non-real-time configuration posted by the module. */
94
+ message?(state: State, data: unknown): void;
95
+ }
96
+ interface WorkletPort {
97
+ onmessage: ((event: {
98
+ data: unknown;
99
+ }) => void) | null;
100
+ postMessage(message: unknown): void;
101
+ }
102
+ /** The part of `AudioWorkletGlobalScope` the kit uses; injectable for tests. */
103
+ interface ProcessorWorkletScope {
104
+ registerProcessor(name: string, processor: unknown): void;
105
+ AudioWorkletProcessor: new () => {
106
+ readonly port: WorkletPort;
107
+ };
108
+ readonly currentFrame: number;
109
+ readonly sampleRate: number;
110
+ }
111
+ /**
112
+ * Register a processor for `definition` in the current worklet scope. Call it
113
+ * once at the top level of the worklet file, with the same definition object
114
+ * the main thread passes to `prepareProcessor`.
115
+ *
116
+ * If `create`, `note` or `process` throws, the processor reports the error
117
+ * once, goes silent and stops; it does not restart itself.
118
+ *
119
+ * With `noteInput`, the kit keeps a queue of note changes sorted by frame and
120
+ * delivers each one to `note` before the `process` call of its block, with
121
+ * its frame offset. A change that arrives after its frame plays at the start
122
+ * of the next block and is counted (a late `cancel` is not counted: it means
123
+ * stop now); the counts reach the main thread at most
124
+ * four times a second. `cancel` before an onset withdraws that note entirely.
125
+ * When the module's Session invalidates its schedule, the kit withdraws every
126
+ * queued scheduled onset and cancels every sounding scheduled note; live
127
+ * gestures continue. With `transport`, `block.transport` gives the Session
128
+ * position at each block's first frame.
129
+ */
130
+ declare function defineProcessor<State>(definition: ProcessorDefinition | ResolvedProcessorDefinition, implementation: ProcessorImplementation<State>, scope?: ProcessorWorkletScope): void;
131
+
132
+ /** An in-place complex FFT of a fixed power-of-two size. */
133
+ interface FFT {
134
+ readonly size: number;
135
+ /** Transform `real` and `imag` in place, time to frequency. */
136
+ forward(real: Float32Array, imag: Float32Array): void;
137
+ /** Transform in place, frequency to time, scaled by 1/size. */
138
+ inverse(real: Float32Array, imag: Float32Array): void;
139
+ }
140
+ /** Create an FFT of `size` (a power of two from 2 to 65536). */
141
+ declare function createFFT(size: number): FFT;
142
+ /** A periodic Hann window of `size` samples, suited to overlap-add at hop size/2 or size/4. */
143
+ declare function hannWindow(size: number): Float32Array;
144
+ interface SpectralFrameOptions {
145
+ /** FFT size, a power of two. */
146
+ readonly size: number;
147
+ /** Samples between frames: size/2 or size/4 (the default). */
148
+ readonly hop?: number;
149
+ }
150
+ /**
151
+ * Overlap-add spectral processing for one channel: feed blocks of any length;
152
+ * every `hop` samples a Hann-windowed frame is transformed, handed to
153
+ * `onFrame(real, imag)` to change in place, transformed back, windowed again
154
+ * and added to the output. The output lags the input by `size` samples.
155
+ */
156
+ interface SpectralFrame {
157
+ readonly size: number;
158
+ readonly hop: number;
159
+ /** The output's delay behind the input, in samples. */
160
+ readonly latency: number;
161
+ process(input: Float32Array, output: Float32Array, onFrame: (real: Float32Array, imag: Float32Array) => void): void;
162
+ reset(): void;
163
+ }
164
+ declare function createSpectralFrame(options: SpectralFrameOptions): SpectralFrame;
165
+
166
+ export { type FFT, type ProcessorBlock, type ProcessorImplementation, type ProcessorNoteEvent, ProcessorRing, type ProcessorSetup, type ProcessorTransport, type ProcessorWorkletScope, type SpectralFrame, type SpectralFrameOptions, createFFT, createSpectralFrame, defineProcessor, hannWindow };
@@ -0,0 +1,166 @@
1
+ import { R as ResolvedProcessorDefinition, d as ProcessorRing, c as ProcessorDefinition } from './ring-DkcMt2Eg.js';
2
+ import './parameter-DwQzFmBR.js';
3
+
4
+ /**
5
+ * One render quantum. The object and its arrays are reused between calls:
6
+ * read and write them only inside `process`, and never keep a reference.
7
+ */
8
+ interface ProcessorBlock {
9
+ /** `inputs[port][channel]`; a disconnected port has no channels. */
10
+ inputs: readonly (readonly Float32Array[])[];
11
+ /** `outputs[port][channel]`, zero-filled before each call. */
12
+ outputs: readonly (readonly Float32Array[])[];
13
+ /**
14
+ * `params[id]` holds one value for a k-rate parameter, or for an a-rate
15
+ * parameter that is constant in this block, and one value per frame
16
+ * otherwise. Automation and connected modulators are already summed in.
17
+ */
18
+ params: Readonly<Record<string, Float32Array>>;
19
+ /** Absolute frame of the block's first sample; `frame / sampleRate` is audio reference time. */
20
+ frame: number;
21
+ sampleRate: number;
22
+ /** The Session transport at the block's first frame, when the definition declares `transport`. */
23
+ transport?: ProcessorTransport;
24
+ }
25
+ /**
26
+ * The Session transport as the audio thread sees it, derived each block from
27
+ * the last anchor the module posted. Reused between calls; read-only.
28
+ */
29
+ interface ProcessorTransport {
30
+ /** False while paused, stopped, invalidated or before a scheduled start. */
31
+ playing: boolean;
32
+ /** Session seconds at the block's first frame, folded into the loop when one is set. */
33
+ position: number;
34
+ rate: number;
35
+ loop: Readonly<{
36
+ startSeconds: number;
37
+ endSeconds: number;
38
+ }> | null;
39
+ /** The Session's scheduling epoch; it changes whenever earlier timing became invalid. */
40
+ epoch: number;
41
+ }
42
+ /**
43
+ * One gate change of one note occurrence, delivered just before the `process`
44
+ * call of the block it falls in. The object is reused: copy what you keep.
45
+ */
46
+ interface ProcessorNoteEvent {
47
+ gate: 'on' | 'off' | 'cancel';
48
+ /** Small integer, stable while the note is held; `off` and `cancel` name the `on` they end. */
49
+ occurrence: number;
50
+ midi: number;
51
+ cents: number;
52
+ /** Normalized 0–1. */
53
+ velocity: number;
54
+ /** Frame within the coming block (0 to block length − 1) at which the change applies. */
55
+ frameOffset: number;
56
+ epoch: number;
57
+ }
58
+ /** What `create` receives. Allocate every buffer, table and voice here. */
59
+ interface ProcessorSetup {
60
+ readonly definition: ResolvedProcessorDefinition;
61
+ readonly sampleRate: number;
62
+ /** The `config` the module was created with, if any. */
63
+ readonly config: unknown;
64
+ /** Post an author-defined observation to the main thread. Not for per-block use. */
65
+ report(data: unknown): void;
66
+ /**
67
+ * The compiled module from `source.wasm`, if any. Instantiate it here with
68
+ * `new WebAssembly.Instance(setup.wasm, imports)`; the instance and its
69
+ * memory belong to this processor.
70
+ */
71
+ readonly wasm?: WebAssembly.Module;
72
+ /**
73
+ * The writer side of this node's shared ring, when the definition requests
74
+ * one and the page can share memory. Absent otherwise: a processor whose
75
+ * ring is optional must work without it. `write` never blocks or allocates.
76
+ */
77
+ readonly ring?: ProcessorRing;
78
+ }
79
+ /**
80
+ * The author's DSP. `process` and `note` run on the audio thread once per
81
+ * render quantum: they must not allocate, create closures or strings, or post
82
+ * messages.
83
+ */
84
+ interface ProcessorImplementation<State> {
85
+ create(setup: ProcessorSetup): State;
86
+ process(state: State, block: ProcessorBlock): void;
87
+ /**
88
+ * Required when the definition declares `noteInput`. Called in time order
89
+ * for every note change in the coming block, before `process`. `cancel`
90
+ * means stop at once, without a release phase.
91
+ */
92
+ note?(state: State, event: ProcessorNoteEvent): void;
93
+ /** Non-real-time configuration posted by the module. */
94
+ message?(state: State, data: unknown): void;
95
+ }
96
+ interface WorkletPort {
97
+ onmessage: ((event: {
98
+ data: unknown;
99
+ }) => void) | null;
100
+ postMessage(message: unknown): void;
101
+ }
102
+ /** The part of `AudioWorkletGlobalScope` the kit uses; injectable for tests. */
103
+ interface ProcessorWorkletScope {
104
+ registerProcessor(name: string, processor: unknown): void;
105
+ AudioWorkletProcessor: new () => {
106
+ readonly port: WorkletPort;
107
+ };
108
+ readonly currentFrame: number;
109
+ readonly sampleRate: number;
110
+ }
111
+ /**
112
+ * Register a processor for `definition` in the current worklet scope. Call it
113
+ * once at the top level of the worklet file, with the same definition object
114
+ * the main thread passes to `prepareProcessor`.
115
+ *
116
+ * If `create`, `note` or `process` throws, the processor reports the error
117
+ * once, goes silent and stops; it does not restart itself.
118
+ *
119
+ * With `noteInput`, the kit keeps a queue of note changes sorted by frame and
120
+ * delivers each one to `note` before the `process` call of its block, with
121
+ * its frame offset. A change that arrives after its frame plays at the start
122
+ * of the next block and is counted (a late `cancel` is not counted: it means
123
+ * stop now); the counts reach the main thread at most
124
+ * four times a second. `cancel` before an onset withdraws that note entirely.
125
+ * When the module's Session invalidates its schedule, the kit withdraws every
126
+ * queued scheduled onset and cancels every sounding scheduled note; live
127
+ * gestures continue. With `transport`, `block.transport` gives the Session
128
+ * position at each block's first frame.
129
+ */
130
+ declare function defineProcessor<State>(definition: ProcessorDefinition | ResolvedProcessorDefinition, implementation: ProcessorImplementation<State>, scope?: ProcessorWorkletScope): void;
131
+
132
+ /** An in-place complex FFT of a fixed power-of-two size. */
133
+ interface FFT {
134
+ readonly size: number;
135
+ /** Transform `real` and `imag` in place, time to frequency. */
136
+ forward(real: Float32Array, imag: Float32Array): void;
137
+ /** Transform in place, frequency to time, scaled by 1/size. */
138
+ inverse(real: Float32Array, imag: Float32Array): void;
139
+ }
140
+ /** Create an FFT of `size` (a power of two from 2 to 65536). */
141
+ declare function createFFT(size: number): FFT;
142
+ /** A periodic Hann window of `size` samples, suited to overlap-add at hop size/2 or size/4. */
143
+ declare function hannWindow(size: number): Float32Array;
144
+ interface SpectralFrameOptions {
145
+ /** FFT size, a power of two. */
146
+ readonly size: number;
147
+ /** Samples between frames: size/2 or size/4 (the default). */
148
+ readonly hop?: number;
149
+ }
150
+ /**
151
+ * Overlap-add spectral processing for one channel: feed blocks of any length;
152
+ * every `hop` samples a Hann-windowed frame is transformed, handed to
153
+ * `onFrame(real, imag)` to change in place, transformed back, windowed again
154
+ * and added to the output. The output lags the input by `size` samples.
155
+ */
156
+ interface SpectralFrame {
157
+ readonly size: number;
158
+ readonly hop: number;
159
+ /** The output's delay behind the input, in samples. */
160
+ readonly latency: number;
161
+ process(input: Float32Array, output: Float32Array, onFrame: (real: Float32Array, imag: Float32Array) => void): void;
162
+ reset(): void;
163
+ }
164
+ declare function createSpectralFrame(options: SpectralFrameOptions): SpectralFrame;
165
+
166
+ export { type FFT, type ProcessorBlock, type ProcessorImplementation, type ProcessorNoteEvent, ProcessorRing, type ProcessorSetup, type ProcessorTransport, type ProcessorWorkletScope, type SpectralFrame, type SpectralFrameOptions, createFFT, createSpectralFrame, defineProcessor, hannWindow };
@@ -0,0 +1,18 @@
1
+ import {
2
+ createFFT,
3
+ createSpectralFrame,
4
+ defineProcessor,
5
+ hannWindow
6
+ } from "./chunk-DDOGX2D5.js";
7
+ import {
8
+ ProcessorRing
9
+ } from "./chunk-OTXYWCLA.js";
10
+ import "./chunk-PXG64RU4.js";
11
+ export {
12
+ ProcessorRing,
13
+ createFFT,
14
+ createSpectralFrame,
15
+ defineProcessor,
16
+ hannWindow
17
+ };
18
+ //# sourceMappingURL=processor-worklet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,51 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+ var _chunkJLVSAZ3Kcjs = require('./chunk-JLVSAZ3K.cjs');
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+ var _chunkRZBLPM3Lcjs = require('./chunk-RZBLPM3L.cjs');
23
+ require('./chunk-OCKAHITL.cjs');
24
+ require('./chunk-K7FYH6UG.cjs');
25
+ require('./chunk-VY6WWZSW.cjs');
26
+ require('./chunk-5AHVQXTF.cjs');
27
+ require('./chunk-I4YMA5VM.cjs');
28
+ require('./chunk-BADJJ6DV.cjs');
29
+ require('./chunk-EXDCK2VL.cjs');
30
+ require('./chunk-7ZTZZ5PN.cjs');
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+
41
+
42
+
43
+
44
+
45
+
46
+
47
+
48
+
49
+
50
+ exports.PROCESSOR_IMMEDIATE_FRAME = _chunkRZBLPM3Lcjs.PROCESSOR_IMMEDIATE_FRAME; exports.PROCESSOR_PROTOCOL_VERSION = _chunkRZBLPM3Lcjs.PROCESSOR_PROTOCOL_VERSION; exports.ProcessorInstrument = _chunkJLVSAZ3Kcjs.ProcessorInstrument; exports.ProcessorModule = _chunkJLVSAZ3Kcjs.ProcessorModule; exports.ProcessorRing = _chunkRZBLPM3Lcjs.ProcessorRing; exports.ProcessorUnavailableError = _chunkJLVSAZ3Kcjs.ProcessorUnavailableError; exports.createProcessorInstrument = _chunkJLVSAZ3Kcjs.createProcessorInstrument; exports.createProcessorModule = _chunkJLVSAZ3Kcjs.createProcessorModule; exports.defaultProcessorNoteTime = _chunkJLVSAZ3Kcjs.defaultProcessorNoteTime; exports.isProcessorPrepared = _chunkJLVSAZ3Kcjs.isProcessorPrepared; exports.prepareProcessor = _chunkJLVSAZ3Kcjs.prepareProcessor; exports.processorAudioParams = _chunkRZBLPM3Lcjs.processorAudioParams; exports.processorCapabilities = _chunkRZBLPM3Lcjs.processorCapabilities; exports.processorEffect = _chunkJLVSAZ3Kcjs.processorEffect; exports.processorName = _chunkRZBLPM3Lcjs.processorName; exports.processorPlugin = _chunkJLVSAZ3Kcjs.processorPlugin; exports.processorSignature = _chunkRZBLPM3Lcjs.processorSignature; exports.resolveProcessorDefinition = _chunkRZBLPM3Lcjs.resolveProcessorDefinition;
51
+ //# sourceMappingURL=processor.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/private/tmp/claude-501/-Users-mamingchen-GitHub-public-WebMusic/77eac0d8-82c0-45c6-aba8-0cd73cfd2b1b/scratchpad/release-0.4.0/platform/kernel/dist/processor.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,qvCAAC","file":"/private/tmp/claude-501/-Users-mamingchen-GitHub-public-WebMusic/77eac0d8-82c0-45c6-aba8-0cd73cfd2b1b/scratchpad/release-0.4.0/platform/kernel/dist/processor.cjs"}