@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.
- package/LICENSE +202 -21
- package/NOTICE +2 -0
- package/README.md +138 -101
- package/dist/audio-context.cjs.map +1 -1
- package/dist/build-receipt.json +3 -3
- package/dist/chunk-27LH6QLZ.cjs +277 -0
- package/dist/chunk-27LH6QLZ.cjs.map +1 -0
- package/dist/chunk-3INDOVUC.cjs.map +1 -1
- package/dist/chunk-3RR2VIKA.js +393 -0
- package/dist/chunk-3RR2VIKA.js.map +1 -0
- package/dist/chunk-3YTKIKKX.cjs +378 -0
- package/dist/chunk-3YTKIKKX.cjs.map +1 -0
- package/dist/chunk-4RG4WQKC.js +360 -0
- package/dist/chunk-4RG4WQKC.js.map +1 -0
- package/dist/chunk-5AHVQXTF.cjs +620 -0
- package/dist/chunk-5AHVQXTF.cjs.map +1 -0
- package/dist/chunk-624KWJWZ.js +170 -0
- package/dist/chunk-624KWJWZ.js.map +1 -0
- package/dist/chunk-6HGFEKD3.cjs +851 -0
- package/dist/chunk-6HGFEKD3.cjs.map +1 -0
- package/dist/chunk-7ZTZZ5PN.cjs.map +1 -1
- package/dist/chunk-ALWV4P7D.js +726 -0
- package/dist/chunk-ALWV4P7D.js.map +1 -0
- package/dist/chunk-BADJJ6DV.cjs +143 -0
- package/dist/chunk-BADJJ6DV.cjs.map +1 -0
- package/dist/chunk-C3LMS36L.cjs +393 -0
- package/dist/chunk-C3LMS36L.cjs.map +1 -0
- package/dist/chunk-C3YWUZW3.cjs.map +1 -1
- package/dist/chunk-CR6OUWBJ.cjs +726 -0
- package/dist/chunk-CR6OUWBJ.cjs.map +1 -0
- package/dist/chunk-CYWDZLWC.js +2141 -0
- package/dist/chunk-CYWDZLWC.js.map +1 -0
- package/dist/chunk-DDOGX2D5.js +378 -0
- package/dist/chunk-DDOGX2D5.js.map +1 -0
- package/dist/chunk-DVN6E5U3.js +620 -0
- package/dist/chunk-DVN6E5U3.js.map +1 -0
- package/dist/chunk-EURMRU2S.js +208 -0
- package/dist/chunk-EURMRU2S.js.map +1 -0
- package/dist/chunk-EXDCK2VL.cjs +20 -0
- package/dist/chunk-EXDCK2VL.cjs.map +1 -0
- package/dist/chunk-G5EIUP52.js +114 -0
- package/dist/chunk-G5EIUP52.js.map +1 -0
- package/dist/chunk-GB4DGKLZ.js +143 -0
- package/dist/chunk-GB4DGKLZ.js.map +1 -0
- package/dist/chunk-GPOEAYOW.js +2147 -0
- package/dist/chunk-GPOEAYOW.js.map +1 -0
- package/dist/chunk-I4YMA5VM.cjs +120 -0
- package/dist/chunk-I4YMA5VM.cjs.map +1 -0
- package/dist/chunk-IVWHMDCB.cjs +4383 -0
- package/dist/chunk-IVWHMDCB.cjs.map +1 -0
- package/dist/chunk-JFCBJMA7.cjs +2147 -0
- package/dist/chunk-JFCBJMA7.cjs.map +1 -0
- package/dist/chunk-JLVSAZ3K.cjs +813 -0
- package/dist/chunk-JLVSAZ3K.cjs.map +1 -0
- package/dist/chunk-K7FYH6UG.cjs +208 -0
- package/dist/chunk-K7FYH6UG.cjs.map +1 -0
- package/dist/chunk-L4MYCETM.cjs +970 -0
- package/dist/chunk-L4MYCETM.cjs.map +1 -0
- package/dist/chunk-MNCMYNYL.js +970 -0
- package/dist/chunk-MNCMYNYL.js.map +1 -0
- package/dist/chunk-NT2BZ3QM.js +120 -0
- package/dist/chunk-NT2BZ3QM.js.map +1 -0
- package/dist/chunk-O7SA5GLC.js +277 -0
- package/dist/chunk-O7SA5GLC.js.map +1 -0
- package/dist/chunk-OCKAHITL.cjs +548 -0
- package/dist/chunk-OCKAHITL.cjs.map +1 -0
- package/dist/{chunk-HOKRTYPV.js → chunk-OPBHDUZK.js} +39 -1
- package/dist/chunk-OPBHDUZK.js.map +1 -0
- package/dist/chunk-OTXYWCLA.js +206 -0
- package/dist/chunk-OTXYWCLA.js.map +1 -0
- package/dist/chunk-P6ZA63J7.js +548 -0
- package/dist/chunk-P6ZA63J7.js.map +1 -0
- package/dist/chunk-QLF3BOST.js +20 -0
- package/dist/chunk-QLF3BOST.js.map +1 -0
- package/dist/chunk-RCWFRZDR.js +4383 -0
- package/dist/chunk-RCWFRZDR.js.map +1 -0
- package/dist/chunk-RZBLPM3L.cjs +206 -0
- package/dist/chunk-RZBLPM3L.cjs.map +1 -0
- package/dist/chunk-TA3TNJZU.cjs +360 -0
- package/dist/chunk-TA3TNJZU.cjs.map +1 -0
- package/dist/chunk-TZSRPTQL.cjs +2141 -0
- package/dist/chunk-TZSRPTQL.cjs.map +1 -0
- package/dist/chunk-UMTPJ76S.cjs.map +1 -1
- package/dist/chunk-UY77FXDW.js +813 -0
- package/dist/chunk-UY77FXDW.js.map +1 -0
- package/dist/chunk-VFU3S7OC.js +851 -0
- package/dist/chunk-VFU3S7OC.js.map +1 -0
- package/dist/chunk-VY6WWZSW.cjs.map +1 -1
- package/dist/chunk-WN5DZOVT.cjs +170 -0
- package/dist/chunk-WN5DZOVT.cjs.map +1 -0
- package/dist/{chunk-HZQX4J2J.cjs → chunk-WOPW6WLR.cjs} +40 -2
- package/dist/chunk-WOPW6WLR.cjs.map +1 -0
- package/dist/chunk-XBSIYUHM.cjs +114 -0
- package/dist/chunk-XBSIYUHM.cjs.map +1 -0
- package/dist/chunk-ZMU72HJS.cjs.map +1 -1
- package/dist/context-DSa0ymyN.d.cts +664 -0
- package/dist/context-DaxfAg3b.d.ts +664 -0
- package/dist/effect-chain-Cu03O5Y0.d.ts +91 -0
- package/dist/effect-chain-Do75T7uK.d.cts +91 -0
- package/dist/effect.cjs +16 -1
- package/dist/effect.cjs.map +1 -1
- package/dist/effect.d.cts +56 -14
- package/dist/effect.d.ts +56 -14
- package/dist/effect.js +16 -1
- package/dist/elements.cjs +37 -2
- package/dist/elements.cjs.map +1 -1
- package/dist/elements.d.cts +197 -8
- package/dist/elements.d.ts +197 -8
- package/dist/elements.js +36 -1
- package/dist/events.cjs.map +1 -1
- package/dist/index.cjs +556 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -5
- package/dist/index.d.ts +17 -5
- package/dist/index.js +567 -20
- package/dist/message.cjs +104 -0
- package/dist/message.cjs.map +1 -0
- package/dist/message.d.cts +738 -0
- package/dist/message.d.ts +738 -0
- package/dist/message.js +104 -0
- package/dist/meter.cjs +2 -2
- package/dist/meter.cjs.map +1 -1
- package/dist/meter.d.cts +9 -1
- package/dist/meter.d.ts +9 -1
- package/dist/meter.js +1 -1
- package/dist/module-control-C25BMtH7.d.ts +61 -0
- package/dist/module-control-yH6nTJM9.d.cts +61 -0
- package/dist/module-plugin-BnPmq1VP.d.ts +198 -0
- package/dist/module-plugin-CHb-5W0Y.d.cts +198 -0
- package/dist/module.cjs +263 -0
- package/dist/module.cjs.map +1 -0
- package/dist/module.d.cts +1112 -0
- package/dist/module.d.ts +1112 -0
- package/dist/module.js +263 -0
- package/dist/parameter-DwQzFmBR.d.cts +172 -0
- package/dist/parameter-DwQzFmBR.d.ts +172 -0
- package/dist/player.cjs.map +1 -1
- package/dist/processor-worklet.cjs +18 -0
- package/dist/processor-worklet.cjs.map +1 -0
- package/dist/processor-worklet.d.cts +166 -0
- package/dist/processor-worklet.d.ts +166 -0
- package/dist/processor-worklet.js +18 -0
- package/dist/processor-worklet.js.map +1 -0
- package/dist/processor.cjs +51 -0
- package/dist/processor.cjs.map +1 -0
- package/dist/processor.d.cts +397 -0
- package/dist/processor.d.ts +397 -0
- package/dist/processor.js +51 -0
- package/dist/processor.js.map +1 -0
- package/dist/project-types-BU4awMnL.d.ts +323 -0
- package/dist/project-types-DufCV8Ma.d.cts +323 -0
- package/dist/ring-C-i9N90a.d.cts +139 -0
- package/dist/ring-DkcMt2Eg.d.ts +139 -0
- package/dist/sequence.cjs +68 -0
- package/dist/sequence.cjs.map +1 -0
- package/dist/sequence.d.cts +303 -0
- package/dist/sequence.d.ts +303 -0
- package/dist/sequence.js +68 -0
- package/dist/sequence.js.map +1 -0
- package/dist/session.cjs +16 -0
- package/dist/session.cjs.map +1 -0
- package/dist/session.d.cts +407 -0
- package/dist/session.d.ts +407 -0
- package/dist/session.js +16 -0
- package/dist/session.js.map +1 -0
- package/dist/tick.cjs.map +1 -1
- package/dist/transport.cjs +50 -2
- package/dist/transport.cjs.map +1 -1
- package/dist/transport.d.cts +145 -1
- package/dist/transport.d.ts +145 -1
- package/dist/transport.js +51 -3
- package/dist/worker.cjs.map +1 -1
- package/package.json +62 -11
- package/dist/chunk-53YD73OY.js +0 -162
- package/dist/chunk-53YD73OY.js.map +0 -1
- package/dist/chunk-BR63OD53.cjs +0 -1
- package/dist/chunk-BR63OD53.cjs.map +0 -1
- package/dist/chunk-HOKRTYPV.js.map +0 -1
- package/dist/chunk-HZQX4J2J.cjs.map +0 -1
- package/dist/chunk-JNXB74G3.cjs +0 -987
- package/dist/chunk-JNXB74G3.cjs.map +0 -1
- package/dist/chunk-SM5YPDDI.cjs +0 -162
- package/dist/chunk-SM5YPDDI.cjs.map +0 -1
- package/dist/chunk-TEM2I2NN.js +0 -1
- package/dist/chunk-VVZX7DQ6.cjs +0 -254
- package/dist/chunk-VVZX7DQ6.cjs.map +0 -1
- package/dist/chunk-WNFGDB7B.js +0 -254
- package/dist/chunk-WNFGDB7B.js.map +0 -1
- package/dist/chunk-XBJBY4J5.js +0 -987
- package/dist/chunk-XBJBY4J5.js.map +0 -1
- package/dist/sync.cjs +0 -12
- package/dist/sync.cjs.map +0 -1
- package/dist/sync.d.cts +0 -304
- package/dist/sync.d.ts +0 -304
- package/dist/sync.js +0 -12
- /package/dist/{chunk-TEM2I2NN.js.map → message.js.map} +0 -0
- /package/dist/{sync.js.map → module.js.map} +0 -0
|
@@ -0,0 +1,2141 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ControlModule,
|
|
3
|
+
decodeOsc,
|
|
4
|
+
encodeOsc,
|
|
5
|
+
isOscBundle
|
|
6
|
+
} from "./chunk-624KWJWZ.js";
|
|
7
|
+
import {
|
|
8
|
+
GraphModule,
|
|
9
|
+
atomsOf,
|
|
10
|
+
bang,
|
|
11
|
+
floatAtom,
|
|
12
|
+
formatMessage,
|
|
13
|
+
intAtom,
|
|
14
|
+
isNumberAtom,
|
|
15
|
+
message,
|
|
16
|
+
messageFromAtoms,
|
|
17
|
+
modulePlugin,
|
|
18
|
+
numberOf,
|
|
19
|
+
numberedPort,
|
|
20
|
+
parseMessage,
|
|
21
|
+
symbolAtom
|
|
22
|
+
} from "./chunk-ALWV4P7D.js";
|
|
23
|
+
import {
|
|
24
|
+
nextGridTime,
|
|
25
|
+
timeValueSeconds,
|
|
26
|
+
timeValueTicks
|
|
27
|
+
} from "./chunk-4RG4WQKC.js";
|
|
28
|
+
import {
|
|
29
|
+
__privateAdd,
|
|
30
|
+
__privateGet,
|
|
31
|
+
__privateMethod,
|
|
32
|
+
__privateSet,
|
|
33
|
+
__privateWrapper
|
|
34
|
+
} from "./chunk-PXG64RU4.js";
|
|
35
|
+
|
|
36
|
+
// src/message/expr.ts
|
|
37
|
+
var FUNCTIONS = {
|
|
38
|
+
abs: { arity: [1, 1], apply: ([a]) => ({ value: Math.abs(a.value), float: a.float }) },
|
|
39
|
+
min: { arity: [2, 2], apply: ([a, b]) => ({ value: Math.min(a.value, b.value), float: a.float || b.float }) },
|
|
40
|
+
max: { arity: [2, 2], apply: ([a, b]) => ({ value: Math.max(a.value, b.value), float: a.float || b.float }) },
|
|
41
|
+
pow: { arity: [2, 2], apply: ([a, b]) => ({ value: a.value ** b.value, float: true }) },
|
|
42
|
+
sqrt: { arity: [1, 1], apply: ([a]) => ({ value: Math.sqrt(a.value), float: true }) },
|
|
43
|
+
exp: { arity: [1, 1], apply: ([a]) => ({ value: Math.exp(a.value), float: true }) },
|
|
44
|
+
log: { arity: [1, 1], apply: ([a]) => ({ value: Math.log(a.value), float: true }) },
|
|
45
|
+
log10: { arity: [1, 1], apply: ([a]) => ({ value: Math.log10(a.value), float: true }) },
|
|
46
|
+
sin: { arity: [1, 1], apply: ([a]) => ({ value: Math.sin(a.value), float: true }) },
|
|
47
|
+
cos: { arity: [1, 1], apply: ([a]) => ({ value: Math.cos(a.value), float: true }) },
|
|
48
|
+
tan: { arity: [1, 1], apply: ([a]) => ({ value: Math.tan(a.value), float: true }) },
|
|
49
|
+
atan2: { arity: [2, 2], apply: ([a, b]) => ({ value: Math.atan2(a.value, b.value), float: true }) },
|
|
50
|
+
floor: { arity: [1, 1], apply: ([a]) => ({ value: Math.floor(a.value), float: true }) },
|
|
51
|
+
ceil: { arity: [1, 1], apply: ([a]) => ({ value: Math.ceil(a.value), float: true }) },
|
|
52
|
+
round: { arity: [1, 1], apply: ([a]) => ({ value: Math.round(a.value), float: true }) },
|
|
53
|
+
int: { arity: [1, 1], apply: ([a]) => ({ value: Math.trunc(a.value), float: false }) },
|
|
54
|
+
float: { arity: [1, 1], apply: ([a]) => ({ value: a.value, float: true }) },
|
|
55
|
+
random: { arity: [2, 2], apply: ([a, b], random3) => ({ value: Math.floor(a.value + random3() * (b.value - a.value)), float: false }) }
|
|
56
|
+
};
|
|
57
|
+
var BINARY = {
|
|
58
|
+
"||": 1,
|
|
59
|
+
"&&": 2,
|
|
60
|
+
"|": 3,
|
|
61
|
+
"^": 4,
|
|
62
|
+
"&": 5,
|
|
63
|
+
"==": 6,
|
|
64
|
+
"!=": 6,
|
|
65
|
+
"<": 7,
|
|
66
|
+
"<=": 7,
|
|
67
|
+
">": 7,
|
|
68
|
+
">=": 7,
|
|
69
|
+
"<<": 8,
|
|
70
|
+
">>": 8,
|
|
71
|
+
"+": 9,
|
|
72
|
+
"-": 9,
|
|
73
|
+
"*": 10,
|
|
74
|
+
"/": 10,
|
|
75
|
+
"%": 10,
|
|
76
|
+
"**": 11
|
|
77
|
+
};
|
|
78
|
+
function tokenize(source) {
|
|
79
|
+
const tokens = [];
|
|
80
|
+
const pattern = /\s*(\$[if][1-9]|\d+\.\d*(?:[eE][-+]?\d+)?|\.\d+(?:[eE][-+]?\d+)?|\d+(?:[eE][-+]?\d+)?|[A-Za-z_][A-Za-z0-9_]*|\*\*|<<|>>|<=|>=|==|!=|&&|\|\||[-+*/%()<>!~&|^,?:])/y;
|
|
81
|
+
let index = 0;
|
|
82
|
+
while (index < source.length) {
|
|
83
|
+
if (/^\s*$/.test(source.slice(index))) break;
|
|
84
|
+
pattern.lastIndex = index;
|
|
85
|
+
const match = pattern.exec(source);
|
|
86
|
+
if (!match) throw new SyntaxError(`expr: cannot read "${source.slice(index).trim()}".`);
|
|
87
|
+
tokens.push(match[1]);
|
|
88
|
+
index = pattern.lastIndex;
|
|
89
|
+
}
|
|
90
|
+
return tokens;
|
|
91
|
+
}
|
|
92
|
+
function compileExpr(source) {
|
|
93
|
+
const tokens = tokenize(source);
|
|
94
|
+
if (!tokens.length) throw new SyntaxError("expr: the expression is empty.");
|
|
95
|
+
let position = 0;
|
|
96
|
+
let inlets = 1;
|
|
97
|
+
const peek = () => tokens[position];
|
|
98
|
+
const take = (expected) => {
|
|
99
|
+
const token = tokens[position];
|
|
100
|
+
if (token === void 0 || expected !== void 0 && token !== expected) {
|
|
101
|
+
throw new SyntaxError(`expr: expected ${expected ?? "a value"}${token === void 0 ? " at the end" : ` but found "${token}"`}.`);
|
|
102
|
+
}
|
|
103
|
+
position++;
|
|
104
|
+
return token;
|
|
105
|
+
};
|
|
106
|
+
const primary = () => {
|
|
107
|
+
const token = take();
|
|
108
|
+
if (token === "(") {
|
|
109
|
+
const inner = conditional();
|
|
110
|
+
take(")");
|
|
111
|
+
return inner;
|
|
112
|
+
}
|
|
113
|
+
if (token === "-" || token === "!" || token === "~" || token === "+") return { kind: "unary", operator: token, operand: unary() };
|
|
114
|
+
if (/^\$[if][1-9]$/.test(token)) {
|
|
115
|
+
const index = Number(token[2]) - 1;
|
|
116
|
+
inlets = Math.max(inlets, index + 1);
|
|
117
|
+
return { kind: "inlet", index, float: token[1] === "f" };
|
|
118
|
+
}
|
|
119
|
+
if (/^[\d.]/.test(token)) return { kind: "number", value: Number(token), float: /[.eE]/.test(token) };
|
|
120
|
+
if (/^[A-Za-z_]/.test(token)) {
|
|
121
|
+
if (token === "pi") return { kind: "number", value: Math.PI, float: true };
|
|
122
|
+
const definition = FUNCTIONS[token];
|
|
123
|
+
if (!definition) throw new SyntaxError(`expr: no function named ${token}.`);
|
|
124
|
+
take("(");
|
|
125
|
+
const args = [];
|
|
126
|
+
if (peek() !== ")") {
|
|
127
|
+
args.push(conditional());
|
|
128
|
+
while (peek() === ",") {
|
|
129
|
+
take(",");
|
|
130
|
+
args.push(conditional());
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
take(")");
|
|
134
|
+
if (args.length < definition.arity[0] || args.length > definition.arity[1]) throw new SyntaxError(`expr: ${token} takes ${definition.arity[0]} argument${definition.arity[0] === 1 ? "" : "s"}.`);
|
|
135
|
+
return { kind: "call", name: token, args };
|
|
136
|
+
}
|
|
137
|
+
throw new SyntaxError(`expr: unexpected "${token}".`);
|
|
138
|
+
};
|
|
139
|
+
const unary = () => primary();
|
|
140
|
+
const binary = (minimum) => {
|
|
141
|
+
let left = unary();
|
|
142
|
+
for (; ; ) {
|
|
143
|
+
const operator = peek();
|
|
144
|
+
const precedence = operator === void 0 ? void 0 : BINARY[operator];
|
|
145
|
+
if (precedence === void 0 || precedence < minimum) return left;
|
|
146
|
+
take();
|
|
147
|
+
const right = binary(operator === "**" ? precedence : precedence + 1);
|
|
148
|
+
left = { kind: "binary", operator, left, right };
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
const conditional = () => {
|
|
152
|
+
const test = binary(1);
|
|
153
|
+
if (peek() !== "?") return test;
|
|
154
|
+
take("?");
|
|
155
|
+
const then = conditional();
|
|
156
|
+
take(":");
|
|
157
|
+
return { kind: "conditional", test, then, otherwise: conditional() };
|
|
158
|
+
};
|
|
159
|
+
const tree = conditional();
|
|
160
|
+
if (position < tokens.length) throw new SyntaxError(`expr: unexpected "${tokens[position]}".`);
|
|
161
|
+
const evaluate = (node, inputs, random3) => {
|
|
162
|
+
switch (node.kind) {
|
|
163
|
+
case "number":
|
|
164
|
+
return { value: node.value, float: node.float };
|
|
165
|
+
case "inlet": {
|
|
166
|
+
const raw = inputs[node.index] ?? 0;
|
|
167
|
+
return node.float ? { value: raw, float: true } : { value: Math.trunc(raw), float: false };
|
|
168
|
+
}
|
|
169
|
+
case "unary": {
|
|
170
|
+
const operand = evaluate(node.operand, inputs, random3);
|
|
171
|
+
if (node.operator === "-") return { value: -operand.value, float: operand.float };
|
|
172
|
+
if (node.operator === "+") return operand;
|
|
173
|
+
if (node.operator === "!") return { value: operand.value ? 0 : 1, float: false };
|
|
174
|
+
return { value: ~Math.trunc(operand.value), float: false };
|
|
175
|
+
}
|
|
176
|
+
case "conditional":
|
|
177
|
+
return evaluate(node.test, inputs, random3).value ? evaluate(node.then, inputs, random3) : evaluate(node.otherwise, inputs, random3);
|
|
178
|
+
case "call":
|
|
179
|
+
return FUNCTIONS[node.name].apply(node.args.map((arg) => evaluate(arg, inputs, random3)), random3);
|
|
180
|
+
case "binary": {
|
|
181
|
+
const a = evaluate(node.left, inputs, random3), b = evaluate(node.right, inputs, random3);
|
|
182
|
+
const float = a.float || b.float;
|
|
183
|
+
const int = (value) => ({ value: Math.trunc(value), float: false });
|
|
184
|
+
switch (node.operator) {
|
|
185
|
+
case "+":
|
|
186
|
+
return { value: a.value + b.value, float };
|
|
187
|
+
case "-":
|
|
188
|
+
return { value: a.value - b.value, float };
|
|
189
|
+
case "*":
|
|
190
|
+
return { value: a.value * b.value, float };
|
|
191
|
+
case "/":
|
|
192
|
+
return float ? { value: a.value / b.value, float } : b.value === 0 ? { value: 0, float } : int(a.value / b.value);
|
|
193
|
+
case "%":
|
|
194
|
+
return float ? { value: a.value % b.value, float } : b.value === 0 ? { value: 0, float } : int(a.value % b.value);
|
|
195
|
+
case "**":
|
|
196
|
+
return { value: a.value ** b.value, float: float || b.value < 0 };
|
|
197
|
+
case "<":
|
|
198
|
+
return { value: Number(a.value < b.value), float: false };
|
|
199
|
+
case "<=":
|
|
200
|
+
return { value: Number(a.value <= b.value), float: false };
|
|
201
|
+
case ">":
|
|
202
|
+
return { value: Number(a.value > b.value), float: false };
|
|
203
|
+
case ">=":
|
|
204
|
+
return { value: Number(a.value >= b.value), float: false };
|
|
205
|
+
case "==":
|
|
206
|
+
return { value: Number(a.value === b.value), float: false };
|
|
207
|
+
case "!=":
|
|
208
|
+
return { value: Number(a.value !== b.value), float: false };
|
|
209
|
+
case "&&":
|
|
210
|
+
return { value: Number(Boolean(a.value) && Boolean(b.value)), float: false };
|
|
211
|
+
case "||":
|
|
212
|
+
return { value: Number(Boolean(a.value) || Boolean(b.value)), float: false };
|
|
213
|
+
case "&":
|
|
214
|
+
return int(Math.trunc(a.value) & Math.trunc(b.value));
|
|
215
|
+
case "|":
|
|
216
|
+
return int(Math.trunc(a.value) | Math.trunc(b.value));
|
|
217
|
+
case "^":
|
|
218
|
+
return int(Math.trunc(a.value) ^ Math.trunc(b.value));
|
|
219
|
+
case "<<":
|
|
220
|
+
return int(Math.trunc(a.value) << Math.trunc(b.value));
|
|
221
|
+
default:
|
|
222
|
+
return int(Math.trunc(a.value) >> Math.trunc(b.value));
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
return Object.freeze({
|
|
228
|
+
inlets,
|
|
229
|
+
evaluate: (inputs, random3 = Math.random) => {
|
|
230
|
+
const result = evaluate(tree, inputs, random3);
|
|
231
|
+
return Number.isFinite(result.value) ? result : { value: 0, float: result.float };
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// src/message/functions.ts
|
|
237
|
+
function atomOf(value, float = false) {
|
|
238
|
+
if (typeof value === "string") return symbolAtom(value);
|
|
239
|
+
return float || !Number.isInteger(value) ? floatAtom(value) : intAtom(value);
|
|
240
|
+
}
|
|
241
|
+
var isValue = (value) => typeof value === "string" || typeof value === "number" && Number.isFinite(value);
|
|
242
|
+
var sameAtom = (a, b) => !!a && !!b && (isNumberAtom(a) && isNumberAtom(b) ? a.value === b.value : a.type === b.type && JSON.stringify(a.value) === JSON.stringify(b.value));
|
|
243
|
+
var textOf = (atom) => formatMessage(messageFromAtoms([atom]));
|
|
244
|
+
var numberMessage = (value, float, time) => float ? message("float", [floatAtom(value)], time) : message("int", [intAtom(Math.round(value))], time);
|
|
245
|
+
var record = (input) => input && typeof input === "object" && !Array.isArray(input) ? input : {};
|
|
246
|
+
var finite = (value) => typeof value === "number" && Number.isFinite(value);
|
|
247
|
+
function values(name, key, input, what) {
|
|
248
|
+
if (!Array.isArray(input) || !input.length || !input.every(isValue)) throw new TypeError(`${name} needs ${what} in "${key}".`);
|
|
249
|
+
return Object.freeze([...input]);
|
|
250
|
+
}
|
|
251
|
+
var _options;
|
|
252
|
+
var FunctionModule = class extends GraphModule {
|
|
253
|
+
constructor(fn, init = {}) {
|
|
254
|
+
super(fn.module.type, init);
|
|
255
|
+
__privateAdd(this, _options);
|
|
256
|
+
const options = __privateSet(this, _options, fn.module.options(init.options ?? {}));
|
|
257
|
+
const holder = {};
|
|
258
|
+
this.inputs = Object.freeze(Object.fromEntries(fn.module.inputs(options).map((spec, index) => [spec.id, this.input(spec.id, spec.label, (value) => holder.instance?.receive(index, value))])));
|
|
259
|
+
const outputs = fn.module.outputs(options).map((spec) => this.output(spec.id, spec.label));
|
|
260
|
+
this.outputs = Object.freeze(Object.fromEntries(outputs.map((port2) => [port2.id, port2])));
|
|
261
|
+
holder.instance = fn.module.bind(options, {
|
|
262
|
+
send: (index, value) => {
|
|
263
|
+
if (!this.disposed) outputs[index]?.send(value);
|
|
264
|
+
},
|
|
265
|
+
random: init.random ?? Math.random,
|
|
266
|
+
print: init.print ?? ((name, text) => console.log(`${name}: ${text}`))
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
/** The options it was made with. Operands stored through an input are not saved. */
|
|
270
|
+
get options() {
|
|
271
|
+
return __privateGet(this, _options);
|
|
272
|
+
}
|
|
273
|
+
exportOptions() {
|
|
274
|
+
return __privateGet(this, _options);
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
_options = new WeakMap();
|
|
278
|
+
function functionModule(fn, init = {}) {
|
|
279
|
+
return new FunctionModule(fn, init);
|
|
280
|
+
}
|
|
281
|
+
var bind = (fn, module) => Object.freeze(Object.assign(fn, { module: Object.freeze(module) }));
|
|
282
|
+
var port = (id, label) => ({ id, label });
|
|
283
|
+
var numbered = (direction, labels) => labels.map((label, index) => port(numberedPort(direction, index), label));
|
|
284
|
+
var scale = bind(function scale2(value, range) {
|
|
285
|
+
const span = range.inHigh - range.inLow;
|
|
286
|
+
const fraction = span === 0 ? 0 : (value - range.inLow) / span;
|
|
287
|
+
const exponent = range.exponent ?? 1;
|
|
288
|
+
const shaped = exponent === 1 ? fraction : Math.sign(fraction) * Math.abs(fraction) ** exponent;
|
|
289
|
+
return range.outLow + shaped * (range.outHigh - range.outLow);
|
|
290
|
+
}, {
|
|
291
|
+
type: "webmusic.scale",
|
|
292
|
+
options(input) {
|
|
293
|
+
const { inLow, inHigh, outLow, outHigh, exponent, float } = record(input);
|
|
294
|
+
if (!finite(inLow) || !finite(inHigh) || !finite(outLow) || !finite(outHigh)) throw new TypeError("scale needs inLow, inHigh, outLow and outHigh.");
|
|
295
|
+
return { inLow, inHigh, outLow, outHigh, exponent: finite(exponent) ? exponent : 1, float: float === true };
|
|
296
|
+
},
|
|
297
|
+
inputs: () => [port("value", "value to scale"), port("inLow", "input low"), port("inHigh", "input high"), port("outLow", "output low"), port("outHigh", "output high")],
|
|
298
|
+
outputs: () => [port("result", "scaled value")],
|
|
299
|
+
bind(options, host) {
|
|
300
|
+
const range = { ...options };
|
|
301
|
+
const keys = ["inLow", "inHigh", "outLow", "outHigh"];
|
|
302
|
+
return {
|
|
303
|
+
receive(index, value) {
|
|
304
|
+
const number = numberOf(value);
|
|
305
|
+
if (number === void 0) return;
|
|
306
|
+
if (index > 0) {
|
|
307
|
+
range[keys[index - 1]] = number;
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
host.send(0, numberMessage(scale(number, range), range.float === true || value.selector === "float", value.time));
|
|
311
|
+
}
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
var select = bind(function select2(value, matches) {
|
|
316
|
+
const subject = value === void 0 || typeof value === "object" ? value : atomOf(value);
|
|
317
|
+
return matches.findIndex((match) => sameAtom(atomOf(match), subject));
|
|
318
|
+
}, {
|
|
319
|
+
type: "webmusic.select",
|
|
320
|
+
options: (input) => ({ matches: values("select", "matches", record(input).matches, "at least one value to match") }),
|
|
321
|
+
inputs: (options) => numbered("in", options.matches.length === 1 ? ["value to test", "value to match"] : ["value to test"]),
|
|
322
|
+
outputs: (options) => numbered("out", [...options.matches.map((match) => `bang on ${textOf(atomOf(match))}`), "anything else"]),
|
|
323
|
+
bind(options, host) {
|
|
324
|
+
const matches = [...options.matches];
|
|
325
|
+
return {
|
|
326
|
+
receive(index, value) {
|
|
327
|
+
const atoms = atomsOf(value);
|
|
328
|
+
if (index === 1) {
|
|
329
|
+
const first = atoms[0];
|
|
330
|
+
if (first && (first.type === "int" || first.type === "float" || first.type === "symbol")) matches[0] = first.value;
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
const found = select(value.selector === "bang" ? symbolAtom("bang") : atoms[0], matches);
|
|
334
|
+
if (found >= 0 && atoms.length <= 1) host.send(found, bang(value.time));
|
|
335
|
+
else host.send(matches.length, value);
|
|
336
|
+
}
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
});
|
|
340
|
+
var route = bind(function route2(value, keys) {
|
|
341
|
+
const atoms = atomsOf(value);
|
|
342
|
+
const index = keys.findIndex((key) => sameAtom(atomOf(key), atoms[0]));
|
|
343
|
+
return index < 0 ? { index, message: value } : { index, message: messageFromAtoms(atoms.slice(1), value.time) };
|
|
344
|
+
}, {
|
|
345
|
+
type: "webmusic.route",
|
|
346
|
+
options: (input) => ({ keys: values("route", "keys", record(input).keys, "at least one value to route") }),
|
|
347
|
+
inputs: () => [port("message", "message to route")],
|
|
348
|
+
outputs: (options) => numbered("out", [...options.keys.map((key) => `rest of ${textOf(atomOf(key))}`), "anything else"]),
|
|
349
|
+
bind: (options, host) => ({
|
|
350
|
+
receive(_index2, value) {
|
|
351
|
+
const routed = route(value, options.keys);
|
|
352
|
+
host.send(routed.index < 0 ? options.keys.length : routed.index, routed.message);
|
|
353
|
+
}
|
|
354
|
+
})
|
|
355
|
+
});
|
|
356
|
+
var TRIGGER_KINDS = ["bang", "int", "float", "symbol", "list", "any"];
|
|
357
|
+
function convert(kind, value) {
|
|
358
|
+
if (typeof kind === "object") return messageFromAtoms([atomOf(kind.value, kind.float)], value.time);
|
|
359
|
+
const atoms = atomsOf(value);
|
|
360
|
+
const first = atoms[0];
|
|
361
|
+
switch (kind) {
|
|
362
|
+
case "bang":
|
|
363
|
+
return bang(value.time);
|
|
364
|
+
case "int":
|
|
365
|
+
return message("int", [intAtom(isNumberAtom(first) ? first.value : 0)], value.time);
|
|
366
|
+
case "float":
|
|
367
|
+
return message("float", [floatAtom(isNumberAtom(first) ? first.value : 0)], value.time);
|
|
368
|
+
case "symbol": {
|
|
369
|
+
const named = atoms.find((atom) => atom.type === "symbol");
|
|
370
|
+
return message("symbol", [symbolAtom(named?.type === "symbol" ? named.value : value.selector)], value.time);
|
|
371
|
+
}
|
|
372
|
+
case "list":
|
|
373
|
+
return message("list", atoms, value.time);
|
|
374
|
+
default:
|
|
375
|
+
return value;
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
var trigger = bind(function trigger2(value, outputs) {
|
|
379
|
+
return outputs.map((kind) => convert(kind, value));
|
|
380
|
+
}, {
|
|
381
|
+
type: "webmusic.trigger",
|
|
382
|
+
options(input) {
|
|
383
|
+
const given = record(input).outputs;
|
|
384
|
+
if (given === void 0) return { outputs: ["bang", "bang"] };
|
|
385
|
+
const valid = (item) => TRIGGER_KINDS.includes(item) || !!item && typeof item === "object" && isValue(item.value);
|
|
386
|
+
if (!Array.isArray(given) || !given.length || !given.every(valid)) throw new TypeError('trigger needs "outputs": bang, int, float, symbol, list, any or {value}.');
|
|
387
|
+
return { outputs: Object.freeze([...given]) };
|
|
388
|
+
},
|
|
389
|
+
inputs: () => [port("message", "message to distribute")],
|
|
390
|
+
outputs: (options) => numbered("out", options.outputs.map((kind) => typeof kind === "object" ? textOf(atomOf(kind.value, kind.float)) : kind)),
|
|
391
|
+
bind: (options, host) => ({
|
|
392
|
+
receive(_index2, value) {
|
|
393
|
+
const sent = trigger(value, options.outputs);
|
|
394
|
+
for (let index = sent.length - 1; index >= 0; index--) host.send(index, sent[index]);
|
|
395
|
+
}
|
|
396
|
+
})
|
|
397
|
+
});
|
|
398
|
+
var SLOT_TYPES = ["int", "float", "symbol"];
|
|
399
|
+
function slotAtom(slot) {
|
|
400
|
+
const type = typeof slot === "string" ? slot : slot.type;
|
|
401
|
+
const value = typeof slot === "string" ? void 0 : slot.value;
|
|
402
|
+
if (type === "symbol") return symbolAtom(value === void 0 ? "" : String(value));
|
|
403
|
+
const number = typeof value === "number" ? value : 0;
|
|
404
|
+
return type === "float" ? floatAtom(number) : intAtom(number);
|
|
405
|
+
}
|
|
406
|
+
function coerce(slot, value) {
|
|
407
|
+
if (slot.type === "int") return isNumberAtom(value) ? intAtom(value.value) : slot;
|
|
408
|
+
if (slot.type === "float") return isNumberAtom(value) ? floatAtom(value.value) : slot;
|
|
409
|
+
if (slot.type === "symbol") return value.type === "symbol" ? value : symbolAtom(textOf(value));
|
|
410
|
+
return value;
|
|
411
|
+
}
|
|
412
|
+
function slotOptions(name, input) {
|
|
413
|
+
const given = record(input).slots;
|
|
414
|
+
if (given === void 0) return { slots: ["int", "int"] };
|
|
415
|
+
const valid = (item) => SLOT_TYPES.includes(item) || !!item && typeof item === "object" && SLOT_TYPES.includes(item.type) && (item.value === void 0 || isValue(item.value));
|
|
416
|
+
if (!Array.isArray(given) || !given.length || !given.every(valid)) throw new TypeError(`${name} needs "slots": int, float, symbol or {type, value}.`);
|
|
417
|
+
return { slots: Object.freeze([...given]) };
|
|
418
|
+
}
|
|
419
|
+
var asAtom = (value) => typeof value === "object" ? value : atomOf(value);
|
|
420
|
+
var pack = bind(function pack2(slots, values2 = [], time) {
|
|
421
|
+
return message("list", slots.map((slot, index) => values2[index] === void 0 ? slotAtom(slot) : coerce(slotAtom(slot), asAtom(values2[index]))), time);
|
|
422
|
+
}, {
|
|
423
|
+
type: "webmusic.pack",
|
|
424
|
+
options: (input) => slotOptions("pack", input),
|
|
425
|
+
inputs: (options) => numbered("in", options.slots.map((_, index) => index === 0 ? "first element, outputs the list" : `element ${index + 1}`)),
|
|
426
|
+
outputs: () => [port("list", "list")],
|
|
427
|
+
bind(options, host) {
|
|
428
|
+
const held = options.slots.map(slotAtom);
|
|
429
|
+
const store = (atoms) => atoms.forEach((atom, offset) => {
|
|
430
|
+
if (offset < held.length) held[offset] = coerce(held[offset], atom);
|
|
431
|
+
});
|
|
432
|
+
return {
|
|
433
|
+
receive(index, value) {
|
|
434
|
+
const atoms = atomsOf(value);
|
|
435
|
+
if (index > 0) {
|
|
436
|
+
if (atoms[0]) held[index] = coerce(held[index], atoms[0]);
|
|
437
|
+
return;
|
|
438
|
+
}
|
|
439
|
+
if (value.selector === "bang") {
|
|
440
|
+
host.send(0, message("list", held, value.time));
|
|
441
|
+
return;
|
|
442
|
+
}
|
|
443
|
+
if (value.selector === "set") {
|
|
444
|
+
store(atoms.slice(1));
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
store(atoms);
|
|
448
|
+
host.send(0, message("list", held, value.time));
|
|
449
|
+
}
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
});
|
|
453
|
+
var unpack = bind(function unpack2(value, slots) {
|
|
454
|
+
const atoms = atomsOf(value);
|
|
455
|
+
return slots.map((slot, index) => atoms[index] === void 0 ? void 0 : messageFromAtoms([coerce(slotAtom(slot), atoms[index])], value.time));
|
|
456
|
+
}, {
|
|
457
|
+
type: "webmusic.unpack",
|
|
458
|
+
options: (input) => slotOptions("unpack", input),
|
|
459
|
+
inputs: () => [port("list", "list to split")],
|
|
460
|
+
outputs: (options) => numbered("out", options.slots.map((_, index) => `element ${index + 1}`)),
|
|
461
|
+
bind: (options, host) => ({
|
|
462
|
+
receive(_index2, value) {
|
|
463
|
+
const sent = unpack(value, options.slots);
|
|
464
|
+
for (let index = sent.length - 1; index >= 0; index--) {
|
|
465
|
+
const part = sent[index];
|
|
466
|
+
if (part) host.send(index, part);
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
})
|
|
470
|
+
});
|
|
471
|
+
var expr = bind(function expr2(expression, inputs = [], random3) {
|
|
472
|
+
return compileExpr(expression).evaluate(inputs, random3).value;
|
|
473
|
+
}, {
|
|
474
|
+
type: "webmusic.expr",
|
|
475
|
+
options(input) {
|
|
476
|
+
const expression = record(input).expression;
|
|
477
|
+
if (typeof expression !== "string") throw new TypeError('expr needs an "expression".');
|
|
478
|
+
compileExpr(expression);
|
|
479
|
+
return { expression };
|
|
480
|
+
},
|
|
481
|
+
inputs: (options) => numbered("in", Array.from({ length: compileExpr(options.expression).inlets }, (_, index) => index === 0 ? "$1, evaluates" : `$${index + 1}`)),
|
|
482
|
+
outputs: () => [port("result", "result")],
|
|
483
|
+
bind(options, host) {
|
|
484
|
+
const compiled = compileExpr(options.expression);
|
|
485
|
+
const inputs = new Array(compiled.inlets).fill(0);
|
|
486
|
+
const evaluate = (time) => {
|
|
487
|
+
const result = compiled.evaluate(inputs, host.random);
|
|
488
|
+
host.send(0, numberMessage(result.value, result.float, time));
|
|
489
|
+
};
|
|
490
|
+
return {
|
|
491
|
+
receive(index, value) {
|
|
492
|
+
if (index === 0 && value.selector === "bang") {
|
|
493
|
+
evaluate(value.time);
|
|
494
|
+
return;
|
|
495
|
+
}
|
|
496
|
+
atomsOf(value).forEach((atom, offset) => {
|
|
497
|
+
if (isNumberAtom(atom) && index + offset < inputs.length) inputs[index + offset] = atom.value;
|
|
498
|
+
});
|
|
499
|
+
if (index === 0) evaluate(value.time);
|
|
500
|
+
}
|
|
501
|
+
};
|
|
502
|
+
}
|
|
503
|
+
});
|
|
504
|
+
function seededRandom(seed) {
|
|
505
|
+
let state = seed >>> 0;
|
|
506
|
+
return () => {
|
|
507
|
+
state = state + 1831565813 >>> 0;
|
|
508
|
+
let t = state;
|
|
509
|
+
t = Math.imul(t ^ t >>> 15, t | 1);
|
|
510
|
+
t ^= t + Math.imul(t ^ t >>> 7, t | 61);
|
|
511
|
+
return ((t ^ t >>> 14) >>> 0) / 4294967296;
|
|
512
|
+
};
|
|
513
|
+
}
|
|
514
|
+
var random = bind(function random2(range, next = Math.random) {
|
|
515
|
+
return Math.floor(next() * range);
|
|
516
|
+
}, {
|
|
517
|
+
type: "webmusic.random",
|
|
518
|
+
options(input) {
|
|
519
|
+
const { range, seed } = record(input);
|
|
520
|
+
return { range: Math.max(1, Math.trunc(finite(range) ? range : 2)), ...finite(seed) ? { seed } : {} };
|
|
521
|
+
},
|
|
522
|
+
inputs: () => [port("trigger", "bang for a number, seed"), port("range", "range")],
|
|
523
|
+
outputs: () => [port("value", "random int from 0")],
|
|
524
|
+
bind(options, host) {
|
|
525
|
+
let range = options.range ?? 2;
|
|
526
|
+
let seed = options.seed;
|
|
527
|
+
let next = seed === void 0 ? host.random : seededRandom(seed);
|
|
528
|
+
return {
|
|
529
|
+
receive(index, value) {
|
|
530
|
+
const number = numberOf(value);
|
|
531
|
+
if (index === 1) {
|
|
532
|
+
if (number !== void 0 && number >= 1) range = Math.trunc(number);
|
|
533
|
+
return;
|
|
534
|
+
}
|
|
535
|
+
if (value.selector === "seed") {
|
|
536
|
+
seed = number === void 0 || number === 0 ? void 0 : number;
|
|
537
|
+
next = seed === void 0 ? host.random : seededRandom(seed);
|
|
538
|
+
return;
|
|
539
|
+
}
|
|
540
|
+
if (value.selector === "bang") host.send(0, message("int", [intAtom(random(range, next))], value.time));
|
|
541
|
+
}
|
|
542
|
+
};
|
|
543
|
+
}
|
|
544
|
+
});
|
|
545
|
+
var print = bind(function print2(value, name = "print", write = (line) => console.log(line)) {
|
|
546
|
+
const line = `${name}: ${formatMessage(value)}`;
|
|
547
|
+
write(line);
|
|
548
|
+
return line;
|
|
549
|
+
}, {
|
|
550
|
+
type: "webmusic.print",
|
|
551
|
+
options(input) {
|
|
552
|
+
const name = record(input).name;
|
|
553
|
+
return { name: typeof name === "string" && name ? name : "print" };
|
|
554
|
+
},
|
|
555
|
+
inputs: () => [port("value", "anything to print")],
|
|
556
|
+
outputs: () => [],
|
|
557
|
+
bind: (options, host) => ({
|
|
558
|
+
receive(_index2, value) {
|
|
559
|
+
host.print(options.name ?? "print", formatMessage(value));
|
|
560
|
+
}
|
|
561
|
+
})
|
|
562
|
+
});
|
|
563
|
+
var MESSAGE_FUNCTIONS = Object.freeze([select, route, trigger, pack, unpack, expr, scale, random, print]);
|
|
564
|
+
|
|
565
|
+
// src/message/timers.ts
|
|
566
|
+
var plainValue = (atom) => atom && (atom.type === "int" || atom.type === "float" || atom.type === "symbol") ? atom.value : void 0;
|
|
567
|
+
var isBang = (value) => value.selector === "bang";
|
|
568
|
+
var isNumber = (value) => value.selector === "int" || value.selector === "float";
|
|
569
|
+
var finite2 = (value) => typeof value === "number" && Number.isFinite(value);
|
|
570
|
+
var count = (name, value, fallback, most) => {
|
|
571
|
+
if (value === void 0) return fallback;
|
|
572
|
+
if (!finite2(value)) throw new TypeError(`${name} must be a number.`);
|
|
573
|
+
return Math.max(1, Math.min(most, Math.trunc(value)));
|
|
574
|
+
};
|
|
575
|
+
var _LoadBang = class _LoadBang extends GraphModule {
|
|
576
|
+
constructor(options = {}) {
|
|
577
|
+
super(_LoadBang.type, options);
|
|
578
|
+
this.inputs = { trigger: this.input("trigger", "bang", (value) => this.outputs.bang.send(bang(value.time))) };
|
|
579
|
+
this.outputs = { bang: this.output("bang", "bang when the component loads") };
|
|
580
|
+
}
|
|
581
|
+
onActivate() {
|
|
582
|
+
this.outputs.bang.send(bang());
|
|
583
|
+
}
|
|
584
|
+
exportOptions() {
|
|
585
|
+
return {};
|
|
586
|
+
}
|
|
587
|
+
};
|
|
588
|
+
_LoadBang.type = "webmusic.load-bang";
|
|
589
|
+
var LoadBang = _LoadBang;
|
|
590
|
+
function intervalOf(value, fallback) {
|
|
591
|
+
if (finite2(value)) return value > 0 ? { kind: "ms", ms: value } : fallback;
|
|
592
|
+
if (typeof value !== "string") return fallback;
|
|
593
|
+
if (timeValueTicks(value) !== void 0) return { kind: "musical", text: value };
|
|
594
|
+
const seconds = timeValueSeconds(value);
|
|
595
|
+
return seconds > 0 ? { kind: "ms", ms: seconds * 1e3 } : fallback;
|
|
596
|
+
}
|
|
597
|
+
var _interval, _running, _cancel, _release, _Metro_instances, control_fn, _tick, scheduleLocked_fn, begin_fn;
|
|
598
|
+
var _Metro = class _Metro extends GraphModule {
|
|
599
|
+
constructor(options = {}) {
|
|
600
|
+
super(_Metro.type, options);
|
|
601
|
+
__privateAdd(this, _Metro_instances);
|
|
602
|
+
this.inputs = {
|
|
603
|
+
control: this.input("control", "on/off, bang, stop", (value) => __privateMethod(this, _Metro_instances, control_fn).call(this, value)),
|
|
604
|
+
interval: this.input("interval", "interval (ms or a time value such as 4n)", (value) => {
|
|
605
|
+
__privateSet(this, _interval, intervalOf(plainValue(atomsOf(value)[0]), __privateGet(this, _interval)));
|
|
606
|
+
if (__privateGet(this, _running)) __privateMethod(this, _Metro_instances, begin_fn).call(this, this.timeOf(value));
|
|
607
|
+
})
|
|
608
|
+
};
|
|
609
|
+
this.outputs = { ticks: this.output("ticks", "bang") };
|
|
610
|
+
__privateAdd(this, _interval);
|
|
611
|
+
__privateAdd(this, _running);
|
|
612
|
+
__privateAdd(this, _cancel);
|
|
613
|
+
__privateAdd(this, _release);
|
|
614
|
+
// Free-running: every interval from the start, on the clock.
|
|
615
|
+
__privateAdd(this, _tick, (time) => {
|
|
616
|
+
this.outputs.ticks.send(bang(time));
|
|
617
|
+
if (__privateGet(this, _interval).kind === "ms") __privateSet(this, _cancel, this.clock.schedule(time + __privateGet(this, _interval).ms / 1e3, __privateGet(this, _tick)));
|
|
618
|
+
});
|
|
619
|
+
if (finite2(options.interval) && !(options.interval > 0)) throw new RangeError("metro interval must be greater than 0.");
|
|
620
|
+
__privateSet(this, _interval, intervalOf(options.interval, { kind: "ms", ms: 500 }));
|
|
621
|
+
__privateSet(this, _running, options.running === true);
|
|
622
|
+
__privateSet(this, _release, this.musicalTime?.subscribe(() => {
|
|
623
|
+
if (__privateGet(this, _interval).kind === "musical" && __privateGet(this, _running)) __privateMethod(this, _Metro_instances, scheduleLocked_fn).call(this);
|
|
624
|
+
}));
|
|
625
|
+
}
|
|
626
|
+
/** Whether the metronome is on. A transport-locked one ticks only while the Session plays. */
|
|
627
|
+
get running() {
|
|
628
|
+
return __privateGet(this, _running);
|
|
629
|
+
}
|
|
630
|
+
/** The interval: milliseconds, or the time value it follows. */
|
|
631
|
+
get interval() {
|
|
632
|
+
return __privateGet(this, _interval).kind === "ms" ? __privateGet(this, _interval).ms : __privateGet(this, _interval).text;
|
|
633
|
+
}
|
|
634
|
+
/** Turn it on from `time` (now by default). Activates the module if it is not yet active. */
|
|
635
|
+
start(time) {
|
|
636
|
+
__privateSet(this, _running, true);
|
|
637
|
+
if (!this.active) {
|
|
638
|
+
this.activate();
|
|
639
|
+
return;
|
|
640
|
+
}
|
|
641
|
+
__privateMethod(this, _Metro_instances, begin_fn).call(this, time ?? this.clock.now());
|
|
642
|
+
}
|
|
643
|
+
stop() {
|
|
644
|
+
var _a;
|
|
645
|
+
(_a = __privateGet(this, _cancel)) == null ? void 0 : _a.call(this);
|
|
646
|
+
__privateSet(this, _cancel, void 0);
|
|
647
|
+
__privateSet(this, _running, false);
|
|
648
|
+
}
|
|
649
|
+
exportOptions() {
|
|
650
|
+
return { interval: this.interval, running: __privateGet(this, _running) };
|
|
651
|
+
}
|
|
652
|
+
onActivate() {
|
|
653
|
+
__privateMethod(this, _Metro_instances, begin_fn).call(this, this.clock.now());
|
|
654
|
+
}
|
|
655
|
+
onDispose() {
|
|
656
|
+
var _a;
|
|
657
|
+
this.stop();
|
|
658
|
+
(_a = __privateGet(this, _release)) == null ? void 0 : _a.call(this);
|
|
659
|
+
}
|
|
660
|
+
};
|
|
661
|
+
_interval = new WeakMap();
|
|
662
|
+
_running = new WeakMap();
|
|
663
|
+
_cancel = new WeakMap();
|
|
664
|
+
_release = new WeakMap();
|
|
665
|
+
_Metro_instances = new WeakSet();
|
|
666
|
+
control_fn = function(value) {
|
|
667
|
+
if (value.selector === "stop" || isNumber(value) && numberOf(value) === 0) this.stop();
|
|
668
|
+
else if (isBang(value) || isNumber(value) || value.selector === "start") {
|
|
669
|
+
__privateSet(this, _running, true);
|
|
670
|
+
__privateMethod(this, _Metro_instances, begin_fn).call(this, this.timeOf(value));
|
|
671
|
+
}
|
|
672
|
+
};
|
|
673
|
+
_tick = new WeakMap();
|
|
674
|
+
// Musical: on the transport's grid, only while it plays.
|
|
675
|
+
scheduleLocked_fn = function(from) {
|
|
676
|
+
var _a;
|
|
677
|
+
(_a = __privateGet(this, _cancel)) == null ? void 0 : _a.call(this);
|
|
678
|
+
__privateSet(this, _cancel, void 0);
|
|
679
|
+
const musical = this.musicalTime;
|
|
680
|
+
if (__privateGet(this, _interval).kind !== "musical" || !__privateGet(this, _running) || !this.active || !musical?.playing()) return;
|
|
681
|
+
const step = timeValueSeconds(__privateGet(this, _interval).text, musical.tempo());
|
|
682
|
+
const position = from ?? nextGridTime(musical.position(), step);
|
|
683
|
+
const when = musical.timeAt(position);
|
|
684
|
+
if (when === void 0) return;
|
|
685
|
+
__privateSet(this, _cancel, this.clock.schedule(Math.max(this.clock.now(), when), (time) => {
|
|
686
|
+
__privateSet(this, _cancel, void 0);
|
|
687
|
+
this.outputs.ticks.send(bang(time));
|
|
688
|
+
__privateMethod(this, _Metro_instances, scheduleLocked_fn).call(this, position + step);
|
|
689
|
+
}));
|
|
690
|
+
};
|
|
691
|
+
begin_fn = function(time) {
|
|
692
|
+
var _a;
|
|
693
|
+
(_a = __privateGet(this, _cancel)) == null ? void 0 : _a.call(this);
|
|
694
|
+
__privateSet(this, _cancel, void 0);
|
|
695
|
+
if (!this.active || !__privateGet(this, _running)) return;
|
|
696
|
+
if (__privateGet(this, _interval).kind === "ms") __privateGet(this, _tick).call(this, time);
|
|
697
|
+
else __privateMethod(this, _Metro_instances, scheduleLocked_fn).call(this);
|
|
698
|
+
};
|
|
699
|
+
_Metro.type = "webmusic.metro";
|
|
700
|
+
var Metro = _Metro;
|
|
701
|
+
var _time, _authored, _cancel2;
|
|
702
|
+
var _Delay = class _Delay extends GraphModule {
|
|
703
|
+
constructor(options = {}) {
|
|
704
|
+
super(_Delay.type, options);
|
|
705
|
+
this.inputs = {
|
|
706
|
+
trigger: this.input("trigger", "bang, stop, or delay time to start", (value) => {
|
|
707
|
+
const number = numberOf(value);
|
|
708
|
+
if (value.selector === "stop") {
|
|
709
|
+
this.cancel();
|
|
710
|
+
return;
|
|
711
|
+
}
|
|
712
|
+
if (isNumber(value) && number !== void 0 && number >= 0) __privateSet(this, _time, number);
|
|
713
|
+
if (isBang(value) || isNumber(value)) this.trigger(this.timeOf(value));
|
|
714
|
+
}),
|
|
715
|
+
time: this.input("time", "delay time (ms)", (value) => {
|
|
716
|
+
const number = numberOf(value);
|
|
717
|
+
if (number !== void 0 && number >= 0) __privateSet(this, _time, number);
|
|
718
|
+
})
|
|
719
|
+
};
|
|
720
|
+
this.outputs = { bang: this.output("bang", "bang after the delay") };
|
|
721
|
+
__privateAdd(this, _time);
|
|
722
|
+
__privateAdd(this, _authored);
|
|
723
|
+
__privateAdd(this, _cancel2);
|
|
724
|
+
__privateSet(this, _time, __privateSet(this, _authored, finite2(options.time) ? options.time : 0));
|
|
725
|
+
}
|
|
726
|
+
/** The delay, in milliseconds. */
|
|
727
|
+
get time() {
|
|
728
|
+
return __privateGet(this, _time);
|
|
729
|
+
}
|
|
730
|
+
set time(value) {
|
|
731
|
+
if (value >= 0) __privateSet(this, _time, value);
|
|
732
|
+
}
|
|
733
|
+
/** Send the bang `time` milliseconds after `from` (now by default). */
|
|
734
|
+
trigger(from = this.clock.now()) {
|
|
735
|
+
var _a;
|
|
736
|
+
(_a = __privateGet(this, _cancel2)) == null ? void 0 : _a.call(this);
|
|
737
|
+
__privateSet(this, _cancel2, this.clock.schedule(from + __privateGet(this, _time) / 1e3, (when) => {
|
|
738
|
+
__privateSet(this, _cancel2, void 0);
|
|
739
|
+
this.outputs.bang.send(bang(when));
|
|
740
|
+
}));
|
|
741
|
+
}
|
|
742
|
+
/** Drop the pending bang. */
|
|
743
|
+
cancel() {
|
|
744
|
+
var _a;
|
|
745
|
+
(_a = __privateGet(this, _cancel2)) == null ? void 0 : _a.call(this);
|
|
746
|
+
__privateSet(this, _cancel2, void 0);
|
|
747
|
+
}
|
|
748
|
+
exportOptions() {
|
|
749
|
+
return { time: __privateGet(this, _authored) };
|
|
750
|
+
}
|
|
751
|
+
onDispose() {
|
|
752
|
+
var _a;
|
|
753
|
+
(_a = __privateGet(this, _cancel2)) == null ? void 0 : _a.call(this);
|
|
754
|
+
}
|
|
755
|
+
};
|
|
756
|
+
_time = new WeakMap();
|
|
757
|
+
_authored = new WeakMap();
|
|
758
|
+
_cancel2 = new WeakMap();
|
|
759
|
+
_Delay.type = "webmusic.delay";
|
|
760
|
+
var Delay = _Delay;
|
|
761
|
+
var _time2, _authored2, _pending;
|
|
762
|
+
var _Pipe = class _Pipe extends GraphModule {
|
|
763
|
+
constructor(options = {}) {
|
|
764
|
+
super(_Pipe.type, options);
|
|
765
|
+
this.inputs = {
|
|
766
|
+
value: this.input("value", "value to delay, clear", (value) => {
|
|
767
|
+
if (value.selector === "clear") {
|
|
768
|
+
this.clear();
|
|
769
|
+
return;
|
|
770
|
+
}
|
|
771
|
+
this.send(value);
|
|
772
|
+
}),
|
|
773
|
+
time: this.input("time", "delay time (ms)", (value) => {
|
|
774
|
+
const number = numberOf(value);
|
|
775
|
+
if (number !== void 0 && number >= 0) __privateSet(this, _time2, number);
|
|
776
|
+
})
|
|
777
|
+
};
|
|
778
|
+
this.outputs = { value: this.output("value", "the value after the delay") };
|
|
779
|
+
__privateAdd(this, _time2);
|
|
780
|
+
__privateAdd(this, _authored2);
|
|
781
|
+
__privateAdd(this, _pending, /* @__PURE__ */ new Set());
|
|
782
|
+
__privateSet(this, _time2, __privateSet(this, _authored2, finite2(options.time) ? options.time : 0));
|
|
783
|
+
}
|
|
784
|
+
/** The delay, in milliseconds. */
|
|
785
|
+
get time() {
|
|
786
|
+
return __privateGet(this, _time2);
|
|
787
|
+
}
|
|
788
|
+
set time(value) {
|
|
789
|
+
if (value >= 0) __privateSet(this, _time2, value);
|
|
790
|
+
}
|
|
791
|
+
/** Send `value` from the output after the delay, counted from its own time. */
|
|
792
|
+
send(value) {
|
|
793
|
+
const atoms = atomsOf(value);
|
|
794
|
+
const cancel = this.clock.schedule(this.timeOf(value) + __privateGet(this, _time2) / 1e3, (when) => {
|
|
795
|
+
__privateGet(this, _pending).delete(cancel);
|
|
796
|
+
this.outputs.value.send(messageFromAtoms(atoms, when));
|
|
797
|
+
});
|
|
798
|
+
__privateGet(this, _pending).add(cancel);
|
|
799
|
+
}
|
|
800
|
+
/** Drop every value still waiting. */
|
|
801
|
+
clear() {
|
|
802
|
+
for (const cancel of __privateGet(this, _pending)) cancel();
|
|
803
|
+
__privateGet(this, _pending).clear();
|
|
804
|
+
}
|
|
805
|
+
exportOptions() {
|
|
806
|
+
return { time: __privateGet(this, _authored2) };
|
|
807
|
+
}
|
|
808
|
+
onDispose() {
|
|
809
|
+
this.clear();
|
|
810
|
+
}
|
|
811
|
+
};
|
|
812
|
+
_time2 = new WeakMap();
|
|
813
|
+
_authored2 = new WeakMap();
|
|
814
|
+
_pending = new WeakMap();
|
|
815
|
+
_Pipe.type = "webmusic.pipe";
|
|
816
|
+
var Pipe = _Pipe;
|
|
817
|
+
var _float, _current, _nextTime, _grain, _authoredGrain, _cancel3;
|
|
818
|
+
var _Line = class _Line extends GraphModule {
|
|
819
|
+
constructor(options = {}) {
|
|
820
|
+
super(_Line.type, options);
|
|
821
|
+
this.inputs = {
|
|
822
|
+
target: this.input("target", "target, or target and time (ms)", (value) => {
|
|
823
|
+
const atoms = atomsOf(value);
|
|
824
|
+
if (value.selector === "stop") {
|
|
825
|
+
this.stop();
|
|
826
|
+
return;
|
|
827
|
+
}
|
|
828
|
+
if (value.selector === "set") {
|
|
829
|
+
const n = numberOf(message("list", atoms.slice(1)));
|
|
830
|
+
if (n !== void 0) {
|
|
831
|
+
this.stop();
|
|
832
|
+
__privateSet(this, _current, n);
|
|
833
|
+
}
|
|
834
|
+
return;
|
|
835
|
+
}
|
|
836
|
+
const target = isNumberAtom(atoms[0]) ? atoms[0].value : void 0;
|
|
837
|
+
if (target === void 0) return;
|
|
838
|
+
const duration = isNumberAtom(atoms[1]) ? atoms[1].value : __privateGet(this, _nextTime);
|
|
839
|
+
__privateSet(this, _nextTime, 0);
|
|
840
|
+
this.ramp(target, duration, this.timeOf(value));
|
|
841
|
+
}),
|
|
842
|
+
time: this.input("time", "ramp time (ms)", (value) => {
|
|
843
|
+
const n = numberOf(value);
|
|
844
|
+
if (n !== void 0 && n >= 0) __privateSet(this, _nextTime, n);
|
|
845
|
+
}),
|
|
846
|
+
grain: this.input("grain", "grain (ms)", (value) => {
|
|
847
|
+
const n = numberOf(value);
|
|
848
|
+
if (n !== void 0 && n > 0) __privateSet(this, _grain, n);
|
|
849
|
+
})
|
|
850
|
+
};
|
|
851
|
+
this.outputs = { value: this.output("value", "ramp values"), done: this.output("done", "bang at the end") };
|
|
852
|
+
__privateAdd(this, _float);
|
|
853
|
+
__privateAdd(this, _current);
|
|
854
|
+
__privateAdd(this, _nextTime, 0);
|
|
855
|
+
__privateAdd(this, _grain);
|
|
856
|
+
__privateAdd(this, _authoredGrain);
|
|
857
|
+
__privateAdd(this, _cancel3);
|
|
858
|
+
__privateSet(this, _float, options.float === true);
|
|
859
|
+
__privateSet(this, _current, finite2(options.value) ? options.value : 0);
|
|
860
|
+
__privateSet(this, _grain, __privateSet(this, _authoredGrain, finite2(options.grain) && options.grain > 0 ? options.grain : 20));
|
|
861
|
+
}
|
|
862
|
+
/** The value the ramp has reached. */
|
|
863
|
+
get value() {
|
|
864
|
+
return __privateGet(this, _current);
|
|
865
|
+
}
|
|
866
|
+
/** Ramp to `target` over `duration` milliseconds from `start` (now by default); 0 jumps. */
|
|
867
|
+
ramp(target, duration = 0, start = this.clock.now()) {
|
|
868
|
+
this.stop();
|
|
869
|
+
const { value, done } = this.outputs;
|
|
870
|
+
if (duration <= 0) {
|
|
871
|
+
__privateSet(this, _current, target);
|
|
872
|
+
value.send(numberMessage(target, __privateGet(this, _float), start));
|
|
873
|
+
done.send(bang(start));
|
|
874
|
+
return;
|
|
875
|
+
}
|
|
876
|
+
const from = __privateGet(this, _current), steps = Math.max(1, Math.ceil(duration / __privateGet(this, _grain)));
|
|
877
|
+
let step = 0;
|
|
878
|
+
const next = (time) => {
|
|
879
|
+
step++;
|
|
880
|
+
__privateSet(this, _current, step >= steps ? target : from + (target - from) * (step / steps));
|
|
881
|
+
value.send(numberMessage(__privateGet(this, _current), __privateGet(this, _float), time));
|
|
882
|
+
if (step >= steps) {
|
|
883
|
+
__privateSet(this, _cancel3, void 0);
|
|
884
|
+
done.send(bang(time));
|
|
885
|
+
return;
|
|
886
|
+
}
|
|
887
|
+
__privateSet(this, _cancel3, this.clock.schedule(start + duration / 1e3 * ((step + 1) / steps), next));
|
|
888
|
+
};
|
|
889
|
+
__privateSet(this, _cancel3, this.clock.schedule(start + duration / 1e3 / steps, next));
|
|
890
|
+
}
|
|
891
|
+
/** Stop where the ramp is. */
|
|
892
|
+
stop() {
|
|
893
|
+
var _a;
|
|
894
|
+
(_a = __privateGet(this, _cancel3)) == null ? void 0 : _a.call(this);
|
|
895
|
+
__privateSet(this, _cancel3, void 0);
|
|
896
|
+
}
|
|
897
|
+
exportOptions() {
|
|
898
|
+
return { value: __privateGet(this, _current), grain: __privateGet(this, _authoredGrain), float: __privateGet(this, _float) };
|
|
899
|
+
}
|
|
900
|
+
onDispose() {
|
|
901
|
+
this.stop();
|
|
902
|
+
}
|
|
903
|
+
};
|
|
904
|
+
_float = new WeakMap();
|
|
905
|
+
_current = new WeakMap();
|
|
906
|
+
_nextTime = new WeakMap();
|
|
907
|
+
_grain = new WeakMap();
|
|
908
|
+
_authoredGrain = new WeakMap();
|
|
909
|
+
_cancel3 = new WeakMap();
|
|
910
|
+
_Line.type = "webmusic.line";
|
|
911
|
+
var Line = _Line;
|
|
912
|
+
var _minimum, _maximum, _authored3, _next;
|
|
913
|
+
var _Counter = class _Counter extends GraphModule {
|
|
914
|
+
constructor(options = {}) {
|
|
915
|
+
super(_Counter.type, options);
|
|
916
|
+
this.inputs = {
|
|
917
|
+
trigger: this.input("trigger", "bang to count, set, reset, min, max", (value) => {
|
|
918
|
+
const number = numberOf(value);
|
|
919
|
+
switch (value.selector) {
|
|
920
|
+
case "bang":
|
|
921
|
+
this.count(value.time);
|
|
922
|
+
return;
|
|
923
|
+
case "reset":
|
|
924
|
+
this.reset();
|
|
925
|
+
return;
|
|
926
|
+
case "set":
|
|
927
|
+
if (number !== void 0) __privateSet(this, _next, Math.trunc(number));
|
|
928
|
+
return;
|
|
929
|
+
case "min":
|
|
930
|
+
if (number !== void 0) __privateSet(this, _minimum, Math.trunc(number));
|
|
931
|
+
return;
|
|
932
|
+
case "max":
|
|
933
|
+
if (number !== void 0) __privateSet(this, _maximum, Math.trunc(number));
|
|
934
|
+
return;
|
|
935
|
+
case "int":
|
|
936
|
+
case "float":
|
|
937
|
+
if (number !== void 0) {
|
|
938
|
+
__privateSet(this, _next, Math.trunc(number));
|
|
939
|
+
this.count(value.time);
|
|
940
|
+
}
|
|
941
|
+
return;
|
|
942
|
+
}
|
|
943
|
+
}),
|
|
944
|
+
next: this.input("next", "next value", (value) => {
|
|
945
|
+
const number = numberOf(value);
|
|
946
|
+
if (number !== void 0) __privateSet(this, _next, Math.trunc(number));
|
|
947
|
+
})
|
|
948
|
+
};
|
|
949
|
+
this.outputs = { count: this.output("count", "count"), wrap: this.output("wrap", "bang when it wraps") };
|
|
950
|
+
__privateAdd(this, _minimum);
|
|
951
|
+
__privateAdd(this, _maximum);
|
|
952
|
+
__privateAdd(this, _authored3);
|
|
953
|
+
__privateAdd(this, _next);
|
|
954
|
+
__privateSet(this, _minimum, finite2(options.minimum) ? options.minimum : 0);
|
|
955
|
+
__privateSet(this, _maximum, finite2(options.maximum) ? options.maximum : Infinity);
|
|
956
|
+
__privateSet(this, _authored3, { minimum: __privateGet(this, _minimum), maximum: __privateGet(this, _maximum) });
|
|
957
|
+
__privateSet(this, _next, finite2(options.next) ? options.next : __privateGet(this, _minimum));
|
|
958
|
+
}
|
|
959
|
+
/** The value the next count sends. */
|
|
960
|
+
get next() {
|
|
961
|
+
return __privateGet(this, _next);
|
|
962
|
+
}
|
|
963
|
+
set next(value) {
|
|
964
|
+
__privateSet(this, _next, Math.trunc(value));
|
|
965
|
+
}
|
|
966
|
+
/** Send the count and advance it; returns the value sent. */
|
|
967
|
+
count(time) {
|
|
968
|
+
const value = __privateGet(this, _next);
|
|
969
|
+
__privateSet(this, _next, value + 1);
|
|
970
|
+
let wrapped = false;
|
|
971
|
+
if (__privateGet(this, _next) > __privateGet(this, _maximum)) {
|
|
972
|
+
__privateSet(this, _next, __privateGet(this, _minimum));
|
|
973
|
+
wrapped = true;
|
|
974
|
+
}
|
|
975
|
+
this.outputs.count.send(message("int", [intAtom(value)], time));
|
|
976
|
+
if (wrapped) this.outputs.wrap.send(bang(time));
|
|
977
|
+
return value;
|
|
978
|
+
}
|
|
979
|
+
/** Return to the minimum without sending. */
|
|
980
|
+
reset() {
|
|
981
|
+
__privateSet(this, _next, __privateGet(this, _minimum));
|
|
982
|
+
}
|
|
983
|
+
exportOptions() {
|
|
984
|
+
const { minimum, maximum } = __privateGet(this, _authored3);
|
|
985
|
+
return { minimum, ...Number.isFinite(maximum) ? { maximum } : {}, next: __privateGet(this, _next) };
|
|
986
|
+
}
|
|
987
|
+
};
|
|
988
|
+
_minimum = new WeakMap();
|
|
989
|
+
_maximum = new WeakMap();
|
|
990
|
+
_authored3 = new WeakMap();
|
|
991
|
+
_next = new WeakMap();
|
|
992
|
+
_Counter.type = "webmusic.counter";
|
|
993
|
+
var Counter = _Counter;
|
|
994
|
+
var _count, _ports, _open, _Gate_instances, clamp_fn;
|
|
995
|
+
var _Gate = class _Gate extends GraphModule {
|
|
996
|
+
constructor(options = {}) {
|
|
997
|
+
super(_Gate.type, options);
|
|
998
|
+
__privateAdd(this, _Gate_instances);
|
|
999
|
+
__privateAdd(this, _count);
|
|
1000
|
+
__privateAdd(this, _ports);
|
|
1001
|
+
__privateAdd(this, _open);
|
|
1002
|
+
__privateSet(this, _count, count("gate count", options.count, 1, 64));
|
|
1003
|
+
__privateSet(this, _open, __privateMethod(this, _Gate_instances, clamp_fn).call(this, finite2(options.open) ? options.open : 0));
|
|
1004
|
+
this.inputs = {
|
|
1005
|
+
open: this.input("open", "outlet to open (0 closes)", (value) => {
|
|
1006
|
+
const n = numberOf(value);
|
|
1007
|
+
if (n !== void 0) this.open = n;
|
|
1008
|
+
}),
|
|
1009
|
+
message: this.input("message", "message to pass", (value) => {
|
|
1010
|
+
if (__privateGet(this, _open) > 0) __privateGet(this, _ports)[__privateGet(this, _open) - 1].send(value);
|
|
1011
|
+
})
|
|
1012
|
+
};
|
|
1013
|
+
__privateSet(this, _ports, Array.from({ length: __privateGet(this, _count) }, (_, index) => this.output(numberedPort("out", index), `open ${index + 1}`)));
|
|
1014
|
+
this.outputs = Object.freeze(Object.fromEntries(__privateGet(this, _ports).map((port2) => [port2.id, port2])));
|
|
1015
|
+
}
|
|
1016
|
+
/** The open output, counted from 1; 0 when closed. */
|
|
1017
|
+
get open() {
|
|
1018
|
+
return __privateGet(this, _open);
|
|
1019
|
+
}
|
|
1020
|
+
set open(value) {
|
|
1021
|
+
__privateSet(this, _open, __privateMethod(this, _Gate_instances, clamp_fn).call(this, value));
|
|
1022
|
+
this.changed();
|
|
1023
|
+
}
|
|
1024
|
+
exportOptions() {
|
|
1025
|
+
return { count: __privateGet(this, _count), open: __privateGet(this, _open) };
|
|
1026
|
+
}
|
|
1027
|
+
};
|
|
1028
|
+
_count = new WeakMap();
|
|
1029
|
+
_ports = new WeakMap();
|
|
1030
|
+
_open = new WeakMap();
|
|
1031
|
+
_Gate_instances = new WeakSet();
|
|
1032
|
+
clamp_fn = function(value) {
|
|
1033
|
+
return Math.max(0, Math.min(__privateGet(this, _count), Math.trunc(value)));
|
|
1034
|
+
};
|
|
1035
|
+
_Gate.type = "webmusic.gate";
|
|
1036
|
+
var Gate = _Gate;
|
|
1037
|
+
var _count2, _open2, _Switch_instances, clamp_fn2;
|
|
1038
|
+
var _Switch = class _Switch extends GraphModule {
|
|
1039
|
+
constructor(options = {}) {
|
|
1040
|
+
super(_Switch.type, options);
|
|
1041
|
+
__privateAdd(this, _Switch_instances);
|
|
1042
|
+
__privateAdd(this, _count2);
|
|
1043
|
+
__privateAdd(this, _open2);
|
|
1044
|
+
__privateSet(this, _count2, count("switch count", options.count, 2, 64));
|
|
1045
|
+
__privateSet(this, _open2, __privateMethod(this, _Switch_instances, clamp_fn2).call(this, finite2(options.open) ? options.open : 0));
|
|
1046
|
+
const ports = [
|
|
1047
|
+
this.input(numberedPort("in", 0), "inlet to pass (0 closes)", (value) => {
|
|
1048
|
+
const n = numberOf(value);
|
|
1049
|
+
if (n !== void 0) this.open = n;
|
|
1050
|
+
}),
|
|
1051
|
+
...Array.from({ length: __privateGet(this, _count2) }, (_, index) => this.input(numberedPort("in", index + 1), `input ${index + 1}`, (value) => {
|
|
1052
|
+
if (index + 1 === __privateGet(this, _open2)) this.outputs.message.send(value);
|
|
1053
|
+
}))
|
|
1054
|
+
];
|
|
1055
|
+
this.inputs = Object.freeze(Object.fromEntries(ports.map((port2) => [port2.id, port2])));
|
|
1056
|
+
this.outputs = { message: this.output("message", "the open input") };
|
|
1057
|
+
}
|
|
1058
|
+
/** The open input, counted from 1; 0 when closed. */
|
|
1059
|
+
get open() {
|
|
1060
|
+
return __privateGet(this, _open2);
|
|
1061
|
+
}
|
|
1062
|
+
set open(value) {
|
|
1063
|
+
__privateSet(this, _open2, __privateMethod(this, _Switch_instances, clamp_fn2).call(this, value));
|
|
1064
|
+
}
|
|
1065
|
+
exportOptions() {
|
|
1066
|
+
return { count: __privateGet(this, _count2), open: __privateGet(this, _open2) };
|
|
1067
|
+
}
|
|
1068
|
+
};
|
|
1069
|
+
_count2 = new WeakMap();
|
|
1070
|
+
_open2 = new WeakMap();
|
|
1071
|
+
_Switch_instances = new WeakSet();
|
|
1072
|
+
clamp_fn2 = function(value) {
|
|
1073
|
+
return Math.max(0, Math.min(__privateGet(this, _count2), Math.trunc(value)));
|
|
1074
|
+
};
|
|
1075
|
+
_Switch.type = "webmusic.switch";
|
|
1076
|
+
var Switch = _Switch;
|
|
1077
|
+
|
|
1078
|
+
// src/message/values.ts
|
|
1079
|
+
var finite3 = (value) => typeof value === "number" && Number.isFinite(value);
|
|
1080
|
+
var whole = (name, value, fallback, least, most) => {
|
|
1081
|
+
if (value === void 0) return fallback;
|
|
1082
|
+
if (!finite3(value)) throw new TypeError(`${name} must be a number.`);
|
|
1083
|
+
return Math.max(least, Math.min(most, Math.trunc(value)));
|
|
1084
|
+
};
|
|
1085
|
+
var _flashes;
|
|
1086
|
+
var _Button = class _Button extends ControlModule {
|
|
1087
|
+
constructor(options = {}) {
|
|
1088
|
+
super(_Button.type, options);
|
|
1089
|
+
this.kind = "button";
|
|
1090
|
+
this.inputs = { trigger: this.input("trigger", "anything flashes and outputs a bang", (value) => this.receive(value)) };
|
|
1091
|
+
this.outputs = { bang: this.output("bang", "bang") };
|
|
1092
|
+
__privateAdd(this, _flashes, 0);
|
|
1093
|
+
}
|
|
1094
|
+
/** How many times it has fired. */
|
|
1095
|
+
get flashes() {
|
|
1096
|
+
return __privateGet(this, _flashes);
|
|
1097
|
+
}
|
|
1098
|
+
/** Fire: flash and send a bang at `time`. */
|
|
1099
|
+
press(time) {
|
|
1100
|
+
__privateWrapper(this, _flashes)._++;
|
|
1101
|
+
this.changed();
|
|
1102
|
+
this.outputs.bang.send(bang(time));
|
|
1103
|
+
}
|
|
1104
|
+
snapshot() {
|
|
1105
|
+
return { flashes: __privateGet(this, _flashes) };
|
|
1106
|
+
}
|
|
1107
|
+
exportOptions() {
|
|
1108
|
+
return {};
|
|
1109
|
+
}
|
|
1110
|
+
receive(value) {
|
|
1111
|
+
this.press(value.time);
|
|
1112
|
+
}
|
|
1113
|
+
};
|
|
1114
|
+
_flashes = new WeakMap();
|
|
1115
|
+
_Button.type = "webmusic.button";
|
|
1116
|
+
var Button = _Button;
|
|
1117
|
+
var _on;
|
|
1118
|
+
var _Toggle = class _Toggle extends ControlModule {
|
|
1119
|
+
constructor(options = {}) {
|
|
1120
|
+
super(_Toggle.type, options);
|
|
1121
|
+
this.kind = "toggle";
|
|
1122
|
+
this.inputs = { value: this.input("value", "bang flips, a number sets, set", (value) => this.receive(value)) };
|
|
1123
|
+
this.outputs = { value: this.output("value", "0 or 1") };
|
|
1124
|
+
__privateAdd(this, _on);
|
|
1125
|
+
__privateSet(this, _on, options.value === true);
|
|
1126
|
+
}
|
|
1127
|
+
get value() {
|
|
1128
|
+
return __privateGet(this, _on);
|
|
1129
|
+
}
|
|
1130
|
+
/** Set the value and send it; `silent` stores it without sending. */
|
|
1131
|
+
set(on, options = {}) {
|
|
1132
|
+
__privateSet(this, _on, on);
|
|
1133
|
+
this.changed();
|
|
1134
|
+
if (!options.silent) this.outputs.value.send(message("int", [intAtom(on ? 1 : 0)], options.time));
|
|
1135
|
+
}
|
|
1136
|
+
snapshot() {
|
|
1137
|
+
return { on: __privateGet(this, _on) };
|
|
1138
|
+
}
|
|
1139
|
+
exportOptions() {
|
|
1140
|
+
return { value: __privateGet(this, _on) };
|
|
1141
|
+
}
|
|
1142
|
+
receive(value) {
|
|
1143
|
+
const number = numberOf(value);
|
|
1144
|
+
if (value.selector === "set") {
|
|
1145
|
+
if (number !== void 0) this.set(number !== 0, { silent: true });
|
|
1146
|
+
return;
|
|
1147
|
+
}
|
|
1148
|
+
if (value.selector === "bang") this.set(!__privateGet(this, _on), { time: value.time });
|
|
1149
|
+
else if (number !== void 0) this.set(number !== 0, { time: value.time });
|
|
1150
|
+
}
|
|
1151
|
+
};
|
|
1152
|
+
_on = new WeakMap();
|
|
1153
|
+
_Toggle.type = "webmusic.toggle";
|
|
1154
|
+
var Toggle = _Toggle;
|
|
1155
|
+
var NUMBER_CONTROLS = ["number", "slider", "dial"];
|
|
1156
|
+
var _value, _NumberValue_instances, clamp_fn3;
|
|
1157
|
+
var _NumberValue = class _NumberValue extends ControlModule {
|
|
1158
|
+
constructor(options = {}) {
|
|
1159
|
+
super(_NumberValue.type, options);
|
|
1160
|
+
__privateAdd(this, _NumberValue_instances);
|
|
1161
|
+
this.inputs = { value: this.input("value", "value to set and output, set, bang", (value) => this.receive(value)) };
|
|
1162
|
+
this.outputs = { value: this.output("value", "value") };
|
|
1163
|
+
__privateAdd(this, _value);
|
|
1164
|
+
if (options.control !== void 0 && !NUMBER_CONTROLS.includes(options.control)) throw new TypeError("A number is shown as number, slider or dial.");
|
|
1165
|
+
this.kind = options.control ?? "number";
|
|
1166
|
+
const box = this.kind === "number";
|
|
1167
|
+
this.min = finite3(options.min) ? options.min : box ? -Infinity : 0;
|
|
1168
|
+
this.max = finite3(options.max) ? options.max : box ? Infinity : 127;
|
|
1169
|
+
this.float = options.float === true;
|
|
1170
|
+
__privateSet(this, _value, __privateMethod(this, _NumberValue_instances, clamp_fn3).call(this, finite3(options.value) ? options.value : Math.min(Math.max(0, Math.min(this.min, this.max)), Math.max(this.min, this.max))));
|
|
1171
|
+
}
|
|
1172
|
+
get value() {
|
|
1173
|
+
return __privateGet(this, _value);
|
|
1174
|
+
}
|
|
1175
|
+
/** Set the value, moved into the range, and send it; `silent` stores it without sending. */
|
|
1176
|
+
set(value, options = {}) {
|
|
1177
|
+
__privateSet(this, _value, __privateMethod(this, _NumberValue_instances, clamp_fn3).call(this, value));
|
|
1178
|
+
this.changed();
|
|
1179
|
+
if (!options.silent) this.outputs.value.send(numberMessage(__privateGet(this, _value), this.float, options.time));
|
|
1180
|
+
}
|
|
1181
|
+
snapshot() {
|
|
1182
|
+
return { value: __privateGet(this, _value), min: this.min, max: this.max, float: this.float };
|
|
1183
|
+
}
|
|
1184
|
+
exportOptions() {
|
|
1185
|
+
return { control: this.kind, ...Number.isFinite(this.min) ? { min: this.min } : {}, ...Number.isFinite(this.max) ? { max: this.max } : {}, float: this.float, value: __privateGet(this, _value) };
|
|
1186
|
+
}
|
|
1187
|
+
receive(input) {
|
|
1188
|
+
const number = numberOf(input);
|
|
1189
|
+
if (input.selector === "bang") {
|
|
1190
|
+
this.outputs.value.send(numberMessage(__privateGet(this, _value), this.float, input.time));
|
|
1191
|
+
return;
|
|
1192
|
+
}
|
|
1193
|
+
if (number === void 0) return;
|
|
1194
|
+
this.set(number, { silent: input.selector === "set", time: input.time });
|
|
1195
|
+
}
|
|
1196
|
+
};
|
|
1197
|
+
_value = new WeakMap();
|
|
1198
|
+
_NumberValue_instances = new WeakSet();
|
|
1199
|
+
clamp_fn3 = function(value) {
|
|
1200
|
+
const bounded = Math.min(Math.max(this.min, this.max), Math.max(Math.min(this.min, this.max), value));
|
|
1201
|
+
return this.float ? bounded : Math.round(bounded);
|
|
1202
|
+
};
|
|
1203
|
+
_NumberValue.type = "webmusic.number";
|
|
1204
|
+
var NumberValue = _NumberValue;
|
|
1205
|
+
var _index, _Choice_instances, send_fn, clamp_fn4;
|
|
1206
|
+
var _Choice = class _Choice extends ControlModule {
|
|
1207
|
+
constructor(options) {
|
|
1208
|
+
super(_Choice.type, options);
|
|
1209
|
+
__privateAdd(this, _Choice_instances);
|
|
1210
|
+
this.inputs = { index: this.input("index", "index to choose and output, set, bang", (value) => this.receive(value)) };
|
|
1211
|
+
this.outputs = { index: this.output("index", "index"), item: this.output("item", "item") };
|
|
1212
|
+
__privateAdd(this, _index);
|
|
1213
|
+
if (options.control !== void 0 && options.control !== "menu" && options.control !== "tab") throw new TypeError("A choice is shown as menu or tab.");
|
|
1214
|
+
this.kind = options.control ?? "menu";
|
|
1215
|
+
if (!Array.isArray(options.items) || !options.items.length || !options.items.every((item) => typeof item === "string")) {
|
|
1216
|
+
throw new TypeError(`${this.kind} needs at least one item.`);
|
|
1217
|
+
}
|
|
1218
|
+
this.items = Object.freeze([...options.items]);
|
|
1219
|
+
__privateSet(this, _index, __privateMethod(this, _Choice_instances, clamp_fn4).call(this, finite3(options.value) ? options.value : 0));
|
|
1220
|
+
}
|
|
1221
|
+
/** The chosen index. */
|
|
1222
|
+
get value() {
|
|
1223
|
+
return __privateGet(this, _index);
|
|
1224
|
+
}
|
|
1225
|
+
/** Choose an index and send it; `silent` stores it without sending. */
|
|
1226
|
+
set(index, options = {}) {
|
|
1227
|
+
__privateSet(this, _index, __privateMethod(this, _Choice_instances, clamp_fn4).call(this, index));
|
|
1228
|
+
this.changed();
|
|
1229
|
+
if (!options.silent) __privateMethod(this, _Choice_instances, send_fn).call(this, options.time);
|
|
1230
|
+
}
|
|
1231
|
+
snapshot() {
|
|
1232
|
+
return { items: this.items, index: __privateGet(this, _index) };
|
|
1233
|
+
}
|
|
1234
|
+
exportOptions() {
|
|
1235
|
+
return { control: this.kind, items: this.items, value: __privateGet(this, _index) };
|
|
1236
|
+
}
|
|
1237
|
+
receive(value) {
|
|
1238
|
+
const number = numberOf(value);
|
|
1239
|
+
if (value.selector === "bang") {
|
|
1240
|
+
__privateMethod(this, _Choice_instances, send_fn).call(this, value.time);
|
|
1241
|
+
return;
|
|
1242
|
+
}
|
|
1243
|
+
if (number === void 0) return;
|
|
1244
|
+
this.set(number, { silent: value.selector === "set", time: value.time });
|
|
1245
|
+
}
|
|
1246
|
+
};
|
|
1247
|
+
_index = new WeakMap();
|
|
1248
|
+
_Choice_instances = new WeakSet();
|
|
1249
|
+
send_fn = function(time) {
|
|
1250
|
+
this.outputs.item.send(messageFromAtoms([symbolAtom(this.items[__privateGet(this, _index)])], time));
|
|
1251
|
+
this.outputs.index.send(message("int", [intAtom(__privateGet(this, _index))], time));
|
|
1252
|
+
};
|
|
1253
|
+
clamp_fn4 = function(value) {
|
|
1254
|
+
return Math.max(0, Math.min(this.items.length - 1, Math.trunc(value)));
|
|
1255
|
+
};
|
|
1256
|
+
_Choice.type = "webmusic.choice";
|
|
1257
|
+
var Choice = _Choice;
|
|
1258
|
+
var _text;
|
|
1259
|
+
var _MessageBox = class _MessageBox extends ControlModule {
|
|
1260
|
+
constructor(options = {}) {
|
|
1261
|
+
super(_MessageBox.type, options);
|
|
1262
|
+
this.kind = "message";
|
|
1263
|
+
this.inputs = { trigger: this.input("trigger", "bang outputs, $1\u2026 fill from any message, set", (value) => this.receive(value)) };
|
|
1264
|
+
this.outputs = { message: this.output("message", "the message") };
|
|
1265
|
+
__privateAdd(this, _text);
|
|
1266
|
+
if (options.text !== void 0 && typeof options.text !== "string") throw new TypeError("A message box holds text.");
|
|
1267
|
+
__privateSet(this, _text, options.text ?? "");
|
|
1268
|
+
}
|
|
1269
|
+
get text() {
|
|
1270
|
+
return __privateGet(this, _text);
|
|
1271
|
+
}
|
|
1272
|
+
set text(value) {
|
|
1273
|
+
__privateSet(this, _text, value);
|
|
1274
|
+
this.changed();
|
|
1275
|
+
}
|
|
1276
|
+
/** Send the text as messages, with `$1`… taken from `values`. */
|
|
1277
|
+
send(values2 = [], time) {
|
|
1278
|
+
const text = (atom) => formatMessage(messageFromAtoms([atom]));
|
|
1279
|
+
for (const part of __privateGet(this, _text).split(",")) {
|
|
1280
|
+
const filled = part.replace(/\$([1-9])/g, (_, digit) => {
|
|
1281
|
+
const atom = values2[Number(digit) - 1];
|
|
1282
|
+
return atom ? text(atom) : "0";
|
|
1283
|
+
}).trim();
|
|
1284
|
+
if (filled) this.outputs.message.send(parseMessage(filled, time));
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
snapshot() {
|
|
1288
|
+
return { text: __privateGet(this, _text) };
|
|
1289
|
+
}
|
|
1290
|
+
exportOptions() {
|
|
1291
|
+
return { text: __privateGet(this, _text) };
|
|
1292
|
+
}
|
|
1293
|
+
receive(value) {
|
|
1294
|
+
if (value.selector === "set") {
|
|
1295
|
+
this.text = value.atoms.map((atom) => formatMessage(messageFromAtoms([atom]))).join(" ");
|
|
1296
|
+
return;
|
|
1297
|
+
}
|
|
1298
|
+
this.send(value.selector === "bang" ? [] : atomsOf(value), value.time);
|
|
1299
|
+
}
|
|
1300
|
+
};
|
|
1301
|
+
_text = new WeakMap();
|
|
1302
|
+
_MessageBox.type = "webmusic.message-box";
|
|
1303
|
+
var MessageBox = _MessageBox;
|
|
1304
|
+
var _values, _ValueList_instances, send_fn2, clamp_fn5;
|
|
1305
|
+
var _ValueList = class _ValueList extends ControlModule {
|
|
1306
|
+
constructor(options = {}) {
|
|
1307
|
+
super(_ValueList.type, options);
|
|
1308
|
+
__privateAdd(this, _ValueList_instances);
|
|
1309
|
+
this.kind = "multislider";
|
|
1310
|
+
this.inputs = { values: this.input("values", "list to set and output, set, bang", (value) => this.receive(value)) };
|
|
1311
|
+
this.outputs = { values: this.output("values", "list of values") };
|
|
1312
|
+
__privateAdd(this, _values);
|
|
1313
|
+
const count3 = whole("count", options.count, 8, 1, 128);
|
|
1314
|
+
this.min = finite3(options.min) ? options.min : 0;
|
|
1315
|
+
this.max = finite3(options.max) ? options.max : 1;
|
|
1316
|
+
this.float = options.float !== false;
|
|
1317
|
+
const saved = options.values;
|
|
1318
|
+
__privateSet(this, _values, Array.from({ length: count3 }, (_, index) => __privateMethod(this, _ValueList_instances, clamp_fn5).call(this, Array.isArray(saved) && finite3(saved[index]) ? saved[index] : this.min)));
|
|
1319
|
+
}
|
|
1320
|
+
get values() {
|
|
1321
|
+
return [...__privateGet(this, _values)];
|
|
1322
|
+
}
|
|
1323
|
+
/** Set values from the first on and send the list; `silent` stores them without sending. */
|
|
1324
|
+
set(values2, options = {}) {
|
|
1325
|
+
values2.forEach((value, index) => {
|
|
1326
|
+
if (finite3(value) && index < __privateGet(this, _values).length) __privateGet(this, _values)[index] = __privateMethod(this, _ValueList_instances, clamp_fn5).call(this, value);
|
|
1327
|
+
});
|
|
1328
|
+
this.changed();
|
|
1329
|
+
if (!options.silent) __privateMethod(this, _ValueList_instances, send_fn2).call(this, options.time);
|
|
1330
|
+
}
|
|
1331
|
+
snapshot() {
|
|
1332
|
+
return { values: [...__privateGet(this, _values)], min: this.min, max: this.max, float: this.float };
|
|
1333
|
+
}
|
|
1334
|
+
exportOptions() {
|
|
1335
|
+
return { count: __privateGet(this, _values).length, min: this.min, max: this.max, float: this.float, values: [...__privateGet(this, _values)] };
|
|
1336
|
+
}
|
|
1337
|
+
receive(value) {
|
|
1338
|
+
const atoms = atomsOf(value);
|
|
1339
|
+
if (value.selector === "bang") {
|
|
1340
|
+
__privateMethod(this, _ValueList_instances, send_fn2).call(this, value.time);
|
|
1341
|
+
return;
|
|
1342
|
+
}
|
|
1343
|
+
const silent = value.selector === "set";
|
|
1344
|
+
const given = silent ? atoms.slice(1) : atoms;
|
|
1345
|
+
if (!silent && !given.some(isNumberAtom)) return;
|
|
1346
|
+
this.set(given.map((atom) => isNumberAtom(atom) ? atom.value : NaN), { silent, time: value.time });
|
|
1347
|
+
}
|
|
1348
|
+
};
|
|
1349
|
+
_values = new WeakMap();
|
|
1350
|
+
_ValueList_instances = new WeakSet();
|
|
1351
|
+
send_fn2 = function(time) {
|
|
1352
|
+
this.outputs.values.send(message("list", __privateGet(this, _values).map((value) => this.float ? floatAtom(value) : intAtom(value)), time));
|
|
1353
|
+
};
|
|
1354
|
+
clamp_fn5 = function(value) {
|
|
1355
|
+
const bounded = Math.min(Math.max(this.min, this.max), Math.max(Math.min(this.min, this.max), value));
|
|
1356
|
+
return this.float ? bounded : Math.round(bounded);
|
|
1357
|
+
};
|
|
1358
|
+
_ValueList.type = "webmusic.value-list";
|
|
1359
|
+
var ValueList = _ValueList;
|
|
1360
|
+
var _cells, _Matrix_instances, send_fn3;
|
|
1361
|
+
var _Matrix = class _Matrix extends ControlModule {
|
|
1362
|
+
constructor(options = {}) {
|
|
1363
|
+
super(_Matrix.type, options);
|
|
1364
|
+
__privateAdd(this, _Matrix_instances);
|
|
1365
|
+
this.kind = "matrix";
|
|
1366
|
+
this.inputs = { cell: this.input("cell", "column row value, clear, bang", (value) => this.receive(value)) };
|
|
1367
|
+
this.outputs = { cell: this.output("cell", "column row value") };
|
|
1368
|
+
__privateAdd(this, _cells);
|
|
1369
|
+
this.columns = whole("columns", options.columns, 4, 1, 32);
|
|
1370
|
+
this.rows = whole("rows", options.rows, 4, 1, 32);
|
|
1371
|
+
const saved = options.cells;
|
|
1372
|
+
__privateSet(this, _cells, Array.from({ length: this.columns * this.rows }, (_, index) => Array.isArray(saved) && saved[index] === 1 ? 1 : 0));
|
|
1373
|
+
}
|
|
1374
|
+
/** The cells by row, 0 or 1 each. */
|
|
1375
|
+
get cells() {
|
|
1376
|
+
return [...__privateGet(this, _cells)];
|
|
1377
|
+
}
|
|
1378
|
+
/** Set one cell and send it; `silent` stores it without sending. Cells outside the grid are ignored. */
|
|
1379
|
+
set(column, row, on, options = {}) {
|
|
1380
|
+
if (column < 0 || column >= this.columns || row < 0 || row >= this.rows) return;
|
|
1381
|
+
__privateGet(this, _cells)[row * this.columns + column] = on ? 1 : 0;
|
|
1382
|
+
this.changed();
|
|
1383
|
+
if (!options.silent) __privateMethod(this, _Matrix_instances, send_fn3).call(this, column, row, on ? 1 : 0, options.time);
|
|
1384
|
+
}
|
|
1385
|
+
clear() {
|
|
1386
|
+
__privateGet(this, _cells).fill(0);
|
|
1387
|
+
this.changed();
|
|
1388
|
+
}
|
|
1389
|
+
snapshot() {
|
|
1390
|
+
return { columns: this.columns, rows: this.rows, cells: [...__privateGet(this, _cells)] };
|
|
1391
|
+
}
|
|
1392
|
+
exportOptions() {
|
|
1393
|
+
return { columns: this.columns, rows: this.rows, cells: [...__privateGet(this, _cells)] };
|
|
1394
|
+
}
|
|
1395
|
+
receive(value) {
|
|
1396
|
+
if (value.selector === "clear") {
|
|
1397
|
+
this.clear();
|
|
1398
|
+
return;
|
|
1399
|
+
}
|
|
1400
|
+
if (value.selector === "bang") {
|
|
1401
|
+
for (let row2 = 0; row2 < this.rows; row2++) for (let column2 = 0; column2 < this.columns; column2++) if (__privateGet(this, _cells)[row2 * this.columns + column2]) __privateMethod(this, _Matrix_instances, send_fn3).call(this, column2, row2, 1, value.time);
|
|
1402
|
+
return;
|
|
1403
|
+
}
|
|
1404
|
+
const silent = value.selector === "set";
|
|
1405
|
+
const numbers = (silent ? value.atoms : atomsOf(value)).filter(isNumberAtom).map((atom) => Math.trunc(atom.value));
|
|
1406
|
+
if (numbers.length < 3) return;
|
|
1407
|
+
const [column, row, on] = numbers;
|
|
1408
|
+
this.set(column, row, on !== 0, { silent, time: value.time });
|
|
1409
|
+
}
|
|
1410
|
+
};
|
|
1411
|
+
_cells = new WeakMap();
|
|
1412
|
+
_Matrix_instances = new WeakSet();
|
|
1413
|
+
send_fn3 = function(column, row, value, time) {
|
|
1414
|
+
this.outputs.cell.send(message("list", [intAtom(column), intAtom(row), intAtom(value)], time));
|
|
1415
|
+
};
|
|
1416
|
+
_Matrix.type = "webmusic.matrix";
|
|
1417
|
+
var Matrix = _Matrix;
|
|
1418
|
+
|
|
1419
|
+
// src/message/sources.ts
|
|
1420
|
+
var finite4 = (value) => typeof value === "number" && Number.isFinite(value);
|
|
1421
|
+
function constantControl(audio, initial) {
|
|
1422
|
+
const node = audio.createConstantSource();
|
|
1423
|
+
node.offset.value = initial;
|
|
1424
|
+
node.start();
|
|
1425
|
+
const segments = [];
|
|
1426
|
+
const valueAt = (time) => {
|
|
1427
|
+
let value = initial;
|
|
1428
|
+
for (const segment of segments) {
|
|
1429
|
+
if (time >= segment.end) value = segment.to;
|
|
1430
|
+
else if (time >= segment.start) value = segment.from + (segment.to - segment.from) * ((time - segment.start) / Math.max(1e-9, segment.end - segment.start));
|
|
1431
|
+
}
|
|
1432
|
+
return value;
|
|
1433
|
+
};
|
|
1434
|
+
return {
|
|
1435
|
+
control: Object.freeze({ output: node, rate: "a-rate", range: Object.freeze({ min: -1, max: 1 }) }),
|
|
1436
|
+
/** Jump to `value` at `time`. */
|
|
1437
|
+
set(value, time) {
|
|
1438
|
+
node.offset.cancelScheduledValues(time);
|
|
1439
|
+
node.offset.setValueAtTime(value, time);
|
|
1440
|
+
segments.splice(0, segments.length, { start: time, from: value, end: time, to: value });
|
|
1441
|
+
},
|
|
1442
|
+
/** Ramp through `[target, ms]` pairs from `time`; returns when it ends. */
|
|
1443
|
+
ramp(pairs, time) {
|
|
1444
|
+
let start = time, from = valueAt(time);
|
|
1445
|
+
node.offset.cancelScheduledValues(time);
|
|
1446
|
+
node.offset.setValueAtTime(from, time);
|
|
1447
|
+
segments.splice(0, segments.length);
|
|
1448
|
+
for (const [target, ms] of pairs) {
|
|
1449
|
+
const end = start + Math.max(0, ms) / 1e3;
|
|
1450
|
+
if (end > start) node.offset.linearRampToValueAtTime(target, end);
|
|
1451
|
+
else node.offset.setValueAtTime(target, end);
|
|
1452
|
+
segments.push({ start, from, end, to: target });
|
|
1453
|
+
start = end;
|
|
1454
|
+
from = target;
|
|
1455
|
+
}
|
|
1456
|
+
return start;
|
|
1457
|
+
},
|
|
1458
|
+
when: (time) => Math.max(audio.currentTime, time ?? audio.currentTime),
|
|
1459
|
+
current: () => valueAt(audio.currentTime),
|
|
1460
|
+
dispose() {
|
|
1461
|
+
try {
|
|
1462
|
+
node.stop();
|
|
1463
|
+
} catch {
|
|
1464
|
+
}
|
|
1465
|
+
node.disconnect();
|
|
1466
|
+
}
|
|
1467
|
+
};
|
|
1468
|
+
}
|
|
1469
|
+
var _output, _last;
|
|
1470
|
+
var _ControlSource = class _ControlSource extends GraphModule {
|
|
1471
|
+
constructor(options = {}) {
|
|
1472
|
+
super(_ControlSource.type, options);
|
|
1473
|
+
this.inputs = { value: this.input("value", "value", (value) => {
|
|
1474
|
+
const number = numberOf(value);
|
|
1475
|
+
if (number !== void 0) this.set(number, value.time);
|
|
1476
|
+
}) };
|
|
1477
|
+
__privateAdd(this, _output);
|
|
1478
|
+
__privateAdd(this, _last);
|
|
1479
|
+
__privateSet(this, _last, finite4(options.value) ? options.value : 0);
|
|
1480
|
+
__privateSet(this, _output, constantControl(this.audio(), __privateGet(this, _last)));
|
|
1481
|
+
this.addPort(void 0, { id: "output", label: "signal", kind: "control", direction: "output" });
|
|
1482
|
+
}
|
|
1483
|
+
get control() {
|
|
1484
|
+
return __privateGet(this, _output).control;
|
|
1485
|
+
}
|
|
1486
|
+
/** The last value it was set to. */
|
|
1487
|
+
get value() {
|
|
1488
|
+
return __privateGet(this, _last);
|
|
1489
|
+
}
|
|
1490
|
+
/** Jump to `value` at `time` (now by default). */
|
|
1491
|
+
set(value, time) {
|
|
1492
|
+
__privateSet(this, _last, value);
|
|
1493
|
+
__privateGet(this, _output).set(value, __privateGet(this, _output).when(time));
|
|
1494
|
+
}
|
|
1495
|
+
exportOptions() {
|
|
1496
|
+
return { value: __privateGet(this, _last) };
|
|
1497
|
+
}
|
|
1498
|
+
onDispose() {
|
|
1499
|
+
__privateGet(this, _output).dispose();
|
|
1500
|
+
}
|
|
1501
|
+
};
|
|
1502
|
+
_output = new WeakMap();
|
|
1503
|
+
_last = new WeakMap();
|
|
1504
|
+
_ControlSource.type = "webmusic.control-source";
|
|
1505
|
+
var ControlSource = _ControlSource;
|
|
1506
|
+
var _output2, _cancel4;
|
|
1507
|
+
var _ControlRamp = class _ControlRamp extends GraphModule {
|
|
1508
|
+
constructor(options = {}) {
|
|
1509
|
+
super(_ControlRamp.type, options);
|
|
1510
|
+
this.inputs = { target: this.input("target", "target, or target and time (ms) pairs", (value) => {
|
|
1511
|
+
const numbers = atomsOf(value).filter(isNumberAtom).map((atom) => atom.value);
|
|
1512
|
+
if (value.selector === "stop") {
|
|
1513
|
+
this.stop(value.time);
|
|
1514
|
+
return;
|
|
1515
|
+
}
|
|
1516
|
+
if (!numbers.length) return;
|
|
1517
|
+
if (numbers.length === 1) {
|
|
1518
|
+
__privateGet(this, _output2).set(numbers[0], __privateGet(this, _output2).when(value.time));
|
|
1519
|
+
return;
|
|
1520
|
+
}
|
|
1521
|
+
const pairs = [];
|
|
1522
|
+
for (let index = 0; index + 1 < numbers.length; index += 2) pairs.push([numbers[index], numbers[index + 1]]);
|
|
1523
|
+
this.ramp(pairs, value.time);
|
|
1524
|
+
}) };
|
|
1525
|
+
this.outputs = { done: this.output("done", "bang at the end") };
|
|
1526
|
+
__privateAdd(this, _output2);
|
|
1527
|
+
__privateAdd(this, _cancel4);
|
|
1528
|
+
__privateSet(this, _output2, constantControl(this.audio(), finite4(options.value) ? options.value : 0));
|
|
1529
|
+
this.addPort(void 0, { id: "output", label: "signal", kind: "control", direction: "output" });
|
|
1530
|
+
}
|
|
1531
|
+
get control() {
|
|
1532
|
+
return __privateGet(this, _output2).control;
|
|
1533
|
+
}
|
|
1534
|
+
/** The value the signal has now. */
|
|
1535
|
+
get value() {
|
|
1536
|
+
return __privateGet(this, _output2).current();
|
|
1537
|
+
}
|
|
1538
|
+
/** Ramp through `[target, milliseconds]` pairs from `time` (now by default). */
|
|
1539
|
+
ramp(pairs, time) {
|
|
1540
|
+
var _a;
|
|
1541
|
+
const end = __privateGet(this, _output2).ramp(pairs, __privateGet(this, _output2).when(time));
|
|
1542
|
+
(_a = __privateGet(this, _cancel4)) == null ? void 0 : _a.call(this);
|
|
1543
|
+
__privateSet(this, _cancel4, this.clock.schedule(end, (when) => {
|
|
1544
|
+
__privateSet(this, _cancel4, void 0);
|
|
1545
|
+
this.outputs.done.send(bang(when));
|
|
1546
|
+
}));
|
|
1547
|
+
}
|
|
1548
|
+
/** Hold the value the signal has at `time` (now by default). */
|
|
1549
|
+
stop(time) {
|
|
1550
|
+
var _a;
|
|
1551
|
+
__privateGet(this, _output2).set(__privateGet(this, _output2).current(), __privateGet(this, _output2).when(time));
|
|
1552
|
+
(_a = __privateGet(this, _cancel4)) == null ? void 0 : _a.call(this);
|
|
1553
|
+
}
|
|
1554
|
+
exportOptions() {
|
|
1555
|
+
return { value: __privateGet(this, _output2).current() };
|
|
1556
|
+
}
|
|
1557
|
+
onDispose() {
|
|
1558
|
+
var _a;
|
|
1559
|
+
(_a = __privateGet(this, _cancel4)) == null ? void 0 : _a.call(this);
|
|
1560
|
+
__privateGet(this, _output2).dispose();
|
|
1561
|
+
}
|
|
1562
|
+
};
|
|
1563
|
+
_output2 = new WeakMap();
|
|
1564
|
+
_cancel4 = new WeakMap();
|
|
1565
|
+
_ControlRamp.type = "webmusic.control-ramp";
|
|
1566
|
+
var ControlRamp = _ControlRamp;
|
|
1567
|
+
var _TransportReadout = class _TransportReadout extends GraphModule {
|
|
1568
|
+
constructor(options = {}) {
|
|
1569
|
+
super(_TransportReadout.type, options);
|
|
1570
|
+
this.inputs = { trigger: this.input("trigger", "bang reports the position", (value) => {
|
|
1571
|
+
if (value.selector === "bang") this.report(value.time);
|
|
1572
|
+
}) };
|
|
1573
|
+
this.outputs = {
|
|
1574
|
+
position: this.output("position", "bar beat tick"),
|
|
1575
|
+
tempo: this.output("tempo", "tempo (bpm)"),
|
|
1576
|
+
seconds: this.output("seconds", "position (seconds)"),
|
|
1577
|
+
playing: this.output("playing", "playing (0 or 1)")
|
|
1578
|
+
};
|
|
1579
|
+
}
|
|
1580
|
+
/** Send the four readings, last output first. Without a Session it sends nothing. */
|
|
1581
|
+
report(time) {
|
|
1582
|
+
const musical = this.musicalTime;
|
|
1583
|
+
if (!musical) return;
|
|
1584
|
+
const position = musical.barsBeatsTicks();
|
|
1585
|
+
this.outputs.playing.send(message("int", [intAtom(musical.playing() ? 1 : 0)], time));
|
|
1586
|
+
this.outputs.seconds.send(message("float", [floatAtom(musical.position())], time));
|
|
1587
|
+
this.outputs.tempo.send(message("float", [floatAtom(musical.tempo().bpm)], time));
|
|
1588
|
+
this.outputs.position.send(message("list", [intAtom(position.bar), intAtom(position.beat), intAtom(position.tick)], time));
|
|
1589
|
+
}
|
|
1590
|
+
exportOptions() {
|
|
1591
|
+
return {};
|
|
1592
|
+
}
|
|
1593
|
+
};
|
|
1594
|
+
_TransportReadout.type = "webmusic.transport-readout";
|
|
1595
|
+
var TransportReadout = _TransportReadout;
|
|
1596
|
+
var _previous, _timer;
|
|
1597
|
+
var _GamepadSource = class _GamepadSource extends GraphModule {
|
|
1598
|
+
constructor(options = {}) {
|
|
1599
|
+
super(_GamepadSource.type, options);
|
|
1600
|
+
this.inputs = { trigger: this.input("trigger", "bang reports every button and axis", (value) => {
|
|
1601
|
+
if (value.selector === "bang") this.report(true);
|
|
1602
|
+
}) };
|
|
1603
|
+
this.outputs = { events: this.output("events", "button i value, axis i value") };
|
|
1604
|
+
__privateAdd(this, _previous, { buttons: [], axes: [] });
|
|
1605
|
+
__privateAdd(this, _timer);
|
|
1606
|
+
this.index = finite4(options.index) ? Math.trunc(options.index) : 0;
|
|
1607
|
+
}
|
|
1608
|
+
/** Send what changed since the last report, or every button and axis with `all`. */
|
|
1609
|
+
report(all = false) {
|
|
1610
|
+
const pads = typeof navigator !== "undefined" && typeof navigator.getGamepads === "function" ? navigator.getGamepads() : [];
|
|
1611
|
+
const pad = pads[this.index];
|
|
1612
|
+
if (!pad) return;
|
|
1613
|
+
const current = { buttons: pad.buttons.map((button) => button.value), axes: [...pad.axes] };
|
|
1614
|
+
const { events } = this.outputs;
|
|
1615
|
+
current.buttons.forEach((value, i) => {
|
|
1616
|
+
if (all || __privateGet(this, _previous).buttons[i] !== value) events.send(message("button", [intAtom(i), floatAtom(value)]));
|
|
1617
|
+
});
|
|
1618
|
+
current.axes.forEach((value, i) => {
|
|
1619
|
+
if (all || Math.abs((__privateGet(this, _previous).axes[i] ?? 0) - value) > 2e-3) events.send(message("axis", [intAtom(i), floatAtom(value)]));
|
|
1620
|
+
});
|
|
1621
|
+
__privateSet(this, _previous, current);
|
|
1622
|
+
}
|
|
1623
|
+
exportOptions() {
|
|
1624
|
+
return { index: this.index };
|
|
1625
|
+
}
|
|
1626
|
+
onActivate() {
|
|
1627
|
+
__privateSet(this, _timer, setInterval(() => this.guard(() => this.report(false)), 16));
|
|
1628
|
+
}
|
|
1629
|
+
onDispose() {
|
|
1630
|
+
if (__privateGet(this, _timer)) clearInterval(__privateGet(this, _timer));
|
|
1631
|
+
}
|
|
1632
|
+
};
|
|
1633
|
+
_previous = new WeakMap();
|
|
1634
|
+
_timer = new WeakMap();
|
|
1635
|
+
_GamepadSource.type = "webmusic.gamepad";
|
|
1636
|
+
var GamepadSource = _GamepadSource;
|
|
1637
|
+
var _device, _report;
|
|
1638
|
+
var _HidSource = class _HidSource extends GraphModule {
|
|
1639
|
+
constructor(options = {}) {
|
|
1640
|
+
super(_HidSource.type, options);
|
|
1641
|
+
this.inputs = { control: this.input("control", "open, close", (value) => {
|
|
1642
|
+
if (value.selector === "open") void this.open().catch((error) => this.fail(error));
|
|
1643
|
+
else if (value.selector === "close") this.close();
|
|
1644
|
+
}) };
|
|
1645
|
+
this.outputs = { reports: this.output("reports", "report id bytes\u2026"), device: this.output("device", "device name") };
|
|
1646
|
+
__privateAdd(this, _device);
|
|
1647
|
+
__privateAdd(this, _report, (event) => {
|
|
1648
|
+
const bytes = Array.from({ length: event.data.byteLength }, (_, i) => intAtom(event.data.getUint8(i)));
|
|
1649
|
+
this.outputs.reports.send(message("report", [intAtom(event.reportId), ...bytes]));
|
|
1650
|
+
});
|
|
1651
|
+
}
|
|
1652
|
+
/** Ask the browser for a device and listen to it. Call it from a click, as the browser requires. */
|
|
1653
|
+
async open() {
|
|
1654
|
+
const api = globalThis.navigator?.hid;
|
|
1655
|
+
if (!api) throw new Error("This browser has no WebHID.");
|
|
1656
|
+
const [chosen] = await api.requestDevice({ filters: [] });
|
|
1657
|
+
if (!chosen || this.disposed) return;
|
|
1658
|
+
this.close();
|
|
1659
|
+
if (!chosen.opened) await chosen.open();
|
|
1660
|
+
__privateSet(this, _device, chosen);
|
|
1661
|
+
chosen.addEventListener("inputreport", __privateGet(this, _report));
|
|
1662
|
+
this.outputs.device.send(message("symbol", [symbolAtom(chosen.productName || "HID device")]));
|
|
1663
|
+
}
|
|
1664
|
+
/** Release the device. */
|
|
1665
|
+
close() {
|
|
1666
|
+
const device = __privateGet(this, _device);
|
|
1667
|
+
if (!device) return;
|
|
1668
|
+
device.removeEventListener("inputreport", __privateGet(this, _report));
|
|
1669
|
+
void device.close().catch((error) => this.fail(error));
|
|
1670
|
+
__privateSet(this, _device, void 0);
|
|
1671
|
+
}
|
|
1672
|
+
exportOptions() {
|
|
1673
|
+
return {};
|
|
1674
|
+
}
|
|
1675
|
+
onDispose() {
|
|
1676
|
+
this.close();
|
|
1677
|
+
}
|
|
1678
|
+
};
|
|
1679
|
+
_device = new WeakMap();
|
|
1680
|
+
_report = new WeakMap();
|
|
1681
|
+
_HidSource.type = "webmusic.hid";
|
|
1682
|
+
var HidSource = _HidSource;
|
|
1683
|
+
function fromOsc(packet) {
|
|
1684
|
+
if (isOscBundle(packet)) return packet.elements.flatMap(fromOsc);
|
|
1685
|
+
const atoms = packet.args.flatMap((arg) => {
|
|
1686
|
+
switch (arg.type) {
|
|
1687
|
+
case "i":
|
|
1688
|
+
return [intAtom(arg.value)];
|
|
1689
|
+
case "f":
|
|
1690
|
+
return [floatAtom(arg.value)];
|
|
1691
|
+
case "s":
|
|
1692
|
+
return [symbolAtom(arg.value)];
|
|
1693
|
+
case "T":
|
|
1694
|
+
return [intAtom(1)];
|
|
1695
|
+
case "F":
|
|
1696
|
+
return [intAtom(0)];
|
|
1697
|
+
default:
|
|
1698
|
+
return [];
|
|
1699
|
+
}
|
|
1700
|
+
});
|
|
1701
|
+
return [message(packet.address, atoms)];
|
|
1702
|
+
}
|
|
1703
|
+
function toOsc(value) {
|
|
1704
|
+
if (!value.selector.startsWith("/")) return void 0;
|
|
1705
|
+
const args = value.atoms.flatMap((atom) => {
|
|
1706
|
+
if (atom.type === "int") return [{ type: "i", value: atom.value }];
|
|
1707
|
+
if (atom.type === "float") return [{ type: "f", value: atom.value }];
|
|
1708
|
+
if (atom.type === "symbol") return [{ type: "s", value: atom.value }];
|
|
1709
|
+
return [];
|
|
1710
|
+
});
|
|
1711
|
+
return { address: value.selector, args };
|
|
1712
|
+
}
|
|
1713
|
+
function bridgeUrl(name, url) {
|
|
1714
|
+
if (typeof url !== "string" || !url) throw new TypeError(`${name} needs a ws:// or wss:// bridge address.`);
|
|
1715
|
+
return url;
|
|
1716
|
+
}
|
|
1717
|
+
function oscSocket(url, onPacket, onStatus, fail) {
|
|
1718
|
+
if (typeof WebSocket === "undefined") throw new Error("This environment has no WebSocket.");
|
|
1719
|
+
if (!/^wss?:\/\//.test(url)) throw new Error("An OSC bridge address starts with ws:// or wss://.");
|
|
1720
|
+
let socket;
|
|
1721
|
+
let closed = false;
|
|
1722
|
+
let retry;
|
|
1723
|
+
const connect = () => {
|
|
1724
|
+
if (closed) return;
|
|
1725
|
+
socket = new WebSocket(url);
|
|
1726
|
+
socket.binaryType = "arraybuffer";
|
|
1727
|
+
socket.onopen = () => onStatus("open");
|
|
1728
|
+
socket.onclose = () => {
|
|
1729
|
+
onStatus("closed");
|
|
1730
|
+
if (!closed) retry = setTimeout(connect, 2e3);
|
|
1731
|
+
};
|
|
1732
|
+
socket.onerror = () => onStatus("error");
|
|
1733
|
+
socket.onmessage = (event) => {
|
|
1734
|
+
if (!onPacket || !(event.data instanceof ArrayBuffer)) return;
|
|
1735
|
+
try {
|
|
1736
|
+
onPacket(decodeOsc(event.data));
|
|
1737
|
+
} catch (error) {
|
|
1738
|
+
fail(error);
|
|
1739
|
+
}
|
|
1740
|
+
};
|
|
1741
|
+
};
|
|
1742
|
+
connect();
|
|
1743
|
+
return {
|
|
1744
|
+
send(packet) {
|
|
1745
|
+
if (socket?.readyState === 1) socket.send(encodeOsc(packet));
|
|
1746
|
+
},
|
|
1747
|
+
close() {
|
|
1748
|
+
closed = true;
|
|
1749
|
+
if (retry) clearTimeout(retry);
|
|
1750
|
+
socket?.close();
|
|
1751
|
+
}
|
|
1752
|
+
};
|
|
1753
|
+
}
|
|
1754
|
+
var _socket;
|
|
1755
|
+
var _OscSource = class _OscSource extends GraphModule {
|
|
1756
|
+
constructor(options) {
|
|
1757
|
+
super(_OscSource.type, options);
|
|
1758
|
+
this.outputs = { messages: this.output("messages", "/address arguments\u2026"), status: this.output("status", "connection: open, closed, error") };
|
|
1759
|
+
__privateAdd(this, _socket);
|
|
1760
|
+
this.url = bridgeUrl("An OSC source", options?.url);
|
|
1761
|
+
}
|
|
1762
|
+
exportOptions() {
|
|
1763
|
+
return { url: this.url };
|
|
1764
|
+
}
|
|
1765
|
+
onActivate() {
|
|
1766
|
+
__privateSet(this, _socket, oscSocket(
|
|
1767
|
+
this.url,
|
|
1768
|
+
(packet) => {
|
|
1769
|
+
for (const value of fromOsc(packet)) this.outputs.messages.send(value);
|
|
1770
|
+
},
|
|
1771
|
+
(status) => this.outputs.status.send(message("symbol", [symbolAtom(status)])),
|
|
1772
|
+
(error) => this.fail(error)
|
|
1773
|
+
));
|
|
1774
|
+
}
|
|
1775
|
+
onDispose() {
|
|
1776
|
+
__privateGet(this, _socket)?.close();
|
|
1777
|
+
}
|
|
1778
|
+
};
|
|
1779
|
+
_socket = new WeakMap();
|
|
1780
|
+
_OscSource.type = "webmusic.osc-in";
|
|
1781
|
+
var OscSource = _OscSource;
|
|
1782
|
+
var _socket2;
|
|
1783
|
+
var _OscSink = class _OscSink extends GraphModule {
|
|
1784
|
+
constructor(options) {
|
|
1785
|
+
super(_OscSink.type, options);
|
|
1786
|
+
this.inputs = { messages: this.input("messages", "/address arguments\u2026", (value) => this.send(value)) };
|
|
1787
|
+
this.outputs = { status: this.output("status", "connection: open, closed, error") };
|
|
1788
|
+
__privateAdd(this, _socket2);
|
|
1789
|
+
this.url = bridgeUrl("An OSC sink", options?.url);
|
|
1790
|
+
}
|
|
1791
|
+
/** Send one message; one whose selector is not an address is dropped. */
|
|
1792
|
+
send(value) {
|
|
1793
|
+
const packet = toOsc(value);
|
|
1794
|
+
if (packet) __privateGet(this, _socket2)?.send(packet);
|
|
1795
|
+
}
|
|
1796
|
+
exportOptions() {
|
|
1797
|
+
return { url: this.url };
|
|
1798
|
+
}
|
|
1799
|
+
onActivate() {
|
|
1800
|
+
__privateSet(this, _socket2, oscSocket(this.url, void 0, (status) => this.outputs.status.send(message("symbol", [symbolAtom(status)])), (error) => this.fail(error)));
|
|
1801
|
+
}
|
|
1802
|
+
onDispose() {
|
|
1803
|
+
__privateGet(this, _socket2)?.close();
|
|
1804
|
+
}
|
|
1805
|
+
};
|
|
1806
|
+
_socket2 = new WeakMap();
|
|
1807
|
+
_OscSink.type = "webmusic.osc-out";
|
|
1808
|
+
var OscSink = _OscSink;
|
|
1809
|
+
|
|
1810
|
+
// src/message/script.ts
|
|
1811
|
+
var SCRIPT_PRELUDE = String.raw`
|
|
1812
|
+
'use strict';
|
|
1813
|
+
for (const name of ['fetch', 'XMLHttpRequest', 'WebSocket', 'EventSource', 'importScripts']) {
|
|
1814
|
+
try { Object.defineProperty(self, name, {value: undefined, configurable: false, writable: false}); } catch {}
|
|
1815
|
+
}
|
|
1816
|
+
const pending = new Map();
|
|
1817
|
+
let nextCall = 0;
|
|
1818
|
+
const format = value => {
|
|
1819
|
+
if (typeof value === 'string') return value;
|
|
1820
|
+
try { const text = JSON.stringify(value); return text === undefined ? String(value) : text; } catch { return String(value); }
|
|
1821
|
+
};
|
|
1822
|
+
const post = (...values) => postMessage({type: 'post', text: values.map(format).join(' ')});
|
|
1823
|
+
const outlet = (index, ...values) => postMessage({type: 'outlet', index, values: JSON.parse(JSON.stringify(values))});
|
|
1824
|
+
const hostCall = (name, args) => new Promise((resolve, reject) => {
|
|
1825
|
+
const id = ++nextCall;
|
|
1826
|
+
pending.set(id, {resolve, reject});
|
|
1827
|
+
postMessage({type: 'host', id, name, args});
|
|
1828
|
+
});
|
|
1829
|
+
let program;
|
|
1830
|
+
// Input with await runs in an async function, as a browser console does:
|
|
1831
|
+
// top-level declarations become globals so later input sees them, and the
|
|
1832
|
+
// last statement's value is returned when it is an expression.
|
|
1833
|
+
const evaluateAsync = code => {
|
|
1834
|
+
const body = code.replace(/(^|[;\n{}])(\s*)(?:var|let|const)\s+([A-Za-z_$][\w$]*)\s*=/g, '$1$2globalThis.$3 =').trim().replace(/;+\s*$/, '');
|
|
1835
|
+
const cut = body.lastIndexOf(';');
|
|
1836
|
+
const head = body.slice(0, cut + 1), tail = body.slice(cut + 1);
|
|
1837
|
+
const statement = /^\s*(if|for|while|do|switch|try|return|throw|function|class|async\s+function)\b|^\s*[{}]?\s*$/.test(tail);
|
|
1838
|
+
if (!statement) {
|
|
1839
|
+
try { return (0, eval)('(async () => {\n' + head + '\nreturn (' + tail + '\n);\n})()'); }
|
|
1840
|
+
catch (error) { if (!(error instanceof SyntaxError)) throw error; }
|
|
1841
|
+
}
|
|
1842
|
+
return (0, eval)('(async () => {\n' + body + '\n})()');
|
|
1843
|
+
};
|
|
1844
|
+
self.post = post;
|
|
1845
|
+
self.outlet = outlet;
|
|
1846
|
+
const fail = (id, error) => postMessage({type: 'result', id, error: {name: error && error.name || 'Error', message: error && error.message || String(error)}});
|
|
1847
|
+
self.onmessage = async ({data}) => {
|
|
1848
|
+
if (data.type === 'setup') {
|
|
1849
|
+
const space = {};
|
|
1850
|
+
for (const name of data.api) space[name] = (...args) => hostCall(name, args);
|
|
1851
|
+
self[data.namespace] = Object.freeze(space);
|
|
1852
|
+
return;
|
|
1853
|
+
}
|
|
1854
|
+
if (data.type === 'reply') {
|
|
1855
|
+
const call = pending.get(data.id);
|
|
1856
|
+
if (!call) return;
|
|
1857
|
+
pending.delete(data.id);
|
|
1858
|
+
if (data.error) call.reject(Object.assign(new Error(data.error.message), {name: data.error.name}));
|
|
1859
|
+
else call.resolve(data.value);
|
|
1860
|
+
return;
|
|
1861
|
+
}
|
|
1862
|
+
try {
|
|
1863
|
+
if (data.type === 'load') {
|
|
1864
|
+
program = new Function('outlet', 'post', 'let inlet = 0, messagename = "";\n' + data.code +
|
|
1865
|
+
'\n;return {enter(index, name) { inlet = index; messagename = name; },' +
|
|
1866
|
+
' find(name) { return /^[A-Za-z_$][\\w$]*$/.test(name) ? eval("typeof " + name + " === \\"function\\" ? " + name + " : undefined") : undefined; }};')(outlet, post);
|
|
1867
|
+
postMessage({type: 'result', id: data.id, value: null});
|
|
1868
|
+
} else if (data.type === 'message') {
|
|
1869
|
+
if (!program) return;
|
|
1870
|
+
const {inlet, selector, values} = data;
|
|
1871
|
+
const named = selector === 'int' ? 'msg_int' : selector === 'float' ? 'msg_float' : selector;
|
|
1872
|
+
program.enter(inlet, selector);
|
|
1873
|
+
const direct = program.find(named);
|
|
1874
|
+
if (direct) { await direct(...values); return; }
|
|
1875
|
+
const anything = program.find('anything');
|
|
1876
|
+
if (anything) await anything(selector, ...values);
|
|
1877
|
+
} else if (data.type === 'eval') {
|
|
1878
|
+
const run = /\bawait\b/.test(data.code) ? evaluateAsync(data.code) : (0, eval)(data.code);
|
|
1879
|
+
const value = await run;
|
|
1880
|
+
postMessage({type: 'result', id: data.id, value: value === undefined ? null : JSON.parse(JSON.stringify(value) ?? 'null'), text: value === undefined ? 'undefined' : format(value)});
|
|
1881
|
+
}
|
|
1882
|
+
} catch (error) {
|
|
1883
|
+
if (data.id !== undefined) fail(data.id, error);
|
|
1884
|
+
else postMessage({type: 'error', error: {name: error && error.name || 'Error', message: error && error.message || String(error)}});
|
|
1885
|
+
}
|
|
1886
|
+
};
|
|
1887
|
+
`;
|
|
1888
|
+
function defaultWorker(source) {
|
|
1889
|
+
if (typeof Worker === "undefined" || typeof Blob === "undefined" || typeof URL === "undefined") throw new Error("Scripts need Web Workers.");
|
|
1890
|
+
const url = URL.createObjectURL(new Blob([source], { type: "text/javascript" }));
|
|
1891
|
+
const worker = new Worker(url);
|
|
1892
|
+
URL.revokeObjectURL(url);
|
|
1893
|
+
return worker;
|
|
1894
|
+
}
|
|
1895
|
+
var toError = (error) => Object.assign(new Error(error?.message ?? "Script error"), { name: error?.name ?? "Error" });
|
|
1896
|
+
var _worker, _options2, _calls, _next2, _terminated, _ScriptSandbox_instances, request_fn, receive_fn, host_fn;
|
|
1897
|
+
var ScriptSandbox = class {
|
|
1898
|
+
constructor(options = {}) {
|
|
1899
|
+
__privateAdd(this, _ScriptSandbox_instances);
|
|
1900
|
+
__privateAdd(this, _worker);
|
|
1901
|
+
__privateAdd(this, _options2);
|
|
1902
|
+
__privateAdd(this, _calls, /* @__PURE__ */ new Map());
|
|
1903
|
+
__privateAdd(this, _next2, 0);
|
|
1904
|
+
__privateAdd(this, _terminated, false);
|
|
1905
|
+
__privateSet(this, _options2, options);
|
|
1906
|
+
__privateSet(this, _worker, (options.createWorker ?? defaultWorker)(SCRIPT_PRELUDE));
|
|
1907
|
+
__privateGet(this, _worker).onmessage = (event) => __privateMethod(this, _ScriptSandbox_instances, receive_fn).call(this, event.data);
|
|
1908
|
+
__privateGet(this, _worker).onerror = (event) => options.onError?.(new Error(event.message ?? "Script error"));
|
|
1909
|
+
const api = options.api ?? {};
|
|
1910
|
+
__privateGet(this, _worker).postMessage({ type: "setup", namespace: options.namespace ?? "host", api: Object.keys(api) });
|
|
1911
|
+
}
|
|
1912
|
+
get terminated() {
|
|
1913
|
+
return __privateGet(this, _terminated);
|
|
1914
|
+
}
|
|
1915
|
+
/** Compile `code` as a module script; rejects with its syntax or top-level error. */
|
|
1916
|
+
async load(code) {
|
|
1917
|
+
await __privateMethod(this, _ScriptSandbox_instances, request_fn).call(this, { type: "load", code });
|
|
1918
|
+
}
|
|
1919
|
+
/** Run REPL input in the script's global scope; resolves with the value and its printed form. `await` makes it async. */
|
|
1920
|
+
async evaluate(code) {
|
|
1921
|
+
const result = await __privateMethod(this, _ScriptSandbox_instances, request_fn).call(this, { type: "eval", code });
|
|
1922
|
+
return { value: result.value, text: result.text ?? "undefined" };
|
|
1923
|
+
}
|
|
1924
|
+
/** Hand a message to the loaded script's handler; fire and forget. */
|
|
1925
|
+
deliver(inlet, value) {
|
|
1926
|
+
if (__privateGet(this, _terminated)) return;
|
|
1927
|
+
__privateGet(this, _worker).postMessage({ type: "message", inlet, selector: value.selector, values: value.atoms.map((atom) => atom.value) });
|
|
1928
|
+
}
|
|
1929
|
+
terminate() {
|
|
1930
|
+
if (__privateGet(this, _terminated)) return;
|
|
1931
|
+
__privateSet(this, _terminated, true);
|
|
1932
|
+
__privateGet(this, _worker).onmessage = null;
|
|
1933
|
+
__privateGet(this, _worker).onerror = null;
|
|
1934
|
+
__privateGet(this, _worker).terminate();
|
|
1935
|
+
for (const call of __privateGet(this, _calls).values()) call.reject(new Error("The script was stopped."));
|
|
1936
|
+
__privateGet(this, _calls).clear();
|
|
1937
|
+
}
|
|
1938
|
+
};
|
|
1939
|
+
_worker = new WeakMap();
|
|
1940
|
+
_options2 = new WeakMap();
|
|
1941
|
+
_calls = new WeakMap();
|
|
1942
|
+
_next2 = new WeakMap();
|
|
1943
|
+
_terminated = new WeakMap();
|
|
1944
|
+
_ScriptSandbox_instances = new WeakSet();
|
|
1945
|
+
request_fn = function(data) {
|
|
1946
|
+
if (__privateGet(this, _terminated)) return Promise.reject(new Error("The script was stopped."));
|
|
1947
|
+
const id = ++__privateWrapper(this, _next2)._;
|
|
1948
|
+
return new Promise((resolve, reject) => {
|
|
1949
|
+
__privateGet(this, _calls).set(id, { resolve, reject });
|
|
1950
|
+
__privateGet(this, _worker).postMessage({ ...data, id });
|
|
1951
|
+
});
|
|
1952
|
+
};
|
|
1953
|
+
receive_fn = function(data) {
|
|
1954
|
+
if (__privateGet(this, _terminated) || !data || typeof data !== "object") return;
|
|
1955
|
+
switch (data.type) {
|
|
1956
|
+
case "post":
|
|
1957
|
+
__privateGet(this, _options2).onPost?.(String(data.text));
|
|
1958
|
+
return;
|
|
1959
|
+
case "outlet":
|
|
1960
|
+
__privateGet(this, _options2).onOutlet?.(Number(data.index), Array.isArray(data.values) ? data.values : []);
|
|
1961
|
+
return;
|
|
1962
|
+
case "error":
|
|
1963
|
+
__privateGet(this, _options2).onError?.(toError(data.error));
|
|
1964
|
+
return;
|
|
1965
|
+
case "result": {
|
|
1966
|
+
const call = __privateGet(this, _calls).get(Number(data.id));
|
|
1967
|
+
if (!call) return;
|
|
1968
|
+
__privateGet(this, _calls).delete(Number(data.id));
|
|
1969
|
+
if (data.error) call.reject(toError(data.error));
|
|
1970
|
+
else call.resolve({ value: data.value, text: typeof data.text === "string" ? data.text : void 0 });
|
|
1971
|
+
return;
|
|
1972
|
+
}
|
|
1973
|
+
case "host":
|
|
1974
|
+
void __privateMethod(this, _ScriptSandbox_instances, host_fn).call(this, Number(data.id), String(data.name), Array.isArray(data.args) ? data.args : []);
|
|
1975
|
+
}
|
|
1976
|
+
};
|
|
1977
|
+
host_fn = async function(id, name, args) {
|
|
1978
|
+
const fn = __privateGet(this, _options2).api?.[name];
|
|
1979
|
+
try {
|
|
1980
|
+
if (!fn) throw new Error(`No host function ${name}.`);
|
|
1981
|
+
const value = await fn(...args);
|
|
1982
|
+
if (!__privateGet(this, _terminated)) __privateGet(this, _worker).postMessage({ type: "reply", id, value: value === void 0 ? null : value });
|
|
1983
|
+
} catch (error) {
|
|
1984
|
+
if (!__privateGet(this, _terminated)) __privateGet(this, _worker).postMessage({ type: "reply", id, error: { name: error instanceof Error ? error.name : "Error", message: error instanceof Error ? error.message : String(error) } });
|
|
1985
|
+
}
|
|
1986
|
+
};
|
|
1987
|
+
function scriptAtom(value) {
|
|
1988
|
+
if (typeof value === "number") return Number.isInteger(value) ? intAtom(value) : floatAtom(value);
|
|
1989
|
+
if (typeof value === "string") return symbolAtom(value);
|
|
1990
|
+
if (typeof value === "boolean") return intAtom(value ? 1 : 0);
|
|
1991
|
+
if (Array.isArray(value)) return { type: "array", value };
|
|
1992
|
+
return { type: "dict", value: value ?? null };
|
|
1993
|
+
}
|
|
1994
|
+
function scriptMessage(values2) {
|
|
1995
|
+
if (!values2.length) return message("bang");
|
|
1996
|
+
const atoms = values2.map(scriptAtom);
|
|
1997
|
+
const [first, ...rest] = atoms;
|
|
1998
|
+
if (atoms.length === 1) return message(first.type === "int" ? "int" : first.type === "float" ? "float" : first.type === "symbol" ? "symbol" : "list", atoms);
|
|
1999
|
+
if (first.type === "symbol") return message(first.value, rest);
|
|
2000
|
+
return message("list", atoms);
|
|
2001
|
+
}
|
|
2002
|
+
|
|
2003
|
+
// src/message/script-module.ts
|
|
2004
|
+
var DEFAULT_CODE = 'function bang() { outlet(0, "bang"); }';
|
|
2005
|
+
var count2 = (value, fallback) => typeof value === "number" && Number.isInteger(value) && value >= 1 && value <= 16 ? value : fallback;
|
|
2006
|
+
var _counts, _sandbox;
|
|
2007
|
+
var _ScriptModule = class _ScriptModule extends GraphModule {
|
|
2008
|
+
constructor(options = {}) {
|
|
2009
|
+
super(_ScriptModule.type, options);
|
|
2010
|
+
__privateAdd(this, _counts);
|
|
2011
|
+
__privateAdd(this, _sandbox);
|
|
2012
|
+
this.code = typeof options.code === "string" ? options.code : DEFAULT_CODE;
|
|
2013
|
+
__privateSet(this, _counts, { inputs: count2(options.inputs, 1), outputs: count2(options.outputs, 1) });
|
|
2014
|
+
const inputs = Array.from({ length: __privateGet(this, _counts).inputs }, (_, index) => this.input(numberedPort("in", index), `messages to the script, inlet ${index}`, (value) => this.deliver(index, value)));
|
|
2015
|
+
const outputs = Array.from({ length: __privateGet(this, _counts).outputs }, (_, index) => this.output(numberedPort("out", index), `outlet ${index}`));
|
|
2016
|
+
this.inputs = Object.freeze(Object.fromEntries(inputs.map((port2) => [port2.id, port2])));
|
|
2017
|
+
this.outputs = Object.freeze(Object.fromEntries(outputs.map((port2) => [port2.id, port2])));
|
|
2018
|
+
try {
|
|
2019
|
+
__privateSet(this, _sandbox, new ScriptSandbox({
|
|
2020
|
+
createWorker: options.createWorker,
|
|
2021
|
+
onPost: (text) => {
|
|
2022
|
+
if (options.print) options.print(text);
|
|
2023
|
+
else console.log(`js: ${text}`);
|
|
2024
|
+
},
|
|
2025
|
+
onOutlet: (index, values2) => {
|
|
2026
|
+
if (!this.disposed && Number.isInteger(index) && index >= 0 && index < outputs.length) outputs[index].send(scriptMessage(values2));
|
|
2027
|
+
},
|
|
2028
|
+
onError: (error) => this.fail(error)
|
|
2029
|
+
}));
|
|
2030
|
+
__privateGet(this, _sandbox).load(this.code).catch((error) => this.fail(error));
|
|
2031
|
+
} catch (error) {
|
|
2032
|
+
this.fail(error);
|
|
2033
|
+
}
|
|
2034
|
+
}
|
|
2035
|
+
/** Hand a message to the script's handler for input `index`. */
|
|
2036
|
+
deliver(index, value) {
|
|
2037
|
+
__privateGet(this, _sandbox)?.deliver(index, value);
|
|
2038
|
+
}
|
|
2039
|
+
exportOptions() {
|
|
2040
|
+
return { inputs: __privateGet(this, _counts).inputs, outputs: __privateGet(this, _counts).outputs, code: this.code };
|
|
2041
|
+
}
|
|
2042
|
+
onDispose() {
|
|
2043
|
+
__privateGet(this, _sandbox)?.terminate();
|
|
2044
|
+
}
|
|
2045
|
+
};
|
|
2046
|
+
_counts = new WeakMap();
|
|
2047
|
+
_sandbox = new WeakMap();
|
|
2048
|
+
_ScriptModule.type = "webmusic.script";
|
|
2049
|
+
var ScriptModule = _ScriptModule;
|
|
2050
|
+
|
|
2051
|
+
// src/message/plugins.ts
|
|
2052
|
+
function createMessagePlugins(environment = {}) {
|
|
2053
|
+
const classes = [
|
|
2054
|
+
LoadBang,
|
|
2055
|
+
Metro,
|
|
2056
|
+
Delay,
|
|
2057
|
+
Pipe,
|
|
2058
|
+
Line,
|
|
2059
|
+
Counter,
|
|
2060
|
+
Gate,
|
|
2061
|
+
Switch,
|
|
2062
|
+
ControlSource,
|
|
2063
|
+
ControlRamp,
|
|
2064
|
+
Button,
|
|
2065
|
+
Toggle,
|
|
2066
|
+
NumberValue,
|
|
2067
|
+
Choice,
|
|
2068
|
+
MessageBox,
|
|
2069
|
+
ValueList,
|
|
2070
|
+
Matrix,
|
|
2071
|
+
TransportReadout,
|
|
2072
|
+
GamepadSource,
|
|
2073
|
+
HidSource,
|
|
2074
|
+
OscSource,
|
|
2075
|
+
OscSink
|
|
2076
|
+
];
|
|
2077
|
+
return Object.freeze([
|
|
2078
|
+
...MESSAGE_FUNCTIONS.map((fn) => modulePlugin(fn.module.type, (options, request) => new FunctionModule(fn, {
|
|
2079
|
+
...options,
|
|
2080
|
+
options,
|
|
2081
|
+
...environment.random ? { random: environment.random } : {},
|
|
2082
|
+
...environment.print ? { print: (name, text) => environment.print(name, text, request.record.id) } : {}
|
|
2083
|
+
}), environment)),
|
|
2084
|
+
...classes.map((Type) => modulePlugin(Type.type, (options) => new Type(options), environment)),
|
|
2085
|
+
modulePlugin(ScriptModule.type, (options, request) => new ScriptModule({
|
|
2086
|
+
...options,
|
|
2087
|
+
...environment.createScriptWorker ? { createWorker: environment.createScriptWorker } : {},
|
|
2088
|
+
...environment.print ? { print: (text) => environment.print("js", text, request.record.id) } : {}
|
|
2089
|
+
}), environment)
|
|
2090
|
+
]);
|
|
2091
|
+
}
|
|
2092
|
+
|
|
2093
|
+
export {
|
|
2094
|
+
compileExpr,
|
|
2095
|
+
atomOf,
|
|
2096
|
+
numberMessage,
|
|
2097
|
+
FunctionModule,
|
|
2098
|
+
functionModule,
|
|
2099
|
+
scale,
|
|
2100
|
+
select,
|
|
2101
|
+
route,
|
|
2102
|
+
trigger,
|
|
2103
|
+
pack,
|
|
2104
|
+
unpack,
|
|
2105
|
+
expr,
|
|
2106
|
+
seededRandom,
|
|
2107
|
+
random,
|
|
2108
|
+
print,
|
|
2109
|
+
MESSAGE_FUNCTIONS,
|
|
2110
|
+
LoadBang,
|
|
2111
|
+
Metro,
|
|
2112
|
+
Delay,
|
|
2113
|
+
Pipe,
|
|
2114
|
+
Line,
|
|
2115
|
+
Counter,
|
|
2116
|
+
Gate,
|
|
2117
|
+
Switch,
|
|
2118
|
+
Button,
|
|
2119
|
+
Toggle,
|
|
2120
|
+
NumberValue,
|
|
2121
|
+
Choice,
|
|
2122
|
+
MessageBox,
|
|
2123
|
+
ValueList,
|
|
2124
|
+
Matrix,
|
|
2125
|
+
ControlSource,
|
|
2126
|
+
ControlRamp,
|
|
2127
|
+
TransportReadout,
|
|
2128
|
+
GamepadSource,
|
|
2129
|
+
HidSource,
|
|
2130
|
+
fromOsc,
|
|
2131
|
+
toOsc,
|
|
2132
|
+
OscSource,
|
|
2133
|
+
OscSink,
|
|
2134
|
+
SCRIPT_PRELUDE,
|
|
2135
|
+
ScriptSandbox,
|
|
2136
|
+
scriptAtom,
|
|
2137
|
+
scriptMessage,
|
|
2138
|
+
ScriptModule,
|
|
2139
|
+
createMessagePlugins
|
|
2140
|
+
};
|
|
2141
|
+
//# sourceMappingURL=chunk-CYWDZLWC.js.map
|