AudioFrequencyMeter for Arduino Mega?

I'd like to read in a frequency from a small electret microphone and I found this library and tutorial on how to do it:

but it only works on the Arduino Zero since it's built for the 'samd' architecture. Would anyone know how to convert the source files to work on an Arduino Mega which uses an 'avr' architecture? This tutorial seems like a really simple way to read an input frequency into an Arduino and it would be great to be able to use this circuit and code. If anyone knows any other good way to read a frequency from the MAX4466 electret microphone (Electret Microphone Amplifier - MAX4466 with Adjustable Gain : ID 1063 : $6.95 : Adafruit Industries, Unique & fun DIY electronics and kits) into an Arduino Mega, that would also be helpful. Sorry if this is a tall order, but any help would be appreciated!

What do you want to measure? Simple frequency measurements like that will only work on sin waves. For more complex waveforms like real instruments it is a lot harder. The problem is all the harmonics make the measurement of the fundamental frequency hard to spot.

Thanks for the reply! I'm just using the microphone to listen for and detect a certain frequency which will be used to signal for the Arduino to do other stuff upon hearing it played once. Would you know how to change some of those source files to work or even a good way to read a frequency into an Arduino Mega?

What are you listening to?
Do you know its harmonic content?
How unique is this sound? Is it important that other sounds could give a false trigger?

Measuring a simple electrical is simple. Detecting a specific audio sound is not.

It would just be listening to ambient noise while waiting for a high frequency to be played in close proximity to the microphone which gets played for about 5 seconds. Ideally, the other functions would be triggered after hearing this high frequency for about 2 seconds. It's a pretty unique sound that would just be used to kickoff a lot of other processing on the Arduino.

It's a pretty unique sound

It might be to you but to electronics it is just another waveform.

that would just be used to kickoff a lot of other processing on the Arduino.

Doesn't answer the question as to how important it is to you to miss this trigger or to get a false one.

It's vitally important that the trigger is not missed or falsely detected. I believe by design it will be roughly a 4 kHz tone played for 5 seconds from a close distance to the electret microphone.

I would use an LM567 tone decoding chip to do this.

Any system no matter what it is, is susceptible to false positive and negitave responses, that is just the way the world is.