Search in sources :

Example 11 with BassBoost

use of android.media.audiofx.BassBoost in project MusicDNA by harjot-oberai.

the class PlayerFragment method setupVisualizerFxAndUI.

public void setupVisualizerFxAndUI() {
    try {
        mVisualizer = new Visualizer(mMediaPlayer.getAudioSessionId());
        mEqualizer = new Equalizer(0, mMediaPlayer.getAudioSessionId());
        mEqualizer.setEnabled(true);
        try {
            bassBoost = new BassBoost(0, mMediaPlayer.getAudioSessionId());
            bassBoost.setEnabled(false);
            BassBoost.Settings bassBoostSettingTemp = bassBoost.getProperties();
            BassBoost.Settings bassBoostSetting = new BassBoost.Settings(bassBoostSettingTemp.toString());
            bassBoostSetting.strength = (1000 / 19);
            bassBoost.setProperties(bassBoostSetting);
            mMediaPlayer.setAuxEffectSendLevel(1.0f);
            presetReverb = new PresetReverb(0, mMediaPlayer.getAudioSessionId());
            presetReverb.setPreset(PresetReverb.PRESET_NONE);
            presetReverb.setEnabled(false);
            mMediaPlayer.setAuxEffectSendLevel(1.0f);
        } catch (Exception e) {
            e.printStackTrace();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    if (homeActivity.isEqualizerEnabled) {
        try {
            bassBoost.setEnabled(true);
            BassBoost.Settings bassBoostSettingTemp = bassBoost.getProperties();
            BassBoost.Settings bassBoostSetting = new BassBoost.Settings(bassBoostSettingTemp.toString());
            if (homeActivity.bassStrength == -1) {
                bassBoostSetting.strength = (1000 / 19);
            } else {
                bassBoostSetting.strength = homeActivity.bassStrength;
            }
            bassBoost.setProperties(bassBoostSetting);
            mMediaPlayer.setAuxEffectSendLevel(1.0f);
            if (homeActivity.reverbPreset == -1) {
                presetReverb.setPreset(PresetReverb.PRESET_NONE);
            } else {
                presetReverb.setPreset(homeActivity.reverbPreset);
            }
            presetReverb.setEnabled(true);
            mMediaPlayer.setAuxEffectSendLevel(1.0f);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    if (homeActivity.isEqualizerEnabled && homeActivity.isEqualizerReloaded) {
        try {
            homeActivity.isEqualizerEnabled = true;
            int pos = homeActivity.presetPos;
            if (pos != 0) {
                mEqualizer.usePreset((short) (pos - 1));
            } else {
                for (short i = 0; i < 5; i++) {
                    mEqualizer.setBandLevel(i, (short) homeActivity.seekbarpos[i]);
                }
            }
            if (homeActivity.bassStrength != -1 && homeActivity.reverbPreset != -1) {
                bassBoost.setEnabled(true);
                bassBoost.setStrength(homeActivity.bassStrength);
                presetReverb.setEnabled(true);
                presetReverb.setPreset(homeActivity.reverbPreset);
            }
            mMediaPlayer.setAuxEffectSendLevel(1.0f);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    try {
        mVisualizer.setCaptureSize(Visualizer.getCaptureSizeRange()[1]);
        mVisualizer.setDataCaptureListener(new Visualizer.OnDataCaptureListener() {

            public void onWaveFormDataCapture(Visualizer visualizer, byte[] bytes, int samplingRate) {
            }

            public void onFftDataCapture(Visualizer visualizer, byte[] bytes, int samplingRate) {
                homeActivity.updateVisualizer(bytes);
            }
        }, Visualizer.getMaxCaptureRate() / 2, false, true);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : PresetReverb(android.media.audiofx.PresetReverb) BassBoost(android.media.audiofx.BassBoost) Visualizer(android.media.audiofx.Visualizer) Equalizer(android.media.audiofx.Equalizer)

Example 12 with BassBoost

use of android.media.audiofx.BassBoost in project android_frameworks_base by ParanoidAndroid.

the class BassBoostTest method getEffect.

private void getEffect(int session) {
    synchronized (sInstances) {
        if (sInstances.containsKey(session)) {
            mBassBoost = sInstances.get(session);
        } else {
            try {
                mBassBoost = new BassBoost(0, session);
            } catch (IllegalArgumentException e) {
                Log.e(TAG, "BassBoost effect not supported");
            } catch (IllegalStateException e) {
                Log.e(TAG, "BassBoost cannot get strength supported");
            } catch (UnsupportedOperationException e) {
                Log.e(TAG, "BassBoost library not loaded");
            } catch (RuntimeException e) {
                Log.e(TAG, "BassBoost effect not found");
            }
            sInstances.put(session, mBassBoost);
        }
        mReleaseButton.setEnabled(false);
        mOnOffButton.setEnabled(false);
        if (mBassBoost != null) {
            if (mSettings != "") {
                mBassBoost.setProperties(new BassBoost.Settings(mSettings));
            }
            mBassBoost.setEnableStatusListener(mEffectListener);
            mBassBoost.setControlStatusListener(mEffectListener);
            mBassBoost.setParameterListener(mEffectListener);
            mReleaseButton.setChecked(true);
            mReleaseButton.setEnabled(true);
            mOnOffButton.setChecked(mBassBoost.getEnabled());
            mOnOffButton.setEnabled(true);
        }
    }
}
Also used : BassBoost(android.media.audiofx.BassBoost)

Example 13 with BassBoost

use of android.media.audiofx.BassBoost in project android_frameworks_base by ParanoidAndroid.

the class MediaBassBoostTest method getBassBoost.

//-----------------------------------------------------------------
// private methods
//----------------------------------
private void getBassBoost(int session) {
    if (mBassBoost == null || session != mSession) {
        if (session != mSession && mBassBoost != null) {
            mBassBoost.release();
            mBassBoost = null;
        }
        try {
            mBassBoost = new BassBoost(0, session);
            mSession = session;
        } catch (IllegalArgumentException e) {
            Log.e(TAG, "getBassBoost() BassBoost not found exception: " + e);
        } catch (UnsupportedOperationException e) {
            Log.e(TAG, "getBassBoost() Effect library not loaded exception: " + e);
        }
    }
    assertNotNull("could not create mBassBoost", mBassBoost);
}
Also used : BassBoost(android.media.audiofx.BassBoost)

Example 14 with BassBoost

use of android.media.audiofx.BassBoost in project platform_frameworks_base by android.

the class MediaBassBoostTest method test0_0ConstructorAndRelease.

//-----------------------------------------------------------------
// BASS BOOST TESTS:
//----------------------------------
//-----------------------------------------------------------------
// 0 - constructor
//----------------------------------
//Test case 0.0: test constructor and release
@LargeTest
public void test0_0ConstructorAndRelease() throws Exception {
    boolean result = false;
    String msg = "test1_0ConstructorAndRelease()";
    BassBoost bb = null;
    try {
        bb = new BassBoost(0, 0);
        assertNotNull(msg + ": could not create BassBoost", bb);
        try {
            assertTrue(msg + ": invalid effect ID", (bb.getId() != 0));
        } catch (IllegalStateException e) {
            msg = msg.concat(": BassBoost not initialized");
        }
        result = true;
    } catch (IllegalArgumentException e) {
        msg = msg.concat(": BassBoost not found");
    } catch (UnsupportedOperationException e) {
        msg = msg.concat(": Effect library not loaded");
    } finally {
        if (bb != null) {
            bb.release();
        }
    }
    assertTrue(msg, result);
}
Also used : BassBoost(android.media.audiofx.BassBoost) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 15 with BassBoost

use of android.media.audiofx.BassBoost in project platform_frameworks_base by android.

the class MediaBassBoostTest method getBassBoost.

//-----------------------------------------------------------------
// private methods
//----------------------------------
private void getBassBoost(int session) {
    if (mBassBoost == null || session != mSession) {
        if (session != mSession && mBassBoost != null) {
            mBassBoost.release();
            mBassBoost = null;
        }
        try {
            mBassBoost = new BassBoost(0, session);
            mSession = session;
        } catch (IllegalArgumentException e) {
            Log.e(TAG, "getBassBoost() BassBoost not found exception: " + e);
        } catch (UnsupportedOperationException e) {
            Log.e(TAG, "getBassBoost() Effect library not loaded exception: " + e);
        }
    }
    assertNotNull("could not create mBassBoost", mBassBoost);
}
Also used : BassBoost(android.media.audiofx.BassBoost)

Aggregations

BassBoost (android.media.audiofx.BassBoost)19 LargeTest (android.test.suitebuilder.annotation.LargeTest)6 Equalizer (android.media.audiofx.Equalizer)1 PresetReverb (android.media.audiofx.PresetReverb)1 Visualizer (android.media.audiofx.Visualizer)1