Fixed menu choices
This commit is contained in:
parent
e780df7d22
commit
87b5441fc8
|
|
@ -20,6 +20,7 @@ float VOL = 0.5f;
|
||||||
float ABS_VOL = 0.5f;
|
float ABS_VOL = 0.5f;
|
||||||
//float decay = 1.0f;
|
//float decay = 1.0f;
|
||||||
float decay = 0.99998f;
|
float decay = 0.99998f;
|
||||||
|
float decay_off = 0.9995f;
|
||||||
Adafruit_SSD1306 display(OLED_W, OLED_H, &Wire);
|
Adafruit_SSD1306 display(OLED_W, OLED_H, &Wire);
|
||||||
// ----- Menu Functions
|
// ----- Menu Functions
|
||||||
int sound = 0; //Default voice
|
int sound = 0; //Default voice
|
||||||
|
|
@ -28,7 +29,7 @@ int sound_count = sizeof(sounds) / sizeof(sounds[0]);
|
||||||
|
|
||||||
// Modes
|
// Modes
|
||||||
int mode = 0;
|
int mode = 0;
|
||||||
String mode_names[7] = { "Vol", "Sou", "Oct", "Env", "Arp", "ArpΔ", "Arp"};
|
String mode_names[7] = { "Volume", "Sound", "Octave", "Envel.", "ArpTyp", "ArpSpd", "ArpDir"};
|
||||||
int mode_count = sizeof(mode_names) / sizeof(mode_names[0]);
|
int mode_count = sizeof(mode_names) / sizeof(mode_names[0]);
|
||||||
|
|
||||||
// Octave
|
// Octave
|
||||||
|
|
@ -90,6 +91,7 @@ struct Voice {
|
||||||
float startFreq = 0;
|
float startFreq = 0;
|
||||||
float phase1 = 0;
|
float phase1 = 0;
|
||||||
float phase2 = 0;
|
float phase2 = 0;
|
||||||
|
float decay = decay;
|
||||||
float env = 0;
|
float env = 0;
|
||||||
float amp = 0;
|
float amp = 0;
|
||||||
long arp_time = 0;
|
long arp_time = 0;
|
||||||
|
|
@ -109,6 +111,7 @@ void noteOn(float freq) {
|
||||||
v.arp_position = 0;
|
v.arp_position = 0;
|
||||||
v.phase1 = 0.5f;
|
v.phase1 = 0.5f;
|
||||||
v.phase2 = 0.5f;
|
v.phase2 = 0.5f;
|
||||||
|
v.decay = decay;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -117,7 +120,8 @@ void noteOn(float freq) {
|
||||||
void noteOff(float freq) {
|
void noteOff(float freq) {
|
||||||
for (auto &v : voices) {
|
for (auto &v : voices) {
|
||||||
if (v.active && fabs(v.startFreq - freq) < 0.01f) {
|
if (v.active && fabs(v.startFreq - freq) < 0.01f) {
|
||||||
v.active = false;
|
//v.active = false;
|
||||||
|
v.decay = decay_off;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -254,7 +258,7 @@ private:
|
||||||
if (v.phase2 >= 1) v.phase2 -= 1;
|
if (v.phase2 >= 1) v.phase2 -= 1;
|
||||||
|
|
||||||
v.amp = v.env;
|
v.amp = v.env;
|
||||||
v.env *= decay;
|
v.env *= v.decay;
|
||||||
if (v.env < 0.0005f) v.active = false;
|
if (v.env < 0.0005f) v.active = false;
|
||||||
|
|
||||||
mix += osc * v.amp;
|
mix += osc * v.amp;
|
||||||
|
|
@ -461,11 +465,11 @@ void drawInfo() {
|
||||||
|
|
||||||
// Show current menu mode
|
// Show current menu mode
|
||||||
display.setCursor(64, 6);
|
display.setCursor(64, 6);
|
||||||
display.print("Set:");
|
display.print("Set:" + mode_names[mode]);
|
||||||
display.setCursor(100, 6);
|
|
||||||
display.print(mode_names[mode]);
|
|
||||||
display.setCursor(90, 18);
|
display.setCursor(90, 18);
|
||||||
display.print("Oct:" + String(octave));
|
display.print("Oct:" + String(octave));
|
||||||
|
display.setCursor(40, 18);
|
||||||
|
display.print("Arp: "+ String((arpeggio ? "On" : "Off")));
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateOLED(uint16_t keys) {
|
void updateOLED(uint16_t keys) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue