android.media.audiofx.LoudnessEnhancer Java Examples

The following examples show how to use android.media.audiofx.LoudnessEnhancer. 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: LoudnessEnhancerCompatKitKat.java    From Android-Music-Player with MIT License 5 votes vote down vote up
@Override
public AudioEffect create(int audioSession) {
    try {
        return new LoudnessEnhancer(audioSession);
    } catch (RuntimeException e) {
        // NOTE: some devices doesn't support LoudnessEnhancer class and may throw an exception
        // (ME176C throws IllegalArgumentException)
        Log.w(TAG, "Failed to instantiate loudness enhancer class", e);
    }
    return null;
}
 
Example #3
Source File: LoudnessEnhancerController.java    From Audinaut with GNU General Public License v3.0 5 votes vote down vote up
public LoudnessEnhancerController(int audioSessionId) {
    try {
        enhancer = new LoudnessEnhancer(audioSessionId);
    } catch (Throwable x) {
        Log.w(TAG, "Failed to create enhancer", x);
    }
}
 
Example #4
Source File: LoudnessEnhancerController.java    From Popeens-DSub with GNU General Public License v3.0 5 votes vote down vote up
public LoudnessEnhancerController(Context context, int audioSessionId) {
	this.context = context;
	try {
		this.audioSessionId = audioSessionId;
		enhancer = new LoudnessEnhancer(audioSessionId);
	} catch (Throwable x) {
		Log.w(TAG, "Failed to create enhancer", x);
	}
}
 
Example #5
Source File: LoudnessEnhancerCompatKitKat.java    From android-openslmediaplayer with Apache License 2.0 5 votes vote down vote up
@Override
public AudioEffect create(int audioSession) {
    try {
        return new LoudnessEnhancer(audioSession);
    } catch (RuntimeException e) {
        // NOTE: some devices doesn't support LoudnessEnhancer class and may throw an exception
        // (ME176C throws IllegalArgumentException)
        Log.w(TAG, "Failed to instantiate loudness enhancer class", e);
    }
    return null;
}
 
Example #6
Source File: LoudnessEnhancerCompatKitKat.java    From Android-Music-Player with MIT License 4 votes vote down vote up
@Override
public float getTargetGain(AudioEffect effect) {
    return ((LoudnessEnhancer) effect).getTargetGain();
}
 
Example #7
Source File: LoudnessEnhancerCompatKitKat.java    From Android-Music-Player with MIT License 4 votes vote down vote up
@Override
public void setTargetGain(AudioEffect effect, int gainmB) {
    ((LoudnessEnhancer) effect).setTargetGain(gainmB);
}
 
Example #8
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 #9
Source File: LoudnessEnhancerCompatKitKat.java    From android-openslmediaplayer with Apache License 2.0 4 votes vote down vote up
@Override
public float getTargetGain(AudioEffect effect) {
    return ((LoudnessEnhancer) effect).getTargetGain();
}
 
Example #10
Source File: LoudnessEnhancerCompatKitKat.java    From android-openslmediaplayer with Apache License 2.0 4 votes vote down vote up
@Override
public void setTargetGain(AudioEffect effect, int gainmB) {
    ((LoudnessEnhancer) effect).setTargetGain(gainmB);
}