Twilight Princess
Decompilation of The Legend of Zelda: Twilight Princess
Loading...
Searching...
No Matches
StrmPlayer.h
Go to the documentation of this file.
1#ifndef NW4HBM_SND_STRM_PLAYER_H
2#define NW4HBM_SND_STRM_PLAYER_H
3
4#include "snd_types.h"
5
6#include "AxVoice.h"
7
9#define MAKE_DTOR_ZERO
10#include "BasicPlayer.h"
11#undef MAKE_DTOR_ZERO
12
13#include "InstancePool.h"
14#include "StrmChannel.h"
15#include "StrmFile.h"
16
17namespace nw4hbm {
18 namespace snd {
19 namespace detail {
20
21 class StrmPlayer : public BasicPlayer {
22 public:
27
28 typedef struct StrmHeader {
30 static const int STRM_CHANNEL_MAX = 8;
31
32 /* 0x00 */ StrmInfo strmInfo;
35
37 static const int LOAD_BUFFER_SIZE = 0x4000 + 32;
39 friend class StrmPlayer;
40
41 public:
42 virtual void NotifyAsyncEnd(bool result);
43
44 void SetAdpcmLoopContext(int channelNum, u16* predScale);
45 void* GetBuffer(int channelNum);
46
47 private:
52
53 /* 0x04 */ StrmPlayer* mPlayer;
54 /* 0x08 */ Status mStatus;
57
58 public:
60
61 static u8 mMramBuf[LOAD_BUFFER_SIZE] ATTRIBUTE_ALIGN(32);
62 };
63 typedef ut::LinkList<LoadCommand, offsetof(LoadCommand, mLinkNode)> LoadCommandList;
64
65 typedef void (*NotifyLoadHeaderAsyncEndCallback)(bool, const StrmHeader*, void*);
67 public:
75
76 virtual ~StrmCallback() {}
77
79 void* callbackData, u32 userId,
80 u32 userData) const = 0;
81 virtual Result LoadStream(void* mramAddr, u32 size, s32 offset, int numChannels,
82 u32 blockSize, s32 blockHeaderOffset,
83 bool needUpdateAdpcmLoop,
85 u32 userData) const = 0;
86
87 virtual void CancelLoading(u32 userId, u32 userData) const = 0;
88 };
89
90 public:
92
93 /* 0x0C */ virtual bool Start();
94 /* 0x10 */ virtual void Stop();
95 /* 0x14 */ virtual void Pause(bool flag);
96 /* 0x18 */ virtual bool IsActive() const { return mActiveFlag; }
97 /* 0x1C */ virtual bool IsPrepared() const { return mPreparedFlag; };
98 /* 0x20 */ virtual bool IsStarted() const { return mStartedFlag; };
99 /* 0x24 */ virtual bool IsPause() const { return mPauseFlag; };
100 /* 0x28 */ virtual void SetVolume(f32 volume) { mExtVolume = volume; }
101 /* 0x2C */ virtual void SetPitch(f32 pitch) { mExtPitch = pitch; }
102 /* 0x30 */ virtual void SetPan(f32 pan) { mExtPan = pan; }
103 /* 0x34 */ virtual void SetSurroundPan(f32 surroundPan) {
104 mExtSurroundPan = surroundPan;
105 }
106 /* 0x38 */ virtual void SetPan2(f32 pan2) { mExtPan2 = pan2; }
107 /* 0x3C */ virtual void SetSurroundPan2(f32 surroundPan2) {
108 mExtSurroundPan2 = surroundPan2;
109 }
110 /* 0x40 */ virtual void SetLpfFreq(f32 lpfFreq) { mExtLpfFreq = lpfFreq; }
111 /* 0x44 */ virtual f32 GetVolume() const { return mExtVolume; };
112 /* 0x48 */ virtual f32 GetPitch() const { return mExtPitch; };
113 /* 0x4C */ virtual f32 GetPan() const { return mExtPan; };
114 /* 0x50 */ virtual f32 GetSurroundPan() const { return mExtSurroundPan; };
115 /* 0x54 */ virtual f32 GetPan2() const { return mExtPan2; };
116 /* 0x58 */ virtual f32 GetSurroundPan2() const { return mExtSurroundPan2; };
117 /* 0x5C */ virtual f32 GetLpfFreq() const { return mExtLpfFreq; };
118 /* 0x60 */ virtual void SetOutputLine(int lineFlag);
119 /* 0x64 */ virtual void SetMainOutVolume(f32 volume);
120 /* 0x68 */ virtual void SetMainSend(f32 send);
121 /* 0x6C */ virtual void SetFxSend(AuxBus bus, f32 send);
122 /* 0x70 */ virtual void SetRemoteOutVolume(int remoteIndex, f32 volume);
123 /* 0x74 */ virtual void SetRemoteSend(int remoteIndex, f32 send);
124 /* 0x78 */ virtual void SetRemoteFxSend(int remoteIndex, f32 send);
125 /* 0x7C */ virtual int GetOutputLine() const;
126 /* 0x80 */ virtual f32 GetMainOutVolume() const;
127 /* 0x84 */ virtual f32 GetMainSend() const;
128 /* 0x88 */ virtual f32 GetFxSend(AuxBus bus) const;
129 /* 0x8C */ virtual f32 GetRemoteOutVolume(int remoteIndex) const;
130 /* 0x90 */ virtual f32 GetRemoteSend(int remoteIndex) const;
131 /* 0x94 */ virtual f32 GetRemoteFxSend(int remoteIndex) const;
132
133 void Setup(const StrmHeader* header);
134 bool SetupPlayer(const StrmHeader* header);
135 void Shutdown();
136
137 bool Prepare(StrmBufferPool* bufferPool, StartOffsetType startOffsetType,
138 s32 startOffset, int voices, StrmCallback* callback, u32 callbackData);
139
140 void InitParam(int voices);
141 void ForceStop();
142
143 void Update();
144
145 static void UpdateAllPlayers();
146 static void StopAllPlayers();
148
149 private:
150 static const int DATA_BLOCK_COUNT_MIN = 4;
151 static const int DATA_BLOCK_COUNT_MAX = 32;
152 static const int DATA_BLOCK_SIZE_MAX = 0x2000;
153
154 bool AllocChannels(int channels, int voices);
156
158 void UpdateLoopAddress(u32 startSample, u32 endSample);
161 void SetLoopEndToZeroBuffer(int endBlock);
164
166 bool CalcStartOffset(s32* blockIndex, u32* blockOffset, s32* loopCount);
167
169 void* pCallbackArg);
170
171 static void NotifyStrmHeaderAsyncEndCallback(bool result, const StrmHeader* header,
172 void* userData);
173
174 public:
176
177 private:
178 /* 0x010 */ StrmInfo mStrmInfo;
179 /* 0x048 */ u8 mActiveFlag;
180 /* 0x049 */ u8 mStartedFlag;
181 /* 0x04A */ u8 mPreparedFlag;
182 /* 0x04B */ u8 mPauseFlag;
183 /* 0x04C */ u8 mDiskErrorFlag;
184 /* 0x04D */ u8 mPauseStatus;
185 /* 0x04E */ u8 mLoadWaitFlag;
188 /* 0x051 */ u8 mValidAdpcmLoop;
189 /* 0x052 */ u8 mPlayFinishFlag;
190 /* 0x053 */ u8 mLoadFinishFlag;
191 /* 0x054 */ s32 mLoopCounter;
192 /* 0x058 */ int mPrepareCounter;
193 /* 0x05C */ int mChangeNumBlocks;
194 /* 0x060 */ int mDataBlockSize;
195 /* 0x064 */ int mBufferBlockCount;
196 /* 0x068 */ int mBufferBlockCountBase;
199 /* 0x074 */ int mLoadingDataBlockIndex;
202 /* 0x080 */ int mPlayingDataBlockIndex;
203 /* 0x084 */ int mLoopStartBlockIndex;
204 /* 0x088 */ int mLastBlockIndex;
206 /* 0x090 */ int mStartOffset;
212 /* 0x434 */ u32 mCallbackData;
213 /* 0x438 */ AxVoice* mVoice;
214 /* 0x43C */ f32 mExtVolume;
215 /* 0x440 */ f32 mExtPan;
216 /* 0x444 */ f32 mExtSurroundPan;
217 /* 0x448 */ f32 mExtPan2;
219 /* 0x450 */ f32 mExtPitch;
220 /* 0x454 */ f32 mExtLpfFreq;
221 /* 0x458 */ int mOutputLineFlag;
222 /* 0x45C */ f32 mMainOutVolume;
223 /* 0x460 */ f32 mMainSend;
224 /* 0x464 */ f32 mFxSend[AUX_BUS_NUM];
225 /* 0x470 */ f32 mRemoteOutVolume[WPAD_MAX_CONTROLLERS];
226 /* 0x480 */ f32 mRemoteSend[WPAD_MAX_CONTROLLERS];
227 /* 0x490 */ f32 mRemoteFxSend[WPAD_MAX_CONTROLLERS];
228 /* 0x4A0 */ s32 mChannelCount;
229 /* 0x4A4 */ s32 mVoiceOutCount;
232 };
233
234 typedef ut::LinkList<StrmPlayer, offsetof(StrmPlayer, mPlayerLink)> StrmPlayerList;
235
236 } // namespace detail
237 } // namespace snd
238} // namespace nw4hbm
239
240#endif
static BOOL flag
Definition DEMOAVX.c:20
static s32 offset
Definition WUD.c:1669
Definition AxVoice.h:123
CallbackStatus
Definition AxVoice.h:127
Definition StrmChannel.h:16
ut::LinkListNode mLinkNode
Definition StrmPlayer.h:59
virtual void NotifyAsyncEnd(bool result)
Status mStatus
Definition StrmPlayer.h:54
@ STATE_SETUP
Definition StrmPlayer.h:49
@ STATE_INTERVAL
Definition StrmPlayer.h:50
static u8 mMramBuf[LOAD_BUFFER_SIZE] ATTRIBUTE_ALIGN(32)
s32 mBufferBlockIndex
Definition StrmPlayer.h:56
s32 mStreamBlockIndex
Definition StrmPlayer.h:55
void SetAdpcmLoopContext(int channelNum, u16 *predScale)
StrmPlayer * mPlayer
Definition StrmPlayer.h:53
virtual void CancelLoading(u32 userId, u32 userData) const =0
virtual Result LoadStream(void *mramAddr, u32 size, s32 offset, int numChannels, u32 blockSize, s32 blockHeaderOffset, bool needUpdateAdpcmLoop, StrmPlayer::LoadCommand &callback, u32 userId, u32 userData) const =0
virtual ~StrmCallback()
Definition StrmPlayer.h:76
@ RESULT_CANCELED
Definition StrmPlayer.h:71
@ RESULT_ASYNC
Definition StrmPlayer.h:72
@ RESULT_RETRY
Definition StrmPlayer.h:73
@ RESULT_SUCCESS
Definition StrmPlayer.h:69
@ RESULT_FAILED
Definition StrmPlayer.h:70
virtual Result LoadHeader(StrmPlayer::NotifyLoadHeaderAsyncEndCallback callback, void *callbackData, u32 userId, u32 userData) const =0
Definition StrmPlayer.h:21
void Setup(const StrmHeader *header)
u8 mLoadWaitFlag
Definition StrmPlayer.h:185
virtual f32 GetMainSend() const
ut::LinkListNode mPlayerLink
Definition StrmPlayer.h:175
virtual void SetMainSend(f32 send)
StrmBufferPool * mBufferPool
Definition StrmPlayer.h:210
StartOffsetType
Definition StrmPlayer.h:23
@ START_OFFSET_TYPE_MILLISEC
Definition StrmPlayer.h:25
@ START_OFFSET_TYPE_SAMPLE
Definition StrmPlayer.h:24
f32 mRemoteSend[WPAD_MAX_CONTROLLERS]
Definition StrmPlayer.h:226
virtual void SetRemoteSend(int remoteIndex, f32 send)
StrmChannel mChannels[CHANNEL_MAX]
Definition StrmPlayer.h:230
u8 mNoRealtimeLoadFlag
Definition StrmPlayer.h:186
virtual void SetPan(f32 pan)
Definition StrmPlayer.h:102
LoadCommandList mFillBufferCommandList
Definition StrmPlayer.h:208
u8 mPlayFinishFlag
Definition StrmPlayer.h:189
LoadCommand mLoadCoammndArray[32]
Definition StrmPlayer.h:209
int mLastBlockIndex
Definition StrmPlayer.h:204
int mPlayingBufferBlockCount
Definition StrmPlayer.h:200
u8 mDiskErrorFlag
Definition StrmPlayer.h:183
void UpdateDataLoopAddress(s32 endBlock)
int mLoadingBufferBlockIndex
Definition StrmPlayer.h:198
virtual f32 GetPan2() const
Definition StrmPlayer.h:115
virtual void SetPan2(f32 pan2)
Definition StrmPlayer.h:106
virtual f32 GetSurroundPan() const
Definition StrmPlayer.h:114
virtual void SetRemoteOutVolume(int remoteIndex, f32 volume)
virtual f32 GetRemoteOutVolume(int remoteIndex) const
void(*) NotifyLoadHeaderAsyncEndCallback(bool, const StrmHeader *, void *)
Definition StrmPlayer.h:65
f32 mRemoteFxSend[WPAD_MAX_CONTROLLERS]
Definition StrmPlayer.h:227
u8 mLoadFinishFlag
Definition StrmPlayer.h:190
struct nw4hbm::snd::detail::StrmPlayer::StrmHeader StrmHeader
u8 mSkipUpdateAdpcmLoop
Definition StrmPlayer.h:187
static const int DATA_BLOCK_COUNT_MAX
Definition StrmPlayer.h:151
u8 mStartedFlag
Definition StrmPlayer.h:180
void UpdateLoadingBlockIndex(LoadCommand::Status status)
f32 mExtPan
Definition StrmPlayer.h:215
f32 mExtVolume
Definition StrmPlayer.h:214
f32 mMainOutVolume
Definition StrmPlayer.h:222
virtual void SetMainOutVolume(f32 volume)
virtual bool IsPrepared() const
Definition StrmPlayer.h:97
virtual f32 GetRemoteSend(int remoteIndex) const
StrmInfo mStrmInfo
Definition StrmPlayer.h:178
int mLoadingBufferBlockCount
Definition StrmPlayer.h:197
s32 mVoiceOutCount
Definition StrmPlayer.h:229
u16 mAdpcmPredScale[CHANNEL_MAX]
Definition StrmPlayer.h:231
virtual int GetOutputLine() const
f32 mExtPitch
Definition StrmPlayer.h:219
virtual void SetOutputLine(int lineFlag)
virtual void SetSurroundPan(f32 surroundPan)
Definition StrmPlayer.h:103
int mBufferBlockCount
Definition StrmPlayer.h:195
f32 mFxSend[AUX_BUS_NUM]
Definition StrmPlayer.h:224
virtual bool IsStarted() const
Definition StrmPlayer.h:98
f32 mExtLpfFreq
Definition StrmPlayer.h:220
static const int DATA_BLOCK_COUNT_MIN
Definition StrmPlayer.h:150
virtual f32 GetFxSend(AuxBus bus) const
static const int DATA_BLOCK_SIZE_MAX
Definition StrmPlayer.h:152
void UpdateLoopAddress(u32 startSample, u32 endSample)
virtual void SetRemoteFxSend(int remoteIndex, f32 send)
int mPlayingBufferBlockIndex
Definition StrmPlayer.h:201
static const int LOAD_BUFFER_SIZE
TODO: How is this calculated?
Definition StrmPlayer.h:37
u8 mActiveFlag
Definition StrmPlayer.h:179
int mDataBlockSize
Definition StrmPlayer.h:194
LoadCommandList mFreeLoadCommandList
Definition StrmPlayer.h:207
virtual f32 GetVolume() const
Definition StrmPlayer.h:111
u32 mCallbackData
Definition StrmPlayer.h:212
virtual f32 GetSurroundPan2() const
Definition StrmPlayer.h:116
virtual f32 GetLpfFreq() const
Definition StrmPlayer.h:117
int mPlayingDataBlockIndex
Definition StrmPlayer.h:202
virtual f32 GetPan() const
Definition StrmPlayer.h:113
virtual void Pause(bool flag)
virtual bool IsActive() const
Definition StrmPlayer.h:96
virtual void SetLpfFreq(f32 lpfFreq)
Definition StrmPlayer.h:110
f32 mExtPan2
Definition StrmPlayer.h:217
virtual void SetVolume(f32 volume)
Definition StrmPlayer.h:100
virtual f32 GetRemoteFxSend(int remoteIndex) const
virtual void SetFxSend(AuxBus bus, f32 send)
bool SetupPlayer(const StrmHeader *header)
s32 mLoopCounter
Definition StrmPlayer.h:191
f32 mExtSurroundPan
Definition StrmPlayer.h:216
s32 mChannelCount
Definition StrmPlayer.h:228
AxVoice * mVoice
Definition StrmPlayer.h:213
static void NotifyStrmHeaderAsyncEndCallback(bool result, const StrmHeader *header, void *userData)
u8 mValidAdpcmLoop
Definition StrmPlayer.h:188
u8 mPreparedFlag
Definition StrmPlayer.h:181
bool AllocChannels(int channels, int voices)
bool Prepare(StrmBufferPool *bufferPool, StartOffsetType startOffsetType, s32 startOffset, int voices, StrmCallback *callback, u32 callbackData)
int mLoadingDataBlockIndex
Definition StrmPlayer.h:199
virtual bool IsPause() const
Definition StrmPlayer.h:99
f32 mExtSurroundPan2
Definition StrmPlayer.h:218
int mStartOffset
Definition StrmPlayer.h:206
virtual f32 GetMainOutVolume() const
u8 mPauseStatus
Definition StrmPlayer.h:184
StrmCallback * mCallback
Definition StrmPlayer.h:211
u8 mPauseFlag
Definition StrmPlayer.h:182
StartOffsetType mStartOffsetType
Definition StrmPlayer.h:205
bool CalcStartOffset(s32 *blockIndex, u32 *blockOffset, s32 *loopCount)
int mChangeNumBlocks
Definition StrmPlayer.h:193
virtual void SetPitch(f32 pitch)
Definition StrmPlayer.h:101
virtual void SetSurroundPan2(f32 surroundPan2)
Definition StrmPlayer.h:107
virtual f32 GetPitch() const
Definition StrmPlayer.h:112
f32 mMainSend
Definition StrmPlayer.h:223
int mPrepareCounter
Definition StrmPlayer.h:192
static void VoiceCallbackFunc(AxVoice *voice, AxVoice::CallbackStatus status, void *pCallbackArg)
int mLoopStartBlockIndex
Definition StrmPlayer.h:203
f32 mRemoteOutVolume[WPAD_MAX_CONTROLLERS]
Definition StrmPlayer.h:225
void SetLoopEndToZeroBuffer(int endBlock)
int mOutputLineFlag
Definition StrmPlayer.h:221
ut::LinkList< LoadCommand, offsetof(LoadCommand, mLinkNode)> LoadCommandList
Definition StrmPlayer.h:63
int mBufferBlockCountBase
Definition StrmPlayer.h:196
Definition LinkList.h:23
unsigned int size
Definition __os.h:106
static u32 status
Definition fstload.c:9
unsigned long u32
Definition types.h:12
float f32
Definition types.h:25
unsigned short int u16
Definition types.h:10
signed long s32
Definition types.h:11
unsigned char u8
Definition types.h:8
ut::LinkList< StrmPlayer, offsetof(StrmPlayer, mPlayerLink)> StrmPlayerList
Definition StrmPlayer.h:234
static const int CHANNEL_MAX
Definition snd_types.h:48
AuxBus
Definition snd_types.h:73
@ AUX_BUS_NUM
Definition snd_types.h:73
Definition HBMAnmController.h:6
static void callback(u32 param_0)
Definition OSExec.c:308
Definition snd_types.h:107
Definition StrmChannel.h:10
Definition StrmFile.h:82
AdpcmInfo adpcmInfo[STRM_CHANNEL_MAX]
Definition StrmPlayer.h:33
static const int STRM_CHANNEL_MAX
TODO: Why 8 if the player only supports 2???
Definition StrmPlayer.h:30
StrmInfo strmInfo
Definition StrmPlayer.h:32