I am working on note-recognition code for my cello, and I am currently using FMOD’s getSpectrum function as the basis. However, getSpectrum is quite limited: even at the highest precision, a single frequency bin is still 2.9hz wide, while the lowest cello notes are only 3.9hz apart. To reach this precision, I need to use 8192 samples, which on a samplerate of 48000 means that the spectrum is the average of a time period of 0.17s. For fast note detection and for detecting quick notes (which are around 0.1s each), that is just not good enough.
So I am wondering: are there ways to do better than this? I assume getSpectrum uses an FFT algorithm. I am willing to spend a lot of processing power just on getting a better real-time spectrum (a whole CPU core, if needed). Are there other algorithms that would get me a more precise spectrum from a smaller number of samples?
Thanks in advance!
- Oogst asked 6 years ago
I’ve asked around with some math specialists and what they have told me, is that Fast Fourier Transform is actually the best one can do. The "Fast" in the name refers to that it runs in O(n*log(n)) or something like that, instead of the O(n^2) of previous algorithms. The "Fast" does not refer to an approximation or decrease in output quality or something like that.
That would mean I could not do any better. However, I am also noticing serious input and output lag in music composition programs like Cubase, so I think I might seriously decrease the detection delay in my algorithm by buying a good external soundcard for my computer.
- Oogst answered 5 years ago
Yes fmod uses an FFT. You could probably do better yourself than fmod’s simple implementation. The complex number representation is not exposed and we massage the numbers to get them into 0-1 range. You could use a simple DSP callback to analyze the PCM data flowing through fmod – and use FFTW or something to try and get data that fits your needs better.
Please login first to submit.