Skip to main content
Version: 20 Mar 2024

NativeBindings

See ml_audio.h for additional comments.

Inherits from:
MagicLeapNativeBindings

Public Methods

MLResult.Code MLAudioGetMasterVolume

Gets the value of the master volume.

public MLResult.Code MLAudioGetMasterVolume(
out float volume
)

Parameters

TypeNameDescription
out floatvolumeThe value of the master volume.

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


MLResult.Code MLAudioGetOutputDevice

Gets the current audio output device.

public MLResult.Code MLAudioGetOutputDevice(
out MLAudioOutput.Device device
)

Parameters

TypeNameDescription
out MLAudioOutput.DevicedeviceThe audio output device.

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


MLResult.Code MLAudioGetSoundBypassesMasterVolume

Queries whether a sound output is exempt from attenuation due to master volume. This call reports whether the output from a sound output is bypassing master volume, making it effectively "always audible" (assuming it is neither muted nor set to zero volume on a per-sound basis). This option can only be set on medical-enabled devices(60601 compliant), and will only work for non-spatial sounds.Non-spatial sound parameters such as volume, mute, pitch and looping are still in effect for sounds that are bypassing master volume.

public MLResult.Code MLAudioGetSoundBypassesMasterVolume(
ulong audioHandle,
out bool isBypassing
)

Parameters

TypeNameDescription
ulongaudioHandle
out boolisBypassing

MLResult.Code MLAudioGetSpatialSoundEnable

Enables/disables 3D audio processing for a sound output.

public MLResult.Code MLAudioGetSpatialSoundEnable(
ulong handle,
out bool enabled
)

Parameters

TypeNameDescription
ulonghandleMLHandle used to identify the sound output.
out boolenabledIndicates whether 3D processing is on or off.

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.AudioHandleNotFound if handle was not found. MLResult.Result will be MLResult.Code.AudioInternalConfigError if internal config error. MLResult.Result will be MLResult.Code.NotImplemented .


MLResult.Code MLAudioGetSpatialSoundPosition

Returns the 3D position for one channel of a sound output.

public MLResult.Code MLAudioGetSpatialSoundPosition(
ulong handle,
uint channel,
out MagicLeapNativeBindings.MLVec3f position
)

Parameters

TypeNameDescription
ulonghandleMLHandle used to identify the sound output.
uintchannelSelects the channel whose position is being set.
out MagicLeapNativeBindings.MLVec3fpositionStruct to set the position

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.AudioHandleNotFound if handle was not found. MLResult.Result will be MLResult.Code.AudioInternalConfigError if internal config error. MLResult.Result will be MLResult.Code.NotImplemented .


delegate void MLAudioMasterVolumeChangedCallback

The callback that occurs when the master volume changes.

public delegate void MLAudioMasterVolumeChangedCallback(
float volume,
IntPtr callback
)

Parameters

TypeNameDescription
floatvolumeThe value of the master volume.
IntPtrcallbackA pointer to the callback.

delegate void MLAudioMediaEventCallback

Callback to notify when a media event has occurred.

public delegate void MLAudioMediaEventCallback(
MediaEvent mediaEvent,
IntPtr callback
)

Parameters

TypeNameDescription
MediaEventvolumeThe new media event.
IntPtrcallbackA pointer to the callback.

MLResult.Code MLAudioSetMasterVolumeCallback

Registers a callback for when the master volume changes.

public MLResult.Code MLAudioSetMasterVolumeCallback(
MLAudioMasterVolumeChangedCallback callback,
IntPtr data
)

Parameters

TypeNameDescription
MLAudioMasterVolumeChangedCallbackcallbackA 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.AllocFailed if failed due to internal error. MLResult.Result will be MLResult.Code.NotImplemented .


MLResult.Code MLAudioSetMediaEventCallback

Registers a callback for user-issued media control events. Events that can result in a callback being called include: pressing a play button; pressing a stop button; pressing a pause button; pressing a next track button, pressing a previous track button; The particular event type (MLAudioMediaEvent) that caused the callback is passed to the callback as its first argument. The 'context' argument is passed back to the callback as its second argument.

public MLResult.Code MLAudioSetMediaEventCallback(
MLAudioMediaEventCallback callback,
IntPtr context
)

Parameters

TypeNameDescription
MLAudioMediaEventCallbackcallback
IntPtrcontext

MLResult.Code MLAudioSetSoundBypassesMasterVolume

Setting this option on a sound output causes its output to bypass master volume, making it effectively "always audible" (assuming it is neither muted nor set to zero volume on a per-sound basis). This option can only be set on medical-enabled devices (60601 compliant), and will only work for non-spatial sounds.Non-spatial sound parameters such as volume, mute, pitch and looping are still in effect for sounds that are bypassing master volume.

public MLResult.Code MLAudioSetSoundBypassesMasterVolume(
ulong audioHandle,
bool isBypassing
)

Parameters

TypeNameDescription
ulongaudioHandle
boolisBypassing

MLResult.Code MLAudioSetSpatialSoundEnable

Enables/disables 3D audio processing for a sound output.

public MLResult.Code MLAudioSetSpatialSoundEnable(
ulong handle,
bool enable
)

Parameters

TypeNameDescription
ulonghandleMLHandle used to identify the sound output.
boolenableDetermines whether 3D processing is on or off.

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.AudioHandleNotFound if handle was not found. MLResult.Result will be MLResult.Code.AudioInternalConfigError if internal config error. MLResult.Result will be MLResult.Code.NotImplemented .


MLResult.Code MLAudioSetSpatialSoundPosition

Sets the 3D position for one channel of a sound output.

public MLResult.Code MLAudioSetSpatialSoundPosition(
ulong handle,
uint channel,
ref MagicLeapNativeBindings.MLVec3f position
)

Parameters

TypeNameDescription
ulonghandleMLHandle used to identify the sound output.
uintchannelSelects the channel whose position is being set.
ref MagicLeapNativeBindings.MLVec3fpositionStruct to set the position

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.AudioHandleNotFound if handle was not found. MLResult.Result will be MLResult.Code.AudioInternalConfigError if internal config error. MLResult.Result will be MLResult.Code.NotImplemented .