libgui 3.00
libgui is a GUI library for the GameCube, Wii, and Wii U
 
Loading...
Searching...
No Matches
GuiSound Class Reference

Sound conversion and playback. More...

#include <GuiSound.h>

Public Member Functions

 GuiSound (const uint8_t *s, int32_t l, SOUND t)
 Constructor.
 
 GuiSound ()
 Constructor.
 
 ~GuiSound ()
 Destructor.
 
void play ()
 Start sound playback.
 
void stop ()
 Stop sound playback.
 
void pause ()
 Pause sound playback.
 
void resume ()
 Resume sound playback.
 
bool isPlaying ()
 Checks if the sound is currently playing.
 
void setVolume (int v)
 Set sound volume.
 
void setLoop (bool l)
 Set the sound to loop playback (only applies to OGG)
 

Static Public Member Functions

static void setDefaultVolume (VOLUME_TYPE t, int v)
 Set global default volume for a volume category (music or sound effects)
 
static void setDefaultSounds (GuiSound *over, GuiSound *click)
 Registers the sounds every GuiButton and UiScope uses Call it once at startup, so pages need no sound objects of their own.
 
static GuiSound * getDefaultOver ()
 
static GuiSound * getDefaultClick ()
 

Protected Attributes

const uint8_t * sound = nullptr
 Pointer to the sound data.
 
SOUND type = SOUND::NONE
 Sound format type (PCM or OGG)
 
int32_t length = 0
 Length of sound data.
 
int32_t voice = -1
 Backend-assigned voice handle (PCM only)
 
int32_t volume = 100
 Sound volume (0-100)
 
bool loop = false
 Loop sound playback.
 

Static Protected Attributes

static int defaultMusicVolume = 100
 Global music volume (0-100) – applies to any looping sound.
 
static int defaultSfxVolume = 100
 Global sound effects volume (0-100) – applies to any non-looping sound.
 
static GuiSound * defaultOver = nullptr
 See setDefaultSounds()
 
static GuiSound * defaultClick = nullptr
 See setDefaultSounds()
 
static GuiSound * playingOGG = nullptr
 Pointer to the GuiSound instance currently occupying the single shared hardware OGG stream.
 
static GuiSound * activeMusic = nullptr
 Pointer to the last GuiSound with loop==true that was told to play, ie: the "background music" track.
 

Detailed Description

Sound conversion and playback.

Generic – delegates to audioSystem for everything platform-specific.

Definition at line 26 of file GuiSound.h.

Constructor & Destructor Documentation

◆ GuiSound() [1/2]

GuiSound::GuiSound ( const uint8_t * s,
int32_t l,
SOUND t )

Constructor.

Parameters
sPointer to the sound data
lLength of sound data
tSound format type (PCM or OGG)

Definition at line 20 of file GuiSound.cpp.

◆ GuiSound() [2/2]

GuiSound::GuiSound ( )

Constructor.

Definition at line 18 of file GuiSound.cpp.

◆ ~GuiSound()

GuiSound::~GuiSound ( )

Destructor.

Definition at line 30 of file GuiSound.cpp.

Member Function Documentation

◆ getDefaultClick()

static GuiSound * GuiSound::getDefaultClick ( )
inlinestatic
Returns
the click sound registered by setDefaultSounds(), or nullptr

Definition at line 71 of file GuiSound.h.

◆ getDefaultOver()

static GuiSound * GuiSound::getDefaultOver ( )
inlinestatic
Returns
the over sound registered by setDefaultSounds(), or nullptr

Definition at line 69 of file GuiSound.h.

◆ isPlaying()

bool GuiSound::isPlaying ( )

Checks if the sound is currently playing.

Returns
true if sound is playing, false otherwise

Definition at line 127 of file GuiSound.cpp.

◆ pause()

void GuiSound::pause ( )

Pause sound playback.

Definition at line 91 of file GuiSound.cpp.

◆ play()

void GuiSound::play ( )

Start sound playback.

Definition at line 44 of file GuiSound.cpp.

◆ resume()

void GuiSound::resume ( )

Resume sound playback.

Definition at line 109 of file GuiSound.cpp.

◆ setDefaultSounds()

void GuiSound::setDefaultSounds ( GuiSound * over,
GuiSound * click )
static

Registers the sounds every GuiButton and UiScope uses Call it once at startup, so pages need no sound objects of their own.

The app owns both sounds and keeps them alive while such widgets exist. nullptr (the initial state) is silence; a button can still override either with setSoundOver()/setSoundClick().

Parameters
overPlayed when a button gets the selection
clickPlayed when a button is clicked

Definition at line 173 of file GuiSound.cpp.

◆ setDefaultVolume()

void GuiSound::setDefaultVolume ( VOLUME_TYPE t,
int v )
static

Set global default volume for a volume category (music or sound effects)

Parameters
tVolume category (MUSIC or SFX)
vVolume (0-100)

Definition at line 179 of file GuiSound.cpp.

◆ setLoop()

void GuiSound::setLoop ( bool l)

Set the sound to loop playback (only applies to OGG)

Parameters
lLoop (true to loop)

Definition at line 168 of file GuiSound.cpp.

◆ setVolume()

void GuiSound::setVolume ( int v)

Set sound volume.

Parameters
vSound volume (0-100)

Definition at line 145 of file GuiSound.cpp.

◆ stop()

void GuiSound::stop ( )

Stop sound playback.

Definition at line 67 of file GuiSound.cpp.

Member Data Documentation

◆ activeMusic

GuiSound * GuiSound::activeMusic = nullptr
staticprotected

Pointer to the last GuiSound with loop==true that was told to play, ie: the "background music" track.

Definition at line 90 of file GuiSound.h.

◆ defaultClick

GuiSound * GuiSound::defaultClick = nullptr
staticprotected

See setDefaultSounds()

Definition at line 84 of file GuiSound.h.

◆ defaultMusicVolume

int GuiSound::defaultMusicVolume = 100
staticprotected

Global music volume (0-100) – applies to any looping sound.

Definition at line 81 of file GuiSound.h.

◆ defaultOver

GuiSound * GuiSound::defaultOver = nullptr
staticprotected

See setDefaultSounds()

Definition at line 83 of file GuiSound.h.

◆ defaultSfxVolume

int GuiSound::defaultSfxVolume = 100
staticprotected

Global sound effects volume (0-100) – applies to any non-looping sound.

Definition at line 82 of file GuiSound.h.

◆ length

int32_t GuiSound::length = 0
protected

Length of sound data.

Definition at line 76 of file GuiSound.h.

◆ loop

bool GuiSound::loop = false
protected

Loop sound playback.

Definition at line 79 of file GuiSound.h.

◆ playingOGG

GuiSound * GuiSound::playingOGG = nullptr
staticprotected

Pointer to the GuiSound instance currently occupying the single shared hardware OGG stream.

Definition at line 87 of file GuiSound.h.

◆ sound

const uint8_t* GuiSound::sound = nullptr
protected

Pointer to the sound data.

Definition at line 74 of file GuiSound.h.

◆ type

SOUND GuiSound::type = SOUND::NONE
protected

Sound format type (PCM or OGG)

Definition at line 75 of file GuiSound.h.

◆ voice

int32_t GuiSound::voice = -1
protected

Backend-assigned voice handle (PCM only)

Definition at line 77 of file GuiSound.h.

◆ volume

int32_t GuiSound::volume = 100
protected

Sound volume (0-100)

Definition at line 78 of file GuiSound.h.


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