Skip to main content
Version: 20 Mar 2024

Parameters

Module: Audio / Audio Definitions / Audio Output

More...

Functions

Name
MLResultMLAudioSetSoundVolumeLinear(MLHandle handle, float volume)
Sets the volume of a sound output using a linear scale.
MLResultMLAudioGetSoundVolumeLinear(MLHandle handle, float * out_volume)
Queries the volume of a sound output in a linear scale.
MLResultMLAudioSetSoundVolumeDb(MLHandle handle, float volume)
Sets the volume of a sound output using a decibel scale.
MLResultMLAudioGetSoundVolumeDb(MLHandle handle, float * out_volume)
Queries the volume of a sound output using a decibel scale.
MLResultMLAudioSetSoundPitch(MLHandle handle, float pitch)
Sets the pitch of a sound output by modifying its playback speed.
MLResultMLAudioGetSoundPitch(MLHandle handle, float * out_pitch)
Queries the pitch of a sound output which corresponds to its playback speed.
MLResultMLAudioSetSoundMute(MLHandle handle, bool is_muted)
Sets the mute state of a sound output.
MLResultMLAudioGetSoundMute(MLHandle handle, bool * out_is_muted)
Queries the mute state of a sound output.
MLResultMLAudioSetSoundBypassesMasterVolume(MLHandle handle, bool is_bypassing)
Sets whether a sound output is exempt from attenuation due to master volume.
MLResultMLAudioGetSoundBypassesMasterVolume(MLHandle handle, bool * out_is_bypassing)
Queries whether a sound output is exempt from attenuation due to master volume.
MLResultMLAudioSetSoundLooping(MLHandle handle, bool is_looping)
Sets whether a sound output is looping or not.
MLResultMLAudioGetSoundLooping(MLHandle handle, bool * out_is_looping)
Queries whether a sound output is looping or not.
MLResultMLAudioSetStreamedFileOffset(MLHandle handle, uint32_t offset_in_msec)
Sets the playback position of a sound output that's playing a Streamed File.
MLResultMLAudioGetStreamedFileOffset(MLHandle handle, uint32_t * out_offset_in_msec)
Queries the playback position of a sound output that's playing a Streamed File.
MLResultMLAudioGetOutputDevice(MLAudioOutputDevice * out_current_device)
Queries which type of sound output device is being used for sound output.
MLResultMLAudioSetOutputDeviceCallback(MLAudioOutputDeviceChangedCallback callback, void * context)
Registers a callback for when the active audio hardware output has changed.

Detailed Description

PARAMETERS.


Functions Documentation

MLAudioSetSoundVolumeLinear

MLResult MLAudioSetSoundVolumeLinear(
MLHandle handle,
float volume
)

Sets the volume of a sound output using a linear scale.

Parameters

MLHandlehandleMLHandle of the sound output.
floatvolumeThe linear volume that the sound output will be set to.

Returns

MLResultMLResult_InvalidParamFailed due to an invalid parameter.
MLResultMLResult_OkSuccessfully set the value.
MLResultMLResult_UnspecifiedFailureFailed due to an unknown error.
MLResultMLAudioResult_HandleNotFoundFailed due to a missing handle.
MLResultMLAudioResult_InternalConfigErrorFailed due to an internal configuration error.
MLResultMLAudioResult_NotImplementedFailed because feature has not been implemented yet.

Required Permissions:

  • None

The range of valid values is from 0 to 8. A value of 0 indicates silence. A value of 1 indicates unity gain. A maximum value of 8 indicates 8x unity gain (+18 dB).


MLAudioGetSoundVolumeLinear

MLResult MLAudioGetSoundVolumeLinear(
MLHandle handle,
float * out_volume
)

Queries the volume of a sound output in a linear scale.

Parameters

MLHandlehandleMLHandle of the sound output.
float *out_volumeRetrieved linear volume of the sound output.

Returns

MLResultMLResult_InvalidParamFailed due to an invalid parameter.
MLResultMLResult_OkSuccessfully retrieved the value.
MLResultMLResult_UnspecifiedFailureFailed due to an unknown error.
MLResultMLAudioResult_HandleNotFoundFailed due to a missing handle.
MLResultMLAudioResult_InternalConfigErrorFailed due to an internal configuration error.
MLResultMLAudioResult_NotImplementedFailed because feature has not been implemented yet.

Required Permissions:

  • None

