The software algorithm commonly usually used for frequency detection is called the Fast Fourier Transform (FFT). I would guess that its been implemented on the Arduino by someone, have a good look on google to see if you can find some code that you can use.