Java Code Examples for android.media.audiofx.Equalizer#release()

The following examples show how to use android.media.audiofx.Equalizer#release() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MusicService.java    From YTPlayer with GNU General Public License v3.0 6 votes vote down vote up
static void setDefaultEqualizerValues() {
    try {
        boolean isSet = settingPref.getBoolean("equalizer_default",false);
        if (!isSet) {
            SharedPreferences.Editor editor = settingPref.edit();
            int sessionId = player.getAudioComponent().getAudioSessionId();

            mEqualizer = new Equalizer(1000,sessionId);
            short numberFrequencyBands = mEqualizer.getNumberOfBands();
            final short lowerEqualizerBandLevel = mEqualizer.getBandLevelRange()[0];
            final short upperEqualizerBandLevel = mEqualizer.getBandLevelRange()[1];

            editor.putInt("bandLength",numberFrequencyBands);
            editor.putInt("lowerBand",lowerEqualizerBandLevel);
            editor.putInt("higherBand",upperEqualizerBandLevel);
            editor.putBoolean("equalizer_default",true);
            editor.apply();

            mEqualizer.release();
        }
    }catch (Exception ignored){}
}
 
Example 2
Source File: MusicUtils.java    From Rey-MusicPlayer with Apache License 2.0 6 votes vote down vote up
public static boolean isEqualizerSupported() {
    int noOfBands = 0;
    int noOfPresents = 0;
    try {
        Equalizer equalizer = new Equalizer(0, 0);
        noOfBands = equalizer.getNumberOfBands();
        noOfPresents = equalizer.getNumberOfPresets();
        equalizer.release();
        equalizer = null;
    } catch (Exception e) {

    }

    return noOfBands > 0 && noOfPresents > 0 && !isHTC();

}
 
Example 3
Source File: EqualizerFragment.java    From Jockey with Apache License 2.0 5 votes vote down vote up
private RemoteEqualizer generateEqualizerConfig() {
    // Obtain an instance of the system equalizer to discover available configuration options
    // for an equalizer including bands and presets. This equalizer is not used to control
    // audio settings and is released before this method ends
    Equalizer systemEqualizer = new Equalizer(0, 1);

    RemoteEqualizer eq = new RemoteEqualizer(systemEqualizer);
    Equalizer.Settings settings = mPrefStore.getEqualizerSettings();
    if (settings != null) {
        eq.setProperties(mPrefStore.getEqualizerSettings());
    }

    systemEqualizer.release();
    return eq;
}