Change Android Audio Record Default input Source

一笑奈何 提交于 2019-12-23 10:19:55

问题


I am currently writing an app that calls for the recording and real time processing of audio data. For this, I am using the AudioRecord class. This works all well and good, except the default setting for recording audio on my primary testing device, a galaxy nexus, is to record from the back speaker. I am assuming most phones default record source will be the back, or bottom microphones, because when you are using the phone to call, your mouth is near the bottom.

However, my app requires that I record from the speaker on the front of the phone, and so I was hoping someone could help me with how to change the AudioRecord input source programmatically. I have searched extensively for the answer to this.

Some things I have considered are:

  • Using the AudioManager Class and turning on the speaker phone, such as:
    AudioManager am = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
    am.setSpeakerphoneOn(true);

  • Changing the AudioSource parameter in the construction of my AudioRecord object:
    AudioRecord ar = new AudioRecord(AudioSource.????, ..., ..., ..., ...);

  • I have found that the API's are not too specific about which AudioSource formats are which, so I was wondering if anyone else has struggled with this issue and could point me in the right direction.

    Thanks in advance,


    回答1:


    Android does not currently support call recording, so I believe you can't change it to record from the earpiece. You shouldn't really need to however, the Mic at the bottom of the phone should be able to record things to the full capacity you need. To set the AudioRecord to the mic, just do:

    AudioRecord ar = new AudioRecord(AudioSource.MIC, ..., ..., ..., ...);
    

    This will give you the best recording quality.



    来源:https://stackoverflow.com/questions/10360512/change-android-audio-record-default-input-source

    易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
    该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!