OK I think we have cracked this one. It is a classic case of an X-Y Problem. What you did NOT say was that you wanted to measure the frequency of a complex waveform. I suspect you want to make your own guitar tuner.I downloaded that app and recorder the note it produces, it is a very complex waveform that will give you a seemingly random number of frequencies. Consider these three pictures of exactly the same note plotted out at different scales. You will see it is composed of all sorts of random frequencies. Your code measures the time between zero crossings to work out the frequency. You will see that this changes almost randomly over the length of the note.The harmonic mix of the note changes over the duration of the note, the largest harmonic is not always the fundamental. Measuring this is way way way more complex than the software you have. In short you need an FFT to analyse your tone, and even then you are likely to be an octave out.
it's just sooooo strange.
I just switched entirely to using a trumpet
could the voltage of the 9v battery I'm using affect things? Like if it's dropped too much?
I've started to look into Paul's freqmeaure library again, and if I can't manage to figure this out I'm going to go ahead and order parts for that, it looks pretty solid.
The hardware isn't yet in a working condition.