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

The following examples show how to use android.media.audiofx.Equalizer#usePreset() . 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: StandardEqualizer.java    From android-openslmediaplayer with Apache License 2.0 6 votes vote down vote up
private void workaroundGalaxyS4SetProperties(IEqualizer.Settings settings) {
    final Equalizer eq = getEqualizer();

    if (settings.curPreset != PRESET_UNDEFINED) {
        // NOTE: if curPreset has valid preset no.,
        // bandLevels values are not used.
        settings = DefaultEqualizerPresets.getPreset(settings.curPreset);
    }

    // apply
    if (settings.curPreset != PRESET_UNDEFINED) {
        try {
            eq.usePreset(settings.curPreset);
        } catch (IllegalArgumentException e) {
            // HTC devices raises IllegalArgumentException
        }
    }
    for (short band = 0; band < settings.numBands; band++) {
        eq.setBandLevel(band, settings.bandLevels[band]);
    }

    mWorkaroundCurPreset = settings.curPreset;
    System.arraycopy(settings.bandLevels, 0, mWorkaroundBandLevels, 0,
            mNumBands);
}
 
Example 2
Source File: StandardEqualizer.java    From android-openslmediaplayer with Apache License 2.0 6 votes vote down vote up
private void workaroundCyanogenModSetProperties(IEqualizer.Settings settings) {
    // apply
    if (settings.curPreset != PRESET_UNDEFINED) {
        final Equalizer eq = getEqualizer();

        eq.usePreset(settings.curPreset);
        mWorkaroundCurPreset = settings.curPreset;
        for (short band = 0; band < settings.numBands; band++) {
            mWorkaroundBandLevels[band] = eq.getBandLevel(band);
        }
    } else {
        for (short band = 0; band < settings.numBands; band++) {
            workaroundCyanogenModSetBandLevel(band, settings.bandLevels[band]);
        }

        mWorkaroundCurPreset = settings.curPreset;
        System.arraycopy(settings.bandLevels, 0, mWorkaroundBandLevels, 0, mNumBands);
    }
}
 
Example 3
Source File: EqualizerFragment.java    From AndroidEqualizer with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Settings.isEditing = true;

    if (getArguments() != null && getArguments().containsKey(ARG_AUDIO_SESSIOIN_ID)){
        audioSesionId = getArguments().getInt(ARG_AUDIO_SESSIOIN_ID);
    }

    if (Settings.equalizerModel == null){
        Settings.equalizerModel = new EqualizerModel();
        Settings.equalizerModel.setReverbPreset(PresetReverb.PRESET_NONE);
        Settings.equalizerModel.setBassStrength((short) (1000 / 19));
    }

    mEqualizer = new Equalizer(0, audioSesionId);

    bassBoost = new BassBoost(0, audioSesionId);
    bassBoost.setEnabled(Settings.isEqualizerEnabled);
    BassBoost.Settings bassBoostSettingTemp = bassBoost.getProperties();
    BassBoost.Settings bassBoostSetting = new BassBoost.Settings(bassBoostSettingTemp.toString());
    bassBoostSetting.strength = Settings.equalizerModel.getBassStrength();
    bassBoost.setProperties(bassBoostSetting);

    presetReverb = new PresetReverb(0, audioSesionId);
    presetReverb.setPreset(Settings.equalizerModel.getReverbPreset());
    presetReverb.setEnabled(Settings.isEqualizerEnabled);

    mEqualizer.setEnabled(Settings.isEqualizerEnabled);

    if (Settings.presetPos == 0){
        for (short bandIdx = 0; bandIdx < mEqualizer.getNumberOfBands(); bandIdx++) {
            mEqualizer.setBandLevel(bandIdx, (short) Settings.seekbarpos[bandIdx]);
        }
    }
    else {
        mEqualizer.usePreset((short) Settings.presetPos);
    }
}
 
Example 4
Source File: DialogEqualizerFragment.java    From AndroidEqualizer with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Settings.isEditing = true;

    if (getArguments() != null && getArguments().containsKey(ARG_AUDIO_SESSIOIN_ID)) {
        audioSesionId = getArguments().getInt(ARG_AUDIO_SESSIOIN_ID);
    }

    if (Settings.equalizerModel == null) {
        Settings.equalizerModel = new EqualizerModel();
        Settings.equalizerModel.setReverbPreset(PresetReverb.PRESET_NONE);
        Settings.equalizerModel.setBassStrength((short) (1000 / 19));
    }

    mEqualizer = new Equalizer(0, audioSesionId);

    bassBoost = new BassBoost(0, audioSesionId);
    bassBoost.setEnabled(true);
    BassBoost.Settings bassBoostSettingTemp = bassBoost.getProperties();
    BassBoost.Settings bassBoostSetting     = new BassBoost.Settings(bassBoostSettingTemp.toString());
    bassBoostSetting.strength = Settings.equalizerModel.getBassStrength();
    bassBoost.setProperties(bassBoostSetting);

    presetReverb = new PresetReverb(0, audioSesionId);
    presetReverb.setPreset(Settings.equalizerModel.getReverbPreset());
    presetReverb.setEnabled(true);

    mEqualizer.setEnabled(true);

    if (Settings.presetPos == 0) {
        for (short bandIdx = 0; bandIdx < mEqualizer.getNumberOfBands(); bandIdx++) {
            mEqualizer.setBandLevel(bandIdx, (short) Settings.seekbarpos[bandIdx]);
        }
    } else {
        mEqualizer.usePreset((short) Settings.presetPos);
    }
}
 
Example 5
Source File: StandardEqualizer.java    From android-openslmediaplayer with Apache License 2.0 5 votes vote down vote up
private void workaroundCyanogenModUsePreset(short preset) {
    if (preset != PRESET_UNDEFINED) {
        final Equalizer eq = getEqualizer();

        eq.usePreset(preset);

        for (short band = 0; band < mNumBands; band++) {
            mWorkaroundBandLevels[band] = eq.getBandLevel(band);
        }
        mWorkaroundCurPreset = preset;
    }
}