Android 中通过耳机插孔输入音频?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24774483/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 08:44:09  来源:igfitidea点击:

Audio input through headphone Hyman in Android?

androidaudiosignal-processingaudio-recording

提问by ns89

I am trying to get audio input through the headphone Hyman for my final year project. It would be a great help if someone can share some code on how to capture the data. I have been trying but as I am fairly new to android, I couldn't find any API for headphone Hyman in MediaRecorder.AudioSource... There are only these sources available: http://developer.android.com/reference/android/media/MediaRecorder.AudioSource.html

我正在尝试通过耳机插孔为我最后一年的项目获取音频输入。如果有人可以分享一些关于如何捕获数据的代码,那将是一个很大的帮助。我一直在尝试,但由于我对 android 还很陌生,我在 MediaRecorder.AudioSource 中找不到任何耳机插孔的 API ......只有这些来源可用:http: //developer.android.com/reference/android /media/MediaRecorder.AudioSource.html

采纳答案by Hartmut Pfitzinger

If you choose e.g. DEFAULTor MICfrom MediaRecorder.AudioSourceas the input then a TRRS plug attached to your phone will automatically be used as the input instead of the internal microphone.

如果您选择 egDEFAULTMICfromMediaRecorder.AudioSource作为输入,那么连接到手机的 TRRS 插头将自动用作输入而不是内部麦克风。

But you have two keep three things in mind:

但是你有两个要记住三件事:

1) Number of channels

1)通道数

The TRRS plug has two lines for left and right channel of the headphone but only one line for the external microphone (see e.g. this description of the plug). So you can only do monophonic recordings (the only smartphone exception at the moment: the Sony Z2 has a new TRRRS plug). You can build an adapter on your own (see e.g. the pictures here).

TRRS 插头有两条线用于耳机的左右声道,但只有一条线用于外部麦克风(例如参见插头的说明)。所以你只能进行单声道录音(目前唯一的智能手机例外:索尼 Z2 有一个新的 TRRRS 插头)。您可以自己构建一个适配器(例如参见此处的图片)。

2) Level

2)级别

You can't connect the line-out of e.g. a CD player directly to the input. You need to use e.g. a resistive voltage divider to reduce the output level to avoid overload.

您不能将 CD 播放器等的线路输出直接连接到输入端。您需要使用例如电阻分压器来降低输出电平以避免过载。

3) Signal manipulation

3)信号操纵

Typically, there is smartphone-manufacturer-dependent fancy signal processing in the firmware like automatic gain control (AGC) and/or equalization, noise suppression, echo cancellation. You can't switch it off, so you don't get a perfect copy of your input signal.

通常,固件中有依赖于智能手机制造商的奇特信号处理,如自动增益控制 (AGC) 和/或均衡、噪声抑制、回声消除。您无法将其关闭,因此您无法获得输入信号的完美副本。