android.media.audiofx.BassBoost Java Examples

The following examples show how to use android.media.audiofx.BassBoost. 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: PlayService.java    From music_player with Open Software License 3.0 7 votes vote down vote up
private void initialAudioEffect(final int audioSessionId) {
    new Thread(new Runnable() {
        @Override
        public void run() {
            try {
                loudnessEnhancer = new LoudnessEnhancer(audioSessionId);
                mBass = new BassBoost(0, audioSessionId);
                mVirtualizer = new Virtualizer(0, audioSessionId);
                mEqualizer = new Equalizer(0, audioSessionId);
                canceler = AcousticEchoCanceler.create(audioSessionId);
                control = AutomaticGainControl.create(audioSessionId);
                suppressor = NoiseSuppressor.create(audioSessionId);
                getPreference();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }).start();
}
 
Example #2
Source File: EqualizerFragment.java    From Bop with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setRetainInstance(true);
    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 = (1000 / 19);
    bassBoost.setProperties(bassBoostSetting);

    presetReverb = new PresetReverb(0, audioSesionId);
    presetReverb.setPreset(PresetReverb.PRESET_NONE);
    presetReverb.setEnabled(true);
    Settings.equalizerModel = new EqualizerModel();
    mEqualizer.setEnabled(true);
    
    unbindSystemEqualizer(audioSesionId);
}
 
Example #3
Source File: AudioEffectsImpl.java    From PainlessMusicPlayer with Apache License 2.0 5 votes vote down vote up
private void restoreBassBoost() {
    mBassBoost = new BassBoost(Integer.MAX_VALUE, mSessionId);
    synchronized (SETTINGS_LOCK) {
        mBassBoost.setStrength((short) mBassBoostSettings.strength);
    }
    mBassBoost.setEnabled(true);
}
 
Example #4
Source File: EqualizerVolumePanel.java    From Noyze with Apache License 2.0 5 votes vote down vote up
private void release(AudioEffect effect) {
    if (null != effect) {
        effect.setControlStatusListener(null);
        effect.setEnableStatusListener(null);
        if (effect instanceof Equalizer) {
            ((Equalizer) effect).setParameterListener(null);
        } else if (effect instanceof BassBoost) {
            ((BassBoost) effect).setParameterListener(null);
        } else if (effect instanceof Virtualizer) {
            ((Virtualizer) effect).setParameterListener(null);
        }
        effect.release();
    }
}
 
Example #5
Source File: StandardBassBoost.java    From android-openslmediaplayer with Apache License 2.0 5 votes vote down vote up
void onParameterChange(
        android.media.audiofx.BassBoost effect,
        int status, int param, short value) {
    IBassBoost.OnParameterChangeListener listener = null;

    listener = mUserOnParameterChangeListener;

    if (listener != null) {
        listener.onParameterChange(this, status, param, value);
    }
}
 
Example #6
Source File: AudioEffectSettingsConverter.java    From android-openslmediaplayer with Apache License 2.0 5 votes vote down vote up
/**
 * BassBoost.Settings -> IBassBoost.Settings
 *
 * @param settings BassBoost.Settings
 * @return IBassBoost.Settings
 */
public static IBassBoost.Settings convert(BassBoost.Settings settings) {
    IBassBoost.Settings settings2 = new IBassBoost.Settings();

    settings2.strength = settings.strength;

    return settings2;
}
 
Example #7
Source File: AudioEffectSettingsConverter.java    From android-openslmediaplayer with Apache License 2.0 5 votes vote down vote up
/**
 * IBassBoost.Settings -> BassBoost.Settings
 *
 * @param settings IBassBoost.Settings
 * @return BassBoost.Settings
 */
public static BassBoost.Settings convert(IBassBoost.Settings settings) {
    BassBoost.Settings settings2 = new BassBoost.Settings();

    settings2.strength = settings.strength;

    return settings2;
}
 
Example #8
Source File: EqualizerController.java    From Popeens-DSub with GNU General Public License v3.0 5 votes vote down vote up
public void apply(Equalizer equalizer, BassBoost boost, LoudnessEnhancerController loudnessController) {
	for (short i = 0; i < bandLevels.length; i++) {
		equalizer.setBandLevel(i, bandLevels[i]);
	}
	equalizer.setEnabled(enabled);
	if(bass != 0) {
		boost.setEnabled(true);
		boost.setStrength(bass);
	}
	if(loudness != 0) {
		loudnessController.enable();
		loudnessController.setGain(loudness);
	}
}
 
Example #9
Source File: EqualizerController.java    From Popeens-DSub with GNU General Public License v3.0 5 votes vote down vote up
public BassBoost getBassBoost() {
	if(released) {
		released = false;
		try {
			init();
		} catch (Throwable x) {
			bass = null;
			Log.w(TAG, "Failed to create bass booster.", x);
		}
	}
	return bass;
}
 
Example #10
Source File: EqualizerController.java    From Popeens-DSub with GNU General Public License v3.0 5 votes vote down vote up
private void init() {
	equalizer = new Equalizer(0, audioSessionId);
	bass = new BassBoost(0, audioSessionId);
	if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
		loudnessAvailable = true;
		loudnessEnhancerController = new LoudnessEnhancerController(context, audioSessionId);
	}
}
 
