Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Android Emulator pick up audio?

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 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);
 ...
like image 564
chaimp Avatar asked Dec 13 '10 02:12

chaimp


2 Answers

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?

like image 67
Pure Function Avatar answered Sep 30 '22 01:09

Pure Function


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.

like image 23
srubin Avatar answered Sep 30 '22 01:09

srubin