to top
Android APIs
public class

EnvironmentalReverb

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

Class Overview

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 EnvironmentalReverb class allows an application to control each reverb engine property in a global reverb environment and is more suitable for games. For basic control, more suitable for music applications, it is recommended to use the PresetReverb class.

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

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

The EnvironmentalReverb 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 MODIFY_AUDIO_SETTINGS

See AudioEffect class for more details on controlling audio effects.

Summary

Nested Classes
interface EnvironmentalReverb.OnParameterChangeListener The OnParameterChangeListener interface defines a method called by the EnvironmentalReverb when a parameter value has changed. 
class EnvironmentalReverb.Settings The Settings class regroups all environmental reverb parameters. 
Constants
int PARAM_DECAY_HF_RATIO Decay HF ratio.
int PARAM_DECAY_TIME Decay time.
int PARAM_DENSITY Density.
int PARAM_DIFFUSION Diffusion.
int PARAM_REFLECTIONS_DELAY Early reflections delay.
int PARAM_REFLECTIONS_LEVEL Early reflections level.
int PARAM_REVERB_DELAY Reverb delay.
int PARAM_REVERB_LEVEL Reverb level.
int PARAM_ROOM_HF_LEVEL Room HF level.
int PARAM_ROOM_LEVEL Room level.
[Expand]
Inherited Constants
From class android.media.audiofx.AudioEffect
Public Constructors
EnvironmentalReverb(int priority, int audioSession)
Class constructor.
Public Methods
short getDecayHFRatio()
Gets the ratio of high frequency decay time (at 5 kHz) relative to low frequencies.
int getDecayTime()
Gets the decay time.
short getDensity()
Gets the density level.
short getDiffusion()
Gets diffusion level.
EnvironmentalReverb.Settings getProperties()
Gets the environmental reverb properties.
int getReflectionsDelay()
Gets the reflections delay.
short getReflectionsLevel()
Gets the volume level of the early reflections.
int getReverbDelay()
Gets the reverb delay.
short getReverbLevel()
Gets the reverb level.
short getRoomHFLevel()
Gets the room HF level.
short getRoomLevel()
Gets the master volume level of the environmental reverb effect.
void setDecayHFRatio(short decayHFRatio)
Sets the ratio of high frequency decay time (at 5 kHz) relative to the decay time at low frequencies.
void setDecayTime(int decayTime)
Sets the time taken for the level of reverberation to decay by 60 dB.
void setDensity(short density)
Controls the modal density of the late reverberation decay.
void setDiffusion(short diffusion)
Sets the echo density in the late reverberation decay.
void setParameterListener(EnvironmentalReverb.OnParameterChangeListener listener)
Registers an OnParameterChangeListener interface.
void setProperties(EnvironmentalReverb.Settings settings)
Sets the environmental reverb properties.
void setReflectionsDelay(int reflectionsDelay)
Sets the delay time for the early reflections.
void setReflectionsLevel(short reflectionsLevel)
Sets the volume level of the early reflections.
void setReverbDelay(int reverbDelay)
Sets the time between the first reflection and the reverberation.
void setReverbLevel(short reverbLevel)
Sets the volume level of the late reverberation.
void setRoomHFLevel(short roomHF)
Sets the volume level at 5 kHz relative to the volume level at low frequencies of the overall reverb effect.
void setRoomLevel(short room)
Sets the master volume level of the environmental reverb effect.
[Expand]
Inherited Methods
From class android.media.audiofx.AudioEffect
From class java.lang.Object

Constants

public static final int PARAM_DECAY_HF_RATIO

Added in API level 9

Decay HF ratio. Parameter ID for EnvironmentalReverb.OnParameterChangeListener

Constant Value: 3 (0x00000003)

public static final int PARAM_DECAY_TIME

Added in API level 9

Decay time. Parameter ID for OnParameterChangeListener

Constant Value: 2 (0x00000002)

public static final int PARAM_DENSITY

Added in API level 9

Density. Parameter ID for OnParameterChangeListener

Constant Value: 9 (0x00000009)

public static final int PARAM_DIFFUSION

Added in API level 9

Diffusion. Parameter ID for OnParameterChangeListener

Constant Value: 8 (0x00000008)

public static final int PARAM_REFLECTIONS_DELAY

Added in API level 9

Early reflections delay. Parameter ID for OnParameterChangeListener

Constant Value: 5 (0x00000005)