Example #11
Source File: EqualizerVolumePanel.java    From Noyze with Apache License 2.0 5 votes vote down vote up
private void release(AudioEffect effect) {
    if (null != effect) {
        effect.setControlStatusListener(null);
        effect.setEnableStatusListener(null);
        if (effect instanceof Equalizer) {
            ((Equalizer) effect).setParameterListener(null);
        } else if (effect instanceof BassBoost) {
            ((BassBoost) effect).setParameterListener(null);
        } else if (effect instanceof Virtualizer) {
            ((Virtualizer) effect).setParameterListener(null);
        }
        effect.release();
    }
}
 
Example #12
Source File: MusicUtils.java    From mobile-manager-tool with MIT License 5 votes vote down vote up
/**
 * @param media player from apollo service.
 */
public static void initEqualizer(MediaPlayer player, Context context){
	releaseEqualizer();
	int id = player.getAudioSessionId();
	mEqualizer = new Equalizer(1,id);
	mBoost = new BassBoost(1, id);
	updateEqualizerSettings(context);
}
 
Example #13
Source File: EqualizerController.java    From Audinaut with GNU General Public License v3.0 5 votes vote down vote up
public void apply(Equalizer equalizer, BassBoost boost, LoudnessEnhancerController loudnessController) {
    for (short i = 0; i < bandLevels.length; i++) {
        equalizer.setBandLevel(i, bandLevels[i]);
    }
    equalizer.setEnabled(enabled);
    if (bass != 0) {
        boost.setEnabled(true);
        boost.setStrength(bass);
    }
    if (loudness != 0) {
        loudnessController.enable();
        loudnessController.setGain(loudness);
    }
}
 
Example #14
Source File: EqualizerController.java    From Audinaut with GNU General Public License v3.0 5 votes vote down vote up
public BassBoost getBassBoost() {
    if (released) {
        released = false;
        try {
            init();
        } catch (Throwable x) {
            bass = null;
            Log.w(TAG, "Failed to create bass booster.", x);
        }
    }
    return bass;
}
 
Example #15
Source File: EqualizerHelper.java    From Rey-MusicPlayer with Apache License 2.0 5 votes vote down vote up
public EqualizerHelper(int audioSessionId1, boolean equalizerEnabled) throws RuntimeException {

        mEqualizer = new Equalizer(0, audioSessionId1);
        mEqualizer.setEnabled(equalizerEnabled);

        mVirtualizer = new Virtualizer(0, audioSessionId1);
        mVirtualizer.setEnabled(equalizerEnabled);

        mBassBoost = new BassBoost(0, audioSessionId1);
        mBassBoost.setEnabled(equalizerEnabled);

        mPresetReverb = new PresetReverb(0, audioSessionId1);
        mPresetReverb.setEnabled(equalizerEnabled);
    }
 
