@thi.ng/dsp
Version:
Composable signal generators, oscillators, filters, FFT, spectrum, windowing & related DSP utils
42 lines • 1.64 kB
TypeScript
import type { Fn2 } from "@thi.ng/api";
import { AProc } from "./aproc.js";
export type WaveShaperFn = Fn2<number, number, number>;
/**
* Customizable wave shaper for user defined shaping function supporting one
* (optional, implementation specific) adjustable curve parameter. By default
* uses {@link waveshapeTan} and supports configurable curvature.
* Post-amplification is applied to the transformed result value (see remarks).
*
* @remarks
* If `amp` is `true` (default), the curve will be normalized such that input
* values in the `[-1,1]` range will be mapped to the same output interval.
*
* The following wave shaping functions are supplied by default:
*
* - {@link waveshapeTan}
* - {@link waveshapeSigmoid}
* - {@link waveshapeSin}
*
* [Interactive graph](https://www.desmos.com/calculator/hg4i7o836i)
*
* @param thresh - fold threshold
* @param amp - post amplifier / autogain flag
*/
export declare const waveShaper: (thresh?: number, amp?: number | true, map?: WaveShaperFn) => WaveShaper;
export declare class WaveShaper extends AProc<number, number> {
protected _coeff: number;
protected _map: WaveShaperFn;
protected _amp: number;
protected _autoGain: boolean;
constructor(_coeff?: number, amp?: number | true, _map?: WaveShaperFn);
next(x: number): number;
coeff(): number;
setCoeff(t: number): void;
amp(): number;
setAmp(a: number): void;
setAutoGain(): void;
}
export declare const waveshapeTan: WaveShaperFn;
export declare const waveshapeSigmoid: WaveShaperFn;
export declare const waveshapeSin: WaveShaperFn;
//# sourceMappingURL=waveshaper.d.ts.map