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.
|
finalize
public SoundBuffer()
public SoundBuffer(ConstSoundBuffer other)
other
- the sound buffer to copy.@Deprecated protected long nativeCreate()
SFMLNativeObject
nativeCreate
in class SFMLNativeObject
@Deprecated protected void nativeSetExPtr()
SFMLNativeObject
nativeSetExPtr
in class SFMLNativeObject
@Deprecated protected void nativeDelete()
SFMLNativeObject
nativeDelete
in class SFMLNativeObject
public 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
ConstSoundBuffer
saveToFile
in interface ConstSoundBuffer
path
- the path to the file to write.IOException
- in case saving failed.public short[] getSamples()
ConstSoundBuffer
getSamples
in interface ConstSoundBuffer
public int getSampleCount()
ConstSoundBuffer
getSampleCount
in interface ConstSoundBuffer
public int getSampleRate()
ConstSoundBuffer
getSampleRate
in interface ConstSoundBuffer
public int getChannelCount()
ConstSoundBuffer
getChannelCount
in interface ConstSoundBuffer
public Time getDuration()
ConstSoundBuffer
getDuration
in interface ConstSoundBuffer