Bug: Incorrect Millisecond to Sample Conversion in waveFormDiff.ts
Summary
The window size calculation in src/audio/waveFormDiff.ts incorrectly converts milliseconds to samples by dividing the duration by 100 instead of 1000.
This results in the computed window size being 10 times larger than intended, affecting the accuracy of waveform comparison and any downstream processing that relies on the configured analysis window.
Affected File
src/audio/waveFormDiff.ts
Problem
Current implementation:
let windowSize = Math.floor((windowSizeMs / 100) * sampleRate);
The conversion from milliseconds to seconds is incorrect.
To convert milliseconds to seconds, the value must be divided by 1000, not 100.
Example
Given:
windowSizeMs = 50
sampleRate = 44,100 Hz
Current calculation:
Math.floor((50 / 100) * 44100)
Result:
This corresponds to approximately 500 ms, which is 10× larger than the requested window.
Expected calculation:
Math.floor((50 / 1000) * 44100)
Result:
This correctly represents a 50 ms analysis window.
Expected Behavior
The window size should accurately represent the configured duration in milliseconds by converting milliseconds to seconds before multiplying by the sample rate.
Suggested Fix
Replace:
let windowSize = Math.floor((windowSizeMs / 100) * sampleRate);
with:
let windowSize = Math.floor((windowSizeMs / 1000) * sampleRate);
Acceptance Criteria
Bug: Incorrect Millisecond to Sample Conversion in
waveFormDiff.tsSummary
The window size calculation in
src/audio/waveFormDiff.tsincorrectly converts milliseconds to samples by dividing the duration by100instead of1000.This results in the computed window size being 10 times larger than intended, affecting the accuracy of waveform comparison and any downstream processing that relies on the configured analysis window.
Affected File
Problem
Current implementation:
The conversion from milliseconds to seconds is incorrect.
To convert milliseconds to seconds, the value must be divided by 1000, not 100.
Example
Given:
windowSizeMs = 50sampleRate = 44,100 HzCurrent calculation:
Result:
This corresponds to approximately 500 ms, which is 10× larger than the requested window.
Expected calculation:
Result:
This correctly represents a 50 ms analysis window.
Expected Behavior
The window size should accurately represent the configured duration in milliseconds by converting milliseconds to seconds before multiplying by the sample rate.
Suggested Fix
Replace:
with:
Acceptance Criteria
100) with1000.50 mswindow at a44.1 kHzsample rate produces2,205samples.