Added in API level 29

MicrophoneDirection


public interface MicrophoneDirection

android.media.MicrophoneDirection


Interface defining mechanism for controlling the directionality and field width of audio capture.

Summary

Constants

int MIC_DIRECTION_AWAY_FROM_USER

Optimize capture for audio coming from the side of the device pointing away from the user.

int MIC_DIRECTION_EXTERNAL

Optimize capture for audio coming from an off-device microphone.

int MIC_DIRECTION_TOWARDS_USER

Optimize capture for audio coming from the side of the device facing the user.

int MIC_DIRECTION_UNSPECIFIED

Don't do any directionality processing of the activated microphone(s).

Public methods

abstract boolean setPreferredMicrophoneDirection(int direction)

Specifies the logical microphone (for processing).

abstract boolean setPreferredMicrophoneFieldDimension(float zoom)

Specifies the zoom factor (i.e.

Constants

MIC_DIRECTION_AWAY_FROM_USER

Added in API level 29
public static final int MIC_DIRECTION_AWAY_FROM_USER

Optimize capture for audio coming from the side of the device pointing away from the user. In the typical case, a device with a single screen, screen-side camera/microphone and non-screen-side camera/microphone, this will be the non-screen side. For a different device geometry, it is the side for which the expectation is to be facing away from the user. This is the "taking a video of something else" case.

Constant Value: 2 (0x00000002)

MIC_DIRECTION_EXTERNAL

Added in API level 29
public static final int MIC_DIRECTION_EXTERNAL

Optimize capture for audio coming from an off-device microphone.

Constant Value: 3 (0x00000003)

MIC_DIRECTION_TOWARDS_USER

Added in API level 29
public static final int MIC_DIRECTION_TOWARDS_USER

Optimize capture for audio coming from the side of the device facing the user. In the typical case, a device with a single screen, screen-side camera/microphone and non-screen-side camera/microphone, this will be the screen side (as in a "selfie"). For a different device geometry, it is the side for which the expectation is to be facing the user.

Constant Value: 1 (0x00000001)

MIC_DIRECTION_UNSPECIFIED

Added in API level 29
public static final int MIC_DIRECTION_UNSPECIFIED

Don't do any directionality processing of the activated microphone(s).

Constant Value: 0 (0x00000000)

Public methods

setPreferredMicrophoneDirection

Added in API level 29
public abstract boolean setPreferredMicrophoneDirection (int direction)

Specifies the logical microphone (for processing). Applications can use this to specify which side of the device to optimize capture from. Typically used in conjunction with the camera capturing video. Usage would include specifying the audio capture to follow camera being used to capture video.

Parameters
direction int: Direction constant. Value is MIC_DIRECTION_UNSPECIFIED, MIC_DIRECTION_TOWARDS_USER, MIC_DIRECTION_AWAY_FROM_USER, or MIC_DIRECTION_EXTERNAL

Returns
boolean true if sucessful.

setPreferredMicrophoneFieldDimension

Added in API level 29
public abstract boolean setPreferredMicrophoneFieldDimension (float zoom)

Specifies the zoom factor (i.e. the field dimension) for the selected microphone (for processing). The selected microphone is determined by the use-case for the stream. Usage would include specifying the audio focus to follow the zoom specified for the camera being used to capture video.

Parameters
zoom float: the desired field dimension of microphone capture. Range is from -1 (wide angle), though 0 (no zoom) to 1 (maximum zoom). Value is between -1.0 and 1.0 inclusive

Returns
boolean true if sucessful.