14namespace tracktion {
inline namespace engine
27 : playHeadState (processStateToUse.playHeadState),
28 processState (processStateToUse)
35 double sampleRate,
int blockSize)
38 nodePlayer.
setNode (std::move (node), sampleRate, blockSize);
57 nodePlayer.
setNode (std::move (newNode));
62 nodePlayer.
setNode (std::move (newNode), sampleRateToUse, blockSizeToUse);
65 void prepareToPlay (
double sampleRateToUse,
int blockSizeToUse)
81 if (splitTimelineRange.isSplit)
83 const auto firstProportion = splitTimelineRange.timelineRange1.getLength() / (
double) pc.referenceSampleRange.
getLength();
87 jassert (firstReferenceRange.getLength() + secondReferenceRange.getLength() == pc.referenceSampleRange.
getLength());
89 const auto firstNumSamples = (choc::buffer::FrameCount)
std::llround (pc.numSamples * firstProportion);
90 const auto secondNumSamples = pc.numSamples - firstNumSamples;
91 jassert (firstNumSamples + secondNumSamples == pc.numSamples);
94 auto destAudio = pc.buffers.audio.getStart (firstNumSamples);
95 auto& destMidi = pc.buffers.midi;
97 processState.
update (nodePlayer.
getSampleRate(), firstReferenceRange, ProcessState::UpdateContinuityFlags::yes);
99 numMisses += nodePlayer.
process (pc1);
103 const auto firstDuration = processState.editTimeRange.getLength();
105 auto destAudio = pc.buffers.audio.getFrameRange ({ firstNumSamples, firstNumSamples + secondNumSamples });
109 processState.
update (nodePlayer.
getSampleRate(), secondReferenceRange, ProcessState::UpdateContinuityFlags::yes);
110 numMisses += nodePlayer.
process (pc2);
113 pc.buffers.midi.mergeFromWithOffset (scratchMidi, firstDuration.inSeconds());
118 processState.
update (nodePlayer.
getSampleRate(), pc.referenceSampleRange, ProcessState::UpdateContinuityFlags::yes);
119 numMisses += nodePlayer.
process (pc);
constexpr ValueType getStart() const noexcept
constexpr ValueType getEnd() const noexcept
constexpr Range withEnd(const ValueType newEnd) const noexcept
constexpr ValueType getLength() const noexcept
Plays back a Node with PlayHeadState and ProcessState.
MultiThreadedNodePlayer(ProcessState &processStateToUse)
Creates an NodePlayer to process a Node.
MultiThreadedNodePlayer(std::unique_ptr< tracktion::graph::Node > node, ProcessState &processStateToUse, double sampleRate, int blockSize)
Creates an NodePlayer to process a Node.
double getSampleRate() const
Returns the current sample rate.
int process(const tracktion::graph::Node::ProcessContext &pc)
Processes a block of audio and MIDI data.
void setNumThreads(size_t numThreads)
Sets the number of threads to use for rendering.
void clearNode()
Clears the Node currently playing.
Plays back a node with mutiple threads.
double getSampleRate() const
Returns the current sample rate.
int process(const Node::ProcessContext &)
Process a block of the Node.
void clearNode()
Clears the current Node.
void setNode(std::unique_ptr< Node >)
Sets the Node to process.
Node * getNode()
Returns the current Node.
void prepareToPlay(double sampleRateToUse, int blockSizeToUse)
Prepares the current Node to be played.
void setNumThreads(size_t)
Sets the number of threads to use for rendering.
Main graph Node processor class.
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...
void setReferenceSampleRange(juce::Range< int64_t > sampleRange)
Sets the reference sample count, adjusting the timeline if the play head is playing.
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 the state of a process call.
void update(double sampleRate, juce::Range< int64_t > referenceSampleRange, UpdateContinuityFlags)
Updates the internal state based on a reference sample range.