NWengine 0.9
Loading...
Searching...
No Matches
Sound Class Reference

Represents a sound asset. More...

#include <Audio.h>

Inheritance diagram for Sound:
Asset

Public Member Functions

 Sound ()=default
 Default constructor for the Sound class.
 
void Play ()
 Plays the sound.
 
void SetVolume (float volume)
 Sets the volume of the sound.
 
void SetFrequency (float frequency)
 Sets the frequency of the sound.
 
void SetLoop (bool loop)
 Sets whether the sound should loop or not.
 
void Stop ()
 Stops the sound.
 
bool HasFinished ()
 Checks if the sound has finished playing.
 
void Clean () override
 Cleans up the sound.
 
AssetGetFromCache (void *id)
 Gets the sound asset from the cache.
 
AssetLoadFromFile (const char *path, void *id)
 Loads the sound asset from a file.
 
AssetLoadFromBuffer (void *alBuffer, void *id)
 Loads the sound asset from a buffer.
 
 NW_DECL_RES_LIST (SoundIdentifier, Sound)
 Declares the resource list for SoundIdentifier and Sound.
 

Static Public Member Functions

static bool Init ()
 Initializes the Sound class.
 
static void Destroy ()
 Destroys the Sound class.
 

Public Attributes

uint32 _buffID = 0
 
uint32 _source = 0
 
float volume = 1.0f
 
float frequency = 1.0f
 
bool isLooping = false
 
bool isPlaying = false
 

Detailed Description

Represents a sound asset.

Member Function Documentation

◆ Clean()

void Sound::Clean ( )
overridevirtual

Cleans up the sound.

Reimplemented from Asset.

◆ GetFromCache()

Asset * Sound::GetFromCache ( void * id)
virtual

Gets the sound asset from the cache.

Parameters
idThe ID of the sound asset.
Returns
The sound asset if found, nullptr otherwise.

Reimplemented from Asset.

◆ HasFinished()

bool Sound::HasFinished ( )

Checks if the sound has finished playing.

Returns
True if the sound has finished playing, false otherwise.

◆ Init()

bool Sound::Init ( )
static

Initializes the Sound class.

Returns
True if initialization is successful, false otherwise.

◆ LoadFromBuffer()

Asset * Sound::LoadFromBuffer ( void * alBuffer,
void * id )
virtual

Loads the sound asset from a buffer.

Parameters
alBufferThe OpenAL buffer.
idThe ID of the sound asset.
Returns
The loaded sound asset if successful, nullptr otherwise.

Reimplemented from Asset.

◆ LoadFromFile()

Asset * Sound::LoadFromFile ( const char * path,
void * id )
virtual

Loads the sound asset from a file.

Parameters
pathThe path of the sound file.
idThe ID of the sound asset.
Returns
The loaded sound asset if successful, nullptr otherwise.

Reimplemented from Asset.

◆ SetFrequency()

void Sound::SetFrequency ( float frequency)

Sets the frequency of the sound.

Parameters
frequencyThe frequency value to set.

◆ SetLoop()

void Sound::SetLoop ( bool loop)

Sets whether the sound should loop or not.

Parameters
loopTrue to enable looping, false otherwise.

◆ SetVolume()

void Sound::SetVolume ( float volume)

Sets the volume of the sound.

Parameters
volumeThe volume value to set.

Member Data Documentation

◆ _buffID

uint32 Sound::_buffID = 0

The buffer ID of the sound.

◆ _source

uint32 Sound::_source = 0

The source ID of the sound.

◆ frequency

float Sound::frequency = 1.0f

The frequency of the sound.

◆ isLooping

bool Sound::isLooping = false

Flag indicating if the sound is looping.

◆ isPlaying

bool Sound::isPlaying = false

Flag indicating if the sound is currently playing.

◆ volume

float Sound::volume = 1.0f

The volume of the sound.


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