libgui 2.01
libgui is a GUI library for the GameCube, Wii, and Wii U
 
Loading...
Searching...
No Matches
WutAudioDriver.h
1/****************************************************************************
2 * Platform Abstraction Layer (WUT driver)
3 * Daryl Borth 2026
4 * WutAudioDriver.h
5 ***************************************************************************/
6#pragma once
7
8#include <stdint.h>
9#include <sndcore2/core.h>
10#include <sndcore2/voice.h>
11#include "../AudioDriver.h"
12#include "../../libgui/GuiSoundOggPlayer.h"
13
19{
20 public:
21 void init() override;
22 void start() override;
23 void stop() override;
24 void shutdown() override;
25
26 int32_t playVoice(const uint8_t* data, int32_t length, int volume) override;
27 void stopVoice(int32_t voice) override;
28 void pauseVoice(int32_t voice) override;
29 void resumeVoice(int32_t voice) override;
30 bool isVoicePlaying(int32_t voice) override;
31 void setVoiceVolume(int32_t voice, int volume) override;
32
33 void playStream(const uint8_t* data, int32_t length, bool loop, int volume) override;
34 void stopStream() override;
35 void pauseStream() override;
36 void resumeStream() override;
37 bool isStreamPlaying() override;
38 void setStreamVolume(int volume) override;
39
43
44 private:
45 struct WutVoiceSlot {
46 AXVoice* voice;
47 bool active;
48 };
49
50 GuiSoundOggPlayer oggPlayer;
51 WutVoiceSlot voices[16];
52 int nextVoiceSlot;
53
54 AXVoice* streamVoiceL;
55 AXVoice* streamVoiceR;
56
57 // Circular Ring Buffer (16,384 samples = 32KB per channel)
58 static const uint32_t STREAM_BUFFER_SAMPLES = 16384;
59 alignas(32) int16_t streamBufL[STREAM_BUFFER_SAMPLES];
60 alignas(32) int16_t streamBufR[STREAM_BUFFER_SAMPLES];
61
62 uint32_t writeOffset;
63 bool eofSilenceWritten;
64 int streamVolume;
65};
Platform audio backend GuiSound delegates to: fixed one-shot PCM voices plus one background OGG strea...
Definition AudioDriver.h:18
Platform-agnostic Tremor (integer OGG) decoder.
Wii U AudioDriver: AX (sndcore2), 16 fixed AXVoice slots for one-shots plus a dedicated stereo stream...
void pauseStream() override
Pauses the stream, keeping its position.
void init() override
Allocates the backend's audio resources. Does not start playback; see start().
void resumeVoice(int32_t voice) override
Resumes a voice paused with pauseVoice().
void stopVoice(int32_t voice) override
Stops a voice returned by playVoice() and frees its slot.
void resumeStream() override
Resumes a stream paused with pauseStream().
void shutdown() override
Releases everything init() allocated. Call stop() first.
void stopStream() override
Stops the stream started by playStream().
void start() override
Starts the audio backend running (eg. registers the DSP/AX callback).
void setVoiceVolume(int32_t voice, int volume) override
Changes the volume of a playing voice.
int32_t playVoice(const uint8_t *data, int32_t length, int volume) override
Start a one-shot/short PCM voice.
void stop() override
Stops the audio backend.
void setStreamVolume(int volume) override
Changes the stream volume.
bool isStreamPlaying() override
bool isVoicePlaying(int32_t voice) override
void handleStreamCallback()
AX frame callback hook that refills the stream ring buffers.
void pauseVoice(int32_t voice) override
Pauses a playing voice, keeping its position and slot.
void playStream(const uint8_t *data, int32_t length, bool loop, int volume) override
Streamed (OGG) playback.