diff --git a/src/games/stendhal/client/sound/facade/SoundSystemFacade.java b/src/games/stendhal/client/sound/facade/SoundSystemFacade.java index 3e9d39c4d05..400ae88f367 100644 --- a/src/games/stendhal/client/sound/facade/SoundSystemFacade.java +++ b/src/games/stendhal/client/sound/facade/SoundSystemFacade.java @@ -1,6 +1,6 @@ /* $Id$ */ /*************************************************************************** - * (C) Copyright 2003-2010 - Stendhal * + * (C) Copyright 2003-2024 - Stendhal * *************************************************************************** *************************************************************************** * * @@ -16,6 +16,7 @@ import java.util.List; import games.stendhal.client.listener.PositionChangeListener; +import games.stendhal.common.constants.SoundLayer; /** * this class is the interface between the game logic and the @@ -41,4 +42,13 @@ public interface SoundSystemFacade extends PositionChangeListener { public void changeVolume(float volume); public List getDeviceNames(); + + public SoundHandle playLocalizedEffect(String name, int x, int y, int radius, SoundLayer layer, + float volume, boolean loop); + + public SoundHandle playLocalizedEffect(String name, int x, int y, SoundLayer layer); + + public SoundHandle playGlobalizedEffect(String name, SoundLayer layer, float volume, boolean loop); + + public SoundHandle playGlobalizedEffect(String name, SoundLayer layer); } diff --git a/src/games/stendhal/client/sound/nosound/NoSoundFacade.java b/src/games/stendhal/client/sound/nosound/NoSoundFacade.java index a0d86433e10..328be895ec8 100644 --- a/src/games/stendhal/client/sound/nosound/NoSoundFacade.java +++ b/src/games/stendhal/client/sound/nosound/NoSoundFacade.java @@ -1,6 +1,6 @@ /* $Id$ */ /*************************************************************************** - * (C) Copyright 2003-2010 - Stendhal * + * (C) Copyright 2003-2024 - Stendhal * *************************************************************************** *************************************************************************** * * @@ -20,6 +20,7 @@ import games.stendhal.client.sound.facade.SoundHandle; import games.stendhal.client.sound.facade.SoundSystemFacade; import games.stendhal.client.sound.facade.Time; +import games.stendhal.common.constants.SoundLayer; public class NoSoundFacade implements SoundSystemFacade { @@ -56,6 +57,31 @@ public void mute(boolean turnOffSound, boolean useFading, Time delay) { // do nothing } + @Override + public SoundHandle playLocalizedEffect(String name, int x, int y, int radius, SoundLayer layer, float volume, + boolean loop) { + // do nothing + return new NoSoundHandle(); + } + + @Override + public SoundHandle playLocalizedEffect(String name, int x, int y, SoundLayer layer) { + // do nothing + return new NoSoundHandle(); + } + + @Override + public SoundHandle playGlobalizedEffect(String name, SoundLayer layer, float volume, boolean loop) { + // do nothing + return new NoSoundHandle(); + } + + @Override + public SoundHandle playGlobalizedEffect(String name, SoundLayer layer) { + // do nothing + return new NoSoundHandle(); + } + @Override public void stop(SoundHandle sound, Time fadingDuration) { // do nothing diff --git a/src/games/stendhal/client/sound/sound/SoundSystemFacadeImpl.java b/src/games/stendhal/client/sound/sound/SoundSystemFacadeImpl.java index 7f5821b98e3..fc2046ed4b0 100644 --- a/src/games/stendhal/client/sound/sound/SoundSystemFacadeImpl.java +++ b/src/games/stendhal/client/sound/sound/SoundSystemFacadeImpl.java @@ -1,6 +1,6 @@ /* $Id$ */ /*************************************************************************** - * (C) Copyright 2003-2010 - Stendhal * + * (C) Copyright 2003-2024 - Stendhal * *************************************************************************** *************************************************************************** * * @@ -12,18 +12,25 @@ ***************************************************************************/ package games.stendhal.client.sound.sound; +import static games.stendhal.common.Constants.DEFAULT_SOUND_RADIUS; + import java.util.Collection; import java.util.LinkedList; import java.util.List; import org.apache.log4j.Logger; +import games.stendhal.client.sound.facade.AudibleArea; +import games.stendhal.client.sound.facade.AudibleCircleArea; +import games.stendhal.client.sound.facade.InfiniteAudibleArea; +import games.stendhal.client.sound.facade.SoundFileType; import games.stendhal.client.sound.facade.SoundGroup; import games.stendhal.client.sound.facade.SoundHandle; import games.stendhal.client.sound.facade.SoundSystemFacade; import games.stendhal.client.sound.facade.Time; import games.stendhal.client.sound.manager.DeviceEvaluator.Device; import games.stendhal.client.sound.manager.SoundManagerNG.Sound; +import games.stendhal.common.constants.SoundLayer; import games.stendhal.common.math.Algebra; /** @@ -70,6 +77,33 @@ public void update() { } } + @Override + public SoundHandle playLocalizedEffect(String name, int x, int y, int radius, SoundLayer layer, + float volume, boolean loop) { + final AudibleArea area = new AudibleCircleArea(Algebra.vecf(x, y), radius / 4.0f, radius); + final SoundGroup group = getGroup(layer.groupName); + group.loadSound(name, name + ".ogg", SoundFileType.OGG, false); + return group.play(name, volume, 0, area, null, loop, true); + } + + @Override + public SoundHandle playLocalizedEffect(String name, int x, int y, SoundLayer layer) { + return playLocalizedEffect(name, x, y, DEFAULT_SOUND_RADIUS, layer, 1.0f, false); + } + + @Override + public SoundHandle playGlobalizedEffect(String name, SoundLayer layer, float volume, boolean loop) { + final AudibleArea area = new InfiniteAudibleArea(); + final SoundGroup group = getGroup(layer.groupName); + group.loadSound(name, name + ".ogg", SoundFileType.OGG, false); + return group.play(name, volume, 0, area, null, loop, true); + } + + @Override + public SoundHandle playGlobalizedEffect(String name, SoundLayer layer) { + return playGlobalizedEffect(name, layer, 1.0f, false); + } + @Override public void stop(SoundHandle sound, Time fadingDuration) { if (sound != null) {