BassBoost


public class BassBoost
extends AudioEffect

java.lang.Object
   ↳ android.media.audiofx.AudioEffect
     ↳ android.media.audiofx.BassBoost


Bass boost is an audio effect to boost or amplify low frequencies of the sound. It is comparable to a simple equalizer but limited to one band amplification in the low frequency range.

An application creates a BassBoost object to instantiate and control a bass boost engine in the audio framework.

The methods, parameter types and units exposed by the BassBoost implementation are directly mapping those defined by the OpenSL ES 1.0.1 Specification (http://www.khronos.org/opensles/) for the SLBassBoostItf interface. Please refer to this specification for more details.

To attach the BassBoost to a particular AudioTrack or MediaPlayer, specify the audio session ID of this AudioTrack or MediaPlayer when constructing the BassBoost.

NOTE: attaching a BassBoost 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.

Summary

Nested classes

interface BassBoost.OnParameterChangeListener

The OnParameterChangeListener interface defines a method called by the BassBoost when a parameter value has changed. 

class BassBoost.Settings

The Settings class regroups all bass boost parameters. 

Constants

int PARAM_STRENGTH

Bass boost effect strength.

int PARAM_STRENGTH_SUPPORTED

Is strength parameter supported by bass boost engine.

Inherited constants

String ACTION_CLOSE_AUDIO_EFFECT_CONTROL_SESSION

Intent to signal to the effect control application or service that an audio session is closed and that effects should not be applied anymore.

String ACTION_DISPLAY_AUDIO_EFFECT_CONTROL_PANEL

Intent to launch an audio effect control panel UI.

String ACTION_OPEN_AUDIO_EFFECT_CONTROL_SESSION

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 ALREADY_EXISTS

Internal operation status.

int CONTENT_TYPE_GAME

Value for EXTRA_CONTENT_TYPE when the type of content played is game audio

int CONTENT_TYPE_MOVIE

Value for EXTRA_CONTENT_TYPE when the type of content played is video or movie

int CONTENT_TYPE_MUSIC

Value for EXTRA_CONTENT_TYPE when the type of content played is music

int CONTENT_TYPE_VOICE

Value for EXTRA_CONTENT_TYPE when the type of content played is voice audio

String EFFECT_AUXILIARY

Effect connection mode is auxiliary.

String EFFECT_INSERT

Effect connection mode is insert.

String EFFECT_POST_PROCESSING

Effect connection mode is post processing.

String EFFECT_PRE_PROCESSING

Effect connection mode is pre processing.

int ERROR

Unspecified error.

int ERROR_BAD_VALUE

Operation failed due to bad parameter value.

int ERROR_DEAD_OBJECT

Operation failed due to dead remote object.

int ERROR_INVALID_OPERATION

Operation failed because it was requested in wrong state.

int ERROR_NO_INIT

Operation failed due to bad object initialization.

int ERROR_NO_MEMORY

Operation failed due to lack of memory.

String EXTRA_AUDIO_SESSION

Contains the ID of the audio session the effects should be applied to.

String EXTRA_CONTENT_TYPE

Indicates which type of content is played by the application.

String EXTRA_PACKAGE_NAME

Contains the package name of the calling application.

int SUCCESS

Successful operation.

Inherited fields

public static final UUID EFFECT_TYPE_AEC

UUID for Acoustic Echo Canceler (AEC)

public static final UUID EFFECT_TYPE_AGC

UUID for Automatic Gain Control (AGC)

public static final UUID EFFECT_TYPE_BASS_BOOST

UUID for bass boost effect

public static final UUID EFFECT_TYPE_DYNAMICS_PROCESSING

UUID for Dynamics Processing

public static final UUID EFFECT_TYPE_ENV_REVERB

UUID for environmental reverberation effect

public static final UUID EFFECT_TYPE_EQUALIZER

UUID for equalizer effect

public static final UUID EFFECT_TYPE_HAPTIC_GENERATOR

UUID for Haptic Generator.

public static final UUID EFFECT_TYPE_LOUDNESS_ENHANCER

UUID for Loudness Enhancer

public static final UUID EFFECT_TYPE_NS

UUID for Noise Suppressor (NS)

public static final UUID EFFECT_TYPE_PRESET_REVERB

UUID for preset reverberation effect

public static final UUID EFFECT_TYPE_VIRTUALIZER

UUID for virtualizer effect

Public constructors

BassBoost(int priority, int audioSession)

Class constructor.

Public methods

BassBoost.Settings getProperties()

Gets the bass boost properties.

short getRoundedStrength()

Gets the current strength of the effect.

boolean getStrengthSupported()

Indicates whether setting strength is supported.

void setParameterListener(BassBoost.OnParameterChangeListener listener)

Registers an OnParameterChangeListener interface.

void setProperties(BassBoost.Settings settings)

Sets the bass boost properties.

void setStrength(short strength)

Sets the strength of the bass boost effect.

Inherited methods

void finalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

AudioEffect.Descriptor getDescriptor()

Get the effect descriptor.

boolean getEnabled()

Returns effect enabled state

int getId()

Returns effect unique identifier.

boolean hasControl()

Checks if this AudioEffect object is controlling the effect engine.

static Descriptor[] queryEffects()

Query all effects available on the platform.

void release()

Releases the native AudioEffect resources.

void setControlStatusListener(AudioEffect.OnControlStatusChangeListener listener)

Sets the listener AudioEffect notifies when the effect engine control is taken or returned.

void setEnableStatusListener(AudioEffect.OnEnableStatusChangeListener listener)

Sets the listener AudioEffect notifies when the effect engine is enabled or disabled.

int setEnabled(boolean enabled)

Enable or disable the effect.

Object clone()

Creates and returns a copy of this object.

boolean equals(Object obj)

Indicates whether some other object is "equal to" this one.

void finalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

final Class<?> getClass()

Returns the runtime class of this Object.

int hashCode()

Returns a hash code value for the object.

final void notify()

Wakes up a single thread that is waiting on this object's monitor.

final void notifyAll()

Wakes up all threads that are waiting on this object's monitor.

String toString()

Returns a string representation of the object.

final void wait(long timeoutMillis, int nanos)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait(long timeoutMillis)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait()

Causes the current thread to wait until it is awakened, typically by being notified or interrupted.

Constants

PARAM_STRENGTH

Added in API level 9
public static final int PARAM_STRENGTH

Bass boost effect strength. Parameter ID for BassBoost.OnParameterChangeListener

Constant Value: 1 (0x00000001)

PARAM_STRENGTH_SUPPORTED

Added in API level 9
public static final int PARAM_STRENGTH_SUPPORTED

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

Constant Value: 0 (0x00000000)

Public constructors

BassBoost

Added in API level 9
public BassBoost (int priority, 
                int audioSession)

Class constructor.

Parameters
priority int: the priority level requested by the application for controlling the BassBoost 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 BassBoost will be attached to the MediaPlayer or AudioTrack in the same audio session.

Throws
java.lang.IllegalStateException
java.lang.IllegalArgumentException
java.lang.UnsupportedOperationException
java.lang.RuntimeException
IllegalArgumentException
IllegalStateException
RuntimeException
UnsupportedOperationException

Public methods

getProperties

Added in API level 9
public BassBoost.Settings getProperties ()

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

Returns
BassBoost.Settings a BassBoost.Settings object containing all current parameters values

Throws
java.lang.IllegalStateException
java.lang.IllegalArgumentException
java.lang.UnsupportedOperationException
IllegalArgumentException
IllegalStateException
UnsupportedOperationException

getRoundedStrength

Added in API level 9
public short getRoundedStrength ()

Gets the current strength of the effect.

Returns
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

Throws
java.lang.IllegalStateException
java.lang.IllegalArgumentException
java.lang.UnsupportedOperationException
IllegalArgumentException
IllegalStateException
UnsupportedOperationException

getStrengthSupported

Added in API level 9
public boolean getStrengthSupported ()

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
boolean true is strength parameter is supported, false otherwise

setParameterListener

Added in API level 9
public void setParameterListener (BassBoost.OnParameterChangeListener listener)

Registers an OnParameterChangeListener interface.

Parameters
listener BassBoost.OnParameterChangeListener: OnParameterChangeListener interface registered

setProperties

Added in API level 9
public void setProperties (BassBoost.Settings settings)

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

Parameters
settings BassBoost.Settings: a BassBoost.Settings object containing the properties to apply

Throws
java.lang.IllegalStateException
java.lang.IllegalArgumentException
java.lang.UnsupportedOperationException
IllegalArgumentException
IllegalStateException
UnsupportedOperationException

setStrength

Added in API level 9
public void setStrength (short strength)

Sets the strength of the bass boost 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.

Throws
java.lang.IllegalStateException
java.lang.IllegalArgumentException
java.lang.UnsupportedOperationException
IllegalArgumentException
IllegalStateException
UnsupportedOperationException