The range of valid values is from 0 to 8. A value of 0 indicates silence. A value of 1 indicates unity gain. A maximum value of 8 indicates 8x unity gain (+18 dB).


MLAudioSetSoundVolumeDb

MLResult MLAudioSetSoundVolumeDb(
MLHandle handle,
float volume
)

Sets the volume of a sound output using a decibel scale.

Parameters

MLHandlehandleMLHandle of the sound output.
floatvolumeThe dB volume that the sound output will be set to.

Returns

MLResultMLResult_InvalidParamFailed due to an invalid parameter.
MLResultMLResult_OkSuccessfully set the value.
MLResultMLResult_UnspecifiedFailureFailed due to an unknown error.
MLResultMLAudioResult_HandleNotFoundFailed due to a missing handle.
MLResultMLAudioResult_InternalConfigErrorFailed due to an internal configuration error.
MLResultMLAudioResult_NotImplementedFailed because feature has not been implemented yet.

Required Permissions:

  • None

The range of valid values is from -100 dB to +18 dB. A value of -100 dB indicates silence. A value of 0 dB indicates unity gain. A maximum value of 18 dB indicates 8x unity gain.


MLAudioGetSoundVolumeDb

MLResult MLAudioGetSoundVolumeDb(
MLHandle handle,
float * out_volume
)

Queries the volume of a sound output using a decibel scale.

Parameters

MLHandlehandleMLHandle of the sound output.
float *out_volumeRetrieved dB volume of the sound output.

Returns

MLResultMLResult_InvalidParamFailed due to an invalid parameter.
MLResultMLResult_OkSuccessfully retrieved the value.
MLResultMLResult_UnspecifiedFailureFailed due to an unknown error.
MLResultMLAudioResult_HandleNotFoundFailed due to a missing handle.
MLResultMLAudioResult_InternalConfigErrorFailed due to an internal configuration error.
MLResultMLAudioResult_NotImplementedFailed because feature has not been implemented yet.

Required Permissions:

  • None

The range of valid values is from -100 dB to +18 dB. A value of -100 dB indicates silence. A value of 0 dB indicates unity gain. A maximum value of 18 dB indicates 8x unity gain.


MLAudioSetSoundPitch

MLResult MLAudioSetSoundPitch(
MLHandle handle,
float pitch
)

Sets the pitch of a sound output by modifying its playback speed.

Parameters

MLHandlehandleMLHandle of the sound output.
floatpitchThe pitch of the sound output to be set.

Returns

MLResultMLResult_InvalidParamFailed due to an invalid parameter.
MLResultMLResult_OkSuccessfully set the value.
MLResultMLResult_UnspecifiedFailureFailed due to an unknown error.
MLResultMLAudioResult_HandleNotFoundFailed due to a missing handle.
MLResultMLAudioResult_InternalConfigErrorFailed due to an internal configuration error.
MLResultMLAudioResult_InvalidBufferSizeFailed due to an invalid buffer size.
MLResultMLAudioResult_NotImplementedFailed because feature has not been implemented yet.

Required Permissions:

  • None

The range of valid values is from 0.5 which plays at half speed and produces an octave shift down, to 2.0 which plays at double speed and produces an octave shift up. The default value of 1.0 plays the sound at its original speed and pitch.


MLAudioGetSoundPitch

MLResult MLAudioGetSoundPitch(
MLHandle handle,
float * out_pitch
)

Queries the pitch of a sound output which corresponds to its playback speed.

Parameters

MLHandlehandleMLHandle of the sound output.
float *out_pitchRetrieved pitch of the sound output.

Returns

MLResultMLResult_InvalidParamFailed due to an invalid parameter.
MLResultMLResult_OkSuccessfully retrieved the value.
MLResultMLResult_UnspecifiedFailureFailed due to an unknown error.
MLResultMLAudioResult_HandleNotFoundFailed due to a missing handle.
MLResultMLAudioResult_InternalConfigErrorFailed due to an internal configuration error.
MLResultMLAudioResult_NotImplementedFailed because feature has not been implemented yet.

Required Permissions:

  • None

The range of valid values is from 0.5 which plays at half speed and produces an octave shift down, to 2.0 which plays at double speed and produces an octave shift up. At the default value of 1.0 the sound plays at its original speed and pitch.


MLAudioSetSoundMute

MLResult MLAudioSetSoundMute(
MLHandle handle,
bool is_muted
)

Sets the mute state of a sound output.

Parameters

