tracktion-engine 3.0-10-g034fdde4aa5
Tracktion Engine — High level data model for audio applications

« « « Anklang Documentation
Loading...
Searching...
No Matches
tracktion_AutomatableEditItem.h
Go to the documentation of this file.
1 /*
2 ,--. ,--. ,--. ,--.
3 ,-' '-.,--.--.,--,--.,---.| |,-.,-' '-.`--' ,---. ,--,--, Copyright 2024
4 '-. .-'| .--' ,-. | .--'| /'-. .-',--.| .-. || \ Tracktion Software
5 | | | | \ '-' \ `--.| \ \ | | | |' '-' '| || | Corporation
6 `---' `--' `--`--'`---'`--'`--' `---' `--' `---' `--''--' www.tracktion.com
7
8 Tracktion Engine uses a GPL/commercial licence - see LICENCE.md for details.
9*/
10
11namespace tracktion { inline namespace engine
12{
13
18{
19public:
21 ~AutomatableEditItem() override;
22
23 //==============================================================================
24 virtual void flushPluginStateToValueTree();
25 virtual void restorePluginStateFromValueTree (const juce::ValueTree&) { jassertfalse; }
26
27 //==============================================================================
28 juce::Array<AutomatableParameter*> getAutomatableParameters() const;
29 int getNumAutomatableParameters() const;
30 AutomatableParameter::Ptr getAutomatableParameter (int index) const { return automatableParams[index]; }
31 AutomatableParameter::Ptr getAutomatableParameterByID (const juce::String& paramID) const;
32 void visitAllAutomatableParams (const std::function<void(AutomatableParameter&)>& visit) const;
33
34 void deleteParameter (AutomatableParameter*);
35 void deleteAutomatableParameters();
36
37 int indexOfAutomatableParameter (const AutomatableParameter::Ptr&) const;
38
39 AutomatableParameterTree& getParameterTree() const;
40 juce::ReferenceCountedArray<AutomatableParameter> getFlattenedParameterTree() const;
41
43 {
45 virtual void parameterListChanged (AutomatableEditItem&) = 0;
46 };
47
48 void addParameterListChangeListener (ParameterListChangeListener*);
49 void removeParameterListChangeListener (ParameterListChangeListener*);
50
51 //==============================================================================
52 // true if it's got any points on any params
53 bool isAutomationNeeded() const noexcept { return automationActive.load (std::memory_order_relaxed); }
54
55 // updates any automatables to their state at this time
56 void setAutomatableParamPosition (TimePosition);
57
58 // true if it's not been more than a few hundred ms since a block was processed
59 bool isBeingActivelyPlayed() const;
60
63
68
71
74
75 //==============================================================================
76 juce::ValueTree elementState;
77 juce::CachedValue<bool> remapOnTempoChange;
78
79protected:
80 virtual void buildParameterTree() const;
81
82 void updateLastPlaybackTime();
83 void clearParameterList();
84 void addAutomatableParameter (const AutomatableParameter::Ptr&);
85 void rebuildParameterTree();
86
89
92
93private:
94 RealTimeSpinLock activeParameterLock;
95 juce::ReferenceCountedArray<AutomatableParameter> automatableParams, activeParameters;
96 mutable AutomatableParameterTree parameterTree;
97
98 mutable bool parameterTreeBuilt = false;
99 std::atomic<bool> automationActive { false };
100 uint32_t systemTimeOfLastPlayedBlock = 0;
101 TimePosition lastTime;
102
103 struct ParameterChangeListeners : public juce::AsyncUpdater
104 {
105 ParameterChangeListeners (AutomatableEditItem&);
106 AutomatableEditItem& owner;
108 void handleAsyncUpdate() override;
109 };
110
111 std::unique_ptr<ParameterChangeListeners> parameterChangeListeners;
112 void sendListChangeMessage() const;
113
114 //==============================================================================
115 juce::ReferenceCountedArray<AutomatableParameter> getFlattenedParameterTree (AutomatableParameterTree::TreeNode&) const;
116
117 JUCE_DECLARE_WEAK_REFERENCEABLE (AutomatableEditItem)
119};
120
121}} // namespace tracktion { inline namespace engine
Base class for elements that have some kind of automatable parameters.
void resetRecordingStatus()
Marks the end of an automation recording stream.
void restoreChangedParametersFromState()
Restores the value of any explicitly set parameters.
virtual void updateAutomatableParamPosition(TimePosition)
Updates all the auto params to their positions at this time.
void saveChangedParametersToState()
Saves the explicit value of any parameters that have deviated to the state.
void updateActiveParameters()
Iterates all the parameters to find out which ones need to be automated.
void updateParameterStreams(TimePosition)
Updates all the parameter streams to their positions at this time.
Base class for objects that live inside an edit - e.g.
The Tracktion Edit class!
A basic spin lock that uses an atomic_flag to store the locked state so should never result in a syst...
T is_pointer_v
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
#define jassertfalse
#define JUCE_DECLARE_WEAK_REFERENCEABLE(Class)
T load(T... args)
typedef uint32_t
Represents a position in real-life time.