Skip to content

PitchSmoother state not reset on sample rate change #18

@user1303836

Description

@user1303836

Problem

When the host calls prepareToPlay (which happens on sample rate changes), PitchSmoother::prepare() (source/dsp/PitchSmoother.h:8-12) only updates sr and calls recomputeAlpha(). It does NOT reset hasValue or smoothed.

This means stale pitch data from a previous sample rate session persists. The smoother will start from whatever frequency it was tracking before the sample rate change, potentially causing a brief glitch or incorrect modulation frequency.

Note: PluginProcessor::prepareToPlay does reset hasValidPitch = false (line 72), but PitchSmoother's internal state remains stale.

Corroborated by: 3/8 audit agents (param-state, stability-edge, pitch-detection)

Suggested Fix

Add state reset to PitchSmoother::prepare():

void prepare(double sampleRate) {
    sr = static_cast<float>(sampleRate);
    hasValue = false;
    smoothed = 0.0f;
    recomputeAlpha();
}

Impact

  • Stability: Brief glitch/artifact on sample rate change
  • Severity: Medium -- sample rate changes are infrequent but should be handled correctly

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions