Skip to main content
Version: 12 Dec 2024

NativeBindings

See ml_audio.h for additional comments.

Inherits from:
MagicLeapNativeBindings

Public Methods

MLResult.Code MLAudioCreateInputFromMicCapture

Creates a new sound input that provides audio from the mics on the wearable.

public MLResult.Code MLAudioCreateInputFromMicCapture(
MicCaptureType captureType,
in MLAudioOutput.NativeBindings.MLAudioBufferFormat format,
uint bufferSizeInBytes,
MLAudioOnBufferDelegate callback,
IntPtr context,
out ulong handle
)

Parameters

TypeNameDescription
MicCaptureTypecaptureTypeSpecifies the type of mic capture created.
in MLAudioOutput.NativeBindings.MLAudioBufferFormatformatMLAudioBufferFormat specifying the audio format of the stream.
uintbufferSizeInBytesRequested size in bytes for each of the two stream buffers.
MLAudioOnBufferDelegatecallbackFunction to use for callback.
IntPtrcontextA generic data pointer passed back to the callback.
out ulonghandleHandle used in subsequent calls for this sound input.

Returns: MLResult.Result will be MLResult.AllocFailed due to memory allocation failure. MLResult.Result will be MLResult.InvalidParam due to an invalid parameter. MLResult.Result will be MLResult.Ok Successfully created new sound input that provides a mic capture stream. MLResult.Result will be MLResult.PermissionDenied due to lack of permission. MLResult.Result will be MLResult.UnspecifiedFailure due to an unknown error. MLResult.Result will be MLAudioResult.InternalConfigError due to an internal configuration error. MLResult.Result will be MLAudioResult.InvalidBitsPerSample due to an invalid bits per sample. MLResult.Result will be MLAudioResult.InvalidBufferSize due to an invalid buffer size. MLResult.Result will be MLAudioResult.InvalidChannelCount due to an invalid channel count. MLResult.Result will be MLAudioResult.InvalidSampleFormat due to an invalid sample format. MLResult.Result will be MLAudioResult.InvalidSampleRate due to an invalid sample rate. MLResult.Result will be MLAudioResult.InvalidValidBits due to an invalid valid bits per sample. MLResult.Result will be MLAudioResult.NotImplemented because feature has not been implemented yet.


MLResult.Code MLAudioGetBufferedInputDefaults

Returns the preferred (i.e. best performing) settings for buffered input.

public MLResult.Code MLAudioGetBufferedInputDefaults(
uint channelCount,
uint samplesPerSecond,
out MLAudioOutput.NativeBindings.MLAudioBufferFormat format,
out uint recommendedSizeInBytes,
out uint minimumSizeInBytes
)

Parameters

TypeNameDescription
uintchannelCountNumber of audio channels (e.g. 2 for stereo).
uintsamplesPerSecondSample rate for the buffered input.
out MLAudioOutput.NativeBindings.MLAudioBufferFormatformatRecommended Settings for MLAudioBufferFormat.
out uintrecommendedSizeInBytesRecommended size for the buffers.
out uintminimumSizeInBytesMinimum allowable size for the buffers.

Returns: MLResult.Result will be MLResult.AllocFailed due to memory allocation failure. MLResult.Result will be MLResult.InvalidParam due to an invalid parameter. MLResult.Result will be MLResult.Ok Successfully created new sound input that provides a "mixed capture" stream. MLResult.Result will be MLResult.PermissionDenied due to lack of permission. MLResult.Result will be MLResult.UnspecifiedFailure due to an unknown error. MLResult.Result will be MLAudioResult.InternalConfigError due to an internal configuration error. MLResult.Result will be MLAudioResult.InvalidBitsPerSample due to an invalid bits per sample. MLResult.Result will be MLAudioResult.InvalidBufferSize due to an invalid buffer size. MLResult.Result will be MLAudioResult.InvalidChannelCount due to an invalid channel count. MLResult.Result will be MLAudioResult.InvalidSampleFormat due to an invalid sample format. MLResult.Result will be MLAudioResult.InvalidSampleRate due to an invalid sample rate. MLResult.Result will be MLAudioResult.InvalidValidBits due to an invalid valid bits per sample. MLResult.Result will be MLAudioResult.NotImplemented because feature has not been implemented yet.


MLResult.Code MLAudioGetInputBuffer

Returns a full buffer containing captured audio data.

public MLResult.Code MLAudioGetInputBuffer(
ulong handle,
out MLAudioOutput.NativeBindings.MLAudioBuffer buffer
)

Parameters

TypeNameDescription
ulonghandleUsed to identify the sound input.
out MLAudioOutput.NativeBindings.MLAudioBufferbufferContains the buffer to read from.

Returns: MLResult.Result will be MLResult.InvalidParam due to an invalid parameter. MLResult.Result will be MLResult.Ok Successfully returned full buffer containing captured audio data. MLResult.Result will be MLResult.UnspecifiedFailure due to an unknown error. MLResult.Result will be MLResult.AudioBufferNotReady because buffer was not ready. MLResult.Result will be MLResult.AudioHandleNotFound due to a missing handle. MLResult.Result will be MLResult.AudioInternalConfigError due to an internal configurations error. MLResult.Result will be MLResult.NotImplemented because feature has not been implemented yet. MLResult.Result will be MLResult.OperationUnavailable because operation is unavailable.


