* @param pan panning to be used (-1=left, 0=middle, +1=right)
* @param volume volume to be used, from 0 to 1
* @param loop the number of times to loop the sound
*/
private void playSound(Object key, float pan, float volume, int loop) {
Clip c = getSounds().getSound(key);
if (c == null) {
return;
}
if (properties.getOptionsSoundEnableMixerPan() && c.isControlSupported(FloatControl.Type.PAN)) {
FloatControl panCtrl = (FloatControl) c.getControl(FloatControl.Type.PAN);
panCtrl.setValue(pan);
}
if (properties.getOptionsSoundEnableMixerVolume() && c.isControlSupported(FloatControl.Type.MASTER_GAIN)) {
FloatControl volCtrl = (FloatControl) c.getControl(FloatControl.Type.MASTER_GAIN);
float min = volCtrl.getMinimum() / 4;
if (volume != 1) {
volCtrl.setValue(min * (1 - volume));
}
}
c.loop(loop);
}