Skip to content

PitchSmoother should operate in log-frequency domain #19

@user1303836

Description

@user1303836

Problem

PitchSmoother::process() (source/dsp/PitchSmoother.h:37) applies exponential smoothing in linear frequency space: smoothed += alpha * (detectedFreq - smoothed).

Musical pitch perception is logarithmic. A jump from 100Hz to 200Hz (one octave) and 1000Hz to 2000Hz (also one octave) are treated as having 10x different magnitude by the linear smoother. This makes smoothing feel inconsistent -- sluggish at low frequencies, twitchy at high frequencies.

Corroborated by: 3/8 audit agents (dsp-algorithm, ring-mod-research, pitch-detection)

Suggested Fix

Smooth in log-frequency space:

float process(float detectedFreq, float confidence) {
    if (confidence < sensitivityThreshold)
        return hasValue ? std::exp2(smoothed) : 0.0f;
    float logFreq = std::log2(detectedFreq);
    if (!hasValue) {
        smoothed = logFreq;
        hasValue = true;
    } else {
        smoothed += alpha * (logFreq - smoothed);
    }
    return std::exp2(smoothed);
}

Impact

  • Audio quality: Perceptually uniform smoothing across the guitar's frequency range
  • Severity: Medium -- noticeable improvement at high smoothing values

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions