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. | |
Sound conversion and playback.
Generic – delegates to audioSystem for everything platform-specific.
Definition at line 26 of file GuiSound.h.
| GuiSound::GuiSound | ( | const uint8_t * | s, |
| int32_t | l, | ||
| SOUND | t ) |
Constructor.
| s | Pointer to the sound data |
| l | Length of sound data |
| t | Sound format type (PCM or OGG) |
Definition at line 20 of file GuiSound.cpp.
| GuiSound::GuiSound | ( | ) |
Constructor.
Definition at line 18 of file GuiSound.cpp.
| GuiSound::~GuiSound | ( | ) |
Destructor.
Definition at line 30 of file GuiSound.cpp.
|
inlinestatic |
Definition at line 71 of file GuiSound.h.
|
inlinestatic |
Definition at line 69 of file GuiSound.h.
| bool GuiSound::isPlaying | ( | ) |
Checks if the sound is currently playing.
Definition at line 127 of file GuiSound.cpp.
| void GuiSound::pause | ( | ) |
Pause sound playback.
Definition at line 91 of file GuiSound.cpp.
| void GuiSound::play | ( | ) |
Start sound playback.
Definition at line 44 of file GuiSound.cpp.
| void GuiSound::resume | ( | ) |
Resume sound playback.
Definition at line 109 of file GuiSound.cpp.
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().
| over | Played when a button gets the selection |
| click | Played when a button is clicked |
Definition at line 173 of file GuiSound.cpp.
|
static |
Set global default volume for a volume category (music or sound effects)
| t | Volume category (MUSIC or SFX) |
| v | Volume (0-100) |
Definition at line 179 of file GuiSound.cpp.
| void GuiSound::setLoop | ( | bool | l | ) |
Set the sound to loop playback (only applies to OGG)
| l | Loop (true to loop) |
Definition at line 168 of file GuiSound.cpp.
| void GuiSound::setVolume | ( | int | v | ) |
| void GuiSound::stop | ( | ) |
Stop sound playback.
Definition at line 67 of file GuiSound.cpp.
|
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.
|
staticprotected |
Definition at line 84 of file GuiSound.h.
|
staticprotected |
Global music volume (0-100) – applies to any looping sound.
Definition at line 81 of file GuiSound.h.
|
staticprotected |
Definition at line 83 of file GuiSound.h.
|
staticprotected |
Global sound effects volume (0-100) – applies to any non-looping sound.
Definition at line 82 of file GuiSound.h.
|
protected |
Length of sound data.
Definition at line 76 of file GuiSound.h.
|
protected |
Loop sound playback.
Definition at line 79 of file GuiSound.h.
|
staticprotected |
Pointer to the GuiSound instance currently occupying the single shared hardware OGG stream.
Definition at line 87 of file GuiSound.h.
|
protected |
Pointer to the sound data.
Definition at line 74 of file GuiSound.h.
|
protected |
Sound format type (PCM or OGG)
Definition at line 75 of file GuiSound.h.
|
protected |
Backend-assigned voice handle (PCM only)
Definition at line 77 of file GuiSound.h.
|
protected |
Sound volume (0-100)
Definition at line 78 of file GuiSound.h.