Adjusted Accent and Accent Level hendling
This commit is contained in:
@ -99,12 +99,13 @@ Oscil <SAW_MAX_8192_AT_16384_512_NUM_CELLS, MOZZI_AUDIO_RATE> aSaw8192(SAW_MAX_8
|
||||
MetaOscil<SAW_MAX_138_AT_16384_512_NUM_CELLS, MOZZI_AUDIO_RATE, 16> aSaw {&aSaw138, &aSaw154, &aSaw182, &aSaw240, &aSaw292, &aSaw341, &aSaw390, &aSaw431, &aSaw512, &aSaw630, &aSaw744, &aSaw1170, &aSaw1638, &aSaw2730, &aSaw4096, &aSaw8192};
|
||||
|
||||
IntMap kMapNote( 0, 4095, 24 * pitchSubSteps, 84 * pitchSubSteps );
|
||||
IntMap kMapResonance( 0, 1023, 0, 255 );
|
||||
IntMap kMapCutoff( 0, 1023, 26, 100 );
|
||||
IntMap kMapAttack( 0, 1023, 3, 100 );
|
||||
IntMap kMapDecay( 0, 1023, 200, 2000 );
|
||||
IntMap kMapEnvMod( 0, 1023, 0, 160 );
|
||||
IntMap kMapEnvMod( 0, 1023, 0, 140 );
|
||||
IntMap kMapResonance( 0, 1023, 0, 255 );
|
||||
IntMap kMapDrive( 0, 1023, 0, 400 );
|
||||
IntMap kMapAttack( 0, 1023, 1, 100 );
|
||||
IntMap kMapDecay( 0, 1023, 100, 1500 );
|
||||
IntMap kMapAccentLevel( 0, 1023, 0, 128 );
|
||||
|
||||
Ead kEnvelope(MOZZI_CONTROL_RATE);
|
||||
LowPassFilter lpfr;
|
||||
@ -124,10 +125,10 @@ int driveAmount;
|
||||
byte notePlaying;
|
||||
bool accent = false;
|
||||
|
||||
|
||||
void MIDINoteOn(byte channel, byte note, byte velocity) {
|
||||
notePlaying = note;
|
||||
|
||||
accent = false; //reset if the previous note was accented
|
||||
if (velocity >= 127) {
|
||||
accent = true;
|
||||
}
|
||||
@ -150,7 +151,6 @@ void MIDINoteOff(byte channel, byte note, byte velocity) {
|
||||
if (note == notePlaying || !droneSwitchVal) {
|
||||
MIDINotePlaying = false;
|
||||
digitalWrite(LED, HIGH);
|
||||
accent = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -269,11 +269,14 @@ void updateControl(){
|
||||
int CVInVal = mozziAnalogRead(CVIn);
|
||||
|
||||
//Remap the values and assign to parameters
|
||||
int cutoff = accent? 100 : kMapCutoff(knob1Val);
|
||||
int resonance = accent? 255 : kMapResonance(knob2Val);
|
||||
int accentLevel = kMapAccentLevel(knobSVal);
|
||||
int baseCutoff = kMapCutoff(knob1Val);
|
||||
int cutoff = accent? (baseCutoff + (((long)accentLevel * (100 - baseCutoff)) >> 7)) : baseCutoff;
|
||||
int resonance = accent? (255 - (((long)(128 - accentLevel) * (255 - kMapResonance(knob2Val))) >> 7)) : kMapResonance(knob2Val);
|
||||
int envMod = kMapEnvMod(knob3Val);
|
||||
driveAmount = kMapDrive(knob4Val);
|
||||
|
||||
|
||||
//Set pitch and play notes on trigger
|
||||
if (MIDINoteFaded) {
|
||||
noteFreq = mtof((float) kMapNote(CVInVal << 2) / pitchSubSteps);
|
||||
@ -288,12 +291,13 @@ void updateControl(){
|
||||
|
||||
//Update Envelope Settings
|
||||
int attackTime = kMapAttack(knobAVal);
|
||||
int decayReleaseTime = kMapDecay(knobDRVal);
|
||||
kEnvelope.setDecay(accent? 400 : decayReleaseTime);
|
||||
kEnvelope.setAttack(accent? 3 : attackTime);
|
||||
int baseDecay = kMapDecay(knobDRVal);
|
||||
int decayTime = accent? (100 + (((long)(128 - accentLevel) * (baseDecay - 100)) >> 7)) : baseDecay;
|
||||
kEnvelope.setDecay(decayTime);
|
||||
kEnvelope.setAttack(accent? 1 : attackTime);
|
||||
|
||||
//Calculate makeup Gain
|
||||
//makeupGain = (256L * 127) / (127 + driveAmount); // Q8 fixed-point compensation factor
|
||||
//makeupGain = ((long)256 * 127) / (127 + driveAmount);
|
||||
|
||||
//Set Oscilator Frequency
|
||||
Q16n16 oscFreq;
|
||||
@ -308,14 +312,14 @@ void updateControl(){
|
||||
|
||||
int env = kEnvelope.next();
|
||||
|
||||
if (!MIDINotePlaying && !MIDINoteFaded && env == 0) { //threshhold might need adjustment
|
||||
if (!MIDINotePlaying && !MIDINoteFaded && env == 0) {
|
||||
MIDINoteFaded = true;
|
||||
accent = false;
|
||||
}
|
||||
|
||||
gain = accent? env * 2 : env;
|
||||
gain = accent? constrain(env + (((long)env * accentLevel) >> 7), 0, 255) : env; //needs finetuning
|
||||
|
||||
lpfr.setCutoffFreqAndResonance(constrain(cutoff + (((long)env * envMod * cutoff)>>16), 0, 255), resonance);
|
||||
|
||||
}
|
||||
|
||||
AudioOutput updateAudio(){
|
||||
|
||||
Reference in New Issue
Block a user