@thi.ng/dsp
Version:
Composable signal generators, oscillators, filters, FFT, spectrum, windowing & related DSP utils
41 lines • 1.63 kB
TypeScript
import type { IReset, Tuple } from "@thi.ng/api";
import type { IRandom } from "@thi.ng/random";
import { AGen } from "./agen.js";
export type PNoiseCoeffs = Tuple<number, 5>;
/**
* Pink noise generator with customizable frequency distribution. The
* default config produces a power spectrum roughly following the `1/f`
* pink characteristic.
*
* @remarks
* Custom frequency/power distributions can be obtained by providing
* `amp` and `prob`ability tuples for the 5 internal bins used to
* compute the noise. `amp` defines per-bin power contributions, the
* latter bin update probabilities.
*
* Resulting noise values are normalized to given `gain`, which itself
* is scale relative to the sum of given `amp` values.
*
* References:
*
* - http://web.archive.org/web/20160513114217/http://home.earthlink.net/~ltrammell/tech/newpink.htm
* - http://web.archive.org/web/20160515145318if_/http://home.earthlink.net/~ltrammell/tech/pinkalg.htm
* - https://www.musicdsp.org/en/latest/Synthesis/220-trammell-pink-noise-c-class.html
*
* @param gain -
* @param rnd -
* @param amp -
* @param prob -
*/
export declare const pinkNoise: (gain?: number, rnd?: IRandom, amp?: PNoiseCoeffs, prob?: PNoiseCoeffs) => PinkNoise;
export declare class PinkNoise extends AGen<number> implements IReset {
protected _gain: number;
protected _rnd: IRandom;
protected _amp: PNoiseCoeffs;
protected _bins: number[];
protected _psum: number[];
constructor(_gain?: number, _rnd?: IRandom, _amp?: PNoiseCoeffs, prob?: PNoiseCoeffs);
reset(): this;
next(): number;
}
//# sourceMappingURL=pink-noise.d.ts.map