BogaudioModules

BogaudioModules for VCV Rack
Log | Files | Refs | README | LICENSE

commit b633fefca04c9ed36a833a613bf1900d2f930aa7
parent 11c447bdda1250927b872500657fc2f456ca5679
Author: Matt Demanett <matt@demanett.net>
Date:   Sat, 18 Jul 2020 16:47:57 -0400

VCOs: fix exponential FM handling in linear frequency mode.  Also fix frequency initialization on module load in linear frequency mode. #124

Diffstat:
Msrc/vco_base.cpp | 10++++------
Msrc/vco_base.hpp | 4+++-
2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/vco_base.cpp b/src/vco_base.cpp @@ -117,12 +117,7 @@ void VCOBase::modulateChannel(int c) { e.baseVOct += clamp(inputs[_pitchInputID].getVoltage(c), -5.0f, 5.0f); } if (_linearMode) { - if (_slowMode) { - e.baseHz = e.baseVOct; - } - else { - e.baseHz = e.baseVOct * 1000.0f; - } + e.baseHz = linearModeVoltsToHertz(e.baseVOct); } else { if (_slowMode) { @@ -146,6 +141,9 @@ void VCOBase::processChannel(const ProcessArgs& args, int c) { if (_fmLinearMode) { phaseOffset = Phasor::radiansToPhase(2.0f * fm); } + else if (_linearMode) { + frequency += linearModeVoltsToHertz(fm); + } else { frequency = cvToFrequency(e.baseVOct + fm); } diff --git a/src/vco_base.hpp b/src/vco_base.hpp @@ -4,6 +4,7 @@ #include "dsp/filters/resample.hpp" #include "dsp/oscillator.hpp" #include "dsp/signal.hpp" +#include <math.h> using namespace bogaudio::dsp; @@ -13,7 +14,7 @@ struct VCOBase : BGModule { struct Engine { static constexpr int oversample = 8; - float frequency = 0.0f; + float frequency = INFINITY; float baseVOct = 0.0f; float baseHz = 0.0f; @@ -79,6 +80,7 @@ struct VCOBase : BGModule { , _polyInputID(piID) {} + inline float linearModeVoltsToHertz(float v) { return _slowMode ? v : 1000.0f * v; } void reset() override; void sampleRateChange() override; json_t* dataToJson() override;