UNPKG

2.83 kBTypeScriptView Raw
1import { Interval, Seconds, Time } from "../core/type/Units.js";
2import { FeedbackEffect, FeedbackEffectOptions } from "./FeedbackEffect.js";
3import { Param } from "../core/context/Param.js";
4export interface PitchShiftOptions extends FeedbackEffectOptions {
5 pitch: Interval;
6 windowSize: Seconds;
7 delayTime: Time;
8}
9/**
10 * PitchShift does near-realtime pitch shifting to the incoming signal.
11 * The effect is achieved by speeding up or slowing down the delayTime
12 * of a DelayNode using a sawtooth wave.
13 * Algorithm found in [this pdf](http://dsp-book.narod.ru/soundproc.pdf).
14 * Additional reference by [Miller Pucket](http://msp.ucsd.edu/techniques/v0.11/book-html/node115.html).
15 * @category Effect
16 */
17export declare class PitchShift extends FeedbackEffect<PitchShiftOptions> {
18 readonly name: string;
19 /**
20 * The pitch signal
21 */
22 private _frequency;
23 /**
24 * Uses two DelayNodes to cover up the jump in the sawtooth wave.
25 */
26 private _delayA;
27 /**
28 * The first LFO.
29 */
30 private _lfoA;
31 /**
32 * The second DelayNode
33 */
34 private _delayB;
35 /**
36 * The second LFO.
37 */
38 private _lfoB;
39 /**
40 * Cross fade quickly between the two delay lines to cover up the jump in the sawtooth wave
41 */
42 private _crossFade;
43 /**
44 * LFO which alternates between the two delay lines to cover up the disparity in the
45 * sawtooth wave.
46 */
47 private _crossFadeLFO;
48 /**
49 * The delay node
50 */
51 private _feedbackDelay;
52 /**
53 * The amount of delay on the input signal
54 */
55 readonly delayTime: Param<"time">;
56 /**
57 * Hold the current pitch
58 */
59 private _pitch;
60 /**
61 * Hold the current windowSize
62 */
63 private _windowSize;
64 /**
65 * @param pitch The interval to transpose the incoming signal by.
66 */
67 constructor(pitch?: Interval);
68 constructor(options?: Partial<PitchShiftOptions>);
69 static getDefaults(): PitchShiftOptions;
70 /**
71 * Repitch the incoming signal by some interval (measured in semi-tones).
72 * @example
73 * const pitchShift = new Tone.PitchShift().toDestination();
74 * const osc = new Tone.Oscillator().connect(pitchShift).start().toDestination();
75 * pitchShift.pitch = -12; // down one octave
76 * pitchShift.pitch = 7; // up a fifth
77 */
78 get pitch(): number;
79 set pitch(interval: number);
80 /**
81 * The window size corresponds roughly to the sample length in a looping sampler.
82 * Smaller values are desirable for a less noticeable delay time of the pitch shifted
83 * signal, but larger values will result in smoother pitch shifting for larger intervals.
84 * A nominal range of 0.03 to 0.1 is recommended.
85 */
86 get windowSize(): Seconds;
87 set windowSize(size: Seconds);
88 dispose(): this;
89}