@audio/synth-envelope 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 ADDED
@@ -0,0 +1,34 @@
1
+ # @audio/synth-envelope [![npm](https://img.shields.io/npm/v/@audio/synth-envelope)](https://www.npmjs.com/package/@audio/synth-envelope) [![MIT](https://img.shields.io/badge/MIT-%E0%A5%90-white)](https://github.com/krishnized/license)
2
+
3
+ ADSR contour generator (one-shot, known length)
4
+
5
+ ```
6
+ npm install @audio/synth-envelope
7
+ ```
8
+
9
+ ```js
10
+ import adsr from '@audio/synth-envelope'
11
+ ```
12
+
13
+ ADSR gain-contour generator — attack/decay linear, sustain flat, release exponential-ish. Returns a `Float32Array` contour to multiply onto any source (gain, filter cutoff, amplitude); one-shot, whole envelope rendered up front (known total length, unlike a gate-driven realtime ADSR).
14
+
15
+ ```js
16
+ adsr({ attack: 0.01, decay: 0.1, sustain: 0.7, release: 0.3, duration: 1 })
17
+ ```
18
+
19
+ | Param | Default | |
20
+ |---|---|---|
21
+ | `attack` | `0.01` | Seconds |
22
+ | `decay` | `0.1` | Seconds |
23
+ | `sustain` | `0.7` | Sustain level, 0..1 |
24
+ | `release` | `0.3` | Seconds |
25
+ | `duration` | `1` | Note-on length, seconds (release starts here) |
26
+ | `fs` | `44100` | Sample rate |
27
+
28
+ **Use when:** shaping any generator's amplitude or a filter cutoff — used internally by [`synth-voice`](https://github.com/audiojs/synth/tree/main/packages/synth-voice).
29
+
30
+ ---
31
+
32
+ Part of [@audio/synth](https://github.com/audiojs/synth) — the synth family umbrella.
33
+
34
+ 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/compile. Do not edit by hand.
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 Ctx = { sampleRate: number, maxBlockSize: number, maxChannels: number, currentTime: number, duration?: number, events?: readonly any[], emit?: (name: string, ...args: any[]) => void, [k: string]: unknown }
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 'adsr' */
@@ -28,12 +30,12 @@ export declare const adsr: {
28
30
  streaming: false
29
31
  params: {
30
32
  /** 0.001..2 s (default 0.01) */
31
- "attack": { type: "number", default: 0.01 }
33
+ "attack": { type: "number", min: 0.001, max: 2, default: 0.01, unit: "s", curve: "log" }
32
34
  /** 0.001..2 s (default 0.1) */
33
- "decay": { type: "number", default: 0.1 }
35
+ "decay": { type: "number", min: 0.001, max: 2, default: 0.1, unit: "s", curve: "log" }
34
36
  /** 0..1 (default 0.7) */
35
- "sustain": { type: "number", default: 0.7 }
37
+ "sustain": { type: "number", min: 0, max: 1, default: 0.7 }
36
38
  /** 0.001..4 s (default 0.3) */
37
- "release": { type: "number", default: 0.3 }
39
+ "release": { type: "number", min: 0.001, max: 4, default: 0.3, unit: "s", curve: "log" }
38
40
  }
39
41
  }
package/envelope.d.ts ADDED
@@ -0,0 +1,17 @@
1
+ /** ADSR gain-contour generator — one-shot, whole envelope rendered up front. */
2
+ export interface AdsrOptions {
3
+ /** seconds, default 0.01 */
4
+ attack?: number
5
+ /** seconds, default 0.1 */
6
+ decay?: number
7
+ /** sustain level 0..1, default 0.7 */
8
+ sustain?: number
9
+ /** seconds, default 0.3 */
10
+ release?: number
11
+ /** note-on length, seconds (release starts here), default 1 */
12
+ duration?: number
13
+ /** sample rate, default 44100 */
14
+ fs?: number
15
+ }
16
+
17
+ export default function adsr(options?: AdsrOptions): Float32Array
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@audio/synth-envelope",
3
- "version": "1.1.2",
3
+ "version": "1.1.4",
4
4
  "description": "ADSR envelope generator — gain contour for amplitude/filter modulation",
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
  "envelope.js",
21
+ "envelope.d.ts",
18
22
  "audio.js",
19
23
  "audio.d.ts"
20
24
  ],
25
+ "types": "envelope.d.ts",
21
26
  "keywords": [
22
27
  "audio",
23
28
  "dsp",
@@ -32,5 +37,11 @@
32
37
  "publishConfig": {
33
38
  "access": "public"
34
39
  },
35
- "audio": "./audio.js"
40
+ "audio": "./audio.js",
41
+ "repository": {
42
+ "type": "git",
43
+ "url": "git+https://github.com/audiojs/synth.git",
44
+ "directory": "packages/synth-envelope"
45
+ },
46
+ "funding": "https://github.com/sponsors/audiojs"
36
47
  }