Android, How to use microphone in order to calculate sound frequencies?

久未见 提交于 2019-12-03 07:55:02

问题


I'm working on Audio tuner application in order to tune musical instruments. User should play a note, then in my application I should show which frequency it has.

The first, I should access to microphone?

AudioRecord recorder = new AudioRecord(MediaRecorder.AudioSource.MIC,
sampleRate, AudioFormat.CHANNEL_IN_STEREO,
AudioFormat.ENCODING_PCM_16BIT, bufferSize);

Then I need to calculate frequency of sound. How can I do this?


回答1:


I'm also trying to do this. I haven't managed it myself yet, as I'm completely new to android development, but here are two useful links to the source code of other tuners, one in Java, one not:

  • http://www.psychicorigami.com/2009/01/17/a-5k-java-guitar-tuner/
  • http://www.codeproject.com/Articles/32172/FFT-Guitar-Tuner

EDIT: Thought I better link to the MANY alternatives on this site with people trying to make a guitar tuner.

  • How to create tuner that runs continuously?
  • Sound convertion to frequency in android
  • Real time pitch detection

RE-EDIT: FFT.java

Solved my problems. (Not linked properly because I'm a new user)




回答2:


You need to calculate the FFT. Maybe yu can try this link:

FFT

But you can find on internet many implementation of the algorithm for FFT.



来源:https://stackoverflow.com/questions/9044672/android-how-to-use-microphone-in-order-to-calculate-sound-frequencies

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!