JavaDefaultSoundManager.java 文件源码

java
阅读 71 收藏 0 点赞 0 评论 0

项目:monkey-shines-java-port 作者:
/**
 * 
 * Automatically called on construction and game setting change to match clip volume to
 * user defined levels.
 * 
 * @param value
 *      percentage to set music volume to
 * 
 */
private void setSoundVolume(int value) {
    if (value == 0) {
        soundOff = true;
        return;
    }

    soundOff = false;

    float decibelLevelOffset = SoundUtils.resolveDecibelOffsetFromPercentage(value);
    System.out.println("Decibel offset for sound: " + decibelLevelOffset);
    for (GameSoundEffect effect : GameSoundEffect.values() ) {
        Optional<Clip> clip = sounds.get(effect);
        if (clip.isPresent() ) {
            FloatControl gainControl = (FloatControl)
                clip.get().getControl(FloatControl.Type.MASTER_GAIN);
            gainControl.setValue(decibelLevelOffset);
        }
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号