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};
|
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 kMapNote( 0, 4095, 24 * pitchSubSteps, 84 * pitchSubSteps );
|
||||||
IntMap kMapResonance( 0, 1023, 0, 255 );
|
|
||||||
IntMap kMapCutoff( 0, 1023, 26, 100 );
|
IntMap kMapCutoff( 0, 1023, 26, 100 );
|
||||||
IntMap kMapAttack( 0, 1023, 3, 100 );
|
IntMap kMapEnvMod( 0, 1023, 0, 140 );
|
||||||
IntMap kMapDecay( 0, 1023, 200, 2000 );
|
IntMap kMapResonance( 0, 1023, 0, 255 );
|
||||||
IntMap kMapEnvMod( 0, 1023, 0, 160 );
|
|
||||||
IntMap kMapDrive( 0, 1023, 0, 400 );
|
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);
|
Ead kEnvelope(MOZZI_CONTROL_RATE);
|
||||||
LowPassFilter lpfr;
|
LowPassFilter lpfr;
|
||||||
@ -124,10 +125,10 @@ int driveAmount;
|
|||||||
byte notePlaying;
|
byte notePlaying;
|
||||||
bool accent = false;
|
bool accent = false;
|
||||||
|
|
||||||
|
|
||||||
void MIDINoteOn(byte channel, byte note, byte velocity) {
|
void MIDINoteOn(byte channel, byte note, byte velocity) {
|
||||||
notePlaying = note;
|
notePlaying = note;
|
||||||
|
|
||||||
|
accent = false; //reset if the previous note was accented
|
||||||
if (velocity >= 127) {
|
if (velocity >= 127) {
|
||||||
accent = true;
|
accent = true;
|
||||||
}
|
}
|
||||||
@ -150,7 +151,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);
|
||||||
accent = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -269,11 +269,14 @@ 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 = accent? 100 : kMapCutoff(knob1Val);
|
int accentLevel = kMapAccentLevel(knobSVal);
|
||||||
int resonance = accent? 255 : kMapResonance(knob2Val);
|
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);
|
int envMod = kMapEnvMod(knob3Val);
|
||||||
driveAmount = kMapDrive(knob4Val);
|
driveAmount = kMapDrive(knob4Val);
|
||||||
|
|
||||||
|
|
||||||
//Set pitch and play notes on trigger
|
//Set pitch and play notes on trigger
|
||||||
if (MIDINoteFaded) {
|
if (MIDINoteFaded) {
|
||||||
noteFreq = mtof((float) kMapNote(CVInVal << 2) / pitchSubSteps);
|
noteFreq = mtof((float) kMapNote(CVInVal << 2) / pitchSubSteps);
|
||||||
@ -288,12 +291,13 @@ void updateControl(){
|
|||||||
|
|
||||||
//Update Envelope Settings
|
//Update Envelope Settings
|
||||||
int attackTime = kMapAttack(knobAVal);
|
int attackTime = kMapAttack(knobAVal);
|
||||||
int decayReleaseTime = kMapDecay(knobDRVal);
|
int baseDecay = kMapDecay(knobDRVal);
|
||||||
kEnvelope.setDecay(accent? 400 : decayReleaseTime);
|
int decayTime = accent? (100 + (((long)(128 - accentLevel) * (baseDecay - 100)) >> 7)) : baseDecay;
|
||||||
kEnvelope.setAttack(accent? 3 : attackTime);
|
kEnvelope.setDecay(decayTime);
|
||||||
|
kEnvelope.setAttack(accent? 1 : attackTime);
|
||||||
|
|
||||||
//Calculate makeup Gain
|
//Calculate makeup Gain
|
||||||
//makeupGain = (256L * 127) / (127 + driveAmount); // Q8 fixed-point compensation factor
|
//makeupGain = ((long)256 * 127) / (127 + driveAmount);
|
||||||
|
|
||||||
//Set Oscilator Frequency
|
//Set Oscilator Frequency
|
||||||
Q16n16 oscFreq;
|
Q16n16 oscFreq;
|
||||||
@ -308,14 +312,14 @@ void updateControl(){
|
|||||||
|
|
||||||
int env = kEnvelope.next();
|
int env = kEnvelope.next();
|
||||||
|
|
||||||
if (!MIDINotePlaying && !MIDINoteFaded && env == 0) { //threshhold might need adjustment
|
if (!MIDINotePlaying && !MIDINoteFaded && env == 0) {
|
||||||
MIDINoteFaded = true;
|
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);
|
lpfr.setCutoffFreqAndResonance(constrain(cutoff + (((long)env * envMod * cutoff)>>16), 0, 255), resonance);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioOutput updateAudio(){
|
AudioOutput updateAudio(){
|
||||||
|
|||||||
Reference in New Issue
Block a user