@audio/synth-rhythm 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.
- package/audio.js +31 -0
- package/package.json +6 -3
package/audio.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// atom manifest — metronome / click track at a BPM grid, accented downbeats.
|
|
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).rhythm()` renders rhythm over those 5 seconds).
|
|
5
|
+
|
|
6
|
+
import rhythmFn from './rhythm.js'
|
|
7
|
+
|
|
8
|
+
export const rhythm = (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 beats = params.beats[0] | 0
|
|
14
|
+
const bars = Math.max(1, Math.ceil((n / ctx.sampleRate) * params.bpm[0] / 60 / beats))
|
|
15
|
+
const d = rhythmFn({
|
|
16
|
+
bpm: params.bpm[0], bars, beats, fs: ctx.sampleRate,
|
|
17
|
+
freq: params.freq[0], accentFreq: params.accentFreq[0], amp: params.amp[0],
|
|
18
|
+
})
|
|
19
|
+
const m = Math.min(n, d.length)
|
|
20
|
+
for (let c = 0; c < out.length; c++) { out[c].set(d.subarray(0, m)); out[c].fill(0, m) }
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
rhythm.channels = { inputs: [], outputs: 'any' }
|
|
24
|
+
rhythm.streaming = false
|
|
25
|
+
rhythm.params = {
|
|
26
|
+
bpm: { type: 'number', min: 20, max: 300, default: 120 },
|
|
27
|
+
beats: { type: 'number', min: 1, max: 12, default: 4, step: 1 },
|
|
28
|
+
freq: { type: 'number', min: 200, max: 4000, default: 1000, unit: 'Hz' },
|
|
29
|
+
accentFreq: { type: 'number', min: 200, max: 6000, default: 1500, unit: 'Hz' },
|
|
30
|
+
amp: { type: 'number', min: 0, max: 1, default: 0.7 },
|
|
31
|
+
}
|
package/package.json
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@audio/synth-rhythm",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Rhythm / click track — BPM grid with accented downbeats",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"main": "rhythm.js",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": "./rhythm.js",
|
|
10
|
+
"./audio": "./audio.js",
|
|
10
11
|
"./package.json": "./package.json"
|
|
11
12
|
},
|
|
12
13
|
"files": [
|
|
13
|
-
"rhythm.js"
|
|
14
|
+
"rhythm.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
|
}
|