|
Krotos Modules 3
|
#include <Kwidget.h>
Classes | |
| struct | Constants |
| class | ParameterInfo |
| Holds the information needed to create a new Kwidget parameter. More... | |
Public Types | |
| enum | DragID_Index { KwidgetID = 0 , ParameterID = 1 } |
Public Member Functions | |
| Kwidget (const String &kwidgetType, const String &kwidgetID) | |
| virtual | ~Kwidget ()=default |
| void | init () |
| std::unique_ptr< KwidgetProcessor > | createVoice () |
| std::unique_ptr< KwidgetGUI > | createControls () |
| KwidgetProcessor * | getVoice (int idx) const |
| int | getNumVoices () const |
| KwidgetProcessor * | getActiveVoice () const |
| virtual void | noteOn (int voiceIdx, int midiNote, float velocity) |
| virtual void | noteOff (int voiceIdx, float velocity) |
| virtual void | noteCleared (int voiceIdx) |
| virtual bool | isActive (int voiceIdx) |
| void | addModulator (const String ¶mID, Kwidget *modulator, int modulatorIdx, float depth=0.99f, KAttachment::Polarity=KAttachment::Polarity::Bipolar) |
| void | removeModulator (const String ¶mID, Kwidget *modulator, int modulatorIdx) |
| void | setModulatorDepth (const String ¶mID, Kwidget *modulator, int modulatorIdx, float depth) |
| void | setModulatorPolarity (const String ¶mID, Kwidget *modulator, int modulatorIdx, KAttachment::Polarity polarity) |
| const std::vector< std::shared_ptr< KParameter > > & | getParameters () const |
| KParameter * | getParameter (const String ¶meterID) const noexcept |
| Get a raw pointer to a KParameter belonging to this Kwidget's KwidgetProcessor. Useful for low overhead direct parameter access. | |
| std::shared_ptr< KParameter > | getParameterToAttach (const String ¶meterID) const noexcept |
| Get a shared pointer to a KParameter, for use with KParameter::Listener objects and situations where the parameter lifetime goes beyond local scope. | |
| CustomParameter * | getCustomParameter (const String ¶meterID) |
| CustomParameterTree * | getCustomParameterTree (const Identifier &type) |
| Get a CustomParameterTree belonging to this Kwidget. | |
| template<typename T > | |
| T * | getCustomParameter (const Identifier &type) |
| Get the CustomParameterTree subclass object of the specified type. | |
| void | notifyAllParametersListeners () |
| Call every parameter's value changed listeners with their current values. | |
| const ValueTree & | getState () |
| virtual void | setState (const ValueTree &newState, KwidgetAudioProcessor &processor) |
| void | flushState () |
| bool | isModulator () const |
| int | getNumModulators () const |
| const String & | getKwidgetType () const |
| const String & | getKwidgetID () const |
| const String & | getKwidgetVersionFromCurrentState () const |
| String | getKwidgetVersion () const |
| virtual const String & | getKwidgetLabel () |
| StringArray | getDragID (const String ¶meterID) |
| virtual size_t | numGUIImplementations () |
| virtual String | getGuiName (int) |
| virtual void | createNestedKwidgets (KwidgetAudioProcessor &) |
| bool | isAChildKwidget () |
| std::vector< Kwidget * > & | getChildKwidgets () |
| bool | isStateChanging () |
| void | addChildKwidget (Kwidget *child) |
| void | removeChildKwidgetFromTree (String kwidgetID) |
| Kwidget * | findChildKwidget (String kiwdgetID) |
| void | addParameterCallback (const String ¶mID, std::function< void(float)> callback) |
| void | addVersionedParameterCallback (StringRef kwidgetVersionTheParameterChangedIn, const String ¶mID, std::function< void(float)> callback) |
| Add an action to be performed when a specified parameter of a specific kwidget version changes value. This can be used to implement backwards compatibility when older versions of the kwidget state are loaded, and the parameters in newer versions may have been changed or removed. | |
| int | getTemplateID () |
Public Member Functions inherited from krotos::ResourceLock | |
| ResourceLock () | |
| bool | requestAccess (const StringRef id) |
| Called by a client to request access to the resource. | |
| bool | hasAccess (const StringRef id) const |
| Called by a client to enquire whether it has access to the resource. | |
| void | finishedAccessing (const StringRef id) |
| Called by a client to inform the resource that it no longer needs access. | |
| void | setAccessible (bool isAccessible) |
| Called by the resource to grant or deny access to clients. | |
Static Public Member Functions | |
| static String | getParentID (String childKwidgetID) |
Protected Member Functions | |
| virtual std::vector< ParameterInfo > | createParameters ()=0 |
| virtual std::unique_ptr< KwidgetProcessor > | createProcessor ()=0 |
| virtual std::unique_ptr< KwidgetGUI > | createGUI ()=0 |
| void | addChildGuis (std::unique_ptr< KwidgetGUI > &parentGui) |
| CustomParameter * | createAndAddCustomParameter (const String ¶mID, const var &value) |
| template<typename T > | |
| T * | createAndAddCustomParameter (const Identifier &type) |
| Create a highly customizable piece of state for this Kwidget by appending a subclass of CustomParameterTree to this Kwidget's state. | |
| void | setKwidgetVersion (const String &kwidgetVersionString) |
Protected Attributes | |
| std::vector< Kwidget * > | m_childKwidgets |
Private Member Functions | |
| KParameter * | createAndAddParameter (const ParameterInfo &info) |
Private Attributes | |
| const String | m_kwidgetType |
| const String | m_kwidgetID |
| String | m_kwidgetStateVersion |
| ValueTree | m_kwidgetTree |
| ValueTree | m_paramTree |
| ValueTree | m_customParamTree |
| ValueTree | m_childTree |
| ValueTree | m_customDataTree |
| std::vector< std::shared_ptr< KParameter > > | m_parameters |
| std::map< String, int > | m_parameterIDs |
| Array< KwidgetProcessor * > | m_processors |
| KwidgetProcessor * | m_activeVoice {nullptr} |
| std::unique_ptr< KwidgetProcessor > | m_initialVoice |
| OwnedArray< CustomParameter > | m_customParameters |
| std::map< String, int > | m_customParameterIDs |
| OwnedArray< CustomParameterTree > | m_customParameterTrees |
| std::map< Identifier, int > | m_customParameterTreeTypes |
| OwnedArray< KParameter::AudioListenerObject > | m_parameterCallbacks |
| bool | m_stateChanging {false} |
| krotos::Kwidget::Kwidget | ( | const String & | kwidgetType, |
| const String & | kwidgetID ) |
|
virtualdefault |
Destructor.
|
protected |
| void krotos::Kwidget::addChildKwidget | ( | Kwidget * | child | ) |
| void krotos::Kwidget::addModulator | ( | const String & | paramID, |
| Kwidget * | modulator, | ||
| int | modulatorIdx, | ||
| float | depth = 0.99f, | ||
| KAttachment::Polarity | polarity = KAttachment::Polarity::Bipolar ) |
Add a modulator to one of the parameters owned by this Kwidget.
| void krotos::Kwidget::addParameterCallback | ( | const String & | paramID, |
| std::function< void(float)> | callback ) |
Add an action to be performed when a specified parameter changes value.
| paramID | The ID of the parameter to listen to. |
| callback | The action to be performed when the parameter changes value. |
| void krotos::Kwidget::addVersionedParameterCallback | ( | StringRef | kwidgetVersionTheParameterChangedIn, |
| const String & | paramID, | ||
| std::function< void(float)> | callback ) |
Add an action to be performed when a specified parameter of a specific kwidget version changes value. This can be used to implement backwards compatibility when older versions of the kwidget state are loaded, and the parameters in newer versions may have been changed or removed.
| kwidgetVersionTheParameterChangedIn | The version of the Kwidget that introduced the parameter change. For example, if version "1.1" were the new version of the kwidget wherein the parameter was changed, the kwidgetVersion would be "1.1" |
| paramID | The ID of the parameter to listen to. |
| callback | The action to be performed when the parameter changes value. |
|
protected |
Create a highly customizable piece of state for this Kwidget by appending a subclass of CustomParameterTree to this Kwidget's state.
Your subclass should provide the high level methods, type safety and listener actions that your custom data structure needs. You can also use the base CustomParameterTree, however this should only be for simple uses, as the base class only offers a limited selection of wrapper methods around the underlying ValueTree.
| T | The type of the CustomParameterTree subclass to be created. |
| type | A unique Identifier for the custom tree type. |
|
protected |
Create a custom piece of state for this Kwidget. This will create a new ValueTree and append it to this Kwidget's state.
| paramID | A unique String identifying the new parameter. |
| value | The initial value of the new parameter. |
|
private |
| std::unique_ptr< KwidgetGUI > krotos::Kwidget::createControls | ( | ) |
|
protectedpure virtual |
Override this method to define the type of KwidgetGUI used by this Kwidget.
Implemented in krotos::Kwidget_Adsr, krotos::Kwidget_AudioOut, krotos::Kwidget_ConvolutionReverb, krotos::Kwidget_CoreEngine, krotos::Kwidget_Filter, krotos::Kwidget_Lfo, krotos::Kwidget_MacroControls, krotos::Kwidget_MacroSlider, krotos::Kwidget_MoogVcf, krotos::Kwidget_OfflineAnalyser, krotos::Kwidget_Pan, krotos::Kwidget_PhaseVocoder, krotos::Kwidget_Recorder, krotos::Kwidget_Reformer, krotos::Kwidget_SAFilter, krotos::Kwidget_Saturation, krotos::Kwidget_Sawtooth, krotos::Kwidget_Scaledadsr, krotos::Kwidget_Sine, krotos::Kwidget_Template, krotos::Kwidget_TriggerButton, and krotos::Kwidget_XyPad.
|
inlinevirtual |
override so your kwidget can create its own nested kwidgets
Reimplemented in krotos::Kwidget_CoreEngine, and krotos::Kwidget_Reformer.
|
protectedpure virtual |
Override this method to define the parameters used by this Kwidget.
Implemented in krotos::Kwidget_Adsr, krotos::Kwidget_AudioOut, krotos::Kwidget_ConvolutionReverb, krotos::Kwidget_CoreEngine, krotos::Kwidget_Filter, krotos::Kwidget_Lfo, krotos::Kwidget_MacroControls, krotos::Kwidget_MacroSlider, krotos::Kwidget_MoogVcf, krotos::Kwidget_OfflineAnalyser, krotos::Kwidget_Pan, krotos::Kwidget_PhaseVocoder, krotos::Kwidget_Recorder, krotos::Kwidget_Reformer, krotos::Kwidget_SAFilter, krotos::Kwidget_Saturation, krotos::Kwidget_Sawtooth, krotos::Kwidget_Scaledadsr, krotos::Kwidget_Sine, krotos::Kwidget_Template, krotos::Kwidget_TriggerButton, and krotos::Kwidget_XyPad.
|
protectedpure virtual |
Override this method to define the type of KwidgetProcessor used by this Kwidget.
Implemented in krotos::Kwidget_Adsr, krotos::Kwidget_AudioOut, krotos::Kwidget_ConvolutionReverb, krotos::Kwidget_CoreEngine, krotos::Kwidget_Filter, krotos::Kwidget_Lfo, krotos::Kwidget_MacroControls, krotos::Kwidget_MacroSlider, krotos::Kwidget_MoogVcf, krotos::Kwidget_OfflineAnalyser, krotos::Kwidget_Pan, krotos::Kwidget_PhaseVocoder, krotos::Kwidget_Recorder, krotos::Kwidget_Reformer, krotos::Kwidget_SAFilter, krotos::Kwidget_Saturation, krotos::Kwidget_Sawtooth, krotos::Kwidget_Scaledadsr, krotos::Kwidget_Sine, krotos::Kwidget_Template, krotos::Kwidget_TriggerButton, and krotos::Kwidget_XyPad.
| std::unique_ptr< KwidgetProcessor > krotos::Kwidget::createVoice | ( | ) |
Creates a voice and exports the KwidgetProcessor object for use in an AudioProcessorGraph.
| Kwidget * krotos::Kwidget::findChildKwidget | ( | String | kiwdgetID | ) |
| void krotos::Kwidget::flushState | ( | ) |
|
inline |
Get a pointer to the most recently used voice.
|
inline |
| T * krotos::Kwidget::getCustomParameter | ( | const Identifier & | type | ) |
Get the CustomParameterTree subclass object of the specified type.
| T | The type of the CustomParameterTree subclass to retrieve. |
| type | A unique Identifier for the custom tree type. |
| CustomParameter * krotos::Kwidget::getCustomParameter | ( | const String & | parameterID | ) |
Get a CustomParameter belonging to this Kwidget's KwidgetProcessor.
| CustomParameterTree * krotos::Kwidget::getCustomParameterTree | ( | const Identifier & | type | ) |
Get a CustomParameterTree belonging to this Kwidget.
| type | The name ("type") of the CustomParameterTree to find |
| StringArray krotos::Kwidget::getDragID | ( | const String & | parameterID | ) |
Returns a String Array containing the current KwidgetID and ParameterID. The enum DragID_Index should be used to index the elements within this array
|
inlinevirtual |
override to return the names of the Gui representation
Reimplemented in krotos::Kwidget_CoreEngine, and krotos::Kwidget_Reformer.
| const String & krotos::Kwidget::getKwidgetID | ( | ) | const |
Get a reference to the unique Kwidget ID.
|
virtual |
Returns a user facing label for the kwidget. By default, this returns the kwidget type. Override this to return a neatly formatted string for a kwidget.
Reimplemented in krotos::Kwidget_MacroSlider.
| const String & krotos::Kwidget::getKwidgetType | ( | ) | const |
Get a reference to the type of the Kwidget.
| String krotos::Kwidget::getKwidgetVersion | ( | ) | const |
| const String & krotos::Kwidget::getKwidgetVersionFromCurrentState | ( | ) | const |
Get the version number of the current loaded state of this kwidget
| int krotos::Kwidget::getNumModulators | ( | ) | const |
| int krotos::Kwidget::getNumVoices | ( | ) | const |
Get the total number of voices.
|
noexcept |
Get a raw pointer to a KParameter belonging to this Kwidget's KwidgetProcessor. Useful for low overhead direct parameter access.
| parameterID | The ID of the parameter to retrieve. |
| const std::vector< std::shared_ptr< KParameter > > & krotos::Kwidget::getParameters | ( | ) | const |
Get the list of KParameters owned by this Kwidget.
|
noexcept |
Get a shared pointer to a KParameter, for use with KParameter::Listener objects and situations where the parameter lifetime goes beyond local scope.
| parameterID | The ID of the parameter to retrieve. |
|
static |
Get the ID of the parent of a nested kwidget
| [in] | childKwidgetID | String ID of the child kwidget |
| const ValueTree & krotos::Kwidget::getState | ( | ) |
Get a const reference to the ValueTree that this Kwidget is using to hold its state.
| int krotos::Kwidget::getTemplateID | ( | ) |
Returns the ID of this kwidgets parent template, if it has one. If not, returns -1.
| KwidgetProcessor * krotos::Kwidget::getVoice | ( | int | idx | ) | const |
Get a pointer to one of this Kwidget's voices.
| void krotos::Kwidget::init | ( | ) |
Initialises the parameters of the Kwidget. This should be called in the first line of the constructor of any concrete child classes.
| bool krotos::Kwidget::isAChildKwidget | ( | ) |
|
virtual |
Reimplemented in krotos::Kwidget_CoreEngine, and krotos::Kwidget_Reformer.
| bool krotos::Kwidget::isModulator | ( | ) | const |
Returns true if this Kwidget is a modulator.
|
inline |
override to return a pointer to the primary Gui for this kwidget
|
virtual |
Send a message to a particular voice that it has been turned off and will receive no more calls to its process function.
| voiceIdx | The index of the voice that is being cleared. |
Reimplemented in krotos::Kwidget_CoreEngine, and krotos::Kwidget_Reformer.
|
virtual |
Send a 'note off' message to a particular voice. Note: Note on and off messages do not by default get sent to child Kwidgets parents of child kwidgets can override these methods and pass the messages to their childern if required If you do override, remember to call the base class first from your new overridden method
| voiceIdx | The index of the voice you would like to turn on. |
| velocity | The velocity of the note event. |
Reimplemented in krotos::Kwidget_CoreEngine, and krotos::Kwidget_Reformer.
|
virtual |
Send a 'note on' message to a particular voice. Note: Note on and off messages do not by default get sent to child Kwidgets parents of child kwidgets can override these methods and pass the messages to their childern if required If you do override, remember to call the base class first from your new overridden method
| voiceIdx | The index of the voice you would like to turn on. |
| midiNote | The integer value of the MIDI note to use. |
| velocity | The velocity of the note event. |
Reimplemented in krotos::Kwidget_CoreEngine, and krotos::Kwidget_Reformer.
| void krotos::Kwidget::notifyAllParametersListeners | ( | ) |
Call every parameter's value changed listeners with their current values.
|
inlinevirtual |
Reimplemented in krotos::Kwidget_CoreEngine, and krotos::Kwidget_Reformer.
| void krotos::Kwidget::removeChildKwidgetFromTree | ( | String | kwidgetID | ) |
| void krotos::Kwidget::removeModulator | ( | const String & | paramID, |
| Kwidget * | modulator, | ||
| int | modulatorIdx ) |
Remove a modulator from one of the parameters owned by this Kwidget.
|
protected |
Set the kwidget version, by default this is "1.0" This should be used when a kwidget is changed in such a way that it is no longer compatible with a previous version.
| kwidgetVersionString | a version number with two digits separated by a period e.g. "1.1" |
| void krotos::Kwidget::setModulatorDepth | ( | const String & | paramID, |
| Kwidget * | modulator, | ||
| int | modulatorIdx, | ||
| float | depth ) |
| void krotos::Kwidget::setModulatorPolarity | ( | const String & | paramID, |
| Kwidget * | modulator, | ||
| int | modulatorIdx, | ||
| KAttachment::Polarity | polarity ) |
|
virtual |
Set the state of the Kwidget using a ValueTree (probably one obtained from the getState() function).
|
private |
|
protected |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |