11namespace tracktion {
inline namespace engine
19 : sampleRate (newSampleRate)
23 const auto numSamplesToStore = (
size_t) tracktion::toSamples (maxNumSecondsToStore, newSampleRate);
27 void addValue (
int numSamplesDelta,
float value)
31 const float delta = (value - lastValue) / numSamplesDelta;
32 float alpha = lastValue;
34 while (--numSamplesDelta >= 0)
36 if (++headIndex == values.
size())
40 values[headIndex] = alpha;
46 [[nodiscard]]
float getValueAt (
TimeDuration numSeconds)
const
48 const size_t sampleDelta = (
size_t) tracktion::toSamples (numSeconds, sampleRate);
50 if (sampleDelta > values.
size())
53 const int deltaIndex =
int (headIndex) -
int (sampleDelta);
56 return values[valueIndex];
64 (
size_t) tracktion::toSamples (numSecondsBeforeNow, sampleRate));
65 v.reserve (numValues);
67 int index = (
int) headIndex;
69 for (
int i = (
int) numValues; --i >= 0;)
71 v.push_back (values[(
size_t) index]);
74 index = (
int) values.
size() - 1;
81 double sampleRate = 0.0;
82 float lastValue = 0.0;
98 modifier::getEnabledNames().size(), modifier::getEnabledNames());
103 remapOnTempoChange =
true;
109 jassert (getNumAutomatableParameters() == 0);
117 p->removeModifier (*
this);
120 t->hideAutomatableParametersForSource (
itemID);
127 if (rack.hasType (IDs::RACK))
128 RackType::removeBrokenConnections (rack, um);
134 TRACKTION_ASSERT_MESSAGE_THREAD
135 sampleRate = newSampleRate;
137 if (initialiseCount++ == 0)
146 const int numSamples = (
int) tracktion::toSamples (numSecondsToStore, sampleRate);
147 const int numBlocks = (numSamples / blockSizeSamples) * 2;
148 valueFifoQueue.reset ((
size_t) numBlocks);
157 TRACKTION_ASSERT_MESSAGE_THREAD
160 if (--initialiseCount == 0)
179 if (valueFifoQueue.getFreeSlots() == 0)
182 valueFifoQueue.pop (temp);
185 valueFifoQueue.push (newV);
197 return valueFifo->getValueAt (numSecondsBeforeNow);
204 if (! messageThreadValueFifo)
212 if (! valueFifoQueue.pop (tmp))
215 messageThreadValueFifo->addValue (tmp.
first, tmp.
second);
219 return messageThreadValueFifo->getValues (numSecondsBeforeNow);
224 for (
auto p : getAutomatableParameters())
225 p->detachFromCurrentValue();
227 deleteAutomatableParameters();
233 edit (e), state (parent)
235 jassert (parent.hasType (IDs::MODIFIERS));
236 callBlocking ([
this] { rebuildObjects(); });
246 return i == IDs::LFO || i == IDs::BREAKPOINTOSCILLATOR
247 || i == IDs::STEP || i == IDs::ENVELOPEFOLLOWER
248 || i == IDs::RANDOM || i == IDs::MIDITRACKER;
254 TRACKTION_ASSERT_MESSAGE_THREAD
258 for (
auto m : objects)
267 TRACKTION_ASSERT_MESSAGE_THREAD
272 v.getParent().removeChild (v, um);
274 const auto existing = objects[index];
275 const int indexBefore = existing ==
nullptr ? -1 : parent.indexOf (existing->state);
276 parent.addChild (v, indexBefore, um);
280 for (
auto o : objects)
290 sm->selectOnly (modifier);
308 if (v.hasType (IDs::LFO)) m =
new LFOModifier (edit, v);
310 else if (v.hasType (IDs::STEP)) m =
new StepModifier (edit, v);
312 else if (v.hasType (IDs::RANDOM)) m =
new RandomModifier (edit, v);
319 m->incReferenceCount();
324void ModifierList::deleteObject (Modifier* m)
327 m->decReferenceCount();
338 if (mod->itemID == modifierID)
bool isUsingDefault() const
void referTo(ValueTree &tree, const Identifier &property, UndoManager *um)
bool isValid() const noexcept
ObjectClass * add(ObjectClass *newObject)
void removeChild(const ValueTree &child, UndoManager *undoManager)
ValueTree getParent() const noexcept
Base class for elements that have some kind of automatable parameters.
void resetRecordingStatus()
Marks the end of an automation recording stream.
const EditItemID itemID
Every EditItem has an ID which is unique within the edit.
The Tracktion Edit class!
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.
Holds a list of Modifiers that have been added to a Track.
~ModifierList() override
Destructor.
static bool isModifier(const juce::Identifier &)
Tests whether the Identifier is of a known Modifier type.
ModifierList(Edit &, const juce::ValueTree &)
Creates a ModifierList for an Edit and given state.
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.
Manages a list of items that are currently selected.
#define TRANS(stringLiteral)
IntegerType negativeAwareModulo(IntegerType dividend, const IntegerType divisor) noexcept
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< Track * > getAllTracks(const Edit &edit)
Returns all the tracks in an Edit.
Modifier::Ptr findModifierForID(ModifierList &ml, EditItemID modifierID)
Returns a Modifier if it can be found in the list.
Represents a duration in real-life time.
Represents a position in real-life time.
ID for objects of type EditElement - e.g.
Bass class for parameter Modifiers.
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.
~Modifier() override
Destructor.
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 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.
void baseClassDeinitialise()
Deinitialises the Modifier.
Modifier(Edit &, const juce::ValueTree &)
Creates a Modifier for a given state.
float getValueAt(TimeDuration numSecondsBeforeNow) const
Returns the value of the at a given time in the past.
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.
int bufferNumSamples
The number of samples to write into the audio buffer.
#define CRASH_TRACER
This macro adds the current location to a stack which gets logged if a crash happens.