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

« « « Anklang Documentation
Loading...
Searching...
No Matches
tracktion_Modifier.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{
19 virtual ~ModifierTimer() = default;
20 virtual void updateStreamTime (TimePosition editTime, int numSamples) = 0;
21};
22
23//==============================================================================
35 public Selectable,
38{
41
43 Modifier (Edit&, const juce::ValueTree&);
45 ~Modifier() override;
46
48 void remove();
49
51 virtual void initialise() = 0;
52
56 virtual float getCurrentValue() = 0;
57
60
61 //==============================================================================
63 virtual juce::StringArray getMidiInputNames() { return {}; }
64
66 virtual juce::StringArray getAudioInputNames() { return {}; }
67
70 {
71 none,
72 preFX,
73 postFX
74 };
75
78
79 //==============================================================================
81 virtual void initialise (double /*sampleRate*/, int /*blockSizeSamples*/) {}
83 virtual void deinitialise() {}
85 virtual void applyToBuffer (const PluginRenderContext&) {}
86
87 //==============================================================================
89 bool baseClassNeedsInitialising() const noexcept { return initialiseCount == 0; }
91 void baseClassInitialise (double sampleRate, int blockSizeSamples);
96
97 //==============================================================================
99 static constexpr TimeDuration maxHistoryTime = TimeDuration::fromSeconds (3.0);
100
106
110 float getValueAt (TimeDuration numSecondsBeforeNow) const;
111
116 std::vector<float> getValues (TimeDuration numSecondsBeforeNow) const;
117
118 //==============================================================================
126 double getSampleRate() const { return sampleRate; }
127
129 void selectableAboutToBeDeleted() override;
130
131protected:
133 void setEditTime (TimePosition newEditTime) { lastEditTime = newEditTime; }
134
135private:
136 int initialiseCount = 0;
137 double sampleRate = 44100.0;
138 std::atomic<TimePosition> lastEditTime { TimePosition() };
139
140 class ValueFifo;
141 std::unique_ptr<ValueFifo> valueFifo, messageThreadValueFifo;
142 mutable choc::fifo::SingleReaderSingleWriterFIFO<std::pair<int, float>> valueFifoQueue;
143};
144
145//==============================================================================
150 private ValueTreeObjectList<Modifier>
151{
152public:
158 ~ModifierList() override;
159
161 static bool isModifier (const juce::Identifier&);
162
165
166 //==============================================================================
169
170 //==============================================================================
172 bool isSuitableType (const juce::ValueTree&) const override;
174 Modifier* createNewObject (const juce::ValueTree&) override;
176 void deleteObject (Modifier*) override;
177
179 void newObjectAdded (Modifier*) override;
181 void objectRemoved (Modifier*) override;
183 void objectOrderChanged() override;
184
185 Edit& edit;
186 juce::ValueTree state;
187};
188
189//==============================================================================
191template<typename ModifierType>
193{
195
196 for (auto m : ml.getModifiers())
197 if (auto type = dynamic_cast<ModifierType*> (m))
198 mods.add (type);
199
200 return mods;
201}
202
204Modifier::Ptr findModifierForID (ModifierList&, EditItemID);
205
206}} // namespace tracktion { inline namespace engine
ObjectClass * add(ObjectClass *newObject)
Base class for elements that have some kind of automatable parameters.
The Tracktion Edit class!
Holds a list of Modifiers that have been added to a Track.
static bool isModifier(const juce::Identifier &)
Tests whether the Identifier is of a known Modifier type.
juce::ReferenceCountedObjectPtr< Modifier > insertModifier(juce::ValueTree, int index, SelectionManager *)
Adds a Modifier from a state at a given index.
juce::ReferenceCountedArray< Modifier > getModifiers() const
Returns all the Modifiers in the list.
Base class for things that can be selected, and whose properties can appear in the properties panel.
Manages a list of items that are currently selected.
Modifier::Ptr findModifierForID(ModifierList &ml, EditItemID modifierID)
Returns a Modifier if it can be found in the list.
juce::Array< ModifierType * > getModifiersOfType(const AutomatableParameter &ap)
Returns all the modifers in use of a specific type.
Represents a duration in real-life time.
Represents a position in real-life time.
Connects a modifier source to an AutomatableParameter.
Base class for things that can be used to modify parameters.
Base class for objects which need to know about the global Edit time every block.
Bass class for parameter Modifiers.
virtual AutomatableParameter::ModifierAssignment * createAssignment(const juce::ValueTree &)=0
Must return a new ModifierAssignment for a given state.
virtual void initialise(double, int)
Sub classes should implement this to initialise the Modifier.
virtual juce::StringArray getAudioInputNames()
Can return an array of names represeting audio inputs.
virtual float getCurrentValue()=0
Must return the current value of the modifier.
void selectableAboutToBeDeleted() override
Called just before the selectable is about to be deleted so any subclasses should still be valid at t...
juce::ValueTree state
Modifier internal state.
void baseClassApplyToBuffer(const PluginRenderContext &)
Updates internal value history and calls the subclass's applyToBuffer method.
virtual void applyToBuffer(const PluginRenderContext &)
Sub classes should implement this to process the Modifier.
TimePosition getCurrentTime() const
Returns the edit time of the current value.
void setEditTime(TimePosition newEditTime)
Subclasses can call this to update the edit time of the current value.
virtual void deinitialise()
Sub classes should implement this to deinitialise the Modifier.
void baseClassInitialise(double sampleRate, int blockSizeSamples)
Initialises the Modifier.
static constexpr TimeDuration maxHistoryTime
The max number of seconds of modifier value history that is stored.
virtual juce::StringArray getMidiInputNames()
Can return an array of names represeting MIDI inputs.
virtual void initialise()=0
Call this once after construction to connect it to the audio graph.
juce::CachedValue< juce::Colour > colour
Colour property.
AutomatableParameter::Ptr enabledParam
Parameter to change the enabled state.
void remove()
Removes this Modifier from its parent Track.
juce::CachedValue< float > enabled
Enabled property.
bool baseClassNeedsInitialising() const noexcept
Returns true if the Modifier needs initialising.
virtual ProcessingPosition getProcessingPosition()
Should return the position in the plugin chain that this Modifier should be processed.
void baseClassDeinitialise()
Deinitialises the Modifier.
float getValueAt(TimeDuration numSecondsBeforeNow) const
Returns the value of the at a given time in the past.
ProcessingPosition
Determines the position in the FX chain where the modifier should be processed.
@ none
The Modifier needs no processing.
@ preFX
The Modifier is processed before the plugn chain.
@ postFX
The Modifier is processed after the plugn chain.
double getSampleRate() const
Returns the sample rate the Modifier has been initialised with.
std::vector< float > getValues(TimeDuration numSecondsBeforeNow) const
Returns a vector of previous sample values.
The context passed to plugin render methods to provide it with buffers to fill.