@audio/synth-chirp 1.1.2 → 1.1.4
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/README.md +35 -0
- package/audio.d.ts +7 -5
- package/chirp.d.ts +19 -0
- package/package.json +13 -2
package/README.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# @audio/synth-chirp [](https://www.npmjs.com/package/@audio/synth-chirp) [](https://github.com/krishnized/license)
|
|
2
|
+
|
|
3
|
+
Frequency sweep — exp/linear
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
npm install @audio/synth-chirp
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
```js
|
|
10
|
+
import chirp from '@audio/synth-chirp'
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Frequency sweep generator. Exponential (log) sweep is the ESS measurement signal (Farina 2000, used by [`@audio/measure-ir`](https://github.com/audiojs/measure-ir)); linear sweep is for response plots. Instantaneous frequency: linear `f(t) = f0 + (f1-f0)·t/T`, exponential `f(t) = f0·(f1/f0)^(t/T)`. Unpitched — single opts argument, edges fade to avoid clicks.
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
chirp({ f0: 20, f1: 20000, duration: 1, method: 'exp' }) // → Float32Array
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
| Param | Default | |
|
|
20
|
+
|---|---|---|
|
|
21
|
+
| `f0` | `20` | Start frequency, Hz |
|
|
22
|
+
| `f1` | `fs/2 · 0.95` | End frequency, Hz |
|
|
23
|
+
| `duration` | `1` | Seconds |
|
|
24
|
+
| `method` | `'exp'` | `'exp'` or `'lin'` |
|
|
25
|
+
| `amp` | `0.9` | Peak amplitude |
|
|
26
|
+
| `fade` | `0.005` | Edge fade, seconds (anti-click) |
|
|
27
|
+
| `fs` | `44100` | Sample rate |
|
|
28
|
+
|
|
29
|
+
**Use when:** measuring an impulse response (ESS deconvolution) or sweeping a filter/effect for a Bode-style plot.
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
Part of [@audio/synth](https://github.com/audiojs/synth) — the synth family umbrella.
|
|
34
|
+
|
|
35
|
+
MIT © [audiojs](https://github.com/audiojs)
|
package/audio.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
// Generated from the audio.js manifest (params metadata is the source of truth).
|
|
2
|
-
// Regenerate: node tools/dts.js in @audio/
|
|
2
|
+
// Regenerate: node tools/dts.js in @audio/plugin. Do not edit by hand.
|
|
3
3
|
|
|
4
4
|
/** Automatable number — scalar, `t => value` fn, or breakpoint curve {t, v} */
|
|
5
5
|
type Auto = number | ((t: number) => number) | { t: number[], v: number[] }
|
|
6
6
|
/** Per-block param values as delivered by hosts (numbers arrive as 1-length Float32Array) */
|
|
7
7
|
type Live = Record<string, Float32Array | string | boolean>
|
|
8
|
-
type
|
|
8
|
+
type Transport = Readonly<{ playing: boolean, bpm: number, beat: number, barStart: number, timeSig: [number, number] }>
|
|
9
|
+
/** What a host hands a processor it builds: the contract's Context (CONTRACT.d.ts, 1.0) */
|
|
10
|
+
type Ctx = { readonly sampleRate: number, readonly maxBlockSize: number, readonly maxChannels: number, readonly layouts?: { readonly inputs: readonly (string | undefined)[], readonly outputs: readonly (string | undefined)[] }, readonly params: Live, readonly buffers: Readonly<Record<string, Float32Array[] | undefined>>, readonly events?: readonly { time: number, kind: 'on' | 'off', midi: number, velocity: number, id: number }[], emit(name: string, value: number): void, readonly transport: Transport }
|
|
9
11
|
type Process = (inputs: Float32Array[][], outputs: Float32Array[][], params: Live) => void
|
|
10
12
|
|
|
11
13
|
/** Chainable-host options for 'chirp' */
|
|
@@ -28,12 +30,12 @@ export declare const chirp: {
|
|
|
28
30
|
streaming: false
|
|
29
31
|
params: {
|
|
30
32
|
/** 1..20000 Hz (default 20) */
|
|
31
|
-
"f0": { type: "number", default: 20 }
|
|
33
|
+
"f0": { type: "number", min: 1, max: 20000, default: 20, unit: "Hz", curve: "log" }
|
|
32
34
|
/** 1..22050 Hz (default 20000) */
|
|
33
|
-
"f1": { type: "number", default: 20000 }
|
|
35
|
+
"f1": { type: "number", min: 1, max: 22050, default: 20000, unit: "Hz", curve: "log" }
|
|
34
36
|
/** default "exp" */
|
|
35
37
|
"method": { type: "enum", values: ["exp","linear"], default: "exp" }
|
|
36
38
|
/** 0..1 (default 0.9) */
|
|
37
|
-
"amp": { type: "number", default: 0.9 }
|
|
39
|
+
"amp": { type: "number", min: 0, max: 1, default: 0.9 }
|
|
38
40
|
}
|
|
39
41
|
}
|
package/chirp.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Frequency sweep generator — exponential (ESS) or linear. */
|
|
2
|
+
export interface ChirpOptions {
|
|
3
|
+
/** start frequency, Hz, default 20 */
|
|
4
|
+
f0?: number
|
|
5
|
+
/** end frequency, Hz, default fs/2 * 0.95 */
|
|
6
|
+
f1?: number
|
|
7
|
+
/** seconds, default 1 */
|
|
8
|
+
duration?: number
|
|
9
|
+
/** sample rate, default 44100 */
|
|
10
|
+
fs?: number
|
|
11
|
+
/** sweep shape, default 'exp' */
|
|
12
|
+
method?: 'exp' | 'lin'
|
|
13
|
+
/** peak amplitude, default 0.9 */
|
|
14
|
+
amp?: number
|
|
15
|
+
/** edge fade, seconds, default 0.005 */
|
|
16
|
+
fade?: number
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default function chirp(options?: ChirpOptions): Float32Array
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@audio/synth-chirp",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
4
4
|
"description": "Chirp — linear/exponential frequency sweep (ESS measurement signal, Farina 2000)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -13,11 +13,16 @@
|
|
|
13
13
|
},
|
|
14
14
|
"./package.json": "./package.json"
|
|
15
15
|
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"prepublishOnly": "node ../../../compile/tools/tested.js"
|
|
18
|
+
},
|
|
16
19
|
"files": [
|
|
17
20
|
"chirp.js",
|
|
21
|
+
"chirp.d.ts",
|
|
18
22
|
"audio.js",
|
|
19
23
|
"audio.d.ts"
|
|
20
24
|
],
|
|
25
|
+
"types": "chirp.d.ts",
|
|
21
26
|
"keywords": [
|
|
22
27
|
"audio",
|
|
23
28
|
"dsp",
|
|
@@ -34,5 +39,11 @@
|
|
|
34
39
|
"publishConfig": {
|
|
35
40
|
"access": "public"
|
|
36
41
|
},
|
|
37
|
-
"audio": "./audio.js"
|
|
42
|
+
"audio": "./audio.js",
|
|
43
|
+
"repository": {
|
|
44
|
+
"type": "git",
|
|
45
|
+
"url": "git+https://github.com/audiojs/synth.git",
|
|
46
|
+
"directory": "packages/synth-chirp"
|
|
47
|
+
},
|
|
48
|
+
"funding": "https://github.com/sponsors/audiojs"
|
|
38
49
|
}
|