persona-3-dual
A DS demake of Persona 3
Loading...
Searching...
No Matches
AudioManager.hpp
Go to the documentation of this file.
1
6
7#pragma once
9#include <aegis/manager.hpp>
10#include <maxmod9.h>
11#include <string>
12
13class AudioManager : public ae::Manager, public ae::Singleton<AudioManager>
14{
15 public:
16 void init() override;
17
18 void process() override;
19
20 void shutdown() override;
21
29 void registerAudio(std::string path, ae::q20_12_t loopStartTime, ae::q20_12_t loopEndTime);
30
34 void playAudio();
35
39 void pauseAudio();
40
44 void stopAudio();
45
51 void registerSFX(SFX sfx);
52
60 void playSFX(SFX sfx, int volume, int panning);
61
65 void stopSFX();
66
72 ae::q20_12_t getDuration(); // unused
73
79 ae::q20_12_t getTime();
80
81 private:
82 friend class Singleton<AudioManager>;
83 AudioManager() = default;
84
85 qoaplay_desc* qp = nullptr;
86 bool isLoopingEnabled = false;
87 bool isAudioRegistered = false;
88 int startFrame = 0;
89 int endFrame = 0;
90
96 int getFrame();
97
103 void seekFrame(int frame);
104
111 void setLoop(ae::q20_12_t startTime, ae::q20_12_t endTime);
112
116 void loop();
117
121 void rewind();
122
128 uint32_t decodeFrame();
129
137 uint32_t decode(short* sample_data, int num_samples);
138
147 static mm_word audioCallback(mm_word length, mm_addr dest, mm_stream_formats format);
148
157 mm_word processStream(mm_word length, mm_addr dest, mm_stream_formats format);
158};
SFX
SFX wrapper enums.
static mm_word audioCallback(mm_word length, mm_addr dest, mm_stream_formats format)
Callback for maxmod audio streaming, acting as a wrapper for processStream.
void stopSFX()
Stop all currently playing SFXs.
void setLoop(ae::q20_12_t startTime, ae::q20_12_t endTime)
Set the audio looping points.
void registerSFX(SFX sfx)
Register the SFX to be played.
void stopAudio()
Deregister the currently registered audio.
void pauseAudio()
Pause the currently registered audio, if playing.
ae::q20_12_t getDuration()
Get the total duration of the audio.
void process() override
mm_word processStream(mm_word length, mm_addr dest, mm_stream_formats format)
Processes the next audio data to play.
void rewind()
Move to the start of the audio track.
ae::q20_12_t getTime()
Get the current time of the audio.
void seekFrame(int frame)
Move to the specified audio frame.
void shutdown() override
void loop()
Looping logic.
void registerAudio(std::string path, ae::q20_12_t loopStartTime, ae::q20_12_t loopEndTime)
Sets up the audio track to be played.
uint32_t decodeFrame()
Decode the current audio frame.
void playSFX(SFX sfx, int volume, int panning)
Play the specified registered SFX.
void init() override
int getFrame()
Get the current audio frame.
uint32_t decode(short *sample_data, int num_samples)
Decode the given audio sample based on the current frame.
void playAudio()
Play the currently registered audio, if paused.
AudioManager()=default
qoaplay_desc * qp
volatile int32_t frame
Definition main.cpp:35
QOA audio stream data.