Polycode
Polycode::Sound Class Reference

Loads and plays a sound. More...

List of all members.

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.

Detailed Description

Loads and plays a sound.

This class can load and play an OGG or WAV sound file.


Constructor & Destructor Documentation

Sound::Sound ( const String fileName)

Constructor.

Parameters:
fileNamePath to an OGG or WAV file to load.

Member Function Documentation

int Sound::getOffset ( )

Returns the current sample offset (playback progress) of this sound.

Returns:
The sample offset if it is known, -1 otherwise.
int Sound::getSampleLength ( )

Returns the number of samples in the sound.

Returns:
The sample length if it is known, -1 otherwise.
bool Sound::isPlaying ( )

Returns true if the sound is playing.

Returns:
True if sound is playing, false if otherwise.
void Sound::Play ( bool  loop = false)

Play the sound once or in a loop.

Parameters:
onceIf this is true, play it once, otherwise, loop.
void Sound::setOffset ( int  off)

Sets the current sample offset of this sound.

Parameters:
offA number 0 <= off < sound sample length
void Sound::setPitch ( Number  newPitch)

Sets the pitch of this sound.

Parameters:
newPitchA Number 0-1.
void Sound::setVolume ( Number  newVolume)

Sets the volume of this sound.

Parameters:
newVolumeA Number 0-1, where 0 is no sound and 1 is the loudest.