PresetReverb


public class PresetReverb
extends AudioEffect

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


A sound generated within a room travels in many directions. The listener first hears the direct sound from the source itself. Later, he or she hears discrete echoes caused by sound bouncing off nearby walls, the ceiling and the floor. As sound waves arrive after undergoing more and more reflections, individual reflections become indistinguishable and the listener hears continuous reverberation that decays over time. Reverb is vital for modeling a listener's environment. It can be used in music applications to simulate music being played back in various environments, or in games to immerse the listener within the game's environment. The PresetReverb class allows an application to configure the global reverb using a reverb preset. This is primarily used for adding some reverb in a music playback context. Applications requiring control over a more advanced environmental reverb are advised to use the EnvironmentalReverb class.

An application creates a PresetReverb object to instantiate and control a reverb engine in the audio framework.

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

The PresetReverb is an output mix auxiliary effect and should be created on Audio session 0. In order for a MediaPlayer or AudioTrack to be fed into this effect, they must be explicitely attached to it and a send level must be specified. Use the effect ID returned by getId() method to designate this particular effect when attaching it to the MediaPlayer or AudioTrack.

Creating a reverb on the output mix (audio session 0) requires permission Manifest.permission.MODIFY_AUDIO_SETTINGS

See AudioEffect class for more details on controlling audio effects.

Summary

Nested classes

interface PresetReverb.OnParameterChangeListener

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

class PresetReverb.Settings

The Settings class regroups all preset reverb parameters. 

Constants

int PARAM_PRESET

Preset.

short PRESET_LARGEHALL

Reverb preset representing a large-sized hall suitable for a full orchestra

short PRESET_LARGEROOM

Reverb preset representing a large-sized room suitable for live performances

short PRESET_MEDIUMHALL

Reverb preset representing a medium-sized hall

short PRESET_MEDIUMROOM

Reverb preset representing a medium room with a length of ten meters or less

short PRESET_NONE

No reverb or reflections

short PRESET_PLATE

Reverb preset representing a synthesis of the traditional plate reverb

short PRESET_SMALLROOM

Reverb preset representing a small room less than five meters in length

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

PresetReverb(int priority, int audioSession)

Class constructor.

Public methods

short getPreset()

Gets current reverb preset.

PresetReverb.Settings getProperties()

Gets the preset reverb properties.

void setParameterListener(PresetReverb.OnParameterChangeListener listener)

Registers an OnParameterChangeListener interface.

void setPreset(short preset)

Enables a preset on the reverb.

void setProperties(PresetReverb.Settings settings)

Sets the preset reverb properties.

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_PRESET

Added in API level 9
public static final int PARAM_PRESET

Preset. Parameter ID for PresetReverb.OnParameterChangeListener

Constant Value: 0 (0x00000000)

PRESET_LARGEHALL

Added in API level 9
public static final short PRESET_LARGEHALL

Reverb preset representing a large-sized hall suitable for a full orchestra

Constant Value: 5 (0x00000005)

PRESET_LARGEROOM

Added in API level 9
public static final short PRESET_LARGEROOM

Reverb preset representing a large-sized room suitable for live performances

Constant Value: 3 (0x00000003)

PRESET_MEDIUMHALL

Added in API level 9
public static final short PRESET_MEDIUMHALL

Reverb preset representing a medium-sized hall

Constant Value: 4 (0x00000004)

PRESET_MEDIUMROOM

Added in API level 9
public static final short PRESET_MEDIUMROOM

Reverb preset representing a medium room with a length of ten meters or less

Constant Value: 2 (0x00000002)

PRESET_NONE

Added in API level 9
public static final short PRESET_NONE

No reverb or reflections

Constant Value: 0 (0x00000000)

PRESET_PLATE

Added in API level 9
public static final short PRESET_PLATE

Reverb preset representing a synthesis of the traditional plate reverb

Constant Value: 6 (0x00000006)

PRESET_SMALLROOM

Added in API level 9
public static final short PRESET_SMALLROOM

Reverb preset representing a small room less than five meters in length

Constant Value: 1 (0x00000001)

Public constructors

PresetReverb

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

Class constructor.

Parameters
priority int: the priority level requested by the application for controlling the PresetReverb 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. If audioSession is not 0, the PresetReverb will be attached to the MediaPlayer or AudioTrack in the same audio session. Otherwise, the PresetReverb will apply to the output mix. As the PresetReverb is an auxiliary effect it is recommended to instantiate it on audio session 0 and to attach it to the MediaPLayer auxiliary output.

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

Public methods

getPreset

Added in API level 9
public short getPreset ()

Gets current reverb preset.

Returns
short the preset that is set at the moment.

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

getProperties

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

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

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

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

setParameterListener

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

Registers an OnParameterChangeListener interface.

Parameters
listener PresetReverb.OnParameterChangeListener: OnParameterChangeListener interface registered

setPreset

Added in API level 9
public void setPreset (short preset)

Enables a preset on the reverb.

The reverb PRESET_NONE disables any reverb from the current output but does not free the resources associated with the reverb. For an application to signal to the implementation to free the resources, it must call the release() method.

Parameters
preset short: this must be one of the the preset constants defined in this class. e.g. PRESET_SMALLROOM

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

setProperties

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

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

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

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