NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
snd_SoundArchive.h
1#ifndef NW4R_SND_SOUND_ARCHIVE_H
2#define NW4R_SND_SOUND_ARCHIVE_H
3
4/*******************************************************************************
5 * headers
6 */
7
8#include <types.h>
9
10#include "nw4r/snd/snd_global.h"
11
12/*******************************************************************************
13 * types
14 */
15
16// forward declarations
17namespace nw4r { namespace snd { namespace detail { class SoundArchiveFileReader; }}}
18
19namespace nw4r { namespace ut { class FileStream; }}
20
21/*******************************************************************************
22 * classes and functions
23 */
24
25namespace nw4r { namespace snd
26{
27 // [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x265b9
28 class SoundArchive
29 {
30 // enums
31 public:
32 // [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x26182
33 enum SoundType
34 {
35 SOUND_TYPE_INVALID,
36
37 SOUND_TYPE_SEQ,
38 SOUND_TYPE_STRM,
39 SOUND_TYPE_WAVE,
40 };
41
42 // nested types
43 public:
44 // [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x25c18
45 struct BankInfo
46 {
47 ulong fileId; // size 0x04, offset 0x00
48 }; // size 0x04
49
50 // [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x25ac7
51 struct FileInfo
52 {
53 ulong fileSize; // size 0x04, offset 0x00
54 ulong waveDataFileSize; // size 0x04, offset 0x04
55 char const *extFilePath; // size 0x04, offset 0x08
56 ulong filePosCount; // size 0x04, offset 0x0c
57 }; // size 0x10
58
59 // [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x25a5b
60 struct FilePos
61 {
62 ulong groupId; // size 0x04, offset 0x00
63 ulong index; // size 0x04, offset 0x04
64 }; // size 0x08
65
66 // [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x2593d
67 struct GroupInfo
68 {
69 ulong itemCount; // size 0x04, offset 0x00
70 char const *extFilePath; // size 0x04, offset 0x04
71 ulong offset; // size 0x04, offset 0x08
72 ulong size; // size 0x04, offset 0x0c
73 ulong waveDataOffset; // size 0x04, offset 0x10
74 ulong waveDataSize; // size 0x04, offset 0x14
75 }; // size 0x18
76
77 // [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x2584d
79 {
80 ulong fileId; // size 0x04, offset 0x00
81 ulong offset; // size 0x04, offset 0x04
82 ulong size; // size 0x04, offset 0x08
83 ulong waveDataOffset; // size 0x04, offset 0x0c
84 ulong waveDataSize; // size 0x04, offset 0x10
85 }; // size 0x14
86
87 // [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x25b9b
89 {
90 int playableSoundCount; // size 0x04, offset 0x00
91 ulong heapSize; // size 0x04, offset 0x04
92 }; // size 0x08
93
94 // [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x25dc1
96 {
97 ulong dataOffset; // size 0x04, offset 0x00
98 ulong bankId; // size 0x04, offset 0x04
99 ulong allocTrack; // size 0x04, offset 0x08
100 int channelPriority; // size 0x04, offset 0x0c
101 bool releasePriorityFixFlag; // size 0x01, offset 0x10
102 /* 3 bytes padding */
103 }; // size 0x14
104
105 // [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x25d0f
107 {
108 ulong startPosition; // size 0x04, offset 0x00
109 u16 allocChannelCount; // size 0x02, offset 0x04
110 u16 allocTrackFlag; // size 0x02, offset 0x06
111 }; // size 0x08
112
113 // [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x25c5f
115 {
116 s32 subNo; // size 0x04, offset 0x00
117 int channelPriority; // size 0x04, offset 0x04
118 bool releasePriorityFixFlag; // size 0x01, offset 0x08
119 /* 3 bytes padding */
120 }; // size 0x0c
121
123 ulong flags; // at 0x0
124 u8 decayCurve; // at 0x4
125 u8 decayRatio; // at 0x5
126 u8 field_0x06; // at 0x6
127 };
128
129 // [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x256dc
131 {
132 int seqSoundCount; // size 0x04, offset 0x00
133 int seqTrackCount; // size 0x04, offset 0x04
134 int strmSoundCount; // size 0x04, offset 0x08
135 int strmTrackCount; // size 0x04, offset 0x0c
136 int strmChannelCount; // size 0x04, offset 0x10
137 int waveSoundCount; // size 0x04, offset 0x14
138 int waveTrackCount; // size 0x04, offset 0x18
139 }; // size 0x1c
140
141 // [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x26012
143 {
144 ulong fileId; // size 0x04, offset 0x00
145 ulong playerId; // size 0x04, offset 0x04
146 int actorPlayerId; // size 0x04, offset 0x08
147 int playerPriority; // size 0x04, offset 0x0c
148 int volume; // size 0x04, offset 0x10
149 int remoteFilter; // size 0x04, offset 0x14
150 PanMode panMode; // size 0x04, offset 0x18
151 PanCurve panCurve; // size 0x04, offset 0x1c
152 }; // size 0x20
153
154 // methods
155 public:
156 // cdtors
157 SoundArchive();
158 virtual ~SoundArchive();
159
160 // virtual function ordering
161 // vtable SoundArchive
162 virtual void const *detail_GetFileAddress(ulong fileId) const = 0;
163 virtual void const *detail_GetWaveDataFileAddress(ulong fileId) const = 0;
164 virtual int detail_GetRequiredStreamBufferSize() const = 0;
165 virtual ut::FileStream *OpenStream(void *buffer, int size, ulong begin,
166 ulong length) const = 0;
167 virtual ut::FileStream *OpenExtStream(void *buffer, int size,
168 char const *extFilePath,
169 ulong begin, ulong length) const = 0;
170
171 // methods
172 void Setup(detail::SoundArchiveFileReader *fileReader);
173 void Shutdown();
174
175 ulong GetPlayerCount() const;
176 ulong GetGroupCount() const;
177 bool IsAvailable() const;
178 SoundType GetSoundType(ulong soundId) const;
179
180 const char* GetSoundLabelString(ulong id) const;
181 ulong ConvertLabelStringToSoundId(char const *label) const;
182 ulong ConvertLabelStringToPlayerId(const char* pLabel) const;
183 ulong ConvertLabelStringToGroupId(const char* pLabel) const;
184 ulong ConvertLabelStringToBankId(const char* pLabel) const;
185 ulong GetSoundUserParam(ulong id) const;
186
187 bool ReadSoundInfo(ulong soundId, SoundInfo *info) const;
188 bool ReadSeqSoundInfo(ulong soundId, SeqSoundInfo *info) const;
189 bool detail_ReadStrmSoundInfo(ulong soundId, StrmSoundInfo *info) const;
190 bool detail_ReadWaveSoundInfo(ulong soundId, WaveSoundInfo *info) const;
191
192 bool ReadPlayerInfo(ulong playerId, PlayerInfo *info) const;
193 bool ReadSoundArchivePlayerInfo(SoundArchivePlayerInfo *info) const;
194 bool detail_ReadSound3DParam(ulong soundId, nw4r::snd::SoundArchive::Sound3DParam*) const;
195
196 bool ReadBankInfo(ulong bankId, BankInfo *info) const;
197
198 bool detail_ReadGroupInfo(ulong groupId, GroupInfo *info) const;
199 bool detail_ReadGroupItemInfo(ulong groupId, ulong index,
200 GroupItemInfo *info) const;
201
202 ulong detail_GetFileCount() const;
203 bool detail_ReadFileInfo(ulong fileId, FileInfo *info) const;
204 bool detail_ReadFilePos(ulong fileId, ulong index, FilePos *info) const;
205
206 ut::FileStream *detail_OpenFileStream(ulong fileId, void *buffer,
207 int size) const;
208 ut::FileStream* detail_OpenGroupStream(ulong id, void* pBuffer,
209 int bufferSize) const;
210 ut::FileStream* detail_OpenGroupWaveDataStream(ulong id, void* pBuffer,
211 int bufferSize) const;
212
213 void SetExternalFileRoot(const char* pExtFileRoot);
214
215 private:
216 ut::FileStream *OpenExtStreamImpl(void *buffer, int size,
217 char const *extFilePath, ulong begin,
218 ulong length) const;
219
220 // static members
221 public:
222 static int const FILE_PATH_MAX = 255;
223 static ulong const INVALID_ID = -1;
224
225 // members
226 private:
227 /* vtable */ // size 0x004, offset 0x000
228 detail::SoundArchiveFileReader *mFileReader; // size 0x004, offset 0x004
229 char mExtFileRoot[FILE_PATH_MAX + 1]; // size 0x100, offset 0x008
230 }; // size 0x108
231}} // namespace nw4r::snd
232
233#endif // NW4R_SND_SOUND_ARCHIVE_H
Debugging library which includes various utilities used by the rest of nw4r.
Definition ut_list.cpp:4