Skip to main content
Version: 20 Mar 2024

Analysis

Module: Audio / Audio Definitions / Audio Output / Audio Input

More...

Functions

Name
MLResultMLAudioBeginTraitAnalysisFromMicCapture(MLAudioTraitAnalysisTarget target, MLAudioTraitAnalysisCallback callback, void context, MLHandle out_handle)
Starts a trait analysis of the energy contained in the mic signals.
MLResultMLAudioGetTraitAnalysis(MLHandle handle, float * out_value)
Queries the current value of the trait analysis.
MLResultMLAudioEndTraitAnalysis(MLHandle handle)
Stops a trait analysis.
MLResultMLAudioBeginSpectralAnalysisFromMicCapture(MLAudioSpectralAnalysisTarget target, MLAudioSpectralAnalysisCallback callback, void context, MLHandle out_handle)
Starts a spectral analysis of the energy contained in the mic signals.
MLResultMLAudioGetSpectralAnalysis(MLHandle handle, MLAudioSpectralAnalysis * out_values)
Queries the current values of a spectral analysis.
MLResultMLAudioEndSpectralAnalysis(MLHandle handle)
Stops a spectral analysis.

Detailed Description

ANALYSIS.


Functions Documentation

MLAudioBeginTraitAnalysisFromMicCapture

MLResult MLAudioBeginTraitAnalysisFromMicCapture(
MLAudioTraitAnalysisTarget target,
MLAudioTraitAnalysisCallback callback,
void * context,
MLHandle * out_handle
)

Starts a trait analysis of the energy contained in the mic signals.

Parameters

MLAudioTraitAnalysisTargettargetMLAudioTraitAnalysisTarget enum specifying the type of analysis requested.
MLAudioTraitAnalysisCallbackcallbackCallback function pointer.
void *contextGeneric data pointer passed back through the callback.
MLHandle *out_handleMLHandle to be used in subsequent calls.

Returns

MLResultMLResult_InvalidParamFailed due to an invalid parameter.
MLResultMLResult_OkSuccessfully began analysis.
MLResultMLResult_UnspecifiedFailureFailed due to an unknown error.

Required Permissions:

  • None

A trait analysis measures the characteristics of an audio stream, producing a single value representing the result of the analysis at a point in time. This function creates a new trait analysis, initializes its connection to the device microphones as the audio data source, and returns a handle in the 'out_handle' argument. The 'target' argument specifies the type of trait analysis, which implies the type of audio content to be analyzed. Results may be acquired either on a polling basis by calling MLAudioGetTraitAnalysis, or via a callback set by the optional 'callback' argument of this function, triggered whenever a new value is available.

API Level:

  • 20

MLAudioGetTraitAnalysis

MLResult MLAudioGetTraitAnalysis(
MLHandle handle,
float * out_value
)

Queries the current value of the trait analysis.

Parameters

MLHandlehandleMLHandle of the analysis.
float *out_valueRetrieved value of trait analysis.

Returns

MLResultMLResult_InvalidParamFailed due to an invalid parameter.
MLResultMLResult_OkSuccessfully retrieved the value.
MLResultMLResult_UnspecifiedFailureFailed due to an unknown error.
MLResultMLAudioResult_NotImpelmentedreturn control frequencies because feature has not been implemented yet.

Required Permissions:

  • None

API Level:

  • 20

MLAudioEndTraitAnalysis

MLResult MLAudioEndTraitAnalysis(
MLHandle handle
)

Stops a trait analysis.

Parameters

MLHandlehandleMLHandle of the analysis.

Returns

MLResultMLResult_InvalidParamFailed due to an invalid parameter.
MLResultMLResult_OkSuccessfully ended analysis.
MLResultMLResult_UnspecifiedFailureFailed due to an unknown error.

Required Permissions:

  • None

API Level:

  • 20

MLAudioBeginSpectralAnalysisFromMicCapture

MLResult MLAudioBeginSpectralAnalysisFromMicCapture(
MLAudioSpectralAnalysisTarget target,
MLAudioSpectralAnalysisCallback callback,
void * context,
MLHandle * out_handle
)

Starts a spectral analysis of the energy contained in the mic signals.

Parameters

MLAudioSpectralAnalysisTargettargetMLAudioSpectralAnalysisTarget enum specifying type of analysis requested.
MLAudioSpectralAnalysisCallbackcallbackCallback function pointer.
void *contextGeneric data pointer passed back through the callback.
MLHandle *out_handleMLHandle to be used in subsequent calls.

Returns

MLResultMLResult_OKSuccessfully began analysis.
MLResultMLResult_InvalidParamFailed due to an invalid parameter.
MLResultMLResult_UnspecifiedFailureFailed due to an unknown error.

Required Permissions:

  • None

A spectral analysis measures the characteristics of an audio stream on a per-frequency-band basis. This function creates a new spectral analysis, initializes its connection to the device microphones as the audio data source, and returns a handle in the 'out_handle' argument. The 'target' argument specifies the type of spectral analysis, which implies the type of audio content to be analyzed. Spectral analysis results are returned in the MLAudioSpectralAnalysis struct, which contains a time window of spectral analysis values. Results may be acquired either on a polling basis by calling MLAudioGetSpectralAnalysis, or via a callback set by the optional 'callback' argument of this function, triggered whenever new values are available. Cleanup of the MLAudioSpectralAnalysis struct passed in the optional callback is handled by the audio system; i.e., the caller is not responsible for deallocating memory if the callback is used.

API Level:

  • 20

MLAudioGetSpectralAnalysis

MLResult MLAudioGetSpectralAnalysis(
MLHandle handle,
MLAudioSpectralAnalysis * out_values
)

Queries the current values of a spectral analysis.

Parameters

MLHandlehandleMLHandle of the spectral analysis.
MLAudioSpectralAnalysis *out_valuesMLAudioSpectralAnalysis struct to be filled with the results properties.

Returns

MLResultMLResult_InvalidParamFailed due to an invalid parameter.
MLResultMLResult_OkSuccessfully retrieved analysis.
MLResultMLResult_UnspecifiedFailureFailed due to an unknown error.
MLResultMLAudioResult_OperationUnavailableFailed because operation is unavailable.

Required Permissions:

  • None

To store the values being queried, this function allocates a memory block which is pointed to by the 'values' field of the MLAudioSpectralAnalysis struct passed as the 'out_values' argument. The format of the data in this memory block can vary based on the selected MLAudioSpectralAnalysisTarget associated with the specified handle. The caller is responsible for deallocating this memory after each call to MLAudioGetSpectralAnalysis.

API Level:

  • 20

MLAudioEndSpectralAnalysis

MLResult MLAudioEndSpectralAnalysis(
MLHandle handle
)

Stops a spectral analysis.

Parameters

MLHandlehandleMLHandle of the spectral analysis.

Returns

MLResultMLResult_OKSuccessfully stopped analysis.
MLResultMLResult_InvalidParamFailed due to an invalid parameter.
MLResultMLResult_UnspecifiedFailureFailed due to an unknown error.

Required Permissions:

  • None

API Level:

  • 20