1 | import { Frequency } from "../core/type/Units.js";
|
2 | import { Effect, EffectOptions } from "../effect/Effect.js";
|
3 | import { Signal } from "../signal/Signal.js";
|
4 | interface FrequencyShifterOptions extends EffectOptions {
|
5 | frequency: Frequency;
|
6 | }
|
7 | /**
|
8 | * FrequencyShifter can be used to shift all frequencies of a signal by a fixed amount.
|
9 | * The amount can be changed at audio rate and the effect is applied in real time.
|
10 | * The frequency shifting is implemented with a technique called single side band modulation using a ring modulator.
|
11 | * Note: Contrary to pitch shifting, all frequencies are shifted by the same amount,
|
12 | * destroying the harmonic relationship between them. This leads to the classic ring modulator timbre distortion.
|
13 | * The algorithm will produces some aliasing towards the high end, especially if your source material
|
14 | * contains a lot of high frequencies. Unfortunatelly the webaudio API does not support resampling
|
15 | * buffers in real time, so it is not possible to fix it properly. Depending on the use case it might
|
16 | * be an option to low pass filter your input before frequency shifting it to get ride of the aliasing.
|
17 | * You can find a very detailed description of the algorithm here: https://larzeitlin.github.io/RMFS/
|
18 | *
|
19 | * @example
|
20 | * const input = new Tone.Oscillator(230, "sawtooth").start();
|
21 | * const shift = new Tone.FrequencyShifter(42).toDestination();
|
22 | * input.connect(shift);
|
23 | * @category Effect
|
24 | */
|
25 | export declare class FrequencyShifter extends Effect<FrequencyShifterOptions> {
|
26 | readonly name: string;
|
27 | /**
|
28 | * The ring modulators carrier frequency. This frequency determines
|
29 | * by how many Hertz the input signal will be shifted up or down. Default is 0.
|
30 | */
|
31 | readonly frequency: Signal<"frequency">;
|
32 | /**
|
33 | * The ring modulators sine carrier
|
34 | */
|
35 | private _sine;
|
36 | /**
|
37 | * The ring modulators cosine carrier
|
38 | */
|
39 | private _cosine;
|
40 | /**
|
41 | * The sine multiply operator
|
42 | */
|
43 | private _sineMultiply;
|
44 | /**
|
45 | * The cosine multiply operator
|
46 | */
|
47 | private _cosineMultiply;
|
48 | /**
|
49 | * The negate operator
|
50 | */
|
51 | private _negate;
|
52 | /**
|
53 | * The final add operator
|
54 | */
|
55 | private _add;
|
56 | /**
|
57 | * The phase shifter to create the initial 90° phase offset
|
58 | */
|
59 | private _phaseShifter;
|
60 | /**
|
61 | * @param frequency The incoming signal is shifted by this frequency value.
|
62 | */
|
63 | constructor(frequency?: Frequency);
|
64 | constructor(options?: Partial<FrequencyShifterOptions>);
|
65 | static getDefaults(): FrequencyShifterOptions;
|
66 | dispose(): this;
|
67 | }
|
68 | export {};
|