@audio/effect-flanger 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.
Files changed (2) hide show
  1. package/audio-module.js +30 -0
  2. package/package.json +7 -4
@@ -0,0 +1,30 @@
1
+ // audio-module manifest — wraps the flanger atom; state rides per-channel params objects.
2
+ // `delay` sizes the buffer at construction (flags: restart); rate/depth/feedback are live.
3
+
4
+ import flangerFn from './flanger.js'
5
+
6
+ export const flanger = (ctx) => {
7
+ const chP = []
8
+ for (let c = 0, N = ctx.maxChannels ?? 8; c < N; c++)
9
+ chP.push({ fs: ctx.sampleRate, delay: ctx.params.delay[0] })
10
+ return (inputs, outputs, params) => {
11
+ const inp = inputs[0], out = outputs[0]
12
+ if (!inp || !inp.length) return
13
+ for (let c = 0; c < inp.length; c++) {
14
+ const p = chP[c]
15
+ p.rate = params.rate[0]
16
+ p.depth = params.depth[0]
17
+ p.feedback = params.feedback[0]
18
+ out[c].set(inp[c])
19
+ flangerFn(out[c], p)
20
+ }
21
+ }
22
+ }
23
+ flanger.channels = 'any'
24
+ flanger.tail = ({ params }) => { let fb = params.feedback[0]; let reps = fb > 0 ? Math.log(1e-3) / Math.log(fb) : 1; return Math.max(0.05, (reps + 1) * 0.02) } // RT60 from live feedback × delay.max(20ms)
25
+ flanger.params = {
26
+ rate: { type: 'number', min: 0.02, max: 5, default: 0.3, unit: 'Hz', curve: 'log' },
27
+ depth: { type: 'number', min: 0, max: 1, default: 0.7 },
28
+ delay: { type: 'number', min: 0.1, max: 20, default: 3, unit: 'ms', flags: ['restart'] },
29
+ feedback: { type: 'number', min: 0, max: 0.9, default: 0.5 },
30
+ }
package/package.json CHANGED
@@ -1,16 +1,18 @@
1
1
  {
2
2
  "name": "@audio/effect-flanger",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Flanger — modulated short delay with feedback",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "main": "flanger.js",
8
8
  "exports": {
9
9
  ".": "./flanger.js",
10
- "./package.json": "./package.json"
10
+ "./package.json": "./package.json",
11
+ "./audio-module": "./audio-module.js"
11
12
  },
12
13
  "files": [
13
- "flanger.js"
14
+ "flanger.js",
15
+ "audio-module.js"
14
16
  ],
15
17
  "keywords": [
16
18
  "audio",
@@ -34,5 +36,6 @@
34
36
  },
35
37
  "publishConfig": {
36
38
  "access": "public"
37
- }
39
+ },
40
+ "audio-module": "./audio-module.js"
38
41
  }