android.media.audiofx.Virtualizer Java Examples

The following examples show how to use android.media.audiofx.Virtualizer. 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: 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 #3
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 #4
Source File: AudioEffectSettingsConverter.java    From android-openslmediaplayer with Apache License 2.0 5 votes vote down vote up
/**
 * IVirtualizer.Settings -> Virtualizer.Settings
 *
 * @param settings IVirtualizer.Settings
 * @return Virtualizer.Settings
 */
public static Virtualizer.Settings convert(IVirtualizer.Settings settings) {
    Virtualizer.Settings settings2 = new Virtualizer.Settings();

    settings2.strength = settings.strength;

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

    settings2.strength = settings.strength;

    return settings2;
}
 
Example #6
Source File: StandardVirtualizer.java    From android-openslmediaplayer with Apache License 2.0 5 votes vote down vote up
void onParameterChange(
        android.media.audiofx.Virtualizer effect,
        int status, int param, short value) {
    IVirtualizer.OnParameterChangeListener listener = null;

    listener = mUserOnParameterChangeListener;

    if (listener != null) {
        listener.onParameterChange(this, status, param, value);
    }
}
 
Example #7
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 #8
Source File: EqualizerHelper.java    From Rey-MusicPlayer with Apache License 2.0 4 votes vote down vote up
public Virtualizer getVirtualizer() {
    return mVirtualizer;
}
 
Example #9
Source File: EqualizerHelper.java    From Rey-MusicPlayer with Apache License 2.0 4 votes vote down vote up
public void setVirtualizer(Virtualizer virtualizer) {
    mVirtualizer = virtualizer;
}
 
Example #10
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 #11
Source File: StandardVirtualizer.java    From android-openslmediaplayer with Apache License 2.0 4 votes vote down vote up
@Override
public void onParameterChange(
        android.media.audiofx.Virtualizer effect, int status, int param, short value) {
    StandardVirtualizer.this.onParameterChange(effect, status, param, value);
}
 
Example #12
Source File: StandardVirtualizer.java    From android-openslmediaplayer with Apache License 2.0 4 votes vote down vote up
public StandardVirtualizer(int priority, int audioSession) throws IllegalStateException,
        IllegalArgumentException, UnsupportedOperationException, RuntimeException {
    super(new Virtualizer(priority, audioSession));
    getVirtualizer().setParameterListener(mOnParameterChangeListener);
    initializeForCompat();
}
 
Example #13
Source File: StandardVirtualizer.java    From android-openslmediaplayer with Apache License 2.0 2 votes vote down vote up
/**
 * Get underlying Virtualizer instance.
 *
 * @return underlying Virtualizer instance.
 */
public Virtualizer getVirtualizer() {
    return (Virtualizer) super.getAudioEffect();
}