WE Core
Loading...
Searching...
No Matches
RichterLFOPair.h
Go to the documentation of this file.
1/*
2 * File: RichterLFOPair.h
3 *
4 * Created: 18/05/2015
5 *
6 * This file is part of WECore.
7 *
8 * WECore is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * WECore is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with WECore. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#pragma once
23
24#include "RichterLFO.h"
26
27namespace WECore::Richter {
58 class RichterLFOPair : public ModulationSource<double> {
59 public:
60 inline RichterLFOPair();
61 virtual ~RichterLFOPair() override = default;
64
76 inline void prepareForNextBuffer(double bpm, double timeInSeconds);
77
83 inline void setSampleRate(double sampleRate);
84
86 std::shared_ptr<RichterLFO> MOD;
87
88 private:
98 inline double _getNextOutputImpl(double inSample) override;
99
103 inline void _resetImpl() override;
104 };
105
107 MOD = std::make_shared<RichterLFO>();
110 }
111
113 double timeInSeconds) {
114 LFO.prepareForNextBuffer(bpm, timeInSeconds);
115 MOD->prepareForNextBuffer(bpm, timeInSeconds);
116 }
117
118 void RichterLFOPair::setSampleRate(double sampleRate) {
119 LFO.setSampleRate(sampleRate);
120 MOD->setSampleRate(sampleRate);
121 }
122
124 LFO.reset();
125 MOD->reset();
126 }
127
128 double RichterLFOPair::_getNextOutputImpl(double /*inSample*/) {
129 double retVal {1};
130
131 // Advance the modulation LFO state
132 MOD->getNextOutput(0);
133
134 // Always call getNextOutput regardless of bypassed state
135 const double tempGain {LFO.getNextOutput(0)};
136
137 if (LFO.getBypassSwitch()) {
138 // The output of the LFO is a value in the range -1:1, we need to convert this into a
139 // gain in the range 0:1 and make sure the value is 1 when the depth is 0
140 retVal = (tempGain / 2) + (2 - LFO.getDepth()) / 2;
141 }
142
143 return retVal;
144 }
145}
SampleType getNextOutput(SampleType inSample)
void prepareForNextBuffer(double bpm, double timeInSeconds)
Definition RichterLFO.h:327
bool addDepthModulationSource(std::shared_ptr< ModulationSource > source)
Definition RichterLFO.h:263
bool addFreqModulationSource(std::shared_ptr< ModulationSource > source)
Definition RichterLFO.h:231
void setSampleRate(double val)
Definition RichterLFO.h:91
RichterLFOPair(RichterLFOPair &other)=delete
double _getNextOutputImpl(double inSample) override
void setSampleRate(double sampleRate)
void prepareForNextBuffer(double bpm, double timeInSeconds)
std::shared_ptr< RichterLFO > MOD
virtual ~RichterLFOPair() override=default
RichterLFOPair operator=(RichterLFOPair &other)=delete