-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSoundEnvelope.h
More file actions
48 lines (36 loc) · 874 Bytes
/
SoundEnvelope.h
File metadata and controls
48 lines (36 loc) · 874 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
/*
* SoundEnvelope.h
*
* Created on: Apr 13, 2020
* Author: ans
*/
#ifndef SOUNDENVELOPE_H_
#define SOUNDENVELOPE_H_
#pragma once
class SoundEnvelope {
public:
struct ADRTimes {
double attackTime;
double decayTime;
double releaseTime;
ADRTimes(double a, double d, double r) : attackTime(a), decayTime(d), releaseTime(r) {}
ADRTimes() : ADRTimes(0., 0., 0.) {}
};
SoundEnvelope(const ADRTimes& adr, double startAmplitude, double sustainAmplitude);
SoundEnvelope();
SoundEnvelope(double length);
virtual ~SoundEnvelope();
void on(double time);
void off(double time);
double get(double time) const;
bool done(double time) const;
const ADRTimes& getADRTimes() const;
private:
ADRTimes adrTimes;
double amplitudeStart;
double amplitudeSustain;
double timeStarted;
double timeReleased;
bool isOn;
};
#endif /* SOUNDENVELOPE_H_ */