11namespace tracktion {
inline namespace engine
14MacroParameter::Assignment::Assignment (
const juce::ValueTree& v,
const MacroParameter& mp)
15 : AutomatableParameter::ModifierAssignment (mp.edit, v),
16 macroParamID (EditItemID::fromVar (mp.paramID))
24 return mp->paramID == macroParamID.toString();
33 automatable, { 0.0f, 1.0f }),
36 jassert (EditItemID::fromID (v).isValid());
39 value.
referTo (state, IDs::value, um, 0.5f);
40 defaultValue.
referTo (state, IDs::defaultValue, um);
41 macroName.
referTo (state, IDs::name, um);
43 attachToCurrentValue (value);
46MacroParameter::~MacroParameter()
48 detachFromCurrentValue();
51void MacroParameter::initialise()
61void MacroParameter::parameterChanged (
float,
bool byAutomation)
67 TRACKTION_ASSERT_MESSAGE_THREAD
71 if (! ap->automatableEditElement.isBeingActivelyPlayed())
79 for (
auto mp : mpl->getMacroParameters())
80 if (EditItemID::fromVar (mp->paramID) == pid)
91 macroParameterList (mpl), edit (mpl.edit)
93 jassert (v.hasType (IDs::MACROPARAMETERS));
112 for (
auto& p : macroParameters)
123 for (
auto& p : macroParameters)
135 return v.hasType (IDs::MACROPARAMETER);
141 macroParameters.
add (mp);
142 macroParameterList.addAutomatableParameter (mp);
149 macroParameterList.deleteParameter (mp);
158 p->removeModifier (*mp);
161 t->hideAutomatableParametersForSource (EditItemID::fromVar (mp->paramID));
170 if (v.hasType (IDs::MACROPARAMETER) && i == IDs::name)
171 macroParameterList.rebuildParameterTree();
182 jassert (state.hasType (IDs::MACROPARAMETERS));
189MacroParameterList::~MacroParameterList()
191 TRACKTION_ASSERT_MESSAGE_THREAD
196 TRACKTION_ASSERT_MESSAGE_THREAD
203 auto mp = list->objects.getLast();
212void MacroParameterList::removeMacroParameter (MacroParameter& mp)
214 TRACKTION_ASSERT_MESSAGE_THREAD
220 auto paramID = EditItemID::fromVar (mp.paramID);
223 t->hideAutomatableParametersForSource (paramID);
227 if (mp.state.getParent() == state)
235void MacroParameterList::hideMacroParametersFromTracks()
const
239 TRACKTION_ASSERT_MESSAGE_THREAD
242 for (
auto mp : getMacroParameters())
244 auto paramID = EditItemID::fromVar (mp->paramID);
247 t->hideAutomatableParametersForSource (paramID);
253 return list->getMacroParameters();
256void MacroParameterList::visitMacroParameters (
const std::function<
void(AutomatableParameter&)>& visit)
const
258 list->visitMacroParameters (visit);
261Track* MacroParameterList::getTrack()
const
263 TRACKTION_ASSERT_MESSAGE_THREAD
278 if (p->getMacroParameterList() == mpl)
286 : ownerEdit (e), parentStateForList (p)
290 if (existing.isValid())
296 return macroParameterList.get();
301 if (macroParameterList ==
nullptr)
304 return *macroParameterList;
309 if (macroParameterList !=
nullptr)
310 return macroParameterList->getMacroParameters();
void referTo(ValueTree &tree, const Identifier &property, UndoManager *um)
bool isValid() const noexcept
void removeObject(ObjectClass *objectToRemove)
void ensureStorageAllocated(const int minNumElements)
ObjectClass * add(ObjectClass *newObject)
void removeChild(const ValueTree &child, UndoManager *undoManager)
void addChild(const ValueTree &child, int index, UndoManager *undoManager)
ValueTree getParent() const noexcept
ValueTree getChildWithName(const Identifier &type) const
ValueTree getOrCreateChildWithName(const Identifier &type, UndoManager *undoManager)
Base class for elements that have some kind of automatable parameters.
void restoreChangedParametersFromState()
Restores the value of any explicitly set parameters.
void updateFromAutomationSources(TimePosition)
Updates the parameter and modifier values from its current automation sources.
const EditItemID itemID
Every EditItem has an ID which is unique within the edit.
The Tracktion Edit class!
TransportControl & getTransport() const noexcept
Returns the TransportControl which is used to stop/stop/position playback and recording.
bool isLoading() const
Returns true if the Edit's not yet fully loaded.
juce::UndoManager & getUndoManager() noexcept
Returns the juce::UndoManager used for this Edit.
EditItemID createNewItemID() const
Returns a new EditItemID to use for a new EditItem.
MacroParameterList * getMacroParameterList()
If no parameters have been created, this may return nullptr.
MacroParameterList & getMacroParameterListForWriting()
This ensures that the list has been created.
MacroParameterElement(Edit &, const juce::ValueTree &)
Constructor.
A MacroParameter is an AutomatableParameter which is a collection of Mappings.
TimePosition getPosition() const
Returns the current transport position.
#define TRANS(stringLiteral)
Track * findTrackForState(const Edit &edit, const juce::ValueTree &v)
Returns the Track with a given state if contained in the Edit.
juce::ReferenceCountedArray< AutomatableParameter > getAllParametersBeingModifiedBy(Edit &edit, AutomatableParameter::ModifierSource &m)
Iterates an Edit looking for all parameters that are being modified by the given ModifierSource.
juce::Array< MacroParameterList * > getAllMacroParameterLists(const Edit &edit)
Returns all the MacroParameterLists in an Edit.
juce::Array< Track * > getAllTracks(const Edit &edit)
Returns all the tracks in an Edit.
MacroParameter::Ptr getMacroParameterForID(Edit &e, EditItemID pid)
Searched the Edit for a MacroParameter with this ID.
Plugin::Array getAllPlugins(const Edit &edit, bool includeMasterVolume)
Returns all the plugins in a given Edit.
Plugin::Ptr getOwnerPlugin(MacroParameterList *mpl)
If this MacroParameterList belongs to an Plugin, this will return it.
Base class for things that can be used to modify parameters.
ID for objects of type EditElement - e.g.
static bool isTrack(const juce::ValueTree &) noexcept
Returns true if the given ValeTree is for a known Track type.