MLHandlehandleMLHandle of the sound output.
boolis_mutedIf true, the sound output will be muted.

Returns

MLResultMLResult_OkSuccessfully set the value.
MLResultMLResult_UnspecifiedFailureFailed due to an unknown error.
MLResultMLAudioResult_HandleNotFoundFailed due to a missing handle.
MLResultMLAudioResult_InternalConfigErrorFailed due to an internal configuration error.
MLResultMLAudioResult_NotImplementedFailed because feature has not been implemented yet.

Required Permissions:

  • None

The 'sound mute' of a sound output only affects that one sound output.


MLAudioGetSoundMute

MLResult MLAudioGetSoundMute(
MLHandle handle,
bool * out_is_muted
)

Queries the mute state of a sound output.

Parameters

MLHandlehandleMLHandle of the sound output.
bool *out_is_mutedIf true, the sound output is muted.

Returns

MLResultMLResult_InvalidParamFailed due to an invalid parameter.
MLResultMLResult_OkSuccessfully retrieved the value.
MLResultMLResult_UnspecifiedFailureFailed due to an unknown error.
MLResultMLAudioResult_HandleNotFoundFailed due to a missing handle.
MLResultMLAudioResult_InternalConfigErrorFailed due to an internal configuration error.
MLResultMLAudioResult_NotImplementedFailed because feature has not been implemented yet.

Required Permissions:

  • None

The 'sound mute' of a sound output only affects that one sound output.

API Level:

  • 20

MLAudioSetSoundBypassesMasterVolume

MLResult MLAudioSetSoundBypassesMasterVolume(
MLHandle handle,
bool is_bypassing
)

Sets whether a sound output is exempt from attenuation due to master volume.

Parameters

MLHandlehandleMLHandle of the sound output.
boolis_bypassingIndicates whether the sound output should bypass master volume or not.

Returns

MLResultMLResult_OkSuccessfully set the value.
MLResultMLResult_UnspecifiedFailureFailed due to an unknown error.
MLResultMLAudioResult_HandleNotFoundFailed due to a missing handle.
MLResultMLResult_IncompatibleSKUFailed due to feature not being supported on current device version.

Required Permissions:

  • None

This call sets whether 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 is available only on certain SKUs; trying to set it when the device is not compatible will produce an error as listed below. In addition, this option only works when a sound is non-spatial; the non-spatial sound parameters volume, pitch, etc remain active for sounds that are bypassing master volume.

API Level:

  • 20

MLAudioGetSoundBypassesMasterVolume

MLResult MLAudioGetSoundBypassesMasterVolume(
MLHandle handle,
bool * out_is_bypassing
)

Queries whether a sound output is exempt from attenuation due to master volume.

Parameters

MLHandlehandleMLHandle of the sound output.
bool *out_is_bypassingIndicates whether the sound output is bypassing master volume or not.

Returns

MLResultMLResult_OkSuccessfully queried the bypassing state of the sound output.
MLResultMLResult_InvalidParamFailed due to an invalid parameter.
MLResultMLResult_UnspecifiedFailureFailed due to an unknown error.
MLResultMLResult_IncompatibleSKUFailed due to feature not being supported on current device version.
MLResultMLAudioResult_HandleNotFoundFailed due to a missing handle.
MLResultMLAudioResult_InternalConfigErrorFailed due to an internal configuration error.

Required Permissions:

  • None

This call queries whether 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 is available only on certain SKUs; trying to query it when the device is not compatible will produce an error as listed below. In addition, this option only works when a sound is non-spatial; the non-spatial sound parameters volume, pitch, etc remain active for sounds that are bypassing master volume.

API Level:

  • 20

MLAudioSetSoundLooping

MLResult MLAudioSetSoundLooping(
MLHandle handle,
bool is_looping
)

Sets whether a sound output is looping or not.

Parameters

MLHandlehandleMLHandle of the sound output.
boolis_loopingDetermines whether the sound output is looping or not.

Returns

MLResultMLResult_OkSuccessfully set looping of audio.
MLResultMLResult_UnspecifiedFailureFailed due to an unknown error.
MLResultMLAudioResult_HandleNotFoundFailed due to a missing handle.
MLResultMLAudioResult_NotImplementedFailed because feature has not been implemented yet.

Required Permissions:

  • None

Looping is available for sound outputs that use Loaded Files and Streamed Files (and their audio resource equivalents). If a sound output is set to looping, then when it reaches the end of the file, it continues playing from the beginning of the file. Looping is not available for sound outputs that use Buffered Outputs.


