@avoid.quest/audio 0.1.0 → 0.1.1-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/README.md +30 -2
  2. package/dist/effects/index.d.ts +21 -72
  3. package/dist/effects/index.js +212 -505
  4. package/dist/effects/index.js.map +1 -1
  5. package/dist/index.d.ts +1 -1
  6. package/dist/index.js +1 -1
  7. package/dist/midi/index.d.ts +0 -24
  8. package/dist/midi/index.js +222 -258
  9. package/dist/midi/index.js.map +1 -1
  10. package/dist/native-Bern4_PB.js +172 -0
  11. package/dist/native-Bern4_PB.js.map +1 -0
  12. package/dist/pcm-buffer-DSzGHbon.js +436 -0
  13. package/dist/pcm-buffer-DSzGHbon.js.map +1 -0
  14. package/dist/playback/index.d.ts +60 -114
  15. package/dist/playback/index.js +899 -1062
  16. package/dist/playback/index.js.map +1 -1
  17. package/dist/queue/index.d.ts +8 -19
  18. package/dist/queue/index.js +461 -960
  19. package/dist/queue/index.js.map +1 -1
  20. package/dist/recognize/index.d.ts +37 -74
  21. package/dist/recognize/index.js +172 -2715
  22. package/dist/recognize/index.js.map +1 -1
  23. package/dist/routing/index.d.ts +3 -34
  24. package/dist/routing/index.js +413 -536
  25. package/dist/routing/index.js.map +1 -1
  26. package/dist/shazam-gBrX1NEY.d.ts +27 -0
  27. package/dist/sync/index.d.ts +9 -77
  28. package/dist/sync/index.js +320 -542
  29. package/dist/sync/index.js.map +1 -1
  30. package/dist/{worklet-loader-BvEW0oVO.d.ts → worklet-loader-BabwPALw.d.ts} +4 -7
  31. package/dist/{worklet-loader-S7R8ZAmP.js → worklet-loader-f741D1tk.js} +37 -52
  32. package/dist/worklet-loader-f741D1tk.js.map +1 -0
  33. package/dist/worklets/couch-live.js +110 -192
  34. package/dist/worklets/couch-live.js.map +1 -1
  35. package/dist/worklets/meter.js +14 -20
  36. package/dist/worklets/meter.js.map +1 -1
  37. package/dist/worklets/pcm-capture.d.ts +6 -0
  38. package/dist/worklets/pcm-capture.js +52 -0
  39. package/dist/worklets/pcm-capture.js.map +1 -0
  40. package/package.json +8 -3
  41. package/dist/worklet-loader-S7R8ZAmP.js.map +0 -1
@@ -1,5 +1,46 @@
1
1
  import { Effect, Schema, Scope } from "effect";
2
2
  import { i as AudioMidiError } from "../errors-BT9HxDLn.js";
3
+ // src/midi/access.ts
4
+ const MIDI_BUTTON_DEBOUNCE_MS = 50;
5
+ const MIDI_CONTINUOUS_COALESCE_MS = 33;
6
+ function listMidiDevices(access) {
7
+ return access ? [...access.inputs.values()].map((i) => ({
8
+ id: i.id,
9
+ manufacturer: i.manufacturer ?? "",
10
+ name: i.name ?? i.id,
11
+ state: i.state ?? "connected"
12
+ })) : [];
13
+ }
14
+ function openMidiInputSafely(input, isStillAttached) {
15
+ if (typeof input.open !== "function") return;
16
+ (async () => {
17
+ try {
18
+ await input.open?.();
19
+ if (!isStillAttached()) await input.close?.();
20
+ } catch {}
21
+ })();
22
+ }
23
+ function requestMidiAccess(options = {}) {
24
+ return Effect.tryPromise({
25
+ catch: (error) => {
26
+ if (error instanceof AudioMidiError) return error;
27
+ const name = error instanceof Error ? error.name : "";
28
+ return new AudioMidiError({
29
+ code: name === "SecurityError" || name === "NotAllowedError" ? "PERMISSION_DENIED" : "ACCESS_FAILED",
30
+ message: `Web MIDI access failed: ${String(error)}`
31
+ });
32
+ },
33
+ try: async () => {
34
+ const nav = globalThis.navigator;
35
+ const req = options.requestMIDIAccess ?? nav?.requestMIDIAccess?.bind(nav);
36
+ if (typeof req !== "function") throw new AudioMidiError({
37
+ code: "UNSUPPORTED",
38
+ message: "Web MIDI API is not supported."
39
+ });
40
+ return await req({ sysex: options.sysex ?? false });
41
+ }
42
+ });
43
+ }
3
44
  // src/midi/parser.ts
