3
votes

I'm currently developing an audio processing software that must detect the frequency of the incoming signal by use of Zero Crossing estimation. It's not difficult to estimate the frequency when a perfect sin wave is the input, but when speaking about a piano, the soundwave is different and the theory behind this changes.

At the moment the software detects every zero and saves the index location between it and the previous one (to record how many samples have gone by).

The following is an array that contains the samples between each zero for a 130 Hz piano C note sampled at 44.1kHz.

44  11  36  65  56  12  37  66  52  13  38  67  51  11  39  68  50  11  47  60  49  11  48  61  47  14  47  66  43  13

The task is to determine an unknown pattern of an unknown length. But, these patterns might have an error margin. For example,

44, 11, 36, 65
56, 12, 37, 66
52, 13, 38, 67

are patterns. So, after processing the pattern's mean sums the frequency can be easily detected. How can I detect these type of patterns, knowing that the pattern, as is, and the length of it is unknown.

1
I would suggest that you don't use zero-crossing to estimate frequency... - Oliver Charlesworth
Reminds me of auto-correlation. Anyhow, you should be looking for Pitch Detection. - Alexey Frunze
The microprocessor in which is implemented cannot run a FFT in real-time, that's why I'm using the ZeroX approach @OliCharlesworth - facandiav
I'll give it a look @AlexeyFrunze, thanks - facandiav
Oh, if you can't do FFT, auto-correlation won't work, because FFT is the most efficient way of calculating it. I think your chances of succeeding with a weak CPU are pretty slim. - Alexey Frunze

1 Answers

1
votes

You should try low-passing your signal first. This will reduce the signal components, including higher overtones which are leading to extra zero crossings. The point here is to increase the strength of the fundamental relative to other harmonics, which are effectively just creating extraneous zero crossings.

For some hints on EQ:

http://blog.bjornroche.com/2012/08/basic-audio-eqs.html

and eq as it specifically pertains to pitch detection:

http://blog.bjornroche.com/2012/07/frequency-detection-using-fft-aka-pitch.html

Depending on your signal, you may need something steeper, like a higher order or different kind of filter.

Of course, zeroX pitch detection will be inherently limited, and a low-pass may not be sufficient.

Update: clarified that the purpose of the low pass is to emphasize the fundamental, not to eliminate noise.