Class StageAudioManager
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic @interfacestatic enumstatic enumEcho cancellation algorithms available for audio processing.static classRepresents a preference for an audio effect with a fallback option.static enumNoise suppression algorithms available for audio processing.static enumstatic enumstatic enumPredefined audio configuration presets for common use cases. -
Method Summary
Modifier and TypeMethodDescriptionvoidenableEchoCancellation(boolean isEnabled) Enable or disable echo cancellation.voidenableNoiseSuppression(boolean isEnabled) Enable or disable noise suppression.static StageAudioManagergetInstance(android.content.Context context) Returns an instance of the StageAudioManager.Get the current preferred echo cancellation configuration.Get the current preferred noise suppression configuration.getUsage()booleanWhether echo cancellation is currently enabled.booleanWhether noise suppression is currently enabled.voidsetAudioModeManagementEnabled(boolean isEnabled) Use this method to turn off the audio mode management (including for Bluetooth) done by the IVS SDK if your application wants to manage this itself.voidsetConfiguration(StageAudioManager.Source source, StageAudioManager.ContentType contentType, StageAudioManager.Usage usage) Sets the audio attributes to be applied to input and output audio streams.voidsetPreferredEchoCancellation(StageAudioManager.EffectPreference<StageAudioManager.EchoCancellation> preference) Set the preferred echo cancellation algorithm with a fallback option.voidsetPreferredNoiseSuppression(StageAudioManager.EffectPreference<StageAudioManager.NoiseSuppression> preference) Set the preferred noise suppression algorithm with a fallback option.voidSets a use case preset.
-
Method Details
-
setAudioModeManagementEnabled
public void setAudioModeManagementEnabled(boolean isEnabled) Use this method to turn off the audio mode management (including for Bluetooth) done by the IVS SDK if your application wants to manage this itself. Please see AudioManager#setMode in the Android SDK.You can still use the various presets and the source / usage / content type values which affect AAudio stream attributes, and are important for things like echo cancellation.
- Parameters:
isEnabled- Whether the audio mode management done by this class is enabled, the default is true.
-
enableEchoCancellation
public void enableEchoCancellation(boolean isEnabled) Enable or disable echo cancellation. This can only be set if there are no unreleased instances of Stage or DeviceDiscovery.When enabled, the SDK will apply the echo cancellation algorithm specified by
setPreferredEchoCancellation(EffectPreference). When disabled, no echo cancellation will be applied regardless of the preferred algorithm setting. Note that when the Source attribute is set to VOICE_COMMUNICATION (as it is when the VIDEO_CHAT UseCasePreset is applied), native audio effects -- including echo cancellation -- may still be applied at the platform level independently of this setting. See Android documentation on Audio Effects for details.Echo cancellation is enabled by default when using the VIDEO_CHAT preset and disabled for STUDIO and SUBSCRIBE_ONLY presets.
- Parameters:
isEnabled- Whether echo cancellation should be enabled.- Throws:
IllegalStateException- if called while Stage or DeviceDiscovery instances exist.- See Also:
-
setPreferredEchoCancellation
public void setPreferredEchoCancellation(@NonNull StageAudioManager.EffectPreference<StageAudioManager.EchoCancellation> preference) Set the preferred echo cancellation algorithm with a fallback option. This can only be set if there are no unreleased instances of Stage or DeviceDiscovery.The SDK will attempt to use the preferred algorithm first. If the preferred algorithm is unavailable (due to device limitations or audio configuration), the SDK will automatically fall back to the specified fallback algorithm.
The default configuration is PLATFORM_ACOUSTIC_ECHO_CANCELER preferred with AECM fallback, which provides the best balance of quality and compatibility across devices.
This setting only takes effect when echo cancellation is enabled via
enableEchoCancellation(boolean).- Parameters:
preference- An EffectPreference specifying the preferred and fallback echo cancellation algorithms.- Throws:
IllegalStateException- if called while Stage or DeviceDiscovery instances exist.- See Also:
-
isEchoCancellationEnabled
public boolean isEchoCancellationEnabled()Whether echo cancellation is currently enabled. -
getPreferredEchoCancellation
public StageAudioManager.EffectPreference<StageAudioManager.EchoCancellation> getPreferredEchoCancellation()Get the current preferred echo cancellation configuration.The default configuration is PLATFORM_ACOUSTIC_ECHO_CANCELER preferred with AECM fallback, which provides the best balance of quality and compatibility across devices.
- Returns:
- The current EffectPreference for echo cancellation, containing both the preferred and fallback algorithms.
- See Also:
-
enableNoiseSuppression
public void enableNoiseSuppression(boolean isEnabled) Enable or disable noise suppression. This can only be set if there are no unreleased instances of Stage or DeviceDiscovery.When enabled, the SDK will apply the noise suppression algorithm specified by
setPreferredNoiseSuppression(EffectPreference). When disabled, no noise suppression will be applied regardless of the preferred algorithm setting. Note that when the Source attribute is set to VOICE_COMMUNICATION (as it is when the VIDEO_CHAT UseCasePreset is applied), native audio effects -- including noise suppression -- may still be applied at the platform level independently of this setting. See Android documentation on Audio Effects for details.Noise suppression is enabled by default when using the VIDEO_CHAT preset and disabled for STUDIO and SUBSCRIBE_ONLY presets.
- Parameters:
isEnabled- Whether noise suppression should be enabled.- Throws:
IllegalStateException- if called while Stage or DeviceDiscovery instances exist.- See Also:
-
setPreferredNoiseSuppression
public void setPreferredNoiseSuppression(@NonNull StageAudioManager.EffectPreference<StageAudioManager.NoiseSuppression> preference) Set the preferred noise suppression algorithm with a fallback option. This can only be set if there are no unreleased instances of Stage or DeviceDiscovery.The SDK will attempt to use the preferred algorithm first. If the preferred algorithm is unavailable (due to device limitations or audio configuration), the SDK will automatically fall back to the specified fallback algorithm.
The default configuration is PLATFORM_NOISE_SUPPRESSOR preferred with SOFTWARE fallback, which provides the best balance of quality and compatibility across devices.
This setting only takes effect when noise suppression is enabled via
enableNoiseSuppression(boolean).- Parameters:
preference- An EffectPreference specifying the preferred and fallback noise suppression algorithms. The preferred and fallback must be different.- Throws:
IllegalStateException- if called while Stage or DeviceDiscovery instances exist.- See Also:
-
getPreferredNoiseSuppression
public StageAudioManager.EffectPreference<StageAudioManager.NoiseSuppression> getPreferredNoiseSuppression()Get the current preferred noise suppression configuration. If no configuration was previously set, then the preferred configuration follows the configured UseCasePreset.The default configuration is PLATFORM_NOISE_SUPPRESSOR preferred with SOFTWARE fallback, which provides the best balance of quality and compatibility across devices.
- Returns:
- The current EffectPreference for noise suppression, containing both the preferred and fallback algorithms.
- See Also:
-
isNoiseSuppressionEnabled
public boolean isNoiseSuppressionEnabled()Whether noise suppression is currently enabled. -
setPreset
Sets a use case preset. The default is VIDEO_CHAT.- Parameters:
preset- The desired preset.- Throws:
IllegalStateException- if called while Stage or DeviceDiscovery instances exist.- See Also:
-
setConfiguration
public void setConfiguration(@NonNull StageAudioManager.Source source, @NonNull StageAudioManager.ContentType contentType, @NonNull StageAudioManager.Usage usage) Sets the audio attributes to be applied to input and output audio streams.This provides more granular control of the attributes, as opposed to #setPreset. If using this method, it is recommended to also set the desired echo cancellation and noise suppression as well.
See Android documentation for Source, ContentType and Usage audio attributes for more information.
- Parameters:
source- The desired source attribute.contentType- The desired contentType attribute.usage- The desired usage attribute.- Throws:
IllegalStateException- if called while Stage or DeviceDiscovery instances exist.
-
getSource
-
getContentType
-
getUsage
-
getInstance
Returns an instance of the StageAudioManager.- Parameters:
context- The current application context- Returns:
- the instance of the StageAudioManager
-