MLResult.Code MLAudioGetMicMute

Gets the mute state of the microphone.

public MLResult.Code MLAudioGetMicMute(
out bool isMuted
)

Parameters

TypeNameDescription
out boolisMutedThe mute state of the microphone.

Returns: MLResult.Result will be MLResult.Code.Ok if successful. MLResult.Result will be MLResult.Code.UnspecifiedFailure if failed due to internal error. MLResult.Result will be MLResult.Code.InvalidParam if input parameter is invalid. MLResult.Result will be MLResult.Code.PermissionDenied if AudioCaptureMic permission is denied. MLResult.Result will be MLResult.Code.AllocFailed if failed due to internal error. MLResult.Result will be MLResult.Code.NotImplemented .


IntPtr MLAudioGetResultString

Gets the result string for a MLResult.Code.

public IntPtr MLAudioGetResultString(
MLResult.Code result
)

Parameters

TypeNameDescription
MLResult.CoderesultThe MLResult.Code to be requested.

Returns: A pointer to the result string.


delegate void MLAudioMicMuteCallback

The callback that occurs when the mute state changes for the microphone.

public delegate void MLAudioMicMuteCallback(
bool muted,
IntPtr callback
)

Parameters

TypeNameDescription
boolmutedThe mute state of the microphone.
IntPtrcallbackA pointer to the callback.

delegate void MLAudioOnBufferDelegate

The callback that occurs when an input buffer is available.

public delegate void MLAudioOnBufferDelegate(
ulong handle,
IntPtr context
)

Parameters

TypeNameDescription
ulonghandleHandle used to identify the sound input.
IntPtrcallbackA pointer to the callback.

MLResult.Code MLAudioReleaseInputBuffer

Releases a buffer once it has been read.

public MLResult.Code MLAudioReleaseInputBuffer(
ulong handle
)

Parameters

TypeNameDescription
ulonghandleUsed to identify the sound input.

Returns: MLResult.Result will be MLResult.Ok Successfully released buffer. MLResult.Result will be MLResult.UnspecifiedFailure due to an unknown error. MLResult.Result will be MLResult.AudioBufferNotReady because buffer was not ready. MLResult.Result will be MLResult.AudioHandleNotFound due to a missing handle. MLResult.Result will be MLResult.AudioInternalConfigError due to an internal configurations error. MLResult.Result will be MLResult.NotImplemented because feature has not been implemented yet. MLResult.Result will be MLResult.OperationUnavailable because operation is unavailable.


MLResult.Code MLAudioSetMicMute

Sets the mute state of the microphone.

public MLResult.Code MLAudioSetMicMute(
bool muted
)

Parameters

TypeNameDescription
boolmutedThe mute state of the microphone.

Returns: MLResult.Result will be MLResult.Code.Ok if successful. MLResult.Result will be MLResult.Code.UnspecifiedFailure if failed due to internal error. MLResult.Result will be MLResult.Code.PermissionDenied if AudioCaptureMic permission is denied. MLResult.Result will be MLResult.Code.NotImplemented .


MLResult.Code MLAudioSetMicMuteCallback

Register a callback for when the mute state changes for the microphone.

public MLResult.Code MLAudioSetMicMuteCallback(
MLAudioMicMuteCallback callback,
IntPtr data
)

Parameters

TypeNameDescription
MLAudioMicMuteCallbackcallbackA pointer to the callback.
IntPtrdataA generic data pointer passed back to the callback.

Returns: MLResult.Result will be MLResult.Code.Ok if successful. MLResult.Result will be MLResult.Code.UnspecifiedFailure if failed due to internal error. MLResult.Result will be MLResult.Code.PermissionDenied if AudioCaptureMic permission is denied. MLResult.Result will be MLResult.Code.AllocFailed if failed due to internal error. MLResult.Result will be MLResult.Code.NotImplemented .


MLResult.Code MLAudioStartInput

Starts capture for a sound input.

public MLResult.Code MLAudioStartInput(
ulong handle
)

Parameters

TypeNameDescription
ulonghandleUsed to identify the sound input.

Returns: MLResult.Result will be MLResult.Ok Successfully started capture for sound input. MLResult.Result will be MLResult.PermissionDenied due to lack of permission. MLResult.Result will be MLResult.UnspecifiedFailure due to an unknown error. MLResult.Result will be MLResult.AudioHandleNotFound due to a missing handle. MLResult.Result will be MLResult.NotImplemented because feature has not been implemented yet.


MLResult.Code MLAudioStopInput

Stops capture for a sound input.

public MLResult.Code MLAudioStopInput(
ulong handle
)

Parameters

TypeNameDescription
ulonghandleUsed to identify the sound input.

Returns: MLResult.Result will be MLResult.Ok Successfully stopped capture for sound input. MLResult.Result will be MLResult.PermissionDenied due to lack of permission. MLResult.Result will be MLResult.UnspecifiedFailure due to an unknown error. MLResult.Result will be MLResult.AudioHandleNotFound due to a missing handle. MLResult.Result will be MLResult.NotImplemented because feature has not been implemented yet.