Compare commits
2 Commits
83921644dc
...
86535fa998
| Author | SHA1 | Date | |
|---|---|---|---|
| 86535fa998 | |||
| 92faf5c81e |
@ -8,15 +8,15 @@
|
||||
|
||||
// todo:
|
||||
// add glide handling
|
||||
// make a glide on/off swithc instead of drone, both for MIDI and CV (sample pitch on gate)
|
||||
// add accent handling
|
||||
// test StateVariable vs Resonant filters
|
||||
// exponential envelope https://sensorium.github.io/Mozzi/doc/html/07_8_envelopes_2_ead__envelope_2_ead__envelope_8ino-example.html
|
||||
|
||||
#include <Mozzi.h>
|
||||
#include <MIDI.h>
|
||||
#include <Oscil.h>
|
||||
#include <MetaOscil.h>
|
||||
#include <StateVariable.h>
|
||||
//#include <StateVariable.h>
|
||||
#include <ResonantFilter.h>
|
||||
//#include <ADSR.h>
|
||||
#include <Ead.h>
|
||||
#include <mozzi_midi.h>
|
||||
@ -100,17 +100,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 kMapLFOSpeed( 0, 1023, 500, 20000 );
|
||||
IntMap kMapFreqMod( 0, 1023, 0, 1023 );
|
||||
IntMap kMapResonance( 0, 1023, 200, 1 );
|
||||
IntMap kMapCutoff( 0, 1023, 1, 20 );
|
||||
IntMap kMapResonance( 0, 1023, 0, 255 );
|
||||
IntMap kMapCutoff( 0, 1023, 20, 127 );
|
||||
IntMap kMapAttack( 0, 1023, 3, 100 );
|
||||
IntMap kMapDecayRelease( 0, 1023, 200, 2000 );
|
||||
IntMap kMapSustain( 0, 1023, 0, 255 );
|
||||
IntMap kMapDecay( 0, 1023, 200, 2000 );
|
||||
IntMap kMapEnvMod( 0, 1023, 0, 255 );
|
||||
|
||||
//ADSR <MOZZI_CONTROL_RATE, MOZZI_CONTROL_RATE> envelope;
|
||||
Ead kEnvelope(MOZZI_CONTROL_RATE);
|
||||
StateVariable <LOWPASS> lpf;
|
||||
//StateVariable <LOWPASS> lpf;
|
||||
LowPassFilter lpfr;
|
||||
|
||||
|
||||
//Global variables
|
||||
@ -132,6 +131,7 @@ void MIDINoteOn(byte channel, byte note, byte velocity) {
|
||||
|
||||
void MIDINoteOff(byte channel, byte note, byte velocity) {
|
||||
//envelope.noteOff();
|
||||
MIDINotePlaying = false;
|
||||
digitalWrite(LED, HIGH);
|
||||
}
|
||||
|
||||
@ -253,8 +253,9 @@ void updateControl(){
|
||||
int CVInVal = mozziAnalogRead(CVIn);
|
||||
|
||||
//Remap the values and assign to parameter
|
||||
int resonance = kMapResonance(knob3Val);
|
||||
int cutoff = kMapCutoff(knob4Val);
|
||||
int cutoff = kMapCutoff(knob1Val);
|
||||
int resonance = kMapResonance(knob2Val);
|
||||
int envMod = kMapEnvMod(knob3Val);
|
||||
|
||||
//Set pitch and play notes on trigger
|
||||
if (!MIDINotePlaying) {
|
||||
@ -273,13 +274,12 @@ void updateControl(){
|
||||
}*/
|
||||
|
||||
//Update Filter settings
|
||||
lpf.setResonance(resonance);
|
||||
//lpf.setCentreFreq(cutoff);
|
||||
//lpf.setResonance(resonance);
|
||||
|
||||
//Update Envelope Settings
|
||||
int attackTime = kMapAttack(knobAVal);
|
||||
int decayReleaseTime = kMapDecayRelease(knobDRVal);
|
||||
int sustainLevel = kMapSustain(knobSVal);
|
||||
int decayReleaseTime = kMapDecay(knobDRVal);
|
||||
//int sustainLevel = kMapSustain(knobSVal);
|
||||
kEnvelope.setDecay(decayReleaseTime);
|
||||
kEnvelope.setAttack(attackTime);
|
||||
//envelope.setDecayLevel(sustainLevel);
|
||||
@ -300,20 +300,21 @@ void updateControl(){
|
||||
} else {
|
||||
gain = 255;
|
||||
}
|
||||
lpf.setCentreFreq(env * cutoff);
|
||||
//lpf.setCentreFreq(constrain(cutoff + (((long) env * envMod) >> 8), 20, 4096));
|
||||
lpfr.setCutoffFreqAndResonance(constrain(cutoff + (((long)env * envMod * cutoff)>>16), 0, 255), resonance);
|
||||
|
||||
}
|
||||
|
||||
AudioOutput updateAudio(){
|
||||
long signal;
|
||||
if(envSwitchVal) {
|
||||
signal = aSquare.next() * 0.5;
|
||||
signal = (aSquare.next() * 3) >> 2;// 0.75 gain to ~ match saw level
|
||||
} else {
|
||||
signal = aSaw.next() * 1;
|
||||
signal = aSaw.next();
|
||||
}
|
||||
signal = lpf.next(signal); //filter
|
||||
signal = lpfr.next(signal); //filter
|
||||
signal = (signal * gain); //envelope
|
||||
signal = softClip((signal * (127 + driveAmount)) >> 6); //overdrive
|
||||
//signal = softClip((signal * (127 + driveAmount)) >> 6); //overdrive
|
||||
return MonoOutput::fromNBit(17, signal).clip();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user