add velocity effects
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
|
|
||||||
#include "Voice.h"
|
#include "Voice.h"
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
Voice::Voice(SmoothedParam* params) : params_(params) {
|
Voice::Voice(SmoothedParam* params) : params_(params) {
|
||||||
|
|
||||||
@@ -78,7 +79,11 @@ float Voice::process(float* params, bool& scopeTrigger) {
|
|||||||
float pitchOffset = 1.0f;
|
float pitchOffset = 1.0f;
|
||||||
float phaseInc = pitchOffset * 2.0f * M_PI * frequency_ / static_cast<float>(sampleRate_);
|
float phaseInc = pitchOffset * 2.0f * M_PI * frequency_ / static_cast<float>(sampleRate_);
|
||||||
|
|
||||||
float gain = gainEnv * getParam(ParamId::Osc1VolumeDepth);
|
// calculate the change that the velocity will make
|
||||||
|
// TODO: make velocity parameters configurable, probably also for filterCutoff and filterResonance
|
||||||
|
float velocityGain = std::lerp(velocityCenter, velocity_, velocitySensitivity);
|
||||||
|
|
||||||
|
float gain = gainEnv * getParam(ParamId::Osc1VolumeDepth) * velocityGain;
|
||||||
float sampleOut = 0.0f;
|
float sampleOut = 0.0f;
|
||||||
|
|
||||||
// sample generation
|
// sample generation
|
||||||
@@ -108,9 +113,10 @@ float Voice::process(float* params, bool& scopeTrigger) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// filter sample
|
// filter sample
|
||||||
float cutoffFreq = cutoffEnv * pow(2.0f, getParam(ParamId::FilterCutoffDepth)) * frequency_;
|
float cutoffFreq = cutoffEnv * pow(2.0f, getParam(ParamId::FilterCutoffDepth)) * frequency_ * velocityGain;
|
||||||
filter1_.setParams(Filter::Type::BiquadLowpass, cutoffFreq, resonanceEnv * getParam(ParamId::FilterResonanceDepth));
|
float resonance = resonanceEnv * getParam(ParamId::FilterResonanceDepth) * velocityGain;
|
||||||
filter2_.setParams(Filter::Type::BiquadLowpass, cutoffFreq, resonanceEnv * getParam(ParamId::FilterResonanceDepth));
|
filter1_.setParams(Filter::Type::BiquadLowpass, cutoffFreq, resonance);
|
||||||
|
filter2_.setParams(Filter::Type::BiquadLowpass, cutoffFreq, resonance);
|
||||||
sampleOut = filter1_.biquadProcess(sampleOut);
|
sampleOut = filter1_.biquadProcess(sampleOut);
|
||||||
sampleOut = filter2_.biquadProcess(sampleOut);
|
sampleOut = filter2_.biquadProcess(sampleOut);
|
||||||
|
|
||||||
|
|||||||
@@ -71,4 +71,8 @@ private:
|
|||||||
// paramstore pointer
|
// paramstore pointer
|
||||||
SmoothedParam* params_;
|
SmoothedParam* params_;
|
||||||
|
|
||||||
|
// TODO: add a parameter in the paramstore for this
|
||||||
|
float velocitySensitivity = 0.7f;
|
||||||
|
float velocityCenter = 2.0f;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user