NW4F Snd
Loading...
Searching...
No Matches
snd_SoundActor.h
Go to the documentation of this file.
1#ifndef NW_SND_SOUND_ACTOR_H_
2#define NW_SND_SOUND_ACTOR_H_
3
4#include <nw/snd/snd_SoundStartable.h>
5#include <nw/snd/snd_ExternalSoundPlayer.h>
6#include <nw/snd/snd_BasicSound.h> // SoundActorParam
7
8namespace nw { namespace snd {
9
11
13{
15
16public:
17 static const int ACTOR_PLAYER_COUNT = 4;
18
19 SoundActor(SoundArchivePlayer& soundArchivePlayer);
21 ~SoundActor() override;
22
23 void Initialize(SoundArchivePlayer& soundArchivePlayer);
24 void Finalize();
25
26public:
27 void StopAllSound(int fadeFrames);
28 void PauseAllSound(bool flag, int fadeFrames);
29
30protected:
32 SoundHandle* handle,
33 u32 soundId,
34 const SoundStartable::StartInfo* startInfo,
35 void* setupArg
36 );
37
38public:
39 void SetVolume(f32 volume)
40 {
41 m_ActorParam.volume = volume;
42 }
43
44 f32 GetVolume() const
45 {
46 return m_ActorParam.volume;
47 }
48
49 void SetPitch(f32 pitch)
50 {
51 m_ActorParam.pitch = pitch;
52 }
53
54 f32 GetPitch() const
55 {
56 return m_ActorParam.pitch;
57 }
58
59 void SetMainOutVolume(f32 volume)
60 {
61 m_ActorParam.tvVolume = volume;
62 }
63
65 {
66 return m_ActorParam.tvVolume;
67 }
68
69 void SetPan(f32 pan)
70 {
71 m_ActorParam.tvPan = pan;
72 }
73
74 f32 GetPan() const
75 {
76 return m_ActorParam.tvPan;
77 }
78
79 void SetDrcOutVolume(f32 volume, u32 drcIndex = 0)
80 {
81 //NW_ASSERT_MAXLT(drcIndex, DRC_OUT_COUNT);
82 m_ActorParam.drcVolume[drcIndex] = volume;
83 }
84
85 f32 GetDrcOutVolume(u32 drcIndex = 0) const
86 {
87 //NW_ASSERT_MAXLT(drcIndex, DRC_OUT_COUNT);
88 return m_ActorParam.drcVolume[drcIndex];
89 }
90
91 void SetDrcPan(f32 pan, u32 drcIndex = 0)
92 {
93 //NW_ASSERT_MAXLT(drcIndex, DRC_OUT_COUNT);
94 m_ActorParam.drcPan[drcIndex] = pan;
95 }
96
97 f32 GetDrcPan(u32 drcIndex = 0) const
98 {
99 //NW_ASSERT_MAXLT(drcIndex, DRC_OUT_COUNT);
100 return m_ActorParam.drcPan[drcIndex];
101 }
102
103 int GetPlayingSoundCount(int actorPlayerId) const;
104
105 void SetPlayableSoundCount(int actorPlayerId, int count);
106 int GetPlayableSoundCount(int actorPlayerId) const;
107
108 template <class Function>
109 void ForEachSoundRef(Function& function, bool reverse = false);
110
111 template <class Function>
112 Function ForEachSound(Function function, bool reverse = false);
113
115 {
116 if (actorPlayerId < 0 || ACTOR_PLAYER_COUNT <= actorPlayerId)
117 return NULL;
118
119 return &m_ActorPlayer[actorPlayerId];
120 }
121
123 {
124 return m_ActorParam;
125 }
126
128 SoundHandle* handle,
129 u32 soundId,
130 const SoundStartable::StartInfo* startInfo,
131 internal::BasicSound::AmbientInfo* ambientInfo,
132 void* setupArg
133 );
134
135private:
137 SoundHandle* handle,
138 u32 soundId,
139 bool holdFlag,
140 const SoundStartable::StartInfo* startInfo
141 ) override;
142 SoundArchive::ItemId detail_GetItemId(const char* pString) override;
143
145 {
147 };
148
152
155};
156static_assert(sizeof(SoundActor) == 0x64);
157
158template <class Function>
159inline void SoundActor::ForEachSoundRef(Function& function, bool reverse)
160{
161 for (int actorPlayerIndex = 0; actorPlayerIndex < ACTOR_PLAYER_COUNT; actorPlayerIndex++)
162 m_ActorPlayer[actorPlayerIndex].ForEachSoundRef<Function>(function, reverse);
163}
164
165template <class Function>
166inline Function SoundActor::ForEachSound(Function function, bool reverse)
167{
168 for (int actorPlayerIndex = 0; actorPlayerIndex < ACTOR_PLAYER_COUNT; actorPlayerIndex++)
169 m_ActorPlayer[actorPlayerIndex].ForEachSound<Function>(function, reverse);
170
171 return function;
172}
173
174} } // namespace nw::snd
175
176#endif // NW_SND_SOUND_ACTOR_H_
Definition snd_SoundActor.h:13
void SetPlayableSoundCount(int actorPlayerId, int count)
SoundActor(SoundArchivePlayer &soundArchivePlayer)
virtual SoundStartable::StartResult SetupSound(SoundHandle *handle, u32 soundId, const SoundStartable::StartInfo *startInfo, void *setupArg)
f32 GetDrcPan(u32 drcIndex=0) const
Definition snd_SoundActor.h:97
SoundArchivePlayer * m_pSoundArchivePlayer
Definition snd_SoundActor.h:149
virtual SoundStartable::StartResult detail_SetupSoundWithAmbientInfo(SoundHandle *handle, u32 soundId, const SoundStartable::StartInfo *startInfo, internal::BasicSound::AmbientInfo *ambientInfo, void *setupArg)
void Initialize(SoundArchivePlayer &soundArchivePlayer)
Function ForEachSound(Function function, bool reverse=false)
Definition snd_SoundActor.h:166
f32 GetPan() const
Definition snd_SoundActor.h:74
const internal::SoundActorParam & detail_GetActorParam() const
Definition snd_SoundActor.h:122
f32 GetVolume() const
Definition snd_SoundActor.h:44
bool m_IsInitialized
Definition snd_SoundActor.h:153
ActorPlayer * detail_GetActorPlayer(int actorPlayerId)
Definition snd_SoundActor.h:114
~SoundActor() override
void SetDrcOutVolume(f32 volume, u32 drcIndex=0)
Definition snd_SoundActor.h:79
void SetPitch(f32 pitch)
Definition snd_SoundActor.h:49
void SetVolume(f32 volume)
Definition snd_SoundActor.h:39
f32 GetDrcOutVolume(u32 drcIndex=0) const
Definition snd_SoundActor.h:85
ActorPlayer m_ActorPlayer[ACTOR_PLAYER_COUNT]
Definition snd_SoundActor.h:150
SoundStartable::StartResult detail_SetupSound(SoundHandle *handle, u32 soundId, bool holdFlag, const SoundStartable::StartInfo *startInfo) override
void StopAllSound(int fadeFrames)
f32 GetMainOutVolume() const
Definition snd_SoundActor.h:64
f32 GetPitch() const
Definition snd_SoundActor.h:54
SoundArchive::ItemId detail_GetItemId(const char *pString) override
internal::SoundActorParam m_ActorParam
Definition snd_SoundActor.h:151
bool m_IsFinalized
Definition snd_SoundActor.h:154
void SetDrcPan(f32 pan, u32 drcIndex=0)
Definition snd_SoundActor.h:91
void SetPan(f32 pan)
Definition snd_SoundActor.h:69
int GetPlayableSoundCount(int actorPlayerId) const
static const int ACTOR_PLAYER_COUNT
Definition snd_SoundActor.h:17
void PauseAllSound(bool flag, int fadeFrames)
void ForEachSoundRef(Function &function, bool reverse=false)
Definition snd_SoundActor.h:159
internal::ExternalSoundPlayer ActorPlayer
Definition snd_SoundActor.h:14
void SetMainOutVolume(f32 volume)
Definition snd_SoundActor.h:59
int GetPlayingSoundCount(int actorPlayerId) const
Definition snd_SoundArchivePlayer.h:26
Definition snd_SoundArchive.h:11
u32 ItemId
Definition snd_SoundArchive.h:13
Definition snd_SoundHandle.h:10
Definition snd_SoundStartable.h:14
Definition snd_SoundStartable.h:11
Definition snd_BasicSound.h:146
Definition snd_ExternalSoundPlayer.h:14
Definition snd_BasicSound.cpp:3
Definition snd_BasicSound.cpp:3
Definition snd_SoundActor.h:145
bool holdFlag
Definition snd_SoundActor.h:146
Definition snd_SoundStartable.h:70
Definition snd_BasicSound.h:163
Definition snd_BasicSound.h:107