[go: up one dir, main page]

Menu

[r39]: / Source / TVF.h  Maximize  Restore  History

Download this file

78 lines (56 with data), 2.3 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/**************************************************************************
Copyright (C) 2019 Arnaud Champenois arthelion@free.fr
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#pragma once
#include "TimeVariant.h"
class TVF : public TimeVariant {
public:
TVF(const TVFParameters&tvfParam) :
TimeVariant(tvfParam), mTVFParam(tvfParam) {}
virtual ~TVF() override;
virtual void init(double sampleRate) override;
double next(double value) {
if (mLowCutFrequency > TVFLowestCutoffFrequency)
value = mLowCutFilter.processSample(value);
if (!isActive() && isLFOBypassed()) {
moveLFO(1.0);
value = mFilter.processSample(value);
}
else {
double cutoff = nextFreqADSR(false)*mCutoffValue*nextLFO();
if (cutoff < TVFLowestCutoffFrequency)
return 0.0;
if (cutoff > mMaxCutoff)
cutoff = mMaxCutoff;
mFilter.parameters->setCutOffFrequency(mSampleRate, cutoff, mResonanceValue);
value = mFilter.processSample(value);
}
if (mMidGain != 0.0f) {
value = mBandFilter.processSample(value);
}
return value;
}
void updateInternalValues(int controller = 0) override;
private:
juce::dsp::StateVariableFilter::Filter<double> mFilter;
juce::dsp::StateVariableFilter::Filter<double> mLowCutFilter;
juce::dsp::IIR::Filter<double> mBandFilter;
//Parameters
const TVFParameters& mTVFParam;
// Current values
double mLowCutFrequency = 0.0;
double mCutoffValue = TVFHighestCutoffFrequency;
double mMaxCutoff = TVFHighestCutoffFrequency;
double mResonanceValue = TVFDefaultResonance;
float mMidFreq = 0.0f, mMidGain = 0.0f, mMidQ = 0.0f;
};