@@ -121,7 +121,7 @@ struct Delay : Module { | |||||
// Scale time knob to 1V/oct pitch based on formula explained in constructor, for backwards compatibility | // Scale time knob to 1V/oct pitch based on formula explained in constructor, for backwards compatibility | ||||
float pitch = std::log2(1000.f) - std::log2(10000.f) * params[TIME_PARAM].getValue(); | float pitch = std::log2(1000.f) - std::log2(10000.f) * params[TIME_PARAM].getValue(); | ||||
pitch += inputs[TIME_INPUT].getVoltage() * params[TIME_CV_PARAM].getValue(); | pitch += inputs[TIME_INPUT].getVoltage() * params[TIME_CV_PARAM].getValue(); | ||||
float freq = clockFreq / 2.f * std::pow(2.f, pitch); | |||||
float freq = clockFreq / 2.f * dsp::exp2_taylor5(pitch); | |||||
// Number of desired delay samples | // Number of desired delay samples | ||||
float index = args.sampleRate / freq; | float index = args.sampleRate / freq; | ||||
// In order to delay accurate samples, subtract by the historyBuffer size, and an experimentally tweaked amount. | // In order to delay accurate samples, subtract by the historyBuffer size, and an experimentally tweaked amount. | ||||
@@ -136,7 +136,7 @@ struct Gates : Module { | |||||
// Gate output | // Gate output | ||||
float gatePitch = params[LENGTH_PARAM].getValue() + inputs[LENGTH_INPUT].getPolyVoltage(c); | float gatePitch = params[LENGTH_PARAM].getValue() + inputs[LENGTH_INPUT].getPolyVoltage(c); | ||||
float gateLength = dsp::approxExp2_taylor5(gatePitch + 30.f) / 1073741824; | |||||
float gateLength = dsp::exp2_taylor5(gatePitch + 30.f) / 1073741824; | |||||
if (std::isfinite(e.gateTime)) { | if (std::isfinite(e.gateTime)) { | ||||
e.gateTime += args.sampleTime; | e.gateTime += args.sampleTime; | ||||
if (reset || e.gateTime >= gateLength) { | if (reset || e.gateTime >= gateLength) { | ||||
@@ -131,7 +131,7 @@ struct LFO : Module { | |||||
// Pitch and frequency | // Pitch and frequency | ||||
float_4 pitch = freqParam; | float_4 pitch = freqParam; | ||||
pitch += inputs[FM_INPUT].getVoltageSimd<float_4>(c) * fmParam; | pitch += inputs[FM_INPUT].getVoltageSimd<float_4>(c) * fmParam; | ||||
float_4 freq = clockFreq / 2.f * dsp::approxExp2_taylor5(pitch + 30.f) / std::pow(2.f, 30.f); | |||||
float_4 freq = clockFreq / 2.f * dsp::exp2_taylor5(pitch); | |||||
// Pulse width | // Pulse width | ||||
float_4 pw = pwParam; | float_4 pw = pwParam; | ||||
@@ -97,7 +97,7 @@ struct Process : Module { | |||||
float slew = INFINITY; | float slew = INFINITY; | ||||
if (std::isfinite(slewParam)) { | if (std::isfinite(slewParam)) { | ||||
float slewPitch = slewParam + inputs[SLEW_INPUT].getPolyVoltage(c); | float slewPitch = slewParam + inputs[SLEW_INPUT].getPolyVoltage(c); | ||||
slew = dsp::approxExp2_taylor5(-slewPitch + 30.f) / std::exp2(30.f); | |||||
slew = dsp::exp2_taylor5(-slewPitch + 30.f) / std::exp2(30.f); | |||||
} | } | ||||
float slewDelta = slew * args.sampleTime; | float slewDelta = slew * args.sampleTime; | ||||
@@ -148,7 +148,7 @@ struct Random : Module { | |||||
// Advance clock phase by rate | // Advance clock phase by rate | ||||
float rate = params[RATE_PARAM].getValue(); | float rate = params[RATE_PARAM].getValue(); | ||||
rate += inputs[RATE_PARAM].getVoltage() * params[RATE_CV_PARAM].getValue(); | rate += inputs[RATE_PARAM].getVoltage() * params[RATE_CV_PARAM].getValue(); | ||||
clockFreq = std::pow(2.f, rate); | |||||
clockFreq = dsp::exp2_taylor5(rate); | |||||
deltaPhase = std::fmin(clockFreq * args.sampleTime, 0.5f); | deltaPhase = std::fmin(clockFreq * args.sampleTime, 0.5f); | ||||
clockPhase += deltaPhase; | clockPhase += deltaPhase; | ||||
// Trigger | // Trigger | ||||
@@ -182,7 +182,7 @@ struct SEQ3 : Module { | |||||
else { | else { | ||||
// Internal clock | // Internal clock | ||||
float clockPitch = params[TEMPO_PARAM].getValue() + inputs[TEMPO_INPUT].getVoltage() * params[TEMPO_CV_PARAM].getValue(); | float clockPitch = params[TEMPO_PARAM].getValue() + inputs[TEMPO_INPUT].getVoltage() * params[TEMPO_CV_PARAM].getValue(); | ||||
float clockFreq = std::pow(2.f, clockPitch); | |||||
float clockFreq = dsp::exp2_taylor5(clockPitch); | |||||
phase += clockFreq * args.sampleTime; | phase += clockFreq * args.sampleTime; | ||||
if (phase >= 1.f && !resetGate) { | if (phase >= 1.f && !resetGate) { | ||||
clock = true; | clock = true; | ||||
@@ -152,7 +152,7 @@ struct Scope : Module { | |||||
// Add point to buffer if recording | // Add point to buffer if recording | ||||
if (bufferIndex < BUFFER_SIZE) { | if (bufferIndex < BUFFER_SIZE) { | ||||
// Compute time | // Compute time | ||||
float deltaTime = std::pow(2.f, -params[TIME_PARAM].getValue()) / BUFFER_SIZE; | |||||
float deltaTime = dsp::exp2_taylor5(-params[TIME_PARAM].getValue()) / BUFFER_SIZE; | |||||
int frameCount = (int) std::ceil(deltaTime * args.sampleRate); | int frameCount = (int) std::ceil(deltaTime * args.sampleRate); | ||||
// Get input | // Get input | ||||
@@ -169,7 +169,7 @@ struct VCF : Module { | |||||
// Get pitch | // Get pitch | ||||
float_4 pitch = freqParam + inputs[FREQ_INPUT].getPolyVoltageSimd<float_4>(c) * freqCvParam; | float_4 pitch = freqParam + inputs[FREQ_INPUT].getPolyVoltageSimd<float_4>(c) * freqCvParam; | ||||
// Set cutoff | // Set cutoff | ||||
float_4 cutoff = dsp::FREQ_C4 * simd::pow(2.f, pitch); | |||||
float_4 cutoff = dsp::FREQ_C4 * dsp::exp2_taylor5(pitch); | |||||
// Without oversampling, we must limit to 8000 Hz or so @ 44100 Hz | // Without oversampling, we must limit to 8000 Hz or so @ 44100 Hz | ||||
cutoff = clamp(cutoff, 1.f, args.sampleRate * 0.18f); | cutoff = clamp(cutoff, 1.f, args.sampleRate * 0.18f); | ||||
filter.setCutoff(cutoff); | filter.setCutoff(cutoff); | ||||
@@ -324,10 +324,10 @@ struct VCO : Module { | |||||
float_4 freq; | float_4 freq; | ||||
if (!linear) { | if (!linear) { | ||||
pitch += inputs[FM_INPUT].getPolyVoltageSimd<float_4>(c) * fmParam; | pitch += inputs[FM_INPUT].getPolyVoltageSimd<float_4>(c) * fmParam; | ||||
freq = dsp::FREQ_C4 * dsp::approxExp2_taylor5(pitch + 30.f) / std::pow(2.f, 30.f); | |||||
freq = dsp::FREQ_C4 * dsp::exp2_taylor5(pitch); | |||||
} | } | ||||
else { | else { | ||||
freq = dsp::FREQ_C4 * dsp::approxExp2_taylor5(pitch + 30.f) / std::pow(2.f, 30.f); | |||||
freq = dsp::FREQ_C4 * dsp::exp2_taylor5(pitch); | |||||
freq += dsp::FREQ_C4 * inputs[FM_INPUT].getPolyVoltageSimd<float_4>(c) * fmParam; | freq += dsp::FREQ_C4 * inputs[FM_INPUT].getPolyVoltageSimd<float_4>(c) * fmParam; | ||||
} | } | ||||
freq = clamp(freq, 0.f, args.sampleRate / 2.f); | freq = clamp(freq, 0.f, args.sampleRate / 2.f); | ||||
@@ -145,7 +145,7 @@ struct WTLFO : Module { | |||||
for (int c = 0; c < channels; c += 4) { | for (int c = 0; c < channels; c += 4) { | ||||
// Calculate frequency in Hz | // Calculate frequency in Hz | ||||
float_4 pitch = freqParam + inputs[FM_INPUT].getVoltageSimd<float_4>(c) * fmParam; | float_4 pitch = freqParam + inputs[FM_INPUT].getVoltageSimd<float_4>(c) * fmParam; | ||||
float_4 freq = clockFreq / 2.f * dsp::approxExp2_taylor5(pitch + 30.f) / std::pow(2.f, 30.f); | |||||
float_4 freq = clockFreq / 2.f * dsp::exp2_taylor5(pitch); | |||||
freq = simd::fmin(freq, 1024.f); | freq = simd::fmin(freq, 1024.f); | ||||
// Accumulate phase | // Accumulate phase | ||||
@@ -159,10 +159,10 @@ struct WTVCO : Module { | |||||
float_4 freq; | float_4 freq; | ||||
if (!linear) { | if (!linear) { | ||||
pitch += inputs[FM_INPUT].getPolyVoltageSimd<float_4>(c) * fmParam; | pitch += inputs[FM_INPUT].getPolyVoltageSimd<float_4>(c) * fmParam; | ||||
freq = dsp::FREQ_C4 * dsp::approxExp2_taylor5(pitch + 30.f) / std::pow(2.f, 30.f); | |||||
freq = dsp::FREQ_C4 * dsp::exp2_taylor5(pitch); | |||||
} | } | ||||
else { | else { | ||||
freq = dsp::FREQ_C4 * dsp::approxExp2_taylor5(pitch + 30.f) / std::pow(2.f, 30.f); | |||||
freq = dsp::FREQ_C4 * dsp::exp2_taylor5(pitch); | |||||
freq += dsp::FREQ_C4 * inputs[FM_INPUT].getPolyVoltageSimd<float_4>(c) * fmParam; | freq += dsp::FREQ_C4 * inputs[FM_INPUT].getPolyVoltageSimd<float_4>(c) * fmParam; | ||||
} | } | ||||