@audio/synth-pluck 1.1.1 → 1.1.3

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-pluck [![npm](https://img.shields.io/npm/v/@audio/synth-pluck)](https://www.npmjs.com/package/@audio/synth-pluck) [![MIT](https://img.shields.io/badge/MIT-%E0%A5%90-white)](https://github.com/krishnized/license)
2
+
3
+ Karplus-Strong plucked string
4
+
5
+ ```
6
+ npm install @audio/synth-pluck
7
+ ```
8
+
9
+ ```js
10
+ import pluck from '@audio/synth-pluck'
11
+ ```
12
+
13
+ Karplus-Strong plucked string (Karplus & Strong 1983): a seeded noise burst circulates through an averaging delay loop sized to the pitch period, decaying via the loop's damping factor. Pitched — `(freq, opts)`.
14
+
15
+ ```js
16
+ pluck(220, { damp: 0.996, duration: 1.5 }) // → Float32Array
17
+ ```
18
+
19
+ | Param | Default | |
20
+ |---|---|---|
21
+ | `freq` | — | Hz (positional) — sets the delay-loop length |
22
+ | `duration` | `1` | Seconds |
23
+ | `amp` | `0.7` | Noise-burst amplitude |
24
+ | `damp` | `0.996` | Loop damping — closer to 1 decays slower |
25
+ | `seed` | `1` | PRNG seed for the excitation burst |
26
+ | `fs` | `44100` | Sample rate |
27
+
28
+ **Use when:** plucked-string/guitar-like tones without a physical model; cheap and classic.
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 ADDED
@@ -0,0 +1,39 @@
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.
3
+
4
+ /** Automatable number — scalar, `t => value` fn, or breakpoint curve {t, v} */
5
+ type Auto = number | ((t: number) => number) | { t: number[], v: number[] }
6
+ /** Per-block param values as delivered by hosts (numbers arrive as 1-length Float32Array) */
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 }
9
+ type Process = (inputs: Float32Array[][], outputs: Float32Array[][], params: Live) => void
10
+
11
+ /** Chainable-host options for 'pluck' */
12
+ export interface PluckOptions {
13
+ /** 20..4000 Hz (default 220) */
14
+ "freq"?: Auto
15
+ /** 0.9..0.9999 (default 0.996) */
16
+ "damp"?: Auto
17
+ /** 0..1 (default 0.7) */
18
+ "amp"?: Auto
19
+ /** 1..65536 (default 1) */
20
+ "seed"?: Auto
21
+ at?: number | string
22
+ duration?: number | string
23
+ }
24
+
25
+ export declare const pluck: {
26
+ (ctx: Ctx): Process
27
+ channels: {"inputs":[],"outputs":"any"}
28
+ streaming: false
29
+ params: {
30
+ /** 20..4000 Hz (default 220) */
31
+ "freq": { type: "number", default: 220 }
32
+ /** 0.9..0.9999 (default 0.996) */
33
+ "damp": { type: "number", default: 0.996 }
34
+ /** 0..1 (default 0.7) */
35
+ "amp": { type: "number", default: 0.7 }
36
+ /** 1..65536 (default 1) */
37
+ "seed": { type: "number", default: 1 }
38
+ }
39
+ }
package/package.json CHANGED
@@ -1,19 +1,25 @@
1
1
  {
2
2
  "name": "@audio/synth-pluck",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "description": "Karplus-Strong plucked string synthesis",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "main": "pluck.js",
8
8
  "exports": {
9
9
  ".": "./pluck.js",
10
- "./audio": "./audio.js",
10
+ "./audio": {
11
+ "types": "./audio.d.ts",
12
+ "default": "./audio.js"
13
+ },
11
14
  "./package.json": "./package.json"
12
15
  },
13
16
  "files": [
14
17
  "pluck.js",
15
- "audio.js"
18
+ "pluck.d.ts",
19
+ "audio.js",
20
+ "audio.d.ts"
16
21
  ],
22
+ "types": "pluck.d.ts",
17
23
  "keywords": [
18
24
  "audio",
19
25
  "dsp",
@@ -28,5 +34,11 @@
28
34
  "publishConfig": {
29
35
  "access": "public"
30
36
  },
31
- "audio": "./audio.js"
37
+ "audio": "./audio.js",
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "git+https://github.com/audiojs/synth.git",
41
+ "directory": "packages/synth-pluck"
42
+ },
43
+ "funding": "https://github.com/sponsors/audiojs"
32
44
  }
package/pluck.d.ts ADDED
@@ -0,0 +1,16 @@
1
+ /** Karplus-Strong plucked string — seeded noise burst through an averaging delay loop. */
2
+ export interface PluckOptions {
3
+ /** sample rate, default 44100 */
4
+ fs?: number
5
+ /** seconds, default 1 */
6
+ duration?: number
7
+ /** noise-burst amplitude, default 0.7 */
8
+ amp?: number
9
+ /** loop damping 0.9..0.9999, default 0.996 */
10
+ damp?: number
11
+ /** PRNG seed, default 1 */
12
+ seed?: number
13
+ }
14
+
15
+ /** freq: Hz (positional) — sets the delay-loop length */
16
+ export default function pluck(freq: number, options?: PluckOptions): Float32Array