NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
snd_SeqSound.h
1#ifndef NW4R_SND_SEQ_SOUND_H
2#define NW4R_SND_SEQ_SOUND_H
3
4/*******************************************************************************
5 * headers
6 */
7
8#include <types.h>
9
10#include "nw4r/snd/snd_BasicSound.h"
11#include "nw4r/snd/snd_debug.h"
12#include "nw4r/snd/snd_SeqPlayer.h"
13#include "nw4r/snd/snd_Task.h"
14
15#include "nw4r/ut/ut_LinkList.h"
16
17/*******************************************************************************
18 * types
19 */
20
21// forward declarations
22namespace nw4r { namespace snd { namespace detail { class NoteOnCallback; }}}
23namespace nw4r { namespace snd { namespace detail { class SeqTrackAllocator; }}}
24namespace nw4r { namespace snd { namespace detail { template <class> class SoundInstanceManager; }}}
25namespace nw4r { namespace snd { class SeqSoundHandle; }}
26
27namespace nw4r { namespace ut { namespace detail { class RuntimeTypeInfo; }}}
28namespace nw4r { namespace ut { class FileStream; }}
29
30/*******************************************************************************
31 * classes and functions
32 */
33
34namespace nw4r { namespace snd { namespace detail
35{
36 // [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x2ed0a
37 class SeqSound : public BasicSound
38 {
39 // typedefs
40 public:
41 /* redeclare with this class instead of BasicSound for
42 * SoundInstanceManager
43 */
44 typedef ut::LinkList<SeqSound, 0xf0> PriorityLinkList;
45
46 // nested types
47 public:
48 // [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x2eb5e
49 class SeqLoadTask : public Task
50 {
51 // typedefs
52 public:
53 typedef void Callback(bool result, void const *seqBase,
54 void *userData);
55
56 // methods
57 public:
58 // cdtors
59 SeqLoadTask();
60
61 // virtual function ordering
62 // vtable Task
63 virtual void Execute();
64 virtual void Cancel();
65 virtual void OnCancel();
66
67 // members
68 public:
69 /* base Task */ // size 0x10, offset 0x00
70 ut::FileStream *mFileStream; // size 0x04, offset 0x10
71 void *mBuffer; // size 0x04, offset 0x14
72 int mBufferSize; // size 0x04, offset 0x18
73 Callback *mCallback; // size 0x04, offset 0x1c
74 void *mCallbackData; // size 0x04, offset 0x20
75 }; // size 0x24
76
77 // methods
78 public:
79 // cdtors
80 SeqSound(SoundInstanceManager<SeqSound> *manager, int priority,
81 int ambientPriority);
82
83 // virtual function ordering
84 // vtable BasicSound
85 virtual ut::detail::RuntimeTypeInfo const *GetRuntimeTypeInfo() const
86 {
87 return &typeInfo;
88 }
89 virtual void Shutdown();
90 virtual bool IsPrepared() const { return mPreparedFlag; }
91 virtual bool IsAttachedTempSpecialHandle();
92 virtual void DetachTempSpecialHandle();
93 virtual void InitParam();
94 virtual BasicPlayer &GetBasicPlayer() { return mSeqPlayer; }
95 virtual BasicPlayer const &GetBasicPlayer() const { return mSeqPlayer; }
96 virtual void OnUpdatePlayerPriority();
97
98 // methods
99 SeqPlayer::SetupResult Setup(SeqTrackAllocator *trackAllocator,
100 ulong allocTracks,
101 NoteOnCallback *callback);
102 void Prepare(void const *seqBase, s32 seqOffset,
103 SeqPlayer::OffsetType startOffsetType, int startOffset);
104 void Prepare(ut::FileStream *fileStream, s32 seqOffset,
105 SeqPlayer::OffsetType startOffsetType, int startOffset);
106
107 void *GetFileStreamBuffer() { return mFileStreamBuffer; }
108 s32 GetFileStreamBufferSize() { return sizeof mFileStreamBuffer; }
109
110 void SetReleasePriorityFix(bool fix);
111 void SetTempoRatio(f32 tempo);
112 void SetChannelPriority(int priority);
113 void SetSeqUserprocCallback(SeqPlayer::SeqUserprocCallback *callback,
114 void *arg);
115
116 void Skip(SeqPlayer::OffsetType offsetType, int offset);
117
118 bool LoadData(SeqLoadTask::Callback *callback,
119 void *callbackArg);
120
121 static void NotifyLoadAsyncEndSeqData(bool result, void const *seqBase,
122 void *userData);
123
124 void SetTrackMute(ulong trackFlags, SeqMute mute);
125 void SetTrackSilence(ulong trackFlags, bool silence, int fadeFrames);
126 void SetTrackVolume(ulong trackFlags, f32 volume);
127 bool ReadVariable(int varNo, s16 *value) const;
128 bool WriteVariable(int varNo, s16 value);
129 static bool WriteGlobalVariable(int varNo, s16 value);
130 bool WriteTrackVariable(int trackNo, int varNo, s16 value);
131 ulong GetTick() const;
132
133 static DebugSoundType GetSoundType()
134 {
135 return DEBUG_SOUND_TYPE_SEQSOUND;
136 }
137
138 // static members
139 public:
140 static int const FILE_STREAM_BUFFER_SIZE = 128;
141
142 static ut::detail::RuntimeTypeInfo const typeInfo;
143
144 // members
145 private:
146 /* base BasicSound */ // size 0x100, offset 0x000
147 SeqPlayer mSeqPlayer; // size 0x154, offset 0x100
148 SeqSoundHandle *mTempSpecialHandle; // size 0x004, offset 0x254
149 SoundInstanceManager<SeqSound> *mManager; // size 0x004, offset 0x258
150 s32 mSeqOffset; // size 0x004, offset 0x25c
151 SeqPlayer::OffsetType mStartOffsetType; // size 0x004, offset 0x260
152 int mStartOffset; // size 0x004, offset 0x264
153 bool volatile mLoadingFlag; // size 0x001, offset 0x268
154 bool volatile mPreparedFlag; // size 0x001, offset 0x269
155 /* 2 bytes padding */
156 ut::FileStream *mFileStream; // size 0x004, offset 0x26c
157 int mFileStreamBuffer[FILE_STREAM_BUFFER_SIZE]; // size 0x200, offset 0x2a0
158 SeqLoadTask mSeqLoadTask; // size 0x024, offset 0x4a0
159
160 // friends
161 private:
162 friend class snd::SeqSoundHandle;
163 }; // size 0x4c4
164}}} // namespace nw4r::snd::detail
165
166#endif // NW4R_SND_SEQ_SOUND_H
Debugging library which includes various utilities used by the rest of nw4r.
Definition ut_list.cpp:4