36class SampleLowLevelReader {
38 SampleLowLevelReader() =
default;
39 virtual ~SampleLowLevelReader() { unassignAllReasons(
false); };
40 explicit SampleLowLevelReader(SampleLowLevelReader&,
bool stealReasons =
false);
41 SampleLowLevelReader(SampleLowLevelReader&& other)
noexcept;
42 SampleLowLevelReader& operator=(
const SampleLowLevelReader& other) =
delete;
43 SampleLowLevelReader& operator=(SampleLowLevelReader&& other)
noexcept;
45 void unassignAllReasons(
bool wontBeUsedAgain);
46 void jumpForwardLinear(int32_t numChannels, int32_t byteDepth, uint32_t bitMask, int32_t jumpAmount,
47 int32_t phaseIncrement);
48 void jumpForwardZeroes(int32_t bufferSize, int32_t numChannels, int32_t phaseIncrement);
49 void fillInterpolationBufferRetrospectively(
Sample* sample, int32_t bufferSize, int32_t startI,
50 int32_t playDirection);
51 void jumpBackSamples(
Sample* sample, int32_t numToJumpBack, int32_t playDirection);
55 bool justLooped =
false, int32_t priorityRating = 1);
58 int32_t priorityRating = 1);
60 bool loopingAtLowLevel, int32_t bufferSize,
bool allowEndlessSilenceAtEnd =
false,
61 int32_t priorityRating = 1);
63 void misalignPlaybackParameters(
Sample* sample);
64 void realignPlaybackParameters(
Sample* sample);
67 bool compensateForInterpolationBuffer =
false);
70 int32_t priorityRating);
72 [[nodiscard]]
virtual bool shouldObeyMarkers()
const {
return false; }
76 [[gnu::always_inline]]
void prefetchPlayData(int32_t numBytes, int32_t playDirection)
const {
77 if (clusters[0] ==
nullptr) {
80 char const* pos = currentPlayPos;
81 for (int32_t done = 0; done < numBytes; done += 32) {
82 __builtin_prefetch(pos);
83 pos += 32 * playDirection;
87 void readSamplesNative(int32_t** __restrict__ oscBufferPos, int32_t numSamplesTotal,
Sample* sample,
88 int32_t jumpAmount, int32_t numChannels, int32_t numChannelsAfterCondensing,
89 int32_t* amplitude, int32_t amplitudeIncrement,
TimeStretcher* timeStretcher =
nullptr,
90 bool bufferingToTimeStretcher =
false);
92 void readSamplesResampled(int32_t** __restrict__ oscBufferPos, int32_t numSamples,
Sample* sample,
93 int32_t jumpAmount, int32_t numChannels, int32_t numChannelsAfterCondensing,
94 int32_t phaseIncrement, int32_t* amplitude, int32_t amplitudeIncrement,
95 int32_t bufferSize,
bool writingCache,
char** __restrict__ cacheWritePos,
96 bool* doneAnySamplesYet,
TimeStretcher* timeStretcher,
bool bufferingToTimeStretcher,
100 int32_t numSamples, int32_t numChannels, int32_t numChannelsAfterCondensing,
101 int32_t phaseIncrement, int32_t amplitude, int32_t amplitudeIncrement,
102 bool loopingAtLowLevel, int32_t jumpAmount, int32_t bufferSize,
104 int32_t whichPlayHead, int32_t whichKernel, int32_t priorityRating);
107 void bufferIndividualSampleForInterpolation(int32_t numChannels, int32_t byteDepth,
char* playPosNow);
108 void bufferZeroForInterpolation(int32_t numChannels);
111 char* currentPlayPos{};
112 char* reassessmentLocation{};
113 char* clusterStartLocation{};
114 uint8_t reassessmentAction{};
115 int8_t interpolationBufferSizeLastTime{};
117 deluge::dsp::Interpolator interpolator_{};
119 std::array<Cluster*, kNumClustersLoadedAhead> clusters = {
nullptr,
nullptr};
122 template <
int32_t numChannels,
int32_t numChannelsAfterCondensing>
123 void readSamplesLinear(int32_t* __restrict__& oscBufferPos, int32_t
const* oscBufferEnd, int32_t jumpAmount,
124 int32_t byteDepth, int32_t phaseIncrement, int32_t& amplitude, int32_t amplitudeIncrement,
126 bool assignClusters(SamplePlaybackGuide* guide, Sample* sample, int32_t clusterIndex, int32_t priorityRating);
127 bool fillInterpolationBufferForward(SamplePlaybackGuide* guide, Sample* sample, int32_t interpolationBufferSize,
128 bool loopingAtLowLevel, int32_t numSpacesToFill, int32_t priorityRating);