Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android AudioRecord which settings to record call

I use AudioRecord class to record the voice during a call.

I am intererested to record only the voice of the person who owns the phone ( from the microphone). During the recording I would like to do some audio processing but this is offtopic for now.

Android has the following AudioSources options:

  • MediaRecorder.AudioSource.VOICE_CALL
  • MediaRecorder.AudioSource.MIC
  • MediaRecorder.AudioSource.VOICE_UPLINK
  • MediaRecorder.AudioSource.VOICE_DOWNLINK

Can you explain what is the differences among them. Ok MIC is obvious but VOICE_CALL vs VOICE_UPLINK vs VOICE_DOWNLINK ?

Also I should choose a sample rate ( 8000Hz, 16000Hz, 2250Hz, 44100Hz ). Can you please tell me what sample rate to choose and why?

For audio format I chose AudioFormat.ENCODING_PCM_16BIT but it also has: - AudioFormat.ENCODING_DEFAULT - AudioFormat.ENCODING_INVALID - AudioFormat.ENCODING_PCM_8BIT

Finally is how many channels should I use and why? ( AudioFormat.CHANNEL_IN_STEREO or AudioFormat.CHANNEL_IN_MONO )

like image 572
gosom Avatar asked Apr 26 '12 09:04

gosom


People also ask

How can I record a call on my Android without them knowing?

If you have an Android phone, the Automatic Call Recorder by Appliqato is one of the best apps available in the Google Play Store for recording phone calls. Once installed, the app automatically records all outgoing and incoming phone calls without alerting the person you're recording.

Can I record a Phone call on my Samsung?

On your Android device, open the Phone app . Call recording. Under 'Always record', turn on Numbers not in your contacts. Tap Always record.


1 Answers

You should always aim to use 44100 as sample rate since it is the only sample rate that is guaranteed to work according to google.

"the sample rate expressed in Hertz. 44100Hz is currently the only rate that is guaranteed to work on all devices, but other rates such as 22050, 16000, and 11025 may work on some devices." Dev site

As for stereo versus mono, use mono.

"describes the configuration of the audio channels. See CHANNEL_IN_MONO and CHANNEL_IN_STEREO. CHANNEL_IN_MONO is guaranteed to work on all devices." Dev site

Finally: 8bit pcm vs 16bit pcm: Use 16bit pcm,

"Audio data format: PCM 16 bit per sample. Guaranteed to be supported by devices." Dev site

Just remember to use a short[] buffer instead of byte buffer when using 16bit. Since 16bit is 2 bytes you will have to combine two entries in the buffer at a time:

byte][]{sample_1_upper, sample_1_lower, sample_2_upper, sample_2_lower,...,sample_n_lower} However if you'll use a short[]buffer:
short[]{sample1, sample2, ..., sample3}

I've never tried to record a call, but if the OS doesn't bind the MIC source you could probably record from it. Since you're recording from the microphone you should only get the users voice.

like image 113
Risch Avatar answered Nov 15 '22 19:11

Risch