Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can the Android emulator record and play back audio using pc hardware?

I don't have an android phone, but i'm trying to develop for it anyway. The only way to test my application at the moment is to use the emulator, which I've read does not support audio recording. However, I read about the startup command "-audio " which allows audio input/output from your pc using the 'winaudio' backend. I haven't been able to get it to work though, is it possible to record using my pc's microphone? If so, what am I doing wrong?

like image 872
Steve Avatar asked Mar 10 '11 03:03

Steve


People also ask

How to record audio from Android emulator?

I did not investigate the cause. You need to add audio recording + playback support to the emulator (Android SDK and AVD manager -> Virtual devices -> Edit -> Hardware -> New). Then use the [MediaRecorder API] [1] to record (MediaRecorder.AudioSource.MIC).

How do I record audio from a virtual device?

You need to add audio recording + playback support to the emulator (Android SDK and AVD manager -> Virtual devices -> Edit -> Hardware -> New). Then use the [MediaRecorder API] [1] to record (MediaRecorder.AudioSource.MIC).

Does mediarecorder work on Android emulator?

I gone through Android Documentation and its clearly mention MediaRecorder does not work on the emulator.Right Now i dont have android phone to test. YES, you can, just enable "Virtual microphone uses host audio input". Also, the app should ask for permission, you should allow it to use your audio.

Can you run Android emulators on a PC?

There are a lot of valid reasons why someone would want to run Android emulators on their PC. App developers may be trying to test their application before shipping it out. Gamers may want to use a mouse and keyboard on their games. Maybe you just want it there to have it.


2 Answers

Yes, it can. On Mac OSX, you must set the microphone on the emulator settings, after it's opened.

While the emulator is opened, on the right side bar (where the volume buttons are localized), click on the three dots (last button of the list) to open the emulator settings.

enter image description here

On the settings screen (called "Extended controls"), select Microphone and turn on the option "Virtual microphone uses host audio input".

enter image description here

like image 146
Bernardo do Amaral Teodosio Avatar answered Oct 11 '22 17:10

Bernardo do Amaral Teodosio


Recording audio is possible at least in the standard 2.3.3 emulator on Windows 7; I have tried it and it works. However, the recorded audio did sound a bit weird (slow) in my case. I did not investigate the cause.

You need to add audio recording + playback support to the emulator (Android SDK and AVD manager -> Virtual devices -> Edit -> Hardware -> New). Then use the [MediaRecorder API][1] to record (MediaRecorder.AudioSource.MIC).

Code is:

fMediaRecorder= new MediaRecorder();
fMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
fMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.AMR_NB);
fMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);

fMediaRecorder.setAudioChannels(1);
fMediaRecorder.setAudioSamplingRate(8000);

fMediaRecorder.setOutputFile(fTmpFile.getAbsolutePath());

fMediaRecorder.prepare();

fMediaRecorder.start();

You also need

<uses-permission android:name="android.permission.RECORD_AUDIO"/> 

in your AndroidManifest.xml

Works for me, but Audio IS distorted.

like image 28
Tom Avatar answered Oct 11 '22 16:10

Tom