# How do I create pitch detection?

**URL:** <https://qa.fmod.com/t/how-do-i-create-pitch-detection/21093>\
**Category:** FMOD Engine\
**Tags:** cpp\
**Created:** [January 12, 2024, 9:19pm UTC](https://qa.fmod.com/t/how-do-i-create-pitch-detection/21093 "2024-01-12T21:19:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![PooCluster](https://avatars.discourse-cdn.com/v4/letter/p/f17d59/32.png) [@PooCluster](https://qa.fmod.com/u/PooCluster)\
**Post date:** [January 12, 2024, 9:19pm UTC](https://qa.fmod.com/t/how-do-i-create-pitch-detection/21093/1 "2024-01-12T21:19:33Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![aishi1](https://avatars.discourse-cdn.com/v4/letter/a/c57346/32.png) [@aishi1](https://qa.fmod.com/u/aishi1)\
**Post date:** [January 13, 2024, 10:25pm UTC](https://qa.fmod.com/t/how-do-i-create-pitch-detection/21093/2 "2024-01-13T22:25:44Z")

</div>

Hello,

Wish I could give a more comprehensive answer, but looking into the built-in [FFT](https://www.fmod.com/docs/2.02/api/effects-reference.html#fft) dsp is a definitely good place to start. There are some functions in [FMOD::System](https://www.fmod.com/docs/2.02/api/core-api-system.html) 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.

---

<div class="post-metadata">

**Author:** ![Leah\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/leah_fmod/32/3685_2.png) [@Leah\_FMOD](https://qa.fmod.com/u/Leah_FMOD)\
**Post date:** [January 15, 2024, 3:34am UTC](https://qa.fmod.com/t/how-do-i-create-pitch-detection/21093/3 "2024-01-15T03:34:04Z")

</div>

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`](https://www.fmod.com/docs/2.02/api/core-api-channelcontrol.html#channelcontrol_adddsp), which will allow you to use [`DSP::getParameterFloat`](https://www.fmod.com/docs/2.02/api/core-api-dsp.html#dsp_getparameterfloat) to get the parameter [`FMOD_DSP_FFT_DOMINANT_FREQ`](https://www.fmod.com/docs/2.02/api/core-api-common-dsp-effects.html#fmod_dsp_fft_dominant_freq), which will provide you with the most dominant pitch of the signal.
