IT. Expert System.

Android Reference

AudioEffect


android.media.audiofx

Class AudioEffect

  • Direct Known Subclasses:
    AcousticEchoCanceler, AutomaticGainControl, BassBoost, EnvironmentalReverb, Equalizer, NoiseSuppressor, PresetReverb, Virtualizer


    public class AudioEffect
    extends Object
    AudioEffect is the base class for controlling audio effects provided by the android audio framework.

    Applications should not use the AudioEffect class directly but one of its derived classes to control specific effects:

    To apply the audio effect to a specific AudioTrack or MediaPlayer instance, the application must specify the audio session ID of that instance when creating the AudioEffect. (see MediaPlayer.getAudioSessionId() for details on audio sessions).

    NOTE: attaching insert effects (equalizer, bass boost, virtualizer) to the global audio output mix by use of session 0 is deprecated.

    Creating an AudioEffect object will create the corresponding effect engine in the audio framework if no instance of the same effect type exists in the specified audio session. If one exists, this instance will be used.

    The application creating the AudioEffect object (or a derived class) will either receive control of the effect engine or not depending on the priority parameter. If priority is higher than the priority used by the current effect engine owner, the control will be transfered to the new object. Otherwise control will remain with the previous object. In this case, the new application will be notified of changes in effect engine state or control ownership by the appropiate listener.

    • Field Detail

      • EFFECT_TYPE_ENV_REVERB

        public static final UUID EFFECT_TYPE_ENV_REVERB
        UUID for environmental reverb effect
      • EFFECT_TYPE_PRESET_REVERB

        public static final UUID EFFECT_TYPE_PRESET_REVERB
        UUID for preset reverb effect
      • EFFECT_TYPE_EQUALIZER

        public static final UUID EFFECT_TYPE_EQUALIZER
        UUID for equalizer effect
      • EFFECT_TYPE_BASS_BOOST

        public static final UUID EFFECT_TYPE_BASS_BOOST
        UUID for bass boost effect
      • EFFECT_TYPE_VIRTUALIZER

        public static final UUID EFFECT_TYPE_VIRTUALIZER
        UUID for virtualizer effect
      • EFFECT_TYPE_AGC

        public static final UUID EFFECT_TYPE_AGC
        UUID for Automatic Gain Control (AGC) audio pre-processing
      • EFFECT_TYPE_AEC

        public static final UUID EFFECT_TYPE_AEC
        UUID for Acoustic Echo Canceler (AEC) audio pre-processing
      • EFFECT_TYPE_NS

        public static final UUID EFFECT_TYPE_NS
        UUID for Noise Suppressor (NS) audio pre-processing
      • EFFECT_TYPE_NULL

        public static final UUID EFFECT_TYPE_NULL
        Null effect UUID. Used when the UUID for effect type of
      • STATE_UNINITIALIZED

        public static final int STATE_UNINITIALIZED
        State of an AudioEffect object that was not successfully initialized upon creation
        See Also:
        Constant Field Values
      • STATE_INITIALIZED

        public static final int STATE_INITIALIZED
        State of an AudioEffect object that is ready to be used.
        See Also:
        Constant Field Values
      • NATIVE_EVENT_CONTROL_STATUS

        public static final int NATIVE_EVENT_CONTROL_STATUS
        Event id for engine control ownership change notification.
        See Also:
        Constant Field Values
      • NATIVE_EVENT_ENABLED_STATUS

        public static final int NATIVE_EVENT_ENABLED_STATUS
        Event id for engine state change notification.
        See Also:
        Constant Field Values
      • NATIVE_EVENT_PARAMETER_CHANGED

        public static final int NATIVE_EVENT_PARAMETER_CHANGED
        Event id for engine parameter change notification.
        See Also:
        Constant Field Values
      • ALREADY_EXISTS

        public static final int ALREADY_EXISTS
        Internal operation status. Not returned by any method.
        See Also:
        Constant Field Values
      • ERROR_NO_INIT

        public static final int ERROR_NO_INIT
        Operation failed due to bad object initialization.
        See Also:
        Constant Field Values
      • ERROR_BAD_VALUE

        public static final int ERROR_BAD_VALUE
        Operation failed due to bad parameter value.
        See Also:
        Constant Field Values
      • ERROR_INVALID_OPERATION

        public static final int ERROR_INVALID_OPERATION
        Operation failed because it was requested in wrong state.
        See Also:
        Constant Field Values
      • ERROR_NO_MEMORY

        public static final int ERROR_NO_MEMORY
        Operation failed due to lack of memory.
        See Also:
        Constant Field Values
      • ERROR_DEAD_OBJECT

        public static final int ERROR_DEAD_OBJECT
        Operation failed due to dead remote object.
        See Also:
        Constant Field Values
      • EFFECT_INSERT

        public static final 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.
        See Also:
        Constant Field Values
      • EFFECT_AUXILIARY

        public static final 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.

        See Also:
        Constant Field Values
      • EFFECT_PRE_PROCESSING

        public static final String EFFECT_PRE_PROCESSING
        Effect connection mode is pre processing. The audio pre processing effects are attached to an audio input (AudioRecord).
        See Also:
        Constant Field Values
      • mListenerLock

        public final Object mListenerLock
        Lock to protect listeners updates against event notifications
      • mNativeEventHandler

        public android.media.audiofx.AudioEffect.NativeEventHandler mNativeEventHandler
        Handler for events coming from the native code
      • ACTION_DISPLAY_AUDIO_EFFECT_CONTROL_PANEL

        public static final 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 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.

        See Also:
        Constant Field Values
      • ACTION_OPEN_AUDIO_EFFECT_CONTROL_SESSION

        public static final 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.

        See Also:
        Constant Field Values
      • ACTION_CLOSE_AUDIO_EFFECT_CONTROL_SESSION

        public static final 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.

        See Also:
        Constant Field Values
    • Constructor Detail

      • AudioEffect

        public AudioEffect(UUID type,
                   UUID uuid,
                   int priority,
                   int audioSession)
                    throws IllegalArgumentException,
                           UnsupportedOperationException,
                           RuntimeException
        Class constructor.
        Parameters:
        type - type of effect engine created. See EFFECT_TYPE_ENV_REVERB, EFFECT_TYPE_EQUALIZER ... Types corresponding to built-in effects are defined by AudioEffect class. Other types can be specified provided they correspond an existing OpenSL ES interface ID and the corresponsing effect is available on the platform. If an unspecified effect type is requested, the constructor with throw the IllegalArgumentException. This parameter can be set to EFFECT_TYPE_NULL in which case only the uuid will be used to select the effect.
        uuid - unique identifier of a particular effect implementation. Must be specified if the caller wants to use a particular implementation of an effect type. This parameter can be set to EFFECT_TYPE_NULL in which case only the type will be used to select the effect.
        priority - the priority level requested by the application for controlling the effect engine. As the same effect 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. The effect will be attached to the MediaPlayer or AudioTrack in the same audio session.
        Throws:
        IllegalArgumentException
        UnsupportedOperationException
        RuntimeException
    • Method Detail

      • release

        public void 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.
      • finalize

        protected void finalize()
        Description copied from class: Object
        Invoked when the garbage collector has detected that this instance is no longer reachable. The default implementation does nothing, but this method can be overridden to free resources.

        Note that objects that override finalize are significantly more expensive than objects that don't. Finalizers may be run a long time after the object is no longer reachable, depending on memory pressure, so it's a bad idea to rely on them for cleanup. Note also that finalizers are run on a single VM-wide finalizer thread, so doing blocking work in a finalizer is a bad idea. A finalizer is usually only necessary for a class that has a native peer and needs to call a native method to destroy that peer. Even then, it's better to provide an explicit close method (and implement Closeable), and insist that callers manually dispose of instances. This works well for something like files, but less well for something like a BigInteger where typical calling code would have to deal with lots of temporaries. Unfortunately, code that creates lots of temporaries is the worst kind of code from the point of view of the single finalizer thread.

        If you must use finalizers, consider at least providing your own ReferenceQueue and having your own thread process that queue.

        Unlike constructors, finalizers are not automatically chained. You are responsible for calling super.finalize() yourself.

        Uncaught exceptions thrown by finalizers are ignored and do not terminate the finalizer thread. See Effective Java Item 7, "Avoid finalizers" for more.

        Overrides:
        finalize in class Object
      • queryPreProcessings

        public static AudioEffect.Descriptor[] queryPreProcessings(int audioSession)
        Query all audio pre processing effects applied to the AudioRecord with the supplied audio session ID. Returns an array of AudioEffect.Descriptor objects.
        Parameters:
        audioSession - system wide unique audio session identifier.
        Throws:
        IllegalStateException
      • isEffectTypeAvailable

        public static boolean isEffectTypeAvailable(UUID type)
        Checks if the device implements the specified effect type.
        Parameters:
        type - the requested effect type.
        Returns:
        true if the device implements the specified effect type, false otherwise.
      • setEnabled

        public int setEnabled(boolean enabled)
                       throws IllegalStateException
        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.
        Parameters:
        enabled - the requested enable state
        Returns:
        SUCCESS in case of success, ERROR_INVALID_OPERATION or ERROR_DEAD_OBJECT in case of failure.
        Throws:
        IllegalStateException
      • setParameter

        public int setParameter(byte[] param,
                       byte[] value)
                         throws IllegalStateException
        Set effect parameter. The setParameter method is provided in several forms addressing most common parameter formats. This form is the most generic one where the parameter and its value are both specified as an array of bytes. The parameter and value type and length are therefore totally free. For standard effect defined by OpenSL ES, the parameter format and values must match the definitions in the corresponding OpenSL ES interface.
        Parameters:
        param - the identifier of the parameter to set
        value - the new value for the specified parameter
        Returns:
        SUCCESS in case of success, ERROR_BAD_VALUE, ERROR_NO_MEMORY, ERROR_INVALID_OPERATION or ERROR_DEAD_OBJECT in case of failure
        Throws:
        IllegalStateException
      • getParameter

        public int getParameter(byte[] param,
                       byte[] value)
                         throws IllegalStateException
        Get effect parameter. The getParameter method is provided in several forms addressing most common parameter formats. This form is the most generic one where the parameter and its value are both specified as an array of bytes. The parameter and value type and length are therefore totally free.
        Parameters:
        param - the identifier of the parameter to set
        value - the new value for the specified parameter
        Returns:
        the number of meaningful bytes in value array in case of success or ERROR_BAD_VALUE, ERROR_NO_MEMORY, ERROR_INVALID_OPERATION or ERROR_DEAD_OBJECT in case of failure.
        Throws:
        IllegalStateException
      • command

        public int command(int cmdCode,
                  byte[] command,
                  byte[] reply)
                    throws IllegalStateException
        Send a command to the effect engine. This method is intended to send proprietary commands to a particular effect implementation. In case of success, returns the number of meaningful bytes in reply array. In case of failure, the returned value is negative and implementation specific.
        Throws:
        IllegalStateException
      • getId

        public int getId()
                  throws IllegalStateException
        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)
        Returns:
        the effect identifier.
        Throws:
        IllegalStateException
      • hasControl

        public boolean hasControl()
                           throws IllegalStateException
        Checks if this AudioEffect object is controlling the effect engine.
        Returns:
        true if this instance has control of effect engine, false otherwise.
        Throws:
        IllegalStateException
      • setEnableStatusListener

        public void setEnableStatusListener(AudioEffect.OnEnableStatusChangeListener listener)
        Sets the listener AudioEffect notifies when the effect engine is enabled or disabled.
        Parameters:
        listener -
      • setControlStatusListener

        public void setControlStatusListener(AudioEffect.OnControlStatusChangeListener listener)
        Sets the listener AudioEffect notifies when the effect engine control is taken or returned.
        Parameters:
        listener -
      • setParameterListener

        public void setParameterListener(AudioEffect.OnParameterChangeListener listener)
        Sets the listener AudioEffect notifies when a parameter is changed.
        Parameters:
        listener -
      • checkStatus

        public void checkStatus(int status)
      • isError

        public static boolean isError(int status)
      • byteArrayToInt

        public int byteArrayToInt(byte[] valueBuf)
      • byteArrayToInt

        public int byteArrayToInt(byte[] valueBuf,
                         int offset)
      • intToByteArray

        public byte[] intToByteArray(int value)
      • byteArrayToShort

        public short byteArrayToShort(byte[] valueBuf)
      • byteArrayToShort

        public short byteArrayToShort(byte[] valueBuf,
                             int offset)
      • shortToByteArray

        public byte[] shortToByteArray(short value)
      • concatArrays

        public byte[] concatArrays(byte[]... arrays)


Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 891 / 96446809. Delta: 0.04324 с