GlistEngine
Loading...
Searching...
No Matches
gSound Class Reference

A sound class using miniaudio with ma_engine and ma_sound. More...

#include <gSound.h>

Inheritance diagram for gSound:
Collaboration diagram for gSound:

Public Member Functions

 gSound ()
 
virtual ~gSound ()
 
int load (const std::string &fullPath) override
 Loads a sound file from the full file system path.
 
int loadSound (const std::string &soundPath) override
 Loads the sound file from the given project-relative path.
 
void play () override
 Starts sound playback and resets the position to the beginning.
 
bool isLoaded () override
 
bool isPlaying () override
 
bool isPaused () override
 
void setPaused (bool isPaused) override
 Pauses or resumes the playback.
 
void stop () override
 Stops playback and resets position to the beginning.
 
void close () override
 Unloads and frees the sound resource.
 
int getDuration () override
 Returns the total duration of the sound in milliseconds.
 
int getPosition () override
 Returns the current playback position in milliseconds.
 
void setPosition (int position) override
 Sets the current playback position in milliseconds.
 
LoopType getLoopType () override
 
void setLoopType (LoopType loopType) override
 Sets the loop type for playback.
 
float getVolume () override
 Gets the current volume level.
 
void setVolume (float volume) override
 Sets the volume level.
 
const std::string & getPath () override
 Gets the path to the currently loaded file.
 
- Public Member Functions inherited from gObject
 gObject ()
 
void logi (std::string message)
 
void logd (std::string message)
 
void logw (std::string message)
 
void loge (std::string message)
 
void logi (std::string tag, std::string message)
 
void logd (std::string tag, std::string message)
 
void logw (std::string tag, std::string message)
 
void loge (std::string tag, std::string message)
 

Additional Inherited Members

- Public Types inherited from gBaseSound
enum  LoopType : int { LOOPTYPE_DEFAULT = 0 , LOOPTYPE_NONE = 1 , LOOPTYPE_NORMAL = 2 }
 
- Static Public Member Functions inherited from gObject
static std::string gGetAppDir ()
 
static std::string gGetAssetsDir ()
 
static void gSetAssetsDir (std::string assetsDir)
 
static std::string gGetFilesDir ()
 
static std::string gGetImagesDir ()
 
static std::string gGetFontsDir ()
 
static std::string gGetModelsDir ()
 
static std::string gGetTexturesDir ()
 
static std::string gGetShadersDir ()
 
static std::string gGetSoundsDir ()
 
static std::string gGetDatabasesDir ()
 
static std::string gGetVideosDir ()
 
static void setCurrentResolution (int scalingNo, int currentResolutionNo)
 
- Static Public Attributes inherited from gObject
static const int LOGLEVEL_SILENT
 
static const int LOGLEVEL_DEBUG
 
static const int LOGLEVEL_INFO
 
static const int LOGLEVEL_WARNING
 
static const int LOGLEVEL_ERROR
 
- Static Protected Attributes inherited from gObject
static int renderpassnum
 
static int renderpassno
 
static int releasescaling
 
static int releaseresolution
 

Detailed Description

A sound class using miniaudio with ma_engine and ma_sound.

This class wraps a miniaudio ma_sound object and provides functions for loading, playing, pausing, stopping, seeking, and controlling volume and looping. Multiple gSound instances can be played simultaneously.

Constructor & Destructor Documentation

◆ gSound()

gSound::gSound ( )

◆ ~gSound()

virtual gSound::~gSound ( )
virtual

Member Function Documentation

◆ close()

void gSound::close ( )
overridevirtual

Unloads and frees the sound resource.

Implements gBaseSound.

◆ getDuration()

int gSound::getDuration ( )
overridevirtual

Returns the total duration of the sound in milliseconds.

Returns
Duration in ms.

Implements gBaseSound.

◆ getLoopType()

LoopType gSound::getLoopType ( )
overridevirtual

Implements gBaseSound.

◆ getPath()

const std::string & gSound::getPath ( )
overridevirtual

Gets the path to the currently loaded file.

Returns
File path as a string reference.

Implements gBaseSound.

◆ getPosition()

int gSound::getPosition ( )
overridevirtual

Returns the current playback position in milliseconds.

Returns
Position in ms.

Implements gBaseSound.

◆ getVolume()

float gSound::getVolume ( )
overridevirtual

Gets the current volume level.

Returns
Volume between 0.0 (mute) and 1.0 (max).

Implements gBaseSound.

◆ isLoaded()

bool gSound::isLoaded ( )
overridevirtual

Implements gBaseSound.

◆ isPaused()

bool gSound::isPaused ( )
overridevirtual

Implements gBaseSound.

◆ isPlaying()

bool gSound::isPlaying ( )
overridevirtual

Implements gBaseSound.

◆ load()

int gSound::load ( const std::string &  fullPath)
overridevirtual

Loads a sound file from the full file system path.

Parameters
fullPathFull absolute path to the audio file.
Returns
int 1 if successful, 0 otherwise.

Implements gBaseSound.

◆ loadSound()

int gSound::loadSound ( const std::string &  soundPath)
overridevirtual

Loads the sound file from the given project-relative path.

Parameters
soundPathProject-relative path to the sound file.
Returns
int 1 if successful, 0 otherwise.

Implements gBaseSound.

◆ play()

void gSound::play ( )
overridevirtual

Starts sound playback and resets the position to the beginning.

Implements gBaseSound.

◆ setLoopType()

void gSound::setLoopType ( LoopType  loopType)
overridevirtual

Sets the loop type for playback.

Parameters
loopTypeLooping behavior.

Implements gBaseSound.

◆ setPaused()

void gSound::setPaused ( bool  isPaused)
overridevirtual

Pauses or resumes the playback.

Parameters
isPausedTrue to pause, false to resume.

Implements gBaseSound.

◆ setPosition()

void gSound::setPosition ( int  position)
overridevirtual

Sets the current playback position in milliseconds.

Parameters
positionNew position in ms.

Implements gBaseSound.

◆ setVolume()

void gSound::setVolume ( float  volume)
overridevirtual

Sets the volume level.

Parameters
volumeVolume between 0.0 (mute) and 1.0 (max).

Implements gBaseSound.

◆ stop()

void gSound::stop ( )
overridevirtual

Stops playback and resets position to the beginning.

Implements gBaseSound.


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