Package org.xjge.core
Class Sound
java.lang.Object
org.xjge.core.Sound
public final class Sound
extends java.lang.Object
Supplies the data parsed from an audio file into a new sound object that can
be used by the
Audio
class to play sound effects. The engine
supports two formats, 8-bit mono (for sound effects), and 16-bit stereo
(for music). Vorbis .ogg is the preferred file format of this engine.- Since:
- 2.0.0
-
Field Summary
Fields Modifier and Type Field Description int
handle
-
Constructor Summary
Constructors Constructor Description Sound(java.lang.String filename)
Creates a new sound object from the audio file specified. -
Method Summary
Modifier and Type Method Description void
freeSound()
Frees the audio data buffer used by this object.int
getChannels()
Obtains the amount of channels this sound exhibits.int
getSampleRate()
Obtains the unaltered sample rate of the sound.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
handle
public final int handle
-
-
Constructor Details
-
Sound
public Sound(java.lang.String filename)Creates a new sound object from the audio file specified. If the audio file cannot be found, the engine will instead use a fallback sound in its place.- Parameters:
filename
- the name of the file to load. Expects the file extension to be included.
-
-
Method Details
-
getChannels
public int getChannels()Obtains the amount of channels this sound exhibits. This typically can be used to determine whether or not a sound is mixed in a mono or stereo format.- Returns:
- the number of channels used by the sound object
-
getSampleRate
public int getSampleRate()Obtains the unaltered sample rate of the sound. Typically in the range of 44kHz to 48kHz.- Returns:
- the sample rate of the sound object in hertz
-
freeSound
public void freeSound()Frees the audio data buffer used by this object.
-