Java 类javafx.scene.media.EqualizerBand 实例源码

项目:jmusic    文件:PlayerCore.java   
/**
 * 让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());
}
项目:jmusic    文件:PlayerCore.java   
/**
 * 减少某一个频段的增益
 * @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));
}
项目:jmusic    文件:PlayerCore.java   
/**
 * 增加某一个频段的增益
 * @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));
}
项目:jmusic    文件:PlayerCore.java   
/**
 * 将音效设置成默认
 */
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);
}