@audio/synth-sfx 1.1.2 → 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 +40 -3
- package/package.json +10 -2
- package/sfx.d.ts +40 -0
package/README.md
CHANGED
|
@@ -1,5 +1,42 @@
|
|
|
1
|
-
# @audio/synth-sfx
|
|
1
|
+
# @audio/synth-sfx [](https://www.npmjs.com/package/@audio/synth-sfx) [](https://github.com/krishnized/license)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
ZZFX-class parameterized SFX, 8 deterministic presets
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
```
|
|
6
|
+
npm install @audio/synth-sfx
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
```js
|
|
10
|
+
import sfx, { PRESETS } from '@audio/synth-sfx'
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Game/UI sound-effect generator (ZZFX/sfxr class): one parameterized pipeline — shaped oscillator → frequency slide/vibrato/arpeggio → ADSR-ish envelope → optional lowpass/bitcrush — behind 8 named presets covering the sfxr archetypes (`pickup`, `laser`, `explosion`, `powerup`, `hit`, `jump`, `blip`, `coin`). Every field is overridable; noise is seeded, so renders are reproducible.
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
sfx('laser') // named preset
|
|
17
|
+
sfx('coin', { seed: 42 }) // preset + override
|
|
18
|
+
sfx({ freq: 500, shape: 'square' }) // full custom parameter object
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
| Param | Default | |
|
|
22
|
+
|---|---|---|
|
|
23
|
+
| `preset` | `'blip'` | Preset name or full parameter object (positional) |
|
|
24
|
+
| `freq` | preset | Base frequency, Hz |
|
|
25
|
+
| `shape` | preset | `'sine'` \| `'square'` \| `'saw'` \| `'triangle'` \| `'noise'` |
|
|
26
|
+
| `slide` | `0` | Octaves/second exponential pitch slide |
|
|
27
|
+
| `vibrato` / `vibratoDepth` | `0` / `0.1` | Hz / depth |
|
|
28
|
+
| `arp` / `arpAt` | `0` / `0.05` | Frequency multiplier stepped at `arpAt` seconds |
|
|
29
|
+
| `attack` / `sustain` / `release` | `0.005` / `0.08` / `0.12` | Seconds |
|
|
30
|
+
| `lowpass` | `0` | One-pole lowpass cutoff, Hz (0 = off) |
|
|
31
|
+
| `crush` | `0` | 0..1 bitcrush amount |
|
|
32
|
+
| `amp` | `0.8` | Peak amplitude |
|
|
33
|
+
| `seed` | — | Noise PRNG seed |
|
|
34
|
+
| `fs` | `44100` | Sample rate |
|
|
35
|
+
|
|
36
|
+
**Use when:** deterministic game/UI SFX without shipping audio assets.
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
Part of [@audio/synth](https://github.com/audiojs/synth) — the synth family umbrella.
|
|
41
|
+
|
|
42
|
+
MIT © [audiojs](https://github.com/audiojs)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@audio/synth-sfx",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "Game/UI sound effects generator — ZZFX / ChipTone class parameterized synthesis",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -27,11 +27,19 @@
|
|
|
27
27
|
},
|
|
28
28
|
"files": [
|
|
29
29
|
"sfx.js",
|
|
30
|
+
"sfx.d.ts",
|
|
30
31
|
"audio.js",
|
|
31
32
|
"audio.d.ts"
|
|
32
33
|
],
|
|
34
|
+
"types": "sfx.d.ts",
|
|
33
35
|
"publishConfig": {
|
|
34
36
|
"access": "public"
|
|
35
37
|
},
|
|
36
|
-
"audio": "./audio.js"
|
|
38
|
+
"audio": "./audio.js",
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "git+https://github.com/audiojs/synth.git",
|
|
42
|
+
"directory": "packages/synth-sfx"
|
|
43
|
+
},
|
|
44
|
+
"funding": "https://github.com/sponsors/audiojs"
|
|
37
45
|
}
|
package/sfx.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/** ZZFX/sfxr-class parameterized SFX generator — shaped osc → slide/vibrato/arp → envelope → lowpass/bitcrush. */
|
|
2
|
+
export type SfxPreset = 'pickup' | 'laser' | 'explosion' | 'powerup' | 'hit' | 'jump' | 'blip' | 'coin'
|
|
3
|
+
|
|
4
|
+
export interface SfxOptions {
|
|
5
|
+
/** base frequency, Hz */
|
|
6
|
+
freq?: number
|
|
7
|
+
/** waveform */
|
|
8
|
+
shape?: 'sine' | 'square' | 'saw' | 'triangle' | 'noise'
|
|
9
|
+
/** octaves/second exponential pitch slide, default 0 */
|
|
10
|
+
slide?: number
|
|
11
|
+
/** Hz, default 0 */
|
|
12
|
+
vibrato?: number
|
|
13
|
+
/** depth, default 0.1 */
|
|
14
|
+
vibratoDepth?: number
|
|
15
|
+
/** frequency multiplier stepped at arpAt, default 0 */
|
|
16
|
+
arp?: number
|
|
17
|
+
/** seconds, default 0.05 */
|
|
18
|
+
arpAt?: number
|
|
19
|
+
/** seconds, default 0.005 */
|
|
20
|
+
attack?: number
|
|
21
|
+
/** seconds, default 0.08 */
|
|
22
|
+
sustain?: number
|
|
23
|
+
/** seconds, default 0.12 */
|
|
24
|
+
release?: number
|
|
25
|
+
/** one-pole lowpass cutoff Hz, 0 = off, default 0 */
|
|
26
|
+
lowpass?: number
|
|
27
|
+
/** 0..1 bitcrush amount, default 0 */
|
|
28
|
+
crush?: number
|
|
29
|
+
/** sample rate, default 44100 */
|
|
30
|
+
fs?: number
|
|
31
|
+
/** peak amplitude, default 0.8 */
|
|
32
|
+
amp?: number
|
|
33
|
+
/** noise PRNG seed */
|
|
34
|
+
seed?: number
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const PRESETS: Record<SfxPreset, SfxOptions>
|
|
38
|
+
|
|
39
|
+
/** preset: named preset ('blip' default) or a full parameter object */
|
|
40
|
+
export default function sfx(preset?: SfxPreset | SfxOptions, options?: SfxOptions): Float32Array
|