/** * 让mediaPlayer应用config的设置 * @param mediaPlayer2 * @param config2 */ private void applyEffect() { mediaPlayer.setBalance(config.getBalance()); ObservableList<EqualizerBand> bands=mediaPlayer.getAudioEqualizer().getBands(); double[] dd=config.getEqualizrbands(); for(int i=0;i<dd.length;i++){ bands.get(i).setGain(dd[i]); } mediaPlayer.setVolume(config.getVolume()); }
/** * 减少某一个频段的增益 * @param hz 0~9 * @param d >0 */ public void desEqualizerBand(int hz, double d) { EqualizerBand band=mediaPlayer.getAudioEqualizer().getBands().get(hz); config.getEqualizrbands()[hz]=(Math.max(EqualizerBand.MIN_GAIN,band.getGain()-d)); config.setChanged(true); band.setGain(Math.max(EqualizerBand.MIN_GAIN,band.getGain()-d)); }
/** * 增加某一个频段的增益 * @param hz 0~9 * @param d >0 */ public void addEqualizerBand(int hz, double d) { EqualizerBand band=mediaPlayer.getAudioEqualizer().getBands().get(hz); config.getEqualizrbands()[hz]=(Math.max(EqualizerBand.MIN_GAIN,band.getGain()+d)); config.setChanged(true); band.setGain(Math.min(EqualizerBand.MAX_GAIN,band.getGain()+d)); }
/** * 将音效设置成默认 */ public void setEffectDefault() { config.setEffect(1, 0, new double[12]); config.setChanged(true); mediaPlayer.setBalance(0); ObservableList<EqualizerBand> bands=mediaPlayer.getAudioEqualizer().getBands(); for(EqualizerBand band:bands){ band.setGain(0); } mediaPlayer.setVolume(1); }