back to resonant filter (svf doesn't fit the character). reduced gain before filter fixes the overflow issue
This commit is contained in:
@ -7,6 +7,7 @@
|
||||
// This code is licenced under GPL v3 or later
|
||||
|
||||
// todo:
|
||||
// debug accent handling that overloads the filter, also accent can be too short or too long if it's relying on midi note
|
||||
// add overdrive
|
||||
// frequency from CV (noteFreq) could be Q16n16 for consistency
|
||||
|
||||
@ -14,8 +15,7 @@
|
||||
#include <MIDI.h>
|
||||
#include <Oscil.h>
|
||||
#include <MetaOscil.h>
|
||||
//#include <ResonantFilter.h>
|
||||
#include <StateVariable.h>
|
||||
#include <ResonantFilter.h>
|
||||
#include <Ead.h>
|
||||
#include <Portamento.h>
|
||||
#include <mozzi_midi.h>
|
||||
@ -99,20 +99,16 @@ 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 kMapCutoff( 0, 1023, 26, 100 ); //for lpf
|
||||
//IntMap kMapResonance( 0, 1023, 0, 255 );
|
||||
IntMap kMapCutoff( 0, 1023, 400, 3600 );
|
||||
IntMap kMapResonance( 0, 1023, 200, 64 );
|
||||
IntMap kMapCutoff( 0, 1023, 26, 100 );
|
||||
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 lpf;
|
||||
StateVariable <LOWPASS> svf;
|
||||
|
||||
LowPassFilter lpfr;
|
||||
Portamento <MOZZI_CONTROL_RATE> kGlide;
|
||||
|
||||
//Global variables
|
||||
@ -275,11 +271,8 @@ void updateControl(){
|
||||
//Remap the values and assign to parameters
|
||||
int accentLevel = kMapAccentLevel(knobSVal);
|
||||
int baseCutoff = kMapCutoff(knob1Val);
|
||||
//int cutoff = accent? (baseCutoff + (((long)accentLevel * (100 - baseCutoff)) >> 7)) : baseCutoff; //lpf version
|
||||
int cutoff = accent? (baseCutoff + (((long)accentLevel * (3600 - baseCutoff)) >> 7)) : baseCutoff; //svf version
|
||||
//int resonance = accent? (255 - (((long)(128 - accentLevel) * (255 - kMapResonance(knob2Val))) >> 7)) : kMapResonance(knob2Val); //lpf version
|
||||
int baseResonance = kMapResonance(knob2Val);
|
||||
int resonance = accent? (baseResonance - (((long)accentLevel * (baseResonance - 64)) >> 7)) : baseResonance;
|
||||
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);
|
||||
|
||||
@ -326,9 +319,7 @@ void updateControl(){
|
||||
|
||||
gain = accent? constrain(env + (((long)env * accentLevel) >> 7), 0, 255) : env; //needs finetuning
|
||||
|
||||
//lpf.setCutoffFreqAndResonance(constrain(cutoff + (((long)env * envMod * cutoff)>>16), 0, 255), resonance);
|
||||
svf.setCentreFreq(cutoff + (((long)env * envMod * cutoff)>>16));
|
||||
svf.setResonance(resonance);
|
||||
lpfr.setCutoffFreqAndResonance(constrain(cutoff + (((long)env * envMod * cutoff)>>16), 0, 255), resonance);
|
||||
}
|
||||
|
||||
AudioOutput updateAudio(){
|
||||
@ -338,9 +329,9 @@ AudioOutput updateAudio(){
|
||||
} else {
|
||||
signal = aSaw.next();
|
||||
}
|
||||
//signal = lpf.next(signal); //filter
|
||||
signal = svf.next(signal);
|
||||
signal = (signal * gain); //envelope
|
||||
signal = signal >> 2; //lowering the gain before filter to avoid filter overflow bug
|
||||
signal = lpfr.next(signal); //filter
|
||||
signal = (signal * gain) << 2; //envelope
|
||||
//signal = softClip((signal * (127 + driveAmount)) >> 9); //overdrive
|
||||
//signal = (signal * makeupGain) >> 7; //makeup gain compensation
|
||||
|
||||
|
||||
Reference in New Issue
Block a user