Audio Spectrum

disableAudioSpectrumMonitor

Disables audio spectrum monitoring.

public abstract int disableAudioSpectrumMonitor();

After calling enableAudioSpectrumMonitor, you can call this method to disable audio spectrum monitoring.

Note: You can call this method before or after joining a channel.

Return Values

  • 0: Success.
  • < 0: Failure.

enableAudioSpectrumMonitor

Enables the audio spectrum monitoring feature.

public abstract int enableAudioSpectrumMonitor(int intervalInMS);

You can register an audio spectrum observer and call this method to obtain audio spectrum data of local or remote users.

Scenario

You can call this method before or after joining a channel.

Parameters

intervalInMS
The time interval in milliseconds at which the SDK triggers the onLocalAudioSpectrum and onRemoteAudioSpectrum callbacks. This parameter must not be less than 10; otherwise, the method call fails. (Default: 100)

Return Values

  • 0: Success.
  • < 0: Failure.
    • -2: Invalid parameter.

registerAudioSpectrumObserver

Registers an audio spectrum observer.

public abstract int registerAudioSpectrumObserver(IAudioSpectrumObserver observer);

After successfully registering the audio spectrum observer and calling enableAudioSpectrumMonitor to enable audio spectrum monitoring, the SDK triggers the callbacks you implement in IAudioSpectrumObserver based on the configured interval.

Note: You can call this method before or after joining a channel.

Parameters

observer
The audio spectrum observer. See IAudioSpectrumObserver.

Return Values

  • 0: Success.
  • < 0: Failure.

unRegisterAudioSpectrumObserver

Unregisters the audio spectrum observer.

public abstract int unRegisterAudioSpectrumObserver(IAudioSpectrumObserver observer);

After calling registerAudioSpectrumObserver, you can call this method if you want to disable audio spectrum monitoring.

Note: You can call this method before or after joining a channel.

Parameters

observer
The audio spectrum observer. See IAudioSpectrumObserver.

Return Values

  • 0: Success.
  • < 0: Failure.

onLocalAudioSpectrum

Callback for local audio spectrum data.

@CalledByNative boolean onLocalAudioSpectrum(AudioSpectrumInfo data);

After successfully calling registerAudioSpectrumObserver to implement the onLocalAudioSpectrum callback and calling enableAudioSpectrumMonitor to enable audio spectrum monitoring, the SDK triggers this callback before encoding at the interval you set to report the local user's audio spectrum data.

Trigger Timing

This callback is triggered by the SDK before encoding at the interval you set, after enabling audio spectrum monitoring and setting the interval.

Parameters

data
Audio spectrum data of the local user. See AudioSpectrumInfo.

Return Values

Whether spectrum data is received:
  • true: Spectrum data is received.
  • false: Spectrum data is not received.

onRemoteAudioSpectrum

Callback for remote audio spectrum data.

boolean onRemoteAudioSpectrum(UserAudioSpectrumInfo[] userAudioSpectrumInfos, int spectrumNumber);

After successfully calling registerAudioSpectrumObserver and enableAudioSpectrumMonitor to enable audio spectrum monitoring, the SDK triggers this callback at the interval you set.

Trigger Timing

This callback is triggered at the interval you set after successfully calling registerAudioSpectrumObserver and enabling audio spectrum monitoring.

Parameters

userAudioSpectrumInfos
Audio spectrum information of remote users. The array length equals the number of remote users detected by the SDK. If this array is null, it means no remote user audio spectrum is detected. See UserAudioSpectrumInfo.
spectrumNumber
The number of remote users.

Return Values

  • true: Spectrum data is received.
  • false: Spectrum data is not received.