11namespace tracktion {
inline namespace engine
15 : edit (t.edit), track (&t),
16 processMidiWhileMuted (processMidiWhenMuted_)
18 processMidiWhileMuted =
true;
19 callInputWhileMuted = t.processAudioNodesWhileMuted();
21 if (muteForInputsWhenRecording)
24 if (in->isRecordingActive (t.itemID) && in->getTargets().contains (at->itemID))
25 inputDevicesToMuteFor.add (in);
27 wasBeingPlayedFlag = t.shouldBePlayed();
38 const bool isPlayingNow = isBeingPlayed();
41 wasBeingPlayedFlag = isPlayingNow;
51 return callInputWhileMuted || wasBeingPlayedFlag;
56 return processMidiWhileMuted;
59bool TrackMuteState::isBeingPlayed()
const
61 bool playing = track !=
nullptr ? track->shouldBePlayed() : ! edit.
areAnyTracksSolo();
66 for (
int i = inputDevicesToMuteFor.size(); --i >= 0;)
67 if (inputDevicesToMuteFor.getUnchecked (i)->shouldTrackContentsBeMuted (*track))
76 return track !=
nullptr ? (
size_t) track->itemID.getRawID()
84 bool dontMuteIfTrackContentsShouldBeProcessed_)
85 : trackMuteState (
std::move (muteState)), input (
std::move (inputNode)),
86 dontMuteIfTrackContentsShouldBeProcessed (dontMuteIfTrackContentsShouldBeProcessed_)
90 setOptimisations ({ tracktion::graph::ClearBuffers::no,
91 tracktion::graph::AllocateAudioBuffer::yes });
97 auto props = input->getNodeProperties();
98 hash_combine (props.nodeID, trackMuteState->getItemID());
105 return { input.
get() };
110 if (! info.enableNodeMemorySharing)
113 if (input->numOutputNodes > 1)
116 const auto inputNumChannels = input->getNodeProperties().numberOfChannels;
119 if (inputNumChannels >= desiredNumChannels)
121 canUseSourceBuffers =
true;
123 tracktion::graph::AllocateAudioBuffer::no });
129 return input->hasProcessed();
134 trackMuteState->update();
139 if (canUseSourceBuffers)
145 auto sourceBuffers = input->getProcessedOutput();
146 auto destAudioView = pc.buffers.audio;
147 jassert (sourceBuffers.audio.getSize() == destAudioView.getSize());
149 const bool ignoreMuteStates = dontMuteIfTrackContentsShouldBeProcessed && trackMuteState->shouldTrackContentsBeProcessed();
150 const bool wasJustMuted = ! ignoreMuteStates && trackMuteState->wasJustMuted();
151 const bool wasJustUnMuted = ! ignoreMuteStates && trackMuteState->wasJustUnMuted();
153 if (trackMuteState->shouldTrackBeAudible() || ignoreMuteStates)
155 pc.buffers.midi.copyFrom (sourceBuffers.midi);
159 if (wasJustMuted || wasJustUnMuted)
160 copyIfNotAliased (destAudioView, sourceBuffers.audio);
166 destAudioView.clear();
167 pc.buffers.midi.clear();
171 rampBlock (destAudioView, 1.0f, 0.0f);
172 else if (wasJustUnMuted)
173 rampBlock (destAudioView, 0.0f, 1.0f);
177void TrackMutingNode::rampBlock (choc::buffer::ChannelArrayView<float> view,
float start,
float end)
179 if (view.getNumChannels() == 0)
182 auto buffer = tracktion::graph::toAudioBuffer (view);
183 buffer.applyGainRamp (0, buffer.getNumSamples(), start, end);
The Tracktion Edit class!
bool areAnyTracksSolo() const
Returns true if any tracks are soloed.
juce::Array< InputDeviceInstance * > getAllInputDevices() const
Returns all the active InputDeviceInstance[s] in the Edit.
ProjectItemID getProjectItemID() const noexcept
Returns the ProjectItemID of the Edit.
int64_t getRawID() const noexcept
Returns a combined ID as an integer, useful for creating hashes.
bool shouldTrackBeAudible() const
Returns true if the track's mix bus should be audible.
void update()
Call once per block to update the mute status.
bool shouldTrackMidiBeProcessed() const
Returns true if the track's MIDI should be processed to avoid breaks in long notes.
TrackMuteState(Track &, bool muteForInputsWhenRecording, bool processMidiWhenMuted)
Creates a TrackMuteState for a Track.
size_t getItemID() const
Returns the ID for the relevant item, either the Track or Edit.
bool shouldTrackContentsBeProcessed() const
Returns true if the track's contents should be processed e.g.
bool wasJustMuted() const
Returns true if the last block was audible but this one isn't.
void process(ProcessContext &) override
Called when the node is to be processed.
void prepareToPlay(const tracktion::graph::PlaybackInitialisationInfo &) override
Called once before playback begins for each node.
bool isReadyToProcess() override
Should return true when this node is ready to be processed.
std::vector< Node * > getDirectInputNodes() override
Should return all the inputs directly feeding in to this node.
void prefetchBlock(juce::Range< int64_t >) override
Called before once on all Nodes before they are processed.
void preProcess(choc::buffer::FrameCount, juce::Range< int64_t >) override
Called when the node is to be processed, just before process.
tracktion::graph::NodeProperties getNodeProperties() override
Should return the properties of the node.
Base class for tracks which contain clips and plugins and can be added to Edit[s].
void setAudioOutput(Node *sourceNode, const choc::buffer::ChannelArrayView< float > &)
This can be called during your process function to set a view to the output.
void setOptimisations(NodeOptimisations)
This can be called to provide some hints about allocating or playing back a Node to improve efficienc...
void setBufferViewToUse(Node *sourceNode, const choc::buffer::ChannelArrayView< float > &)
This can be called during prepareToPlay to set a BufferView to use which can improve efficiency.
Struct to describe a single iteration of a process call.
Holds some really basic properties of a node.
Passed into Nodes when they are being initialised, to give them useful contextual information that th...