121 {
123 const size_t blocksCount =
RoundUpUnsafe(samplesCount, blockSize);
124
125 for (size_t blockIndex = startingBlock; blockIndex < blocksCount;
126 ++blockIndex)
127 {
128 const size_t samplesInBlock =
129 std::min(blockSize, samplesCount - blockIndex * blockSize);
130
131 float min = std::numeric_limits<float>::infinity();
132 float max = -std::numeric_limits<float>::infinity();
133
134 double sqSum = 0.0;
135
136 auto samples = bufferSamples + blockIndex * blockSize;
137
138 for (size_t sampleIndex = 0; sampleIndex < samplesInBlock;
139 ++sampleIndex)
140 {
141 const float sample = *samples++;
142
144 max = std::max(max, sample);
145
146 const double dbl = sample;
147
148 sqSum += dbl * dbl;
149 }
150
151 const auto rms =
static_cast<float>(
std::sqrt(sqSum / samplesInBlock));
152
154 }
155
158 sizeof(CacheItem) * blocksCount / sizeof(float));
159
160 std::memmove(ptr,
mCachedData.data(),
sizeof(CacheItem) * blocksCount);
161 }
auto RoundUpUnsafe(LType numerator, RType denominator) noexcept
Returns a rounded up integer result for numerator / denominator.
size_t mLastProcessedSample
std::vector< CacheItem > mCachedData
__finl float_x4 __vecc sqrt(const float_x4 &a)
float * GetWritePointer(size_t floatsCount)
Gets a pointer to a data buffer enough to store floatsCount floats.