1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
#include "nw4r/snd/snd_Sound3DManager.h"
#include "nw4r/snd/snd_AxManager.h"
#include "nw4r/snd/snd_Sound3DEngine.h"
#include "nw4r/snd/snd_Sound3DListener.h"
#include "nw4r/snd/snd_SoundHandle.h"
#include "nw4r/math.h"
#include <cmath>
namespace nw4r {
namespace snd {
namespace {
static Sound3DEngine sEngine;
} // namespace
Sound3DManager::Sound3DManager()
: mpEngine(&sEngine), mMaxPriorityReduction(32), field_0x20(0.9f), field_0x24(0.0f), mBiquadFilterType(0) {}
u32 Sound3DManager::GetRequiredMemSize(const SoundArchive *pArchive) {
u32 numParam = 0;
SoundArchive::SoundArchivePlayerInfo playerInfo;
if (pArchive->ReadSoundArchivePlayerInfo(&playerInfo)) {
numParam += playerInfo.seqSoundCount;
numParam += playerInfo.strmSoundCount;
numParam += playerInfo.waveSoundCount;
}
return numParam * sizeof(Sound3DParam);
}
bool Sound3DManager::Setup(const SoundArchive *pArchive, void *pBuffer, u32 size) {
#pragma unused(pArchive)
mParamPool.Create(pBuffer, size);
return true;
}
void Sound3DManager::SetEngine(Sound3DEngine *engine) {
mpEngine = engine;
}
void Sound3DManager::detail_UpdateAmbientParam(
const void *param, u32 unused1, int unused2, SoundAmbientParam *ambientParam
) {
const Sound3DParam *p = static_cast<const Sound3DParam *>(param);
if (mpEngine != NULL) {
mpEngine->UpdateAmbientParam(this, p, unused1, unused2, ambientParam);
}
}
int Sound3DManager::detail_GetAmbientPriority(const void *param, u32 arg) {
int result = 0;
if (mpEngine != NULL) {
const Sound3DParam *p = static_cast<const Sound3DParam *>(param);
result = mpEngine->GetAmbientPriority(this, p, arg);
}
return result;
}
int Sound3DManager::detail_GetRequiredVoiceOutCount(const void *param, u32 arg) {
int result = 1;
if (mpEngine != NULL) {
const Sound3DParam *p = static_cast<const Sound3DParam *>(param);
result = mpEngine->GetRequiredVoiceOutCount(this, p, arg);
}
return result;
}
void *Sound3DManager::detail_AllocAmbientArg(u32 size) {
if (size != sizeof(Sound3DParam)) {
return NULL;
}
return mParamPool.Alloc();
}
void Sound3DManager::detail_FreeAmbientArg(void *pArg, const detail::BasicSound *pSound) {
#pragma unused(pSound)
mParamPool.Free(static_cast<Sound3DParam *>(pArg));
}
void Sound3DManager::SetBiquadFilterType(int type) {
mBiquadFilterType = type;
}
Sound3DParam::Sound3DParam() {
field_0x18 = 0;
decayCurve = Sound3DManager::DECAY_CURVE_LOGARITHMIC;
decayRatio = 128;
field_0x1E = 0;
userParam = 0;
field_0x24 = 0;
}
} // namespace snd
} // namespace nw4r
|