/**
* Sets the volume.
*
* @param vol the volume
*/
private void setVolume(final int vol) {
int volume = vol;
if (volume < 0) {
volume = MAX_VOLUME;
}
float gainDb = 0.0f;
final FloatControl gain = (FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN);
if (volume == 0) {
gainDb = gain.getMinimum();
} else if (volume < MAX_VOLUME) {
// The volume algorithm is subtractive: The implementation assumes that
// the sound is already at maximum volume, so we avoid distortion by
// making the amplitude values
// The scaling factor for the volume would be 20 normally, but
// it seems that 13 is better
gainDb = (float) (Math.log10(MAX_VOLUME - volume) * 13.0);
}
gain.setValue(-gainDb);
}
DefaultSoundEffect.java 文件源码
java
阅读 21
收藏 0
点赞 0
评论 0
项目:zmpp-wandora
作者:
评论列表
文章目录