FileDocCategorySizeDatePackage
BassBoost.javaAPI DocAndroid 5.1 API11627Thu Mar 12 22:22:30 GMT 2015android.media.audiofx

BassBoost

public class BassBoost extends android.media.audiofx.AudioEffect
Bass boost is an audio effect to boost or amplify low frequencies of the sound. It is comparable to a simple equalizer but limited to one band amplification in the low frequency range.

An application creates a BassBoost object to instantiate and control a bass boost engine in the audio framework.

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

To attach the BassBoost to a particular AudioTrack or MediaPlayer, specify the audio session ID of this AudioTrack or MediaPlayer when constructing the BassBoost.

NOTE: attaching a BassBoost to the global audio output mix by use of session 0 is deprecated.

See {@link android.media.MediaPlayer#getAudioSessionId()} for details on audio sessions.

See {@link android.media.audiofx.AudioEffect} class for more details on controlling audio effects.

Fields Summary
private static final String
TAG
public static final int
PARAM_STRENGTH_SUPPORTED
Is strength parameter supported by bass boost engine. Parameter ID for getParameter().
public static final int
PARAM_STRENGTH
Bass boost effect strength. Parameter ID for {@link android.media.audiofx.BassBoost.OnParameterChangeListener}
private boolean
mStrengthSupported
Indicates if strength parameter is supported by the bass boost engine
private OnParameterChangeListener
mParamListener
Registered listener for parameter changes.
private BaseParameterListener
mBaseParamListener
Listener used internally to to receive raw parameter change event from AudioEffect super class
private final Object
mParamListenerLock
Lock for access to mParamListener
Constructors Summary
public BassBoost(int priority, int audioSession)
Class constructor.

param
priority the priority level requested by the application for controlling the BassBoost 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.
param
audioSession system wide unique audio session identifier. The BassBoost will be attached to the MediaPlayer or AudioTrack in the same audio session.
throws
java.lang.IllegalStateException
throws
java.lang.IllegalArgumentException
throws
java.lang.UnsupportedOperationException
throws
java.lang.RuntimeException


                                                                                               
        
      
             
        super(EFFECT_TYPE_BASS_BOOST, EFFECT_TYPE_NULL, priority, audioSession);

        if (audioSession == 0) {
            Log.w(TAG, "WARNING: attaching a BassBoost to global output mix is deprecated!");
        }

        int[] value = new int[1];
        checkStatus(getParameter(PARAM_STRENGTH_SUPPORTED, value));
        mStrengthSupported = (value[0] != 0);
    
Methods Summary
public android.media.audiofx.BassBoost$SettingsgetProperties()
Gets the bass boost properties. This method is useful when a snapshot of current bass boost settings must be saved by the application.

return
a BassBoost.Settings object containing all current parameters values
throws
IllegalStateException
throws
IllegalArgumentException
throws
UnsupportedOperationException

        Settings settings = new Settings();
        short[] value = new short[1];
        checkStatus(getParameter(PARAM_STRENGTH, value));
        settings.strength = value[0];
        return settings;
    
public shortgetRoundedStrength()
Gets the current strength of the effect.

return
the strength of the effect. The valid range for strength is [0, 1000], where 0 per mille designates the mildest effect and 1000 per mille the strongest
throws
IllegalStateException
throws
IllegalArgumentException
throws
UnsupportedOperationException

        short[] value = new short[1];
        checkStatus(getParameter(PARAM_STRENGTH, value));
        return value[0];
    
public booleangetStrengthSupported()
Indicates whether setting strength is supported. If this method returns false, only one strength is supported and the setStrength() method always rounds to that value.

return
true is strength parameter is supported, false otherwise

       return mStrengthSupported;
    
public voidsetParameterListener(android.media.audiofx.BassBoost$OnParameterChangeListener listener)
Registers an OnParameterChangeListener interface.

param
listener OnParameterChangeListener interface registered

        synchronized (mParamListenerLock) {
            if (mParamListener == null) {
                mParamListener = listener;
                mBaseParamListener = new BaseParameterListener();
                super.setParameterListener(mBaseParamListener);
            }
        }
    
public voidsetProperties(android.media.audiofx.BassBoost$Settings settings)
Sets the bass boost properties. This method is useful when bass boost settings have to be applied from a previous backup.

param
settings a BassBoost.Settings object containing the properties to apply
throws
IllegalStateException
throws
IllegalArgumentException
throws
UnsupportedOperationException

        checkStatus(setParameter(PARAM_STRENGTH, settings.strength));
    
public voidsetStrength(short strength)
Sets the strength of the bass boost effect. If the implementation does not support per mille accuracy for setting the strength, it is allowed to round the given strength to the nearest supported value. You can use the {@link #getRoundedStrength()} method to query the (possibly rounded) value that was actually set.

param
strength strength of the effect. The valid range for strength strength is [0, 1000], where 0 per mille designates the mildest effect and 1000 per mille designates the strongest.
throws
IllegalStateException
throws
IllegalArgumentException
throws
UnsupportedOperationException

        checkStatus(setParameter(PARAM_STRENGTH, strength));