PresetReverb
open class PresetReverb : AudioEffect
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 android.media.audiofx.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 android.Manifest.permission#MODIFY_AUDIO_SETTINGS
See android.media.audiofx.AudioEffect class for more details on controlling audio effects.
Summary
| Nested classes |
| abstract |
The OnParameterChangeListener interface defines a method called by the PresetReverb when a parameter value has changed.
|
| open |
The Settings class regroups all preset reverb parameters.
|
| Constants |
| static Int |
Preset.
|
| static Short |
Reverb preset representing a large-sized hall suitable for a full orchestra
|
| static Short |
Reverb preset representing a large-sized room suitable for live performances
|
| static Short |
Reverb preset representing a medium-sized hall
|
| static Short |
Reverb preset representing a medium room with a length of ten meters or less
|
| static Short |
No reverb or reflections
|
| static Short |
Reverb preset representing a synthesis of the traditional plate reverb
|
| static Short |
Reverb preset representing a small room less than five meters in length
|
| Inherited constants |
From class AudioEffect
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.
The effect control application receiving this intent will delete all effects on this session and store current settings in package specific storage.
The calling package name is indicated by the EXTRA_PACKAGE_NAME extra and the audio session ID by the EXTRA_AUDIO_SESSION extra. Both extras are mandatory.
It is good practice for applications to broadcast this intent when music playback stops and/or when exiting to free system resources consumed by audio effect engines.
|
String |
ACTION_DISPLAY_AUDIO_EFFECT_CONTROL_PANEL
Intent to launch an audio effect control panel UI.
The goal of this intent is to enable separate implementations of music/media player applications and audio effect control application or services. This will allow platform vendors to offer more advanced control options for standard effects or control for platform specific effects.
The intent carries a number of extras used by the player application to communicate necessary pieces of information to the control panel application.
The calling application must use the android.app.Activity#startActivityForResult(Intent, int) method to launch the control panel so that its package name is indicated and used by the control panel application to keep track of changes for this particular application.
The EXTRA_AUDIO_SESSION extra will indicate an audio session to which the audio effects should be applied. If no audio session is specified, either one of the follownig will happen:
- If an audio session was previously opened by the calling application with ACTION_OPEN_AUDIO_EFFECT_CONTROL_SESSION intent, the effect changes will be applied to that session.
- If no audio session is opened, the changes will be stored in the package specific storage area and applied whenever a new audio session is opened by this application.
The EXTRA_CONTENT_TYPE extra will help the control panel application customize both the UI layout and the default audio effect settings if none are already stored for the calling application.
|
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.
This is different from ACTION_DISPLAY_AUDIO_EFFECT_CONTROL_PANEL in that no UI should be displayed in this case. Music player applications can broadcast this intent before starting playback to make sure that any audio effect settings previously selected by the user are applied.
The effect control application receiving this intent will look for previously stored settings for the calling application, create all required audio effects and apply the effect settings to the specified audio session.
The calling package name is indicated by the EXTRA_PACKAGE_NAME extra and the audio session ID by the EXTRA_AUDIO_SESSION extra. Both extras are mandatory.
If no stored settings are found for the calling application, default settings for the content type indicated by EXTRA_CONTENT_TYPE will be applied. The default settings for a given content type are platform specific.
|
Int |
ALREADY_EXISTS
Internal operation status. Not returned by any method.
|
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.
Auxiliary effects must be created on session 0 (global output mix). In order for a MediaPlayer or AudioTrack to be fed into this effect, they must be explicitely attached to this effect and a send level must be specified.
Use the effect ID returned by getId() to designate this particular effect when attaching it to the MediaPlayer or AudioTrack.
|
String |
EFFECT_INSERT
Effect connection mode is insert. Specifying an audio session ID when creating the effect will insert this effect after all players in the same audio session.
|
String |
EFFECT_POST_PROCESSING
Effect connection mode is post processing. The audio post processing effects are attached to an audio output stream or device
|
String |
EFFECT_PRE_PROCESSING
Effect connection mode is pre processing. The audio pre processing effects are attached to an audio input stream or device
|
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.
This extra is for use with ACTION_DISPLAY_AUDIO_EFFECT_CONTROL_PANEL, ACTION_OPEN_AUDIO_EFFECT_CONTROL_SESSION and ACTION_CLOSE_AUDIO_EFFECT_CONTROL_SESSION intents.
The extra value is of type int and is the audio session ID.
|
String |
EXTRA_CONTENT_TYPE
Indicates which type of content is played by the application.
This extra is for use with ACTION_DISPLAY_AUDIO_EFFECT_CONTROL_PANEL and ACTION_OPEN_AUDIO_EFFECT_CONTROL_SESSION intents.
This information is used by the effect control application to customize UI and select appropriate default effect settings. The content type is one of the following:
If omitted, the content type defaults to CONTENT_TYPE_MUSIC.
|
String |
EXTRA_PACKAGE_NAME
Contains the package name of the calling application.
This extra is for use with ACTION_OPEN_AUDIO_EFFECT_CONTROL_SESSION and ACTION_CLOSE_AUDIO_EFFECT_CONTROL_SESSION intents.
The extra value is a string containing the full package name.
|
Int |
SUCCESS
Successful operation.
|
|
| Public constructors |
|
Class constructor.
|
| Public methods |
| open Short |
Gets current reverb preset.
|
| open PresetReverb.Settings! |
Gets the preset reverb properties.
|
| open Unit |
Registers an OnParameterChangeListener interface.
|
| open Unit |
Enables a preset on the reverb.
|
| open Unit |
Sets the preset reverb properties.
|
| Inherited functions |
From class AudioEffect
Unit |
finalize()
Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. A subclass overrides the finalize method to dispose of system resources or to perform other cleanup.
The general contract of finalize is that it is invoked if and when the Java virtual machine has determined that there is no longer any means by which this object can be accessed by any thread that has not yet died, except as a result of an action taken by the finalization of some other object or class which is ready to be finalized. The finalize method may take any action, including making this object available again to other threads; the usual purpose of finalize, however, is to perform cleanup actions before the object is irrevocably discarded. For example, the finalize method for an object that represents an input/output connection might perform explicit I/O transactions to break the connection before the object is permanently discarded.
The finalize method of class Object performs no special action; it simply returns normally. Subclasses of Object may override this definition.
The Java programming language does not guarantee which thread will invoke the finalize method for any given object. It is guaranteed, however, that the thread that invokes finalize will not be holding any user-visible synchronization locks when finalize is invoked. If an uncaught exception is thrown by the finalize method, the exception is ignored and finalization of that object terminates.
After the finalize method has been invoked for an object, no further action is taken until the Java virtual machine has again determined that there is no longer any means by which this object can be accessed by any thread that has not yet died, including possible actions by other objects or classes which are ready to be finalized, at which point the object may be discarded.
The finalize method is never invoked more than once by a Java virtual machine for any given object.
Any exception thrown by the finalize method causes the finalization of this object to be halted, but is otherwise ignored.
|
AudioEffect.Descriptor! |
getDescriptor()
Get the effect descriptor.
|
Boolean |
getEnabled()
Returns effect enabled state
|
Int |
getId()
Returns effect unique identifier. This system wide unique identifier can be used to attach this effect to a MediaPlayer or an AudioTrack when the effect is an auxiliary effect (Reverb)
|
Boolean |
hasControl()
Checks if this AudioEffect object is controlling the effect engine.
|
Array<AudioEffect.Descriptor!>! |
queryEffects()
Query all effects available on the platform. Returns an array of android.media.audiofx.AudioEffect.Descriptor objects
|
Unit |
release()
Releases the native AudioEffect resources. It is a good practice to release the effect engine when not in use as control can be returned to other applications or the native resources released.
|
Unit |
setControlStatusListener(listener: AudioEffect.OnControlStatusChangeListener!)
Sets the listener AudioEffect notifies when the effect engine control is taken or returned.
|
Unit |
setEnableStatusListener(listener: AudioEffect.OnEnableStatusChangeListener!)
Sets the listener AudioEffect notifies when the effect engine is enabled or disabled.
|
Int |
setEnabled(enabled: Boolean)
Enable or disable the effect. Creating an audio effect does not automatically apply this effect on the audio source. It creates the resources necessary to process this effect but the audio signal is still bypassed through the effect engine. Calling this method will make that the effect is actually applied or not to the audio content being played in the corresponding audio session.
|
|
Constants
PRESET_LARGEHALL
static val PRESET_LARGEHALL: Short
Reverb preset representing a large-sized hall suitable for a full orchestra
Value: 5
PRESET_LARGEROOM
static val PRESET_LARGEROOM: Short
Reverb preset representing a large-sized room suitable for live performances
Value: 3
PRESET_MEDIUMHALL
static val PRESET_MEDIUMHALL: Short
Reverb preset representing a medium-sized hall
Value: 4
PRESET_MEDIUMROOM
static val PRESET_MEDIUMROOM: Short
Reverb preset representing a medium room with a length of ten meters or less
Value: 2
PRESET_NONE
static val PRESET_NONE: Short
No reverb or reflections
Value: 0
PRESET_PLATE
static val PRESET_PLATE: Short
Reverb preset representing a synthesis of the traditional plate reverb
Value: 6
PRESET_SMALLROOM
static val PRESET_SMALLROOM: Short
Reverb preset representing a small room less than five meters in length
Value: 1
Public constructors
PresetReverb
PresetReverb(
priority: Int,
audioSession: Int)
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. |
| Exceptions |
java.lang.IllegalArgumentException |
|
java.lang.RuntimeException |
|
java.lang.UnsupportedOperationException |
|
Public methods
getPreset
open fun getPreset(): Short
Gets current reverb preset.
| Return |
Short |
the preset that is set at the moment. |
| Exceptions |
java.lang.IllegalArgumentException |
|
java.lang.IllegalStateException |
|
java.lang.UnsupportedOperationException |
|
getProperties
open fun getProperties(): PresetReverb.Settings!
Gets the preset reverb properties. This method is useful when a snapshot of current preset reverb settings must be saved by the application.
| Exceptions |
java.lang.IllegalArgumentException |
|
java.lang.IllegalStateException |
|
java.lang.UnsupportedOperationException |
|
setPreset
open fun setPreset(preset: Short): Unit
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 |
| Exceptions |
java.lang.IllegalArgumentException |
|
java.lang.IllegalStateException |
|
java.lang.UnsupportedOperationException |
|
setProperties
open fun setProperties(settings: PresetReverb.Settings!): Unit
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 |
| Exceptions |
java.lang.IllegalArgumentException |
|
java.lang.IllegalStateException |
|
java.lang.UnsupportedOperationException |
|