-
Notifications
You must be signed in to change notification settings - Fork 53
Description
I wonder whether line 16 in amdf.js does what it is supposed to do:
const minPeriod = Math.round(sampleRate / maxFrequency + 0.5);
As I understand it, this expression calculates the ratio sampleRate / maxFrequency, hence the
amount of samples that would theoretically occur during one cycle of maxFrequency.
The rounding expression then basically truncates all digits right of the decimal point and adds 1.
For the calculation of maxPeriod this makes sense, since one doesn't want to miss a signal at minimum frequency, so the rounded maxPeriod should definitely not be smaller than the "floating-point" maxPeriod.
Doesn't that mean for minPeriod conversely, that it's rounded value should definitely not be greater than the fractional value?
Example: With sampleRate = 44100 and maxFrequency = 400, the ratio sampleRate/maxFrequency is 110,25.
According to the rounding mechanism in line 16 that would yield minPeriod = 111.
In my opinion this should yield 110.