27 : playHeadState (processStateToUse.playHeadState),
28 processState (processStateToUse)
36 : playHeadState (processStateToUse.playHeadState),
37 processState (processStateToUse),
38 nodePlayer (
std::move (poolCreator),
std::move (audioWorkgroup))
45 double sampleRate,
int blockSize,
49 nodePlayer.
setNode (std::move (node), sampleRate, blockSize);
68 nodePlayer.
setNode (std::move (newNode));
73 nodePlayer.
setNode (std::move (newNode), sampleRateToUse, blockSizeToUse);
76 void prepareToPlay (
double sampleRateToUse,
int blockSizeToUse)
92 if (splitTimelineRange.isSplit)
94 const auto firstRangeLength = splitTimelineRange.timelineRange1.getLength();
96 numMisses += processReferenceRange (pc, pc.referenceSampleRange.
withLength (firstRangeLength));
97 numMisses += processReferenceRange (pc, pc.referenceSampleRange.
withStart (pc.referenceSampleRange.
getStart() + firstRangeLength));
101 numMisses += processReferenceRange (pc, pc.referenceSampleRange);
120 void enablePooledMemoryAllocations (
bool enablePooledMemory)
126 void enableNodeMemorySharing (
bool enableNodeMemorySharing)
128 nodePlayer.enableNodeMemorySharing (enableNodeMemorySharing);
133 ProcessState& processState;
134 MidiMessageArray scratchMidi;
142 const auto originalReferenceLength = (
double) pc.referenceSampleRange.
getLength();
144 (subReferenceSampleRange.
getEnd() - pc.referenceSampleRange.
getStart()) / originalReferenceLength);
146 const auto startSample = (choc::buffer::FrameCount)
std::llround (proportion.getStart() * pc.numSamples);
147 const auto endSample = (choc::buffer::FrameCount)
std::llround (proportion.getEnd() * pc.numSamples);
148 const choc::buffer::FrameRange sampleRange { startSample, endSample };
150 auto destAudio = pc.buffers.audio.getFrameRange (sampleRange);
152 return { sampleRange.size(), subReferenceSampleRange, { destAudio, pc.buffers.midi } };
157 return processTempoChanges (getSubProcessContext (pc, referenceSampleRange));
166 processState.update (sampleRate, pc.referenceSampleRange, ProcessState::UpdateContinuityFlags::no);
167 const auto timeRange = processState.editTimeRange;
169 if (
auto tempoPosition = processState.getTempoSequencePosition())
171 double startProportion = 0.0;
172 auto lastEventPosition = timeRange.getStart();
176 const auto nextTempoChangePosition = tempoPosition->getTimeOfNextChange();
178 if (nextTempoChangePosition == lastEventPosition)
181 if (! timeRange.contains (nextTempoChangePosition))
184 const double proportion = (nextTempoChangePosition - timeRange.getStart()) / timeRange.getLength();
185 const auto numSamples =
static_cast<decltype(pc.numSamples)
> (
std::llround (pc.numSamples * proportion));
186 lastEventPosition = nextTempoChangePosition;
189 if (numSamples < 128)
192 processSubRange (pc, { startProportion, proportion });
193 startProportion = proportion;
197 if (startProportion < 1.0)
198 processSubRange (pc, { startProportion, 1.0 });
202 processSubRange (pc, { 0.0, 1.0 });
210 assert (pc.numSamples > 0);
219 const auto startSample = (choc::buffer::FrameCount)
std::llround (proportion.
getStart() * pc.numSamples);
220 const auto endSample = (choc::buffer::FrameCount)
std::llround (proportion.
getEnd() * pc.numSamples);
221 const choc::buffer::FrameRange sampleRange { startSample, endSample };
223 if (sampleRange.size() == 0)
226 auto destAudio = pc.buffers.audio.getFrameRange (sampleRange);
230 processState.update (sampleRate, referenceRange, ProcessState::UpdateContinuityFlags::yes);
231 const auto numMisses = nodePlayer.
process (pc2);
234 const auto offset = TimeDuration::fromSamples (startReferenceSample - pc.referenceSampleRange.
getStart(), sampleRate);
235 pc.buffers.midi.mergeFromWithOffset (scratchMidi, offset.inSeconds());
Struct to describe a single iteration of a process call.