Polycode
|
Loads and plays a sound. More...
Public Member Functions | |
Sound (const String &fileName) | |
Constructor. | |
void | Play (bool loop=false) |
Play the sound once or in a loop. | |
void | Stop () |
Stop the sound playback. | |
void | setVolume (Number newVolume) |
Sets the volume of this sound. | |
void | setPitch (Number newPitch) |
Sets the pitch of this sound. | |
bool | isPlaying () |
Returns true if the sound is playing. | |
void | setOffset (int off) |
Sets the current sample offset of this sound. | |
int | getOffset () |
Returns the current sample offset (playback progress) of this sound. | |
int | getSampleLength () |
Returns the number of samples in the sound. |
Loads and plays a sound.
This class can load and play an OGG or WAV sound file.
Sound::Sound | ( | const String & | fileName | ) |
Constructor.
fileName | Path to an OGG or WAV file to load. |
int Sound::getOffset | ( | ) |
Returns the current sample offset (playback progress) of this sound.
int Sound::getSampleLength | ( | ) |
Returns the number of samples in the sound.
bool Sound::isPlaying | ( | ) |
Returns true if the sound is playing.
void Sound::Play | ( | bool | loop = false | ) |
Play the sound once or in a loop.
once | If this is true, play it once, otherwise, loop. |
void Sound::setOffset | ( | int | off | ) |
Sets the current sample offset of this sound.
off | A number 0 <= off < sound sample length |
void Sound::setPitch | ( | Number | newPitch | ) |
Sets the pitch of this sound.
newPitch | A Number 0-1. |
void Sound::setVolume | ( | Number | newVolume | ) |
Sets the volume of this sound.
newVolume | A Number 0-1, where 0 is no sound and 1 is the loudest. |