问题
Possible Duplicate:
Real time pitch detection
Determine the audio frequency of sound received via the microphone
I'm developing my own android guitar tuner. Here I will have to use the guitar note frequency. Therefore, I want to know how to convert the sound coming through the mic port into its frequency in android?
回答1:
EDIT: link dead ---This problem is already solved here---
I shall summarize the paper :
Record stuff :
int minSize = AudioRecord.getMinBufferSize(sampleRate,AudioFormat. CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_16BIT); AudioRecord audioInput = new AudioRecord(MediaRecorder.AudioSource.MIC, sampleRate, AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_16BIT); minSize); ... short[] buffer = new short[readSize]; audioInput.startRecording(); audioInput.read(buffer, index, readSize); // record data from mic into bufferAnayze the frequency using FFT.
I'd say you record about 4 seconds of apply FFT on it. Like hotpaw2 says you have to use pitch estimation algorithms to determine the range of frequencies in recorded sound from the strum.
回答2:
You will need a pitch estimation algorithm (there have been many published, such as autocorrelation, ASDF/AMDF, cepstral processing, harmonic product spectrum, RAPT, YAAPT, etc.). Frequency estimation alone is not suitable for guitar tuning, as note pitch is different from spectral frequency.
来源:https://stackoverflow.com/questions/8928695/sound-convertion-to-frequency-in-android