@audio/synth-drum 1.0.0 → 1.1.1

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 +48 -0
  2. package/package.json +6 -3
package/audio.js ADDED
@@ -0,0 +1,48 @@
1
+ // atom manifest — percussion one-shots (Tone.js parity: MembraneSynth = kick,
2
+ // MetalSynth = cymbal, NoiseSynth = snare). Three atoms from one file. Generators:
3
+ // no input bus, output width host-negotiated; whole-render one-shots placed at the
4
+ // start of the materialized timeline.
5
+
6
+ import { membrane, metal, noiseDrum } from './drum.js'
7
+
8
+ const place = (out, d) => {
9
+ const n = out[0].length, m = Math.min(n, d.length)
10
+ for (let c = 0; c < out.length; c++) { out[c].set(d.subarray(0, m)); out[c].fill(0, m) }
11
+ }
12
+
13
+ export const kick = (ctx) => (inputs, outputs, params) => {
14
+ const out = outputs[0]
15
+ if (!out || !out.length) return
16
+ place(out, membrane({ freq: params.freq[0], drop: params.drop[0], duration: Math.min(out[0].length / ctx.sampleRate, 2), fs: ctx.sampleRate, amp: params.amp[0] }))
17
+ }
18
+ kick.channels = { inputs: [], outputs: 'any' }
19
+ kick.streaming = false
20
+ kick.params = {
21
+ freq: { type: 'number', min: 30, max: 120, default: 55, unit: 'Hz' },
22
+ drop: { type: 'number', min: 1, max: 8, default: 3 },
23
+ amp: { type: 'number', min: 0, max: 1, default: 0.9 },
24
+ }
25
+
26
+ export const cymbal = (ctx) => (inputs, outputs, params) => {
27
+ const out = outputs[0]
28
+ if (!out || !out.length) return
29
+ place(out, metal({ freq: params.freq[0], duration: Math.min(out[0].length / ctx.sampleRate, 2), fs: ctx.sampleRate, amp: params.amp[0] }))
30
+ }
31
+ cymbal.channels = { inputs: [], outputs: 'any' }
32
+ cymbal.streaming = false
33
+ cymbal.params = {
34
+ freq: { type: 'number', min: 100, max: 800, default: 200, unit: 'Hz' },
35
+ amp: { type: 'number', min: 0, max: 1, default: 0.5 },
36
+ }
37
+
38
+ export const snare = (ctx) => (inputs, outputs, params) => {
39
+ const out = outputs[0]
40
+ if (!out || !out.length) return
41
+ place(out, noiseDrum({ duration: Math.min(out[0].length / ctx.sampleRate, 1), fs: ctx.sampleRate, amp: params.amp[0], seed: params.seed[0] | 0 }))
42
+ }
43
+ snare.channels = { inputs: [], outputs: 'any' }
44
+ snare.streaming = false
45
+ snare.params = {
46
+ amp: { type: 'number', min: 0, max: 1, default: 0.7 },
47
+ seed: { type: 'number', min: 1, max: 65536, default: 9, step: 1 },
48
+ }
package/package.json CHANGED
@@ -1,16 +1,18 @@
1
1
  {
2
2
  "name": "@audio/synth-drum",
3
- "version": "1.0.0",
3
+ "version": "1.1.1",
4
4
  "description": "Drum synthesis — membrane kick, metal cymbal, noise snare (Tone.js class)",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "main": "drum.js",
8
8
  "exports": {
9
9
  ".": "./drum.js",
10
+ "./audio": "./audio.js",
10
11
  "./package.json": "./package.json"
11
12
  },
12
13
  "files": [
13
- "drum.js"
14
+ "drum.js",
15
+ "audio.js"
14
16
  ],
15
17
  "keywords": [
16
18
  "audio",
@@ -25,5 +27,6 @@
25
27
  },
26
28
  "publishConfig": {
27
29
  "access": "public"
28
- }
30
+ },
31
+ "audio": "./audio.js"
29
32
  }