32 if(
type == SOUND::OGG) {
35 platform->getAudio()->stopStream();
47 int vol = 255 * (
volume / 100.0) * (typeVol / 100.0);
75 platform->getAudio()->stopVoice(
voice);
78 platform->getAudio()->stopStream();
99 platform->getAudio()->pauseVoice(
voice);
102 platform->getAudio()->pauseStream();
117 platform->getAudio()->resumeVoice(
voice);
120 platform->getAudio()->resumeStream();
135 return platform->getAudio()->isVoicePlaying(
voice);
137 return platform->getAudio()->isStreamPlaying();
153 int newvol = 255 * (
volume / 100.0) * (typeVol / 100.0);
158 platform->getAudio()->setVoiceVolume(
voice, newvol);
161 platform->getAudio()->setStreamVolume(newvol);
181 if (t == VOLUME_TYPE::SFX) {
183 }
else if (t == VOLUME_TYPE::MUSIC) {
Umbrella header for the platform-agnostic libgui core.
Sound conversion and playback.
static GuiSound * defaultOver
See setDefaultSounds()
int32_t volume
Sound volume (0-100)
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...
void setVolume(int v)
Set sound volume.
bool loop
Loop sound playback.
static GuiSound * activeMusic
Pointer to the last GuiSound with loop==true that was told to play, ie: the "background music" track.
void setLoop(bool l)
Set the sound to loop playback (only applies to OGG)
GuiSound(const uint8_t *s, int32_t l, SOUND t)
Constructor.
static int defaultMusicVolume
Global music volume (0-100) – applies to any looping sound.
static GuiSound * defaultClick
See setDefaultSounds()
void resume()
Resume sound playback.
const uint8_t * sound
Pointer to the sound data.
void play()
Start sound playback.
SOUND type
Sound format type (PCM or OGG)
void stop()
Stop sound playback.
void pause()
Pause sound playback.
int32_t voice
Backend-assigned voice handle (PCM only)
int32_t length
Length of sound data.
bool isPlaying()
Checks if the sound is currently playing.
static GuiSound * playingOGG
Pointer to the GuiSound instance currently occupying the single shared hardware OGG stream.
static int defaultSfxVolume
Global sound effects volume (0-100) – applies to any non-looping sound.
static void setDefaultVolume(VOLUME_TYPE t, int v)
Set global default volume for a volume category (music or sound effects)
SOUND
Encoding of a GuiSound: a short PCM one-shot or a streamed OGG.
VOLUME_TYPE
Global volume category: music (looping stream) or sound effects.