fixed dropped notes on portamento bug
This commit is contained in:
@ -7,9 +7,9 @@
|
|||||||
// This code is licenced under GPL v3 or later
|
// This code is licenced under GPL v3 or later
|
||||||
|
|
||||||
// todo:
|
// todo:
|
||||||
// debug glide (slides down from lower notes?)
|
|
||||||
// add accent handling
|
// add accent handling
|
||||||
// bring back manual triggering (test conflicts with midi)
|
// bring back manual triggering (test conflicts with midi)
|
||||||
|
// add overdrive
|
||||||
|
|
||||||
#include <Mozzi.h>
|
#include <Mozzi.h>
|
||||||
#include <MIDI.h>
|
#include <MIDI.h>
|
||||||
@ -122,20 +122,18 @@ byte memCode = "a"; //a = MIDI Channel stored in 1023
|
|||||||
int driveAmount;
|
int driveAmount;
|
||||||
byte notePlaying;
|
byte notePlaying;
|
||||||
|
|
||||||
// long debugMaxSignal = 0;
|
|
||||||
// long debugMinSignal = 0;
|
|
||||||
|
|
||||||
void MIDINoteOn(byte channel, byte note, byte velocity) {
|
void MIDINoteOn(byte channel, byte note, byte velocity) {
|
||||||
notePlaying = note;
|
notePlaying = note;
|
||||||
noteFreq = Q16n16_mtof((int) note);
|
noteFreq = Q16n16_mtof((int) note);
|
||||||
|
|
||||||
if (!MIDINotePlaying || !droneSwitchVal) {
|
if (!MIDINotePlaying || !droneSwitchVal) {
|
||||||
glide.setTime(0);
|
glide.setTime(2); //4 at 256, 2 at 512 control rate to avoid portamento glitches caused by 0
|
||||||
glide.start(note);
|
|
||||||
kEnvelope.start();
|
|
||||||
} else {
|
} else {
|
||||||
glide.setTime(GLIDE_TIME);
|
glide.setTime(GLIDE_TIME);
|
||||||
glide.start(note);
|
}
|
||||||
|
glide.start(note);
|
||||||
|
if (!MIDINotePlaying || !droneSwitchVal) {
|
||||||
|
kEnvelope.start();
|
||||||
}
|
}
|
||||||
MIDINotePlaying = true;
|
MIDINotePlaying = true;
|
||||||
digitalWrite(LED, LOW);
|
digitalWrite(LED, LOW);
|
||||||
@ -145,7 +143,6 @@ void MIDINoteOff(byte channel, byte note, byte velocity) {
|
|||||||
if (note == notePlaying || !droneSwitchVal) {
|
if (note == notePlaying || !droneSwitchVal) {
|
||||||
MIDINotePlaying = false;
|
MIDINotePlaying = false;
|
||||||
digitalWrite(LED, HIGH);
|
digitalWrite(LED, HIGH);
|
||||||
glide.setTime(0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -269,18 +266,6 @@ void updateControl(){
|
|||||||
int envMod = kMapEnvMod(knob3Val);
|
int envMod = kMapEnvMod(knob3Val);
|
||||||
driveAmount = kMapDrive(knob4Val);
|
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
|
//Update Envelope Settings
|
||||||
int attackTime = kMapAttack(knobAVal);
|
int attackTime = kMapAttack(knobAVal);
|
||||||
int decayReleaseTime = kMapDecay(knobDRVal);
|
int decayReleaseTime = kMapDecay(knobDRVal);
|
||||||
@ -298,21 +283,9 @@ void updateControl(){
|
|||||||
|
|
||||||
int env = kEnvelope.next();
|
int env = kEnvelope.next();
|
||||||
|
|
||||||
//if(!droneSwitchVal) {
|
gain = env;
|
||||||
gain = env;
|
|
||||||
//} else {
|
|
||||||
// gain = 255;
|
|
||||||
//}
|
|
||||||
lpfr.setCutoffFreqAndResonance(constrain(cutoff + (((long)env * envMod * cutoff)>>16), 0, 255), resonance);
|
|
||||||
|
|
||||||
// static int debugCounter = 0;
|
lpfr.setCutoffFreqAndResonance(constrain(cutoff + (((long)env * envMod * cutoff)>>16), 0, 255), resonance);
|
||||||
// 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;
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -328,9 +301,6 @@ AudioOutput updateAudio(){
|
|||||||
//signal = softClip((signal * (127 + driveAmount)) >> 9); //overdrive
|
//signal = softClip((signal * (127 + driveAmount)) >> 9); //overdrive
|
||||||
//signal = (signal * makeupGain) >> 7; //makeup gain compensation
|
//signal = (signal * makeupGain) >> 7; //makeup gain compensation
|
||||||
|
|
||||||
// if (signal > debugMaxSignal) debugMaxSignal = signal;
|
|
||||||
// if (signal < debugMinSignal) debugMinSignal = signal;
|
|
||||||
|
|
||||||
return MonoOutput::fromNBit(17, signal).clip();
|
return MonoOutput::fromNBit(17, signal).clip();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
//Settings
|
//Settings
|
||||||
const int pitchSubSteps = 16; //set how many steps are there between semitones. set to 1 to quantize to semitones
|
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 MOZZI_CONTROL_RATE 512
|
||||||
#define GLIDE_TIME 150
|
#define GLIDE_TIME 60
|
||||||
|
|
||||||
//Hardware Definitions
|
//Hardware Definitions
|
||||||
#define Knob1 A6 //Intensity
|
#define Knob1 A6 //Intensity
|
||||||
|
|||||||
Reference in New Issue
Block a user