Skip to content

Critical: Frequency detection algorithm not calculating correct frequency #27

@pbalduino

Description

@pbalduino

Description

The tuner's frequency detection algorithm is not correctly calculating the played frequency. Audio input is being captured and processed (confirmed by visible frequency updates and gauge movement), but the detected frequency does not match the actual input frequency.

Impact

  • Core tuning functionality is unreliable
  • Users cannot accurately tune their instruments
  • App shows incorrect frequency readings
  • Affects all instruments and tunings

Dependencies

Expected Behavior

When a known frequency is played:

  1. Audio input is captured ✓ (confirmed working)
  2. Frequency detection algorithm processes the signal
  3. Calculated frequency matches the input frequency ✗ (currently broken)
  4. Visual gauge and UI display the correct frequency and tuning state

Current Behavior

  • App shows "Listening..." status ✓
  • Frequencies are displayed on screen ✓
  • Gauge moves in response to audio ✓
  • Displayed frequency does NOT match the actual played frequency

Steps to Reproduce

  1. Open the app and grant microphone permissions
  2. Generate a known test frequency electronically (verified reference)
  3. Observe that the displayed frequency does not match the generated frequency
  4. Test with multiple known frequencies - all show incorrect values

Testing Method

Electronically generated test frequencies with known, precise values were used to isolate the issue and confirm that the frequency detection algorithm itself is calculating incorrectly (not a microphone or audio capture issue).

Investigation Areas

  • Frequency detection algorithm (likely in AudioProcessor or pitch detection module)
    • Check FFT implementation and configuration
    • Verify sample rate handling
    • Check windowing function
    • Verify bin selection and interpolation logic
  • Autocorrelation or YIN algorithm if used for pitch detection
  • Frequency smoothing implementation (Implement Frequency Smoothing #3) - may be over-smoothing or incorrectly averaging
  • Verify audio buffer size effects on frequency resolution
  • Check for off-by-one errors in frequency bin calculations
  • Verify correct sample rate is being used throughout the pipeline

Possible Root Causes

  • Incorrect FFT size or sample rate assumptions
  • Wrong frequency bin mapping
  • Faulty interpolation between bins
  • Buffer size mismatch affecting resolution
  • Integer overflow or floating-point precision issues

Environment

  • Device: [To be specified]
  • OS Version: Darwin 24.6.0
  • App Version: Latest from main branch (commit 14065f6)

Metadata

Metadata

Assignees

Labels

audioAudio processing related tasksbugSomething isn't workingcoreCore functionalitycriticalCritical bugs that block core functionalitymicrophoneMicrophone input relatedperformancePerformance optimization

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions