@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.
Files changed (188) hide show
  1. package/LICENSE +202 -21
  2. package/NOTICE +2 -0
  3. package/README.md +103 -64
  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-OTXYWCLA.js +206 -0
  68. package/dist/chunk-OTXYWCLA.js.map +1 -0
  69. package/dist/chunk-P6ZA63J7.js +548 -0
  70. package/dist/chunk-P6ZA63J7.js.map +1 -0
  71. package/dist/chunk-QLF3BOST.js +20 -0
  72. package/dist/chunk-QLF3BOST.js.map +1 -0
  73. package/dist/chunk-RCWFRZDR.js +4383 -0
  74. package/dist/chunk-RCWFRZDR.js.map +1 -0
  75. package/dist/chunk-RZBLPM3L.cjs +206 -0
  76. package/dist/chunk-RZBLPM3L.cjs.map +1 -0
  77. package/dist/chunk-TA3TNJZU.cjs +360 -0
  78. package/dist/chunk-TA3TNJZU.cjs.map +1 -0
  79. package/dist/chunk-TZSRPTQL.cjs +2141 -0
  80. package/dist/chunk-TZSRPTQL.cjs.map +1 -0
  81. package/dist/chunk-UMTPJ76S.cjs.map +1 -1
  82. package/dist/chunk-UY77FXDW.js +813 -0
  83. package/dist/chunk-UY77FXDW.js.map +1 -0
  84. package/dist/chunk-VFU3S7OC.js +851 -0
  85. package/dist/chunk-VFU3S7OC.js.map +1 -0
  86. package/dist/chunk-VY6WWZSW.cjs.map +1 -1
  87. package/dist/chunk-WN5DZOVT.cjs +170 -0
  88. package/dist/chunk-WN5DZOVT.cjs.map +1 -0
  89. package/dist/chunk-WOPW6WLR.cjs.map +1 -1
  90. package/dist/chunk-XBSIYUHM.cjs +114 -0
  91. package/dist/chunk-XBSIYUHM.cjs.map +1 -0
  92. package/dist/chunk-ZMU72HJS.cjs.map +1 -1
  93. package/dist/context-DSa0ymyN.d.cts +664 -0
  94. package/dist/context-DaxfAg3b.d.ts +664 -0
  95. package/dist/effect-chain-Cu03O5Y0.d.ts +91 -0
  96. package/dist/effect-chain-Do75T7uK.d.cts +91 -0
  97. package/dist/effect.cjs +16 -1
  98. package/dist/effect.cjs.map +1 -1
  99. package/dist/effect.d.cts +56 -14
  100. package/dist/effect.d.ts +56 -14
  101. package/dist/effect.js +16 -1
  102. package/dist/elements.cjs +37 -2
  103. package/dist/elements.cjs.map +1 -1
  104. package/dist/elements.d.cts +197 -8
  105. package/dist/elements.d.ts +197 -8
  106. package/dist/elements.js +36 -1
  107. package/dist/events.cjs.map +1 -1
  108. package/dist/index.cjs +555 -8
  109. package/dist/index.cjs.map +1 -1
  110. package/dist/index.d.cts +16 -4
  111. package/dist/index.d.ts +16 -4
  112. package/dist/index.js +566 -19
  113. package/dist/message.cjs +104 -0
  114. package/dist/message.cjs.map +1 -0
  115. package/dist/message.d.cts +738 -0
  116. package/dist/message.d.ts +738 -0
  117. package/dist/message.js +104 -0
  118. package/dist/meter.cjs.map +1 -1
  119. package/dist/module-control-C25BMtH7.d.ts +61 -0
  120. package/dist/module-control-yH6nTJM9.d.cts +61 -0
  121. package/dist/module-plugin-BnPmq1VP.d.ts +198 -0
  122. package/dist/module-plugin-CHb-5W0Y.d.cts +198 -0
  123. package/dist/module.cjs +263 -0
  124. package/dist/module.cjs.map +1 -0
  125. package/dist/module.d.cts +1112 -0
  126. package/dist/module.d.ts +1112 -0
  127. package/dist/module.js +263 -0
  128. package/dist/parameter-DwQzFmBR.d.cts +172 -0
  129. package/dist/parameter-DwQzFmBR.d.ts +172 -0
  130. package/dist/player.cjs.map +1 -1
  131. package/dist/processor-worklet.cjs +18 -0
  132. package/dist/processor-worklet.cjs.map +1 -0
  133. package/dist/processor-worklet.d.cts +166 -0
  134. package/dist/processor-worklet.d.ts +166 -0
  135. package/dist/processor-worklet.js +18 -0
  136. package/dist/processor-worklet.js.map +1 -0
  137. package/dist/processor.cjs +51 -0
  138. package/dist/processor.cjs.map +1 -0
  139. package/dist/processor.d.cts +397 -0
  140. package/dist/processor.d.ts +397 -0
  141. package/dist/processor.js +51 -0
  142. package/dist/processor.js.map +1 -0
  143. package/dist/project-types-BU4awMnL.d.ts +323 -0
  144. package/dist/project-types-DufCV8Ma.d.cts +323 -0
  145. package/dist/ring-C-i9N90a.d.cts +139 -0
  146. package/dist/ring-DkcMt2Eg.d.ts +139 -0
  147. package/dist/sequence.cjs +68 -0
  148. package/dist/sequence.cjs.map +1 -0
  149. package/dist/sequence.d.cts +303 -0
  150. package/dist/sequence.d.ts +303 -0
  151. package/dist/sequence.js +68 -0
  152. package/dist/sequence.js.map +1 -0
  153. package/dist/session.cjs +16 -0
  154. package/dist/session.cjs.map +1 -0
  155. package/dist/session.d.cts +407 -0
  156. package/dist/session.d.ts +407 -0
  157. package/dist/session.js +16 -0
  158. package/dist/session.js.map +1 -0
  159. package/dist/tick.cjs.map +1 -1
  160. package/dist/transport.cjs +50 -2
  161. package/dist/transport.cjs.map +1 -1
  162. package/dist/transport.d.cts +145 -1
  163. package/dist/transport.d.ts +145 -1
  164. package/dist/transport.js +51 -3
  165. package/dist/worker.cjs.map +1 -1
  166. package/package.json +61 -10
  167. package/dist/chunk-53YD73OY.js +0 -162
  168. package/dist/chunk-53YD73OY.js.map +0 -1
  169. package/dist/chunk-54JYWB5X.cjs +0 -1051
  170. package/dist/chunk-54JYWB5X.cjs.map +0 -1
  171. package/dist/chunk-BR63OD53.cjs +0 -1
  172. package/dist/chunk-BR63OD53.cjs.map +0 -1
  173. package/dist/chunk-ON64FRCF.js +0 -1051
  174. package/dist/chunk-ON64FRCF.js.map +0 -1
  175. package/dist/chunk-SM5YPDDI.cjs +0 -162
  176. package/dist/chunk-SM5YPDDI.cjs.map +0 -1
  177. package/dist/chunk-TEM2I2NN.js +0 -1
  178. package/dist/chunk-VVZX7DQ6.cjs +0 -254
  179. package/dist/chunk-VVZX7DQ6.cjs.map +0 -1
  180. package/dist/chunk-WNFGDB7B.js +0 -254
  181. package/dist/chunk-WNFGDB7B.js.map +0 -1
  182. package/dist/sync.cjs +0 -12
  183. package/dist/sync.cjs.map +0 -1
  184. package/dist/sync.d.cts +0 -307
  185. package/dist/sync.d.ts +0 -307
  186. package/dist/sync.js +0 -12
  187. /package/dist/{chunk-TEM2I2NN.js.map → message.js.map} +0 -0
  188. /package/dist/{sync.js.map → module.js.map} +0 -0