public static final int PARAM_REFLECTIONS_LEVEL

Added in API level 9

Early reflections level. Parameter ID for OnParameterChangeListener

Constant Value: 4 (0x00000004)

public static final int PARAM_REVERB_DELAY

Added in API level 9

Reverb delay. Parameter ID for OnParameterChangeListener

Constant Value: 7 (0x00000007)

public static final int PARAM_REVERB_LEVEL

Added in API level 9

Reverb level. Parameter ID for OnParameterChangeListener

Constant Value: 6 (0x00000006)

public static final int PARAM_ROOM_HF_LEVEL

Added in API level 9

Room HF level. Parameter ID for OnParameterChangeListener

Constant Value: 1 (0x00000001)

public static final int PARAM_ROOM_LEVEL

Added in API level 9

Room level. Parameter ID for OnParameterChangeListener

Constant Value: 0 (0x00000000)

Public Constructors

public EnvironmentalReverb (int priority, int audioSession)

Added in API level 9

Class constructor.

Parameters
priority the priority level requested by the application for controlling the EnvironmentalReverb 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. If audioSession is not 0, the EnvironmentalReverb will be attached to the MediaPlayer or AudioTrack in the same audio session. Otherwise, the EnvironmentalReverb will apply to the output mix. As the EnvironmentalReverb 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
RuntimeException
IllegalArgumentException
UnsupportedOperationException

Public Methods

public short getDecayHFRatio ()

Added in API level 9

Gets the ratio of high frequency decay time (at 5 kHz) relative to low frequencies.

Returns
Throws
IllegalStateException
IllegalArgumentException
UnsupportedOperationException
IllegalStateException
IllegalArgumentException

public int getDecayTime ()

Added in API level 9

Gets the decay time.

Returns
  • the decay time in milliseconds.
Throws
IllegalStateException
IllegalArgumentException
UnsupportedOperationException
IllegalStateException
IllegalArgumentException

public short getDensity ()

Added in API level 9

Gets the density level.

Returns
Throws
IllegalStateException
IllegalArgumentException
UnsupportedOperationException
IllegalStateException
IllegalArgumentException

public short getDiffusion ()

Added in API level 9

Gets diffusion level.

Returns
Throws
IllegalStateException
IllegalArgumentException
UnsupportedOperationException
IllegalStateException
IllegalArgumentException

public EnvironmentalReverb.Settings getProperties ()

Added in API level 9

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

Returns
  • an EnvironmentalReverb.Settings object containing all current parameters values
Throws
IllegalStateException
IllegalArgumentException
UnsupportedOperationException
IllegalStateException
IllegalArgumentException

public int getReflectionsDelay ()

Added in API level 9

Gets the reflections delay.

Returns
  • the early reflections delay in milliseconds.
Throws
IllegalStateException
IllegalArgumentException
UnsupportedOperationException
IllegalStateException
IllegalArgumentException

public short getReflectionsLevel ()

Added in API level 9

Gets the volume level of the early reflections.

Returns
  • the early reflections level in millibels.
Throws
IllegalStateException
IllegalArgumentException
UnsupportedOperationException
IllegalStateException
IllegalArgumentException

public int getReverbDelay ()

Added in API level 9

Gets the reverb delay.

Returns
  • the reverb delay in milliseconds.
Throws
IllegalStateException
IllegalArgumentException
UnsupportedOperationException
IllegalStateException
IllegalArgumentException

public short getReverbLevel ()

Added in API level 9

Gets the reverb level.

Returns
  • the reverb level in millibels.
Throws
IllegalStateException
IllegalArgumentException
UnsupportedOperationException
IllegalStateException
IllegalArgumentException

public short getRoomHFLevel ()

Added in API level 9

Gets the room HF level.

Returns
  • the room HF level in millibels.
Throws
IllegalStateException
IllegalArgumentException
UnsupportedOperationException
IllegalStateException
IllegalArgumentException

public short getRoomLevel ()

Added in API level 9

Gets the master volume level of the environmental reverb effect.

Returns
  • the room level in millibels.
Throws
IllegalStateException
IllegalArgumentException
UnsupportedOperationException
IllegalStateException
IllegalArgumentException

public void setDecayHFRatio (short decayHFRatio)

Added in API level 9

Sets the ratio of high frequency decay time (at 5 kHz) relative to the decay time at low frequencies.