4
45
  const MIDI_STATUS_NOTE_OFF = 128;
5
46
  const MIDI_STATUS_NOTE_ON = 144;
@@ -9,27 +50,22 @@ const MidiMessageTypeSchema = Schema.Literals([
9
50
  "note-on",
10
51
  "note-off"
11
52
  ]);
12
- /**
13
- * Parses a raw 3-byte Web MIDI message into CC (`0xb0`), Note On (`0x90`),
14
- * or Note Off (`0x80`). Returns `undefined` for unsupported or truncated messages.
15
- */
53
+ const STATUS_TO_TYPE = {
54
+ [176]: "cc",
55
+ [128]: "note-off",
56
+ [144]: "note-on"
57
+ };
16
58
  function parseMidiMessage(data) {
17
59
  if (data.length < 3) return;
18
- const statusByte = data[0] ?? 0;
19
- const controlByte = (data[1] ?? 0) & 127;
20
- const valueByte = (data[2] ?? 0) & 127;
21
- const statusType = statusByte & 240;
22
- const channel = statusByte & 15;
23
- let type;
24
- if (statusType === 176) type = "cc";
25
- else if (statusType === 144) type = "note-on";
26
- else if (statusType === 128) type = "note-off";
60
+ const status = data[0] ?? 0;
61
+ const type = STATUS_TO_TYPE[status & 240];
27
62
  if (type === void 0) return;
63
+ const rawValue = (data[2] ?? 0) & 127;
28
64
  return {
29
- channel,
30
- control: controlByte,
31
- normalized: valueByte / 127,
32
- rawValue: valueByte,
65
+ channel: status & 15,
66
+ control: (data[1] ?? 0) & 127,
67
+ normalized: rawValue / 127,
68
+ rawValue,
33
69
  type
34
70
  };
35
71
  }