MLAudioGetSoundLooping

MLResult MLAudioGetSoundLooping(
MLHandle handle,
bool * out_is_looping
)

Queries whether a sound output is looping or not.

Parameters

MLHandlehandleMLHandle of the sound output.
bool *out_is_loopingIf true, the sound output state is looping.

Returns

MLResultMLResult_InvalidParamFailed due to an invalid parameter.
MLResultMLResult_OkSuccessfully retrieved the value.
MLResultMLResult_UnspecifiedFailureFailed due to an unknown error.
MLResultMLAudioResult_HandleNotFoundFailed due to a missing handle.
MLResultMLAudioResult_NotImplementedFailed because feature has not been implemented yet.

Required Permissions:

  • None

Looping is available for sound outputs that use Loaded Files and Streamed Files (and their audio resource equivalents). If a sound output is set to looping, then when it reaches the end of the file, it continues playing from the beginning of the file. Looping is not available for sound outputs that use Buffered Outputs.


MLAudioSetStreamedFileOffset

MLResult MLAudioSetStreamedFileOffset(
MLHandle handle,
uint32_t offset_in_msec
)

Sets the playback position of a sound output that's playing a Streamed File.

Parameters

MLHandlehandleMLHandle of the sound output.
uint32_toffset_in_msecThe playback position in milliseconds the sound output will be set to.

Returns

MLResultMLResult_InvalidParamFailed due to an invalid parameter.
MLResultMLResult_OkSuccessfully set the value.
MLResultMLResult_UnspecifiedFailureFailed due to an unknown error.
MLResultMLAudioResult_HandleNotFoundFailed due to a missing handle.
MLResultMLAudioResult_NotImplementedFailed because feature has not been implemented yet.
MLResultMLAudioResult_OperationUnavailableFailed because operation is unavailable.

Required Permissions:

  • None

The playback position is in milliseconds and can be set regardless of the playback state.


MLAudioGetStreamedFileOffset

MLResult MLAudioGetStreamedFileOffset(
MLHandle handle,
uint32_t * out_offset_in_msec
)

Queries the playback position of a sound output that's playing a Streamed File.

Parameters

MLHandlehandleMLHandle of the sound output.
uint32_t *out_offset_in_msecRetrieved playback position.

Returns

MLResultMLResult_InvalidParamFailed due to an invalid parameter.
MLResultMLResult_OkSuccessfully retrieved the value.
MLResultMLResult_UnspecifiedFailureFailed due to an unknown error.
MLResultMLAudioResult_HandleNotFoundFailed due to a missing handle.
MLResultMLAudioResult_InternalConfigErrorFailed due to an internal configuration error.
MLResultMLAudioResult_NotImplementedFailed because feature has not been implemented yet.
MLResultMLAudioResult_OperationUnavailableFailed because operation is unavailable.

Required Permissions:

  • None

The playback position is in milliseconds.


MLAudioGetOutputDevice

MLResult MLAudioGetOutputDevice(
MLAudioOutputDevice * out_current_device
)

Queries which type of sound output device is being used for sound output.

Parameters

MLAudioOutputDevice *out_current_deviceEnum indicating what kind of audio output device is currently in use.

Returns

MLResultMLResult_InvalidParamFailed due to an invalid parameter.
MLResultMLResult_OkSuccessfully indicated the type of output device.
MLResultMLResult_UnspecifiedFailureFailed due to an unknown error.
MLResultMLAudioResult_NotImplementedFailed because feature has not been implemented yet.

Required Permissions:

  • None

This is a global configuration that is not specific to individual sound outputs.


MLAudioSetOutputDeviceCallback

MLResult MLAudioSetOutputDeviceCallback(
MLAudioOutputDeviceChangedCallback callback,
void * context
)

Registers a callback for when the active audio hardware output has changed.

Parameters

MLAudioOutputDeviceChangedCallbackcallbackCallback function pointer.
void *contextGeneric data pointer passed back through the callback.

Returns

MLResultMLResult_AllocFailedFailed due to memory allocation failure.
MLResultMLResult_OkSuccessfully registered the callback.
MLResultMLResult_UnspecifiedFailureFailed due to an unknown error.
MLResultMLAudioResult_NotImplementedFailed because feature has not been implemented yet.

Required Permissions:

  • None

API Level:

  • 8