p5.js-sound
p5.js-sound copied to clipboard
getEnergy() throws error with zero as first argument, but not for second, and not for negative numbers
The getEnergy() function throws an 'invalid input for getEnergy()' error if given zero as a first argument. I don't really know anything about the technicalities of how the FFT function works, but I guess since an error is being thrown that this is expected behaviour?
let e = fft.getEnergy(0, 140);
However, passing zero as the second argument and passing negative numbers do not throw an error.
Passing negative numbers seems to return NaN.
let e = fft.getEnergy(-20, 140);
Passing zero as second argument returns undefined
let e = fft.getEnergy(-20, 0);
It would be good to make the error throwing behaviour consistent and also to update the reference page to tell users that they should not pass zero as an argument to getEnergy(). I came across this because users in a class I teach tried it with getEnergy(0, 140) as arguments, which I think is a reasonable expectation.