Closed Sahara150 closed 3 years ago
You might be right, but I wouldn't know enough to improve the algorithm. If you think you can write a more accurate autocorrelate algorithm that's still fast enough, feel free to submit a pull request. The relevant code is in src/polywad.js
, line 40.
This probably happens, cause you take the biggest amplitude
If it's autocorrelation, amplitude shouldn't affect things too much, since it doesn't use the frequency domain to do detection. But, Autocorrelation detection methods can also get tripped up by complex wave forms with many inner-wave-patterns, likely the case for the voice.
I just recently found this repository and when I have some time in the coming weeks I'd like to try my hand at going in and implementing the YIN algorithm, which should be an even more accurate version of autocorrelation (that doesn't sacrifice speed). I also haven't inspected the current code yet, so maybe it's already using YIN lol but I'll poke around
When I e.g. sang an pure A (440 Hz) it tended to show 880 Hz from time to time. This probably happens, cause you take the biggest amplitude (just an assumption, didn´t go completely into your autocorrelate function). However the truly inputted frequency can also be recognized at the form of its higher frequency spectrum. (This way ambiguity errors could be prevented). Is mathematically kinda complex though.