FileDocCategorySizeDatePackage
AudioEffect.javaAPI DocAndroid 5.1 API50956Thu Mar 12 22:22:30 GMT 2015android.media.audiofx

AudioEffect

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:

  • {@link android.media.audiofx.Equalizer}
  • {@link android.media.audiofx.Virtualizer}
  • {@link android.media.audiofx.BassBoost}
  • {@link android.media.audiofx.PresetReverb}
  • {@link android.media.audiofx.EnvironmentalReverb}

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 {@link android.media.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.

Fields Summary
private static final String
TAG
public static final UUID
EFFECT_TYPE_ENV_REVERB
UUID for environmental reverberation effect
public static final UUID
EFFECT_TYPE_PRESET_REVERB
UUID for preset reverberation effect
public static final UUID
EFFECT_TYPE_EQUALIZER
UUID for equalizer effect
public static final UUID
EFFECT_TYPE_BASS_BOOST
UUID for bass boost effect
public static final UUID
EFFECT_TYPE_VIRTUALIZER
UUID for virtualizer effect
public static final UUID
EFFECT_TYPE_AGC
UUID for Automatic Gain Control (AGC)
public static final UUID
EFFECT_TYPE_AEC
UUID for Acoustic Echo Canceler (AEC)
public static final UUID
EFFECT_TYPE_NS
UUID for Noise Suppressor (NS)
public static final UUID
EFFECT_TYPE_LOUDNESS_ENHANCER
UUID for Loudness Enhancer
public static final UUID
EFFECT_TYPE_NULL
Null effect UUID. Used when the UUID for effect type of
public static final int
STATE_UNINITIALIZED
State of an AudioEffect object that was not successfully initialized upon creation
public static final int
STATE_INITIALIZED
State of an AudioEffect object that is ready to be used.
public static final int
NATIVE_EVENT_CONTROL_STATUS
Event id for engine control ownership change notification.
public static final int
NATIVE_EVENT_ENABLED_STATUS
Event id for engine state change notification.
public static final int
NATIVE_EVENT_PARAMETER_CHANGED
Event id for engine parameter change notification.
public static final int
SUCCESS
Successful operation.
public static final int
ERROR
Unspecified error.
public static final int
ALREADY_EXISTS
Internal operation status. Not returned by any method.
public static final int
ERROR_NO_INIT
Operation failed due to bad object initialization.
public static final int
ERROR_BAD_VALUE
Operation failed due to bad parameter value.
public static final int
ERROR_INVALID_OPERATION
Operation failed because it was requested in wrong state.
public static final int
ERROR_NO_MEMORY
Operation failed due to lack of memory.
public static final int
ERROR_DEAD_OBJECT
Operation failed due to dead remote object.
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.
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 {@link #getId()} to designate this particular effect when attaching it to the MediaPlayer or AudioTrack.

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).
private int
mState
Indicates the state of the AudioEffect instance
private final Object
mStateLock
Lock to synchronize access to mState
private int
mId
System wide unique effect ID
private long
mNativeAudioEffect
private long
mJniData
private Descriptor
mDescriptor
Effect descriptor
private OnEnableStatusChangeListener
mEnableStatusChangeListener
Listener for effect engine state change notifications.
private OnControlStatusChangeListener
mControlChangeStatusListener
Listener for effect engine control ownership change notifications.
private OnParameterChangeListener
mParameterChangeListener
Listener for effect engine control ownership change notifications.
public final Object
mListenerLock
Lock to protect listeners updates against event notifications
public NativeEventHandler
mNativeEventHandler
Handler for events coming from the native code
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 {@link 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 {@link #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 {@link #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 {@link #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.

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 {@link #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 {@link #EXTRA_PACKAGE_NAME} extra and the audio session ID by the {@link #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 {@link #EXTRA_CONTENT_TYPE} will be applied. The default settings for a given content type are platform specific.

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 {@link #EXTRA_PACKAGE_NAME} extra and the audio session ID by the {@link #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.

public static final String
EXTRA_AUDIO_SESSION
Contains the ID of the audio session the effects should be applied to.

This extra is for use with {@link #ACTION_DISPLAY_AUDIO_EFFECT_CONTROL_PANEL}, {@link #ACTION_OPEN_AUDIO_EFFECT_CONTROL_SESSION} and {@link #ACTION_CLOSE_AUDIO_EFFECT_CONTROL_SESSION} intents.

The extra value is of type int and is the audio session ID.

public static final String
EXTRA_PACKAGE_NAME
Contains the package name of the calling application.

This extra is for use with {@link #ACTION_OPEN_AUDIO_EFFECT_CONTROL_SESSION} and {@link #ACTION_CLOSE_AUDIO_EFFECT_CONTROL_SESSION} intents.

The extra value is a string containing the full package name.

public static final String
EXTRA_CONTENT_TYPE
Indicates which type of content is played by the application.

This extra is for use with {@link #ACTION_DISPLAY_AUDIO_EFFECT_CONTROL_PANEL} and {@link #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:

  • {@link #CONTENT_TYPE_MUSIC}
  • {@link #CONTENT_TYPE_MOVIE}
  • {@link #CONTENT_TYPE_GAME}
  • {@link #CONTENT_TYPE_VOICE}
If omitted, the content type defaults to {@link #CONTENT_TYPE_MUSIC}.
public static final int
CONTENT_TYPE_MUSIC
Value for {@link #EXTRA_CONTENT_TYPE} when the type of content played is music
public static final int
CONTENT_TYPE_MOVIE
Value for {@link #EXTRA_CONTENT_TYPE} when the type of content played is video or movie
public static final int
CONTENT_TYPE_GAME
Value for {@link #EXTRA_CONTENT_TYPE} when the type of content played is game audio
public static final int
CONTENT_TYPE_VOICE
Value for {@link #EXTRA_CONTENT_TYPE} when the type of content played is voice audio
Constructors Summary
public AudioEffect(UUID type, UUID uuid, int priority, int audioSession)
Class constructor.

param
type type of effect engine created. See {@link #EFFECT_TYPE_ENV_REVERB}, {@link #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 {@link #EFFECT_TYPE_NULL} in which case only the uuid will be used to select the effect.
param
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 {@link #EFFECT_TYPE_NULL} in which case only the type will be used to select the effect.
param
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.
param
audioSession system wide unique audio session identifier. The effect will be attached to the MediaPlayer or AudioTrack in the same audio session.
throws
java.lang.IllegalArgumentException
throws
java.lang.UnsupportedOperationException
throws
java.lang.RuntimeException
hide


    // --------------------------------------------------------------------------
    // Constructor, Finalize
    // --------------------
                                                                                                                                                                                                                                                                                                                                                                                                                                              

            
              
             
        int[] id = new int[1];
        Descriptor[] desc = new Descriptor[1];
        // native initialization
        int initResult = native_setup(new WeakReference<AudioEffect>(this),
                type.toString(), uuid.toString(), priority, audioSession, id,
                desc);
        if (initResult != SUCCESS && initResult != ALREADY_EXISTS) {
            Log.e(TAG, "Error code " + initResult
                    + " when initializing AudioEffect.");
            switch (initResult) {
            case ERROR_BAD_VALUE:
                throw (new IllegalArgumentException("Effect type: " + type
                        + " not supported."));
            case ERROR_INVALID_OPERATION:
                throw (new UnsupportedOperationException(
                        "Effect library not loaded"));
            default:
                throw (new RuntimeException(
                        "Cannot initialize effect engine for type: " + type
                                + " Error: " + initResult));
            }
        }
        mId = id[0];
        mDescriptor = desc[0];
        synchronized (mStateLock) {
            mState = STATE_INITIALIZED;
        }
    
Methods Summary
public static intbyteArrayToInt(byte[] valueBuf)

hide

        return byteArrayToInt(valueBuf, 0);

    
public static intbyteArrayToInt(byte[] valueBuf, int offset)

hide

        ByteBuffer converter = ByteBuffer.wrap(valueBuf);
        converter.order(ByteOrder.nativeOrder());
        return converter.getInt(offset);

    
public static shortbyteArrayToShort(byte[] valueBuf)

hide

        return byteArrayToShort(valueBuf, 0);
    
public static shortbyteArrayToShort(byte[] valueBuf, int offset)

hide

        ByteBuffer converter = ByteBuffer.wrap(valueBuf);
        converter.order(ByteOrder.nativeOrder());
        return converter.getShort(offset);

    
public voidcheckState(java.lang.String methodName)

hide

        synchronized (mStateLock) {
            if (mState != STATE_INITIALIZED) {
                throw (new IllegalStateException(methodName
                        + " called on uninitialized AudioEffect."));
            }
        }
    
public voidcheckStatus(int status)

hide

        if (isError(status)) {
            switch (status) {
            case AudioEffect.ERROR_BAD_VALUE:
                throw (new IllegalArgumentException(
                        "AudioEffect: bad parameter value"));
            case AudioEffect.ERROR_INVALID_OPERATION:
                throw (new UnsupportedOperationException(
                        "AudioEffect: invalid parameter operation"));
            default:
                throw (new RuntimeException("AudioEffect: set/get parameter error"));
            }
        }
    
public intcommand(int cmdCode, byte[] command, byte[] reply)
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.

hide

        checkState("command()");
        return native_command(cmdCode, command.length, command, reply.length, reply);
    
public static byte[]concatArrays(byte[] arrays)

hide

        int len = 0;
        for (byte[] a : arrays) {
            len += a.length;
        }
        byte[] b = new byte[len];

        int offs = 0;
        for (byte[] a : arrays) {
            System.arraycopy(a, 0, b, offs, a.length);
            offs += a.length;
        }
        return b;
    
private voidcreateNativeEventHandler()

        Looper looper;
        if ((looper = Looper.myLooper()) != null) {
            mNativeEventHandler = new NativeEventHandler(this, looper);
        } else if ((looper = Looper.getMainLooper()) != null) {
            mNativeEventHandler = new NativeEventHandler(this, looper);
        } else {
            mNativeEventHandler = null;
        }
    
protected voidfinalize()

        native_finalize();
    
public android.media.audiofx.AudioEffect$DescriptorgetDescriptor()
Get the effect descriptor.

see
android.media.audiofx.AudioEffect.Descriptor
throws
IllegalStateException

        checkState("getDescriptor()");
        return mDescriptor;
    
public booleangetEnabled()
Returns effect enabled state

return
true if the effect is enabled, false otherwise.
throws
IllegalStateException

        checkState("getEnabled()");
        return native_getEnabled();
    
public intgetId()
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)

return
the effect identifier.
throws
IllegalStateException

        checkState("getId()");
        return mId;
    
public intgetParameter(byte[] param, byte[] value)
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.

param
param the identifier of the parameter to set
param
value the new value for the specified parameter
return
the number of meaningful bytes in value array in case of success or {@link #ERROR_BAD_VALUE}, {@link #ERROR_NO_MEMORY}, {@link #ERROR_INVALID_OPERATION} or {@link #ERROR_DEAD_OBJECT} in case of failure.
throws
IllegalStateException
hide

        checkState("getParameter()");
        return native_getParameter(param.length, param, value.length, value);
    
public intgetParameter(int param, byte[] value)
Get effect parameter. The parameter is an integer and the value is an array of bytes.

see
#getParameter(byte[], byte[])
hide

        byte[] p = intToByteArray(param);

        return getParameter(p, value);
    
public intgetParameter(int param, int[] value)
Get effect parameter. The parameter is an integer and the value is an array of 1 or 2 integers

see
#getParameter(byte[], byte[]) In case of success, returns the number of meaningful integers in value array.
hide

        if (value.length > 2) {
            return ERROR_BAD_VALUE;
        }
        byte[] p = intToByteArray(param);

        byte[] v = new byte[value.length * 4];

        int status = getParameter(p, v);

        if (status == 4 || status == 8) {
            value[0] = byteArrayToInt(v);
            if (status == 8) {
                value[1] = byteArrayToInt(v, 4);
            }
            status /= 4;
        } else {
            status = ERROR;
        }
        return status;
    
public intgetParameter(int param, short[] value)
Get effect parameter. The parameter is an integer and the value is an array of 1 or 2 short integers

see
#getParameter(byte[], byte[]) In case of success, returns the number of meaningful short integers in value array.
hide

        if (value.length > 2) {
            return ERROR_BAD_VALUE;
        }
        byte[] p = intToByteArray(param);

        byte[] v = new byte[value.length * 2];

        int status = getParameter(p, v);

        if (status == 2 || status == 4) {
            value[0] = byteArrayToShort(v);
            if (status == 4) {
                value[1] = byteArrayToShort(v, 2);
            }
            status /= 2;
        } else {
            status = ERROR;
        }
        return status;
    
public intgetParameter(int[] param, int[] value)
Get effect parameter. The parameter is an array of 1 or 2 integers and the value is also an array of 1 or 2 integers

see
#getParameter(byte[], byte[]) In case of success, the returns the number of meaningful integers in value array.
hide

        if (param.length > 2 || value.length > 2) {
            return ERROR_BAD_VALUE;
        }
        byte[] p = intToByteArray(param[0]);
        if (param.length > 1) {
            byte[] p2 = intToByteArray(param[1]);
            p = concatArrays(p, p2);
        }
        byte[] v = new byte[value.length * 4];

        int status = getParameter(p, v);

        if (status == 4 || status == 8) {
            value[0] = byteArrayToInt(v);
            if (status == 8) {
                value[1] = byteArrayToInt(v, 4);
            }
            status /= 4;
        } else {
            status = ERROR;
        }
        return status;
    
public intgetParameter(int[] param, short[] value)
Get effect parameter. The parameter is an array of 1 or 2 integers and the value is an array of 1 or 2 short integers

see
#getParameter(byte[], byte[]) In case of success, returns the number of meaningful short integers in value array.
hide

        if (param.length > 2 || value.length > 2) {
            return ERROR_BAD_VALUE;
        }
        byte[] p = intToByteArray(param[0]);
        if (param.length > 1) {
            byte[] p2 = intToByteArray(param[1]);
            p = concatArrays(p, p2);
        }
        byte[] v = new byte[value.length * 2];

        int status = getParameter(p, v);

        if (status == 2 || status == 4) {
            value[0] = byteArrayToShort(v);
            if (status == 4) {
                value[1] = byteArrayToShort(v, 2);
            }
            status /= 2;
        } else {
            status = ERROR;
        }
        return status;
    
public intgetParameter(int[] param, byte[] value)
Get effect parameter. The parameter is an array of 1 or 2 integers and the value is an array of bytes

see
#getParameter(byte[], byte[])
hide

        if (param.length > 2) {
            return ERROR_BAD_VALUE;
        }
        byte[] p = intToByteArray(param[0]);
        if (param.length > 1) {
            byte[] p2 = intToByteArray(param[1]);
            p = concatArrays(p, p2);
        }

        return getParameter(p, value);
    
public booleanhasControl()
Checks if this AudioEffect object is controlling the effect engine.

return
true if this instance has control of effect engine, false otherwise.
throws
IllegalStateException

        checkState("hasControl()");
        return native_hasControl();
    
public static byte[]intToByteArray(int value)

hide

        ByteBuffer converter = ByteBuffer.allocate(4);
        converter.order(ByteOrder.nativeOrder());
        converter.putInt(value);
        return converter.array();
    
public static booleanisEffectTypeAvailable(java.util.UUID type)
Checks if the device implements the specified effect type.

param
type the requested effect type.
return
true if the device implements the specified effect type, false otherwise.
hide

        AudioEffect.Descriptor[] desc = AudioEffect.queryEffects();
        if (desc == null) {
            return false;
        }

        for (int i = 0; i < desc.length; i++) {
            if (desc[i].type.equals(type)) {
                return true;
            }
        }
        return false;
    
public static booleanisError(int status)

hide

        return (status < 0);
    
private final native intnative_command(int cmdCode, int cmdSize, byte[] cmdData, int repSize, byte[] repData)

private final native voidnative_finalize()

private final native booleannative_getEnabled()

private final native intnative_getParameter(int psize, byte[] param, int vsize, byte[] value)

private final native booleannative_hasControl()

private static final native voidnative_init()

private static native java.lang.Object[]native_query_effects()

private static native java.lang.Object[]native_query_pre_processing(int audioSession)

private final native voidnative_release()

private final native intnative_setEnabled(boolean enabled)

private final native intnative_setParameter(int psize, byte[] param, int vsize, byte[] value)

private final native intnative_setup(java.lang.Object audioeffect_this, java.lang.String type, java.lang.String uuid, int priority, int audioSession, int[] id, java.lang.Object[] desc)

private static voidpostEventFromNative(java.lang.Object effect_ref, int what, int arg1, int arg2, java.lang.Object obj)

        AudioEffect effect = (AudioEffect) ((WeakReference) effect_ref).get();
        if (effect == null) {
            return;
        }
        if (effect.mNativeEventHandler != null) {
            Message m = effect.mNativeEventHandler.obtainMessage(what, arg1,
                    arg2, obj);
            effect.mNativeEventHandler.sendMessage(m);
        }

    
public static android.media.audiofx.AudioEffect$Descriptor[]queryEffects()
Query all effects available on the platform. Returns an array of {@link android.media.audiofx.AudioEffect.Descriptor} objects

throws
IllegalStateException

        return (Descriptor[]) native_query_effects();
    
public static android.media.audiofx.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 {@link android.media.audiofx.AudioEffect.Descriptor} objects.

param
audioSession system wide unique audio session identifier.
throws
IllegalStateException
hide

        return (Descriptor[]) native_query_pre_processing(audioSession);
    
public voidrelease()
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.

        synchronized (mStateLock) {
            native_release();
            mState = STATE_UNINITIALIZED;
        }
    
public voidsetControlStatusListener(android.media.audiofx.AudioEffect$OnControlStatusChangeListener listener)
Sets the listener AudioEffect notifies when the effect engine control is taken or returned.

param
listener

        synchronized (mListenerLock) {
            mControlChangeStatusListener = listener;
        }
        if ((listener != null) && (mNativeEventHandler == null)) {
            createNativeEventHandler();
        }
    
public voidsetEnableStatusListener(android.media.audiofx.AudioEffect$OnEnableStatusChangeListener listener)
Sets the listener AudioEffect notifies when the effect engine is enabled or disabled.

param
listener

        synchronized (mListenerLock) {
            mEnableStatusChangeListener = listener;
        }
        if ((listener != null) && (mNativeEventHandler == null)) {
            createNativeEventHandler();
        }
    
public intsetEnabled(boolean enabled)
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.

param
enabled the requested enable state
return
{@link #SUCCESS} in case of success, {@link #ERROR_INVALID_OPERATION} or {@link #ERROR_DEAD_OBJECT} in case of failure.
throws
IllegalStateException

        checkState("setEnabled()");
        return native_setEnabled(enabled);
    
public intsetParameter(int param, int value)
Set effect parameter. The parameter and its value are integers.

see
#setParameter(byte[], byte[])
hide

        byte[] p = intToByteArray(param);
        byte[] v = intToByteArray(value);
        return setParameter(p, v);
    
public intsetParameter(int param, short value)
Set effect parameter. The parameter is an integer and the value is a short integer.

see
#setParameter(byte[], byte[])
hide

        byte[] p = intToByteArray(param);
        byte[] v = shortToByteArray(value);
        return setParameter(p, v);
    
public intsetParameter(int param, byte[] value)
Set effect parameter. The parameter is an integer and the value is an array of bytes.

see
#setParameter(byte[], byte[])
hide

        byte[] p = intToByteArray(param);
        return setParameter(p, value);
    
public intsetParameter(int[] param, int[] value)
Set effect parameter. The parameter is an array of 1 or 2 integers and the value is also an array of 1 or 2 integers

see
#setParameter(byte[], byte[])
hide

        if (param.length > 2 || value.length > 2) {
            return ERROR_BAD_VALUE;
        }
        byte[] p = intToByteArray(param[0]);
        if (param.length > 1) {
            byte[] p2 = intToByteArray(param[1]);
            p = concatArrays(p, p2);
        }
        byte[] v = intToByteArray(value[0]);
        if (value.length > 1) {
            byte[] v2 = intToByteArray(value[1]);
            v = concatArrays(v, v2);
        }
        return setParameter(p, v);
    
public intsetParameter(int[] param, short[] value)
Set effect parameter. The parameter is an array of 1 or 2 integers and the value is an array of 1 or 2 short integers

see
#setParameter(byte[], byte[])
hide

        if (param.length > 2 || value.length > 2) {
            return ERROR_BAD_VALUE;
        }
        byte[] p = intToByteArray(param[0]);
        if (param.length > 1) {
            byte[] p2 = intToByteArray(param[1]);
            p = concatArrays(p, p2);
        }

        byte[] v = shortToByteArray(value[0]);
        if (value.length > 1) {
            byte[] v2 = shortToByteArray(value[1]);
            v = concatArrays(v, v2);
        }
        return setParameter(p, v);
    
public intsetParameter(int[] param, byte[] value)
Set effect parameter. The parameter is an array of 1 or 2 integers and the value is an array of bytes

see
#setParameter(byte[], byte[])
hide

        if (param.length > 2) {
            return ERROR_BAD_VALUE;
        }
        byte[] p = intToByteArray(param[0]);
        if (param.length > 1) {
            byte[] p2 = intToByteArray(param[1]);
            p = concatArrays(p, p2);
        }
        return setParameter(p, value);
    
public intsetParameter(byte[] param, byte[] value)
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.

param
param the identifier of the parameter to set
param
value the new value for the specified parameter
return
{@link #SUCCESS} in case of success, {@link #ERROR_BAD_VALUE}, {@link #ERROR_NO_MEMORY}, {@link #ERROR_INVALID_OPERATION} or {@link #ERROR_DEAD_OBJECT} in case of failure
throws
IllegalStateException
hide

        checkState("setParameter()");
        return native_setParameter(param.length, param, value.length, value);
    
public voidsetParameterListener(android.media.audiofx.AudioEffect$OnParameterChangeListener listener)
Sets the listener AudioEffect notifies when a parameter is changed.

param
listener
hide

        synchronized (mListenerLock) {
            mParameterChangeListener = listener;
        }
        if ((listener != null) && (mNativeEventHandler == null)) {
            createNativeEventHandler();
        }
    
public static byte[]shortToByteArray(short value)

hide

        ByteBuffer converter = ByteBuffer.allocate(2);
        converter.order(ByteOrder.nativeOrder());
        short sValue = (short) value;
        converter.putShort(sValue);
        return converter.array();