NW4F Snd
Loading...
Searching...
No Matches
snd_BasicSound.h
Go to the documentation of this file.
1#ifndef NW_SND_BASIC_SOUND_H_
2#define NW_SND_BASIC_SOUND_H_
3
4#include <nw/snd/snd_Global.h>
5#include <nw/snd/snd_MoveValue.h>
6#include <nw/ut/ut_RuntimeTypeInfo.h>
7#include <nw/ut/ut_LinkList.h>
8
9namespace nw { namespace snd {
10
11class SoundHandle;
12class SoundPlayer;
13class SoundActor;
14
16{
21
26
28 {
29 volume = 1.0f;
30 pan = span = 0.0f;
31 for (int i = 0; i < AUX_BUS_NUM; i++)
32 fxSend[i] = 0.0f;
33 }
34};
35static_assert(sizeof(OutputAmbientParam) == 0x18);
36
38{
49
51 {
53 }
54
56 {
57 volume = 1.0f;
58 pitch = 1.0f;
59 lpf = 0.0f;
60 biquadFilterValue = 0.0f;
62 priority = 0;
63 userData = 0;
64
65 outputLineFlag = -1;
66
67 tvParam.Initialize();
68 for (int i = 0; i < DRC_OUT_COUNT; i++)
69 drcParam[i].Initialize();
70 }
71};
72static_assert(sizeof(SoundParam) == 0x50);
73
75{
86
88 : volume(1.0f)
89 , pitch(1.0f)
90 , lpf(0.0f)
91 , biquadFilterValue(0.0f)
93 , priority(0)
94 , userData(0)
95 , outputLineFlag(-1)
96 {
97 tvParam.Initialize();
98 for (int i = 0; i < DRC_OUT_COUNT; i++)
99 drcParam[i].Initialize();
100 }
101};
102static_assert(sizeof(SoundAmbientParam) == 0x50);
103
104namespace internal {
105
107{
110
113
116
118 {
119 Reset();
120 }
121
122 void Reset()
123 {
124 volume = pitch = tvVolume = 1.0f;
125 tvPan = 0.0f;
126
127 for (int i = 0; i < DRC_OUT_COUNT; i++)
128 {
129 drcVolume[i] = 1.0f;
130 drcPan[i] = 0.0f;
131 }
132 }
133};
134static_assert(sizeof(SoundActorParam) == 0x18);
135
136namespace driver {
137
138class BasicSoundPlayer;
139
140} // nw::snd::internal::driver
141
142class PlayerHeap;
144
146{
147 friend class nw::snd::SoundHandle;
148
149public:
150 NW_UT_RUNTIME_TYPEINFO_ROOT()
151
152public:
153 static const int PRIORITY_MIN = 0;
154 static const int PRIORITY_MAX = 127;
155 static const u32 INVALID_ID = 0xffffffff;
156
157public:
161
170 static_assert(sizeof(AmbientInfo) == 0x14);
171
178
179public:
181 virtual ~BasicSound() {}
182 void Update();
184 void Stop(int fadeFrames);
185 void Pause(bool flag, int fadeFrames);
186 void SetAutoStopCounter(int frames);
187 void FadeIn(int frames);
188
189 virtual void Initialize();
190 virtual void Finalize();
191
192 virtual bool IsPrepared() const = 0;
193 bool IsPause() const;
194 bool IsStarted() const { return m_StartedFlag; }
195
196 void SetPriority(int priority, int ambientPriority);
197 void GetPriority(int* priority, int* ambientPriority) const;
198
199 void SetInitialVolume(f32 volume);
201
202 void SetVolume(f32 volume, int frames = 0);
203 f32 GetVolume() const;
204
205 void SetPitch(f32 pitch);
206 f32 GetPitch() const;
207 /*
208 void SetLpfFreq( f32 lpfFreq );
209 f32 GetLpfFreq() const;
210 void SetBiquadFilter( int type, f32 value );
211 void GetBiquadFilter( int* type, f32* value ) const;
212 */
213 void SetOutputLine(u32 lineFlag);
216 /*
217 void SetPlayerPriority( int priority );
218 */
219 void SetPan(f32 pan);
220 f32 GetPan() const;
221 /*
222 void SetSurroundPan( f32 pan );
223 f32 GetSurroundPan() const;
224 void SetMainSend( f32 send );
225 f32 GetMainSend() const;
226 void SetFxSend( AuxBus bus, f32 send );
227 f32 GetFxSend( AuxBus bus ) const;
228 */
229
230 void SetPanMode(PanMode mode);
232 void SetFrontBypass(bool isFrontBypass);
233 void SetRemoteFilter(u8 filter);
235
236 void SetOutputVolume (OutputDevice device, f32 volume);
237 /*
238 void SetOutputPan (OutputDevice device, f32 pan);
239 void SetOutputSurroundPan(OutputDevice device, f32 span);
240 void SetOutputMainSend (OutputDevice device, f32 send);
241 void SetOutputFxSend (OutputDevice device, AuxBus bus, f32 send);
242 */
243
245 /*
246 f32 GetOutputPan (OutputDevice device) const;
247 f32 GetOutputSurroundPan(OutputDevice device) const;
248 f32 GetOutputMainSend (OutputDevice device) const;
249 f32 GetOutputFxSend (OutputDevice device, AuxBus bus) const;
250 */
251
252 void SetRemoteOutVolume( u32 remoteIndex, f32 volume );
253 f32 GetRemoteOutVolume( u32 remoteIndex ) const;
254 /*
255 void SetRemoteMainSend( u32 remoteIndex, f32 send );
256 f32 GetRemoteMainSend( u32 remoteIndex ) const;
257 void SetRemoteFxSend( u32 remoteIndex, f32 send );
258 f32 GetRemoteFxSend( u32 remoteIndex ) const;
259
260 int GetRemainingFadeFrames() const;
261 int GetRemainingPauseFadeFrames() const;
262 */
263 int GetPlayerPriority() const { return m_Priority; }
264
265 void SetId( u32 id );
266 u32 GetId() const { return m_Id; }
267
269 {
270 return ut::Clamp(
271 static_cast<int>( m_Priority ) + static_cast<int>( m_AmbientParam.priority ),
272 PRIORITY_MIN,
273 PRIORITY_MAX
274 );
275 }
276
277 SoundPlayer* GetSoundPlayer() { return m_pSoundPlayer; }
278 const SoundPlayer* GetSoundPlayer() const { return m_pSoundPlayer; }
279
280 void AttachSoundPlayer(SoundPlayer* player);
281 void DetachSoundPlayer(SoundPlayer* player);
282
285
288
289 void AttachPlayerHeap(PlayerHeap* pHeap);
290 void DetachPlayerHeap(PlayerHeap* pHeap);
291 PlayerHeap* GetPlayerHeap() { return m_pPlayerHeap; }
292
293 void SetAmbientInfo(const AmbientInfo& info);
294 void ClearAmbientArgUpdateCallback() { m_AmbientInfo.argUpdateCallback = NULL; }
295 void ClearAmbientParamUpdateCallback() { m_AmbientInfo.paramUpdateCallback = NULL; }
296 void ClearAmbientArgAllocatorCallback() { m_AmbientInfo.argAllocatorCallback = NULL; }
297 const SoundParam& GetAmbientParam() const { return m_AmbientParam; }
298 static int GetAmbientPriority(const AmbientInfo& ambientInfo, u32 soundId);
299
302 virtual bool IsAttachedTempSpecialHandle() = 0;
305 virtual void DetachTempSpecialHandle() = 0;
306
307 void SetUserParamBuffer(void* buffer, size_t size) { m_pUserParam = buffer; m_UserParamSize = size; }
308 void* GetUserParam() { return m_pUserParam; }
309
318
319protected:
320 virtual driver::BasicSoundPlayer* GetBasicSoundPlayerHandle() = 0;
321
322 virtual void OnUpdatePlayerPriority() {}
323 virtual void OnUpdate() {}
324
325 virtual void UpdateMoveValue();
326 virtual void UpdateParam();
327
329
330private:
332
333 PlayerHeap* m_pPlayerHeap;
336 SoundPlayer* m_pSoundPlayer;
339
343
346
351
355
358
361
364
366
372
373 u32 _e8; // Set in Initialize() to 0 but never used
374
376 {
382
384 {
385 volume.InitValue(1.0f);
386 pan = span = mainSend = 0.0f;
387 for (int i = 0; i < AUX_BUS_NUM; i++)
388 fxSend[i] = 0.0f;
389 }
390
391 void Update()
392 {
393 volume.Update();
394 }
395
397 {
398 return volume.GetValue();
399 }
400
401 void SetVolume(f32 target, int frame)
402 {
403 volume.SetTarget(target, frame);
404 }
405 };
406 static_assert(sizeof(CommonParam) == 0x28);
407
409
413
416
417public:
422};
423static_assert(sizeof(BasicSound) == 0x1A8);
424
426{
427public:
430 const void* arg,
431 u32 soundId,
432 SoundAmbientParam* param
433 ) = 0;
435 const void* arg,
436 u32 soundId
437 ) = 0;
438};
439
441{
442public:
445 void* arg,
446 const internal::BasicSound* sound
447 ) = 0;
448};
449
451{
452public:
454 virtual void* detail_AllocAmbientArg( size_t argSize ) = 0;
456 void* arg,
457 const internal::BasicSound* sound
458 ) = 0;
459};
460
461} } } // namespace nw::snd::internal
462
463#endif // NW_SND_BASIC_SOUND_H_
Definition snd_SoundActor.h:13
Definition snd_SoundHandle.h:10
virtual void detail_FreeAmbientArg(void *arg, const internal::BasicSound *sound)=0
virtual ~AmbientArgAllocatorCallback()
Definition snd_BasicSound.h:453
virtual void * detail_AllocAmbientArg(size_t argSize)=0
virtual void detail_UpdateAmbientArg(void *arg, const internal::BasicSound *sound)=0
virtual ~AmbientArgUpdateCallback()
Definition snd_BasicSound.h:443
virtual int detail_GetAmbientPriority(const void *arg, u32 soundId)=0
virtual void detail_UpdateAmbientParam(const void *arg, u32 soundId, SoundAmbientParam *param)=0
virtual ~AmbientParamUpdateCallback()
Definition snd_BasicSound.h:428
Definition snd_BasicSound.h:146
PauseState GetPauseState() const
Definition snd_BasicSound.h:317
PlayerState m_PlayerState
Definition snd_BasicSound.h:356
const SoundPlayer * GetSoundPlayer() const
Definition snd_BasicSound.h:278
bool IsStarted() const
Definition snd_BasicSound.h:194
void * m_pUserParam
Definition snd_BasicSound.h:414
ut::LinkListNode m_SoundPlayerPlayLink
Definition snd_BasicSound.h:419
void DetachPlayerHeap(PlayerHeap *pHeap)
bool m_StartFlag
Definition snd_BasicSound.h:348
void SetUserParamBuffer(void *buffer, size_t size)
Definition snd_BasicSound.h:307
void SetOutputVolume(OutputDevice device, f32 volume)
void SetAmbientInfo(const AmbientInfo &info)
size_t m_UserParamSize
Definition snd_BasicSound.h:415
void AttachExternalSoundPlayer(ExternalSoundPlayer *extPlayer)
bool m_UnPauseFlag
Definition snd_BasicSound.h:354
void ClearAmbientParamUpdateCallback()
Definition snd_BasicSound.h:295
PlayerHeap * GetPlayerHeap()
Definition snd_BasicSound.h:291
void SetInitialVolume(f32 volume)
CommonParam m_CommonParam
Definition snd_BasicSound.h:410
bool IsPlayerAvailable() const
Definition snd_BasicSound.h:328
void GetPriority(int *priority, int *ambientPriority) const
OutputParam m_OutputParam[OUTPUT_DEVICE_COUNT]
Definition snd_BasicSound.h:411
void SetPriority(int priority, int ambientPriority)
virtual void DetachTempSpecialHandle()=0
PlayerHeap * m_pPlayerHeap
Definition snd_BasicSound.h:333
void SetOutputLine(u32 lineFlag)
bool m_FadeOutFlag
Definition snd_BasicSound.h:352
void SetRemoteOutVolume(u32 remoteIndex, f32 volume)
f32 m_LpfFreq
Definition snd_BasicSound.h:369
ut::LinkListNode m_PriorityLink
Definition snd_BasicSound.h:418
static const u32 INVALID_ID
Definition snd_BasicSound.h:155
virtual bool IsPrepared() const =0
void ClearAmbientArgAllocatorCallback()
Definition snd_BasicSound.h:296
s32 m_AutoStopCounter
Definition snd_BasicSound.h:359
f32 m_BiquadFilterValue
Definition snd_BasicSound.h:370
SoundPlayer * m_pSoundPlayer
Definition snd_BasicSound.h:336
static const int PRIORITY_MAX
Definition snd_BasicSound.h:154
void AttachSoundPlayer(SoundPlayer *player)
void ClearAmbientArgUpdateCallback()
Definition snd_BasicSound.h:294
MoveValue< f32, int > m_FadeVolume
Definition snd_BasicSound.h:344
PauseState
Definition snd_BasicSound.h:311
@ PAUSE_STATE_UNPAUSING
Definition snd_BasicSound.h:315
@ PAUSE_STATE_NORMAL
Definition snd_BasicSound.h:312
@ PAUSE_STATE_PAUSED
Definition snd_BasicSound.h:314
@ PAUSE_STATE_PAUSING
Definition snd_BasicSound.h:313
void AttachSoundActor(SoundActor *actor)
SoundHandle * m_pGeneralHandle
Definition snd_BasicSound.h:334
static int GetAmbientPriority(const AmbientInfo &ambientInfo, u32 soundId)
SoundParam m_AmbientParam
Definition snd_BasicSound.h:341
void SetPanMode(PanMode mode)
bool m_PlayerAvailableFlag
Definition snd_BasicSound.h:353
void AttachPlayerHeap(PlayerHeap *pHeap)
AmbientInfo m_AmbientInfo
Definition snd_BasicSound.h:340
PlayerState
Definition snd_BasicSound.h:173
@ PLAYER_STATE_STOP
Definition snd_BasicSound.h:176
@ PLAYER_STATE_INIT
Definition snd_BasicSound.h:174
@ PLAYER_STATE_PLAY
Definition snd_BasicSound.h:175
u8 m_Priority
Definition snd_BasicSound.h:362
RemoteOutputParam m_RemoteParam[REMOTE_OUT_COUNT]
Definition snd_BasicSound.h:412
s8 m_BiquadFilterType
Definition snd_BasicSound.h:363
void DetachSoundPlayer(SoundPlayer *player)
int CalcCurrentPlayerPriority() const
Definition snd_BasicSound.h:268
u32 _e8
Definition snd_BasicSound.h:373
virtual void OnUpdate()
Definition snd_BasicSound.h:323
virtual ~BasicSound()
Definition snd_BasicSound.h:181
void DetachSoundActor(SoundActor *actor)
void SetRemoteFilter(u8 filter)
void SetAutoStopCounter(int frames)
f32 GetRemoteOutVolume(u32 remoteIndex) const
int GetPlayerPriority() const
Definition snd_BasicSound.h:263
u32 m_UpdateCounter
Definition snd_BasicSound.h:360
bool m_StartedFlag
Definition snd_BasicSound.h:349
void SetVolume(f32 volume, int frames=0)
f32 GetOutputVolume(OutputDevice device) const
bool m_AutoStopFlag
Definition snd_BasicSound.h:350
ut::LinkListNode m_SoundPlayerPriorityLink
Definition snd_BasicSound.h:420
SoundActorParam m_ActorParam
Definition snd_BasicSound.h:342
void DetachExternalSoundPlayer(ExternalSoundPlayer *extPlayer)
PauseState m_PauseState
Definition snd_BasicSound.h:357
void SetFrontBypass(bool isFrontBypass)
bool m_InitializeFlag
Definition snd_BasicSound.h:347
void SetPanCurve(PanCurve curve)
ut::LinkListNode m_ExtSoundPlayerPlayLink
Definition snd_BasicSound.h:421
u32 m_Id
Definition snd_BasicSound.h:365
void Pause(bool flag, int fadeFrames)
void SetVoiceRendererType(VoiceRendererType mode)
virtual driver::BasicSoundPlayer * GetBasicSoundPlayerHandle()=0
void ClearIsFinalizedForCannotAllocatedResourceFlag()
f32 GetVolume() const
Definition snd_BasicSound.cpp:5
const SoundParam & GetAmbientParam() const
Definition snd_BasicSound.h:297
u32 m_OutputLineFlag
Definition snd_BasicSound.h:371
u32 GetId() const
Definition snd_BasicSound.h:266
virtual bool IsAttachedTempSpecialHandle()=0
void ApplyCommonParam(OutputParam &param)
virtual void OnUpdatePlayerPriority()
Definition snd_BasicSound.h:322
MoveValue< f32, int > m_PauseFadeVolume
Definition snd_BasicSound.h:345
ExternalSoundPlayer * m_pExtSoundPlayer
Definition snd_BasicSound.h:338
SoundPlayer * GetSoundPlayer()
Definition snd_BasicSound.h:277
SoundActor * m_pSoundActor
Definition snd_BasicSound.h:337
f32 m_Pitch
Definition snd_BasicSound.h:368
f32 m_InitVolume
Definition snd_BasicSound.h:367
void Stop(int fadeFrames)
SoundHandle * m_pTempGeneralHandle
Definition snd_BasicSound.h:335
void * GetUserParam()
Definition snd_BasicSound.h:308
Definition snd_ExternalSoundPlayer.h:14
Definition snd_BasicSound.h:136
Definition snd_BasicSound.cpp:3
Definition snd_BasicSound.cpp:3
static const int DRC_OUT_COUNT
Definition snd_Global.h:14
static const int REMOTE_OUT_COUNT
Definition snd_Global.h:154
VoiceRendererType
Definition snd_Global.h:157
PanMode
Definition snd_Global.h:45
@ BIQUAD_FILTER_TYPE_INHERIT
Definition snd_Global.h:74
@ AUX_BUS_NUM
Definition snd_Global.h:38
PanCurve
Definition snd_Global.h:52
OutputDevice
Definition snd_Global.h:17
@ OUTPUT_DEVICE_COUNT
Definition snd_Global.h:20
Definition snd_BasicSound.h:16
void Initialize()
Definition snd_BasicSound.h:27
f32 pan
Definition snd_BasicSound.h:18
f32 volume
Definition snd_BasicSound.h:17
f32 span
Definition snd_BasicSound.h:19
f32 fxSend[AUX_BUS_NUM]
Definition snd_BasicSound.h:20
OutputAmbientParam()
Definition snd_BasicSound.h:22
Definition snd_Global.h:166
Definition snd_Global.h:186
Definition snd_BasicSound.h:75
f32 lpf
Definition snd_BasicSound.h:78
int priority
Definition snd_BasicSound.h:81
f32 pitch
Definition snd_BasicSound.h:77
OutputAmbientParam drcParam[DRC_OUT_COUNT]
Definition snd_BasicSound.h:85
f32 biquadFilterValue
Definition snd_BasicSound.h:79
f32 volume
Definition snd_BasicSound.h:76
int biquadFilterType
Definition snd_BasicSound.h:80
u32 userData
Definition snd_BasicSound.h:82
SoundAmbientParam()
Definition snd_BasicSound.h:87
int outputLineFlag
Definition snd_BasicSound.h:83
OutputAmbientParam tvParam
Definition snd_BasicSound.h:84
Definition snd_BasicSound.h:38
f32 pitch
Definition snd_BasicSound.h:40
u32 userData
Definition snd_BasicSound.h:46
f32 volume
Definition snd_BasicSound.h:39
void Initialize()
Definition snd_BasicSound.h:55
OutputAmbientParam drcParam[DRC_OUT_COUNT]
Definition snd_BasicSound.h:48
int priority
Definition snd_BasicSound.h:44
int outputLineFlag
Definition snd_BasicSound.h:45
f32 lpf
Definition snd_BasicSound.h:41
f32 biquadFilterValue
Definition snd_BasicSound.h:42
SoundParam()
Definition snd_BasicSound.h:50
OutputAmbientParam tvParam
Definition snd_BasicSound.h:47
int biquadFilterType
Definition snd_BasicSound.h:43
Definition snd_BasicSound.h:163
AmbientParamUpdateCallback * paramUpdateCallback
Definition snd_BasicSound.h:164
void * arg
Definition snd_BasicSound.h:167
AmbientArgAllocatorCallback * argAllocatorCallback
Definition snd_BasicSound.h:166
unsigned long argSize
Definition snd_BasicSound.h:168
AmbientArgUpdateCallback * argUpdateCallback
Definition snd_BasicSound.h:165
Definition snd_BasicSound.h:376
f32 mainSend
Definition snd_BasicSound.h:380
f32 GetVolume() const
Definition snd_BasicSound.h:396
void Update()
Definition snd_BasicSound.h:391
void Initialize()
Definition snd_BasicSound.h:383
f32 fxSend[AUX_BUS_NUM]
Definition snd_BasicSound.h:381
void SetVolume(f32 target, int frame)
Definition snd_BasicSound.h:401
f32 pan
Definition snd_BasicSound.h:378
MoveValue< f32, int > volume
Definition snd_BasicSound.h:377
f32 span
Definition snd_BasicSound.h:379
Definition snd_BasicSound.h:107
f32 drcPan[DRC_OUT_COUNT]
Definition snd_BasicSound.h:115
f32 tvVolume
Definition snd_BasicSound.h:111
f32 tvPan
Definition snd_BasicSound.h:112
void Reset()
Definition snd_BasicSound.h:122
f32 drcVolume[DRC_OUT_COUNT]
Definition snd_BasicSound.h:114
SoundActorParam()
Definition snd_BasicSound.h:117
f32 pitch
Definition snd_BasicSound.h:109
f32 volume
Definition snd_BasicSound.h:108