Audio Frequency in Android
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.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.
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.
精彩评论