Read the pitch frequency of a audio clip

i need to be able to read the pitch of a song at runtime in unity, and to avoid confusion i dont mean audioClip.pitch or audioClip.frequency, because frequency is the same through out and pitch just changes the pitch of the clip not tell me the actual frequency, any help would be greatly appreciated

Pitch detection is not a trivial problem, since every polyphonic audio data has a whole spectrum of frequencies. The actual “pitch” is just the most significant frequency in it for the human mind.

This spectrum can be extracted with the FFT algoritms, which is a widely discussed and reasearched topic. Unity also has FFT solution, which I found fast enough for some real time work. You can simply use AudioSource.GetSpectrumData, but, as FadeToBlack mentioned, the spectral data will only give you the source material for actual pich detection algorithms (findign the fundamental frequency, etc) If you need some more info on the topic, please refer to the article on this page

to get actual pitch of sound playing at current time, you need to get sound data currently playing (using something like AudioSource.GetOutputData), then you need to learn what is Fast Fourier Transform, find & download some ready solutions around this. using FFT you can detect pitch of your sound (or even detect a note), but it also need to do some hard work. i think simply you need to find some ready solutions for sound analyzing for realtime. if you will not found ready solutions, then you can do some experiments with FFT. it gives you spectrum of your sound, you need to found maximum amplitude, it tells you approximated frequency.