11namespace tracktion {
inline namespace engine
34 Plugin* getPlugin()
const {
return plugin; }
36 Engine& getEngine()
const noexcept;
37 Edit& getEdit()
const noexcept;
38 Track* getTrack()
const noexcept;
45 void updateFromAttachedValue();
46 void detachFromCurrentValue();
49 virtual juce::String getParameterName()
const {
return paramName; }
50 virtual juce::String getParameterShortName (
int)
const {
return paramName; }
66 float getCurrentValue()
const noexcept {
return currentValue; }
67 float getCurrentNormalisedValue()
const noexcept {
return valueRange.
convertTo0to1 (currentValue); }
69 virtual juce::String valueToString (
float value) {
return valueToStringFunction (value); }
70 virtual float stringToValue (
const juce::String& s) {
return stringToValueFunction (s); }
72 virtual juce::String getCurrentValueAsString() {
return valueToString (getCurrentValue()); }
78 virtual void beginParameterChangeGesture() {}
79 virtual void endParameterChangeGesture() {}
92 bool hasAutomationPoints()
const noexcept {
return getCurve().getNumPoints() > 0; }
173 virtual bool isParameterActive()
const {
return true; }
174 virtual bool isDiscrete()
const {
return false; }
175 virtual int getNumberOfStates()
const {
return 0; }
176 virtual float getValueForState (
int)
const {
return 0; }
177 virtual int getStateForValue (
float)
const {
return 0; }
180 virtual bool hasLabels()
const {
return false; }
181 virtual juce::String getLabelForValue (
float)
const {
return {}; }
182 virtual float snapToState (
float val)
const {
return val; }
194 void midiControllerMoved (
float newPosition);
195 void midiControllerPressed();
198 void curveHasChanged();
226 void addListener (Listener* l) { listeners.add (l); }
227 void removeListener (Listener* l) { listeners.remove (l); }
230 struct AttachedValue;
231 struct AttachedFloatValue;
232 struct AttachedIntValue;
233 struct AttachedBoolValue;
237 SafeSelectable<Edit> editRef;
238 Plugin* plugin =
nullptr;
239 Modifier* modifierOwner =
nullptr;
240 MacroParameterList* macroOwner =
nullptr;
242 std::atomic<float> currentValue { 0.0f }, currentParameterValue { 0.0f }, currentBaseValue { 0.0f }, currentModifierValue { 0.0f };
244 bool updateParametersRecursionCheck =
false;
248 struct AutomationSourceList;
251 AutomationSourceList& getAutomationSourceList()
const;
253 void setParameterValue (
float value,
bool isFollowingCurve);
262 virtual void parameterChanged (
float,
bool ) {}
270template<
typename AssignmentType>
276 if (
auto type =
dynamic_cast<AssignmentType*
> (ass))
277 assignments.
add (type);
283template<
typename ModifierType>
289 if (
auto type =
dynamic_cast<ModifierType*
> (mod))
296template<
typename AssignmentType,
typename ModifierSourceType,
typename EditType>
299 TRACKTION_ASSERT_MESSAGE_THREAD
304 for (
auto* ass : param.getAssignments())
305 if (
auto* m =
dynamic_cast<AssignmentType*
> (ass))
306 if (m->isForModifierSource (source))
314AutomatableParameter::ModifierSource*
getSourceForAssignment (
const AutomatableParameter::ModifierAssignment&);
320AutomatableParameter*
getParameter (AutomatableParameter::ModifierAssignment&);
336template<
typename Type>
354 virtual bool hasAnAutomatableParameter() = 0;
358 virtual void chooseAutomatableParameter (
std::function<
void(AutomatableParameter::Ptr)> handleChosenParam,
362 virtual void startParameterLearn (
std::function<
void(AutomatableParameter::Ptr)>) {}
365 bool isAutomatableParameterBeingDraggedOver()
const;
367 bool isInterestedInDragSource (
const SourceDetails& details)
override;
368 void itemDragEnter (
const SourceDetails& dragSourceDetails)
override;
369 void itemDragExit (
const SourceDetails& dragSourceDetails)
override;
370 void itemDropped (
const SourceDetails& dragSourceDetails)
override;
372 static const char* automatableDragString;
375 bool isAutoParamCurrentlyOver =
false;
387 virtual void draggedOntoAutomatableParameterTargetBeforeParamSelection() = 0;
400 bool isEmpty()
const noexcept {
return points.
size() <= 1; }
403 float getCurrentValue()
noexcept {
return currentValue; }
411 void setPositionInterpolated (
TimePosition newTime)
noexcept;
421 int currentIndex = -1;
422 float currentValue = 0.0f;
int size() const noexcept
void add(const ElementType &newElement)
void call(Callback &&callback)
Range< ValueType > getRange() const noexcept
ValueType convertTo0to1(ValueType v) const noexcept
ObjectClass * add(ObjectClass *newObject)
Base class for elements that have some kind of automatable parameters.
juce::Array< ModifierSource * > getModifiers() const
Returns all the current ModifierSources currently in use by assignments.
Selectable * getOwnerSelectable() const
Returns the thing that you'd select if you wanted to show this param.
void removeModifier(ModifierAssignment &)
Removes an assignment.
void parameterChangeGestureBegin()
Call to indicate this parameter is about to be changed.
bool isCurrentlyRecording() const
true if the parameter been moved while in an automation record mode.
ModifierAssignment::Ptr addModifier(ModifierSource &, float value=1.0f, float offset=0.0f, float curve=0.5f)
Creates an assignment for a given source.
juce::ReferenceCountedArray< ModifierAssignment > getAssignments() const
Returns all the current ModifierAssignments.
bool hasActiveModifierAssignments() const
Returns true if any ModifierSources are currently in use by assignments.
juce::String getSelectableDescription() override
Subclasses must return a description of what they are.
void resetRecordingStatus()
this is called before and after playback or recording.
float getCurrentExplicitValue() const
This is the value that has been set explicity, either by calling setParameter or the plugin telling u...
void updateStream()
Forces the parameter to update its automation stream for reading automation.
void updateFromAutomationSources(TimePosition)
Updates the parameter and modifier values from its current automation sources.
bool isAutomationActive() const
Returns true if the parameter is being dynamically changed somehow, either through automation or a Mo...
float getCurrentBaseValue() const
This is the current base value of the parameter i.e.
float getCurrentModifierValue() const
This is the ammount of the modifier that has been applied to the base value to give the current param...
EditItemID getOwnerID() const
Returns the thing that you'd select if you wanted to show this param.
void parameterChangeGestureEnd()
Call to indicate this parameter has stopped being to be changed.
Components can implement this to let things know which automatable parameter they control.
The Tracktion Edit class!
The Engine is the central class for all tracktion sessions.
Base class for things that can be selected, and whose properties can appear in the properties panel.
Base class for tracks which contain clips and plugins and can be added to Edit[s].
#define TRANS(stringLiteral)
int roundToInt(const FloatType value) noexcept
Type getTypedParamValue(const AutomatableParameter &ap)
Returns an int version of an AutomatableParameter cast to a enum type.
juce::ReferenceCountedArray< AssignmentType > getAssignmentsForSource(EditType &edit, const ModifierSourceType &source)
Iterates an Edit looking for all parameters that assigned to a given parameter.
AutomatableParameter::ModifierSource * getSourceForAssignment(const AutomatableParameter::ModifierAssignment &ass)
Iterates an Edit looking for the source of this assignment.
juce::ReferenceCountedArray< AutomatableParameter > getAllParametersBeingModifiedBy(Edit &edit, AutomatableParameter::ModifierSource &m)
Iterates an Edit looking for all parameters that are being modified by the given ModifierSource.
bool getBoolParamValue(const AutomatableParameter &ap)
Returns a bool version of an AutomatableParameter.
AutomatableParameter * getParameter(AutomatableParameter::ModifierAssignment &assignment)
Iterates an Edit looking for the parameter that this ModifierAssignment has been made from.
juce::ReferenceCountedArray< AssignmentType > getAssignmentsOfType(const AutomatableParameter &ap)
Returns all the Assignments of a specific type.
juce::Array< ModifierType * > getModifiersOfType(const AutomatableParameter &ap)
Returns all the modifers in use of a specific type.
int getIntParamValue(const AutomatableParameter &ap)
Returns an int version of an AutomatableParameter.
Represents a position in real-life time.
virtual void currentValueChanged(AutomatableParameter &)
Called when the current value of the parameter changed, either from setting the parameter,...
virtual void parameterChanged(AutomatableParameter &, float)
Called when the parameter is changed by the plugin or host, not from automation.
virtual void curveHasChanged(AutomatableParameter &)=0
Called when the automation curve has changed, point time, value or curve.
Connects a modifier source to an AutomatableParameter.
virtual bool isForModifierSource(const ModifierSource &) const =0
Must return true if this assigment is for the given source.
Base class for things that can be used to modify parameters.
ID for objects of type EditElement - e.g.