summaryrefslogtreecommitdiff
path: root/include/nw4r/snd/snd_Sound3DManager.h
blob: 1c370eeffd16854bb58f66708c2d5cc6c31f9497 (plain)
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
103
104
#ifndef NW4R_SND_SOUND_3D_MANAGER_H
#define NW4R_SND_SOUND_3D_MANAGER_H
#include "nw4r/snd/snd_BasicSound.h"
#include "nw4r/snd/snd_InstancePool.h"
#include "nw4r/snd/snd_Sound3DEngine.h"
#include "nw4r/snd/snd_SoundArchive.h"
#include "nw4r/types_nw4r.h"
#include "nw4r/ut/ut_LinkList.h"

#include "nw4r/math.h"

namespace nw4r {
namespace snd {

struct Sound3DParam {
    /* 0x00 */ math::VEC3 position;
    /* 0x0C */ math::VEC3 velocity;
    /* 0x18 */ UNKWORD field_0x18;
    /* 0x1C */ u8 decayCurve;
    /* 0x1D */ u8 decayRatio;
    /* 0x1E */ u8 field_0x1E;
    /* 0x20 */ u32 userParam;
    /* 0x24 */ UNKWORD field_0x24;

    Sound3DParam();
};

class Sound3DManager : public detail::BasicSound::AmbientInfo::AmbientParamUpdateCallback,
                       public detail::BasicSound::AmbientInfo::AmbientArgAllocaterCallback {
public:
    typedef ut::LinkList<Sound3DListener, 0x64> ListenerList;

    Sound3DManager();

    virtual void detail_UpdateAmbientParam(const void*, u32, int, SoundAmbientParam*) override;
    virtual int detail_GetAmbientPriority(const void*, u32) override;
    virtual int detail_GetRequiredVoiceOutCount(const void*, u32) override;

    virtual void *detail_AllocAmbientArg(u32 size) override;

    virtual void detail_FreeAmbientArg(void *pArg,
                                       const detail::BasicSound *pSound) override;

    u32 GetRequiredMemSize(const SoundArchive *pArchive);
    bool Setup(const SoundArchive *pArchive, void *pBuffer, u32 size);

    const ListenerList &GetListenerList() const {
        return mListenerList;
    }

    ListenerList &GetListenerList() {
        return mListenerList;
    }

    int GetMaxPriorityReduction() const {
        return mMaxPriorityReduction;
    }
    void SetMaxPriorityReduction(int max) {
        mMaxPriorityReduction = max;
    }

    int GetBiquadFilterType() const {
        return mBiquadFilterType;
    }
    void SetBiquadFilterType(int type);

    f32 GetField0x20() const {
        return field_0x20;
    }

    void SetField0x20(f32 value) {
        field_0x20 = value;
    }

    f32 GetField0x24() const {
        return field_0x24;
    }

    void SetField0x24(f32 value) {
        field_0x24 = value;
    }

    void SetEngine(Sound3DEngine *engine);

    enum ParamDecayCurve {
        DECAY_CURVE_NONE,
        DECAY_CURVE_LOGARITHMIC,
        DECAY_CURVE_LINEAR,
    };

private:
    detail::InstancePool<Sound3DParam> mParamPool; // at 0x8
    ListenerList mListenerList;                    // at 0x0C
    Sound3DEngine *mpEngine;                       // at 0x18
    s32 mMaxPriorityReduction;                     // at 0x1C
    f32 field_0x20;                                // at 0x20
    f32 field_0x24;                                // at 0x24
    int mBiquadFilterType;                          // at 0x28
};

} // namespace snd
} // namespace nw4r

#endif