-
Notifications
You must be signed in to change notification settings - Fork 0
/
comp.c
110 lines (89 loc) · 3.05 KB
/
comp.c
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/*
* comp.c
*
* Created on: Dec 20, 2011
* Author: ParallelsWin7
*/
#include "comp.h"
//////////////////////////////////////////////////////////////////////////
//////////// COMP CONSTRUCTORS ///////////////
//////////////////////////////////////////////////////////////////////////
//Setup a compressor based on the input parameters
void comp_ctor(Comp *comp, Enable_enum enable, float threshold, float ratio,
float attack, float release, float gain) {
comp->enable = enable;
comp->threshold = threshold;
comp->ratio = ratio;
comp->attack = attack;
comp->release = release;
comp->gain = gain;
}
///////////////////////////////////////////////////////////////////////////
//////////// COMP GETTERS //////////////
///////////////////////////////////////////////////////////////////////////
//Returns 1 if enabled, 0 if disabled
uint8_t comp_is_enabled(Comp *comp) {
return (int) comp->enable;
}
//Returns the threshold of the compressor
float comp_get_threshold(Comp *comp) {
return comp->threshold;
}
//Returns the ratio of the compressor (Always greater than 1)
float comp_get_ratio(Comp *comp) {
return comp->ratio;
}
//Returns attack time in milliseconds (Always greater than 0)
float comp_get_attack(Comp *comp) {
return comp->attack;
}
//Returns release time in milliseconds (Always greater than 0)
float comp_get_release(Comp *comp) {
return comp->release;
}
//Returns make-up gain
float comp_get_gain(Comp *comp) {
return comp->gain;
}
///////////////////////////////////////////////////////////////////////////
//////////// COMP SETTERS //////////////
///////////////////////////////////////////////////////////////////////////
//set comp to enable status
void comp_enable(Comp *comp) {
comp->enable = ENABLED;
}
//set comp to disabled status
void comp_disable(Comp *comp) {
comp->enable = DISABLED;
}
//set comp threshold
void comp_set_threshold(Comp *comp, float value) {
comp->threshold = value;
}
//set comp ratio
void comp_set_ratio(Comp *comp, float value) {
comp->ratio = value;
}
//set comp attack
void comp_set_attack(Comp *comp, float value) {
comp->attack = value;
}
//set comp release
void comp_set_release(Comp *comp, float value) {
comp->release = value;
}
//set comp gain
void comp_set_gain(Comp *comp, float value) {
comp->gain = value;
}
///////////////////////////////////////////////////////////////////////////
//////////// COMP INSPECTION TOOLS //////////////
///////////////////////////////////////////////////////////////////////////
void comp_inspect(Comp *comp) {
printf("enable: %d\n", comp->enable);
printf("threshold: %lf\n", comp->threshold);
printf("ratio: %lf\n", comp->ratio);
printf("attack: %lf\n", comp->attack);
printf("release: %lf\n", comp->release);
printf("gain: %lf\n\n", comp->gain);
}