@@ -0,0 +1,139 @@
1
+ import { c as ParamDescriptor } from './parameter-DwQzFmBR.cjs';
2
+
3
+ /** One audio bus of a processor. Channel count is fixed for the node's life. */
4
+ interface ProcessorAudioPort {
5
+ readonly id: string;
6
+ readonly channels: number;
7
+ }
8
+ /**
9
+ * Serializable description of one authored DSP processor. The same object is
10
+ * passed to `prepareProcessor` on the main thread and to `defineProcessor` in
11
+ * the worklet file, so both sides agree on ports and parameters.
12
+ */
13
+ interface ProcessorDefinition {
14
+ /** With `version`, the processor's identity; a project stores this pair. */
15
+ readonly id: string;
16
+ readonly version: string;
17
+ /** Default: none, which makes an instrument or generator. */
18
+ readonly audioInputs?: readonly ProcessorAudioPort[];
19
+ /** Default: one stereo output named `output`. At least one is required. */
20
+ readonly audioOutputs?: readonly ProcessorAudioPort[];
21
+ /** Accept queued note events. Default false. */
22
+ readonly noteInput?: boolean;
23
+ /** Receive the Session anchor on the audio thread. Default false. */
24
+ readonly transport?: boolean;
25
+ /**
26
+ * Every parameter is an `AudioParam` of the node. `modulation: 'audio-rate'`
27
+ * makes it a-rate (one value per frame); anything else makes it k-rate (one
28
+ * value per block).
29
+ */
30
+ readonly params?: readonly ParamDescriptor[];
31
+ /** Declared processing latency in samples; never a measured device latency. Default 0. */
32
+ readonly latencySamples?: number;
33
+ /** How long output continues after input and notes end. Default 0; `Infinity` never idles. */
34
+ readonly tailSeconds?: number;
35
+ /**
36
+ * The processor needs a compiled WebAssembly module: preparation then
37
+ * requires `source.wasm`, and `create` receives the module as `setup.wasm`.
38
+ * Default false.
39
+ */
40
+ readonly wasm?: boolean;
41
+ /**
42
+ * A shared ring the processor writes and the main thread reads, for
43
+ * high-rate observation such as a scope or a sample stream. It exists only
44
+ * where `processorCapabilities().sharedMemory` is true; with `required`,
45
+ * preparation fails elsewhere instead of running without it.
46
+ */
47
+ readonly sharedRing?: ProcessorSharedRingRequest;
48
+ }
49
+ /** A processor's request for a shared ring. */
50
+ interface ProcessorSharedRingRequest {
51
+ /** Ring size in `float32` samples: an integer from 128 to 16,777,216. */
52
+ readonly capacity: number;
53
+ /** Fail preparation without cross-origin isolation. Default false: the processor runs without the ring. */
54
+ readonly required?: boolean;
55
+ }
56
+ /** A validated definition with every default applied. Deeply frozen. */
57
+ interface ResolvedProcessorDefinition {
58
+ readonly id: string;
59
+ readonly version: string;
60
+ /** The `registerProcessor` name: `id@version`. */
61
+ readonly name: string;
62
+ readonly audioInputs: readonly ProcessorAudioPort[];
63
+ readonly audioOutputs: readonly ProcessorAudioPort[];
64
+ readonly noteInput: boolean;
65
+ readonly transport: boolean;
66
+ readonly params: readonly ParamDescriptor[];
67
+ readonly latencySamples: number;
68
+ readonly tailSeconds: number;
69
+ readonly wasm: boolean;
70
+ readonly sharedRing: Readonly<{
71
+ capacity: number;
72
+ required: boolean;
73
+ }> | null;
74
+ }
75
+ /** The `AudioParamDescriptor` shape, declared here because worklet globals have no DOM types. */
76
+ interface ProcessorAudioParamDescriptor {
77
+ readonly name: string;
78
+ readonly defaultValue: number;
79
+ readonly minValue: number;
80
+ readonly maxValue: number;
81
+ readonly automationRate: 'a-rate' | 'k-rate';
82
+ }
83
+ /** The `registerProcessor` name of a definition: `id@version`. */
84
+ declare function processorName(definition: Pick<ProcessorDefinition, 'id' | 'version'>): string;
85
+ /**
86
+ * Validate a definition and apply its defaults. Throws before any resource is
87
+ * acquired; resolving an already resolved definition returns it unchanged.
88
+ */
89
+ declare function resolveProcessorDefinition(definition: ProcessorDefinition | ResolvedProcessorDefinition): ResolvedProcessorDefinition;
90
+ /** The node's `AudioParam` declarations, in definition order. */
91
+ declare function processorAudioParams(definition: ProcessorDefinition | ResolvedProcessorDefinition): readonly ProcessorAudioParamDescriptor[];
92
+ /**
93
+ * A stable text form of everything two registrations of one name must agree
94
+ * on. Two definitions with the same `id@version` and different signatures are
95
+ * a conflict, not an update.
96
+ */
97
+ declare function processorSignature(definition: ProcessorDefinition | ResolvedProcessorDefinition): string;
98
+
99
+ /** Where shared memory and the other optional processor features are available. */
100
+ interface ProcessorCapabilities {
101
+ /** `AudioWorkletNode` exists, so processors can run at all. */
102
+ readonly audioWorklet: boolean;
103
+ /** `WebAssembly` exists, so `source.wasm` can be compiled. */
104
+ readonly wasm: boolean;
105
+ /**
106
+ * The page is cross-origin isolated and has `SharedArrayBuffer` and
107
+ * `Atomics`, so a definition's `sharedRing` is provided. Pages served
108
+ * without COOP/COEP headers (GitHub Pages, for one) report false.
109
+ */
110
+ readonly sharedMemory: boolean;
111
+ }
112
+ /** What this environment offers processors. Reading it allocates nothing. */
113
+ declare function processorCapabilities(): ProcessorCapabilities;
114
+ /**
115
+ * A lock-free ring of `float32` samples in one `SharedArrayBuffer`. Exactly
116
+ * one side writes and one side reads. Writing never blocks or allocates: what
117
+ * does not fit is dropped and counted. One slot stays empty, so a ring of
118
+ * capacity `n` holds at most `n − 1` samples.
119
+ */
120
+ declare class ProcessorRing {
121
+ #private;
122
+ /** The shared memory, to hand to the other thread. */
123
+ readonly buffer: SharedArrayBuffer;
124
+ readonly capacity: number;
125
+ /** Allocate a ring. Throws where `SharedArrayBuffer` is unavailable. */
126
+ static create(capacity: number): ProcessorRing;
127
+ /** Attach to a ring another thread created. */
128
+ constructor(buffer: SharedArrayBuffer);
129
+ /** Samples waiting to be read. */
130
+ get available(): number;
131
+ /** Samples the writer has dropped because the ring was full, since creation. */
132
+ get dropped(): number;
133
+ /** Writer side: append `length` samples from `source[start…]`; returns how many fit. Allocates nothing. */
134
+ write(source: ArrayLike<number>, start?: number, length?: number): number;
135
+ /** Reader side: move up to `target.length` samples into `target`; returns how many. */
136
+ read(target: Float32Array): number;
137
+ }
138
+
139
+ export { type ProcessorAudioParamDescriptor as P, type ResolvedProcessorDefinition as R, type ProcessorAudioPort as a, type ProcessorCapabilities as b, type ProcessorDefinition as c, ProcessorRing as d, type ProcessorSharedRingRequest as e, processorCapabilities as f, processorName as g, processorSignature as h, processorAudioParams as p, resolveProcessorDefinition as r };
@@ -0,0 +1,139 @@
1
+ import { c as ParamDescriptor } from './parameter-DwQzFmBR.js';
2
+
3
+ /** One audio bus of a processor. Channel count is fixed for the node's life. */
4
+ interface ProcessorAudioPort {
5
+ readonly id: string;
6
+ readonly channels: number;
7
+ }
8
+ /**
9
+ * Serializable description of one authored DSP processor. The same object is
10
+ * passed to `prepareProcessor` on the main thread and to `defineProcessor` in
11
+ * the worklet file, so both sides agree on ports and parameters.
12
+ */
13
+ interface ProcessorDefinition {
14
+ /** With `version`, the processor's identity; a project stores this pair. */
15
+ readonly id: string;
16
+ readonly version: string;
17
+ /** Default: none, which makes an instrument or generator. */
18
+ readonly audioInputs?: readonly ProcessorAudioPort[];
19
+ /** Default: one stereo output named `output`. At least one is required. */
20
+ readonly audioOutputs?: readonly ProcessorAudioPort[];
21
+ /** Accept queued note events. Default false. */
22
+ readonly noteInput?: boolean;
23
+ /** Receive the Session anchor on the audio thread. Default false. */
24
+ readonly transport?: boolean;
25
+ /**
26
+ * Every parameter is an `AudioParam` of the node. `modulation: 'audio-rate'`
27
+ * makes it a-rate (one value per frame); anything else makes it k-rate (one
28
+ * value per block).
29
+ */
30
+ readonly params?: readonly ParamDescriptor[];
31
+ /** Declared processing latency in samples; never a measured device latency. Default 0. */
32
+ readonly latencySamples?: number;
33
+ /** How long output continues after input and notes end. Default 0; `Infinity` never idles. */
34
+ readonly tailSeconds?: number;
35
+ /**
36
+ * The processor needs a compiled WebAssembly module: preparation then
37
+ * requires `source.wasm`, and `create` receives the module as `setup.wasm`.
38
+ * Default false.
39
+ */
40
+ readonly wasm?: boolean;
41
+ /**
42
+ * A shared ring the processor writes and the main thread reads, for
43
+ * high-rate observation such as a scope or a sample stream. It exists only
44
+ * where `processorCapabilities().sharedMemory` is true; with `required`,
45
+ * preparation fails elsewhere instead of running without it.
46
+ */
47
+ readonly sharedRing?: ProcessorSharedRingRequest;
48
+ }
49
+ /** A processor's request for a shared ring. */
50
+ interface ProcessorSharedRingRequest {
51
+ /** Ring size in `float32` samples: an integer from 128 to 16,777,216. */
52
+ readonly capacity: number;
53
+ /** Fail preparation without cross-origin isolation. Default false: the processor runs without the ring. */
54
+ readonly required?: boolean;
55
+ }
56
+ /** A validated definition with every default applied. Deeply frozen. */
57
+ interface ResolvedProcessorDefinition {
58
+ readonly id: string;
59
+ readonly version: string;
60
+ /** The `registerProcessor` name: `id@version`. */
61
+ readonly name: string;
62
+ readonly audioInputs: readonly ProcessorAudioPort[];
63
+ readonly audioOutputs: readonly ProcessorAudioPort[];
64
+ readonly noteInput: boolean;
65
+ readonly transport: boolean;
66
+ readonly params: readonly ParamDescriptor[];
67
+ readonly latencySamples: number;
68
+ readonly tailSeconds: number;
69
+ readonly wasm: boolean;
70
+ readonly sharedRing: Readonly<{
71
+ capacity: number;
72
+ required: boolean;
73
+ }> | null;
74
+ }
75
+ /** The `AudioParamDescriptor` shape, declared here because worklet globals have no DOM types. */
76
+ interface ProcessorAudioParamDescriptor {
77
+ readonly name: string;
78
+ readonly defaultValue: number;
79
+ readonly minValue: number;
80
+ readonly maxValue: number;
81
+ readonly automationRate: 'a-rate' | 'k-rate';
82
+ }
83
+ /** The `registerProcessor` name of a definition: `id@version`. */
84
+ declare function processorName(definition: Pick<ProcessorDefinition, 'id' | 'version'>): string;
85
+ /**
86
+ * Validate a definition and apply its defaults. Throws before any resource is
87
+ * acquired; resolving an already resolved definition returns it unchanged.
88
+ */
89
+ declare function resolveProcessorDefinition(definition: ProcessorDefinition | ResolvedProcessorDefinition): ResolvedProcessorDefinition;
90
+ /** The node's `AudioParam` declarations, in definition order. */
91
+ declare function processorAudioParams(definition: ProcessorDefinition | ResolvedProcessorDefinition): readonly ProcessorAudioParamDescriptor[];
92
+ /**
93
+ * A stable text form of everything two registrations of one name must agree
94
+ * on. Two definitions with the same `id@version` and different signatures are
95
+ * a conflict, not an update.
96
+ */
97
+ declare function processorSignature(definition: ProcessorDefinition | ResolvedProcessorDefinition): string;
98
+
99
+ /** Where shared memory and the other optional processor features are available. */
100
+ interface ProcessorCapabilities {
101
+ /** `AudioWorkletNode` exists, so processors can run at all. */
102
+ readonly audioWorklet: boolean;
103
+ /** `WebAssembly` exists, so `source.wasm` can be compiled. */
104
+ readonly wasm: boolean;
105
+ /**
106
+ * The page is cross-origin isolated and has `SharedArrayBuffer` and
107
+ * `Atomics`, so a definition's `sharedRing` is provided. Pages served
108
+ * without COOP/COEP headers (GitHub Pages, for one) report false.
109
+ */
110
+ readonly sharedMemory: boolean;
111
+ }
112
+ /** What this environment offers processors. Reading it allocates nothing. */
113
+ declare function processorCapabilities(): ProcessorCapabilities;
114
+ /**
115
+ * A lock-free ring of `float32` samples in one `SharedArrayBuffer`. Exactly
116
+ * one side writes and one side reads. Writing never blocks or allocates: what
117
+ * does not fit is dropped and counted. One slot stays empty, so a ring of
118
+ * capacity `n` holds at most `n − 1` samples.
119
+ */
120
+ declare class ProcessorRing {
121
+ #private;
122
+ /** The shared memory, to hand to the other thread. */
123
+ readonly buffer: SharedArrayBuffer;
124
+ readonly capacity: number;
125
+ /** Allocate a ring. Throws where `SharedArrayBuffer` is unavailable. */
126
+ static create(capacity: number): ProcessorRing;
127
+ /** Attach to a ring another thread created. */
128
+ constructor(buffer: SharedArrayBuffer);
129
+ /** Samples waiting to be read. */
130
+ get available(): number;
131
+ /** Samples the writer has dropped because the ring was full, since creation. */
132
+ get dropped(): number;
133
+ /** Writer side: append `length` samples from `source[start…]`; returns how many fit. Allocates nothing. */
134
+ write(source: ArrayLike<number>, start?: number, length?: number): number;
135
+ /** Reader side: move up to `target.length` samples into `target`; returns how many. */
136
+ read(target: Float32Array): number;
137
+ }
138
+
139
+ export { type ProcessorAudioParamDescriptor as P, type ResolvedProcessorDefinition as R, type ProcessorAudioPort as a, type ProcessorCapabilities as b, type ProcessorDefinition as c, ProcessorRing as d, type ProcessorSharedRingRequest as e, processorCapabilities as f, processorName as g, processorSignature as h, processorAudioParams as p, resolveProcessorDefinition as r };
@@ -0,0 +1,68 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+ var _chunk6HGFEKD3cjs = require('./chunk-6HGFEKD3.cjs');
31
+ require('./chunk-K7FYH6UG.cjs');
32
+ require('./chunk-CR6OUWBJ.cjs');
33
+ require('./chunk-I4YMA5VM.cjs');
34
+ require('./chunk-TA3TNJZU.cjs');
35
+ require('./chunk-BADJJ6DV.cjs');
36
+ require('./chunk-EXDCK2VL.cjs');
37
+ require('./chunk-7ZTZZ5PN.cjs');
38
+
39
+
40
+
41
+
42
+
43
+
44
+
45
+
46
+
47
+
48
+
49
+
50
+
51
+
52
+
53
+
54
+
55
+
56
+
57
+
58
+
59
+
60
+
61
+
62
+
63
+
64
+
65
+
66
+
67
+ exports.SEQUENCE_DOCUMENT = _chunk6HGFEKD3cjs.SEQUENCE_DOCUMENT; exports.SEQUENCE_SCHEMA = _chunk6HGFEKD3cjs.SEQUENCE_SCHEMA; exports.SEQUENCE_VERSION = _chunk6HGFEKD3cjs.SEQUENCE_VERSION; exports.SequenceDocument = _chunk6HGFEKD3cjs.SequenceDocument; exports.SequencePlayer = _chunk6HGFEKD3cjs.SequencePlayer; exports.Sequencer = _chunk6HGFEKD3cjs.Sequencer; exports.addTrack = _chunk6HGFEKD3cjs.addTrack; exports.createMessageSink = _chunk6HGFEKD3cjs.createMessageSink; exports.createNoteSink = _chunk6HGFEKD3cjs.createNoteSink; exports.createSequence = _chunk6HGFEKD3cjs.createSequence; exports.eventIndexAt = _chunk6HGFEKD3cjs.eventIndexAt; exports.eventsBetween = _chunk6HGFEKD3cjs.eventsBetween; exports.insertEvents = _chunk6HGFEKD3cjs.insertEvents; exports.parseSequence = _chunk6HGFEKD3cjs.parseSequence; exports.quantizeEvents = _chunk6HGFEKD3cjs.quantizeEvents; exports.removeEvents = _chunk6HGFEKD3cjs.removeEvents; exports.removeTrack = _chunk6HGFEKD3cjs.removeTrack; exports.sequenceDocumentOf = _chunk6HGFEKD3cjs.sequenceDocumentOf; exports.sequenceEnd = _chunk6HGFEKD3cjs.sequenceEnd; exports.sequenceNote = _chunk6HGFEKD3cjs.sequenceNote; exports.sequenceSeconds = _chunk6HGFEKD3cjs.sequenceSeconds; exports.sequenceTime = _chunk6HGFEKD3cjs.sequenceTime; exports.sequencerPlugin = _chunk6HGFEKD3cjs.sequencerPlugin; exports.setSequenceLength = _chunk6HGFEKD3cjs.setSequenceLength; exports.shiftEvents = _chunk6HGFEKD3cjs.shiftEvents; exports.sliceSequence = _chunk6HGFEKD3cjs.sliceSequence; exports.updateEvents = _chunk6HGFEKD3cjs.updateEvents; exports.updateTrack = _chunk6HGFEKD3cjs.updateTrack;
68
+ //# sourceMappingURL=sequence.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/sequence.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,+kDAAC","file":"/private/tmp/claude-501/-Users-mamingchen-GitHub-public-WebMusic/77eac0d8-82c0-45c6-aba8-0cd73cfd2b1b/scratchpad/release-0.4.0/platform/kernel/dist/sequence.cjs"}
@@ -0,0 +1,303 @@
1
+ import { J as JsonValue, I as NoteOutputPort, j as Message, C as CapabilityKey, l as MessageInputPort, n as MessageOutputPort, t as ModuleCapabilities, w as ModuleHandle } from './context-DSa0ymyN.cjs';
2
+ import { MusicalTempo } from './transport.cjs';
3
+ import { x as ProjectPluginFactory } from './project-types-DufCV8Ma.cjs';
4
+ import { G as GraphModule, a as GraphModuleOptions, d as ModuleOptionsJson, c as ModuleEnvironment } from './module-plugin-CHb-5W0Y.cjs';
5
+ import './tick.cjs';
6
+ import './session.cjs';
7
+ import './parameter-DwQzFmBR.cjs';
8
+ import './effect-chain-Do75T7uK.cjs';
9
+
10
+ declare const SEQUENCE_SCHEMA = "webmusic.sequence";
11
+ declare const SEQUENCE_VERSION = 1;
12
+ /** The axis event times are written on: musical ticks (480 per quarter note) or seconds. */
13
+ type SequenceUnit = 'ticks' | 'seconds';
14
+ interface SequenceEvent {
15
+ /** Unique within its track. */
16
+ readonly id: string;
17
+ /** Start, on the sequence's axis; finite and not negative. */
18
+ readonly time: number;
19
+ /** Length on the same axis; omitted for an instant. */
20
+ readonly duration?: number;
21
+ /** What the event carries. The track's `kind` says how to read it. */
22
+ readonly value: JsonValue;
23
+ }
24
+ interface SequenceTrack {
25
+ /** Unique within its sequence. */
26
+ readonly id: string;
27
+ /**
28
+ * How the events' values are read. `note` and `message` are understood by
29
+ * the Kernel's sinks; any other kind is the application's own.
30
+ */
31
+ readonly kind: string;
32
+ readonly label?: string;
33
+ /** A muted track is kept and edited but not played. */
34
+ readonly muted?: boolean;
35
+ /** Ordered by time, then by ID. */
36
+ readonly events: readonly SequenceEvent[];
37
+ }
38
+ interface Sequence {
39
+ readonly schema: typeof SEQUENCE_SCHEMA;
40
+ readonly version: typeof SEQUENCE_VERSION;
41
+ readonly unit: SequenceUnit;
42
+ /** Where the sequence ends and a loop wraps; the end of its last event when omitted. */
43
+ readonly length?: number;
44
+ readonly tracks: readonly SequenceTrack[];
45
+ }
46
+ /** A note track's value: a MIDI pitch and a velocity from 0 to 1. A bare number is a pitch. */
47
+ interface SequenceNote {
48
+ readonly pitch: number;
49
+ readonly velocity?: number;
50
+ }
51
+ /** An event before it has an ID; {@link insertEvents} gives it one. */
52
+ type SequenceEventInit = Omit<SequenceEvent, 'id'> & {
53
+ readonly id?: string;
54
+ };
55
+ type SequenceTrackInit = Omit<SequenceTrack, 'events'> & {
56
+ readonly events?: readonly SequenceEventInit[];
57
+ };
58
+ interface SequenceInit {
59
+ readonly unit?: SequenceUnit;
60
+ readonly length?: number;
61
+ readonly tracks?: readonly SequenceTrackInit[];
62
+ }
63
+ /**
64
+ * Read a sequence from untrusted JSON: validate it, order its events and
65
+ * freeze the result. Throws a readable TypeError, RangeError or Error and
66
+ * never returns a partly valid sequence.
67
+ */
68
+ declare function parseSequence(input: unknown): Sequence;
69
+ /** A new sequence, in ticks unless `unit` says seconds. */
70
+ declare function createSequence(init?: SequenceInit): Sequence;
71
+ /** Add a track at `index`, or at the end. */
72
+ declare function addTrack(sequence: Sequence, init: SequenceTrackInit, index?: number): Sequence;
73
+ declare function removeTrack(sequence: Sequence, trackId: string): Sequence;
74
+ /** Change a track's label, kind or muted state; its ID and events stay. */
75
+ declare function updateTrack(sequence: Sequence, trackId: string, change: Partial<Pick<SequenceTrack, 'kind' | 'label' | 'muted'>>): Sequence;
76
+ /** Add events to a track. An event without an ID is given the next free `e<n>`. */
77
+ declare function insertEvents(sequence: Sequence, trackId: string, events: readonly SequenceEventInit[]): Sequence;
78
+ /** Remove the named events; IDs the track does not hold are ignored. */
79
+ declare function removeEvents(sequence: Sequence, trackId: string, ids: Iterable<string>): Sequence;
80
+ /** Rewrite the named events (every event when `ids` is omitted); the ID of each is kept. */
81
+ declare function updateEvents(sequence: Sequence, trackId: string, ids: Iterable<string> | undefined, change: Partial<Omit<SequenceEvent, 'id'>> | ((event: SequenceEvent) => Partial<Omit<SequenceEvent, 'id'>>)): Sequence;
82
+ /** Move the named events by `delta`; an event never starts before 0. */
83
+ declare function shiftEvents(sequence: Sequence, trackId: string, ids: Iterable<string> | undefined, delta: number): Sequence;
84
+ interface QuantizeOptions {
85
+ /** How far each start moves toward the grid, 0 to 1. Default 1. */
86
+ readonly strength?: number;
87
+ /** Also round durations to the grid, never below one grid step. Default false. */
88
+ readonly durations?: boolean;
89
+ }
90
+ /** Move the named events' starts toward the nearest multiple of `grid`. */
91
+ declare function quantizeEvents(sequence: Sequence, trackId: string, ids: Iterable<string> | undefined, grid: number, options?: QuantizeOptions): Sequence;
92
+ /** Set where the sequence ends, or let it end with its last event again. */
93
+ declare function setSequenceLength(sequence: Sequence, length: number | undefined): Sequence;
94
+ /** Where a sequence ends: its `length`, or the end of its last event. */
95
+ declare function sequenceEnd(sequence: Sequence): number;
96
+ /** Index of the first event at or after `time` (after it, when `inclusive` is false). */
97
+ declare function eventIndexAt(events: readonly SequenceEvent[], time: number, inclusive?: boolean): number;
98
+ /** The events of a track that start in `[start, end)`. */
99
+ declare function eventsBetween(track: SequenceTrack, start: number, end: number): readonly SequenceEvent[];
100
+ /**
101
+ * The part of a sequence in `[start, end)` as a sequence of its own: events
102
+ * that start there, moved to begin at 0, with durations cut at the end.
103
+ */
104
+ declare function sliceSequence(sequence: Sequence, start: number, end: number): Sequence;
105
+ /** A span of the sequence's axis in seconds; ticks follow `tempo`. */
106
+ declare function sequenceSeconds(sequence: Pick<Sequence, 'unit'>, time: number, tempo: MusicalTempo): number;
107
+ /** Seconds as a span of the sequence's axis; ticks follow `tempo`. */
108
+ declare function sequenceTime(sequence: Pick<Sequence, 'unit'>, seconds: number, tempo: MusicalTempo): number;
109
+ /** Read a note track's value: `{pitch, velocity}` or a bare pitch. Undefined when it is neither. */
110
+ declare function sequenceNote(value: JsonValue): SequenceNote | undefined;
111
+
112
+ interface SequenceDocumentSnapshot {
113
+ readonly sequence: Sequence;
114
+ /** Rises by one with every commit, undo and redo. */
115
+ readonly revision: number;
116
+ readonly canUndo: boolean;
117
+ readonly canRedo: boolean;
118
+ }
119
+ interface SequenceDocumentOptions {
120
+ /** How many earlier sequences undo can return to. 0 keeps no history. Default 100. */
121
+ readonly historyLimit?: number;
122
+ /** Receives a listener's failure; a failing listener never stops a commit. */
123
+ readonly onListenerError?: (error: unknown) => void;
124
+ }
125
+ declare class SequenceDocument {
126
+ #private;
127
+ /** `initial` is validated as untrusted JSON; an empty sequence in ticks when omitted. */
128
+ constructor(initial?: unknown, options?: SequenceDocumentOptions);
129
+ get disposed(): boolean;
130
+ /** The committed state; the same object until the next change. */
131
+ get snapshot(): SequenceDocumentSnapshot;
132
+ /**
133
+ * Replace the sequence with `next`, or with what `next` makes of the
134
+ * current one. The result is validated before anything changes; a change
135
+ * that throws leaves the document as it was. Returning the current
136
+ * sequence commits nothing. Returns the revision now current.
137
+ */
138
+ commit(next: Sequence | ((current: Sequence) => Sequence)): number;
139
+ /** Return to the sequence before the last commit. False when there is none. */
140
+ undo(): boolean;
141
+ /** Reapply the commit last undone. False when there is none. */
142
+ redo(): boolean;
143
+ /** Called after every change, with the new state already readable from `snapshot`. */
144
+ subscribe(listener: () => void): () => void;
145
+ /** Drop history and listeners. The last snapshot stays readable; changes throw. */
146
+ dispose(): void;
147
+ }
148
+
149
+ /** What the player reads time from. A Kernel `MusicalTimeSource` is one. */
150
+ interface SequenceTimeSource {
151
+ tempo(): MusicalTempo;
152
+ playing(): boolean;
153
+ /** Transport position in seconds. */
154
+ position(): number;
155
+ /** Clock time at which the transport reaches `position`; undefined while it is not playing. */
156
+ timeAt(position: number): number | undefined;
157
+ /** Notified after play, pause, seek, a loop jump and a tempo change. */
158
+ subscribe(listener: () => void): () => void;
159
+ }
160
+ /** What the player schedules on. A Kernel `MessageClock` is one. */
161
+ interface SequenceClock {
162
+ now(): number;
163
+ schedule(time: number, callback: (time: number) => void): () => void;
164
+ }
165
+ interface SequencePlayedEvent {
166
+ readonly track: SequenceTrack;
167
+ readonly event: SequenceEvent;
168
+ /** Clock time the event starts at: slightly ahead of `clock.now()`, or just behind it when the event is late. */
169
+ readonly time: number;
170
+ /** The event's duration in clock seconds, at the transport's current tempo and rate. */
171
+ readonly duration?: number;
172
+ /** How many times the sequence had looped before this event; 0 on the first pass. */
173
+ readonly pass: number;
174
+ }
175
+ interface SequenceSink {
176
+ event(played: SequencePlayedEvent): void;
177
+ /**
178
+ * The timeline broke at clock time `time` (pause, seek, loop jump, tempo
179
+ * change, stop): release what is sounding and drop what was scheduled.
180
+ */
181
+ invalidate?(time: number): void;
182
+ }
183
+ interface SequencePlayerOptions {
184
+ /** The sequence to play now; read again whenever the player schedules. */
185
+ read(): Sequence;
186
+ time: SequenceTimeSource;
187
+ clock: SequenceClock;
188
+ /** Sinks by track kind. `'*'` receives the kinds that have no sink of their own. */
189
+ sinks: Readonly<Record<string, SequenceSink>>;
190
+ /** Repeat from the start when the sequence ends. Default false. */
191
+ loop?: boolean;
192
+ /** Transport position, in seconds, at which the sequence begins. Default 0. */
193
+ offset?: number;
194
+ /** Called once when a sequence that does not loop reaches its end, with the clock time. */
195
+ onEnd?(time: number): void;
196
+ /** Receives a sink's or callback's failure; playback continues. */
197
+ onError?(error: unknown): void;
198
+ /**
199
+ * After the timeline breaks, events that started up to this many seconds
200
+ * before the new position still play, at once. Default 0.02.
201
+ */
202
+ catchUp?: number;
203
+ }
204
+ declare class SequencePlayer {
205
+ #private;
206
+ constructor(options: SequencePlayerOptions);
207
+ get running(): boolean;
208
+ get disposed(): boolean;
209
+ get loop(): boolean;
210
+ set loop(value: boolean);
211
+ get offset(): number;
212
+ set offset(value: number);
213
+ /** Follow the transport: events play while it plays. Starting twice changes nothing. */
214
+ start(): void;
215
+ /** Stop following the transport and release what the sinks hold. */
216
+ stop(): void;
217
+ /** The sequence changed: schedule again from what `read()` returns now. Sounding events finish. */
218
+ refresh(): void;
219
+ dispose(): void;
220
+ }
221
+ interface NoteSinkOptions {
222
+ /** The port the notes leave from; borrowed. */
223
+ port: NoteOutputPort;
224
+ clock: SequenceClock;
225
+ /** The `sourceId` of every note. Defaults to the port's ID. */
226
+ sourceId?: string;
227
+ /** Scheduling generation at attack; defaults to 0 without a Session. */
228
+ epoch?(): number;
229
+ /** Seconds a note without a duration sounds. Default 0.1. */
230
+ defaultDuration?: number;
231
+ /** Velocity of a note that names none, 0 to 1. Default 0.8. */
232
+ defaultVelocity?: number;
233
+ }
234
+ /**
235
+ * A sink for `note` tracks: each event becomes a note on the port at its
236
+ * time and is released after its duration. Invalidating releases every note
237
+ * this sink still holds; it never touches another producer's notes.
238
+ */
239
+ declare function createNoteSink(options: NoteSinkOptions): SequenceSink & {
240
+ dispose(): void;
241
+ };
242
+ /**
243
+ * A sink for `message` tracks: a text value is parsed as a message, a number
244
+ * becomes a `float`, and anything else is skipped. `send` receives the
245
+ * message stamped with the event's time.
246
+ */
247
+ declare function createMessageSink(send: (track: SequenceTrack, value: Message, played: SequencePlayedEvent) => void): SequenceSink;
248
+
249
+ /** The capability under which a sequencer lends the document it plays. */
250
+ declare const SEQUENCE_DOCUMENT: CapabilityKey<SequenceDocument>;
251
+ /** The sequence document of a sequencer module, to read, edit and subscribe to. */
252
+ declare function sequenceDocumentOf(module: ModuleHandle | undefined): SequenceDocument | undefined;
253
+ interface SequencerOptions extends GraphModuleOptions {
254
+ /** The sequence to hold: a `Sequence`, or its saved JSON. Default: an empty one. */
255
+ readonly sequence?: unknown;
256
+ /** Start again from the beginning at the end. Default false. */
257
+ readonly loop?: boolean;
258
+ /** Follow the transport when activated. Default true. */
259
+ readonly running?: boolean;
260
+ }
261
+ /**
262
+ * Plays the sequence it holds while the transport plays. Needs the musical
263
+ * time of a Session, from its context or the `musicalTime` option.
264
+ *
265
+ * `control` input: `start`/1 and `stop`/0 turn following on and off; `loop
266
+ * 0/1`; `note track time duration pitch [velocity 0–127]` and `event track
267
+ * time message…` add an event, on the sequence's own axis; `length n` sets
268
+ * where it ends (`length` alone lets it end with its last event); `clear`
269
+ * empties every track. Outputs: `notes`; `events`, each `message` track's
270
+ * events as `<track> message…`; `done`, a bang when a sequence that does not
271
+ * loop ends.
272
+ */
273
+ declare class Sequencer extends GraphModule {
274
+ #private;
275
+ static readonly type = "webmusic.sequencer";
276
+ readonly inputs: {
277
+ control: MessageInputPort;
278
+ };
279
+ /** The notes of the `note` tracks, on the audio clock. */
280
+ readonly notes: NoteOutputPort;
281
+ readonly outputs: {
282
+ readonly events: MessageOutputPort;
283
+ readonly done: MessageOutputPort;
284
+ };
285
+ /** The sequence it plays, to read, edit and subscribe to. */
286
+ readonly document: SequenceDocument;
287
+ constructor(options?: SequencerOptions);
288
+ get capabilities(): ModuleCapabilities;
289
+ /** Whether it follows the transport. */
290
+ get running(): boolean;
291
+ get loop(): boolean;
292
+ set loop(value: boolean);
293
+ /** Follow the transport. Activates the module if it is not yet active. */
294
+ start(): void;
295
+ stop(): void;
296
+ exportOptions(): ModuleOptionsJson;
297
+ protected onActivate(): void;
298
+ protected onDispose(): void;
299
+ }
300
+ /** The project plugin that restores a {@link Sequencer} from a record's options. */
301
+ declare function sequencerPlugin(environment?: ModuleEnvironment): ProjectPluginFactory;
302
+
303
+ export { type NoteSinkOptions, type QuantizeOptions, SEQUENCE_DOCUMENT, SEQUENCE_SCHEMA, SEQUENCE_VERSION, type Sequence, type SequenceClock, SequenceDocument, type SequenceDocumentOptions, type SequenceDocumentSnapshot, type SequenceEvent, type SequenceEventInit, type SequenceInit, type SequenceNote, type SequencePlayedEvent, SequencePlayer, type SequencePlayerOptions, type SequenceSink, type SequenceTimeSource, type SequenceTrack, type SequenceTrackInit, type SequenceUnit, Sequencer, type SequencerOptions, addTrack, createMessageSink, createNoteSink, createSequence, eventIndexAt, eventsBetween, insertEvents, parseSequence, quantizeEvents, removeEvents, removeTrack, sequenceDocumentOf, sequenceEnd, sequenceNote, sequenceSeconds, sequenceTime, sequencerPlugin, setSequenceLength, shiftEvents, sliceSequence, updateEvents, updateTrack };