pitch_shift
pitch_shift(
y,sr,n_steps,options?):Float32Array<ArrayBufferLike>
Defined in: packages/pleco-xa/src/effects/index.js:428
Shift the pitch of a waveform by n_steps steps (duration preserved). Recipe: rate = 2^(-n_steps/bins_per_octave); resample(time_stretch(y, rate), sr/rate → sr); fix_length to the input size.
QUALITY NOTE: the resampling stage uses pleco’s linear-interpolation resample (xa-audioio.js) — no high-quality anti-aliasing filter. Downward shifts (upsampling) are clean; upward shifts can alias above ~sr/(2*rate). This is a documented fidelity limit of the current resampler, not a silent fallback.
Parameters
Section titled “Parameters”Float32Array<ArrayBufferLike>
Audio signal
number
Sample rate of y
n_steps
Section titled “n_steps”number
Steps to shift (may be fractional; 12 steps = 1 octave by default)
options?
Section titled “options?”bins_per_octave?
Section titled “bins_per_octave?”number = 12
Positive integer
n_fft?
Section titled “n_fft?”number
And the other time_stretch STFT options
Returns
Section titled “Returns”Float32Array<ArrayBufferLike>
Pitch-shifted audio, same length as y
Throws
Section titled “Throws”When bins_per_octave is not a positive integer