Attaches to a KParameter to provide parameter smoothing and modulation.
More...
#include <KAttachment.h>
Attaches to a KParameter to provide parameter smoothing and modulation.
A helper class for KParameters that smooths parameter changes and provides functionality for easily integrating the new values into the audio processor.
- See also
- KParameter, KwidgetProcessor
◆ Mode
| Enumerator |
|---|
| Discrete | |
| Continuous | |
◆ Polarity
| Enumerator |
|---|
| Bipolar | |
| Unipolar | |
◆ KAttachment() [1/2]
| krotos::KAttachment::KAttachment |
( |
std::shared_ptr< KParameter > | paramToAttach, |
|
|
std::function< void(float)> | updateFunction = nullptr ) |
Creates a discrete parameter attachment. Discrete attachments do not use any smoothing and if their values change, they trigger an update once at the start of the next block.
If updateFunction is nullptr, no automatic parameter updating will occur. You can call data() to get a pointer to the current parameter values.
- Parameters
-
| paramToAttach | The KParameter to link this attachment to |
| updateFunction | Function that is called to update the processor of the next parameter change |
◆ KAttachment() [2/2]
| krotos::KAttachment::KAttachment |
( |
std::shared_ptr< KParameter > | paramToAttach, |
|
|
float | smoothingTimeSeconds, |
|
|
int | updateRate, |
|
|
std::function< void(float)> | updateFunction = nullptr ) |
Creates a continuous parameter attachment. Continuous attachments use a linear smoother to gradually integrate parameter changes.
If updateFunction is nullptr, no automatic parameter updating will occur. You can call data() to get a pointer to the current parameter values.
- Parameters
-
| paramToAttach | The KParameter to link this attachment to |
| smoothingTimeSeconds | Duration of linear smoother |
| updateRate | Number of samples between processor updates |
| updateFunction | Function that is called to update the processor of the next parameter change |
◆ ~KAttachment()
| krotos::KAttachment::~KAttachment |
( |
| ) |
|
|
override |
◆ addModulator()
Add a new modulator for this parameter.
◆ applyPendingUpdates()
| void krotos::KAttachment::applyPendingUpdates |
( |
| ) |
|
This function clears any pending smoother updates by filling the value buffer with the target value, and applying this value immediately to the processor.
If the smoother is already at its target value, nothing happens.
◆ data()
| const float * krotos::KAttachment::data |
( |
| ) |
|
Get a pointer to the parameter value buffer.
◆ getUpdater()
Used by continuous attachments to provide an easy way of updating the parameter value within a processing loop.
- Returns
- Pointer to m_updater. Call needsUpdate() first to check if it is valid.
◆ modulatorChanged()
| void krotos::KAttachment::modulatorChanged |
( |
const Modulator * | m | ) |
|
|
overrideprivatevirtual |
◆ needsUpdate()
| bool krotos::KAttachment::needsUpdate |
( |
| ) |
const |
Returns true if this object's ParameterUpdater should be active for the next block.
◆ nextBlock()
| bool krotos::KAttachment::nextBlock |
( |
int | numSamples | ) |
|
Update the parameter value buffer for each block. For discrete parameters, changes in value are sent to the processor in this function. For continuous parameters, changes in value should be handled using the result of getUpdater() in the audio processing loop.
- Parameters
-
| numSamples | Number of samples to move forward |
- Returns
- True if a ParameterUpdater is needed for the next block
◆ parameterGestureChanged()
| void krotos::KAttachment::parameterGestureChanged |
( |
int | , |
|
|
bool | ) |
|
inlineoverrideprivate |
◆ parameterValueChanged()
| void krotos::KAttachment::parameterValueChanged |
( |
int | , |
|
|
float | newValue ) |
|
overrideprivate |
◆ prepare()
| void krotos::KAttachment::prepare |
( |
double | sampleRate, |
|
|
int | samplesPerBlock ) |
This function must be called before the first call to nextBlock(), and also whenever the sample rate or block size changes.
◆ removeModulator()
| void krotos::KAttachment::removeModulator |
( |
Modulator * | m | ) |
|
◆ sendInitialUpdate()
| void krotos::KAttachment::sendInitialUpdate |
( |
| ) |
|
|
private |
◆ setModulatorDepth()
| void krotos::KAttachment::setModulatorDepth |
( |
Modulator * | m, |
|
|
float | depth ) |
Set the depth of a modulator.
- Parameters
-
| depth | The magnitude of modulation, must be in the range [-1, 1]. |
◆ setModulatorPolarity()
Set the polarity of a modulator.
- Parameters
-
| polarity | The polarity of modulation, either Bipolar [-1, 1] or Unipolar [0, 1]. |
◆ updateSmoother()
| void krotos::KAttachment::updateSmoother |
( |
| ) |
|
|
private |
◆ ParameterUpdater
| friend class ParameterUpdater |
|
friend |
◆ m_attachmentMode
| const Mode krotos::KAttachment::m_attachmentMode |
|
private |
◆ m_cachedParameterPtr
| RangedAudioParameter* krotos::KAttachment::m_cachedParameterPtr |
|
private |
◆ m_depthMap
◆ m_fastModulators
| Array<Modulator*> krotos::KAttachment::m_fastModulators |
|
private |
◆ m_maxBlockSize
| int krotos::KAttachment::m_maxBlockSize {0} |
|
private |
◆ m_needsUpdate
| bool krotos::KAttachment::m_needsUpdate {false} |
|
private |
◆ m_numSmoothingSamples
| int krotos::KAttachment::m_numSmoothingSamples {0} |
|
private |
◆ m_parameterPtr
| std::weak_ptr<RangedAudioParameter> const krotos::KAttachment::m_parameterPtr |
|
private |
◆ m_parameterValue
| float krotos::KAttachment::m_parameterValue |
|
private |
◆ m_sampleRate
| double krotos::KAttachment::m_sampleRate {0.0} |
|
private |
◆ m_slowModulators
| Array<Modulator*> krotos::KAttachment::m_slowModulators |
|
private |
◆ m_smoother
| SmoothedValue<float> krotos::KAttachment::m_smoother {0.0f} |
|
private |
◆ m_smoothingTimeSeconds
| float krotos::KAttachment::m_smoothingTimeSeconds |
|
private |
◆ m_updateFunction
| const std::function<void(float)> krotos::KAttachment::m_updateFunction |
|
private |
◆ m_updater
◆ m_updateRate
| int krotos::KAttachment::m_updateRate {0} |
|
private |
◆ m_valueBuffer
| AudioBuffer<float> krotos::KAttachment::m_valueBuffer |
|
private |
◆ m_wasSmoothing
| bool krotos::KAttachment::m_wasSmoothing {false} |
|
private |
The documentation for this class was generated from the following files: