NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
snd_SeqTrack.h
1#ifndef NW4R_SND_SEQ_TRACK_H
2#define NW4R_SND_SEQ_TRACK_H
3
4/*******************************************************************************
5 * headers
6 */
7
8#include <types.h>
9
10#include "nw4r/snd/snd_Channel.h"
11#include "nw4r/snd/snd_global.h" // AUX_BUS_NUM
12#include "nw4r/snd/snd_Lfo.h" // LfoParam
13#include "nw4r/snd/snd_MoveValue.h"
14
15/*******************************************************************************
16 * types
17 */
18
19// forward declarations
20namespace nw4r { namespace snd { namespace detail { class SeqPlayer; }}}
21
22namespace nw4r { namespace snd
23{
24 // why is this not attacked to SeqTrack or something?
25 // [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x2d764
26 enum SeqMute
27 {
28 MUTE_OFF,
29 MUTE_NO_STOP,
30 MUTE_RELEASE,
31 MUTE_STOP,
32 };
33}} // namespace nw4r::snd
34
35/*******************************************************************************
36 * classes and functions
37 */
38
39namespace nw4r { namespace snd { namespace detail
40{
41 // [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x2d7c3
42 class SeqTrack
43 {
44 // early constants
45 public:
46 static int const CALL_STACK_DEPTH = 3;
47
48 // enums
49 public:
50 // [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x2d70c
51 enum ParseResult
52 {
53 PARSE_RESULT_CONTINUE,
54 PARSE_RESULT_FINISH,
55 };
56
57 // nested types
58 public:
59 // [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x2cdd6
60 struct CallStack
61 {
62 bool loopFlag; // size 0x01, offset 0x00
63 u8 loopCount; // size 0x01, offset 0x01
64 /* 2 bytes padding */
65 byte_t const *address; // size 0x04, offset 0x04
66 }; // size 0x08
67
68 // [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x2d032
70 {
71 byte_t const *baseAddr; // size 0x04, offset 0x00
72 byte_t const *currentAddr; // size 0x04, offset 0x04
73 bool cmpFlag; // size 0x01, offset 0x08
74 bool noteWaitFlag; // size 0x01, offset 0x09
75 bool tieFlag; // size 0x01, offset 0x0a
76 bool monophonicFlag; // size 0x01, offset 0x0b
77 CallStack callStack[CALL_STACK_DEPTH]; // size 0x18, offset 0x0c
78 u8 callStackDepth; // size 0x01, offset 0x24
79 /* 3 bytes padding */
80 s32 wait; // size 0x04, offset 0x28
81 bool muteFlag; // size 0x01, offset 0x2c
82 bool silenceFlag; // size 0x01, offset 0x2d
83 bool noteFinishWait; // size 0x01, offset 0x2e
84 bool portaFlag; // size 0x01, offset 0x2f
85 bool damperFlag; // size 0x01, offset 0x30
86 /* 3 bytes padding */
87 int bankNo; // size 0x04, offset 0x34
88 int prgNo; // size 0x04, offset 0x38
89 LfoParam lfoParam; // size 0x10, offset 0x3c
90 u8 lfoTarget; // size 0x01, offset 0x4c
91 /* 3 bytes padding */
92 f32 sweepPitch; // size 0x04, offset 0x50
93 MoveValue<u8, s16> volume; // size 0x06, offset 0x54
94 MoveValue<s8, s16> pan; // size 0x06, offset 0x5a
95 MoveValue<s8, s16> surroundPan; // size 0x06, offset 0x60
96 MoveValue<s8, s16> pitchBend; // size 0x01, offset 0x68
97 u8 volume2; // size 0x01, offset 0x66
98 u8 velocityRange; // size 0x01, offset 0x67
99 u8 bendRange; // size 0x01, offset 0x69
100 s8 initPan; // size 0x01, offset 0x6a
101 s8 transpose; // size 0x01, offset 0x6b
102 u8 priority; // size 0x01, offset 0x6c
103 u8 portaKey; // size 0x01, offset 0x6d
104 u8 portaTime; // size 0x01, offset 0x6e
105 u8 attack; // size 0x01, offset 0x6f
106 u8 decay; // size 0x01, offset 0x70
107 u8 sustain; // size 0x01, offset 0x71
108 u8 release; // size 0x01, offset 0x72
109 /* 1 byte padding */
110 s16 envHold; // size 0x02, offset 0x74
111 u8 mainSend; // size 0x01, offset 0x76
112 u8 fxSend[AUX_BUS_NUM]; // size 0x03, offset 0x77
113 u8 biquadType; // size 0x01, offset 0x7a
114 /* 1 byte padding */
115 f32 lpfFreq; // size 0x04, offset 0x7c
116 f32 biquadValue; // size 0x04, offset 0x80
117 }; // size 0x84
118
119 // methods
120 public:
121 // cdtors
122 SeqTrack();
123 virtual ~SeqTrack();
124
125 // virtual function ordering
126 // vtable SeqTrack
127 virtual ParseResult Parse(bool doNoteOn) = 0;
128
129 // methods
130 void InitParam();
131 void SetSeqData(void const *seqBase, s32 seqOffset);
132 void Open();
133 void Close();
134
135 u8 GetPlayerTrackNo() const { return mPlayerTrackNo; }
136 bool IsOpened() const { return mOpenFlag; }
137 ParserTrackParam &GetParserTrackParam() { return mParserTrackParam; }
138 s16 volatile *GetVariablePtr(int varNo);
139 SeqPlayer *GetSeqPlayer() { return mSeqPlayer; }
140 Channel *GetLastChannel() const { return mChannelList; }
141
142 void SetPlayerTrackNo(int playerTrackNo);
143 void SetVolume(f32);
144 void SetTrackVariable(int variable, s16 value);
145 void SetPitch(f32);
146 void SetPan(f32);
147 void SetSurroundPan(f32);
148 void SetPanRange(f32);
149 void SetMute(SeqMute mute);
150 void SetSilence(bool, int);
151 void SetModDepth(f32);
152 void SetModSpeed(f32);
153 void SetBiquadFilter(int, f32);
154 void SetLpfFreq(f32);
155 void SetSeqPlayer(SeqPlayer *player) { mSeqPlayer = player; }
156
157 void AddChannel(Channel *channel);
158
159 void UpdateChannelLength();
160 void UpdateChannelParam();
161 void UpdateChannelRelease(Channel *channel);
162
163 void ReleaseAllChannel(int release);
164 void PauseAllChannel(bool flag);
165 void StopAllChannel();
166 void FreeAllChannel();
167
168 Channel *NoteOn(int key, int velocity, s32 length, bool tieFlag);
169
170 int ParseNextTick(bool doNoteOn);
171
172 static void ChannelCallbackFunc(Channel *dropChannel,
173 Channel::ChannelCallbackStatus status,
174 ulong userData);
175
176 // static members
177 public:
178 static int const MUTE_RELEASE_VALUE = -1; // maybe?
179 static int const PAUSE_RELEASE_VALUE;
180
181 static int const TRACK_VARIABLE_NUM = 16;
182
183 static int const PARSER_PARAM_SIZE; // sizeof(ParserTrackParam) probably
184
185 static int const MAX_ENVELOPE_VALUE = 127;
186 static int const INVALID_ENVELOPE = 255;
187
188 static int const DEFAULT_PORTA_KEY = 60;
189 static int const DEFAULT_BENDRANGE = 2;
190 static int const DEFAULT_PRIORITY = 64;
191
192 /* static int const CALL_STACK_DEPTH = 3; */ // see above
193
194 // members
195 private:
196 /* vtable */ // size 0x04, offset 0x00
197 u8 mPlayerTrackNo; // size 0x01, offset 0x04
198 bool mOpenFlag; // size 0x01, offset 0x05
199 /* 2 bytes padding */
200 f32 mExtVolume; // size 0x04, offset 0x08
201 f32 mExtPitch; // size 0x04, offset 0x0c
202 f32 mExtPan; // size 0x04, offset 0x10
203 f32 mExtSurroundPan; // size 0x04, offset 0x14
204 f32 mPanRange; // size 0x04, offset 0x18
205 ParserTrackParam mParserTrackParam; // size 0x84, offset 0x1c
206 s16 volatile mTrackVariable[TRACK_VARIABLE_NUM]; // size 0x20, offset 0xa0
207 SeqPlayer *mSeqPlayer; // size 0x04, offset 0xc0
208 Channel *mChannelList; // size 0x04, offset 0xc4
209 }; // size 0xc8
210}}} // namespace nw4r::snd::detail
211
212#endif // NW4R_SND_SEQ_TRACK_H