-
Notifications
You must be signed in to change notification settings - Fork 29
/
fullDRC.ino
75 lines (67 loc) · 2.18 KB
/
fullDRC.ino
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
#include <btAudio.h>
btAudio audio = btAudio("ESP_Speaker");
String command;
void setup() {
// Streams audio data to the ESP32
audio.begin();
// Re-connects to last connected device
audio.reconnect();
// Outputs the received data to an I2S DAC, e.g. https://www.adafruit.com/product/3678
int bck = 26;
int ws = 27;
int dout = 25;
audio.I2S(bck, dout, ws);
// Opens the serial port
Serial.begin(115200);
}
float thresh=30;
float attack=0.1;
float release= 0.2;
float ratio = 10;
float kneeWidth= 1;
float gain=0;
void loop() {
delay(300);
if(Serial.available()){
command = Serial.readStringUntil('#');
if(command.equals("compress")){
Serial.println("Applying Compression");
audio.compress(thresh,attack,release,ratio,kneeWidth,gain);
}
else if(command.equals("decompress")){
Serial.println("Releasing Compression");
audio.decompress();
}
else if(command.equals("gain")){
gain =Serial.parseInt();
Serial.println((String)"Compressing with a gain of "+gain);
audio.compress(thresh,attack,release,ratio,kneeWidth,gain);
}
else if(command.equals("thresh")){
thresh =Serial.parseFloat();
Serial.println(thresh);
Serial.println((String)"Compressing with a threshold of " + thresh + "dB");
audio.compress(thresh,attack,release,ratio,kneeWidth,gain);
}
else if(command.equals("attack")){
attack =Serial.parseFloat();
Serial.println((String)"Compressing with an attack time of " + attack*1000 + "ms");
audio.compress(thresh,attack,release,ratio,kneeWidth,gain);
}
else if(command.equals("release")){
release =Serial.parseFloat();
Serial.println((String)"Compressing with an release time of " + release*1000 + "ms");
audio.compress(thresh,attack,release,ratio,kneeWidth,gain);
}
else if(command.equals("ratio")){
ratio =Serial.parseFloat();
Serial.println((String)"Compressing with a Ratio of " + ratio);
audio.compress(thresh,attack,release,ratio,kneeWidth,gain);
}
else if(command.equals("width")){
kneeWidth =Serial.parseInt();
Serial.println((String)"Compressing with a knee width of " + kneeWidth + "dB");
audio.compress(thresh,attack,release,ratio,kneeWidth,gain);
}
}
}