HapticGenerator
public
class
HapticGenerator
Haptic Generator(HG).
HG is an audio post-processor which generates haptic data based on the audio channels. The
generated haptic data is sent along with audio data down to the audio HAL, which will require the
device to support audio-coupled-haptic playback. In that case, the effect will only be created on
device supporting audio-coupled-haptic playback. Call
An application can create a HapticGenerator object to initiate and control this audio effect
in the audio framework.
To attach the HapticGenerator to a particular AudioTrack or MediaPlayer, specify the audio
session ID of this AudioTrack or MediaPlayer when constructing the HapticGenerator.
See
See
Summary
Inherited constants
Intent to signal to the effect control application or service that an audio session
is closed and that effects should not be applied anymore.
Intent to launch an audio effect control panel UI.
Intent to signal to the effect control application or service that a new audio session
is opened and requires audio effects to be applied.
int
Internal operation status.
int
Value for
int
Value for
int
Value for
int
Value for
Effect connection mode is auxiliary.
Effect connection mode is insert.
Effect connection mode is post processing.
Effect connection mode is pre processing.
int
Unspecified error.
int
Operation failed due to bad parameter value.
int
Operation failed due to dead remote object.
int
Operation failed because it was requested in wrong state.
int
Operation failed due to bad object initialization.
int
Operation failed due to lack of memory.
Contains the ID of the audio session the effects should be applied to.
Indicates which type of content is played by the application.
Contains the package name of the calling application.
int
Successful operation.
Inherited fields
public
static
final
UUID
UUID for Acoustic Echo Canceler (AEC)
public
static
final
UUID
UUID for Automatic Gain Control (AGC)
public
static
final
UUID
UUID for bass boost effect
public
static
final
UUID
public
static
final
UUID
UUID for environmental reverberation effect
public
static
final
UUID
UUID for equalizer effect
public
static
final
UUID
public
static
final
UUID
public
static
final
UUID
UUID for Noise Suppressor (NS)
public
static
final
UUID
UUID for preset reverberation effect
public
static
final
UUID
UUID for virtualizer effect
Public methods
void
Release the resources that are held by the effect.
create(int audioSession)
Creates a HapticGenerator and attaches it to the given audio session.
static
boolean
void
Releases the native AudioEffect resources.
int
setEnabled(boolean enabled)
Enable or disable the effect.
Inherited methods
void
Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.
boolean
Returns effect enabled state
int
Returns effect unique identifier.
boolean
Checks if this AudioEffect object is controlling the effect engine.
Query all effects available on the platform.
void
Releases the native AudioEffect resources.
void
Sets the listener AudioEffect notifies when the effect engine control is
taken or returned.
void
Sets the listener AudioEffect notifies when the effect engine is enabled
or disabled.
int
setEnabled(boolean enabled)
Enable or disable the effect.
Creates and returns a copy of this object.
boolean
Indicates whether some other object is "equal to" this one.
void
Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.
final
Class>
Returns the runtime class of this Object.
int
Returns a hash code value for the object.
final
void
Wakes up a single thread that is waiting on this object's
monitor.
final
void
Wakes up all threads that are waiting on this object's monitor.
Returns a string representation of the object.
final
void
wait(long timeout, int nanos)
Causes the current thread to wait until another thread invokes the
final
void
wait(long timeout)
Causes the current thread to wait until either another thread invokes the
final
void
Causes the current thread to wait until another thread invokes the
abstract
void
Closes this resource, relinquishing any underlying resources.
Public methods
close
public void close ()
Release the resources that are held by the effect.
create
public static HapticGenerator create (int audioSession)
Creates a HapticGenerator and attaches it to the given audio session.
Use
Parameters
audioSession
int: system wide unique audio session identifier. The HapticGenerator will be
applied to the players with the same audio session.
Returns
HapticGenerator created or null if the device does not support HapticGenerator or
the audio session is invalid.
Throws
when HapticGenerator is not supported
when the effect library is not loaded.
for all other error
isAvailable
public static boolean isAvailable ()
Returns
boolean
true if the HapticGenerator is available on the device.
release
public void release ()
Releases the native AudioEffect resources.
setEnabled
public int setEnabled (boolean enabled)
Enable or disable the effect.
Parameters
enabled
boolean: the requested enable state