I am running Android Emulator on OS X and trying to use AudioRecord to take a sample of audio and determine the frequency using an FFT jar (for a tuning app).
I am having difficulty with using the phone to debug (http://stackoverflow.com/questions/4425127/android-galaxy-s-phone-adb-debug-bridge-trouble-on-mac-osx) so I want to use the emulator.
When I take a sample of audio from the emulator it appears to contain random values. I would开发者_如何学JAVA assume that it's recording something, but I'm not sure if it's coming from my computer's microphone. Can anybody confirm what these values might be coming from and if it's possible to use the emulator to record.
I am initializing the AudioRecord object like this:
int frequency = 8000;
int channelConfiguration = AudioFormat.CHANNEL_CONFIGURATION_MONO;
int audioEncoding = AudioFormat.ENCODING_PCM_16BIT;
try {
// Create a new AudioRecord object to record the audio.
int bufferSize = AudioRecord.getMinBufferSize(frequency,channelConfiguration,audioEncoding);
AudioRecord audioRecord = new AudioRecord(MediaRecorder.AudioSource.MIC,
frequency, channelConfiguration,
audioEncoding, bufferSize);
...
From the android dev site: "The platform also lets you record audio and video, where supported by the mobile device hardware. To record audio or video, use the MediaRecorder class. Note that the emulator doesn't have hardware to capture audio or video, but actual mobile devices are likely to provide these capabilities, accessible through the MediaRecorder class. "
EDIT: It may actually be possible to record audio through the emulator. See this question: Can the Android emulator record and play back audio using pc hardware?
On OS X, I've found that recording audio with a sample rate of 44100 does not work in the Android emulator, but a sample rate of 16000 does work.
精彩评论