@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,1112 @@
1
+ import { c as ParamDescriptor, C as ConnectionLease, a as ControlSignal, d as ParamHandle, i as ParamSurface } from './parameter-DwQzFmBR.cjs';
2
+ export { P as ParamAudioBus, b as ParamAutomationEvent, e as ParamHandleOptions, f as ParamMapping, g as ParamMappingOptions, h as ParamSnapshot, j as createConnectionLease } from './parameter-DwQzFmBR.cjs';
3
+ import { w as ModuleHandle, j as Message, N as NoteEvent, C as CapabilityKey, f as AudioOutputPort, l as MessageInputPort, I as NoteOutputPort, n as MessageOutputPort, G as NoteInputPort, u as ModuleContext, J as JsonValue, x as ModulePort, r as ModuleAudioEnvironment, s as ModuleAudioEnvironmentOptions, B as ModuleRegistry, q as ModuleAdmission, b as AudioInputPort } from './context-DSa0ymyN.cjs';
4
+ export { A as Atom, a as AudioConnectionMode, c as AudioInputPortOptions, d as AudioMessageClock, e as AudioMessageClockOptions, g as AudioOutputPortOptions, h as ControlPort, D as DerivedModuleContextOptions, M as MAX_MESSAGE_DEPTH, i as ManualMessageClock, k as MessageClock, m as MessageInputPortOptions, o as MessageOutputPortOptions, p as MessageStackOverflowError, t as ModuleCapabilities, v as ModuleContextOptions, y as ModulePortInfo, z as ModulePortMap, E as ModuleRegistryOptions, F as NoteInputHandler, H as NoteInputPortOptions, K as NoteOutputPortOptions, L as NotePitch, P as PORT_FAMILIES, O as PortDirection, Q as PortFamily, R as PortListeners, S as PortMultiplicity, T as PortReadiness, U as SOURCE_SCHEMAS, V as SourcePort, W as SourcePublisher, X as SourcePublisherOptions, Y as SourceReadiness, Z as SourceSnapshot, _ as TransportCommands, $ as TransportPort, a0 as TransportPortOptions, a1 as TransportPortOutcome, a2 as TransportPortSnapshot, a3 as assertModuleId, a4 as assertNoteEvent, a5 as assertPortInfo, a6 as atomsOf, a7 as bang, a8 as connectMessageToParameter, a9 as createCapabilityKey, aa as createControlPort, ab as createModuleHandle, ac as createTransportPort, ad as currentMessageDepth, ae as floatAtom, af as floatMessage, ag as formatMessage, ah as getModulePort, ai as intAtom, aj as intMessage, ak as isNumberAtom, al as message, am as messageClockFor, an as messageFromAtoms, ao as moduleScopeChange, ap as numberOf, aq as parseAtom, ar as parseMessage, as as routeModuleOutput, at as sameModuleScope, au as symbolAtom, av as symbolMessage, aw as withTime } from './context-DSa0ymyN.cjs';
5
+ import { w as ProjectParamEndpoint, p as ProjectMappingRecord, q as ProjectMappingSource, i as ProjectEndpoint, x as ProjectPluginFactory, l as ProjectJson, M as ModuleProject, y as ProjectPluginLookup, F as ProjectRuntimeOptions, G as ProjectRuntimeResources, H as ProjectRuntimeSnapshot, C as ProjectRestoreOptions, D as ProjectRestoreResult, n as ProjectLayout, d as ProjectConnectionRecord, r as ProjectModulationRecord, u as ProjectModuleRecord, P as ProjectAssetReference, B as ProjectPreloadOptions, J as ProjectSignalKind } from './project-types-DufCV8Ma.cjs';
6
+ export { a as ProjectAutomationPoint, b as ProjectAutomationRecord, c as ProjectComment, e as ProjectConnectionRequest, f as ProjectConnector, g as ProjectContextRecord, h as ProjectDiagnostic, j as ProjectFactoryRequest, k as ProjectGroup, m as ProjectJsonObject, o as ProjectMacroRecord, s as ProjectModuleInstance, t as ProjectModuleLayout, v as ProjectModuleUnavailableError, z as ProjectPluginReference, A as ProjectPortDescriptor, E as ProjectRuntimeModule, I as ProjectSessionState, K as isProjectModuleUnavailable } from './project-types-DufCV8Ma.cjs';
7
+ import { a as GraphModuleOptions, G as GraphModule, d as ModuleOptionsJson, c as ModuleEnvironment } from './module-plugin-CHb-5W0Y.cjs';
8
+ export { M as MODULE_PLUGIN_VERSION, b as MUSICAL_TIME, e as ModuleProjectHooks, f as MusicalTimeSource, R as RestoredOptions, j as assertStructuredOptions, k as createMusicalTimeSource, m as moduleBaseOptions, l as modulePlugin, n as numberedPort } from './module-plugin-CHb-5W0Y.cjs';
9
+ import { C as ControlModule } from './module-control-yH6nTJM9.cjs';
10
+ export { M as MODULE_CONTROL, a as ModuleControl, O as OscArgument, b as OscBundle, c as OscMessage, d as OscPacket, e as decodeOsc, f as encodeOsc, i as isOscBundle, m as moduleControlOf } from './module-control-yH6nTJM9.cjs';
11
+ import { SessionTransport, ModuleSession, SessionTransportOptions } from './session.cjs';
12
+ import { MusicalTempo } from './transport.cjs';
13
+ import { E as Effect, I as InsertChain } from './effect-chain-Do75T7uK.cjs';
14
+ import './tick.cjs';
15
+
16
+ /** A preset's values by key; an array blends element by element. */
17
+ type PresetValues = Readonly<Record<string, number | readonly number[]>>;
18
+ /** Slots of stored values, recalled whole or interpolated. */
19
+ declare class PresetBank {
20
+ #private;
21
+ constructor(initial?: Readonly<Record<string, PresetValues>>);
22
+ /** Stored slot numbers, ascending. */
23
+ get slots(): readonly number[];
24
+ has(slot: number): boolean;
25
+ store(slot: number, values: PresetValues): void;
26
+ recall(slot: number): PresetValues | undefined;
27
+ clear(slot: number): void;
28
+ /**
29
+ * Blend stored slots by weight. Weights are normalized; a key present in
30
+ * only some slots takes those slots' share. Numbers and arrays of equal
31
+ * length blend linearly; anything else takes the heaviest slot's value.
32
+ */
33
+ interpolate(weights: Readonly<Record<number, number>>): PresetValues;
34
+ /** Blend two slots: `fraction` 0 is `from`, 1 is `to`. */
35
+ between(from: number, to: number, fraction: number): PresetValues;
36
+ toJSON(): Record<string, Record<string, number | number[]>>;
37
+ }
38
+ /** The base values of every parameter of `modules`, keyed `moduleId.parameterId`. */
39
+ declare function captureParameters(modules: Iterable<ModuleHandle>): Record<string, number>;
40
+ /** Set every parameter of `modules` that `values` names, clamped to its range. Returns how many were set. */
41
+ declare function applyParameters(modules: Iterable<ModuleHandle>, values: PresetValues): number;
42
+
43
+ /** One control gesture from an input device. */
44
+ type ControlEvent = {
45
+ readonly kind: 'cc';
46
+ readonly controller: number;
47
+ readonly value: number;
48
+ readonly channel: number;
49
+ } | {
50
+ readonly kind: 'pitchbend';
51
+ readonly value: number;
52
+ readonly channel: number;
53
+ } | {
54
+ readonly kind: 'program';
55
+ readonly value: number;
56
+ readonly channel: number;
57
+ } | {
58
+ readonly kind: 'pressure';
59
+ readonly value: number;
60
+ readonly channel: number;
61
+ } | {
62
+ readonly kind: 'key';
63
+ readonly key: string;
64
+ readonly down: boolean;
65
+ };
66
+ /** The 0–1 position of an event, or undefined for one that sets nothing (a key release). */
67
+ declare function controlFraction(event: ControlEvent): number | undefined;
68
+ /** The mapping source an event comes from. */
69
+ declare function controlSource(event: ControlEvent): ProjectMappingSource;
70
+ /** Whether `source` listens to `event`; a source without a channel listens to every channel. */
71
+ declare function sourceMatches(source: ProjectMappingSource, event: ControlEvent): boolean;
72
+ /** A short name for a source: `CC 7 ch 1`, `Bend`, `Program`, `Key A`. */
73
+ declare function describeSource(source: ProjectMappingSource): string;
74
+ /**
75
+ * What a mapping writes: a `ParamHandle`, or anything shaped like one, such
76
+ * as an adapter over an interface object's value.
77
+ */
78
+ interface MappableParameter {
79
+ readonly descriptor: Pick<ParamDescriptor, 'range' | 'displayRange'>;
80
+ readonly snapshot: {
81
+ readonly disposed: boolean;
82
+ };
83
+ setBaseValue(value: number): void;
84
+ }
85
+ interface ControlMappingOptions {
86
+ /** Find the live parameter a mapping targets; undefined while it is unavailable. */
87
+ resolve(target: ProjectParamEndpoint): MappableParameter | undefined;
88
+ /** Called after learning or removing a mapping changes the list. */
89
+ onChange?(mappings: readonly ProjectMappingRecord[]): void;
90
+ }
91
+ /** Applies control events to parameters through a list of mappings, and learns new ones. */
92
+ declare class ControlMappings {
93
+ #private;
94
+ constructor(options: ControlMappingOptions, mappings?: readonly ProjectMappingRecord[]);
95
+ get mappings(): readonly ProjectMappingRecord[];
96
+ /** The target waiting for its next control event, if any. */
97
+ get learning(): ProjectParamEndpoint | undefined;
98
+ /** Replace the list, as when a project opens. */
99
+ set(mappings: readonly ProjectMappingRecord[]): void;
100
+ /** The next control event maps to `target`, replacing that target's previous mapping. */
101
+ learn(target: ProjectParamEndpoint): void;
102
+ cancelLearn(): void;
103
+ remove(id: string): void;
104
+ /** Apply one event. Returns true when it learned a mapping or set at least one parameter. */
105
+ handle(event: ControlEvent): boolean;
106
+ subscribe(listener: () => void): () => void;
107
+ }
108
+
109
+ type VoiceSteal = 'oldest' | 'none';
110
+ interface VoiceAssignment {
111
+ /** The voice that now plays the key, or undefined when every voice is busy and stealing is off. */
112
+ readonly voice: number | undefined;
113
+ /** The key that lost its voice to this one, when a voice was stolen. */
114
+ readonly stolen?: string;
115
+ }
116
+ /** Assigns held notes to a fixed number of voices; a new note takes a free voice or steals the oldest. */
117
+ declare class VoiceAllocator {
118
+ #private;
119
+ readonly voices: number;
120
+ readonly steal: VoiceSteal;
121
+ constructor(voices: number, steal?: VoiceSteal);
122
+ /** Keys currently holding a voice, oldest first. */
123
+ get held(): readonly string[];
124
+ /** The voice playing `key`, if any. */
125
+ voiceOf(key: string): number | undefined;
126
+ /** Give `key` a voice: a free one in turn, or the oldest held voice when all are busy. */
127
+ noteOn(key: string): VoiceAssignment;
128
+ /** Free the voice of `key`; returns it, or undefined when the key held none. */
129
+ noteOff(key: string): number | undefined;
130
+ /** Free every voice. */
131
+ clear(): void;
132
+ }
133
+
134
+ interface ProbeEventBase {
135
+ /** The project connection the value crossed. */
136
+ readonly connectionId: string;
137
+ readonly from: ProjectEndpoint;
138
+ readonly to: ProjectEndpoint;
139
+ /** Increases by one per observed delivery of the runtime, in delivery order. */
140
+ readonly sequence: number;
141
+ }
142
+ /** A message about to be delivered along a message cord. */
143
+ interface MessageProbeEvent extends ProbeEventBase {
144
+ readonly kind: 'message';
145
+ readonly message: Message;
146
+ /** Nesting of the delivery: 1 for a message sent from outside any delivery. */
147
+ readonly depth: number;
148
+ }
149
+ /** A note event about to be delivered along a note cord. */
150
+ interface NoteProbeEvent extends ProbeEventBase {
151
+ readonly kind: 'note';
152
+ readonly event: NoteEvent;
153
+ }
154
+ type ProbeEvent = MessageProbeEvent | NoteProbeEvent;
155
+ /** A signal probe: an analyser that listens to one output across rebuilds. */
156
+ interface SignalProbe {
157
+ /** Owned by the probe; read it, never connect it elsewhere. */
158
+ readonly analyser: AnalyserNode;
159
+ /** True while the endpoint exists in the active graph and the analyser hears it. */
160
+ readonly connected: boolean;
161
+ release(): void;
162
+ }
163
+ /** What a debugger needs from a runtime. */
164
+ interface ObservableRuntime {
165
+ observe(listener: (event: ProbeEvent) => void): () => void;
166
+ }
167
+ /** What a debugger needs from a message clock: `AudioMessageClock` and `ManualMessageClock` fit. */
168
+ interface HoldableClock {
169
+ readonly held: boolean;
170
+ hold(): void;
171
+ resume(): void;
172
+ step(): boolean;
173
+ }
174
+ interface Watchpoint {
175
+ readonly id: string;
176
+ readonly connectionId: string;
177
+ /** `trace` reports each hit; `break` also holds the message clock. */
178
+ readonly mode: 'trace' | 'break';
179
+ /** Hit only when this returns true; every message hits without one. */
180
+ readonly condition?: (event: ProbeEvent) => boolean;
181
+ }
182
+ interface WatchpointHit {
183
+ readonly watchpoint: Watchpoint;
184
+ readonly event: ProbeEvent;
185
+ }
186
+ /**
187
+ * Watchpoints over a runtime's cords. A `break` hit holds the message clock
188
+ * after the delivery in progress, so timed modules stop while audio keeps
189
+ * running; `continue()` resumes and `step()` delivers one held event. Ownership:
190
+ * the debugger observes the runtime and borrows the clock; `dispose` releases
191
+ * the observation and resumes a clock it held.
192
+ */
193
+ declare class MessageDebugger {
194
+ #private;
195
+ constructor(runtime: ObservableRuntime, clock: HoldableClock);
196
+ get watchpoints(): readonly Watchpoint[];
197
+ /** True while a break holds the clock. */
198
+ get paused(): boolean;
199
+ /** The latest hit, for a debugger view. */
200
+ get lastHit(): WatchpointHit | undefined;
201
+ set(watchpoint: Watchpoint): void;
202
+ remove(id: string): void;
203
+ onHit(listener: (hit: WatchpointHit) => void): () => void;
204
+ continue(): void;
205
+ /** Deliver one held event; false when none is waiting. */
206
+ step(): boolean;
207
+ dispose(): void;
208
+ }
209
+
210
+ /** The parameter description a WAM node reports. */
211
+ interface WamParameterInfoLike {
212
+ readonly id: string;
213
+ readonly label?: string;
214
+ readonly type?: 'float' | 'int' | 'boolean' | 'choice';
215
+ readonly defaultValue: number;
216
+ readonly minValue: number;
217
+ readonly maxValue: number;
218
+ readonly discreteStep?: number;
219
+ readonly exponent?: number;
220
+ readonly units?: string;
221
+ }
222
+ /** The part of a `WamNode` the adapter uses. */
223
+ interface WamNodeLike extends AudioNode {
224
+ getParameterInfo(...ids: string[]): Promise<Readonly<Record<string, WamParameterInfoLike>>>;
225
+ getParameterValues(normalized?: boolean, ...ids: string[]): Promise<Readonly<Record<string, {
226
+ readonly value: number;
227
+ }>>>;
228
+ setParameterValues(values: Readonly<Record<string, {
229
+ id: string;
230
+ value: number;
231
+ normalized: boolean;
232
+ }>>): Promise<void>;
233
+ getState?(): Promise<unknown>;
234
+ setState?(state: unknown): Promise<void>;
235
+ scheduleEvents(...events: readonly {
236
+ type: 'wam-midi';
237
+ time: number;
238
+ data: {
239
+ bytes: readonly [number, number, number];
240
+ };
241
+ }[]): void;
242
+ destroy?(): void;
243
+ }
244
+ /** The part of a `WebAudioModule` instance the adapter uses. */
245
+ interface WamInstanceLike {
246
+ readonly audioNode: WamNodeLike;
247
+ readonly descriptor?: {
248
+ readonly name?: string;
249
+ readonly hasAudioInput?: boolean;
250
+ readonly hasAudioOutput?: boolean;
251
+ readonly hasMidiInput?: boolean;
252
+ };
253
+ createGui?(): Promise<Element>;
254
+ destroyGui?(gui: Element): void;
255
+ }
256
+ /** A WAM module's default export. */
257
+ interface WamConstructorLike {
258
+ createInstance(groupId: string, context: BaseAudioContext, initialState?: unknown): Promise<WamInstanceLike>;
259
+ }
260
+ interface WamPluginOptions {
261
+ /** Plugin ID. Defaults to `webmusic.wam`. */
262
+ readonly id?: string;
263
+ /**
264
+ * The host group of an AudioContext, from `initializeWamHost(context)` of
265
+ * `@webaudiomodules/sdk`. Called once per AudioContext.
266
+ */
267
+ readonly hostGroup: (context: BaseAudioContext) => string | Promise<string>;
268
+ /** Load a WAM module by URL. Defaults to a dynamic `import()` of the URL. */
269
+ readonly load?: (url: string) => Promise<WamConstructorLike>;
270
+ /** Accept or refuse a URL before loading it. Defaults to accepting any http(s) URL. */
271
+ readonly allow?: (url: string) => boolean;
272
+ }
273
+ /** What a WAM module lends its editor: the instance and its own GUI. */
274
+ interface WamModule {
275
+ readonly instance: WamInstanceLike;
276
+ readonly name: string;
277
+ /** Create the plugin's own interface; destroy it with `destroyGui`. Undefined when the plugin has none. */
278
+ createGui(): Promise<Element> | undefined;
279
+ destroyGui(gui: Element): void;
280
+ }
281
+ declare const WAM_MODULE: CapabilityKey<WamModule>;
282
+ /**
283
+ * A project plugin that runs Web Audio Modules. A record's `config.url` names
284
+ * the WAM; `config.state`, when present, is passed to `createInstance` and
285
+ * refreshed from the plugin after parameter changes. The module has an
286
+ * `input` and an `output` when the plugin declares audio in and out, a
287
+ * `notes` input when it takes MIDI, and one parameter per WAM parameter.
288
+ * A plugin that cannot load leaves the module unresolved with the reason.
289
+ */
290
+ declare function wamPlugin(options: WamPluginOptions): ProjectPluginFactory;
291
+
292
+ declare const MAX_MC_CHANNELS = 32;
293
+ /**
294
+ * Wrap an audio plugin with one `input` and one `output` as `mc.<id>`: the
295
+ * record's `config.channels` instances, each given `config.config`, process
296
+ * one channel each between a splitter and a merger. The first instance's
297
+ * parameters are the module's; setting one sets it on every channel.
298
+ */
299
+ declare function multichannelPlugin(inner: ProjectPluginFactory, id?: string): ProjectPluginFactory;
300
+ interface ChannelOptions extends GraphModuleOptions {
301
+ /** How many channels, 1 to 32. Default 2. */
302
+ readonly channels?: number;
303
+ }
304
+ /** Mono inputs `in0`, `in1`… joined into one multichannel output, `output`. Needs a context. */
305
+ declare class ChannelPack extends GraphModule {
306
+ #private;
307
+ static readonly type = "webmusic.mc.pack";
308
+ readonly channels: number;
309
+ constructor(options?: ChannelOptions);
310
+ getPort(name: string): AudioOutputPort | undefined;
311
+ getInput(name: string): AudioNode | undefined;
312
+ exportOptions(): ModuleOptionsJson;
313
+ protected onDispose(): void;
314
+ }
315
+ /** One multichannel input, `input`, split into mono outputs `out0`, `out1`…. Needs a context. */
316
+ declare class ChannelUnpack extends GraphModule {
317
+ #private;
318
+ static readonly type = "webmusic.mc.unpack";
319
+ readonly channels: number;
320
+ constructor(options?: ChannelOptions);
321
+ getPort(name: string): AudioOutputPort | undefined;
322
+ getInput(name: string): AudioNode | undefined;
323
+ exportOptions(): ModuleOptionsJson;
324
+ protected onDispose(): void;
325
+ }
326
+
327
+ interface NoteMakerOptions extends GraphModuleOptions {
328
+ /** Velocity of the next note, 0 to 127. Default 100. */
329
+ readonly velocity?: number;
330
+ /** How long a note sounds: milliseconds, or a time value such as `8n`. Default 250. */
331
+ readonly duration?: number | string;
332
+ }
333
+ /** Plays a note for each pitch it receives. A list is pitch, velocity, duration; velocity 0 plays nothing. */
334
+ declare class NoteMaker extends GraphModule {
335
+ #private;
336
+ static readonly type = "webmusic.note-maker";
337
+ readonly inputs: {
338
+ pitch: MessageInputPort;
339
+ velocity: MessageInputPort;
340
+ duration: MessageInputPort;
341
+ };
342
+ /** The notes it plays, on the audio clock. */
343
+ readonly notes: NoteOutputPort;
344
+ constructor(options?: NoteMakerOptions);
345
+ /** Velocity of the next note, 0 to 127. */
346
+ get velocity(): number;
347
+ set velocity(value: number);
348
+ /** Duration of the next note: milliseconds as text, or a time value. */
349
+ get duration(): string;
350
+ set duration(value: number | string);
351
+ /** Play `pitch` (MIDI 0 to 127) at `time` (now by default) with the current velocity and duration. */
352
+ play(pitch: number, time?: number): void;
353
+ /** The options it was made with; a velocity or duration set later is not saved. */
354
+ exportOptions(): ModuleOptionsJson;
355
+ protected onDispose(): void;
356
+ }
357
+
358
+ /**
359
+ * What a source cord carries across a boundary (DEC-089): a module that stands
360
+ * for whichever module is cabled into it. A companion given a relay reads the
361
+ * upstream module's ports, parameters and inserts through it, and hears when
362
+ * the upstream module changes or is replaced, so a view inside a component
363
+ * follows a player outside it exactly as if they were cabled directly.
364
+ *
365
+ * Ownership: a relay borrows what it follows and never disposes it. Each
366
+ * `follow` returns a lease; the newest lease still held wins, as a slot's
367
+ * provided values do, so a rebuild that makes the new cord before releasing
368
+ * the old one never leaves a gap.
369
+ */
370
+ declare class SourceRelay implements ModuleHandle {
371
+ #private;
372
+ readonly id: string;
373
+ constructor(id: string);
374
+ /** The module this relay stands for now, if any. */
375
+ get upstream(): ModuleHandle | undefined;
376
+ get params(): ModuleHandle['params'];
377
+ get inserts(): ModuleHandle['inserts'];
378
+ get capabilities(): ModuleHandle['capabilities'];
379
+ get disposed(): boolean;
380
+ getPort(name: string): ReturnType<NonNullable<ModuleHandle['getPort']>>;
381
+ ports(): ReturnType<NonNullable<ModuleHandle['ports']>>;
382
+ prepare(): Promise<void> | void;
383
+ subscribe(listener: () => void): () => void;
384
+ /** Stand for `module` until the lease is released. */
385
+ follow(module: ModuleHandle): ConnectionLease;
386
+ dispose(): void;
387
+ }
388
+ /** The module a source finally comes from: through every relay it crosses, to the first module that is not one. */
389
+ declare function sourceOrigin(module: ModuleHandle | undefined): ModuleHandle | undefined;
390
+
391
+ type BoundaryKind = 'message' | 'audio' | 'note' | 'source';
392
+ /** One inlet channel, seen from inside the component. */
393
+ interface BoundaryInlet {
394
+ readonly kind: BoundaryKind;
395
+ /** Messages arriving at the component's inlet. */
396
+ readonly messages?: MessageOutputPort;
397
+ /** Audio arriving at the component's inlet. */
398
+ readonly audio?: AudioOutputPort;
399
+ /** Notes arriving at the component's inlet. */
400
+ readonly notes?: NoteOutputPort;
401
+ /** The module cabled into the component's source inlet, as a relay. */
402
+ readonly source?: SourceRelay;
403
+ }
404
+ /** One outlet channel, seen from inside the component. */
405
+ interface BoundaryOutlet {
406
+ readonly kind: BoundaryKind;
407
+ /** Send a message out of the component's outlet. */
408
+ send?(message: Message): void;
409
+ /** Connect audio here to leave through the component's outlet. */
410
+ readonly input?: AudioNode;
411
+ /** Play notes out of the component's outlet. */
412
+ readonly notes?: NoteInputPort;
413
+ /** The relay a source outlet carries: it follows whatever is cabled to the source outlet inside. */
414
+ readonly source?: SourceRelay;
415
+ }
416
+ /** What a component lends its child context. */
417
+ interface ComponentBoundary {
418
+ inlet(index: number): BoundaryInlet | undefined;
419
+ outlet(index: number): BoundaryOutlet | undefined;
420
+ }
421
+ declare const COMPONENT_BOUNDARY: CapabilityKey<ComponentBoundary>;
422
+ /** What a PolyComponent lends each voice's context (DEC-077): its index and the notes allocated to it. */
423
+ interface PolyVoice {
424
+ readonly index: number;
425
+ readonly voices: number;
426
+ readonly notes: NoteOutputPort;
427
+ }
428
+ declare const POLY_VOICE: CapabilityKey<PolyVoice>;
429
+ interface NestedComponentOptions extends GraphModuleOptions {
430
+ /** Each inlet channel's kind, in order. Ports `in0`, `in1`…. */
431
+ readonly inlets?: readonly BoundaryKind[];
432
+ /** Each outlet channel's kind, in order. Ports `out0`, `out1`…. */
433
+ readonly outlets?: readonly BoundaryKind[];
434
+ }
435
+ /**
436
+ * The shell of a nested component. The record that owns the child context is
437
+ * the component; its contents are the modules of that context. A host keeps
438
+ * `inlets` and `outlets` in step with the inlet and outlet modules inside.
439
+ * Needs a context.
440
+ */
441
+ declare class NestedComponent extends GraphModule {
442
+ #private;
443
+ static readonly type: string;
444
+ readonly inlets: readonly BoundaryKind[];
445
+ readonly outlets: readonly BoundaryKind[];
446
+ /** The boundary lent to the child context. */
447
+ readonly boundary: ComponentBoundary;
448
+ /** The `notes` input of a component played by voices. */
449
+ protected readonly voiceInput?: NoteInputPort;
450
+ /** `type` and `voices` are for {@link PolyComponent}: voices make the shell own one child context per voice. */
451
+ constructor(options?: NestedComponentOptions, type?: string, voices?: number);
452
+ getPort(name: string): AudioOutputPort | undefined;
453
+ /** The first audio outlet follows the context's default route, like any other audio module. */
454
+ prepare(): void;
455
+ getInput(name: string): AudioNode | undefined;
456
+ /** A source cord into an inlet is followed by that inlet's relay. */
457
+ connectSource(name: string, upstream: ModuleHandle): ConnectionLease | undefined;
458
+ /** A source cord from an outlet carries the outlet's relay. */
459
+ sourceOutput(name: string): ModuleHandle | undefined;
460
+ /**
461
+ * Inner modules keep the parent's destination and admission, so a module
462
+ * not wired to an audio outlet sounds through the parent's default route.
463
+ */
464
+ childContext(child: ModuleContext): ModuleContext;
465
+ exportOptions(): ModuleOptionsJson;
466
+ protected onDispose(): void;
467
+ }
468
+ interface PolyComponentOptions extends NestedComponentOptions {
469
+ /** How many voices, 1 to 64. Default 4. */
470
+ readonly voices?: number;
471
+ }
472
+ /**
473
+ * A nested component played by several voices (DEC-077): it owns one child
474
+ * context per voice, each a copy of the same contents, and each note into its
475
+ * `notes` input goes to one voice at a time.
476
+ */
477
+ declare class PolyComponent extends NestedComponent {
478
+ static readonly type = "webmusic.poly";
479
+ readonly voices: number;
480
+ constructor(options?: PolyComponentOptions);
481
+ /** Notes in, one voice each. */
482
+ get notes(): NoteInputPort;
483
+ exportOptions(): ModuleOptionsJson;
484
+ }
485
+ interface BoundaryModuleOptions extends GraphModuleOptions {
486
+ /** What crosses the boundary here. Default `message`. */
487
+ readonly kind?: BoundaryKind;
488
+ /** Which of the enclosing component's channels, from 0. Default 0. */
489
+ readonly index?: number;
490
+ }
491
+ /** Inside a component: what arrives at inlet `index` of the enclosing component, on the port `output`. Needs a context. */
492
+ declare class InletModule extends GraphModule {
493
+ #private;
494
+ static readonly type = "webmusic.inlet";
495
+ readonly kind: BoundaryKind;
496
+ readonly index: number;
497
+ constructor(options?: BoundaryModuleOptions);
498
+ getPort(name: string): AudioOutputPort | undefined;
499
+ /** A source inlet carries the component's inlet relay. */
500
+ sourceOutput(name: string): ModuleHandle | undefined;
501
+ exportOptions(): ModuleOptionsJson;
502
+ protected onDispose(): void;
503
+ }
504
+ /** Inside a component: what reaches its port `input` leaves through outlet `index` of the enclosing component. Needs a context. */
505
+ declare class OutletModule extends GraphModule {
506
+ #private;
507
+ static readonly type = "webmusic.outlet";
508
+ readonly kind: BoundaryKind;
509
+ readonly index: number;
510
+ constructor(options?: BoundaryModuleOptions);
511
+ getInput(name: string): AudioNode | undefined;
512
+ /** A source outlet hands what reaches it to the component's outlet relay. */
513
+ connectSource(name: string, upstream: ModuleHandle): ConnectionLease | undefined;
514
+ exportOptions(): ModuleOptionsJson;
515
+ protected onDispose(): void;
516
+ }
517
+ /** Inside a PolyComponent's voice: the notes allocated to that voice, on the port `notes`. Needs a context. */
518
+ declare class VoiceNotes extends GraphModule {
519
+ #private;
520
+ static readonly type = "webmusic.voice";
521
+ readonly notes: NoteOutputPort;
522
+ /** The voice this module sits in, when it is inside a poly. */
523
+ readonly voice?: PolyVoice;
524
+ constructor(options?: GraphModuleOptions);
525
+ exportOptions(): ModuleOptionsJson;
526
+ protected onDispose(): void;
527
+ }
528
+
529
+ interface PresetModuleOptions extends GraphModuleOptions {
530
+ /** How many slots, 1 to 64. Default 16. */
531
+ readonly count?: number;
532
+ /** The stored slots, by number. */
533
+ readonly slots?: Readonly<Record<string, PresetValues>>;
534
+ }
535
+ /** Stores and recalls the values of the modules beside it. Needs a context. */
536
+ declare class PresetModule extends ControlModule {
537
+ #private;
538
+ static readonly type = "webmusic.preset";
539
+ readonly kind = "preset";
540
+ readonly inputs: {
541
+ control: MessageInputPort;
542
+ };
543
+ readonly outputs: {
544
+ slot: MessageOutputPort;
545
+ };
546
+ readonly count: number;
547
+ readonly bank: PresetBank;
548
+ constructor(options?: PresetModuleOptions);
549
+ /** The slot last stored or recalled; 0 after a blend. */
550
+ get current(): number;
551
+ /** Capture the other modules into `slot`. */
552
+ store(slot: number): void;
553
+ /** Apply a stored slot and report it. */
554
+ recall(slot: number, time?: number): void;
555
+ /** Apply a blend of stored slots. */
556
+ blend(values: PresetValues): void;
557
+ snapshot(): JsonValue;
558
+ exportOptions(): ModuleOptionsJson;
559
+ protected receive(value: Message): void;
560
+ }
561
+ /** One node of an interpolation pad, in the unit square. */
562
+ interface PadNode {
563
+ readonly x: number;
564
+ readonly y: number;
565
+ readonly radius: number;
566
+ }
567
+ /** Each node's weight: how far the cursor reaches inside it, normalized to sum to 1. */
568
+ declare function nodeWeights(nodes: readonly PadNode[], cursor: {
569
+ x: number;
570
+ y: number;
571
+ }): number[];
572
+ interface NodesModuleOptions extends GraphModuleOptions {
573
+ /** How many nodes, 2 to 12. Default 4. */
574
+ readonly count?: number;
575
+ /** The nodes; used when their number is `count`. Default: on a circle. */
576
+ readonly nodes?: readonly PadNode[];
577
+ readonly cursor?: {
578
+ readonly x: number;
579
+ readonly y: number;
580
+ };
581
+ }
582
+ /** An interpolation pad: a cursor among nodes, sent as one weight per node. */
583
+ declare class NodesModule extends ControlModule {
584
+ #private;
585
+ static readonly type = "webmusic.nodes";
586
+ readonly kind = "nodes";
587
+ readonly inputs: {
588
+ control: MessageInputPort;
589
+ };
590
+ readonly outputs: {
591
+ weights: MessageOutputPort;
592
+ };
593
+ constructor(options?: NodesModuleOptions);
594
+ get nodes(): readonly PadNode[];
595
+ get cursor(): {
596
+ readonly x: number;
597
+ readonly y: number;
598
+ };
599
+ /** The weight of each node for the cursor where it is. */
600
+ get weights(): number[];
601
+ /** Move the cursor and send the weights. */
602
+ moveCursor(x: number, y: number, time?: number): void;
603
+ /** Move a node, and resize it when `radius` is given, and send the weights. */
604
+ moveNode(index: number, x: number, y: number, radius?: number, time?: number): void;
605
+ snapshot(): JsonValue;
606
+ exportOptions(): ModuleOptionsJson;
607
+ protected receive(value: Message): void;
608
+ }
609
+
610
+ /** Project plugins for the note maker, nested and poly components, their inlets, outlets and voices, presets, nodes and the channel pair. */
611
+ declare function createStructurePlugins(environment?: ModuleEnvironment): readonly ProjectPluginFactory[];
612
+
613
+ /** One module instance under test and the owner-side cleanup the module itself does not expose. */
614
+ interface ModuleConformanceSubject {
615
+ readonly module: ModuleHandle;
616
+ dispose?(): void | Promise<void>;
617
+ }
618
+ interface ModuleConformanceOptions {
619
+ /** Call `prepare()` twice; skip for modules that need a live audio device. Default false. */
620
+ prepare?: boolean;
621
+ /** Create and dispose this many instances. Default 2. */
622
+ repetitions?: number;
623
+ /** When set, every instance must report this module ID. */
624
+ expectedId?: string;
625
+ /** Ports (`family/id`) the module lends but does not own, such as a borrowed transport; they may outlive it. */
626
+ borrowedPorts?: readonly string[];
627
+ }
628
+ interface ModuleConformanceFailure {
629
+ readonly check: string;
630
+ readonly message: string;
631
+ }
632
+ interface ModuleConformanceReport {
633
+ readonly passed: boolean;
634
+ readonly instances: number;
635
+ readonly failures: readonly ModuleConformanceFailure[];
636
+ }
637
+ /**
638
+ * Framework-neutral contract checks for a module factory (DEC-068 MC-20).
639
+ * Each package's tests run it against its module factories; third-party
640
+ * modules can run it too. It reports every failure instead of stopping at the
641
+ * first, and never disposes a borrowed resource the subject did not hand it.
642
+ */
643
+ declare function checkModuleConformance(create: () => ModuleConformanceSubject | Promise<ModuleConformanceSubject>, options?: ModuleConformanceOptions): Promise<ModuleConformanceReport>;
644
+
645
+ interface ControlLFOOptions {
646
+ readonly frequency?: number;
647
+ readonly waveform?: Exclude<OscillatorType, 'custom'>;
648
+ }
649
+ /** Native audio-thread oscillator. Its owner, never its panel, controls lifetime. */
650
+ declare class ControlLFO {
651
+ readonly signal: ControlSignal;
652
+ readonly frequency: ParamHandle;
653
+ private readonly oscillator;
654
+ private disposed;
655
+ constructor(context: BaseAudioContext, options?: ControlLFOOptions);
656
+ get waveform(): Exclude<OscillatorType, 'custom'>;
657
+ setWaveform(waveform: Exclude<OscillatorType, 'custom'>): void;
658
+ dispose(): void;
659
+ }
660
+ interface ControlEnvelopeOptions {
661
+ readonly attack?: number;
662
+ readonly decay?: number;
663
+ readonly sustain?: number;
664
+ readonly release?: number;
665
+ }
666
+ /** Global retriggerable ADSR control generator, independent of instrument voices. */
667
+ declare class ControlEnvelope {
668
+ readonly context: BaseAudioContext;
669
+ readonly signal: ControlSignal;
670
+ private readonly source;
671
+ private readonly options;
672
+ private points;
673
+ private disposed;
674
+ constructor(context: BaseAudioContext, options?: ControlEnvelopeOptions);
675
+ trigger(time?: number, velocity?: number): void;
676
+ release(time?: number): void;
677
+ dispose(): void;
678
+ private valueAt;
679
+ private replace;
680
+ private validateTime;
681
+ }
682
+ interface EnvelopeFollowerOptions {
683
+ /** Low-pass corner in Hz. Larger values follow changes faster. */
684
+ readonly smoothingHz?: number;
685
+ }
686
+ /** Audio-rate absolute-value envelope follower, normalized/clipped to [0, 1]. */
687
+ declare class EnvelopeFollower {
688
+ readonly input: GainNode;
689
+ readonly signal: ControlSignal;
690
+ private readonly rectifier;
691
+ private readonly smoother;
692
+ private readonly limiter;
693
+ private disposed;
694
+ constructor(context: BaseAudioContext, options?: EnvelopeFollowerOptions);
695
+ dispose(): void;
696
+ }
697
+
698
+ interface ParamMacroTarget {
699
+ readonly target: ParamHandle;
700
+ /** Mapping endpoints in this target's native unit; reversal is allowed. */
701
+ readonly min: number;
702
+ readonly max: number;
703
+ }
704
+ /** A normalized controller writing the same shared base handles as ordinary UI. */
705
+ declare class ParamMacro {
706
+ readonly targets: readonly ParamMacroTarget[];
707
+ private current;
708
+ private disposed;
709
+ private applying;
710
+ private readonly listeners;
711
+ constructor(targets: Iterable<ParamMacroTarget>, options?: {
712
+ value?: number;
713
+ });
714
+ get value(): number;
715
+ setValue(value: number): void;
716
+ subscribe(listener: (value: number) => void): () => void;
717
+ dispose(): void;
718
+ private validate;
719
+ }
720
+
721
+ /** Copy only bounded plain JSON data. Accessors are rejected without invoking them. */
722
+ declare function copyProjectJson(input: unknown): ProjectJson;
723
+ /** Validate schema/version, exact references and topology before creating any runtime resources. */
724
+ declare function parseModuleProject(input: unknown): ModuleProject;
725
+ /** Canonical validated data only; no runtime objects are visited or serialized. */
726
+ declare function serializeModuleProject(project: unknown, space?: number): string;
727
+
728
+ /** Exact plugin/version dispatch. Registration borrows factories and never executes them. */
729
+ declare class ProjectPluginRegistry implements ProjectPluginLookup {
730
+ #private;
731
+ get(id: string, version: string): ProjectPluginFactory | undefined;
732
+ register(factory: ProjectPluginFactory): ConnectionLease;
733
+ }
734
+
735
+ /**
736
+ * Owns one active graph and at most one muted candidate. It borrows its audio
737
+ * environment; applications own file access, persistence, undo and user gestures.
738
+ */
739
+ declare class ModuleProjectRuntime {
740
+ #private;
741
+ constructor(options: ProjectRuntimeOptions);
742
+ /**
743
+ * Observe every message and note as it is about to cross a cord of the
744
+ * active graph (DEC-078). Delivery is unchanged: listeners run first, in
745
+ * delivery order, and cannot stop or alter it; a throwing listener is
746
+ * reported, not propagated. Returns an unsubscribe function.
747
+ */
748
+ observe(listener: (event: ProbeEvent) => void): () => void;
749
+ /**
750
+ * Listen to an audio or control output with an analyser that follows the
751
+ * endpoint across rebuilds; it never changes the output's routes. The probe
752
+ * owns the analyser; release it to disconnect.
753
+ */
754
+ probeSignal(endpoint: {
755
+ moduleId: string;
756
+ port: string;
757
+ }, options?: {
758
+ fftSize?: number;
759
+ }): SignalProbe;
760
+ get context(): ModuleContext | undefined;
761
+ get session(): SessionTransport | undefined;
762
+ get resources(): ProjectRuntimeResources | undefined;
763
+ getModule(id: string): ModuleHandle | undefined;
764
+ getMacro(id: string): ParamMacro | undefined;
765
+ snapshot(): ProjectRuntimeSnapshot;
766
+ exportProject(): ModuleProject;
767
+ /** Build/prepare a private candidate. A failed factory, asset, parameter or route leaves the active graph intact. */
768
+ restore(input: unknown, options?: ProjectRestoreOptions): Promise<ProjectRestoreResult>;
769
+ retryMissing(options?: ProjectRestoreOptions): Promise<ProjectRestoreResult>;
770
+ cancelRestore(): void;
771
+ /** Presentation-only mutations preserve all instances, routes, voices and Session state. */
772
+ updateLayout(layout: ProjectLayout): void;
773
+ /** Change the Session's tempo and meter (DEC-077) without rebuilding; timers that follow musical time adjust. */
774
+ updateTempo(tempo: Partial<MusicalTempo>): void;
775
+ /** Replace the control mappings (DEC-076); mappings are data and rebuild nothing. */
776
+ updateMappings(mappings: readonly ProjectMappingRecord[]): void;
777
+ updatePresentation(options: {
778
+ modules?: readonly {
779
+ id: string;
780
+ label?: string;
781
+ }[];
782
+ layout?: ProjectLayout;
783
+ }): void;
784
+ /** Add one explicit edge without recreating playing modules. The backend still validates context/routing. */
785
+ connect(connection: ProjectConnectionRecord): Promise<ProjectRuntimeSnapshot>;
786
+ disconnect(id: string): ProjectRuntimeSnapshot;
787
+ connectModulation(record: ProjectModulationRecord): Promise<ProjectRuntimeSnapshot>;
788
+ disconnectModulation(id: string): ProjectRuntimeSnapshot;
789
+ /**
790
+ * Add one module without rebuilding (DEC-094): every other instance, route
791
+ * and voice, and the Session's state, stay as they are. The record joins a
792
+ * context the project already has; `assets` adds the references it names,
793
+ * and `layout` replaces the layout in the same edit, so the new box has its
794
+ * place. A missing plugin leaves the record unresolved, as a restore does.
795
+ * A failure leaves the graph as it was.
796
+ */
797
+ addModule(record: ProjectModuleRecord, options?: {
798
+ readonly assets?: readonly ProjectAssetReference[];
799
+ readonly layout?: ProjectLayout;
800
+ }): Promise<ProjectRuntimeSnapshot>;
801
+ /**
802
+ * Remove one module without rebuilding (DEC-094), with the cords,
803
+ * modulations, automation and mappings that touch it and its place in the
804
+ * layout (a group left with one member is dissolved); `layout` replaces the layout instead. Everything else keeps
805
+ * playing. A module that owns a context, or that a macro targets, is not
806
+ * removed this way: restore the edited project.
807
+ */
808
+ removeModule(id: string, options?: {
809
+ readonly layout?: ProjectLayout;
810
+ }): ProjectRuntimeSnapshot;
811
+ subscribe(listener: (snapshot: ProjectRuntimeSnapshot) => void): () => void;
812
+ dispose(): void;
813
+ }
814
+ /**
815
+ * Preload a runtime's Session as members join it, and the Session that
816
+ * replaces it after a rebuild (DEC-069, DEC-094). A failure `transient` names
817
+ * is asked again 100 ms later, twenty times at most, before it is reported.
818
+ * It creates no AudioContext of its own and resumes none. The runtime does
819
+ * this itself when it is given `preload`; a host whose runtime was not calls
820
+ * it. Returns the release function.
821
+ */
822
+ declare function keepProjectSessionPreloaded(runtime: ModuleProjectRuntime, options?: ProjectPreloadOptions): () => void;
823
+
824
+ interface ProjectEditorPort {
825
+ readonly id: string;
826
+ readonly label?: string;
827
+ readonly direction: 'input' | 'output';
828
+ readonly kind: ProjectSignalKind;
829
+ /** Present only for a synthetic parameter input. Native plugin port IDs remain unchanged. */
830
+ readonly parameterId?: string;
831
+ }
832
+ interface ProjectEditorModule {
833
+ readonly id: string;
834
+ /** The context the module belongs to; nested components have their own (DEC-076). */
835
+ readonly contextId?: string;
836
+ readonly label: string;
837
+ readonly ports: readonly ProjectEditorPort[];
838
+ readonly position?: {
839
+ readonly x: number;
840
+ readonly y: number;
841
+ };
842
+ /** The box's saved size in canvas pixels, when it was resized. */
843
+ readonly size?: {
844
+ readonly width: number;
845
+ readonly height: number;
846
+ };
847
+ readonly status: 'ready' | 'unresolved';
848
+ readonly diagnostic?: string;
849
+ }
850
+ interface ProjectEditorConnection {
851
+ readonly id: string;
852
+ readonly from: ProjectEndpoint;
853
+ readonly to: ProjectEndpoint;
854
+ readonly mode: 'connect' | 'replace' | 'send' | 'tap' | 'default';
855
+ readonly status: 'connected' | 'unresolved';
856
+ readonly diagnostic?: string;
857
+ readonly editable?: boolean;
858
+ /** The project connection this cord shows, for runtime observation (DEC-078); absent for modulations and default routes. */
859
+ readonly recordId?: string;
860
+ }
861
+ interface ProjectEditorState {
862
+ readonly modules: readonly ProjectEditorModule[];
863
+ readonly connections: readonly ProjectEditorConnection[];
864
+ readonly disabled: boolean;
865
+ }
866
+ interface ProjectEditorConnectRequest {
867
+ readonly from: ProjectEndpoint;
868
+ readonly to: ProjectEndpoint;
869
+ readonly mode: 'connect' | 'replace' | 'send' | 'tap';
870
+ }
871
+ interface ProjectEditorBinding {
872
+ snapshot(): ProjectEditorState;
873
+ connect(connection: ProjectEditorConnectRequest): Promise<void>;
874
+ disconnect(id: string): void;
875
+ moveModule(id: string, position: {
876
+ readonly x: number;
877
+ readonly y: number;
878
+ }): void;
879
+ subscribe(notify: () => void): () => void;
880
+ }
881
+ interface ProjectEditorOptions {
882
+ /** Additive depth in the destination's native unit. Defaults to one unit. */
883
+ readonly modulationDepth?: number;
884
+ }
885
+ /** Structural presenter adapter. It borrows the runtime; creating/unmounting UI owns no graph. */
886
+ declare function createProjectEditorBinding(runtime: ModuleProjectRuntime, options?: ProjectEditorOptions): ProjectEditorBinding;
887
+
888
+ /** Read-only view of one Rack channel. Its ID is the admitted module's ID. */
889
+ interface RackChannel {
890
+ readonly id: string;
891
+ readonly module: ModuleHandle;
892
+ readonly volume: number;
893
+ readonly pan: number;
894
+ readonly muted: boolean;
895
+ readonly solo: boolean;
896
+ }
897
+ interface RackModuleOptions {
898
+ id?: string;
899
+ /** Recipe for the master chain's compatibility slot. */
900
+ effect?: Effect;
901
+ onError?: (error: unknown) => void;
902
+ }
903
+ /**
904
+ * The neutral mixing desk under every domain Rack (DEC-063, DEC-068). Each
905
+ * admitted module gets one channel keyed by its module ID: fader, pan,
906
+ * post-fader InsertChain and a tappable channel output that sums into a real
907
+ * master bus. The master runs its own InsertChain once on the sum. The Rack
908
+ * borrows admitted modules and never disposes them; it holds no Session.
909
+ */
910
+ declare class RackModule implements ModuleHandle {
911
+ #private;
912
+ readonly id: string;
913
+ /** Scope for members: this Rack's registry and admission, the upstream Session. */
914
+ readonly context: ModuleContext;
915
+ constructor(upstream: ModuleContext, options?: RackModuleOptions);
916
+ get disposed(): boolean;
917
+ get params(): ParamSurface;
918
+ get inserts(): InsertChain | undefined;
919
+ /** Prepared master input for explicit audio patching; ownership stays with the Rack. */
920
+ get input(): GainNode | undefined;
921
+ get effect(): Effect | undefined;
922
+ get masterVolume(): number;
923
+ setEffect(effect: Effect | undefined): void;
924
+ setMasterVolume(value: number): void;
925
+ list(): readonly RackChannel[];
926
+ channel(id: string): RackChannel | undefined;
927
+ /** Stable post-fader inserts owned by this Rack channel. */
928
+ channelInserts(id: string): InsertChain | undefined;
929
+ setVolume(id: string, value: number): void;
930
+ setPan(id: string, value: number): void;
931
+ mute(id: string, muted: boolean): void;
932
+ solo(id: string, solo: boolean): void;
933
+ /** `master` (aliases `output`, `main`) or `channel:<module id>` for a post-insert channel tap. */
934
+ getPort(name: string): AudioOutputPort | undefined;
935
+ ports(): readonly ModulePort[];
936
+ prepare(): void;
937
+ /**
938
+ * Follow a republished upstream scope in place (DEC-065): a destination-only
939
+ * change re-routes the prepared master and keeps every channel, level and
940
+ * member. Returns false when the change needs a rebind.
941
+ */
942
+ retarget(next: ModuleContext): boolean;
943
+ /** Give a module's output its own channel. The lease removes only that channel. */
944
+ admit(module: ModuleHandle, port: AudioOutputPort): ConnectionLease;
945
+ subscribe(listener: () => void): () => void;
946
+ dispose(): void;
947
+ }
948
+
949
+ interface ProviderScopeOptions {
950
+ /** ID of the derived child context. */
951
+ id: string;
952
+ /** The context this provider borrows, or undefined at a composition root. */
953
+ parent: ModuleContext | undefined;
954
+ /** The host declared `session="local"`: own a Session even when one is inherited. */
955
+ local?: boolean;
956
+ /** Audio environment created only when there is no parent. */
957
+ audio?: ModuleAudioEnvironmentOptions;
958
+ /** Destination resolver for the root context (ignored when a parent exists). */
959
+ destination?: () => AudioNode | undefined;
960
+ registry?: ModuleRegistry;
961
+ admit?: ModuleAdmission | null;
962
+ target?: ModuleHandle | null;
963
+ /** Options for an owned Session; `now` defaults to the audio environment's clock. */
964
+ session?: SessionTransportOptions & {
965
+ now?: () => number;
966
+ };
967
+ }
968
+ /** A provider's derived context plus the resources it created and must release. */
969
+ interface ProviderScope {
970
+ readonly context: ModuleContext;
971
+ readonly session: ModuleSession;
972
+ /** Present when this provider owns the Session (root or `session="local"`). */
973
+ readonly ownedSession?: SessionTransport;
974
+ /** Present when this provider created the audio environment (no parent). */
975
+ readonly ownedAudio?: ModuleAudioEnvironment;
976
+ /** Dispose the owned Session, then the owned audio environment. Idempotent. */
977
+ dispose(): void;
978
+ }
979
+ /**
980
+ * Session election shared by every provider Element (DEC-068): the outermost
981
+ * provider — a player, Rack or Mixer — owns the Session; nested providers
982
+ * borrow it unless they declare `session="local"`. A root without a parent
983
+ * also creates the audio environment. Creating the scope allocates no audio
984
+ * context; the environment stays lazy.
985
+ */
986
+ declare function createProviderScope(options: ProviderScopeOptions): ProviderScope;
987
+
988
+ /** Shared lifecycle of the sink modules: lazily prepared input, idempotent disposal. */
989
+ declare abstract class AudioSink implements ModuleHandle {
990
+ #private;
991
+ readonly id: string;
992
+ protected readonly environment: ModuleAudioEnvironment;
993
+ constructor(environment: ModuleAudioEnvironment, id: string);
994
+ get disposed(): boolean;
995
+ /** Present after {@link prepare}; producers connect to it. */
996
+ get input(): AudioInputPort | undefined;
997
+ ports(): readonly ModulePort[];
998
+ prepare(): void;
999
+ subscribe(listener: () => void): () => void;
1000
+ dispose(): void;
1001
+ protected abstract createInput(context: BaseAudioContext): AudioNode;
1002
+ protected release(): void;
1003
+ protected notify(): void;
1004
+ }
1005
+ /**
1006
+ * The environment's device output as a sink module. Its input is the context
1007
+ * destination, so every unpatched default route ends here. Device selection
1008
+ * uses `AudioContext.setSinkId` where the browser offers it.
1009
+ */
1010
+ declare class DeviceSink extends AudioSink {
1011
+ constructor(environment: ModuleAudioEnvironment, options?: {
1012
+ id?: string;
1013
+ });
1014
+ get supportsDeviceSelection(): boolean;
1015
+ /** Route the whole environment to another output device; rejects where unsupported. */
1016
+ selectDevice(deviceId: string): Promise<void>;
1017
+ protected createInput(context: BaseAudioContext): AudioNode;
1018
+ }
1019
+ interface RecorderLike {
1020
+ readonly state: string;
1021
+ start(): void;
1022
+ stop(): void;
1023
+ addEventListener(type: 'dataavailable', listener: (event: {
1024
+ data: Blob;
1025
+ }) => void): void;
1026
+ addEventListener(type: 'stop' | 'error', listener: (event: Event) => void): void;
1027
+ }
1028
+ type RecorderConstructor = new (stream: MediaStream, options?: {
1029
+ mimeType?: string;
1030
+ }) => RecorderLike;
1031
+ interface CaptureSinkOptions {
1032
+ id?: string;
1033
+ mimeType?: string;
1034
+ /** Injected recorder for environments without `MediaRecorder`. */
1035
+ recorder?: RecorderConstructor;
1036
+ }
1037
+ /**
1038
+ * Record whatever producers connect to its input. Capture uses a
1039
+ * MediaStream destination in the same context, so it never opens a device or
1040
+ * a second AudioContext. `stop()` resolves with the encoded take.
1041
+ */
1042
+ declare class CaptureSink extends AudioSink {
1043
+ #private;
1044
+ constructor(environment: ModuleAudioEnvironment, options?: CaptureSinkOptions);
1045
+ get recording(): boolean;
1046
+ start(): void;
1047
+ /** Finish the current take. */
1048
+ stop(): Promise<Blob>;
1049
+ protected createInput(context: BaseAudioContext): AudioNode;
1050
+ protected release(): void;
1051
+ }
1052
+ interface OfflineEnvironmentOptions {
1053
+ sampleRate: number;
1054
+ /** Rendered length in seconds; ignored when `length` is given. */
1055
+ durationSeconds?: number;
1056
+ /** Rendered length in sample frames. */
1057
+ length?: number;
1058
+ channels?: number;
1059
+ /** Injected constructor for environments without `OfflineAudioContext`. */
1060
+ create?: (channels: number, length: number, sampleRate: number) => OfflineAudioContext;
1061
+ /**
1062
+ * Rendered seconds between scheduler ticks (default 0.025). Lookahead
1063
+ * schedulers in this environment are ticked at each step while rendering.
1064
+ */
1065
+ tickSeconds?: number;
1066
+ }
1067
+ /** An offline environment for realizing a module graph and rendering it once. */
1068
+ interface OfflineModuleEnvironment {
1069
+ readonly environment: ModuleAudioEnvironment;
1070
+ readonly context: OfflineAudioContext;
1071
+ /** Render everything connected to the offline destination, ticking schedulers in rendered time. */
1072
+ render(): Promise<AudioBuffer>;
1073
+ }
1074
+ /**
1075
+ * Whether a context belongs to an offline module environment (DEC-068).
1076
+ * Engines that otherwise require a live AudioContext accept these: the
1077
+ * environment presents them as live until rendering and ticks their
1078
+ * schedulers in rendered time.
1079
+ */
1080
+ declare function isOfflineModuleContext(context: BaseAudioContext | undefined): boolean;
1081
+ /**
1082
+ * Create the offline audio environment that render and export paths realize
1083
+ * module graphs in. The environment owns the offline context; modules borrow
1084
+ * it exactly as they borrow a live environment. Until rendering starts the
1085
+ * context reports `running` and `resume()` resolves, so modules prepare and
1086
+ * start exactly as they do live; rendering then ticks every lookahead
1087
+ * scheduler at each rendered step.
1088
+ */
1089
+ declare function createOfflineModuleEnvironment(options: OfflineEnvironmentOptions): OfflineModuleEnvironment;
1090
+
1091
+ interface ModuleGraphRenderOptions extends OfflineEnvironmentOptions {
1092
+ /** Root scope ID. Default `offline`. */
1093
+ id?: string;
1094
+ /** Session position the render starts from, in Session seconds. Default 0. */
1095
+ startSeconds?: number;
1096
+ /**
1097
+ * Build the graph in the offline scope: create modules (players, Racks,
1098
+ * effects) with this context, exactly as live. Return a cleanup to run
1099
+ * after rendering; modules left registered are not disposed for you.
1100
+ */
1101
+ build(scope: ModuleContext): void | (() => void) | Promise<void | (() => void)>;
1102
+ }
1103
+ /**
1104
+ * Realize a whole module graph offline (DEC-068): the graph is built in an
1105
+ * offline scope with its own Session, started on that Session, and rendered
1106
+ * once. Routes, Racks, inserts and Session scheduling are the live ones;
1107
+ * lookahead schedulers are ticked in rendered time, so the render runs faster
1108
+ * than real time without dropping events. The Session is disposed afterwards.
1109
+ */
1110
+ declare function renderModuleGraph(options: ModuleGraphRenderOptions): Promise<AudioBuffer>;
1111
+
1112
+ export { AudioInputPort, AudioOutputPort, type BoundaryInlet, type BoundaryKind, type BoundaryModuleOptions, type BoundaryOutlet, COMPONENT_BOUNDARY, CapabilityKey, CaptureSink, type CaptureSinkOptions, type ChannelOptions, ChannelPack, ChannelUnpack, type ComponentBoundary, ConnectionLease, ControlEnvelope, type ControlEnvelopeOptions, type ControlEvent, ControlLFO, type ControlLFOOptions, type ControlMappingOptions, ControlMappings, ControlModule, ControlSignal, DeviceSink, EnvelopeFollower, type EnvelopeFollowerOptions, GraphModule, GraphModuleOptions, type HoldableClock, InletModule, JsonValue, MAX_MC_CHANNELS, type MappableParameter, Message, MessageDebugger, MessageInputPort, MessageOutputPort, type MessageProbeEvent, ModuleAdmission, ModuleAudioEnvironment, ModuleAudioEnvironmentOptions, type ModuleConformanceFailure, type ModuleConformanceOptions, type ModuleConformanceReport, type ModuleConformanceSubject, ModuleContext, ModuleEnvironment, type ModuleGraphRenderOptions, ModuleHandle, ModuleOptionsJson, ModulePort, ModuleProject, ModuleProjectRuntime, ModuleRegistry, NestedComponent, type NestedComponentOptions, NodesModule, type NodesModuleOptions, NoteEvent, NoteInputPort, NoteMaker, type NoteMakerOptions, NoteOutputPort, type NoteProbeEvent, type ObservableRuntime, type OfflineEnvironmentOptions, type OfflineModuleEnvironment, OutletModule, POLY_VOICE, type PadNode, ParamDescriptor, ParamHandle, ParamMacro, type ParamMacroTarget, ParamSurface, PolyComponent, type PolyComponentOptions, type PolyVoice, PresetBank, PresetModule, type PresetModuleOptions, type PresetValues, type ProbeEvent, ProjectAssetReference, ProjectConnectionRecord, type ProjectEditorBinding, type ProjectEditorConnectRequest, type ProjectEditorConnection, type ProjectEditorModule, type ProjectEditorOptions, type ProjectEditorPort, type ProjectEditorState, ProjectEndpoint, ProjectJson, ProjectLayout, ProjectMappingRecord, ProjectMappingSource, ProjectModulationRecord, ProjectModuleRecord, ProjectParamEndpoint, ProjectPluginFactory, ProjectPluginLookup, ProjectPluginRegistry, ProjectPreloadOptions, ProjectRestoreOptions, ProjectRestoreResult, ProjectRuntimeOptions, ProjectRuntimeResources, ProjectRuntimeSnapshot, ProjectSignalKind, type ProviderScope, type ProviderScopeOptions, type RackChannel, RackModule, type RackModuleOptions, type SignalProbe, SourceRelay, VoiceAllocator, type VoiceAssignment, VoiceNotes, type VoiceSteal, WAM_MODULE, type WamConstructorLike, type WamInstanceLike, type WamModule, type WamNodeLike, type WamParameterInfoLike, type WamPluginOptions, type Watchpoint, type WatchpointHit, applyParameters, captureParameters, checkModuleConformance, controlFraction, controlSource, copyProjectJson, createOfflineModuleEnvironment, createProjectEditorBinding, createProviderScope, createStructurePlugins, describeSource, isOfflineModuleContext, keepProjectSessionPreloaded, multichannelPlugin, nodeWeights, parseModuleProject, renderModuleGraph, serializeModuleProject, sourceMatches, sourceOrigin, wamPlugin };