Audio input through headphone jack in Android?

前端 未结 1 1059
悲&欢浪女
悲&欢浪女 2021-02-08 17:47

I am trying to get audio input through the headphone jack 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 b

相关标签:
1条回答
  • 2021-02-08 17:55

    If you choose e.g. DEFAULT or MIC from MediaRecorder.AudioSource as the input then a TRRS plug attached to your phone will automatically be used as the input instead of the internal microphone.

    But you have two keep three things in mind:

    1) Number of channels

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

    2) Level

    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.

    3) Signal manipulation

    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.

    0 讨论(0)
提交回复
热议问题