persona-3-dual
A DS demake of Persona 3
Loading...
Searching...
No Matches
audioDb.cpp
Go to the documentation of this file.
1#include "data/audioDb.hpp"
2#include "core/logger.hpp"
3#include <string>
4
5static const AudioDBEntry AUDIO_DB_ENTRY[] = {
6 // battle
8 static_cast<int>(BattleAudio::MASS_DESTRUCTION),
9 "battle/mass_destruction",
10 ae::q20_12_t{0.000},
11 ae::q20_12_t{-1.000}},
12
13 // location
15 static_cast<int>(LocationAudio::IWATODAI_DORM),
16 "locations/iwatodaiDorm/iwatodai_dorm",
17 ae::q20_12_t{1.300},
18 ae::q20_12_t{-1.000}},
20 static_cast<int>(LocationAudio::SUMMER_BOUND),
21 "locations/iwatodaiStreets/summer_bound",
22 ae::q20_12_t{0.000},
23 ae::q20_12_t{-1.000}}, // TODO: get correct looping points
25 static_cast<int>(LocationAudio::COLOR_YOUR_NIGHT),
26 "locations/paulowniaMall/overworld/color_your_night",
27 ae::q20_12_t{0.000},
28 ae::q20_12_t{-1.000}}, // TODO: get correct looping points
30 static_cast<int>(LocationAudio::PAULOWNIA_MALL),
31 "locations/paulowniaMall/station/paulownia_mall",
32 ae::q20_12_t{0.000},
33 ae::q20_12_t{-1.000}}, // TODO: get correct looping points
34
35 // menu
37 static_cast<int>(MenuAudio::MISTIC),
38 "menus/contract/mistic",
39 ae::q20_12_t{0.000},
40 ae::q20_12_t{-1.000}},
42 static_cast<int>(MenuAudio::TIGHTROPE),
43 "menus/title/tightrope",
44 ae::q20_12_t{17.962},
45 ae::q20_12_t{66.082}},
47 static_cast<int>(MenuAudio::ARIA_OF_THE_SOUL),
48 "menus/velvetRoom/aria_of_the_soul",
49 ae::q20_12_t{0.000},
50 ae::q20_12_t{-1.000}},
51
52 // other
54 static_cast<int>(OtherAudio::AFTER_THE_BATTLE),
55 "other/after_the_battle",
56 ae::q20_12_t{24.000},
57 ae::q20_12_t{-1.000}},
60 "other/because_i_will_protect_you",
61 ae::q20_12_t{.000},
62 ae::q20_12_t{-1.000}},
65 "other/club_escapade_nouveau_metalmoth_remix",
66 ae::q20_12_t{0.000},
67 ae::q20_12_t{-1.000}}, // TODO: get correct looping points
68 {AudioType::OTHER, static_cast<int>(OtherAudio::PEACE), "other/peace", ae::q20_12_t{47.060}, ae::q20_12_t{-1.000}},
70 static_cast<int>(OtherAudio::WANT_TO_BE_CLOSE),
71 "other/want_to_be_close",
72 ae::q20_12_t{47.060},
73 ae::q20_12_t{-1.000}},
74};
75
76static const int AUDIO_DB_ENTRY_LEN = sizeof(AUDIO_DB_ENTRY) / sizeof(AUDIO_DB_ENTRY[0]);
77
79{
80 for (int i = 0; i < AUDIO_DB_ENTRY_LEN; ++i)
81 {
82 if (AUDIO_DB_ENTRY[i].type == type && AUDIO_DB_ENTRY[i].id == id)
83 {
84 return AUDIO_DB_ENTRY[i];
85 }
86 }
88 "AudioDBEntry not found for type: " + std::to_string(static_cast<int>(type)) +
89 " id: " + std::to_string(id));
91}
92
93std::string getAudioFilepath(AudioType type, int id)
94{
95 AudioDBEntry entry = getAudioDBEntry(type, id);
96 if (entry.type == AudioType::NONE)
97 {
98 return "";
99 }
100
101 return entry.filename;
102}
103
104ae::q20_12_t getLoopStart(AudioType type, int id)
105{
106 AudioDBEntry entry = getAudioDBEntry(type, id);
107 if (entry.type == AudioType::NONE)
108 {
109 return ae::q20_12_t{0.000};
110 }
111
112 return entry.loopStartTime;
113}
114
115ae::q20_12_t getLoopEnd(AudioType type, int id)
116{
117 AudioDBEntry entry = getAudioDBEntry(type, id);
118 if (entry.type == AudioType::NONE)
119 {
120 return ae::q20_12_t{-1.000};
121 }
122
123 return entry.loopEndTime;
124}
static const int AUDIO_DB_ENTRY_LEN
Definition audioDb.cpp:76
static const AudioDBEntry AUDIO_DB_ENTRY[]
Definition audioDb.cpp:5
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
AudioDBEntry getAudioDBEntry(AudioType type, int id)
Internal helper to get the AudioDBEntry struct.
Definition audioDb.cpp:78
@ MASS_DESTRUCTION
Definition audioDb.hpp:27
AudioType
Definition audioDb.hpp:6
@ BECAUSE_I_WILL_PROTECT_YOU
Definition audioDb.hpp:48
@ AFTER_THE_BATTLE
Definition audioDb.hpp:47
@ WANT_TO_BE_CLOSE
Definition audioDb.hpp:51
@ CLUB_ESCAPADE_NOUVEAU_METALMOTH_REMIX
Definition audioDb.hpp:49
@ ARIA_OF_THE_SOUL
Definition audioDb.hpp:42
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.
ae::q20_12_t loopEndTime
Definition audioDb.hpp:22
AudioType type
Definition audioDb.hpp:18
ae::q20_12_t loopStartTime
Definition audioDb.hpp:21
const char * filename
Definition audioDb.hpp:20