-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompressor.h
126 lines (112 loc) · 4.03 KB
/
compressor.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
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#ifndef COMPRESSOR_COMPRESSOR_H
#define COMPRESSOR_COMPRESSOR_H
////////////////////////////////////////////////////////////
/// \brief Structure holding a compressors state
////////////////////////////////////////////////////////////
typedef struct t_compressor
{
float threshold;
float slope;
float attack;
float attack_gain;
float release;
float release_gain;
float post_gain;
float envelope;
float comp_gain;
float sample_rate;
} t_compressor;
////////////////////////////////////////////////////////////
/// \brief Instanciate new compressor instance
///
/// This functions instanciate a new compressor instance.
///
/// \returns A pointer to the new instance
///
////////////////////////////////////////////////////////////
t_compressor *compressor_new();
////////////////////////////////////////////////////////////
/// \brief Free a compressor instance
///
/// This functions frees the memory acquired by a compressor
/// instance.
///
/// \param self Pointer to a compressor instance
///
////////////////////////////////////////////////////////////
void compressor_free(t_compressor *self);
////////////////////////////////////////////////////////////
/// \brief Main DSP function
///
/// This functions does the main DSP computations.
///
/// \param self Pointer to a compressor instance
/// \param in Pointer to the input buffer
/// \param out Pointer to the output buffer
/// \param comp_out Pointer to the gain output buffer
/// \param env_out Pointer to the envelope follower output buffer
/// \param samples Number of samples
///
////////////////////////////////////////////////////////////
void compressor_perform(t_compressor *self, float *in, float *out, float *comp_out, float *env_out, int samples);
////////////////////////////////////////////////////////////
/// \brief Threshold setter
///
/// This functions sets the threshold of the compressor in dB.
///
/// \param self Pointer to a compressor instance
/// \param threshold New value for the threshold
///
////////////////////////////////////////////////////////////
void compressor_set_threshold(t_compressor *self, float threshold);
////////////////////////////////////////////////////////////
/// \brief Ratio setter
///
/// This functions sets the ratio of the compressor.
///
/// \param self Pointer to a compressor instance
/// \param ratio New value for the ratio
///
////////////////////////////////////////////////////////////
void compressor_set_ratio(t_compressor *self, float ratio);
////////////////////////////////////////////////////////////
/// \brief Attack setter
///
/// This functions sets the attack of the compressor.
///
/// \param self Pointer to a compressor instance
/// \param attack New value for the attack
///
////////////////////////////////////////////////////////////
void compressor_set_attack(t_compressor *self, float attack);
////////////////////////////////////////////////////////////
/// \brief Release setter
///
/// This functions sets the release of the compressor.
///
/// \param self Pointer to a compressor instance
/// \param release New value for the release
///
////////////////////////////////////////////////////////////
void compressor_set_release(t_compressor *self, float release);
////////////////////////////////////////////////////////////
/// \brief Post gain setter
///
/// This functions sets the post gain of the compressor.
///
/// \param self Pointer to a compressor instance
/// \param post_gain New value for the post gain
///
////////////////////////////////////////////////////////////
void compressor_set_post_gain(t_compressor *self, float post_gain);
////////////////////////////////////////////////////////////
/// \brief Samplerate setter
///
/// This functions sets the samplerate of the compressor.
///
/// \param self Pointer to a compressor instance
/// \param sample_rate New value for the samplerate
///
////////////////////////////////////////////////////////////
void compressor_set_sample_rate(t_compressor *self, float sample_rate);
#endif //COMPRESSOR_COMPRESSOR_H