WIP accent

This commit is contained in:
Oleksiy
2026-09-13 22:05:54 +03:00
parent fc65622935
commit 7f57145035

View File

@ -7,7 +7,7 @@
// This code is licenced under GPL v3 or later
// todo:
// add accent handling
// debug accent handling that overloads the filter
// bring back manual triggering (test conflicts with midi)
// add overdrive
@ -121,11 +121,16 @@ byte MIDIChannel;
byte memCode = "a"; //a = MIDI Channel stored in 1023
int driveAmount;
byte notePlaying;
bool accent = false;
void MIDINoteOn(byte channel, byte note, byte velocity) {
notePlaying = note;
noteFreq = Q16n16_mtof((int) note);
if (velocity >= 127) {
accent = true;
}
if (!MIDINotePlaying || !droneSwitchVal) {
glide.setTime(2); //4 at 256, 2 at 512 control rate to avoid portamento glitches caused by 0
} else {
@ -143,6 +148,7 @@ void MIDINoteOff(byte channel, byte note, byte velocity) {
if (note == notePlaying || !droneSwitchVal) {
MIDINotePlaying = false;
digitalWrite(LED, HIGH);
accent = false;
}
}
@ -261,16 +267,16 @@ void updateControl(){
int CVInVal = mozziAnalogRead(CVIn);
//Remap the values and assign to parameters
int cutoff = kMapCutoff(knob1Val);
int resonance = kMapResonance(knob2Val);
int cutoff = accent? 100 : kMapCutoff(knob1Val);
int resonance = accent? 255 : kMapResonance(knob2Val);
int envMod = kMapEnvMod(knob3Val);
driveAmount = kMapDrive(knob4Val);
//Update Envelope Settings
int attackTime = kMapAttack(knobAVal);
int decayReleaseTime = kMapDecay(knobDRVal);
kEnvelope.setDecay(decayReleaseTime);
kEnvelope.setAttack(attackTime);
kEnvelope.setDecay(accent? 400 : decayReleaseTime);
kEnvelope.setAttack(accent? 3 : attackTime);
//Calculate makeup Gain
//makeupGain = (256L * 127) / (127 + driveAmount); // Q8 fixed-point compensation factor
@ -283,7 +289,7 @@ void updateControl(){
int env = kEnvelope.next();
gain = env;
gain = accent? env * 2 : env;
lpfr.setCutoffFreqAndResonance(constrain(cutoff + (((long)env * envMod * cutoff)>>16), 0, 255), resonance);