From fae4f4fc3693c2cb192dc9aa437094a2fc90ade4 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Fri, 10 Feb 2023 23:34:46 -0500 Subject: [PATCH] Use new dsp::exp2_taylor5() function. --- src/Delay.cpp | 2 +- src/Gates.cpp | 2 +- src/LFO.cpp | 2 +- src/Process.cpp | 2 +- src/Random.cpp | 2 +- src/SEQ3.cpp | 2 +- src/Scope.cpp | 2 +- src/VCF.cpp | 2 +- src/VCO.cpp | 4 ++-- src/WTLFO.cpp | 2 +- src/WTVCO.cpp | 4 ++-- 11 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Delay.cpp b/src/Delay.cpp index cafd44f..fe68009 100644 --- a/src/Delay.cpp +++ b/src/Delay.cpp @@ -121,7 +121,7 @@ struct Delay : Module { // 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(); 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 float index = args.sampleRate / freq; // In order to delay accurate samples, subtract by the historyBuffer size, and an experimentally tweaked amount. diff --git a/src/Gates.cpp b/src/Gates.cpp index e1a5753..73039f2 100644 --- a/src/Gates.cpp +++ b/src/Gates.cpp @@ -136,7 +136,7 @@ struct Gates : Module { // Gate output 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)) { e.gateTime += args.sampleTime; if (reset || e.gateTime >= gateLength) { diff --git a/src/LFO.cpp b/src/LFO.cpp index 8706c9b..76cf876 100644 --- a/src/LFO.cpp +++ b/src/LFO.cpp @@ -131,7 +131,7 @@ struct LFO : Module { // Pitch and frequency float_4 pitch = freqParam; pitch += inputs[FM_INPUT].getVoltageSimd(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 float_4 pw = pwParam; diff --git a/src/Process.cpp b/src/Process.cpp index 9d34b30..23d849c 100644 --- a/src/Process.cpp +++ b/src/Process.cpp @@ -97,7 +97,7 @@ struct Process : Module { float slew = INFINITY; if (std::isfinite(slewParam)) { 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; diff --git a/src/Random.cpp b/src/Random.cpp index d7466f6..7982b17 100644 --- a/src/Random.cpp +++ b/src/Random.cpp @@ -148,7 +148,7 @@ struct Random : Module { // Advance clock phase by rate float rate = params[RATE_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); clockPhase += deltaPhase; // Trigger diff --git a/src/SEQ3.cpp b/src/SEQ3.cpp index 95d9a65..99ef636 100644 --- a/src/SEQ3.cpp +++ b/src/SEQ3.cpp @@ -182,7 +182,7 @@ struct SEQ3 : Module { else { // Internal clock 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; if (phase >= 1.f && !resetGate) { clock = true; diff --git a/src/Scope.cpp b/src/Scope.cpp index f670626..7b32d4a 100644 --- a/src/Scope.cpp +++ b/src/Scope.cpp @@ -152,7 +152,7 @@ struct Scope : Module { // Add point to buffer if recording if (bufferIndex < BUFFER_SIZE) { // 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); // Get input diff --git a/src/VCF.cpp b/src/VCF.cpp index 75cd64b..25c1904 100644 --- a/src/VCF.cpp +++ b/src/VCF.cpp @@ -169,7 +169,7 @@ struct VCF : Module { // Get pitch float_4 pitch = freqParam + inputs[FREQ_INPUT].getPolyVoltageSimd(c) * freqCvParam; // 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 cutoff = clamp(cutoff, 1.f, args.sampleRate * 0.18f); filter.setCutoff(cutoff); diff --git a/src/VCO.cpp b/src/VCO.cpp index 9c3040d..84ca0f8 100644 --- a/src/VCO.cpp +++ b/src/VCO.cpp @@ -324,10 +324,10 @@ struct VCO : Module { float_4 freq; if (!linear) { pitch += inputs[FM_INPUT].getPolyVoltageSimd(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 { - 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(c) * fmParam; } freq = clamp(freq, 0.f, args.sampleRate / 2.f); diff --git a/src/WTLFO.cpp b/src/WTLFO.cpp index ffe9796..45b32cb 100644 --- a/src/WTLFO.cpp +++ b/src/WTLFO.cpp @@ -145,7 +145,7 @@ struct WTLFO : Module { for (int c = 0; c < channels; c += 4) { // Calculate frequency in Hz float_4 pitch = freqParam + inputs[FM_INPUT].getVoltageSimd(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); // Accumulate phase diff --git a/src/WTVCO.cpp b/src/WTVCO.cpp index 2d7d0d9..5053663 100644 --- a/src/WTVCO.cpp +++ b/src/WTVCO.cpp @@ -159,10 +159,10 @@ struct WTVCO : Module { float_4 freq; if (!linear) { pitch += inputs[FM_INPUT].getPolyVoltageSimd(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 { - 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(c) * fmParam; }