37class [[gnu::hot]] TimeStretcher {
39 TimeStretcher() =
default;
41 int32_t numChannels, int32_t phaseIncrement, int32_t timeStretchRatio, int32_t playDirection,
42 int32_t priorityRating, int32_t fudgingNumSamplesTilLoop, LoopType loopingType);
44 int32_t numChannels, int32_t timeStretchRatio, int32_t phaseIncrement, uint64_t combinedIncrement,
45 int32_t playDirection, LoopType loopingType, int32_t priorityRating);
46 void beenUnassigned();
47 void unassignAllReasonsForPercLookahead();
48 void unassignAllReasonsForPercCacheClusters();
49 void unassignAllReasonsForHopBack();
51 int32_t timeStretchRatio, int32_t phaseIncrement, uint64_t combinedIncrement, int32_t playDirection,
52 LoopType loopingType, int32_t priorityRating);
54 void rememberPercCacheCluster(
Cluster* cluster);
55 void updateClustersForPercLookahead(
Sample* sample, uint32_t sourceBytePos, int32_t playDirection,
56 int32_t priorityRating);
58 int32_t getSamplePos(int32_t playDirection);
59 bool allocateBuffer(int32_t numChannels);
61 void readFromBuffer(int32_t* oscBufferPos, int32_t numSamples, int32_t numChannels,
62 int32_t numChannelsAfterCondensing, int32_t sourceAmplitudeNow, int32_t amplitudeIncrementNow,
63 int32_t* bufferReadPos);
65 void setupCrossfadeFromCache(
SampleCache* cache, int32_t cacheBytePos, int32_t numChannels);
67#if TIME_STRETCH_ENABLE_BUFFER
68 void reassessWhetherToBeFillingBuffer(int32_t phaseIncrement, int32_t timeStretchRatio,
69 int32_t newBufferFillingMode, int32_t numChannels);
74 uint32_t crossfadeProgress;
75 uint32_t crossfadeIncrement;
77 int32_t samplesTilHopEnd;
82 bool olderHeadReadingFromBuffer;
83 bool hasLoopedBackIntoPreMargin;
84 bool playHeadStillActive[2];
85 uint8_t numTimesMissedHop;
87 int32_t olderBufferReadPos;
89#if TIME_STRETCH_ENABLE_BUFFER
90 bool newerHeadReadingFromBuffer;
91 int32_t newerBufferReadPos;
93 uint8_t bufferFillingMode;
94 int32_t bufferWritePos;
95 uint64_t bufferSamplesWritten;
98 Cluster* clustersForPercLookahead[kNumClustersLoadedAhead];
100 Cluster* percCacheClustersNearby[2];
106 Cluster* clustersForHopBack[kNumClustersLoadedAhead];
114 int32_t percCacheFillStartPos;
115 int32_t percCacheFillEndPos;
116 int8_t percCacheFillDirection;
120 int32_t additionalOscPos, int32_t priorityRating, LoopType loopingType);
121 void updateClustersForHopBack(
Sample* sample, int64_t samplePos, int32_t timeStretchRatio, int32_t phaseIncrement,
122 int32_t playDirection, int32_t priorityRating);
123 void keepClusterForHopRetry(
Cluster* cluster);