Example #16
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 #17
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 #18
Source File: EqualizerController.java    From Audinaut with GNU General Public License v3.0 4 votes vote down vote up
private void init() {
    equalizer = new Equalizer(0, audioSessionId);
    bass = new BassBoost(0, audioSessionId);
    loudnessAvailable = true;
    loudnessEnhancerController = new LoudnessEnhancerController(audioSessionId);
}
 
Example #19
Source File: musicHandler.java    From Android-Music-Player with MIT License 4 votes vote down vote up
@TargetApi(Build.VERSION_CODES.KITKAT)
public musicHandler(musicPlayer Gh) {
	mEvent = new Event("PLayer");
	this.Gh = Gh;
	loadStartup();
	mediaplayer = new MediaPlayer();
	mediaplayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
		@Override
		public void onPrepared(MediaPlayer mp) {
			if(needPlay){
				isPrepared = true;
				play(needId);
			}else{
				isPrepared = true;
				if(needStop){
					needStop = false;
				}else{
					mediaplayer.start();
				}
				mediaplayer.setOnCompletionListener(OC);
				mEvent.trigger(playerEvents.SONG_CHANGED);
			}
		}
	});

	needStop = true;
	playByNumber(0);

	EQs = new EqlizerSettings(Gh.getBaseContext());

	bass = new BassBoost(0, mediaplayer.getAudioSessionId());
	bass.setEnabled(true);


	equlizer = new Equalizer(0, mediaplayer.getAudioSessionId());
	equlizer.setEnabled(true);

	virtualizer = new Virtualizer(0, mediaplayer.getAudioSessionId());
	virtualizer.setEnabled(true);

	if(android.os.Build.VERSION.SDK_INT >= 19){
		loudness = new LoudnessEnhancer(  mediaplayer.getAudioSessionId());
		loudness.setEnabled(true);
	}else{
		loudness = null;
	}


	setEQs(EQs.isOn);


	setBass(EQs.BASS);
	setTrable(EQs.TRABLE);
	setVoice(EQs.VOICE);
	setVirtualizer(EQs.VIRCHULIZER);
	setLoudnessEnhancer(EQs.LOUDNESS);
	mEvent.trigger(playerEvents.EQ_CHANGED);
	mEvent.trigger(playerEvents.PLAYER_COMPLETE);

}
 
Example #20
Source File: EqualizerHelper.java    From Rey-MusicPlayer with Apache License 2.0 4 votes vote down vote up
public void setBassBoost(BassBoost bassBoost) {
    mBassBoost = bassBoost;
}
 
Example #21
Source File: EqualizerHelper.java    From Rey-MusicPlayer with Apache License 2.0 4 votes vote down vote up
public BassBoost getBassBoost() {
    return mBassBoost;
}
 
Example #22
Source File: StandardBassBoost.java    From android-openslmediaplayer with Apache License 2.0 4 votes vote down vote up
@Override
public void onParameterChange(
        android.media.audiofx.BassBoost effect, int status, int param, short value) {
    StandardBassBoost.this.onParameterChange(effect, status, param, value);
}
 
Example #23
Source File: StandardBassBoost.java    From android-openslmediaplayer with Apache License 2.0 4 votes vote down vote up
public StandardBassBoost(int priority, int audioSession) throws IllegalStateException,
        IllegalArgumentException, UnsupportedOperationException, RuntimeException {
    super(new BassBoost(priority, audioSession));
    getBassBoost().setParameterListener(mOnParameterChangeListener);
    initializeForCompat();
}
 
Example #24
Source File: StandardBassBoost.java    From android-openslmediaplayer with Apache License 2.0 2 votes vote down vote up
/**
 * Get underlying BassBoost instance.
 *
 * @return underlying BassBoost instance.
 */
public BassBoost getBassBoost() {
    return (BassBoost) super.getAudioEffect();
}