How do I create pitch detection?

Hello! For context, I’m using FMOD Core API in my C++ project.

It seems FMOD has microphone capabilities, but I honestly don’t know where to start. Basically, I want to detect/connect to a microphone, read real time input from it using a musical instrument, and detect the prominent frequency from the input.

I’m aware that instrument sounds also have harmonic overtones, so I could see that as potential noise for the main pitch determination.

Any pointers? How do I get started?

Hello,

Wish I could give a more comprehensive answer, but looking into the built-in FFT dsp is a definitely good place to start. There are some functions in FMOD::System for reading input drivers and recording to a sound. I haven’t messed with it yet, but I wonder if you could live stream the recorded FMOD::Sound into the FFT, or if there’s a better way to do that.

As far as simple pitch detection goes, the “record” Core API example included with the FMOD Engine provides an example of how to record microphone input and play it using an FMOD sound. Then, as @aishi1 has mentioned, you can make use of FMOD’s FFT DSP. Ater playing a sound on a channel, you can create an FFT DSP and add it to the channel/channel group with ChannelControl::addDSP, which will allow you to use DSP::getParameterFloat to get the parameter FMOD_DSP_FFT_DOMINANT_FREQ, which will provide you with the most dominant pitch of the signal.