@audio/synth-noise 2.0.0 → 2.0.2
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 +36 -0
- package/colors.js +4 -1
- package/package.json +8 -2
package/README.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# @audio/synth-noise [](https://www.npmjs.com/package/@audio/synth-noise) [](https://github.com/krishnized/license)
|
|
2
|
+
|
|
3
|
+
Colors of noise — white/pink/brown/blue/violet, seeded, slope-verified; (duration, opts) seconds; pinkNoise filter kernel as named export
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
npm install @audio/synth-noise
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
```js
|
|
10
|
+
import noise, { white, pink, brown, blue, violet, pinkNoise } from '@audio/synth-noise'
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Seeded, deterministic noise-color generators with defined spectral slopes: white 0 dB/oct, pink -3 (Kellet filter), brown -6 (leaky integration), blue +3 (differentiated pink), violet +6 (differentiated white). Unpitched — `(duration, opts)` in seconds, the family convention every generator follows.
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
noise(1, { color: 'pink', seed: 1 }) // → Float32Array
|
|
17
|
+
pink(1, { seed: 1 }) // same, direct
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
| Param | Default | Applies to | |
|
|
21
|
+
|---|---|---|---|
|
|
22
|
+
| `duration` | `1` | all | Seconds (positional) |
|
|
23
|
+
| `color` | `'white'` | `noise()` only | `'white'` \| `'pink'` \| `'brown'` \| `'blue'` \| `'violet'` |
|
|
24
|
+
| `seed` | `1` | all | PRNG seed |
|
|
25
|
+
| `leak` | `0.999` | `brown` only | Integrator leak coefficient |
|
|
26
|
+
| `fs` | `44100` | all | Sample rate |
|
|
27
|
+
|
|
28
|
+
`pinkNoise` (from `./pink-noise.js`) is the underlying Kellet-filter kernel, exported directly for use outside the color generators.
|
|
29
|
+
|
|
30
|
+
**Use when:** dither, masking noise, testing filters/denoisers against known spectral slopes.
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
Part of [@audio/synth](https://github.com/audiojs/synth) — the synth family umbrella.
|
|
35
|
+
|
|
36
|
+
MIT © [audiojs](https://github.com/audiojs)
|
package/colors.js
CHANGED
|
@@ -9,10 +9,13 @@
|
|
|
9
9
|
import pinkNoise from './pink-noise.js'
|
|
10
10
|
export { default as pinkNoise } from './pink-noise.js'
|
|
11
11
|
|
|
12
|
+
// x ← (1103515245·x + 12345) mod 2³¹ (glibc's TYPE_0 random()), period 2³¹. Math.imul keeps the
|
|
13
|
+
// product exact mod 2³²: as a double it passes 2⁵³, its low bits round, and each of the seeds
|
|
14
|
+
// 1..65536 then falls into a cycle of 10,466 steps or fewer
|
|
12
15
|
function lcg (seed) {
|
|
13
16
|
let s = seed >>> 0 || 1
|
|
14
17
|
return () => {
|
|
15
|
-
s = (s
|
|
18
|
+
s = (Math.imul(s, 1103515245) + 12345) & 0x7fffffff
|
|
16
19
|
return s / 0x3fffffff - 1
|
|
17
20
|
}
|
|
18
21
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@audio/synth-noise",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"description": "Colors of noise — white, pink (Kellet), brown, blue, violet; seeded, slope-verified",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -39,5 +39,11 @@
|
|
|
39
39
|
"access": "public"
|
|
40
40
|
},
|
|
41
41
|
"types": "colors.d.ts",
|
|
42
|
-
"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-noise"
|
|
47
|
+
},
|
|
48
|
+
"funding": "https://github.com/sponsors/audiojs"
|
|
43
49
|
}
|