Parameters
decayHFRatio high frequency decay ratio using a permille scale. The valid range is [100, 2000]. A ratio of 1000 indicates that all frequencies decay at the same rate.
Throws
IllegalStateException
IllegalArgumentException
UnsupportedOperationException
IllegalStateException
IllegalArgumentException

public void setDecayTime (int decayTime)

Added in API level 9

Sets the time taken for the level of reverberation to decay by 60 dB.

Parameters
decayTime decay time in milliseconds. The valid range is [100, 20000].
Throws
IllegalStateException
IllegalArgumentException
UnsupportedOperationException
IllegalStateException
IllegalArgumentException

public void setDensity (short density)

Added in API level 9

Controls the modal density of the late reverberation decay.

The scale should approximately map linearly to the perceived change in reverberation. A lower density creates a hollow sound that is useful for simulating small reverberation spaces such as bathrooms.

Parameters
density density specified using a permille scale. The valid range is [0, 1000]. A value of 1000 o/oo indicates a natural sounding reverberation. Values below this level produce a more colored effect.
Throws
IllegalStateException
IllegalArgumentException
UnsupportedOperationException
IllegalStateException
IllegalArgumentException

public void setDiffusion (short diffusion)

Added in API level 9

Sets the echo density in the late reverberation decay.

The scale should approximately map linearly to the perceived change in reverberation.

Parameters
diffusion diffusion specified using a permille scale. The diffusion valid range is [0, 1000]. A value of 1000 o/oo indicates a smooth reverberation decay. Values below this level give a more grainy character.
Throws
IllegalStateException
IllegalArgumentException
UnsupportedOperationException
IllegalStateException
IllegalArgumentException

public void setParameterListener (EnvironmentalReverb.OnParameterChangeListener listener)

Added in API level 9

Registers an OnParameterChangeListener interface.

Parameters
listener OnParameterChangeListener interface registered

public void setProperties (EnvironmentalReverb.Settings settings)

Added in API level 9

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

Parameters
settings a EnvironmentalReverb.Settings object containing the properties to apply
Throws
IllegalStateException
IllegalArgumentException
UnsupportedOperationException
IllegalStateException
IllegalArgumentException

public void setReflectionsDelay (int reflectionsDelay)

Added in API level 9

Sets the delay time for the early reflections.

This method sets the time between when the direct path is heard and when the first reflection is heard.

Parameters
reflectionsDelay reflections delay in milliseconds. The valid range is [0, 300].
Throws
IllegalStateException
IllegalArgumentException
UnsupportedOperationException
IllegalStateException
IllegalArgumentException

public void setReflectionsLevel (short reflectionsLevel)

Added in API level 9

Sets the volume level of the early reflections.

This level is combined with the overall room level (set using setRoomLevel(short)).

Parameters
reflectionsLevel reflection level in millibels. The valid range is [-9000, 1000].
Throws
IllegalStateException
IllegalArgumentException
UnsupportedOperationException
IllegalStateException
IllegalArgumentException

public void setReverbDelay (int reverbDelay)

Added in API level 9

Sets the time between the first reflection and the reverberation.

Parameters
reverbDelay reverb delay in milliseconds. The valid range is [0, 100].
Throws
IllegalStateException
IllegalArgumentException
UnsupportedOperationException
IllegalStateException
IllegalArgumentException

public void setReverbLevel (short reverbLevel)

Added in API level 9

Sets the volume level of the late reverberation.

This level is combined with the overall room level (set using setRoomLevel(short)).

Parameters
reverbLevel reverb level in millibels. The valid range is [-9000, 2000].
Throws
IllegalStateException
IllegalArgumentException
UnsupportedOperationException
IllegalStateException
IllegalArgumentException

public void setRoomHFLevel (short roomHF)

Added in API level 9

Sets the volume level at 5 kHz relative to the volume level at low frequencies of the overall reverb effect.

This controls a low-pass filter that will reduce the level of the high-frequency.

Parameters
roomHF high frequency attenuation level in millibels. The valid range is [-9000, 0].
Throws
IllegalStateException
IllegalArgumentException
UnsupportedOperationException
IllegalStateException
IllegalArgumentException

public void setRoomLevel (short room)

Added in API level 9

Sets the master volume level of the environmental reverb effect.

Parameters
room room level in millibels. The valid range is [-9000, 0].
Throws
IllegalStateException
IllegalArgumentException
UnsupportedOperationException
IllegalStateException
IllegalArgumentException