-
Notifications
You must be signed in to change notification settings - Fork 0
/
Ramp.h
50 lines (36 loc) · 950 Bytes
/
Ramp.h
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
/*
____ _____ _ _
| __ )| ____| | / \
| _ \| _| | | / _ \
| |_) | |___| |___ / ___ \
|____/|_____|_____/_/ \_\
http://bela.io
C++ Real-Time Audio Programming with Bela - Lecture 14: ADSR
*/
// Ramp.h: header file for defining a second order resonant kow pass filter
#pragma once
class Ramp {
public:
// Constructor
Ramp();
// Constructor specifying a sample rate
Ramp(float sampleRate);
// Set the sample rate, used for all calculations
void setSampleRate(float rate);
// Jump to a value
void setValue(float value);
// Ramp to a value over a period of time
void rampTo(float value, float time);
// Generate and return the next ramp output
float process();
// Return whether the ramp is finished
bool finished();
// Destructor
~Ramp();
private:
// State variables, not accessible to the outside world
float sampleRate_;
float currentValue_;
float increment_;
int counter_;
};