-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenvelope.h
More file actions
48 lines (35 loc) · 942 Bytes
/
envelope.h
File metadata and controls
48 lines (35 loc) · 942 Bytes
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
//
// envelope.h
//
#ifndef _ENVELOPE_H_
#define _ENVELOPE_H_
#include <circle/types.h>
class CEnvelope
{
public:
CEnvelope(unsigned sampleRate);
void NoteOn(void);
void NoteOff(void);
void NoteSlowKill(void);
void NoteKill(void);
void SetAttack(float ms);
void SetDecay(float ms);
void SetSustain(float level);
void SetRelease(float ms);
float Process(void);
bool IsActive(void) const { return m_state != State::Idle; }
private:
float m_sampleRate;
enum class State { Idle, Attack, Decay, Sustain, Release, Kill };
State m_state;
float m_attackTime;
float m_decayTime;
float m_sustainLevel;
float m_releaseTime;
float m_level;
float m_levelOff;
float m_phase; // 0..1 lookup position
float m_phaseInc; // advance per sample
static const float expLUT[2048];
};
#endif