@audio/synth-pluck 1.0.0 → 1.1.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/atom.js +28 -0
- package/package.json +6 -3
package/atom.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// atom manifest — Karplus-Strong plucked string.
|
|
2
|
+
// Generator: no input bus, output width host-negotiated; whole-render (the batch
|
|
3
|
+
// kernel produces its buffer in one call, placed over the materialized timeline —
|
|
4
|
+
// `audio(5).pluck()` renders pluck over those 5 seconds).
|
|
5
|
+
|
|
6
|
+
import pluckFn from './pluck.js'
|
|
7
|
+
|
|
8
|
+
export const pluck = (ctx) => {
|
|
9
|
+
return (inputs, outputs, params) => {
|
|
10
|
+
const out = outputs[0]
|
|
11
|
+
if (!out || !out.length) return
|
|
12
|
+
const n = out[0].length
|
|
13
|
+
const d = pluckFn(params.freq[0], {
|
|
14
|
+
fs: ctx.sampleRate, duration: n / ctx.sampleRate,
|
|
15
|
+
amp: params.amp[0], damp: params.damp[0], seed: params.seed[0] | 0,
|
|
16
|
+
})
|
|
17
|
+
const m = Math.min(n, d.length)
|
|
18
|
+
for (let c = 0; c < out.length; c++) { out[c].set(d.subarray(0, m)); out[c].fill(0, m) }
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
pluck.channels = { inputs: [], outputs: 'any' }
|
|
22
|
+
pluck.streaming = false
|
|
23
|
+
pluck.params = {
|
|
24
|
+
freq: { type: 'number', min: 20, max: 4000, default: 220, unit: 'Hz', curve: 'log' },
|
|
25
|
+
damp: { type: 'number', min: 0.9, max: 0.9999, default: 0.996 },
|
|
26
|
+
amp: { type: 'number', min: 0, max: 1, default: 0.7 },
|
|
27
|
+
seed: { type: 'number', min: 1, max: 65536, default: 1, step: 1 },
|
|
28
|
+
}
|
package/package.json
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@audio/synth-pluck",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Karplus-Strong plucked string synthesis",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"main": "pluck.js",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": "./pluck.js",
|
|
10
|
+
"./atom": "./atom.js",
|
|
10
11
|
"./package.json": "./package.json"
|
|
11
12
|
},
|
|
12
13
|
"files": [
|
|
13
|
-
"pluck.js"
|
|
14
|
+
"pluck.js",
|
|
15
|
+
"atom.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
|
+
"atom": "./atom.js"
|
|
29
32
|
}
|