@audio/synth-poly 1.2.1 → 1.3.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/audio.js +4 -3
- package/package.json +4 -1
package/audio.js
CHANGED
|
@@ -16,14 +16,15 @@ export const poly = (ctx) => {
|
|
|
16
16
|
const on = new Map(), notes = []
|
|
17
17
|
for (let i = 0; i < evs.length; i++) {
|
|
18
18
|
const e = evs[i]
|
|
19
|
-
|
|
19
|
+
// a host older than contract 1.0 names the note number `pitch`
|
|
20
|
+
if (e.kind === 'on') on.set(e.id, { time: e.time, midi: e.midi ?? e.pitch, velocity: e.velocity })
|
|
20
21
|
else if (e.kind === 'off' && on.has(e.id)) {
|
|
21
22
|
const s = on.get(e.id)
|
|
22
|
-
notes.push({ time: s.time / sr, midi: s.
|
|
23
|
+
notes.push({ time: s.time / sr, midi: s.midi, duration: (e.time - s.time) / sr, velocity: s.velocity ?? 1 })
|
|
23
24
|
on.delete(e.id)
|
|
24
25
|
}
|
|
25
26
|
}
|
|
26
|
-
for (const s of on.values()) notes.push({ time: s.time / sr, midi: s.
|
|
27
|
+
for (const s of on.values()) notes.push({ time: s.time / sr, midi: s.midi, duration: (n - s.time) / sr, velocity: s.velocity ?? 1 })
|
|
27
28
|
const type = params.type, amp = params.amp[0]
|
|
28
29
|
const d = polyFn(notes, {
|
|
29
30
|
fs: sr, duration: n / sr,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@audio/synth-poly",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Polyphonic voice allocator — wrap any voice with N-voice polyphony",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -23,6 +23,9 @@
|
|
|
23
23
|
},
|
|
24
24
|
"./package.json": "./package.json"
|
|
25
25
|
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"prepublishOnly": "node ../../../compile/tools/tested.js"
|
|
28
|
+
},
|
|
26
29
|
"files": [
|
|
27
30
|
"poly.js",
|
|
28
31
|
"poly.d.ts",
|