ScummVM API documentation
Sword25::SoundEngine Class Reference
Inheritance diagram for Sword25::SoundEngine:
Sword25::ResourceService Sword25::Persistable Sword25::Service

Public Types

enum  SOUND_TYPES { MUSIC = 0, SPEECH = 1, SFX = 2 }
 
typedef void(* DynamicSoundReadCallback) (void *UserData, void *Data, uint DataLength)
 

Public Member Functions

 SoundEngine (Kernel *pKernel)
 
bool init (uint sampleRate, uint channels=32)
 
void update ()
 
void setVolume (float volume, SOUND_TYPES type)
 
float getVolume (SOUND_TYPES type)
 
void pauseAll ()
 
void resumeAll ()
 
void pauseLayer (uint layer)
 
void resumeLayer (uint layer)
 
bool playSound (const Common::String &fileName, SOUND_TYPES type, float volume=1.0f, float pan=0.0f, bool loop=false, int loopStart=-1, int loopEnd=-1, uint layer=0)
 
uint playSoundEx (const Common::String &fileName, SOUND_TYPES type, float volume=1.0f, float pan=0.0f, bool loop=false, int loopStart=-1, int loopEnd=-1, uint layer=0, uint handleId=0x1337)
 
void setSoundVolume (uint handle, float volume)
 
void setSoundPanning (uint handle, float pan)
 
void pauseSound (uint handle)
 
void resumeSound (uint handle)
 
void stopSound (uint handle)
 
bool isSoundPaused (uint handle)
 
bool isSoundPlaying (uint handle)
 
float getSoundVolume (uint handle)
 
float getSoundPanning (uint handle)
 
ResourceloadResource (const Common::String &fileName) override
 
bool canLoadResource (const Common::String &fileName) override
 
bool persist (OutputPersistenceBlock &writer) override
 
bool unpersist (InputPersistenceBlock &reader) override
 
- Public Member Functions inherited from Sword25::ResourceService
 ResourceService (Kernel *pKernel)
 

Additional Inherited Members

- Protected Member Functions inherited from Sword25::Service
 Service (Kernel *pKernel)
 
KernelGetKernel () const
 

Member Typedef Documentation

◆ DynamicSoundReadCallback

typedef void(* Sword25::SoundEngine::DynamicSoundReadCallback) (void *UserData, void *Data, uint DataLength)

The callback function of PlayDynamicSoundEx

Parameters
UserDataUser-specified pointer
DataPointer to the data buffer
DataLengthLength of the data to be written in bytes

Member Function Documentation

◆ init()

bool Sword25::SoundEngine::init ( uint  sampleRate,
uint  channels = 32 
)

Initializes the sound engine

Parameters
SampleRateSpecifies the sample rate to use.
ChannelsThe maximum number of channels. The default is 32.
Returns
Returns true on success, otherwise false.
Remarks
Calls to other methods may take place only if this method was called successfully.

◆ update()

void Sword25::SoundEngine::update ( )

Performs a "tick" of the sound engine

This method should be called once per frame. It can be used by implementations of the sound engine that are not running in their own thread, or to perform additional administrative tasks that are needed.

◆ setVolume()

void Sword25::SoundEngine::setVolume ( float  volume,
SOUND_TYPES  type 
)

Sets the default volume for the different sound types

Parameters
VolumeThe default volume level (0 = off, 1 = full volume)
TypeThe SoundType whose volume is to be changed

◆ getVolume()

float Sword25::SoundEngine::getVolume ( SOUND_TYPES  type)

Specifies the default volume of different sound types

Parameters
TypeThe SoundType
Returns
Returns the standard sound volume for the given type (0 = off, 1 = full volume).

◆ pauseAll()

void Sword25::SoundEngine::pauseAll ( )

Pauses all the sounds that are playing.

◆ resumeAll()

void Sword25::SoundEngine::resumeAll ( )

Resumes all currently stopped sounds

◆ pauseLayer()

void Sword25::SoundEngine::pauseLayer ( uint  layer)

Pauses all sounds of a given layer.

Parameters
LayerThe Sound Layer

◆ resumeLayer()

void Sword25::SoundEngine::resumeLayer ( uint  layer)

Resumes all the sounds in a layer that was previously stopped with PauseLayer()

Parameters
LayerThe Sound Layer

◆ playSound()

