Skip to content

AudioStreamPlayer - pitch_scale introduces aliasing #116044

@yankscally

Description

@yankscally

Tested versions

all versions

System information

win10

Issue description

When using pitch_scale because of the way playback rate resampling works this can introduce audible aliasing artifacts

For example at a sample rate of 44100 the Nyquist frequency is 22050

When pitching audio upward spectral content is pushed beyond this allowed range of 22050 and without a proper band limiting filter these frequencies fold back (Nyquist reflection) into the audible range causing inharmonic distortion

Additionally the current use of linear interpolation for fractional sample positions introduces further waveform distortion generating harmonics even from simple signals like sine waves

A proper solution would require band limited resampling instead of linear interpolation.

In simple terms, adding a special filter before the resample step will fix this

Steps to reproduce

play a sine wave and loop it (runtime/editor doesnt matter)
modulate pitch_scale down to hear crunchy aliasing.
module it up to hear nasty aliasing

Minimal reproduction project (MRP)

n/a

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions