-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathEnvelope.h
More file actions
49 lines (40 loc) · 841 Bytes
/
Envelope.h
File metadata and controls
49 lines (40 loc) · 841 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
49
#pragma once
/*
MINI VIRTUAL ANALOG SYNTHESIZER
Copyright 2014 Kenneth D. Miller III
Envelope Generator
*/
// envelope generator configuration
class EnvelopeConfig
{
public:
bool enable;
float attack_time;
float attack_rate;
float decay_time;
float decay_rate;
float sustain_level;
float release_time;
float release_rate;
EnvelopeConfig(bool const enable, float const attack_time, float const decay_time, float const sustain_level, float const release_time);
};
// envelope generator state
class EnvelopeState
{
public:
bool gate;
enum State
{
OFF,
ATTACK,
DECAY,
SUSTAIN,
RELEASE,
COUNT
};
State state;
float amplitude;
EnvelopeState();
void Gate(EnvelopeConfig const &config, bool on);
float Update(EnvelopeConfig const &config, float const step);
};