4 : m_parameterPtr(paramToAttach), m_parameterValue(paramToAttach->getValue()), m_attachmentMode(
Mode::Discrete),
5 m_updater(nullptr), m_smoothingTimeSeconds(0.0f), m_updateFunction(std::move(updateFunction))
7 jassert(paramToAttach !=
nullptr);
11 parameter->addListener(
this);
17 std::function<
void(
float)> updateFunction)
18 : m_parameterPtr(paramToAttach), m_parameterValue(paramToAttach->getValue()),
20 m_smoothingTimeSeconds(smoothingTimeSeconds), m_updateFunction(std::move(updateFunction)),
21 m_updateRate(updateRate)
23 jassert(paramToAttach !=
nullptr);
25 if (smoothingTimeSeconds <= 0.0f)
33 if (updateFunction !=
nullptr && updateRate <= 0)
41 parameter->addListener(
this);
49 parameter->removeListener(
this);
62 if (numSmoothingSamples == 0)
88 for (
int i = 0; i < numSamples; i++)
89 bufferPtr[i] = newValue;
120 for (
int i = 0; i < numSamples; i++)
127 auto depth = d.value;
129 auto modValues = modulator->getValues();
131 for (
int i = 0; i < numSamples; i++)
136 bufferPtr[i] += isBipolar ? ((modValues[i] * 2.0f) - 1.0f) * (depth * 0.5f) : modValues[i] * depth;
141 for (
int i = 0; i < numSamples; i++)
179 struct Depth d = {depth, polarity};
198 jassert(depth >= -1.0f && depth <= 1.0f);
229 auto currentVal =
m_smoother.getTargetValue();
230 m_smoother.setCurrentAndTargetValue(currentVal);
256 if (modulator->mappingFunctionPtr !=
nullptr)
259 auto incomingParamValues = modulator->getValues();
267 auto parameterValueGain = Decibels::decibelsToGain(
271 parameterValueGain *= modulator->mappingFunctionPtr(incomingParamValues, depth);
274 parameterValuedB = Decibels::gainToDecibels(
280 value *= modulator->mappingFunctionPtr(incomingParamValues, depth);
287 auto depth = d.value;
292 auto valueIncoming = modulator->getValues()[0];
293 auto modulationValue =
294 isBipolar ? ((valueIncoming * 2.0f) - 1.0f) * (depth * 0.5f) : valueIncoming * depth;
295 value += modulationValue;
Definition KAttachment.h:23
int m_numSmoothingSamples
Definition KAttachment.h:174
std::unique_ptr< ParameterUpdater > m_updater
Definition KAttachment.h:170
void sendInitialUpdate()
Definition KAttachment.cpp:226
bool m_wasSmoothing
Definition KAttachment.h:191
const float * data()
Definition KAttachment.cpp:155
void updateSmoother()
Definition KAttachment.cpp:249
void applyPendingUpdates()
Definition KAttachment.cpp:212
SmoothedValue< float > m_smoother
Definition KAttachment.h:172
void setModulatorDepth(Modulator *m, float depth)
Definition KAttachment.cpp:195
void modulatorChanged(const Modulator *m) override
Definition KAttachment.cpp:243
Array< Modulator * > m_fastModulators
Definition KAttachment.h:177
Polarity
Definition KAttachment.h:120
@ Bipolar
Definition KAttachment.h:121
AudioBuffer< float > m_valueBuffer
Definition KAttachment.h:168
bool m_needsUpdate
Definition KAttachment.h:190
void addModulator(Modulator *m, float depth=1.0f, Polarity polarity=Polarity::Bipolar)
Definition KAttachment.cpp:166
std::map< Modulator *, Depth > m_depthMap
Definition KAttachment.h:185
Array< Modulator * > m_slowModulators
Definition KAttachment.h:176
void prepare(double sampleRate, int samplesPerBlock)
Definition KAttachment.cpp:53
void setModulatorPolarity(Modulator *m, Polarity polarity)
Definition KAttachment.cpp:204
bool nextBlock(int numSamples)
Definition KAttachment.cpp:76
double m_sampleRate
Definition KAttachment.h:187
RangedAudioParameter * m_cachedParameterPtr
Definition KAttachment.h:166
Mode
Definition KAttachment.h:154
const std::function< void(float)> m_updateFunction
Definition KAttachment.h:192
KAttachment(std::shared_ptr< KParameter > paramToAttach, std::function< void(float)> updateFunction=nullptr)
Definition KAttachment.cpp:3
const Mode m_attachmentMode
Definition KAttachment.h:169
int m_maxBlockSize
Definition KAttachment.h:188
float m_smoothingTimeSeconds
Definition KAttachment.h:173
void parameterValueChanged(int, float newValue) override
Definition KAttachment.cpp:220
bool needsUpdate() const
Definition KAttachment.cpp:218
~KAttachment() override
Definition KAttachment.cpp:45
void removeModulator(Modulator *m)
Definition KAttachment.cpp:183
float m_parameterValue
Definition KAttachment.h:167
std::weak_ptr< RangedAudioParameter > const m_parameterPtr
Definition KAttachment.h:165
ParameterUpdater * getUpdater()
Definition KAttachment.cpp:157
Holds a list of modulation destinations and sends events to them when the modulator output is updated...
Definition ModulationSource.h:20
void removeListener(Listener *l)
Definition ModulationSource.cpp:7
bool isFast() const
Definition ModulationSource.h:40
void addListener(Listener *l)
Definition ModulationSource.cpp:5
Definition AirAbsorptionFilter.cpp:2
Definition KAttachment.h:180