public class Virtualizer extends AudioEffect
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 MediaPlayer.getAudioSessionId()
for details on audio sessions.
See AudioEffect
class for more details on controlling
audio effects.
Modifier and Type | Class and Description |
---|---|
static interface |
Virtualizer.ForceVirtualizationMode |
static interface |
Virtualizer.OnParameterChangeListener
The OnParameterChangeListener interface defines a method called by the Virtualizer when a
parameter value has changed.
|
static class |
Virtualizer.Settings
The Settings class regroups all virtualizer parameters.
|
static interface |
Virtualizer.VirtualizationMode |
AudioEffect.Descriptor, AudioEffect.OnControlStatusChangeListener, AudioEffect.OnEnableStatusChangeListener
Modifier and Type | Field and Description |
---|---|
static int |
PARAM_FORCE_VIRTUALIZATION_MODE |
static int |
PARAM_STRENGTH
Virtualizer effect strength.
|
static int |
PARAM_STRENGTH_SUPPORTED
Is strength parameter supported by virtualizer engine.
|
static int |
PARAM_VIRTUAL_SPEAKER_ANGLES |
static int |
PARAM_VIRTUALIZATION_MODE |
static int |
VIRTUALIZATION_MODE_AUTO
A virtualization mode used to indicate the virtualizer effect must stop forcing the
processing to a particular mode in
forceVirtualizationMode(int) . |
static int |
VIRTUALIZATION_MODE_BINAURAL
A virtualization mode typically used over headphones.
|
static int |
VIRTUALIZATION_MODE_OFF
A virtualization mode indicating virtualization processing is not active.
|
static int |
VIRTUALIZATION_MODE_TRANSAURAL
A virtualization mode typically used over speakers.
|
ACTION_CLOSE_AUDIO_EFFECT_CONTROL_SESSION, ACTION_DISPLAY_AUDIO_EFFECT_CONTROL_PANEL, ACTION_OPEN_AUDIO_EFFECT_CONTROL_SESSION, ALREADY_EXISTS, CONTENT_TYPE_GAME, CONTENT_TYPE_MOVIE, CONTENT_TYPE_MUSIC, CONTENT_TYPE_VOICE, EFFECT_AUXILIARY, EFFECT_INSERT, EFFECT_PRE_PROCESSING, EFFECT_TYPE_AEC, EFFECT_TYPE_AGC, EFFECT_TYPE_BASS_BOOST, EFFECT_TYPE_ENV_REVERB, EFFECT_TYPE_EQUALIZER, EFFECT_TYPE_LOUDNESS_ENHANCER, EFFECT_TYPE_NS, EFFECT_TYPE_NULL, EFFECT_TYPE_PRESET_REVERB, EFFECT_TYPE_VIRTUALIZER, ERROR, ERROR_BAD_VALUE, ERROR_DEAD_OBJECT, ERROR_INVALID_OPERATION, ERROR_NO_INIT, ERROR_NO_MEMORY, EXTRA_AUDIO_SESSION, EXTRA_CONTENT_TYPE, EXTRA_PACKAGE_NAME, mListenerLock, mNativeEventHandler, NATIVE_EVENT_CONTROL_STATUS, NATIVE_EVENT_ENABLED_STATUS, NATIVE_EVENT_PARAMETER_CHANGED, STATE_INITIALIZED, STATE_UNINITIALIZED, SUCCESS
Constructor and Description |
---|
Virtualizer(int priority,
int audioSession)
Class constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canVirtualize(int inputChannelMask,
int virtualizationMode)
Checks if the combination of a channel mask and virtualization mode is supported by this
virtualizer.
|
boolean |
forceVirtualizationMode(int virtualizationMode)
Forces the virtualizer effect to use the given processing mode.
|
Virtualizer.Settings |
getProperties()
Gets the virtualizer properties.
|
short |
getRoundedStrength()
Gets the current strength of the effect.
|
boolean |
getSpeakerAngles(int inputChannelMask,
int virtualizationMode,
int[] angles)
Queries the virtual speaker angles (azimuth and elevation) for a combination of a channel
mask and virtualization mode.
|
boolean |
getStrengthSupported()
Indicates whether setting strength is supported.
|
int |
getVirtualizationMode()
Return the virtualization mode being used, if any.
|
void |
setParameterListener(Virtualizer.OnParameterChangeListener listener)
Registers an OnParameterChangeListener interface.
|
void |
setProperties(Virtualizer.Settings settings)
Sets the virtualizer properties.
|
void |
setStrength(short strength)
Sets the strength of the virtualizer effect.
|
byteArrayToInt, byteArrayToInt, byteArrayToShort, byteArrayToShort, checkState, checkStatus, command, concatArrays, finalize, getDescriptor, getEnabled, getId, getParameter, getParameter, getParameter, getParameter, getParameter, getParameter, getParameter, hasControl, intToByteArray, isEffectTypeAvailable, isError, queryEffects, queryPreProcessings, release, setControlStatusListener, setEnabled, setEnableStatusListener, setParameter, setParameter, setParameter, setParameter, setParameter, setParameter, setParameter, setParameterListener, shortToByteArray
public static final int PARAM_STRENGTH_SUPPORTED
public static final int PARAM_STRENGTH
Virtualizer.OnParameterChangeListener
public static final int PARAM_VIRTUAL_SPEAKER_ANGLES
public static final int PARAM_FORCE_VIRTUALIZATION_MODE
public static final int PARAM_VIRTUALIZATION_MODE
public static final int VIRTUALIZATION_MODE_OFF
getVirtualizationMode()
as one of the possible return value.public static final int VIRTUALIZATION_MODE_AUTO
forceVirtualizationMode(int)
.public static final int VIRTUALIZATION_MODE_BINAURAL
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.
public static final int VIRTUALIZATION_MODE_TRANSAURAL
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.
public Virtualizer(int priority, int audioSession) throws IllegalStateException, IllegalArgumentException, UnsupportedOperationException, RuntimeException
priority
- 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
- system wide unique audio session identifier. The Virtualizer will
be attached to the MediaPlayer or AudioTrack in the same audio session.IllegalStateException
IllegalArgumentException
UnsupportedOperationException
RuntimeException
public boolean getStrengthSupported()
public void setStrength(short strength) throws IllegalStateException, IllegalArgumentException, UnsupportedOperationException
getRoundedStrength()
method to query the
(possibly rounded) value that was actually set.strength
- 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.IllegalStateException
IllegalArgumentException
UnsupportedOperationException
public short getRoundedStrength() throws IllegalStateException, IllegalArgumentException, UnsupportedOperationException
IllegalStateException
IllegalArgumentException
UnsupportedOperationException
public boolean canVirtualize(int inputChannelMask, int virtualizationMode) throws IllegalStateException, IllegalArgumentException, UnsupportedOperationException
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.inputChannelMask
- the channel mask of the content to virtualize.virtualizationMode
- the mode for which virtualization processing is to be performed,
one of VIRTUALIZATION_MODE_BINAURAL
, VIRTUALIZATION_MODE_TRANSAURAL
.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.IllegalStateException
IllegalArgumentException
UnsupportedOperationException
public boolean getSpeakerAngles(int inputChannelMask, int virtualizationMode, int[] angles) throws IllegalStateException, IllegalArgumentException, UnsupportedOperationException
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.
inputChannelMask
- the channel mask of the content to virtualize.virtualizationMode
- the mode for which virtualization processing is to be performed,
one of VIRTUALIZATION_MODE_BINAURAL
, VIRTUALIZATION_MODE_TRANSAURAL
.angles
- 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:
3*i
in the array contains the speaker
identification (e.g. AudioFormat.CHANNEL_OUT_FRONT_LEFT
),3*i+1
contains its corresponding azimuth angle
expressed in degrees, where 0 is the direction the listener faces, 180 is behind
the listener, and -90 is to her/his left,3*i+2
contains its corresponding elevation angle
where +90 is directly above the listener, 0 is the horizontal plane, and -90 is
directly below the listener.IllegalStateException
IllegalArgumentException
UnsupportedOperationException
public boolean forceVirtualizationMode(int virtualizationMode) throws IllegalStateException, IllegalArgumentException, UnsupportedOperationException
virtualizationMode
- one of VIRTUALIZATION_MODE_BINAURAL
,
VIRTUALIZATION_MODE_TRANSAURAL
to force a particular processing mode, or
1 to stop forcing a mode.IllegalStateException
IllegalArgumentException
UnsupportedOperationException
public int getVirtualizationMode() throws IllegalStateException, UnsupportedOperationException
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.IllegalStateException
UnsupportedOperationException
public void setParameterListener(Virtualizer.OnParameterChangeListener listener)
listener
- OnParameterChangeListener interface registeredpublic Virtualizer.Settings getProperties() throws IllegalStateException, IllegalArgumentException, UnsupportedOperationException
IllegalStateException
IllegalArgumentException
UnsupportedOperationException
public void setProperties(Virtualizer.Settings settings) throws IllegalStateException, IllegalArgumentException, UnsupportedOperationException
settings
- a Virtualizer.Settings object containing the properties to applyIllegalStateException
IllegalArgumentException
UnsupportedOperationException