NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
snd_WsdPlayer.h
1#ifndef NW4R_SND_WSD_PLAYER_H
2#define NW4R_SND_WSD_PLAYER_H
3
4/*******************************************************************************
5 * headers
6 */
7
8#include <types.h>
9
10#include "nw4r/snd/snd_BasicPlayer.h"
11#include "nw4r/snd/snd_Channel.h"
12#include "nw4r/snd/snd_DisposeCallbackManager.h" // DisposeCallback
13#include "nw4r/snd/snd_Lfo.h" // LfoParam
14#include "nw4r/snd/snd_SoundThread.h"
15#include "nw4r/snd/snd_WaveFile.h"
16
17/*******************************************************************************
18 * classes and functions
19 */
20
21namespace nw4r { namespace snd {
22
24 /* 0x00 */ bool loopFlag;
25 /* 0x04 */ int sampleRate;
26 /* 0x08 */ ulong loopStart;
27 /* 0x0C */ ulong loopEnd;
28};
29
30namespace detail
31{
32 // [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x30b74
33 class WsdPlayer : public BasicPlayer,
34 public DisposeCallback,
36 {
37 // enums
38 public:
39 // [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x30b0e
40 enum StartOffsetType
41 {
42 START_OFFSET_TYPE_SAMPLE,
43 START_OFFSET_TYPE_MILLISEC,
44 };
45
46 // nested types
47 public:
48 // [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x2e896
50 {
51 // methods
52 public:
53 // cdtors
54 virtual ~WsdCallback() {}
55
56 // virtual function ordering
57 // vtable WsdCallback
58 virtual bool GetWaveSoundData(WaveSoundInfo *info,
59 WaveSoundNoteInfo *noteInfo,
60 WaveInfo *waveData,
61 void const *waveSoundData, int index,
62 int noteIndex,
63 ulong userData) const = 0;
64
65 // members
66 private:
67 /* vtable */ // size 0x04, offset 0x00
68 }; // size 0x04
69
70 // methods
71 public:
72 // cdtors
73 WsdPlayer();
74
75 // virtual function ordering
76 // vtable BasicPlayer
77 virtual bool Start();
78 virtual void Stop();
79 virtual void Pause(bool flag);
80 virtual bool IsActive() const { return mActiveFlag != false; }
81 virtual bool IsStarted() const { return mStartedFlag != false; }
82 virtual bool IsPause() const { return mPauseFlag != false; }
83
84 // vtable DisposeCallback
85 virtual void InvalidateData(void const *start, void const *end);
86 virtual void InvalidateWaveData(void const *, void const *) {}
87
88 // vtable SoundThread::PlayerCallback
89 virtual void OnUpdateFrameSoundThread() { Update(); }
90 virtual void OnShutdownSoundThread() { Stop(); }
91
92 // methods
93 bool Prepare(void const *waveSoundBase, int index,
94 StartOffsetType startOffsetType, int startOffset,
95 int voiceOutCount, WsdCallback const *callback,
96 ulong callbackData);
97
98 f32 GetPanRange() const { return mPanRange; }
99 int GetVoiceOutCount() const { return mVoiceOutCount; }
100 int GetChannelPriority() const { return mPriority; }
101 void const *GetWsdDataAddress() const { return mWsdData; }
102
103 void SetReleasePriorityFix(bool flag);
104 void SetChannelPriority(int priority);
105
106 bool IsChannelActive() const
107 {
108 return mChannel != nullptr && mChannel->IsActive();
109 }
110 bool ReadWsdDataInfo(WsdDataInfo*) const;
111 ulong GetPlaySamplePosition() const;
112
113 private:
114 static void ChannelCallbackFunc(Channel *dropChannel,
115 Channel::ChannelCallbackStatus status,
116 ulong userData);
117
118 void InitParam(int voiceOutCount, WsdCallback const *callback,
119 ulong callbackData);
120
121 void Update();
122
123 bool StartChannel(WsdCallback const *callback, ulong callbackData);
124 void UpdateChannel();
125 void CloseChannel();
126
127 void FinishPlayer();
128
129 // static members
130 public:
131 static int const DEFAULT_PRIORITY = 64;
132 static int const MUTE_RELEASE_VALUE;
133 static int const PAUSE_RELEASE_VALUE;
134
135 // members
136 private:
137 /* base BasicPlayer */ // size 0x0a4, offset 0x000
138 /* base DisposeCallback */ // size 0x00c, offset 0x0a4
139 /* base SoundThread::PlayerCallback */ // size 0x00c, offset 0x0b0
140 bool mActiveFlag; // size 0x001, offset 0x0bc
141 bool mStartedFlag; // size 0x001, offset 0x0bd
142 bool mPauseFlag; // size 0x001, offset 0x0be
143 bool mWavePlayFlag; // size 0x001, offset 0x0bf
144 bool mReleasePriorityFixFlag; // size 0x001, offset 0x0c0
145 /* 3 bytes padding */
146 f32 mPanRange; // size 0x004, offset 0x0c4
147 int mVoiceOutCount; // size 0x004, offset 0x0c8
148 u8 mPriority; // size 0x001, offset 0x0cc
149 /* 3 bytes padding */
150 WsdCallback const *mCallback; // size 0x004, offset 0x0d0
151 ulong mCallbackData; // size 0x004, offset 0x0d4
152 void const *mWsdData; // size 0x004, offset 0x0d8
153 int mWsdIndex; // size 0x004, offset 0x0dc
154 StartOffsetType mStartOffsetType; // size 0x004, offset 0x0e0
155 int mStartOffset; // size 0x004, offset 0x0e4
156 LfoParam mLfoParam; // size 0x010, offset 0x0e8
157 WaveSoundInfo mWaveSoundInfo; // size 0x00c, offset 0x0f8
158 Channel *mChannel; // size 0x004, offset 0x104
159 }; // size 0x108
160}}} // namespace nw4r::snd::detail
161
162#endif // NW4R_SND_WSD_PLAYER_H