Code example for Equalizer

Methods: getBandLevelRange, getNumberOfBands, setEnabled

57
	 
	private short minimumBandGain;
	 
	public EqualizerHandler(MediaPlayer mediaPlayer) throws PlayerEqualizerException {
		try { 
			equalizer = new Equalizer(PRIORITY, mediaPlayer.getAudioSessionId());
			equalizer.setEnabled(true);
			init(); 
		} catch (Exception e) {
			throw new PlayerEqualizerException("Fail to construct new equalizer object", e);
		} 
	} 
	 
	public void init() { 
		setTotalBandSize(equalizer.getNumberOfBands());
		setMinimumBandGain(equalizer.getBandLevelRange()[0]);
		setMaximumBandGain(equalizer.getBandLevelRange()[1]);
	} 
	 
	public void setGain(short frequency, short gain) {
		Log.d("equalizer", "Changing gain for band " + frequency + " to " + gain);
		equalizer.setBandLevel(frequency, gain);