fixed dropped notes on portamento bug

This commit is contained in:
Oleksiy
2026-09-13 20:53:36 +03:00
parent 245982c575
commit fc65622935
2 changed files with 10 additions and 40 deletions

View File

@ -7,9 +7,9 @@
// This code is licenced under GPL v3 or later
// todo:
// debug glide (slides down from lower notes?)
// add accent handling
// bring back manual triggering (test conflicts with midi)
// add overdrive
#include <Mozzi.h>
#include <MIDI.h>
@ -122,20 +122,18 @@ byte memCode = "a"; //a = MIDI Channel stored in 1023
int driveAmount;
byte notePlaying;
// long debugMaxSignal = 0;
// long debugMinSignal = 0;
void MIDINoteOn(byte channel, byte note, byte velocity) {
notePlaying = note;
noteFreq = Q16n16_mtof((int) note);
if (!MIDINotePlaying || !droneSwitchVal) {
glide.setTime(0);
glide.start(note);
kEnvelope.start();
glide.setTime(2); //4 at 256, 2 at 512 control rate to avoid portamento glitches caused by 0
} else {
glide.setTime(GLIDE_TIME);
glide.start(note);
}
glide.start(note);
if (!MIDINotePlaying || !droneSwitchVal) {
kEnvelope.start();
}
MIDINotePlaying = true;
digitalWrite(LED, LOW);
@ -145,7 +143,6 @@ void MIDINoteOff(byte channel, byte note, byte velocity) {
if (note == notePlaying || !droneSwitchVal) {
MIDINotePlaying = false;
digitalWrite(LED, HIGH);
glide.setTime(0);
}
}
@ -269,18 +266,6 @@ void updateControl(){
int envMod = kMapEnvMod(knob3Val);
driveAmount = kMapDrive(knob4Val);
//Set pitch and play notes on trigger
// if (!MIDINotePlaying) {
// noteFreq = mtof((float) kMapNote(CVInVal << 2) / pitchSubSteps);
// digitalWrite(LED, !gateInVal);
// if (gateInVal && !gateIsHigh) {
// gateIsHigh = true;
// kEnvelope.start();
// } else if (!gateInVal && gateIsHigh) {
// gateIsHigh = false;
// }
// }
//Update Envelope Settings
int attackTime = kMapAttack(knobAVal);
int decayReleaseTime = kMapDecay(knobDRVal);
@ -298,21 +283,9 @@ void updateControl(){
int env = kEnvelope.next();
//if(!droneSwitchVal) {
gain = env;
//} else {
// gain = 255;
//}
lpfr.setCutoffFreqAndResonance(constrain(cutoff + (((long)env * envMod * cutoff)>>16), 0, 255), resonance);
gain = env;
// static int debugCounter = 0;
// if (++debugCounter >= 100) { // adjust to taste - print every ~100 control cycles
// Serial.print("min: "); Serial.print(debugMinSignal);
// Serial.print(" max: "); Serial.println(debugMaxSignal);
// debugMaxSignal = 0;
// debugMinSignal = 0;
// debugCounter = 0;
// }
lpfr.setCutoffFreqAndResonance(constrain(cutoff + (((long)env * envMod * cutoff)>>16), 0, 255), resonance);
}
@ -328,9 +301,6 @@ AudioOutput updateAudio(){
//signal = softClip((signal * (127 + driveAmount)) >> 9); //overdrive
//signal = (signal * makeupGain) >> 7; //makeup gain compensation
// if (signal > debugMaxSignal) debugMaxSignal = signal;
// if (signal < debugMinSignal) debugMinSignal = signal;
return MonoOutput::fromNBit(17, signal).clip();
}