A way to increase buffer size
Closed this issue · 1 comments
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):
- I can't use the AnalyserNode because the fftsize is limited to 2048.
- I can use a ScriptProcessorNode with getChannelData (even if it's not really convenient because I don't control the execution and multiple onaudioprocess are added to queue) but it's now deprecated in favor of AudioWorkerNode where it seems we can't have fixed buffer size.
So, what would be the perfect way to have a bigger buffer size?
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).