mirror of
https://github.com/2OOP/pism.git
synced 2026-02-04 19:04:49 +00:00
Merge remote-tracking branch 'origin/166-audiomanager-opslitsen-om-single-responsibility-principle-te-volgen' into 166-audiomanager-opslitsen-om-single-responsibility-principle-te-volgen
This commit is contained in:
@@ -44,7 +44,7 @@ public class SoundEffectManager implements org.toop.framework.audio.interfaces.S
|
||||
}
|
||||
|
||||
asset.play();
|
||||
// TODO: Volume of Sound Effect isn't set when loading. When loading an effect it will be full volume.
|
||||
|
||||
logger.debug("Playing sound: {}", asset.getFile().getName());
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@ import static javax.sound.sampled.LineEvent.Type.STOP;
|
||||
public class SoundEffectAsset extends BaseResource implements LoadableResource, AudioResource {
|
||||
private final Clip clip = AudioSystem.getClip();
|
||||
|
||||
private double volume = 100; // TODO: Find a better way to set volume on clip load
|
||||
|
||||
public SoundEffectAsset(final File audioFile) throws LineUnavailableException {
|
||||
super(audioFile);
|
||||
}
|
||||
@@ -54,6 +56,7 @@ public class SoundEffectAsset extends BaseResource implements LoadableResource,
|
||||
if (baseFormat.getSampleSizeInBits() > 16)
|
||||
inputStream = downSampleAudio(inputStream, baseFormat);
|
||||
this.clip.open(inputStream); // ^ Clip can only run 16 bit and lower, thus downsampling necessary.
|
||||
this.updateVolume(this.volume);
|
||||
this.isLoaded = true;
|
||||
} catch (LineUnavailableException | UnsupportedAudioFileException | IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
@@ -79,6 +82,7 @@ public class SoundEffectAsset extends BaseResource implements LoadableResource,
|
||||
@Override
|
||||
public void updateVolume(double volume) {
|
||||
{
|
||||
this.volume = volume;
|
||||
if (clip.isControlSupported(FloatControl.Type.MASTER_GAIN)) {
|
||||
FloatControl volumeControl =
|
||||
(FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN);
|
||||
|
||||
Reference in New Issue
Block a user