Android的AudioRecord其中设置记录通话 [英] Android AudioRecord which settings to record call

查看:191
本文介绍了Android的AudioRecord其中设置记录通话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用AudioRecord类在通话时录制的声音。

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

我intererested记录谁拥有手机(从麦克风)的人的唯一的声音。 在录制过程中,我想做些音频处理,但这是offtopic现在。

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有以下AudioSources选项:

Android has the following AudioSources options:

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

您可以解释一下什么是它们之间的差异。好吧MIC是明显的,但 VOICE_CALL VS VOICE_UPLINK VS VOICE_DOWNLINK?

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

另外,我应该选择的采样率(8000Hz的,16000,,2250Hz,44100Hz的)。能否请你告诉我什么采样率的选择,为什么?

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

有关音频格式我选择AudioFormat.ENCODING_PCM_16BIT 但它也有: - AudioFormat.ENCODING_DEFAULT - AudioFormat.ENCODING_INVALID - AudioFormat.ENCODING_PCM_8BIT

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

最后是我应该有多少个频道的使用,为什么? (AudioFormat.CHANNEL_IN_STEREO或AudioFormat.CHANNEL_IN_MONO)

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

推荐答案

您应该总是使用44100作为采样率,因为它是保证根据谷​​歌工作,唯一的采样率。

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.

pssed赫兹。44100Hz的采样率EX $ P $是目前国内唯一   这是保证在所有的设备率,但其他利率等   如22050,16000,11025和可能工作在某些设备上。<一href="http://developer.android.com/reference/android/media/AudioRecord.html#AudioRecord%28int,%20int,%20int,%20int,%20int%29">Dev网站

"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.

描述音频信道的配置。参见   CHANNEL_IN_MONO和CHANNEL_IN_STEREO。 CHANNEL_IN_MONO保证   能在所有设备上。<一href="http://developer.android.com/reference/android/media/AudioRecord.html#AudioRecord%28int,%20int,%20int,%20int,%20int%29">Dev网站

"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

最后:8位PCM VS 16bit的PCM: 使用16bit的PCM,

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

音频数据格式:可支持每个样本的PCM 16位的保证。   通过设备。开发网站

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

不过,别忘了使用短[]使用16位时,缓冲区,而不是字节的缓冲区。由于16位为2个字节,你将不得不结合两个项目在缓冲的时间:

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:

字节] [] {sample_1_upper,sample_1_lower,sample_2_upper,sample_2_lower,...,sample_n_lower} 但是,如果你会使用短[]缓冲区:
短[] {SAMPLE1,SAMPLE2,...,样本3}

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}

我从来没有试图录制通话内容,但如果操作系统不绑定MIC源,你也许可以从它记录。既然你从麦克风录制你应该只得到了用户的声音。

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.

这篇关于Android的AudioRecord其中设置记录通话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