public class SoundBuffer extends SFMLNativeObject implements ConstSoundBuffer
Sound.| Constructor and Description |
|---|
SoundBuffer()
Constructs a sound buffer.
|
SoundBuffer(ConstSoundBuffer other)
Constructs a sound buffer by copying another sound buffer.
|
| Modifier and Type | Method and Description |
|---|---|
int |
getChannelCount()
Gets the amount of audio channels in the buffer
(e.g.
|
Time |
getDuration()
Gets the duration of the sound.
|
int |
getSampleCount()
Retrieves the amount of samples stored in the buffer.
|
int |
getSampleRate()
Gets the sound buffer's sample rate in samples per second.
|
short[] |
getSamples()
Retrieves the raw 16-bit audio samples stored in the buffer.
|
void |
loadFromFile(Path path)
Attempts to load the sound buffer from a file.
|
void |
loadFromSamples(short[] samples,
int channelCount,
int sampleRate)
Attempts to load the sound buffer from an array of raw 16-bit audio samples.
|
void |
loadFromStream(InputStream in)
Fully loads all available bytes from the specified
InputStream
and attempts to load the sound buffer from it. |
protected long |
nativeCreate()
Deprecated.
|
protected void |
nativeDelete()
Deprecated.
|
protected void |
nativeSetExPtr()
Deprecated.
|
void |
saveToFile(Path path)
Attempts to save the sound buffer to a file.
|
finalizepublic SoundBuffer()
public SoundBuffer(ConstSoundBuffer other)
other - the sound buffer to copy.@Deprecated protected long nativeCreate()
SFMLNativeObjectnativeCreate in class SFMLNativeObject@Deprecated protected void nativeSetExPtr()
SFMLNativeObjectnativeSetExPtr in class SFMLNativeObject@Deprecated protected void nativeDelete()
SFMLNativeObjectnativeDelete in class SFMLNativeObjectpublic void loadFromStream(InputStream in) throws IOException
InputStream
and attempts to load the sound buffer from it.in - the input stream to read from.IOException - in case an I/O error occurs.public void loadFromFile(Path path) throws IOException
path - the path to the file to load the sound buffer from.IOException - in case an I/O error occurs.public void loadFromSamples(short[] samples,
int channelCount,
int sampleRate)
throws IOException
samples - the samples data.channelCount - the amount of audio channels.sampleRate - the sample rate in samples per second.IOException - in case an I/O error occurs.public void saveToFile(Path path) throws IOException
ConstSoundBuffersaveToFile in interface ConstSoundBufferpath - the path to the file to write.IOException - in case saving failed.public short[] getSamples()
ConstSoundBuffergetSamples in interface ConstSoundBufferpublic int getSampleCount()
ConstSoundBuffergetSampleCount in interface ConstSoundBufferpublic int getSampleRate()
ConstSoundBuffergetSampleRate in interface ConstSoundBufferpublic int getChannelCount()
ConstSoundBuffergetChannelCount in interface ConstSoundBufferpublic Time getDuration()
ConstSoundBuffergetDuration in interface ConstSoundBuffer