5#ifndef DUALIE_MUSIC_HPP
6#define DUALIE_MUSIC_HPP
16#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
28 ndspWaveBuf m_waveBufs[3];
29 int16_t* m_audioBuffer =
nullptr;
31 OggOpusFile* m_opusFile;
36 volatile bool m_quit =
false;
37 bool m_looping =
false;
39 bool fillBuffer(ndspWaveBuf* waveBuf_);
40 void allocateBuffers();
42 void audioCallback(
void*
const nul_);
44 static void callbackWrapper(
void* obj);
45 static void threadWrapper(
void* obj);
46 std::string getOpusErrorString(
int error);
79 static constexpr int SAMPLE_RATE = 48000;
80 static constexpr int SAMPLES_PER_BUF = SAMPLE_RATE * 120 / 1000;
81 static constexpr int CHANNELS_PER_SAMPLE = 2;
82 static constexpr int THREAD_AFFINITY = -1;
83 static constexpr int THREAD_STACK_SZ = 32 * 1024;
84 static constexpr size_t WAVEBUF_SIZE = SAMPLES_PER_BUF * CHANNELS_PER_SAMPLE *
sizeof(int16_t);
A class that handles the playback of opus audio files.
Definition Music.hpp:25
void setLooping(bool looping)
Sets whether the music should loop when finished.
Definition Music.cpp:257
void stop()
Stops the currently playing song. Maintains the current position of the music.
Definition Music.cpp:67
void restart()
Restarts the song from the beginning. If playback is stopped, it plays it.
Definition Music.cpp:57
void play()
Plays the opus music file loaded.
Definition Music.cpp:34
void loadFromFile(std::string path)
loads a opus file from romfs
Definition Music.cpp:23