bool Sword25::SoundEngine::playSound ( const Common::String fileName,
SOUND_TYPES  type,
float  volume = 1.0f,
float  pan = 0.0f,
bool  loop = false,
int  loopStart = -1,
int  loopEnd = -1,
uint  layer = 0 
)

Plays a sound

Parameters
FileNameThe filename of the sound to be played
TypeThe type of sound
VolumeThe volume of the sound (0 = off, 1 = full volume)
PanPanning (-1 = full left, 1 = right)
LoopIndicates whether the sound should be looped
LoopStartIndicates the starting loop point. If a value less than 0 is passed, the start of the sound is used.
LoopEndIndicates the ending loop point. If a avlue is passed less than 0, the end of the sound is used.
LayerThe sound layer
Returns
Returns true if the playback of the sound was started successfully.
Remarks
If more control is needed over the playing, eg. changing the sound parameters for Volume and Panning, then PlaySoundEx should be used.

◆ playSoundEx()

uint Sword25::SoundEngine::playSoundEx ( const Common::String fileName,
SOUND_TYPES  type,
float  volume = 1.0f,
float  pan = 0.0f,
bool  loop = false,
int  loopStart = -1,
int  loopEnd = -1,
uint  layer = 0,
uint  handleId = 0x1337 
)

Plays a sound

Parameters
TypeThe type of sound
VolumeThe volume of the sound (0 = off, 1 = full volume)
PanPanning (-1 = full left, 1 = right)
LoopIndicates whether the sound should be looped
LoopStartIndicates the starting loop point. If a value less than 0 is passed, the start of the sound is used.
LoopEndIndicates the ending loop point. If a avlue is passed less than 0, the end of the sound is used.
LayerThe sound layer
Returns
Returns a handle to the sound. With this handle, the sound can be manipulated during playback.
Remarks
If more control is needed over the playing, eg. changing the sound parameters for Volume and Panning, then PlaySoundEx should be used.

◆ setSoundVolume()

void Sword25::SoundEngine::setSoundVolume ( uint  handle,
float  volume 
)

Sets the volume of a playing sound

Parameters
HandleThe sound handle
VolumeThe volume of the sound (0 = off, 1 = full volume)

◆ setSoundPanning()

void Sword25::SoundEngine::setSoundPanning ( uint  handle,
float  pan 
)

Sets the panning of a playing sound

Parameters
HandleThe sound handle
PanPanning (-1 = full left, 1 = right)

◆ pauseSound()

void Sword25::SoundEngine::pauseSound ( uint  handle)

Pauses a playing sound

Parameters
HandleThe sound handle

◆ resumeSound()

void Sword25::SoundEngine::resumeSound ( uint  handle)

Resumes a paused sound

Parameters
HandleThe sound handle

◆ stopSound()

void Sword25::SoundEngine::stopSound ( uint  handle)

Stops a playing sound

Parameters
HandleThe sound handle
Remarks
Calling this method invalidates the passed handle; it can no longer be used.

◆ isSoundPaused()

bool Sword25::SoundEngine::isSoundPaused ( uint  handle)

Returns whether a sound is paused

Parameters
HandleThe sound handle
Returns
Returns true if the sound is paused, false otherwise.

◆ isSoundPlaying()

bool Sword25::SoundEngine::isSoundPlaying ( uint  handle)

Returns whether a sound is still playing.

Parameters
HandleThe sound handle
Returns
Returns true if the sound is playing, false otherwise.

◆ getSoundVolume()

float Sword25::SoundEngine::getSoundVolume ( uint  handle)

Returns the volume of a playing sound (0 = off, 1 = full volume)

◆ getSoundPanning()

float Sword25::SoundEngine::getSoundPanning ( uint  handle)

Returns the panning of a playing sound (-1 = full left, 1 = right)

◆ loadResource()

Resource* Sword25::SoundEngine::loadResource ( const Common::String fileName)
overridevirtual

Loads a resource

Returns
Returns the resource if successful, otherwise NULL

Implements Sword25::ResourceService.

◆ canLoadResource()

bool Sword25::SoundEngine::canLoadResource ( const Common::String fileName)
overridevirtual

Checks whether the given name can be loaded by the resource service

Parameters
FileNameDateiname
Returns
Returns true if the resource can be loaded.

Implements Sword25::ResourceService.


The documentation for this class was generated from the following file: