NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
snd_EnvGenerator.h
1#ifndef NW4R_SND_ENV_GENERATOR_H
2#define NW4R_SND_ENV_GENERATOR_H
3
4/*******************************************************************************
5 * headers
6 */
7
8#include <types.h>
9
10/*******************************************************************************
11 * classes and functions
12 */
13
14namespace nw4r { namespace snd { namespace detail
15{
16 // [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x28b11
17 class EnvGenerator
18 {
19 // enums
20 public:
21 // [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x28a77
22 enum Status
23 {
24 STATUS_ATTACK,
25 STATUS_HOLD,
26 STATUS_DECAY,
27 STATUS_SUSTAIN,
28 STATUS_RELEASE,
29 };
30
31 // methods
32 public:
33 // cdtors
34 EnvGenerator();
35
36 // methods
37 void Init(f32 initDecibel);
38 void Update(int msec);
39 void Reset(f32 initDecibel);
40
41 Status GetStatus() const { return mStatus; }
42 f32 GetValue() const;
43
44 void SetStatus(Status status) { mStatus = status; }
45 void SetAttack(int attack);
46 void SetHold(int hold);
47 void SetDecay(int decay);
48 void SetSustain(int sustain);
49 void SetRelease(int release);
50
51 private:
52 f32 CalcRelease(int release);
53 s16 CalcDecibelSquare(int scale);
54
55 // static members
56 public:
57 static int const CALC_DECIBEL_SCALE_MAX;
58
59 static int const DECIBEL_SQUARE_TABLE_SIZE = 128;
60
61 static int const RELEASE_INIT = 127;
62 static int const SUSTAIN_INIT = 127;
63 static int const DECAY_INIT = 127;
64 static int const HOLD_INIT = 0;
65 static int const ATTACK_INIT = 127;
66 static f32 const volatile VOLUME_INIT;
67
68 private:
69 static s16 const DecibelSquareTable[DECIBEL_SQUARE_TABLE_SIZE];
70
71 // members
72 private:
73 Status mStatus; // size 0x04, offset 0x00
74 f32 mValue; // size 0x04, offset 0x04
75 f32 mDecay; // size 0x04, offset 0x08
76 f32 mRelease; // size 0x04, offset 0x0c
77 f32 mAttack; // size 0x04, offset 0x10
78 u8 mSustain; // size 0x01, offset 0x14
79 /* 1 byte padding */
80 u16 mHold; // size 0x02, offset 0x16
81 u16 mHoldCounter; // size 0x02, offset 0x18
82 /* 2 bytes padding */
83 }; // size 0x1c
84}}} // namespace nw4r::snd::detail
85
86#endif // NW4R_SND_ENV_GENERATOR_H