Virtualizer
open classVirtualizer: AudioEffect
kotlin.Any | ||
↳ | android.media.audiofx.AudioEffect | |
↳ | android.media.audiofx.Virtualizer |
An audio virtualizer is a general name for an effect to spatialize audio channels. The exact behavior of this effect is dependent on the number of audio input channels and the types and number of audio output channels of the device. For example, in the case of a stereo input and stereo headphone output, a stereo widening effect is used when this effect is turned on.
An application creates a Virtualizer object to instantiate and control a virtualizer engine in the audio framework.
The methods, parameter types and units exposed by the Virtualizer implementation are directly mapping those defined by the OpenSL ES 1.0.1 Specification (http://www.khronos.org/opensles/) for the SLVirtualizerItf interface. Please refer to this specification for more details.
To attach the Virtualizer to a particular AudioTrack or MediaPlayer, specify the audio session ID of this AudioTrack or MediaPlayer when constructing the Virtualizer.
NOTE: attaching a Virtualizer to the global audio output mix by use of session 0 is deprecated.
See android.media.MediaPlayer#getAudioSessionId()
for details on audio sessions.
See android.media.audiofx.AudioEffect
class for more details on controlling audio effects.
Summary
Nested classes | |
---|---|
abstract |
The OnParameterChangeListener interface defines a method called by the Virtualizer when a parameter value has changed. |
open |
The Settings class regroups all virtualizer parameters. |
Constants | |
---|---|
static Int |
Virtualizer effect strength. |
static Int |
Is strength parameter supported by virtualizer engine. |
static Int |
A virtualization mode used to indicate the virtualizer effect must stop forcing the processing to a particular mode in |
static Int |
A virtualization mode typically used over headphones. |
static Int |
A virtualization mode indicating virtualization processing is not active. |
static Int |
A virtualization mode typically used over speakers. |
Inherited constants | |
---|---|
Public constructors | |
---|---|
Virtualizer(priority: Int, audioSession: Int) Class constructor. |
Public methods | |
---|---|
open Boolean |
canVirtualize(inputChannelMask: Int, virtualizationMode: Int) Checks if the combination of a channel mask and virtualization mode is supported by this virtualizer. |
open Boolean |
forceVirtualizationMode(virtualizationMode: Int) Forces the virtualizer effect to use the given processing mode. |
open Virtualizer.Settings! |
Gets the virtualizer properties. |
open Short |
Gets the current strength of the effect. |
open Boolean |
getSpeakerAngles(inputChannelMask: Int, virtualizationMode: Int, angles: IntArray!) Queries the virtual speaker angles (azimuth and elevation) for a combination of a channel mask and virtualization mode. |
open Boolean |
Indicates whether setting strength is supported. |
open Int |
Return the virtualization mode being used, if any. |
open Unit |
Registers an OnParameterChangeListener interface. |
open Unit |
setProperties(settings: Virtualizer.Settings!) Sets the virtualizer properties. |
open Unit |
setStrength(strength: Short) Sets the strength of the virtualizer effect. |
Inherited functions | |
---|---|
Inherited properties | |
---|---|
Constants
PARAM_STRENGTH
static valPARAM_STRENGTH: Int
Deprecated: Deprecated in Java.
Virtualizer effect strength. Parameter ID for android.media.audiofx.Virtualizer.OnParameterChangeListener
Value: 1
PARAM_STRENGTH_SUPPORTED
static valPARAM_STRENGTH_SUPPORTED: Int
Deprecated: Deprecated in Java.
Is strength parameter supported by virtualizer engine. Parameter ID for getParameter().
Value: 0
VIRTUALIZATION_MODE_AUTO
static valVIRTUALIZATION_MODE_AUTO: Int
Deprecated: Deprecated in Java.
A virtualization mode used to indicate the virtualizer effect must stop forcing the processing to a particular mode in forceVirtualizationMode(int)
.
Value: 1
VIRTUALIZATION_MODE_BINAURAL
static valVIRTUALIZATION_MODE_BINAURAL: Int
Deprecated: Deprecated in Java.
A virtualization mode typically used over headphones. Binaural virtualization describes an audio processing configuration for virtualization where the left and right channels are respectively reaching the left and right ear of the user, without also feeding the opposite ear (as is the case when listening over speakers).
Such a mode is therefore meant to be used when audio is playing over stereo wired headphones or headsets, but also stereo headphones through a wireless A2DP Bluetooth link.
See canVirtualize(int,int)
to verify this mode is supported by this Virtualizer.
Value: 2
VIRTUALIZATION_MODE_OFF
static valVIRTUALIZATION_MODE_OFF: Int
Deprecated: Deprecated in Java.
A virtualization mode indicating virtualization processing is not active. See getVirtualizationMode()
as one of the possible return value.
Value: 0
VIRTUALIZATION_MODE_TRANSAURAL
static valVIRTUALIZATION_MODE_TRANSAURAL: Int
Deprecated: Deprecated in Java.
A virtualization mode typically used over speakers. Transaural virtualization describes an audio processing configuration that differs from binaural (as described in VIRTUALIZATION_MODE_BINAURAL
in that cross-talk is present, i.e. audio played from the left channel also reaches the right ear of the user, and vice-versa.
When supported, such a mode is therefore meant to be used when audio is playing over the built-in stereo speakers of a device, if they are featured.
See canVirtualize(int,int)
to verify this mode is supported by this Virtualizer.
Value: 3
Public constructors
Virtualizer
Virtualizer(
priority: Int,
audioSession: Int)
Class constructor.
Parameters | |
---|---|
priority |
Int: the priority level requested by the application for controlling the Virtualizer engine. As the same engine can be shared by several applications, this parameter indicates how much the requesting application needs control of effect parameters. The normal priority is 0, above normal is a positive number, below normal a negative number. |
audioSession |
Int: system wide unique audio session identifier. The Virtualizer will be attached to the MediaPlayer or AudioTrack in the same audio session. |
Exceptions | |
---|---|
java.lang.IllegalStateException |
|
java.lang.IllegalArgumentException |
|
java.lang.UnsupportedOperationException |
|
java.lang.RuntimeException |
Public methods
canVirtualize
open funcanVirtualize(
inputChannelMask: Int,
virtualizationMode: Int
): Boolean
Deprecated: Deprecated in Java.
Checks if the combination of a channel mask and virtualization mode is supported by this virtualizer. Some virtualizer implementations may only support binaural processing (i.e. only support headphone output, see VIRTUALIZATION_MODE_BINAURAL
), some may support transaural processing (i.e. for speaker output, see VIRTUALIZATION_MODE_TRANSAURAL
) for the built-in speakers. Use this method to query the virtualizer implementation capabilities.
Parameters | |
---|---|
inputChannelMask |
Int: the channel mask of the content to virtualize. |
virtualizationMode |
Int: the mode for which virtualization processing is to be performed, one of VIRTUALIZATION_MODE_BINAURAL , VIRTUALIZATION_MODE_TRANSAURAL . Value is android.media.audiofx.Virtualizer#VIRTUALIZATION_MODE_BINAURAL , or android.media.audiofx.Virtualizer#VIRTUALIZATION_MODE_TRANSAURAL |
Return | |
---|---|
Boolean |
true if the combination of channel mask and virtualization mode is supported, false otherwise. An indication that a certain channel mask is not supported doesn't necessarily mean you cannot play content with that channel mask, it more likely implies the content will be downmixed before being virtualized. For instance a virtualizer that only supports a mask such as AudioFormat.CHANNEL_OUT_STEREO will still be able to process content with a mask of AudioFormat.CHANNEL_OUT_5POINT1 , but will downmix the content to stereo first, and then will virtualize, as opposed to virtualizing each channel individually. |
Exceptions | |
---|---|
java.lang.IllegalStateException |
|
java.lang.IllegalArgumentException |
|
java.lang.UnsupportedOperationException |
forceVirtualizationMode
open funforceVirtualizationMode(virtualizationMode: Int): Boolean
Deprecated: Deprecated in Java.
Forces the virtualizer effect to use the given processing mode. The effect must be enabled for the forced mode to be applied.
Parameters | |
---|---|
virtualizationMode |
Int: one of VIRTUALIZATION_MODE_BINAURAL , VIRTUALIZATION_MODE_TRANSAURAL to force a particular processing mode, or {@value #VIRTUALIZATION_MODE_AUTO} to stop forcing a mode. Value is android.media.audiofx.Virtualizer#VIRTUALIZATION_MODE_AUTO , android.media.audiofx.Virtualizer#VIRTUALIZATION_MODE_BINAURAL , or android.media.audiofx.Virtualizer#VIRTUALIZATION_MODE_TRANSAURAL |
Return | |
---|---|
Boolean |
true if the processing mode is supported, and it is successfully set, or forcing was successfully disabled, false otherwise. |
Exceptions | |
---|---|
java.lang.IllegalStateException |
|
java.lang.IllegalArgumentException |
|
java.lang.UnsupportedOperationException |
getProperties
open fungetProperties(): Virtualizer.Settings!
Deprecated: Deprecated in Java.
Gets the virtualizer properties. This method is useful when a snapshot of current virtualizer settings must be saved by the application.
Return | |
---|---|
Virtualizer.Settings! |
a Virtualizer.Settings object containing all current parameters values |
Exceptions | |
---|---|
java.lang.IllegalStateException |
|
java.lang.IllegalArgumentException |
|
java.lang.UnsupportedOperationException |
getRoundedStrength
open fungetRoundedStrength(): Short
Deprecated: Deprecated in Java.
Gets the current strength of the effect.
Return | |
---|---|
Short |
the strength of the effect. The valid range for strength is [0, 1000], where 0 per mille designates the mildest effect and 1000 per mille the strongest |
Exceptions | |
---|---|
java.lang.IllegalStateException |
|
java.lang.IllegalArgumentException |
|
java.lang.UnsupportedOperationException |
getSpeakerAngles
open fungetSpeakerAngles(
inputChannelMask: Int,
virtualizationMode: Int,
angles: IntArray!
): Boolean
Deprecated: Deprecated in Java.
Queries the virtual speaker angles (azimuth and elevation) for a combination of a channel mask and virtualization mode. If the virtualization configuration (mask and mode) is supported (see canVirtualize(int,int)
, the array angles will contain upon return the definition of each virtual speaker and its azimuth and elevation angles relative to the listener.
Note that in some virtualizer implementations, the angles may be strength-dependent.
Parameters | |
---|---|
inputChannelMask |
Int: the channel mask of the content to virtualize. |
virtualizationMode |
Int: the mode for which virtualization processing is to be performed, one of VIRTUALIZATION_MODE_BINAURAL , VIRTUALIZATION_MODE_TRANSAURAL . Value is android.media.audiofx.Virtualizer#VIRTUALIZATION_MODE_BINAURAL , or android.media.audiofx.Virtualizer#VIRTUALIZATION_MODE_TRANSAURAL |
angles |
IntArray!: a non-null array whose length is 3 times the number of channels in the channel mask. If the method indicates the configuration is supported, the array will contain upon return triplets of values: for each channel i among the channels of the mask:
|
Return | |
---|---|
Boolean |
true if the combination of channel mask and virtualization mode is supported, false otherwise. |
Exceptions | |
---|---|
java.lang.IllegalStateException |
|
java.lang.IllegalArgumentException |
|
java.lang.UnsupportedOperationException |
getStrengthSupported
open fungetStrengthSupported(): Boolean
Deprecated: Deprecated in Java.
Indicates whether setting strength is supported. If this method returns false, only one strength is supported and the setStrength() method always rounds to that value.
Return | |
---|---|
Boolean |
true is strength parameter is supported, false otherwise |
getVirtualizationMode
open fungetVirtualizationMode(): Int
Deprecated: Deprecated in Java.
Return the virtualization mode being used, if any.
Return | |
---|---|
Int |
the virtualization mode being used. If virtualization is not active, the virtualization mode will be VIRTUALIZATION_MODE_OFF . Otherwise the value will be VIRTUALIZATION_MODE_BINAURAL or VIRTUALIZATION_MODE_TRANSAURAL . Virtualization may not be active either because the effect is not enabled or because the current output device is not compatible with this virtualization implementation. |
Exceptions | |
---|---|
java.lang.IllegalStateException |
|
java.lang.UnsupportedOperationException |
setParameterListener
open funsetParameterListener(listener: Virtualizer.OnParameterChangeListener!): Unit
Deprecated: Deprecated in Java.
Registers an OnParameterChangeListener interface.
Parameters | |
---|---|
listener |
Virtualizer.OnParameterChangeListener!: OnParameterChangeListener interface registered |
setProperties
open funsetProperties(settings: Virtualizer.Settings!): Unit
Deprecated: Deprecated in Java.
Sets the virtualizer properties. This method is useful when virtualizer settings have to be applied from a previous backup.
Parameters | |
---|---|
settings |
Virtualizer.Settings!: a Virtualizer.Settings object containing the properties to apply |
Exceptions | |
---|---|
java.lang.IllegalStateException |
|
java.lang.IllegalArgumentException |
|
java.lang.UnsupportedOperationException |
setStrength
open funsetStrength(strength: Short): Unit
Deprecated: Deprecated in Java.
Sets the strength of the virtualizer effect. If the implementation does not support per mille accuracy for setting the strength, it is allowed to round the given strength to the nearest supported value. You can use the getRoundedStrength()
method to query the (possibly rounded) value that was actually set.
Parameters | |
---|---|
strength |
Short: strength of the effect. The valid range for strength strength is [0, 1000], where 0 per mille designates the mildest effect and 1000 per mille designates the strongest. |
Exceptions | |
---|---|
java.lang.IllegalStateException |
|
java.lang.IllegalArgumentException |
|
java.lang.UnsupportedOperationException |