I have a problem which might be an FMOD getSpectrum() and/or a signal processing understanding issue on my part. Put simply, my problem is that channel->getSpectrum() does not seem to return correct values for inputs of high frequencies.
So I have a big application in which one of the steps is to get the highest peak (=frequency bin with the highest amplitude) at this moment, in the spectrum of the currently running sample.
In order to do this, I get spectrum snapshots of the playing sound every 100ms:
[code:arphniio]getSpectrum(spectrum, 64, 0, FMOD_DSP_FFT_WINDOW_RECT)[/code:arphniio]
and, when asked, I compute the frequency bin with the highest amplitude by searching for the max in the spectrum vector.
I have generated in Matlab some sample .wav files with sine tones of varying frequencies — 500Hz, 1000Hz, 1500Hz, etc. Up to a certain frequency (around 4000 Hz), I get appropriate responses — the max amplitude bin is close to the input frequency.
However, when I use as input sine tones with frequencies higher than ~4000Hz, I get seemingly random results.
Does anybody have an idea how this might be explained? (Should I use another type of window, perhaps?)
- acgrama asked 6 years ago
Could someone please at least test this and/or let me know if I’m doing something incredibly wrong here? I can of course provide the sample .wav files with sine tones at various frequencies. Thank you in advance!
I cannot believe this is how getSpectrum() is supposed to work…
Ok, so I have tested with FMOD’s own [b:34j40lvb]pitchdetection[/b:34j40lvb] example and, even though the range of frequencies it is supposed to cover goes to around 15800Hz, I get the same behaviour like I did with my app: putting on the input a wav file with sine tone of frequency lower than 4000Hz gives me correct note and frequency identification, whereas over 4000Hz the results are wrong.
Did I miss the point of this example, perhaps?
Thanks a lot, that was the problem! The sampling theorem is etched into my mind forever now 😀
(In the unlikely case someone else does the same stupidity I have, here’s the explanation of my problem: I usually use 44.1kHz as sampling rate, but for some reason my settings had reverted to the default 8000Hz. Judging by my meager knowledge of signal processing, I guess this fits with the problems starting at 4000=8000/2)
Please login first to submit.