Reputation: 201
I'm developing an app that records audio input from the device's microphone(s). We'd like to record unprocessed/raw audio (i.e. with no effects applied like noise suppression or automatic gain control) and also give users the option to specify which microphone (e.g. top, front, back, etc.) to use for recording.
According to Android documentation, the only way to get an input audio stream that's guaranteed to be unprocessed is by selecting VOICE_RECOGNITION on setAudioSource()
That said, what would be the correct way to choose the physical microphone to use?
In more recent API levels, there are the following methods that seem to allow for the selection of specific microphones:
direction
constant that specifies the "logical microphone (for processing)". That "logical microphone" seems to map well to what I'm calling a microphone's position (front, back, etc.), but I'm not sure about how this method works in conjunction with setPreferredDevice()
.Does anybody know how to achieve my goals, i.e. get unprocessed audio input while also specifying the physical microphone to use?
Upvotes: 3
Views: 3062
Reputation: 1226
Starting API 29 you can use method AudioRecord.setPreferredMicrophoneDirection
including MicrophoneDirection.MIC_DIRECTION_EXTERNAL
.
Upvotes: 0
Reputation: 1281
The microphone selection is done with MediaRecorder.AudioSource.MIC (front) / MediaRecorder.AudioSource.CAMCORDER (back) / MediaRecorder.AudioSource.DEFAULT (default).
VOICE_RECOGNITION is used to enable/disable AGC but can only be used with the front microphone (MediaRecorder.AudioSource.MIC).
Upvotes: 1