NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
snd_SoundPlayer.h
1#ifndef NW4R_SND_SOUND_PLAYER_H
2#define NW4R_SND_SOUND_PLAYER_H
3
4/*******************************************************************************
5 * headers
6 */
7
8#include <types.h>
9
10#include "nw4r/snd/snd_BasicSound.h"
11#include "nw4r/snd/snd_global.h" // AUX_BUS_NUM
12#include "nw4r/snd/snd_PlayerHeap.h"
13#include "nw4r/snd/snd_SoundHandle.h"
14
15/*******************************************************************************
16 * classes
17 */
18
19namespace nw4r { namespace snd
20{
21 // [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x26c0f
22 // NOTE: different from ketteiban: no remote fields
23 class SoundPlayer
24 {
25 // methods
26 public:
27 // cdtors
28 SoundPlayer();
29 ~SoundPlayer();
30
31 // methods
32 int GetPlayableSoundCount() const { return mPlayableCount; }
33 f32 GetVolume() const { return mVolume; }
34 void SetVolume(f32 volume);
35 f32 GetLpfFreq() const { return mLpfFreq; }
36 void SetLpfFreq(f32 freq);
37 int GetDefaultOutputLine() const { return mOutputLineFlag; }
38 f32 GetMainOutVolume() const { return mMainOutVolume; }
39 int GetBiquadFilterType() const { return mBiquadType; }
40 f32 GetBiquadFilterValue() const { return mBiquadValue; }
41 f32 GetMainSend() const { return mMainSend; }
42 f32 GetFxSend(int index) const { return mFxSend[index]; }
43 void SetFxSend(AuxBus, f32);
44
45 void SetPlayableSoundCount(int count);
46 f32 GetRemoteOutVolume(int remote) const;
47
48 int GetPlayingSoundCount() const { return mSoundList.GetSize(); }
49 detail::BasicSound *GetLowestPrioritySound()
50 {
51 return &mPriorityList.GetFront();
52 }
53
54 void Update();
55 void PauseAllSound(bool flag, int fadeFrames);
56 void StopAllSound(int fadeFrames);
57
58 void RemoveSoundList(detail::BasicSound *sound);
59 bool detail_AppendSound(detail::BasicSound *sound);
60 void detail_RemoveSound(detail::BasicSound *sound);
61 void detail_SetPlayableSoundLimit(int limit);
62 bool detail_CanPlaySound(int startPriority);
63
64 void InsertPriorityList(detail::BasicSound *sound);
65 void RemovePriorityList(detail::BasicSound *sound);
66 void detail_SortPriorityList(detail::BasicSound *sound);
67 void detail_SortPriorityList();
68
69 detail::PlayerHeap *detail_AllocPlayerHeap(detail::BasicSound *sound);
70 void detail_FreePlayerHeap(detail::BasicSound *sound);
71 void detail_AppendPlayerHeap(detail::PlayerHeap *heap);
72
73 // Apparently exists, needed in d/snd
74 template <typename TForEachFunc>
75 TForEachFunc ForEachSound(TForEachFunc pFunc, bool reverse) {
76 if (reverse) {
77 detail::BasicSound::SoundPlayerPlayLinkList::ReverseIterator it = mSoundList.GetBeginReverseIter();
78
79 while (it != mSoundList.GetEndReverseIter()) {
80 detail::BasicSound::SoundPlayerPlayLinkList::ReverseIterator curr = it;
81
82 SoundHandle handle;
83 handle.detail_AttachSoundAsTempHandle(&*curr);
84 pFunc(handle);
85
86 if (handle.IsAttachedSound()) {
87 ++it;
88 }
89 }
90 } else {
91 NW4R_RANGE_FOR_NO_AUTO_INC(it, mSoundList) {
92 decltype(it) curItr = it++;
93 SoundHandle handle;
94 handle.detail_AttachSoundAsTempHandle(&*curItr);
95 pFunc(handle);
96 }
97 }
98
99 return pFunc;
100 }
101
102 // members
103 private:
104 detail::BasicSound::SoundPlayerPlayLinkList mSoundList; // size 0x0c, offset 0x00
105 detail::BasicSound::SoundPlayerPriorityLinkList mPriorityList; // size 0x0c, offset 0x0c
106 detail::PlayerHeap::LinkList mHeapList; // size 0x0c, offset 0x18
107 int mPlayableCount; // size 0x04, offset 0x24
108 int mPlayableLimit; // size 0x04, offset 0x28
109 f32 mVolume; // size 0x04, offset 0x2c
110 f32 mLpfFreq; // size 0x04, offset 0x30
111 int mOutputLineFlag; // size 0x04, offset 0x34
112 f32 mMainOutVolume; // size 0x04, offset 0x38
113 int mBiquadType; // size 0x04, offset 0x3c
114 f32 mBiquadValue; // size 0x04, offset 0x40
115 f32 mRemoteOutVolume[4];
116 f32 mMainSend; // size 0x04, offset 0x44
117 f32 mFxSend[AUX_BUS_NUM]; // size 0x0c, offset 0x48
118 }; // size 0x54
119}} // namespace nw4r::snd
120
121#endif // NW4R_SND_SOUND_PLAYER_H