Please note that the contents of this offline web site may be out of date. To access the most recent documentation visit the online version .
Note that links that point to online resources are green in color and will open in a new window.
We would love it if you could give us feedback about this material by filling this form (You have to be online to fill it)
Android APIs
public class

Virtualizer

extends AudioEffect
java.lang.Object
   ↳ android.media.audiofx.AudioEffect
     ↳ android.media.audiofx.Virtualizer

Class Overview

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 getAudioSessionId() for details on audio sessions.

See AudioEffect class for more details on controlling audio effects.

Summary

Nested Classes
interface Virtualizer.OnParameterChangeListener The OnParameterChangeListener interface defines a method called by the Virtualizer when a parameter value has changed. 
class Virtualizer.Settings The Settings class regroups all virtualizer parameters. 
Constants
int PARAM_STRENGTH Virtualizer effect strength.
int PARAM_STRENGTH_SUPPORTED Is strength parameter supported by virtualizer engine.
[Expand]
Inherited Constants
From class android.media.audiofx.AudioEffect
[Expand]
Inherited Fields
From class android.media.audiofx.AudioEffect
Public Constructors
Virtualizer (int priority, int audioSession)
Class constructor.
Public Methods
Virtualizer.Settings getProperties ()
Gets the virtualizer properties.
short getRoundedStrength ()
Gets the current strength of the effect.
boolean getStrengthSupported ()
Indicates whether setting strength is supported.
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.
[Expand]
Inherited Methods
From class android.media.audiofx.AudioEffect
From class java.lang.Object

Constants

public static final int PARAM_STRENGTH

Added in API level 9

Virtualizer effect strength. Parameter ID for Virtualizer.OnParameterChangeListener

Constant Value: 1 (0x00000001)

public static final int PARAM_STRENGTH_SUPPORTED

Added in API level 9

Is strength parameter supported by virtualizer engine. Parameter ID for getParameter().

Constant Value: 0 (0x00000000)

Public Constructors

public Virtualizer (int priority, int audioSession)

Added in API level 9

Class constructor.

Parameters
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.
Throws
java.lang.IllegalStateException
java.lang.IllegalArgumentException
java.lang.UnsupportedOperationException
RuntimeException
IllegalStateException
IllegalArgumentException
UnsupportedOperationException

Public Methods

public Virtualizer.Settings getProperties ()

Added in API level 9

Gets the virtualizer properties. This method is useful when a snapshot of current virtualizer settings must be saved by the application.

Returns
  • a Virtualizer.Settings object containing all current parameters values

public short getRoundedStrength ()

Added in API level 9

Gets the current strength of the effect.

Returns
  • 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

public boolean getStrengthSupported ()

Added in API level 9

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.

Returns
  • true is strength parameter is supported, false otherwise

public void setParameterListener ( Virtualizer.OnParameterChangeListener listener)

Added in API level 9

Registers an OnParameterChangeListener interface.

Parameters
listener OnParameterChangeListener interface registered

public void setProperties ( Virtualizer.Settings settings)

Added in API level 9

Sets the virtualizer properties. This method is useful when virtualizer settings have to be applied from a previous backup.

Parameters
settings a Virtualizer.Settings object containing the properties to apply

public void setStrength (short strength)

Added in API level 9

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 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.