|
LMMS
|
#include <juce_ParameterAttachments.h>
Public Member Functions | |
| ParameterAttachment (RangedAudioParameter ¶meter, std::function< void(float)> parameterChangedCallback, UndoManager *undoManager=nullptr) | |
| ~ParameterAttachment () override | |
| void | sendInitialUpdate () |
| void | setValueAsCompleteGesture (float newDenormalisedValue) |
| void | beginGesture () |
| void | setValueAsPartOfGesture (float newDenormalisedValue) |
| void | endGesture () |
Private Member Functions | |
| float | normalise (float f) const |
| template<typename Callback> | |
| void | callIfParameterValueChanged (float newDenormalisedValue, Callback &&callback) |
| void | parameterValueChanged (int, float) override |
| void | parameterGestureChanged (int, bool) override |
| void | handleAsyncUpdate () override |
| Private Member Functions inherited from juce::AudioProcessorParameter::Listener | |
| virtual | ~Listener ()=default |
| Private Member Functions inherited from juce::AsyncUpdater | |
| AsyncUpdater () | |
| virtual | ~AsyncUpdater () |
| void | triggerAsyncUpdate () |
| void | cancelPendingUpdate () noexcept |
| void | handleUpdateNowIfNeeded () |
| bool | isUpdatePending () const noexcept |
Private Attributes | |
| RangedAudioParameter & | parameter |
| std::atomic< float > | lastValue { 0.0f } |
| UndoManager * | undoManager = nullptr |
| std::function< void(float)> | setValue |
Used to implement 'attachments' or 'controllers' that link a plug-in parameter to a UI element.
To implement a new attachment type, create a new class which includes an instance of this class as a data member. Your class should pass a function to the constructor of the ParameterAttachment, which will then be called on the message thread when the parameter changes. You can use this function to update the state of the UI control. Your class should also register as a listener of the UI control and respond to respond to changes in the UI element by calling either setValueAsCompleteGesture or beginGesture, setValueAsPartOfGesture and endGesture.
Make sure to call sendInitialUpdate at the end of your new attachment's constructor, so that the UI immediately reflects the state of the parameter.
@tags{Audio}
| juce::ParameterAttachment::ParameterAttachment | ( | RangedAudioParameter & | parameter, |
| std::function< void(float)> | parameterChangedCallback, | ||
| UndoManager * | undoManager = nullptr ) |
Listens to a parameter and calls the the provided function in response to parameter changes. If an undoManager is supplied beginNewTransaction will be called on it whenever the UI requests a parameter change via this attachment.
| parameter | The parameter to which this attachment will listen |
| parameterChangedCallback | The function that will be called on the message thread in response to parameter changes |
| undoManager | The UndoManager that will be used to begin transactions when the UI requests a parameter change. |
|
override |
Destructor.
| void juce::ParameterAttachment::beginGesture | ( | ) |
Begins a gesture on the managed parameter.
Call this when the UI is about to begin a continuous interaction, like when the mouse button is pressed on a slider.
|
private |
| void juce::ParameterAttachment::endGesture | ( | ) |
Ends a gesture on the managed parameter.
Call this when the UI has finished a continuous interaction, like when the mouse button is released on a slider.
|
overrideprivatevirtual |
Called back to do whatever your class needs to do.
This method is called by the message thread at the next convenient time after the triggerAsyncUpdate() method has been called.
Implements juce::AsyncUpdater.
|
inlineprivate |
|
inlineoverrideprivatevirtual |
Indicates that a parameter change gesture has started.
E.g. if the user is dragging a slider, this would be called with gestureIsStarting being true when they first press the mouse button, and it will be called again with gestureIsStarting being false when they release it.
IMPORTANT NOTE: This will be called synchronously, and many audio processors will call it during their audio callback. This means that not only has your handler code got to be completely thread-safe, but it's also got to be VERY fast, and avoid blocking. If you need to handle this event on your message thread, use this callback to trigger an AsyncUpdater or ChangeBroadcaster which you can respond to later on the message thread.
Implements juce::AudioProcessorParameter::Listener.
|
overrideprivatevirtual |
Receives a callback when a parameter has been changed.
IMPORTANT NOTE: This will be called synchronously when a parameter changes, and many audio processors will change their parameter during their audio callback. This means that not only has your handler code got to be completely thread-safe, but it's also got to be VERY fast, and avoid blocking. If you need to handle this event on your message thread, use this callback to trigger an AsyncUpdater or ChangeBroadcaster which you can respond to on the message thread.
Implements juce::AudioProcessorParameter::Listener.
| void juce::ParameterAttachment::sendInitialUpdate | ( | ) |
Calls the parameterChangedCallback function that was registered in the constructor, making the UI reflect the current parameter state.
This function should be called after doing any necessary setup on the UI control that is being managed (e.g. adding ComboBox entries, making buttons toggle-able).
| void juce::ParameterAttachment::setValueAsCompleteGesture | ( | float | newDenormalisedValue | ) |
Triggers a full gesture message on the managed parameter.
Call this in the listener callback of the UI control in response to a one-off change in the UI like a button-press.
| void juce::ParameterAttachment::setValueAsPartOfGesture | ( | float | newDenormalisedValue | ) |
Updates the parameter value during a gesture.
Call this during a continuous interaction, like a slider value changed callback.
|
private |
|
private |
|
private |
|
private |