persona-3-dual
A DS demake of Persona 3
Loading...
Searching...
No Matches
MusicComponent.cpp
Go to the documentation of this file.
1#include "MusicComponent.hpp"
2#include "core/globals.hpp"
3#include "core/logger.hpp"
4#include "types/aeTypes.hpp"
5
10
12{
13 std::string filename = getAudioFilepath(type, audioId);
14 if (filename.empty())
15 {
16 logMessage(LogSeverity::WARNING, "Empty filename for audio type/id");
17 return;
18 }
19 std::string path = fatBasePath + "music/" + filename + ".qoa";
20 ae::q20_12_t loopStartTime = getLoopStart(type, audioId);
21 ae::q20_12_t loopEndTime = getLoopEnd(type, audioId);
22 logMessage(LogSeverity::DEBUG, "Registering music: " + filename);
23 am.registerAudio(path, loopStartTime, loopEndTime);
24}
25
27{
28 am.playAudio();
29}
30
32{
33 am.pauseAudio();
34}
35
37{
38 am.stopAudio();
39}
Orchestrates music.
ae::q20_12_t getLoopStart(AudioType type, int id)
Get the loop start time.
Definition audioDb.cpp:104
ae::q20_12_t getLoopEnd(AudioType type, int id)
Get the loop end time.
Definition audioDb.cpp:115
std::string getAudioFilepath(AudioType type, int id)
Get the audio file path.
Definition audioDb.cpp:93
AudioType
Definition audioDb.hpp:6
AudioManager & am
void registerMusic(AudioType type, AudioID audioId)
Wrapper to set up the music to play.
void destroy() override
Automatically deregisters the currently registered music, if any.
void playMusic()
Play the registered song if currently paused.
void pauseMusic()
Pause the registered song if currently playing.
void stopMusic()
Deregister the currently registered music.
Holds global variables used game-wide.
std::string fatBasePath
Definition main.cpp:38
void logMessage(LogSeverity severity, std::string_view message, std::source_location location)
Logs a diagnostic message and halts only for fatal messages.
Definition logger.cpp:110
Util to handle error logging.