@audio/synth-voice 1.2.0 → 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.
Files changed (2) hide show
  1. package/audio.js +3 -2
  2. package/package.json +4 -1
package/audio.js CHANGED
@@ -19,7 +19,7 @@ export const voice = (ctx) => {
19
19
  const evs = ctx.events || []
20
20
  const on = new Map()
21
21
  const render = (slot, endSample) => {
22
- const freq = midiToHz(slot.pitch)
22
+ const freq = midiToHz(slot.midi)
23
23
  const dur = Math.max(0.01, (endSample - slot.time) / sr)
24
24
  const d = voiceFn(freq, {
25
25
  fs: sr, duration: dur,
@@ -33,7 +33,8 @@ export const voice = (ctx) => {
33
33
  }
34
34
  for (let i = 0; i < evs.length; i++) {
35
35
  const e = evs[i]
36
- if (e.kind === 'on') on.set(e.id, { time: e.time, pitch: e.pitch, velocity: e.velocity })
36
+ // a host older than contract 1.0 names the note number `pitch`
37
+ if (e.kind === 'on') on.set(e.id, { time: e.time, midi: e.midi ?? e.pitch, velocity: e.velocity })
37
38
  else if (e.kind === 'off' && on.has(e.id)) { render(on.get(e.id), e.time); on.delete(e.id) }
38
39
  }
39
40
  for (const slot of on.values()) render(slot, n) // unterminated notes ring to the end
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@audio/synth-voice",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "Synth voice — osc × ADSR through envelope-scaled lowpass (Tone.js Synth class)",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -13,6 +13,9 @@
13
13
  },
14
14
  "./package.json": "./package.json"
15
15
  },
16
+ "scripts": {
17
+ "prepublishOnly": "node ../../../compile/tools/tested.js"
18
+ },
16
19
  "files": [
17
20
  "voice.js",
18
21
  "voice.d.ts",