libgui 2.01
libgui is a GUI library for the GameCube, Wii, and Wii U
 
Loading...
Searching...
No Matches
GuiSound.h
1/****************************************************************************
2 * libgui
3 * Daryl Borth 2009-2026
4 * GuiSound.h
5 ***************************************************************************/
6#pragma once
7
10enum class SOUND {
11 NONE,
12 PCM,
13 OGG
14};
15
18enum class VOLUME_TYPE {
19 MUSIC,
20 SFX
21};
22
27{
28 public:
33 GuiSound(const uint8_t * s, int32_t l, SOUND t);
35 GuiSound();
37 ~GuiSound();
39 void play();
41 void stop();
43 void pause();
45 void resume();
48 bool isPlaying();
51 void setVolume(int v);
54 void setLoop(bool l);
55
59 static void setDefaultVolume(VOLUME_TYPE t, int v);
60
61 protected:
62 const uint8_t * sound = nullptr;
63 SOUND type = SOUND::NONE;
64 int32_t length = 0;
65 int32_t voice = -1;
66 int32_t volume = 100;
67 bool loop = false;
68
69 static int defaultMusicVolume;
70 static int defaultSfxVolume;
71
74
77};
int32_t volume
Sound volume (0-100)
Definition GuiSound.h:66
void setVolume(int v)
Set sound volume.
Definition GuiSound.cpp:143
bool loop
Loop sound playback.
Definition GuiSound.h:67
static GuiSound * activeMusic
Pointer to the last GuiSound with loop==true that was told to play, ie: the "background music" track.
Definition GuiSound.h:76
GuiSound()
Constructor.
Definition GuiSound.cpp:16
void setLoop(bool l)
Set the sound to loop playback (only applies to OGG)
Definition GuiSound.cpp:166
~GuiSound()
Destructor.
Definition GuiSound.cpp:28
GuiSound(const uint8_t *s, int32_t l, SOUND t)
Constructor.
Definition GuiSound.cpp:18
static int defaultMusicVolume
Global music volume (0-100) – applies to any looping sound.
Definition GuiSound.h:69
void resume()
Resume sound playback.
Definition GuiSound.cpp:107
const uint8_t * sound
Pointer to the sound data.
Definition GuiSound.h:62
void play()
Start sound playback.
Definition GuiSound.cpp:42
SOUND type
Sound format type (PCM or OGG)
Definition GuiSound.h:63
void stop()
Stop sound playback.
Definition GuiSound.cpp:65
void pause()
Pause sound playback.
Definition GuiSound.cpp:89
int32_t voice
Backend-assigned voice handle (PCM only)
Definition GuiSound.h:65
int32_t length
Length of sound data.
Definition GuiSound.h:64
bool isPlaying()
Checks if the sound is currently playing.
Definition GuiSound.cpp:125
static GuiSound * playingOGG
Pointer to the GuiSound instance currently occupying the single shared hardware OGG stream.
Definition GuiSound.h:73
static int defaultSfxVolume
Global sound effects volume (0-100) – applies to any non-looping sound.
Definition GuiSound.h:70
static void setDefaultVolume(VOLUME_TYPE t, int v)
Set global default volume for a volume category (music or sound effects)
Definition GuiSound.cpp:171
SOUND
Encoding of a GuiSound: a short PCM one-shot or a streamed OGG.
Definition GuiSound.h:10
VOLUME_TYPE
Global volume category: music (looping stream) or sound effects.
Definition GuiSound.h:18