NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
snd_BasicSound.h
1#ifndef NW4R_SND_BASIC_SOUND_H
2#define NW4R_SND_BASIC_SOUND_H
3
4/*******************************************************************************
5 * headers
6 */
7
8#include <types.h>
9
10#include "nw4r/snd/snd_global.h"
11#include "nw4r/snd/snd_MoveValue.h"
12
13#include "nw4r/ut/ut_algorithm.h" // ut::Clamp
14#include "nw4r/ut/ut_LinkList.h"
15
16/*******************************************************************************
17 * types
18 */
19
20// forward declarations
21namespace nw4r { namespace snd { namespace detail { class BasicPlayer; }}}
22namespace nw4r { namespace snd { namespace detail { class ExternalSoundPlayer; }}}
23namespace nw4r { namespace snd { namespace detail { class PlayerHeap; }}}
24namespace nw4r { namespace snd { class SoundActor; }}
25namespace nw4r { namespace snd { class SoundHandle; }}
26namespace nw4r { namespace snd { class SoundPlayer; }}
27
28namespace nw4r { namespace ut { namespace detail { class RuntimeTypeInfo; }}}
29
30namespace nw4r { namespace snd
31{
32 // [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x27a05
33 struct SoundParam
34 {
35 // methods
36 public:
37 // cdtors
38 SoundParam() :
39 volume (1.0f),
40 pitch (1.0f),
41 pan (0.0f),
42 surroundPan (0.0f),
43 fxSend (0.0f),
44 lpf (0.0f),
45 biquadFilterValue (0.0f),
46 biquadFilterType (0),
47 priority (0),
48 field_0x24 (0)
49 {
50 }
51
52 // members
53 public:
54 f32 volume; // size 0x04, offset 0x00
55 f32 pitch; // size 0x04, offset 0x04
56 f32 pan; // size 0x04, offset 0x08
57 f32 surroundPan; // size 0x04, offset 0x0c
58 f32 fxSend; // size 0x04, offset 0x10
59 f32 lpf; // size 0x04, offset 0x14
60 f32 biquadFilterValue; // size 0x04, offset 0x18
61 int biquadFilterType; // size 0x04, offset 0x1c
62 int priority; // size 0x04, offset 0x20
63 UNKWORD field_0x24;
64 }; // size 0x24
65
66 // [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x27514
67 struct SoundAmbientParam
68 {
69 // methods
70 public:
71 // cdtors
72 SoundAmbientParam() : // where is my nsdmi !!!
73 volume (1.0f),
74 pitch (1.0f),
75 pan (0.0f),
76 surroundPan (0.0f),
77 fxSend (0.0f),
78 lpf (0.0f),
79 biquadFilterValue (0.0f),
80 biquadFilterType (0),
81 priority (0),
82 field_0x24 (0)
83 {
84 }
85
86 // members
87 public:
88 f32 volume; // size 0x04, offset 0x00
89 f32 pitch; // size 0x04, offset 0x04
90 f32 pan; // size 0x04, offset 0x08
91 f32 surroundPan; // size 0x04, offset 0x0c
92 f32 fxSend; // size 0x04, offset 0x10
93 f32 lpf; // size 0x04, offset 0x14
94 f32 biquadFilterValue; // size 0x04, offset 0x18
95 int biquadFilterType; // size 0x04, offset 0x1c
96 int priority; // size 0x04, offset 0x20
97 UNKWORD field_0x24;
98 VoiceOutParam voiceOutParam[4]; // size 0x60, offset 0x24
99 }; // size 0x84
100
101 namespace detail
102 {
103 // [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x270f1
104 struct SoundActorParam
105 {
106 // methods
107 public:
108 // cdtors
109 SoundActorParam() :
110 volume (1.0f),
111 pitch (1.0f),
112 pan (0.0f)
113 {
114 }
115
116 // members
117 public:
118 f32 volume; // size 0x04, offset 0x00
119 f32 pitch; // size 0x04, offset 0x04
120 f32 pan; // size 0x04, offset 0x08
121 }; // size 0x0c
122 } // namespace detail
123}} // namespace nw4r::snd
124
125/*******************************************************************************
126 * classes and functions
127 */
128
129namespace nw4r { namespace snd { namespace detail
130{
131 // [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x28177
132 // NOTE: different from ketteiban: no remote fields. something else instead
133 class BasicSound
134 {
135 // enums
136 public:
137 // [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x27c51
138 enum PauseState
139 {
140 PAUSE_STATE_NORMAL,
141 PAUSE_STATE_PAUSING,
142 PAUSE_STATE_PAUSED,
143 PAUSE_STATE_UNPAUSING,
144 };
145
146 // typedefs
147 public:
148 typedef ut::LinkList<BasicSound, 0xf0> PriorityLinkList;
149 typedef ut::LinkList<BasicSound, 0xf8> SoundPlayerPlayLinkList;
150 typedef ut::LinkList<BasicSound, 0x100> SoundPlayerPriorityLinkList;
151 typedef ut::LinkList<BasicSound, 0x108> ExtSoundPlayerPlayLinkList;
152
153 // nested types
154 public:
155 // [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x277e5
157 {
158 // nested types
159 public:
160 // [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x276d8
162 {
163 public:
164 enum ParamUpdateFlags {
165 PARAM_UPDATE_VOLUME = (1 << 0),
166 PARAM_UPDATE_PAN = (1 << 1),
167 PARAM_UPDATE_SURROUND_PAN = (1 << 2),
168 PARAM_UPDATE_PRIORITY = (1 << 3),
169 };
170 // methods
171 public:
172 virtual ~AmbientParamUpdateCallback() {}
173 virtual void detail_UpdateAmbientParam(const void*, ulong, int, SoundAmbientParam*);
174 virtual int detail_GetAmbientPriority(const void*, ulong);
175 virtual int detail_GetRequiredVoiceOutCount(const void*, ulong);
176
177 // members
178 private:
179 /* vtable */ // size 0x04, offset 0x00
180 }; // size 0x04
181
182 // [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x27732
184 {
185 // methods
186 public:
187 // virtual function ordering
188 // vtable AmbientArgUpdateCallback
189 virtual ~AmbientArgUpdateCallback() {}
190 virtual void at_0x0c(void *, BasicSound *);
191
192 // members
193 private:
194 /* vtable */ // size 0x04, offset 0x00
195 }; // size 0x04
196
197 // NOTE: "Allocator" is misspelled as "Allocater"
198 // [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x2778a
200 {
201 // methods
202 public:
203 // virtual function ordering
204 // vtable AmbientArgAllocaterCallback
206 virtual void *detail_AllocAmbientArg(ulong size); // at 0x8
207
208 virtual void detail_FreeAmbientArg(void *pArg,
209 const detail::BasicSound *pSound); // at 0xC
210
211 // members
212 private:
213 /* vtable */ // size 0x04, offset 0x00
214 }; // size 0x04
215
216 // members
217 public:
218 AmbientParamUpdateCallback *paramUpdateCallback; // size 0x04, offset 0x00
219 AmbientArgUpdateCallback *argUpdateCallback; // size 0x04, offset 0x04
220 AmbientArgAllocaterCallback *argAllocaterCallback; // size 0x04, offset 0x08
221 void *arg; // size 0x04, offset 0x0c
222 ulong argSize; // size 0x04, offset 0x10
223 }; // size 0x14
224
225 // methods
226 public:
227 // cdtors
228 BasicSound(int priority, int ambientPriority);
229 /* virtual ~BasicSound() {} */ // virtual function ordering
230
231 // virtual function ordering
232 // vtable BasicSound
233 virtual ut::detail::RuntimeTypeInfo const *GetRuntimeTypeInfo() const
234 {
235 return &typeInfo;
236 }
237 virtual ~BasicSound() {}
238 virtual void Shutdown();
239 virtual bool IsPrepared() const = 0;
240 virtual bool IsAttachedTempSpecialHandle() = 0;
241 virtual void DetachTempSpecialHandle() = 0;
242 virtual void InitParam();
243 virtual BasicPlayer &GetBasicPlayer() = 0;
244 virtual BasicPlayer const &GetBasicPlayer() const = 0;
245 virtual void OnUpdatePlayerPriority() {}
246 virtual void UpdateMoveValue();
247 virtual void UpdateParam();
248
249 // methods
250 void StartPrepared();
251 void Update();
252 void Pause(bool flag, int fadeFrames);
253 bool IsPause() const;
254 void Stop(int fadeFrames);
255 void SetAutoStopCounter(int count);
256 void FadeIn(int fadeFrames);
257
258 bool GetStartedFlag() const { return mStartedFlag; }
259 ulong GetId() const { return mId; }
260 PlayerHeap *GetPlayerHeap() { return mPlayerHeap; }
261 SoundPlayer *GetSoundPlayer() { return mSoundPlayer; }
262 int GetVoiceOutCount() const;
263 int GetPriority() const { return mPriority; }
264
265 void SetPlayerPriority(int priority);
266 void SetInitialVolume(f32 volume);
267 void SetVolume(f32 volume, int frames);
268 void SetPitch(f32 pitch);
269 void SetPan(f32 pan);
270 void SetSurroundPan(f32 pan);
271 void SetLpfFreq(f32 freq);
272 void SetFxSend(AuxBus bus, f32 send);
273 void SetRemoteFilter(int filter);
274 void SetPanMode(PanMode mode);
275 void SetPanCurve(PanCurve curve);
276 void SetAmbientInfo(AmbientInfo const &ambientArgInfo);
277 void SetId(ulong id);
278 void SetOutputLineFlag(int flag);
279
280 void AttachPlayerHeap(PlayerHeap *heap);
281 void AttachSoundPlayer(SoundPlayer *player);
282 void AttachSoundActor(SoundActor *actor);
283 void AttachExternalSoundPlayer(ExternalSoundPlayer *extPlayer);
284
285 bool IsAttachedGeneralHandle();
286 bool IsAttachedTempGeneralHandle();
287
288 void DetachPlayerHeap(PlayerHeap *heap);
289 void DetachSoundPlayer(SoundPlayer *player);
290 void DetachSoundActor(SoundActor *actor);
291 void DetachExternalSoundPlayer(ExternalSoundPlayer *extPlayer);
292 void DetachGeneralHandle();
293 void DetachTempGeneralHandle();
294
295 int GetRemainingFadeFrames() const;
296
297 int CalcCurrentPlayerPriority() const
298 {
299 return ut::Clamp(mPriority + mAmbientParam.priority, PRIORITY_MIN,
300 PRIORITY_MAX);
301 }
302
303 void ClearAmbientArgUpdateCallback() {
304 mAmbientInfo.argUpdateCallback = NULL;
305 }
306
307 static int GetAmbientPriority(AmbientInfo const &ambientInfo,
308 ulong soundId);
309
310 // static members
311 public:
312 // NOTE: PRIORITY_MAX is a dependent name (see SoundInstanceManager)
313 static ulong const INVALID_ID = -1;
314 static int const PRIORITY_MAX = 127;
315 static int const PRIORITY_MIN = 0;
316
317 static ut::detail::RuntimeTypeInfo const typeInfo;
318
319 // members
320 private:
321 /* vtable */ // size 0x04, offset 0x00
322 PlayerHeap *mPlayerHeap; // size 0x04, offset 0x04
323 SoundHandle *mGeneralHandle; // size 0x04, offset 0x08
324 SoundHandle *mTempGeneralHandle; // size 0x04, offset 0x0c
325 SoundPlayer *mSoundPlayer; // size 0x04, offset 0x10
326 SoundActor *mSoundActor; // size 0x04, offset 0x14
327 ExternalSoundPlayer *mExtSoundPlayer; // size 0x04, offset 0x18
328 AmbientInfo mAmbientInfo; // size 0x14, offset 0x1c
329 SoundParam mAmbientParam; // size 0x24, offset 0x30
330 SoundActorParam mActorParam; // size 0x0c, offset 0x58
331 MoveValue<f32, int> mFadeVolume; // size 0x10, offset 0x64
332 MoveValue<f32, int> mPauseFadeVolume; // size 0x10, offset 0x74
333 bool mStartFlag; // size 0x01, offset 0x84
334 bool mStartedFlag; // size 0x01, offset 0x85
335 bool mAutoStopFlag; // size 0x01, offset 0x86
336 bool mFadeOutFlag; // size 0x01, offset 0x87
337 PauseState mPauseState; // size 0x04, offset 0x88
338 bool mUnPauseFlag; // size 0x01, offset 0x8c
339 /* 3 bytes padding */
340 s32 mAutoStopCounter; // size 0x04, offset 0x90
341 ulong mUpdateCounter; // size 0x04, offset 0x94
342 u8 mPriority; // size 0x01, offset 0x98
343 u8 mVoiceOutCount; // size 0x01, offset 0x99
344 u8 mBiquadFilterType; // size 0x01, offset 0x9a
345 /* 1 byte padding */
346 ulong mId; // size 0x04, offset 0x9c
347 MoveValue<f32, int> mExtMoveVolume; // size 0x10, offset 0xa0
348 f32 mInitVolume; // size 0x04, offset 0xb0
349 f32 mExtPan; // size 0x04, offset 0xb4
350 f32 mExtSurroundPan; // size 0x04, offset 0xb8
351 f32 mExtPitch; // size 0x04, offset 0xbc
352 f32 mLpfFreq; // size 0x04, offset 0xc0
353 f32 mBiquadFilterValue; // size 0x04, offset 0xc4
354 int mOutputLineFlag; // size 0x04, offset 0xc8
355 f32 mMainOutVolume; // size 0x04, offset 0xcc
356 f32 mMainSend; // size 0x04, offset 0xd0
357 f32 mFxSend[AUX_BUS_NUM]; // size 0x0c, offset 0xd4
358 f32 mRemoteOutVolume[4]; // size 0x10, offset 0xe0
359 public:
360 ut::LinkListNode mPriorityLink; // size 0x08, offset 0xf0
361 ut::LinkListNode mSoundPlayerPlayLink; // size 0x08, offset 0xf8
362 ut::LinkListNode mSoundPlayerPriorityLink; // size 0x08, offset 0x100
363 ut::LinkListNode mExtSoundPlayerPlayLink; // size 0x08, offset 0x108
364
365 // friends
366 private:
367 friend class snd::SoundHandle;
368 }; // size 0x100
369}}} // namespace nw4r::snd::detail
370
371#endif // NW4R_SND_BASIC_SOUND_H
Debugging library which includes various utilities used by the rest of nw4r.
Definition ut_list.cpp:4