@webmusic/kernel 0.2.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.
- package/LICENSE +202 -21
- package/NOTICE +2 -0
- package/README.md +103 -64
- package/dist/audio-context.cjs.map +1 -1
- package/dist/build-receipt.json +3 -3
- package/dist/chunk-27LH6QLZ.cjs +277 -0
- package/dist/chunk-27LH6QLZ.cjs.map +1 -0
- package/dist/chunk-3INDOVUC.cjs.map +1 -1
- package/dist/chunk-3RR2VIKA.js +393 -0
- package/dist/chunk-3RR2VIKA.js.map +1 -0
- package/dist/chunk-3YTKIKKX.cjs +378 -0
- package/dist/chunk-3YTKIKKX.cjs.map +1 -0
- package/dist/chunk-4RG4WQKC.js +360 -0
- package/dist/chunk-4RG4WQKC.js.map +1 -0
- package/dist/chunk-5AHVQXTF.cjs +620 -0
- package/dist/chunk-5AHVQXTF.cjs.map +1 -0
- package/dist/chunk-624KWJWZ.js +170 -0
- package/dist/chunk-624KWJWZ.js.map +1 -0
- package/dist/chunk-6HGFEKD3.cjs +851 -0
- package/dist/chunk-6HGFEKD3.cjs.map +1 -0
- package/dist/chunk-7ZTZZ5PN.cjs.map +1 -1
- package/dist/chunk-ALWV4P7D.js +726 -0
- package/dist/chunk-ALWV4P7D.js.map +1 -0
- package/dist/chunk-BADJJ6DV.cjs +143 -0
- package/dist/chunk-BADJJ6DV.cjs.map +1 -0
- package/dist/chunk-C3LMS36L.cjs +393 -0
- package/dist/chunk-C3LMS36L.cjs.map +1 -0
- package/dist/chunk-C3YWUZW3.cjs.map +1 -1
- package/dist/chunk-CR6OUWBJ.cjs +726 -0
- package/dist/chunk-CR6OUWBJ.cjs.map +1 -0
- package/dist/chunk-CYWDZLWC.js +2141 -0
- package/dist/chunk-CYWDZLWC.js.map +1 -0
- package/dist/chunk-DDOGX2D5.js +378 -0
- package/dist/chunk-DDOGX2D5.js.map +1 -0
- package/dist/chunk-DVN6E5U3.js +620 -0
- package/dist/chunk-DVN6E5U3.js.map +1 -0
- package/dist/chunk-EURMRU2S.js +208 -0
- package/dist/chunk-EURMRU2S.js.map +1 -0
- package/dist/chunk-EXDCK2VL.cjs +20 -0
- package/dist/chunk-EXDCK2VL.cjs.map +1 -0
- package/dist/chunk-G5EIUP52.js +114 -0
- package/dist/chunk-G5EIUP52.js.map +1 -0
- package/dist/chunk-GB4DGKLZ.js +143 -0
- package/dist/chunk-GB4DGKLZ.js.map +1 -0
- package/dist/chunk-GPOEAYOW.js +2147 -0
- package/dist/chunk-GPOEAYOW.js.map +1 -0
- package/dist/chunk-I4YMA5VM.cjs +120 -0
- package/dist/chunk-I4YMA5VM.cjs.map +1 -0
- package/dist/chunk-IVWHMDCB.cjs +4383 -0
- package/dist/chunk-IVWHMDCB.cjs.map +1 -0
- package/dist/chunk-JFCBJMA7.cjs +2147 -0
- package/dist/chunk-JFCBJMA7.cjs.map +1 -0
- package/dist/chunk-JLVSAZ3K.cjs +813 -0
- package/dist/chunk-JLVSAZ3K.cjs.map +1 -0
- package/dist/chunk-K7FYH6UG.cjs +208 -0
- package/dist/chunk-K7FYH6UG.cjs.map +1 -0
- package/dist/chunk-L4MYCETM.cjs +970 -0
- package/dist/chunk-L4MYCETM.cjs.map +1 -0
- package/dist/chunk-MNCMYNYL.js +970 -0
- package/dist/chunk-MNCMYNYL.js.map +1 -0
- package/dist/chunk-NT2BZ3QM.js +120 -0
- package/dist/chunk-NT2BZ3QM.js.map +1 -0
- package/dist/chunk-O7SA5GLC.js +277 -0
- package/dist/chunk-O7SA5GLC.js.map +1 -0
- package/dist/chunk-OCKAHITL.cjs +548 -0
- package/dist/chunk-OCKAHITL.cjs.map +1 -0
- package/dist/chunk-OTXYWCLA.js +206 -0
- package/dist/chunk-OTXYWCLA.js.map +1 -0
- package/dist/chunk-P6ZA63J7.js +548 -0
- package/dist/chunk-P6ZA63J7.js.map +1 -0
- package/dist/chunk-QLF3BOST.js +20 -0
- package/dist/chunk-QLF3BOST.js.map +1 -0
- package/dist/chunk-RCWFRZDR.js +4383 -0
- package/dist/chunk-RCWFRZDR.js.map +1 -0
- package/dist/chunk-RZBLPM3L.cjs +206 -0
- package/dist/chunk-RZBLPM3L.cjs.map +1 -0
- package/dist/chunk-TA3TNJZU.cjs +360 -0
- package/dist/chunk-TA3TNJZU.cjs.map +1 -0
- package/dist/chunk-TZSRPTQL.cjs +2141 -0
- package/dist/chunk-TZSRPTQL.cjs.map +1 -0
- package/dist/chunk-UMTPJ76S.cjs.map +1 -1
- package/dist/chunk-UY77FXDW.js +813 -0
- package/dist/chunk-UY77FXDW.js.map +1 -0
- package/dist/chunk-VFU3S7OC.js +851 -0
- package/dist/chunk-VFU3S7OC.js.map +1 -0
- package/dist/chunk-VY6WWZSW.cjs.map +1 -1
- package/dist/chunk-WN5DZOVT.cjs +170 -0
- package/dist/chunk-WN5DZOVT.cjs.map +1 -0
- package/dist/chunk-WOPW6WLR.cjs.map +1 -1
- package/dist/chunk-XBSIYUHM.cjs +114 -0
- package/dist/chunk-XBSIYUHM.cjs.map +1 -0
- package/dist/chunk-ZMU72HJS.cjs.map +1 -1
- package/dist/context-DSa0ymyN.d.cts +664 -0
- package/dist/context-DaxfAg3b.d.ts +664 -0
- package/dist/effect-chain-Cu03O5Y0.d.ts +91 -0
- package/dist/effect-chain-Do75T7uK.d.cts +91 -0
- package/dist/effect.cjs +16 -1
- package/dist/effect.cjs.map +1 -1
- package/dist/effect.d.cts +56 -14
- package/dist/effect.d.ts +56 -14
- package/dist/effect.js +16 -1
- package/dist/elements.cjs +37 -2
- package/dist/elements.cjs.map +1 -1
- package/dist/elements.d.cts +197 -8
- package/dist/elements.d.ts +197 -8
- package/dist/elements.js +36 -1
- package/dist/events.cjs.map +1 -1
- package/dist/index.cjs +555 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +16 -4
- package/dist/index.d.ts +16 -4
- package/dist/index.js +566 -19
- package/dist/message.cjs +104 -0
- package/dist/message.cjs.map +1 -0
- package/dist/message.d.cts +738 -0
- package/dist/message.d.ts +738 -0
- package/dist/message.js +104 -0
- package/dist/meter.cjs.map +1 -1
- package/dist/module-control-C25BMtH7.d.ts +61 -0
- package/dist/module-control-yH6nTJM9.d.cts +61 -0
- package/dist/module-plugin-BnPmq1VP.d.ts +198 -0
- package/dist/module-plugin-CHb-5W0Y.d.cts +198 -0
- package/dist/module.cjs +263 -0
- package/dist/module.cjs.map +1 -0
- package/dist/module.d.cts +1112 -0
- package/dist/module.d.ts +1112 -0
- package/dist/module.js +263 -0
- package/dist/parameter-DwQzFmBR.d.cts +172 -0
- package/dist/parameter-DwQzFmBR.d.ts +172 -0
- package/dist/player.cjs.map +1 -1
- package/dist/processor-worklet.cjs +18 -0
- package/dist/processor-worklet.cjs.map +1 -0
- package/dist/processor-worklet.d.cts +166 -0
- package/dist/processor-worklet.d.ts +166 -0
- package/dist/processor-worklet.js +18 -0
- package/dist/processor-worklet.js.map +1 -0
- package/dist/processor.cjs +51 -0
- package/dist/processor.cjs.map +1 -0
- package/dist/processor.d.cts +397 -0
- package/dist/processor.d.ts +397 -0
- package/dist/processor.js +51 -0
- package/dist/processor.js.map +1 -0
- package/dist/project-types-BU4awMnL.d.ts +323 -0
- package/dist/project-types-DufCV8Ma.d.cts +323 -0
- package/dist/ring-C-i9N90a.d.cts +139 -0
- package/dist/ring-DkcMt2Eg.d.ts +139 -0
- package/dist/sequence.cjs +68 -0
- package/dist/sequence.cjs.map +1 -0
- package/dist/sequence.d.cts +303 -0
- package/dist/sequence.d.ts +303 -0
- package/dist/sequence.js +68 -0
- package/dist/sequence.js.map +1 -0
- package/dist/session.cjs +16 -0
- package/dist/session.cjs.map +1 -0
- package/dist/session.d.cts +407 -0
- package/dist/session.d.ts +407 -0
- package/dist/session.js +16 -0
- package/dist/session.js.map +1 -0
- package/dist/tick.cjs.map +1 -1
- package/dist/transport.cjs +50 -2
- package/dist/transport.cjs.map +1 -1
- package/dist/transport.d.cts +145 -1
- package/dist/transport.d.ts +145 -1
- package/dist/transport.js +51 -3
- package/dist/worker.cjs.map +1 -1
- package/package.json +61 -10
- package/dist/chunk-53YD73OY.js +0 -162
- package/dist/chunk-53YD73OY.js.map +0 -1
- package/dist/chunk-54JYWB5X.cjs +0 -1051
- package/dist/chunk-54JYWB5X.cjs.map +0 -1
- package/dist/chunk-BR63OD53.cjs +0 -1
- package/dist/chunk-BR63OD53.cjs.map +0 -1
- package/dist/chunk-ON64FRCF.js +0 -1051
- package/dist/chunk-ON64FRCF.js.map +0 -1
- package/dist/chunk-SM5YPDDI.cjs +0 -162
- package/dist/chunk-SM5YPDDI.cjs.map +0 -1
- package/dist/chunk-TEM2I2NN.js +0 -1
- package/dist/chunk-VVZX7DQ6.cjs +0 -254
- package/dist/chunk-VVZX7DQ6.cjs.map +0 -1
- package/dist/chunk-WNFGDB7B.js +0 -254
- package/dist/chunk-WNFGDB7B.js.map +0 -1
- package/dist/sync.cjs +0 -12
- package/dist/sync.cjs.map +0 -1
- package/dist/sync.d.cts +0 -307
- package/dist/sync.d.ts +0 -307
- package/dist/sync.js +0 -12
- /package/dist/{chunk-TEM2I2NN.js.map → message.js.map} +0 -0
- /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"}
|