Skip to content

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.

Float32Array<ArrayBufferLike>

Audio signal

number

Sample rate of y

number

Steps to shift (may be fractional; 12 steps = 1 octave by default)

number = 12

Positive integer

number

And the other time_stretch STFT options

Float32Array<ArrayBufferLike>

Pitch-shifted audio, same length as y

When bins_per_octave is not a positive integer