@audio/synth-chirp 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/atom.js +29 -0
  2. package/package.json +6 -3
package/atom.js ADDED
@@ -0,0 +1,29 @@
1
+ // atom manifest — frequency sweep (exponential or linear chirp) over the timeline duration.
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).chirp()` renders chirp over those 5 seconds).
5
+
6
+ import chirpFn from './chirp.js'
7
+
8
+ export const chirp = (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 = chirpFn({
14
+ f0: params.f0[0], f1: params.f1[0],
15
+ duration: n / ctx.sampleRate, fs: ctx.sampleRate,
16
+ method: params.method, amp: params.amp[0],
17
+ })
18
+ const m = Math.min(n, d.length)
19
+ for (let c = 0; c < out.length; c++) { out[c].set(d.subarray(0, m)); out[c].fill(0, m) }
20
+ }
21
+ }
22
+ chirp.channels = { inputs: [], outputs: 'any' }
23
+ chirp.streaming = false
24
+ chirp.params = {
25
+ f0: { type: 'number', min: 1, max: 20000, default: 20, unit: 'Hz', curve: 'log' },
26
+ f1: { type: 'number', min: 1, max: 22050, default: 20000, unit: 'Hz', curve: 'log' },
27
+ method: { type: 'enum', values: ['exp', 'linear'], default: 'exp' },
28
+ amp: { type: 'number', min: 0, max: 1, default: 0.9 },
29
+ }
package/package.json CHANGED
@@ -1,16 +1,18 @@
1
1
  {
2
2
  "name": "@audio/synth-chirp",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Chirp — linear/exponential frequency sweep (ESS measurement signal, Farina 2000)",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "main": "chirp.js",
8
8
  "exports": {
9
9
  ".": "./chirp.js",
10
+ "./atom": "./atom.js",
10
11
  "./package.json": "./package.json"
11
12
  },
12
13
  "files": [
13
- "chirp.js"
14
+ "chirp.js",
15
+ "atom.js"
14
16
  ],
15
17
  "keywords": [
16
18
  "audio",
@@ -27,5 +29,6 @@
27
29
  },
28
30
  "publishConfig": {
29
31
  "access": "public"
30
- }
32
+ },
33
+ "atom": "./atom.js"
31
34
  }