@kidlib/web-audio 0.1.0 → 0.1.2
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/README.md +9 -4
- package/dist/components.d.ts +2 -2
- package/dist/components.js +254 -396
- package/dist/index.d.ts +50 -50
- package/dist/index.js +4948 -7455
- package/dist/io.d.ts +11 -11
- package/dist/io.js +129 -191
- package/dist/keymap-C9_BObLQ.js +239 -0
- package/dist/processors/processors.js +1464 -1612
- package/package.json +25 -34
- package/dist/keymap-3lZMR1Ak.js +0 -167
package/package.json
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kidlib/web-audio",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "High-level Web Audio primitives for musical instruments and tools.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "git+https://github.com/KristinnRoach/web-audio.git"
|
|
9
9
|
},
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
"packageManager": "pnpm@11.5.2",
|
|
10
|
+
"files": [
|
|
11
|
+
"dist"
|
|
12
|
+
],
|
|
14
13
|
"type": "module",
|
|
15
14
|
"types": "./dist/index.d.ts",
|
|
16
15
|
"exports": {
|
|
@@ -27,46 +26,38 @@
|
|
|
27
26
|
"import": "./dist/components.js"
|
|
28
27
|
}
|
|
29
28
|
},
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
],
|
|
33
|
-
"scripts": {
|
|
34
|
-
"build:worklets": "node build-processors.js && mkdir -p dist",
|
|
35
|
-
"build": "pnpm clean && node build-processors.js && vite build",
|
|
36
|
-
"prepack": "pnpm build",
|
|
37
|
-
"watch:processors": "node watch-processors.js",
|
|
38
|
-
"watch": "mkdir -p dist && node build-processors.js && concurrently \"vitest\" \"tsc --emitDeclarationOnly --watch\" \"vite build --watch\" \"pnpm watch:processors\"",
|
|
39
|
-
"clean": "rimraf dist && mkdir -p dist",
|
|
40
|
-
"clean:turbo": "rimraf .turbo",
|
|
41
|
-
"clean:all": "rimraf dist node_modules && pnpm store prune && pnpm prune",
|
|
42
|
-
"lint": "eslint . ",
|
|
43
|
-
"lint:fix": "eslint . --fix",
|
|
44
|
-
"format": "prettier --write .",
|
|
45
|
-
"format:check": "prettier --check .",
|
|
46
|
-
"preview": "vite preview",
|
|
47
|
-
"pretest": "pnpm build:worklets",
|
|
48
|
-
"test": "vitest run",
|
|
49
|
-
"test:browser": "vitest run --config vitest.browser.config.ts",
|
|
50
|
-
"test:coverage": "vitest run --coverage",
|
|
51
|
-
"test:watch": "vitest",
|
|
52
|
-
"test:all": "npm run test && npm run test:browser"
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public"
|
|
53
31
|
},
|
|
54
32
|
"dependencies": {
|
|
55
|
-
"dexie": "^4.0.11",
|
|
56
33
|
"webmidi": "^3.1.13"
|
|
57
34
|
},
|
|
58
35
|
"devDependencies": {
|
|
59
36
|
"@types/audioworklet": "^0.0.72",
|
|
37
|
+
"@types/node": "^24.13.3",
|
|
60
38
|
"@types/webmidi": "^2.1.0",
|
|
61
|
-
"@vitest/browser": "
|
|
62
|
-
"@vitest/coverage-v8": "
|
|
39
|
+
"@vitest/browser-playwright": "4.1.10",
|
|
40
|
+
"@vitest/coverage-v8": "4.1.10",
|
|
63
41
|
"concurrently": "^9.1.2",
|
|
64
42
|
"jsdom": "^26.0.0",
|
|
65
43
|
"playwright": "^1.53.2",
|
|
66
44
|
"rimraf": "^5.0.1",
|
|
67
45
|
"typescript": "5.8.3",
|
|
68
|
-
"vite": "
|
|
46
|
+
"vite": "npm:@voidzero-dev/vite-plus-core@0.2.9",
|
|
69
47
|
"vite-plugin-dts": "^4.5.3",
|
|
70
|
-
"
|
|
48
|
+
"vite-plus": "0.2.9",
|
|
49
|
+
"vitest": "4.1.10"
|
|
50
|
+
},
|
|
51
|
+
"scripts": {
|
|
52
|
+
"build:worklets": "vp node build-processors.js",
|
|
53
|
+
"build": "vp run clean && vp build",
|
|
54
|
+
"watch:processors": "vp node watch-processors.js",
|
|
55
|
+
"watch": "concurrently \"vp test watch\" \"vp build --watch\" \"vp run watch:processors\"",
|
|
56
|
+
"clean": "rimraf dist",
|
|
57
|
+
"test": "vp test run",
|
|
58
|
+
"test:browser": "vp test run --config vitest.browser.config.ts",
|
|
59
|
+
"test:coverage": "vp test run --coverage",
|
|
60
|
+
"test:watch": "vp test",
|
|
61
|
+
"test:all": "vp run test && vp run test:browser"
|
|
71
62
|
}
|
|
72
|
-
}
|
|
63
|
+
}
|
package/dist/keymap-3lZMR1Ak.js
DELETED
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
async function u() {
|
|
2
|
-
try {
|
|
3
|
-
return await navigator.mediaDevices.getUserMedia({ audio: !0, video: !0 }), (await navigator.mediaDevices.enumerateDevices()).map((a) => ({
|
|
4
|
-
deviceId: a.deviceId,
|
|
5
|
-
label: a.label,
|
|
6
|
-
kind: a.kind
|
|
7
|
-
}));
|
|
8
|
-
} catch (e) {
|
|
9
|
-
return console.error("Failed to enumerate devices:", e), [];
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
async function f() {
|
|
13
|
-
if (!navigator.requestMIDIAccess)
|
|
14
|
-
throw new Error("MIDI access not supported in this browser");
|
|
15
|
-
return navigator.requestMIDIAccess();
|
|
16
|
-
}
|
|
17
|
-
async function N(e = {
|
|
18
|
-
echoCancellation: !1,
|
|
19
|
-
noiseSuppression: !0,
|
|
20
|
-
// ?
|
|
21
|
-
autoGainControl: !0
|
|
22
|
-
// ?
|
|
23
|
-
}, a = "") {
|
|
24
|
-
try {
|
|
25
|
-
return await navigator.mediaDevices.getUserMedia({
|
|
26
|
-
audio: a ? {
|
|
27
|
-
...e,
|
|
28
|
-
deviceId: { exact: a }
|
|
29
|
-
} : e
|
|
30
|
-
});
|
|
31
|
-
} catch (t) {
|
|
32
|
-
if (a && t.name === "OverconstrainedError")
|
|
33
|
-
return console.warn(
|
|
34
|
-
"Requested audio input device unavailable, falling back to default"
|
|
35
|
-
), navigator.mediaDevices.getUserMedia({ audio: e });
|
|
36
|
-
throw t;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
async function w(e = {
|
|
40
|
-
width: 1280,
|
|
41
|
-
height: 720,
|
|
42
|
-
facingMode: "user"
|
|
43
|
-
}) {
|
|
44
|
-
return navigator.mediaDevices.getUserMedia({
|
|
45
|
-
video: e
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
async function M() {
|
|
49
|
-
return (await u()).filter((a) => a.kind === "audioinput");
|
|
50
|
-
}
|
|
51
|
-
async function E() {
|
|
52
|
-
return (await u()).filter((a) => a.kind === "audiooutput");
|
|
53
|
-
}
|
|
54
|
-
async function I() {
|
|
55
|
-
return (await u()).filter((a) => a.kind === "videoinput");
|
|
56
|
-
}
|
|
57
|
-
function k(e) {
|
|
58
|
-
return navigator.mediaDevices.addEventListener("devicechange", e), () => navigator.mediaDevices.removeEventListener("devicechange", e);
|
|
59
|
-
}
|
|
60
|
-
const g = {
|
|
61
|
-
KeyZ: 48,
|
|
62
|
-
KeyS: 49,
|
|
63
|
-
KeyX: 50,
|
|
64
|
-
KeyD: 51,
|
|
65
|
-
KeyC: 52,
|
|
66
|
-
KeyV: 53,
|
|
67
|
-
KeyG: 54,
|
|
68
|
-
KeyB: 55,
|
|
69
|
-
KeyH: 56,
|
|
70
|
-
KeyN: 57,
|
|
71
|
-
KeyJ: 58,
|
|
72
|
-
KeyM: 59,
|
|
73
|
-
Comma: 60,
|
|
74
|
-
KeyL: 61,
|
|
75
|
-
Period: 62,
|
|
76
|
-
Semicolon: 63,
|
|
77
|
-
Slash: 64,
|
|
78
|
-
KeyQ: 60,
|
|
79
|
-
Digit2: 61,
|
|
80
|
-
KeyW: 62,
|
|
81
|
-
Digit3: 63,
|
|
82
|
-
KeyE: 64,
|
|
83
|
-
KeyR: 65,
|
|
84
|
-
Digit5: 66,
|
|
85
|
-
KeyT: 67,
|
|
86
|
-
Digit6: 68,
|
|
87
|
-
KeyY: 69,
|
|
88
|
-
Digit7: 70,
|
|
89
|
-
KeyU: 71,
|
|
90
|
-
KeyI: 72,
|
|
91
|
-
Digit9: 73,
|
|
92
|
-
KeyO: 74,
|
|
93
|
-
Digit0: 75,
|
|
94
|
-
KeyP: 76,
|
|
95
|
-
BracketLeft: 77,
|
|
96
|
-
Equal: 78,
|
|
97
|
-
BracketRight: 79,
|
|
98
|
-
// Numpad
|
|
99
|
-
Numpad1: 60,
|
|
100
|
-
Numpad2: 62,
|
|
101
|
-
Numpad3: 64,
|
|
102
|
-
Numpad4: 65,
|
|
103
|
-
Numpad5: 67,
|
|
104
|
-
Numpad6: 69,
|
|
105
|
-
Numpad7: 71,
|
|
106
|
-
Numpad8: 72,
|
|
107
|
-
Numpad9: 74
|
|
108
|
-
};
|
|
109
|
-
function n(e) {
|
|
110
|
-
const { baseNote: a, scale: t } = e;
|
|
111
|
-
if (t.length === 0)
|
|
112
|
-
throw new RangeError("scale must contain at least one interval");
|
|
113
|
-
const y = [
|
|
114
|
-
["KeyZ", "KeyX", "KeyC", "KeyV", "KeyB", "KeyN", "KeyM", "Comma", "Period", "Slash"],
|
|
115
|
-
["KeyA", "KeyS", "KeyD", "KeyF", "KeyG", "KeyH", "KeyJ", "KeyK", "KeyL", "Semicolon", "Quote", "Backslash"],
|
|
116
|
-
["KeyQ", "KeyW", "KeyE", "KeyR", "KeyT", "KeyY", "KeyU", "KeyI", "KeyO", "KeyP", "BracketLeft", "BracketRight"],
|
|
117
|
-
["Digit1", "Digit2", "Digit3", "Digit4", "Digit5", "Digit6", "Digit7", "Digit8", "Digit9", "Digit0", "Minus", "Equal"]
|
|
118
|
-
], o = {};
|
|
119
|
-
return y.forEach((s, i) => {
|
|
120
|
-
const c = a + i * 12;
|
|
121
|
-
s.forEach((r, d) => {
|
|
122
|
-
const K = d % t.length, m = Math.floor(d / t.length);
|
|
123
|
-
o[r] = c + m * 12 + t[K];
|
|
124
|
-
});
|
|
125
|
-
}), ["Numpad1", "Numpad2", "Numpad3", "Numpad4", "Numpad5", "Numpad6", "Numpad7", "Numpad8", "Numpad9"].forEach((s, i) => {
|
|
126
|
-
const c = i % t.length, r = Math.floor(i / t.length);
|
|
127
|
-
o[s] = a + 36 + r * 12 + t[c];
|
|
128
|
-
}), o;
|
|
129
|
-
}
|
|
130
|
-
const p = n({
|
|
131
|
-
baseNote: 36,
|
|
132
|
-
scale: [0, 2, 4, 5, 7, 9, 11]
|
|
133
|
-
}), v = n({
|
|
134
|
-
baseNote: 36,
|
|
135
|
-
scale: [0, 2, 3, 5, 7, 8, 10]
|
|
136
|
-
}), l = n({
|
|
137
|
-
baseNote: 36,
|
|
138
|
-
scale: [0, 2, 4, 7, 9]
|
|
139
|
-
// Major pentatonic
|
|
140
|
-
}), D = n({
|
|
141
|
-
baseNote: 48,
|
|
142
|
-
scale: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
|
|
143
|
-
}), b = "major", A = {
|
|
144
|
-
piano: g,
|
|
145
|
-
major: p,
|
|
146
|
-
minor: v,
|
|
147
|
-
pentatonic: l,
|
|
148
|
-
chromatic: D
|
|
149
|
-
};
|
|
150
|
-
export {
|
|
151
|
-
b as D,
|
|
152
|
-
n as a,
|
|
153
|
-
M as b,
|
|
154
|
-
D as c,
|
|
155
|
-
g as d,
|
|
156
|
-
E as e,
|
|
157
|
-
w as f,
|
|
158
|
-
N as g,
|
|
159
|
-
u as h,
|
|
160
|
-
f as i,
|
|
161
|
-
I as j,
|
|
162
|
-
A as k,
|
|
163
|
-
v as l,
|
|
164
|
-
p as m,
|
|
165
|
-
k as o,
|
|
166
|
-
l as p
|
|
167
|
-
};
|