11namespace tracktion {
inline namespace engine
24 notifyListenersOfDeletion();
27 bool isParameterActive()
const override
30 return ! rp->linkInputs;
46 notifyListenersOfDeletion();
49 bool isParameterActive()
const override
52 return ! rp->linkOutputs;
68 notifyListenersOfDeletion();
72 float stringToValue (
const juce::String& s)
override {
return dbStringToDb (s); }
78 rackTypeID (
EditItemID::fromProperty (state, IDs::rackType)),
79 type (info.edit.getRackList().getRackTypeForID (rackTypeID))
85 leftInDb = addParam (
"left input level",
TRANS(
"Left input level"), { (
float) RackInstance::rackMinDb, (
float) RackInstance::rackMaxDb });
86 addAutomatableParameter (rightInDb =
new RackInputAutomatableParameter (
"right input level",
TRANS(
"Right input level"), *
this, { (
float) RackInstance::rackMinDb, (
float) RackInstance::rackMaxDb }));
87 leftOutDb = addParam (
"left output level",
TRANS(
"Left output level"), { (
float) RackInstance::rackMinDb, (
float) RackInstance::rackMaxDb });
88 addAutomatableParameter (rightOutDb =
new RackOutputAutomatableParameter (
"right output level",
TRANS(
"Right output level"), *
this, { (
float) RackInstance::rackMinDb, (
float) RackInstance::rackMaxDb }));
90 auto um = getUndoManager();
92 dryValue.referTo (state, IDs::dry, um);
93 wetValue.referTo (state, IDs::wet, um, 1.0f);
94 leftInValue.referTo (state, IDs::leftInDb, um);
95 rightInValue.referTo (state, IDs::rightInDb, um);
96 leftOutValue.referTo (state, IDs::leftOutDb, um);
97 rightOutValue.referTo (state, IDs::rightOutDb, um);
99 leftInputGoesTo.referTo (state, IDs::leftTo, um, 1);
100 rightInputGoesTo.referTo (state, IDs::rightTo, um, 2);
101 leftOutputComesFrom.referTo (state, IDs::leftFrom, um, 1);
102 rightOutputComesFrom.referTo (state, IDs::rightFrom, um, 2);
104 dryGain->attachToCurrentValue (dryValue);
105 wetGain->attachToCurrentValue (wetValue);
106 leftInDb->attachToCurrentValue (leftInValue);
107 rightInDb->attachToCurrentValue (rightInValue);
108 leftOutDb->attachToCurrentValue (leftOutValue);
109 rightOutDb->attachToCurrentValue (rightOutValue);
112RackInstance::~RackInstance()
114 notifyListenersOfDeletion();
116 dryGain->detachFromCurrentValue();
117 wetGain->detachFromCurrentValue();
118 leftInDb->detachFromCurrentValue();
119 rightInDb->detachFromCurrentValue();
120 leftOutDb->detachFromCurrentValue();
121 rightOutDb->detachFromCurrentValue();
126 return createValueTree (IDs::PLUGIN,
127 IDs::type, RackInstance::xmlTypeName,
128 IDs::rackType, type.rackID);
134 return getName() +
" (" +
TRANS(
"Double-click to edit the rack") +
")";
136 return getName() +
" (" +
TRANS(
"Click to edit the rack") +
")";
139const char* RackInstance::xmlTypeName =
"rack";
143 return type !=
nullptr ? type->rackName
144 :
TRANS(
"Rack type missing!");
154 struct PluginIndexAndPos
156 bool operator< (
const PluginIndexAndPos& other)
const {
return x < other.x; }
162 auto rackPlugins = thisType->getPlugins();
165 for (
int i = 0; i < rackPlugins.size(); ++i)
166 if (
auto rackPlugin = rackPlugins[i])
167 pluginLocations.
add ({ thisType->getPluginPosition (rackPlugin).x, rackPlugin });
171 if (
auto list = getOwnerList())
173 auto index = list->getPlugins().indexOf (
this);
175 for (
int i = pluginLocations.
size(); --i >= 0;)
177 auto srcPlugin = pluginLocations.
getUnchecked (i).plugin;
178 jassert (srcPlugin !=
nullptr);
179 srcPlugin->flushPluginStateToValueTree();
180 auto pluginState = srcPlugin->state;
184 auto newState = srcPlugin->state.createCopy();
185 EditItemID::remapIDs (newState,
nullptr, edit);
186 jassert (EditItemID::fromID (newState) != EditItemID::fromID (srcPlugin->state));
187 pluginState = newState;
190 if (
auto p = list->insertPlugin (pluginState, index))
213 inputChoices.
add (getNoPinName());
214 auto inputs = type->getInputNames();
216 for (
int i = 1; i < inputs.size(); ++i)
218 if (includeNumberPrefix)
221 inputChoices.
add (inputs[i]);
234 outputChoices.
add (getNoPinName());
235 auto outputs = type->getOutputNames();
237 for (
int i = 1; i < outputs.size(); ++i)
239 if (includeNumberPrefix)
242 outputChoices.
add (outputs[i]);
246 return outputChoices;
251 return TRANS(
"<none>");
254void RackInstance::setInputName (Channel c,
const juce::String& inputName)
256 auto index = getInputChoices (
false).
indexOf (inputName);
266 case left: leftInputGoesTo = index;
break;
267 case right: rightInputGoesTo = index;
break;
272void RackInstance::setOutputName (Channel c,
const juce::String& outputName)
274 auto index = getOutputChoices (
false).
indexOf (outputName);
284 case left: leftOutputComesFrom = index;
break;
285 case right: rightOutputComesFrom = index;
break;
293 type->registerInstance (
this, info);
299 type->deregisterInstance (
this);
307 type->updateAutomatableParamPositions (
time);
310double RackInstance::getLatencySeconds()
325 return TRANS(
"Plugin Rack");
328void RackInstance::setInputLevel (Channel c,
float v)
330 const auto& param = c == left ? leftInDb : rightInDb;
336 const auto& linkedParam = c == left ? rightInDb : leftInDb;
341void RackInstance::setOutputLevel (Channel c,
float v)
343 const auto& param = c == left ? leftOutDb : rightOutDb;
349 const auto& linkedParam = c == left ? rightOutDb : leftOutDb;
356 const auto& input = c == left ? leftInputGoesTo : rightInputGoesTo;
358 if (type ==
nullptr || input < 0 || type->getInputNames()[input].isEmpty())
359 return getNoPinName();
361 return juce::String (input) +
". " + type->getInputNames()[input];
366 const auto& ouput = c == left ? leftOutputComesFrom : rightOutputComesFrom;
368 if (type ==
nullptr || ouput < 0 || type->getOutputNames()[ouput].isEmpty())
369 return getNoPinName();
371 return juce::String (ouput) +
". " + type->getOutputNames()[ouput];
ElementType getUnchecked(int index) const
int size() const noexcept
ElementType * begin() noexcept
ElementType * end() noexcept
void add(const ElementType &newElement)
static Type gainToDecibels(Type gain, Type minusInfinityDb=Type(defaultMinusInfinitydB))
static String toString(Type decibels, int decimalPlaces=2, Type minusInfinityDb=Type(defaultMinusInfinitydB), bool shouldIncludeSuffix=true, StringRef customMinusInfinityString={})
int indexOf(StringRef stringToLookFor, bool ignoreCase=false, int startIndex=0) const
void add(String stringToAdd)
virtual void updateAutomatableParamPosition(TimePosition)
Updates all the auto params to their positions at this time.
RackTypeList & getRackList() const noexcept
Returns the RackTypeList which contains all the RackTypes for the Edit.
UIBehaviour & getUIBehaviour() const
Returns the UIBehaviour class.
PluginManager & getPluginManager() const
Returns the PluginManager instance.
virtual void deleteFromParent()
Attempts to delete this plugin, whether it's a master plugin, track plugin, etc.
juce::String getSelectableDescription() override
Subclasses must return a description of what they are.
void applyToBuffer(const PluginRenderContext &) override
Process the next block of data.
juce::String getTooltip() override
default returns the name, others can return special stuff if needed
void prepareForNextBlock(TimePosition) override
Called between successive rendering blocks.
juce::String getName() const override
The name of the type, e.g.
void deinitialise() override
Called after play stops to release resources.
void updateAutomatableParamPosition(TimePosition) override
Updates all the auto params to their positions at this time.
Manages a list of items that are currently selected.
virtual void showWarningMessage(const juce::String &message)
Should display a temporary warning message.
#define TRANS(stringLiteral)
juce::Array< RackInstance * > getRackInstancesInEditForType(const RackType &rt)
Returns all of the instances of a specific RackType in an Edit.
Passed into Plugins when they are being initialised, to give them useful contextual information that ...
Represents a position in real-life time.
ID for objects of type EditElement - e.g.
The context passed to plugin render methods to provide it with buffers to fill.