@@ -70,267 +106,195 @@ const MidiBindingSetSchema = Schema.Struct({
70
106
  function formatMidiBindingKey(scope, channel, control, messageType) {
71
107
  return `${scope}:${channel}:${control}:${messageType}`;
72
108
  }
73
- /**
74
- * Applies the MIDI value transform pipeline (`rawValue` in `0..127`):
75
- * 1. Normalize to `[0, 1]`
76
- * 2. Optional `invert` (`1 - v`)
77
- * 3. Curve (`linear`, `log`: `Math.log1p(v * (Math.E - 1))`, `exp`: `(Math.exp(v) - 1) / (Math.E - 1)`)
78
- * 4. Linear map to `[min, max]` and clamp to `[min(min, max), max(min, max)]`.
79
- */
80
109
  function applyMidiTransform(rawValue, transform) {
81
110
  let v = Math.max(0, Math.min(127, rawValue)) / 127;
82
111
  if (transform.invert) v = 1 - v;
83
- const curve = transform.curve ?? "linear";
84
- if (curve === "log") v = v <= 0 ? 0 : Math.log1p(v * (Math.E - 1));
85
- else if (curve === "exp") v = (Math.exp(v) - 1) / (Math.E - 1);
112
+ if (transform.curve === "log") v = v <= 0 ? 0 : Math.log1p(v * (Math.E - 1));
113
+ else if (transform.curve === "exp") v = (Math.exp(v) - 1) / (Math.E - 1);
86
114
  const mapped = transform.min + v * (transform.max - transform.min);
87
- const lo = Math.min(transform.min, transform.max);
88
- const hi = Math.max(transform.min, transform.max);
89
- return Math.max(lo, Math.min(hi, mapped));
115
+ return Math.max(Math.min(transform.min, transform.max), Math.min(Math.max(transform.min, transform.max), mapped));
90
116
  }
91
117
  // src/midi/controller.ts
92
- const MIDI_BUTTON_DEBOUNCE_MS = 50;
93
- const MIDI_CONTINUOUS_COALESCE_MS = 33;
94
118
  const decodeMidiBindingSet = Schema.decodeUnknownEffect(MidiBindingSetSchema);
95
- /**
96
- * Requests Web MIDI access (`sysex: false` by default) wrapped as a typed Effect.
97
- */
98
- function requestMidiAccess(options = {}) {
99
- return Effect.tryPromise({
100
- catch: (error) => {
101
- if (error instanceof AudioMidiError) return error;
102
- const errName = error instanceof Error ? error.name : "";
103
- return new AudioMidiError({
104
- code: errName === "SecurityError" || errName === "NotAllowedError" ? "PERMISSION_DENIED" : "ACCESS_FAILED",
105
- message: `Web MIDI access failed: ${String(error)}`
106
- });
107
- },
108
- try: async () => {
109
- const requester = options.requestMIDIAccess ?? (globalThis.navigator !== void 0 && "requestMIDIAccess" in globalThis.navigator ? globalThis.navigator.requestMIDIAccess.bind(globalThis.navigator) : void 0);
110
- if (typeof requester !== "function") throw new AudioMidiError({
111
- code: "UNSUPPORTED",
112
- message: "Web MIDI API (navigator.requestMIDIAccess) is not supported."
113
- });
114
- return await requester({ sysex: options.sysex ?? false });
119
+ const isIgnoredBtn = (m) => m.type === "note-off" || m.rawValue === 0;
120
+ function buildMidiController(options = {}) {
121
+ const debounceMs = options.buttonDebounceMs ?? 50;
122
+ const coalesceMs = options.continuousCoalesceMs ?? 33;
123
+ const now = options.now ?? (() => Date.now());
124
+ let activeScope = options.activeScope ?? "global";
125
+ let midiAccess;
126
+ let stateListener;
127
+ const attached = /* @__PURE__ */ new Map();
128
+ const bindings = /* @__PURE__ */ new Map();
129
+ const lastBtnMs = /* @__PURE__ */ new Map();
130
+ const pendingCont = /* @__PURE__ */ new Map();
131
+ let learnReq;
132
+ let lastFlushMs = 0;
133
+ let flushTimer;
134
+ let rafHandle;
135
+ const cancelFlush = () => {
136
+ if (flushTimer !== void 0) {
137
+ clearTimeout(flushTimer);
138
+ flushTimer = void 0;
115
139
  }
116
- });
117
- }
118
- function listDevices(access) {
119
- if (!access) return [];
120
- const devices = [];
121
- for (const input of access.inputs.values()) devices.push({
122
- id: input.id,
123
- manufacturer: input.manufacturer ?? "",
124
- name: input.name ?? input.id,
125
- state: input.state ?? "connected"
126
- });
127
- return devices;
128
- }
129
- /**
130
- * Creates a `Scope`-managed Web MIDI controller with:
131
- * - Non-destructive `addEventListener`/`removeEventListener` MIDI port attachment
132
- * - Effect `Schema`-validated `importBindings`
133
- * - CC (`0xb0`), Note On (`0x90`), Note Off (`0x80`) parsing
134
- * - `Schema`-ranged parameter transforms (`linear`/`log`/`exp`, invert, clamp)
135
- * - 50 ms button debounce per `targetId` (ignoring `note-off` and velocity `0`)
136
- * - 33 ms continuous value coalescing
137
- * - Scoped MIDI Learn (`${scope}:${channel}:${control}:${type}`).
138
- */
139
- function createMidiController(options = {}) {
140
- return Effect.gen(function* () {
141
- const buttonDebounceMs = options.buttonDebounceMs ?? 50;
142
- const continuousCoalesceMs = options.continuousCoalesceMs ?? 33;
143
- const now = options.now ?? (() => Date.now());
144
- let activeScope = options.activeScope ?? "global";
145
- let midiAccess;
146
- let stateChangeListener;
147
- const attachedInputs = /* @__PURE__ */ new Map();
148
- const bindings = /* @__PURE__ */ new Map();
149
- const lastButtonTriggerMs = /* @__PURE__ */ new Map();
150
- const pendingContinuous = /* @__PURE__ */ new Map();
151
- let learnRequest;
152
- let lastFlushMs = 0;
153
- let flushTimer;
154
- let rafHandle;
155
- const cancelScheduledFlush = () => {
156
- if (flushTimer !== void 0) {
157
- clearTimeout(flushTimer);
158
- flushTimer = void 0;
159
- }
160
- if (rafHandle !== void 0 && typeof globalThis.cancelAnimationFrame === "function") {
161
- globalThis.cancelAnimationFrame(rafHandle);
162
- rafHandle = void 0;
163
- }
164
- };
165
- const flushContinuous = () => {
166
- cancelScheduledFlush();
167
- if (pendingContinuous.size === 0) return 0;
168
- const batch = [...pendingContinuous.values()];
169
- pendingContinuous.clear();
170
- lastFlushMs = now();
171
- for (const event of batch) options.onContinuous?.(event);
172
- return batch.length;
140
+ if (rafHandle !== void 0) {
141
+ globalThis.cancelAnimationFrame?.(rafHandle);
142
+ rafHandle = void 0;
143
+ }
144
+ };
145
+ const flushContinuous = () => {
146
+ cancelFlush();
147
+ if (pendingCont.size === 0) return 0;
148
+ const batch = [...pendingCont.values()];
149
+ pendingCont.clear();
150
+ lastFlushMs = now();
151
+ for (const ev of batch) options.onContinuous?.(ev);
152
+ return batch.length;
153
+ };
154
+ const scheduleFlush = () => {
155
+ if (flushTimer !== void 0 || rafHandle !== void 0) return;
156
+ const delay = Math.max(0, coalesceMs - (now() - lastFlushMs));
157
+ const tick = () => {
158
+ flushTimer = void 0;
159
+ rafHandle = void 0;
160
+ if (pendingCont.size === 0) return;
161
+ if (now() - lastFlushMs >= coalesceMs) flushContinuous();
162
+ else scheduleFlush();
173
163
  };
174
- const scheduleContinuousFlush = () => {
175
- if (flushTimer !== void 0 || rafHandle !== void 0) return;
176
- const elapsed = now() - lastFlushMs;
177
- const delay = Math.max(0, continuousCoalesceMs - elapsed);
178
- const attemptFlush = () => {
179
- flushTimer = void 0;
180
- rafHandle = void 0;
181
- if (pendingContinuous.size === 0) return;
182
- if (now() - lastFlushMs >= continuousCoalesceMs) flushContinuous();
183
- else scheduleContinuousFlush();
164
+ if (delay === 0 && typeof globalThis.requestAnimationFrame === "function") rafHandle = globalThis.requestAnimationFrame(tick);
165
+ else flushTimer = setTimeout(tick, Math.max(1, delay));
166
+ };
167
+ const bind = (b) => {
168
+ bindings.set(formatMidiBindingKey(b.scope, b.channel, b.control, b.messageType), b);
169
+ };
170
+ const lookup = (m) => bindings.get(formatMidiBindingKey(activeScope, m.channel, m.control, m.type)) ?? (activeScope === "global" ? void 0 : bindings.get(formatMidiBindingKey("global", m.channel, m.control, m.type)));
171
+ const handleRawMessage = (data, inputId) => {
172
+ const message = parseMidiMessage(data);
173
+ if (!message) return;
174
+ options.onMessage?.(message, inputId);
175
+ if (learnReq) {
176
+ if (learnReq.actionKind === "button" && isIgnoredBtn(message)) return;
177
+ const req = learnReq;
178
+ learnReq = void 0;
179
+ const learned = {
180
+ actionKind: req.actionKind,
181
+ channel: message.channel,
182
+ control: message.control,
183
+ messageType: message.type,
184
+ scope: req.scope,
185
+ targetId: req.targetId,
186
+ transform: req.transform,
187
+ version: 2
184
188
  };
185
- if (delay === 0 && typeof globalThis.requestAnimationFrame === "function") rafHandle = globalThis.requestAnimationFrame(attemptFlush);
186
- else flushTimer = setTimeout(attemptFlush, Math.max(1, delay));
187
- };
188
- const handleRawMessage = (data, inputId) => {
189
- const message = parseMidiMessage(data);
190
- if (!message) return;
191
- options.onMessage?.(message, inputId);
192
- if (learnRequest) {
193
- if (learnRequest.actionKind === "button" && (message.type === "note-off" || message.rawValue === 0)) return;
194
- const request = learnRequest;
195
- learnRequest = void 0;
196
- const binding = {
197
- actionKind: request.actionKind,
198
- channel: message.channel,
199
- control: message.control,
200
- messageType: message.type,
201
- scope: request.scope,
202
- targetId: request.targetId,
203
- transform: request.transform,
204
- version: 2
205
- };
206
- const key = formatMidiBindingKey(binding.scope, binding.channel, binding.control, binding.messageType);
207
- bindings.set(key, binding);
208
- request.onBound?.(binding);
209
- return;
210
- }
211
- const scopedKey = formatMidiBindingKey(activeScope, message.channel, message.control, message.type);
212
- const binding = bindings.get(scopedKey) ?? (activeScope === "global" ? void 0 : bindings.get(formatMidiBindingKey("global", message.channel, message.control, message.type)));
213
- if (!binding) return;
214
- if (binding.actionKind === "button") {
215
- if (message.type === "note-off" || message.rawValue === 0) return;
216
- const currentMs = now();
217
- const prevMs = lastButtonTriggerMs.get(binding.targetId);
218
- if (prevMs !== void 0 && currentMs - prevMs < buttonDebounceMs) return;
219
- lastButtonTriggerMs.set(binding.targetId, currentMs);
220
- const value = binding.transform ? applyMidiTransform(message.rawValue, binding.transform) : message.normalized;
221
- options.onButton?.({
222
- binding,
223
- message,
224
- value
225
- });
226
- return;
227
- }
228
- const value = binding.transform ? applyMidiTransform(message.rawValue, binding.transform) : message.normalized;
229
- pendingContinuous.set(binding.targetId, {
189
+ bind(learned);
190
+ req.onBound?.(learned);
191
+ return;
192
+ }
193
+ const binding = lookup(message);
194
+ if (!binding) return;
195
+ const value = binding.transform ? applyMidiTransform(message.rawValue, binding.transform) : message.normalized;
196
+ if (binding.actionKind === "button") {
197
+ if (isIgnoredBtn(message)) return;
198
+ const ts = now();
199
+ const prev = lastBtnMs.get(binding.targetId);
200
+ if (prev !== void 0 && ts - prev < debounceMs) return;
201
+ lastBtnMs.set(binding.targetId, ts);
202
+ options.onButton?.({
230
203
  binding,
231
204
  message,
232
205
  value
233
206
  });
234
- scheduleContinuousFlush();
235
- };
236
- const detachInputs = () => {
237
- for (const [input, listener] of attachedInputs) {
238
- input.removeEventListener("midimessage", listener);
239
- if (typeof input.close === "function") input.close().catch(() => false);
240
- }
241
- attachedInputs.clear();
242
- };
243
- const syncInputs = (access) => {
244
- detachInputs();
245
- for (const input of access.inputs.values()) {
246
- const onMessage = (event) => {
247
- if (event.data) handleRawMessage(event.data, input.id);
248
- };
249
- input.addEventListener("midimessage", onMessage);
250
- attachedInputs.set(input, onMessage);
251
- if (typeof input.open === "function") {
252
- const openAndVerify = async () => {
253
- try {
254
- await input.open?.();
255
- } catch {
256
- return;
257
- }
258
- if (attachedInputs.get(input) !== onMessage && typeof input.close === "function") try {
259
- await input.close();
260
- } catch {}
261
- };
262
- openAndVerify();
263
- }
264
- }
265
- const devices = listDevices(access);
266
- options.onDevicesChanged?.(devices);
267
- return devices;
268
- };
269
- const disconnectAccess = () => {
270
- detachInputs();
271
- if (midiAccess && stateChangeListener) midiAccess.removeEventListener("statechange", stateChangeListener);
272
- stateChangeListener = void 0;
273
- midiAccess = void 0;
274
- };
275
- const connectAccess = (access) => {
207
+ return;
208
+ }
209
+ pendingCont.set(binding.targetId, {
210
+ binding,
211
+ message,
212
+ value
213
+ });
214
+ scheduleFlush();
215
+ };
216
+ const detachInputs = () => {
217
+ for (const [input, listener] of attached) {
218
+ input.removeEventListener("midimessage", listener);
219
+ if (typeof input.close === "function") input.close().catch(() => false);
220
+ }
221
+ attached.clear();
222
+ };
223
+ const syncInputs = (access) => {
224
+ detachInputs();
225
+ for (const input of access.inputs.values()) {
226
+ const onMsg = (ev) => {
227
+ if (ev.data) handleRawMessage(ev.data, input.id);
228
+ };
229
+ input.addEventListener("midimessage", onMsg);
230
+ attached.set(input, onMsg);
231
+ openMidiInputSafely(input, () => attached.get(input) === onMsg);
232
+ }
233
+ const devices = listMidiDevices(access);
234
+ options.onDevicesChanged?.(devices);
235
+ return devices;
236
+ };
237
+ const disconnectAccess = () => {
238
+ detachInputs();
239
+ if (midiAccess && stateListener) midiAccess.removeEventListener("statechange", stateListener);
240
+ stateListener = void 0;
241
+ midiAccess = void 0;
242
+ };
243
+ const importBindings = (input) => decodeMidiBindingSet(input).pipe(Effect.mapError((failure) => new AudioMidiError({
244
+ code: "INVALID_BINDING",
245
+ message: `Invalid MIDI binding set: ${String(failure)}`
246
+ })), Effect.map((validated) => {
247
+ bindings.clear();
248
+ for (const b of validated.bindings) bind(b);
249
+ return [...bindings.values()];
250
+ }));
251
+ return {
252
+ bind,
253
+ cancelLearn: () => {
254
+ learnReq = void 0;
255
+ },
256
+ connectAccess: (access) => {
276
257
  disconnectAccess();
277
258
  midiAccess = access;
278
- stateChangeListener = () => {
259
+ stateListener = () => {
279
260
  if (midiAccess === access) syncInputs(access);
280
261
  };
281
- access.addEventListener("statechange", stateChangeListener);
262
+ access.addEventListener("statechange", stateListener);
282
263
  return syncInputs(access);
283
- };
284
- const bind = (binding) => {
285
- const key = formatMidiBindingKey(binding.scope, binding.channel, binding.control, binding.messageType);
286
- bindings.set(key, binding);
287
- };
288
- const unbind = (key) => bindings.delete(key);
289
- const importBindings = (input) => decodeMidiBindingSet(input).pipe(Effect.mapError((parseFailure) => new AudioMidiError({
290
- code: "INVALID_BINDING",
291
- message: `Invalid MIDI binding set: ${String(parseFailure)}`
292
- })), Effect.map((validated) => {
293
- bindings.clear();
294
- for (const binding of validated.bindings) bind(binding);
295
- return [...bindings.values()];
296
- }));
297
- const dispose = () => {
298
- cancelScheduledFlush();
299
- pendingContinuous.clear();
300
- lastButtonTriggerMs.clear();
301
- learnRequest = void 0;
264
+ },
265
+ disconnectAccess,
266
+ dispose: () => {
267
+ cancelFlush();
268
+ pendingCont.clear();
269
+ lastBtnMs.clear();
270
+ learnReq = void 0;
302
271
  disconnectAccess();
303
- };
304
- yield* Scope.addFinalizer(yield* Scope.Scope, Effect.sync(() => {
305
- dispose();
306
- }));
307
- return {
308
- bind,
309
- cancelLearn: () => {
310
- learnRequest = void 0;
311
- },
312
- connectAccess,
313
- disconnectAccess,
314
- dispose,
315
- exportBindings: () => ({
316
- bindings: [...bindings.values()],
317
- version: 2
318
- }),
319
- flushContinuous,
320
- getActiveScope: () => activeScope,
321
- getBindings: () => [...bindings.values()],
322
- getDevices: () => listDevices(midiAccess),
323
- handleRawMessage,
324
- importBindings,
325
- isLearning: () => learnRequest !== void 0,
326
- setActiveScope: (scope) => {
327
- activeScope = scope;
328
- },
329
- startLearn: (request) => {
330
- learnRequest = request;
331
- },
332
- unbind
333
- };
272
+ },
273
+ exportBindings: () => ({
274
+ bindings: [...bindings.values()],
275
+ version: 2
276
+ }),
277
+ flushContinuous,
278
+ getActiveScope: () => activeScope,
279
+ getBindings: () => [...bindings.values()],
280
+ getDevices: () => listMidiDevices(midiAccess),
281
+ handleRawMessage,
282
+ importBindings,
283
+ isLearning: () => learnReq !== void 0,
284
+ setActiveScope: (scope) => {
285
+ activeScope = scope;
286
+ },
287
+ startLearn: (req) => {
288
+ learnReq = req;
289
+ },
290
+ unbind: (key) => bindings.delete(key)
291
+ };
292
+ }
293
+ function createMidiController(options = {}) {
294
+ return Effect.gen(function* () {
295
+ const controller = buildMidiController(options);
296
+ yield* Scope.addFinalizer(yield* Scope.Scope, Effect.sync(controller.dispose));
297
+ return controller;
334
298
  });
335
299
  }
336
300
  export { MIDI_BINDING_SCHEMA_VERSION, MIDI_BUTTON_DEBOUNCE_MS, MIDI_CONTINUOUS_COALESCE_MS, MIDI_STATUS_CC, MIDI_STATUS_NOTE_OFF, MIDI_STATUS_NOTE_ON, MidiActionKindSchema, MidiBindingSchema, MidiBindingSetSchema, MidiCurveSchema, MidiMessageTypeSchema, MidiTransformSchema, applyMidiTransform, createMidiController, formatMidiBindingKey, parseMidiMessage, requestMidiAccess };