0

I have written a code for getting frequency of audio.
I have used Zero Crossing algorithm to convert short array into frequency(int). It works fine.
Whenever I play 2500Hz Audio Frequency in my PC It gives me perfect value.
e.g. 2500Hz=1400
If I play 2500Hz Audio Frequency for 10sec it gives me 1400 for 10sec.
So I can say that it works fine without any problem. There is no any issue with code.

But Now My problem is that whenever I change Device the output also changed.
e.g above output I get when I use Samsung GT-i5700.(Android 2.2)
But When I use Micro-max A-60(Android 2.1) It gives me output like that 2500Hz=771.

I can't find the reason,why output is changed when device is changed?
How can I solve this?
Is there any connection between android version and audio frequency?
Note:
I have cable which gives output from PC speaker to Devices MIC. So I can play Tone in PC and send it directly to Device MIC.

Nirav
  • 5,700
  • 4
  • 34
  • 44
  • Maybe the sample rates are different on the two devices ? Note however that using zero crossings is a very unreliable way of measuring frequency - it only really works for pure tones (sinusoids) with zero noise. Adding hysteresis can help a little, but it's never going to be a great solution. – Paul R Jun 21 '11 at 06:48
  • please paste your code here, we want to see it in order ti help ypu, if you already has it please share it with us, please thanks VanPersie –  Sep 28 '11 at 21:30

2 Answers2

0

Using this implementation on Android, I have found that it rarely gets the correct frequency as well. However, it does produce a "consistent" value when it is hearing a tone versus random speech, which is still useful.

gregm
  • 12,019
  • 7
  • 56
  • 78
0

If the calculated frequency changes when you change handset then I would expect that your code is in fact NOT fine. Have you tried a third handset and observed if the results it gives match one of the previous 2 handsets?

If you are looking for potentially more accurate solutions (saying a 2500Hz tone outputs 1400 seems odd to me) look at How do you analyse the fundamental frequency of a PCM or WAV sample? for options.

Community
  • 1
  • 1
Femi
  • 64,273
  • 8
  • 118
  • 148