BogaudioModules

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

commit beb8bbe5da07b48a7c57703d19c8479e6aa525e8
parent b57623d3c35cc9cc1bf900e77b5e720912742f06
Author: Matt Demanett <matt@demanett.net>
Date:   Thu,  4 Jan 2018 21:52:52 -0500

Add amplitude setting to sine oscillator; saves a multiplication in module step.

Diffstat:
Msrc/Reftone.cpp | 4++--
Msrc/dsp/oscillator.hpp | 9++++++---
2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/Reftone.cpp b/src/Reftone.cpp @@ -37,7 +37,7 @@ struct Reftone : Module { Reftone() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) - , _sine(engineGetSampleRate(), _frequency) + , _sine(engineGetSampleRate(), _frequency, 5.0) { } @@ -61,7 +61,7 @@ void Reftone::step() { _sine.setFrequency(_frequency); outputs[CV_OUTPUT].value = log2f(_frequency / f0); - outputs[OUT_OUTPUT].value = _sine.next() * 5.0; + outputs[OUT_OUTPUT].value = _sine.next(); } diff --git a/src/dsp/oscillator.hpp b/src/dsp/oscillator.hpp @@ -35,16 +35,19 @@ struct OscillatorGenerator : Generator { }; struct SineOscillator : OscillatorGenerator { - float _x = 1.0; - float _y = 0.0; + float _x; + float _y; float _sinDeltaTheta; float _cosDeltaTheta; SineOscillator( float sampleRate, - float frequency + float frequency, + float amplitude = 1.0 ) : OscillatorGenerator(sampleRate, frequency) + , _x(amplitude) + , _y(0.0) { updateDeltaTheta(); }