public final class SoundEngine extends java.lang.Object implements ISoundEngine, IUpdateable, ILaunchable
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_MAX_DISTANCE |
| Constructor and Description |
|---|
SoundEngine() |
| Modifier and Type | Method and Description |
|---|---|
float |
getMaxDistance()
Gets the maximum distance from the listener at which a sound source can
still be heard.
|
ISoundPlayback |
playMusic(Sound sound)
Loops the specified sound file as background music.
|
ISoundPlayback |
playMusic(Sound sound,
boolean loop)
Plays the specified sound file as background music.
|
ISoundPlayback |
playSound(IEntity entity,
Sound sound)
Plays the specified sound and updates its volume and pan by the current
entity location in relation to the listener location.
|
ISoundPlayback |
playSound(IEntity entity,
Sound sound,
boolean loop)
Plays the specified sound and updates its volume and pan by the current
entity location in relation to the listener location.
|
ISoundPlayback |
playSound(java.awt.geom.Point2D location,
Sound sound)
Plays the specified sound at the specified location and updates the volume
and pan in relation to the listener location.
|
ISoundPlayback |
playSound(java.awt.geom.Point2D location,
Sound sound,
boolean loop)
Plays the specified sound at the specified location and updates the volume
and pan in relation to the listener location.
|
ISoundPlayback |
playSound(Sound sound)
Plays the specified sound with the volume configured in the SOUND config
with a center pan.
|
ISoundPlayback |
playSound(Sound sound,
boolean loop)
Plays the specified sound with the volume configured in the SOUND config
with a center pan.
|
void |
setListenerLocationCallback(java.util.function.Function<java.awt.geom.Point2D,java.awt.geom.Point2D> listenerLocationCallback)
This method allows to set the callback that is used by the SoundEngine to
determine where the listener location is.
|
void |
setMaxDistance(float radius)
Sets the maximum distance from the listener at which a sound source can
still be heard.
|
void |
start() |
void |
stopMusic()
Stops the playback of the current background music.
|
void |
terminate() |
void |
update()
This method is called by the game loop on all objects that need to update
their attributes.
|
public static final int DEFAULT_MAX_DISTANCE
public float getMaxDistance()
ISoundEnginegetMaxDistance in interface ISoundEnginepublic ISoundPlayback playMusic(Sound sound)
ISoundEngineplayMusic in interface ISoundEnginesound - The sound from which to play the background music.ISoundPlayback instance that allows to further process
and control the played sound.public ISoundPlayback playMusic(Sound sound, boolean loop)
ISoundEngineplayMusic in interface ISoundEnginesound - The sound from which to play the background music.loop - Determines whether this playback should be looped or not.ISoundPlayback instance that allows to further process
and control the played sound.public ISoundPlayback playSound(IEntity entity, Sound sound)
ISoundEngineplaySound in interface ISoundEngineentity - The entity at which location the sound should be played.sound - The sound to play.ISoundPlayback instance that allows to further process
and control the played sound.public ISoundPlayback playSound(IEntity entity, Sound sound, boolean loop)
ISoundEngineplaySound in interface ISoundEngineentity - The entity at which location the sound should be played.sound - The sound to play.loop - Determines whether this playback should be looped or not.ISoundPlayback instance that allows to further process
and control the played sound.public ISoundPlayback playSound(java.awt.geom.Point2D location, Sound sound)
ISoundEngineplaySound in interface ISoundEnginelocation - The location at which to play the sound.sound - The sound to play.ISoundPlayback instance that allows to further process
and control the played sound.public ISoundPlayback playSound(java.awt.geom.Point2D location, Sound sound, boolean loop)
ISoundEngineplaySound in interface ISoundEnginelocation - The location at which to play the sound.sound - The sound to play.loop - Determines whether this playback should be looped or not.ISoundPlayback instance that allows to further process
and control the played sound.public ISoundPlayback playSound(Sound sound)
ISoundEngineplaySound in interface ISoundEnginesound - The sound to play.ISoundPlayback instance that allows to further process
and control the played sound.public ISoundPlayback playSound(Sound sound, boolean loop)
ISoundEngineplaySound in interface ISoundEnginesound - The sound to play.loop - Determines whether this playback should be looped or not.ISoundPlayback instance that allows to further process
and control the played sound.public void setMaxDistance(float radius)
ISoundEnginesetMaxDistance in interface ISoundEngineradius - The maximum distance at which sounds can still be heard.public void start()
start in interface ILaunchablepublic void stopMusic()
ISoundEnginestopMusic in interface ISoundEnginepublic void terminate()
terminate in interface ILaunchablepublic void update()
IUpdateableupdate in interface IUpdateablepublic void setListenerLocationCallback(java.util.function.Function<java.awt.geom.Point2D,java.awt.geom.Point2D> listenerLocationCallback)
ISoundEnginesetListenerLocationCallback in interface ISoundEnginelistenerLocationCallback - The callback that determines the location of the sound listener.