128 {
130 const size_t blocksCount =
RoundUpUnsafe(samplesCount, blockSize);
131
132 for (size_t blockIndex = startingBlock; blockIndex < blocksCount;
133 ++blockIndex)
134 {
135 const size_t samplesInBlock =
136 std::min(blockSize, samplesCount - blockIndex * blockSize);
137
138 float min = std::numeric_limits<float>::infinity();
139 float max = -std::numeric_limits<float>::infinity();
140
141 double sqSum = 0.0;
142
143 auto samples = bufferSamples + blockIndex * blockSize;
144
145 for (size_t sampleIndex = 0; sampleIndex < samplesInBlock;
146 ++sampleIndex)
147 {
148 const float sample = *samples++;
149
151 max = std::max(max, sample);
152
153 const double dbl = sample;
154
155 sqSum += dbl * dbl;
156 }
157
158 const auto rms =
static_cast<float>(
std::sqrt(sqSum / samplesInBlock));
159
161 }
162
165 sizeof(CacheItem) * blocksCount / sizeof(float));
166
167 std::memmove(ptr,
mCachedData.data(),
sizeof(CacheItem) * blocksCount);
168 }
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.