Waveform independent frequency analysis
What you are asking about is typically called &quot;pitch detection&quot;. There are 100s of articles written on the topic. A good starter would be this one: https://ccrma.stanford.edu/~pdelac/154/m154paper.htm
If you need fairly high precision (for example a tuner application), I recommend a phase locked loop (PLL) or delay locked loop. There is a fundamental trade off between precision and tracking speed and with a PLL you can adjust this easily.