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