fixed dropped notes on portamento bug
This commit is contained in:
@ -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();
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
//Settings
|
||||
const int pitchSubSteps = 16; //set how many steps are there between semitones. set to 1 to quantize to semitones
|
||||
#define MOZZI_CONTROL_RATE 256
|
||||
#define GLIDE_TIME 150
|
||||
#define MOZZI_CONTROL_RATE 512
|
||||
#define GLIDE_TIME 60
|
||||
|
||||
//Hardware Definitions
|
||||
#define Knob1 A6 //Intensity
|
||||
|
||||
Reference in New Issue
Block a user