cwilso / PitchDetect

Pitch detection in Web Audio using autocorrelation
https://cwilso.github.io/PitchDetect/
MIT License
1.3k stars 437 forks source link

A way to increase buffer size #16

Closed Maxime-J closed 8 years ago

Maxime-J commented 8 years ago

Hi,

I'm writing another pitch detection from microphone input and while I use another algorithm (YIN), I follow the same processing flow. (Extract buffer with getFloatTimeDomainData, process it and use requestAnimationFrame)

Now, if I want a buffer bigger than 2048 (for lower frequency detection as example):

So, what would be the perfect way to have a bigger buffer size?

cwilso commented 8 years ago

There isn't a perfect way, really - there are some subtleties. I would personally implement a round-robin buffer inside an AudioWorker, run your pitch detection algorithm there and pass back the pitch detected across the thread boundary every so often.

Keep in mind, by using a larger buffer size this is pretty much what you're having the system do anyway (collect smaller buffers and give them to you together).