1 | import { ToneAudioNodeOptions } from "../core/context/ToneAudioNode.js";
|
2 | import { SignalOperator } from "./SignalOperator.js";
|
3 | export type WaveShaperMappingFn = (value: number, index?: number) => number;
|
4 | type WaveShaperMapping = WaveShaperMappingFn | number[] | Float32Array;
|
5 | interface WaveShaperOptions extends ToneAudioNodeOptions {
|
6 | mapping?: WaveShaperMapping;
|
7 | length: number;
|
8 | curve?: number[] | Float32Array;
|
9 | }
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 | export declare class WaveShaper extends SignalOperator<WaveShaperOptions> {
|
22 | readonly name: string;
|
23 | |
24 |
|
25 |
|
26 | private _shaper;
|
27 | |
28 |
|
29 |
|
30 | input: WaveShaperNode;
|
31 | |
32 |
|
33 |
|
34 | output: WaveShaperNode;
|
35 | |
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 | constructor(mapping?: WaveShaperMapping, length?: number);
|
48 | constructor(options?: Partial<WaveShaperOptions>);
|
49 | static getDefaults(): WaveShaperOptions;
|
50 | /**
|
51 | * Uses a mapping function to set the value of the curve.
|
52 | * @param mapping The function used to define the values.
|
53 | * The mapping function take two arguments:
|
54 | * the first is the value at the current position
|
55 | * which goes from -1 to 1 over the number of elements
|
56 | * in the curve array. The second argument is the array position.
|
57 | * @example
|
58 | * const shaper = new Tone.WaveShaper();
|
59 | * // map the input signal from [-1, 1] to [0, 10]
|
60 | * shaper.setMap((val, index) => (val + 1) * 5);
|
61 | */
|
62 | setMap(mapping: WaveShaperMappingFn, length?: number): this;
|
63 | /**
|
64 | * The array to set as the waveshaper curve. For linear curves
|
65 | * array length does not make much difference, but for complex curves
|
66 | * longer arrays will provide smoother interpolation.
|
67 | */
|
68 | get curve(): Float32Array | null;
|
69 | set curve(mapping: Float32Array | null);
|
70 | /**
|
71 | * Specifies what type of oversampling (if any) should be used when
|
72 | * applying the shaping curve. Can either be "none", "2x" or "4x".
|
73 | */
|
74 | get oversample(): OverSampleType;
|
75 | set oversample(oversampling: OverSampleType);
|
76 | /**
|
77 | * Clean up.
|
78 | */
|
79 | dispose(): this;
|
80 | }
|
81 | export {};
|