@audio/synth-drum 1.1.2 → 2.0.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 +2 -2
- package/drum.js +2 -2
- package/package.json +1 -1
package/audio.js
CHANGED
|
@@ -13,7 +13,7 @@ const place = (out, d) => {
|
|
|
13
13
|
export const kick = (ctx) => (inputs, outputs, params) => {
|
|
14
14
|
const out = outputs[0]
|
|
15
15
|
if (!out || !out.length) return
|
|
16
|
-
place(out, membrane(
|
|
16
|
+
place(out, membrane(params.freq[0], { drop: params.drop[0], duration: Math.min(out[0].length / ctx.sampleRate, 2), fs: ctx.sampleRate, amp: params.amp[0] }))
|
|
17
17
|
}
|
|
18
18
|
kick.channels = { inputs: [], outputs: 'any' }
|
|
19
19
|
kick.streaming = false
|
|
@@ -26,7 +26,7 @@ kick.params = {
|
|
|
26
26
|
export const cymbal = (ctx) => (inputs, outputs, params) => {
|
|
27
27
|
const out = outputs[0]
|
|
28
28
|
if (!out || !out.length) return
|
|
29
|
-
place(out, metal(
|
|
29
|
+
place(out, metal(params.freq[0], { duration: Math.min(out[0].length / ctx.sampleRate, 2), fs: ctx.sampleRate, amp: params.amp[0] }))
|
|
30
30
|
}
|
|
31
31
|
cymbal.channels = { inputs: [], outputs: 'any' }
|
|
32
32
|
cymbal.streaming = false
|
package/drum.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Drum synthesis — membrane (pitch-dropping sine kick), metal (inharmonic square-ish
|
|
2
2
|
// cymbal), noise (snare/hat band noise), Tone.js MembraneSynth/MetalSynth/NoiseSynth class.
|
|
3
3
|
|
|
4
|
-
export function membrane (
|
|
4
|
+
export function membrane (freq = 55, { drop = 3, duration = 0.5, fs = 44100, amp = 0.9 } = {}) {
|
|
5
5
|
let n = Math.round(duration * fs)
|
|
6
6
|
let out = new Float32Array(n)
|
|
7
7
|
let phase = 0
|
|
@@ -14,7 +14,7 @@ export function membrane ({ freq = 55, drop = 3, duration = 0.5, fs = 44100, amp
|
|
|
14
14
|
return out
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
export function metal (
|
|
17
|
+
export function metal (freq = 200, { duration = 0.6, fs = 44100, amp = 0.5 } = {}) {
|
|
18
18
|
const RATIOS = [1, 1.483, 1.932, 2.546, 2.63, 3.897] // classic FM-bell inharmonic set
|
|
19
19
|
let n = Math.round(duration * fs)
|
|
20
20
|
let out = new Float32Array(n)
|