11namespace tracktion {
inline namespace engine
19 : input (
std::
move (inputNode)),
20 playHeadState (playHeadStateToUse),
21 muteTimes (
std::
move (muteTimes_))
23 jassert (! muteTimes.isEmpty());
25 setOptimisations ({ tracktion::graph::ClearBuffers::no,
26 tracktion::graph::AllocateAudioBuffer::yes });
32 auto props = input->getNodeProperties();
40 return { input.get() };
45 sampleRate = info.sampleRate;
48bool TimedMutingNode::isReadyToProcess()
50 return input->hasProcessed();
57 auto sourceBuffers = input->getProcessedOutput();
58 auto destAudioBlock = pc.buffers.audio;
59 auto& destMidiBlock = pc.buffers.midi;
60 jassert (sourceBuffers.audio.getSize() == destAudioBlock.getSize());
62 destMidiBlock.copyFrom (sourceBuffers.midi);
64 if (! playHeadState.playHead.isPlaying())
67 setAudioOutput (input.get(), sourceBuffers.audio);
71 copy (destAudioBlock, sourceBuffers.audio);
72 processSection (destAudioBlock, tracktion::timeRangeFromSamples (timelineRange, sampleRate));
75void TimedMutingNode::processSection (choc::buffer::ChannelArrayView<float> view, TimeRange editTime)
77 for (
auto r : muteTimes)
79 if (r.overlaps (editTime))
81 auto mute = r.getIntersectionWith (editTime);
89 else if (editTime.contains (mute))
91 auto startSample = tracktion::toSamples (mute.getStart() - editTime.getStart(), sampleRate);
92 auto numSamples = tracktion::toSamples (mute.getLength(), sampleRate);
93 muteSection (view, startSample, numSamples);
95 else if (mute.getEnd() <= editTime.getEnd())
97 auto numSamples = tracktion::toSamples (editTime.getEnd() - mute.getEnd(), sampleRate);
98 muteSection (view, 0, numSamples);
100 else if (mute.getStart() >= editTime.getStart())
103 muteSection (view, startSample, choc::buffer::FrameCount (view.getNumFrames()) - startSample);
108 if (r.getEnd() >= editTime.getEnd())
113void TimedMutingNode::muteSection (choc::buffer::ChannelArrayView<float> block, int64_t startSample, int64_t numSamples)
116 block.getFrameRange ({ (choc::buffer::FrameCount) startSample,
117 (choc::buffer::FrameCount) (startSample + numSamples) }).clear();
Struct to describe a single iteration of a process call.
Determines how this block releates to other previous render blocks and if the play head has jumped in...
constexpr int64_t toSamples(TimePosition, double sampleRate)
Converts a TimePosition to a number of samples.
SplitTimelineRange referenceSampleRangeToSplitTimelineRange(const PlayHead &playHead, juce::Range< int64_t > referenceSampleRange)
Converts a reference sample range to a TimelinePositionWindow which could have two time ranges if the...
Holds some really basic properties of a node.
Passed into Nodes when they are being initialised, to give them useful contextual information that th...