MCPcopy Create free account
hub / github.com/aethersdr/AetherSDR / measureInt16StereoLevelBlock

Function measureInt16StereoLevelBlock

src/core/TxMicChannelNormalizer.cpp:358–385  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

356}
357
358LevelBlock measureInt16StereoLevelBlock(const QByteArray& pcm)
359{
360 LevelBlock block;
361 const int sampleCount = pcm.size() / static_cast<int>(sizeof(int16_t));
362 if (sampleCount <= 0) {
363 return block;
364 }
365
366 const auto* src = reinterpret_cast<const int16_t*>(pcm.constData());
367 const int stereoFrames = sampleCount / 2;
368 for (int i = 0; i < stereoFrames; ++i) {
369 const float left = absInt16(src[i * 2]);
370 const float right = absInt16(src[i * 2 + 1]);
371 const float s = std::max(left, right);
372 block.peak = std::max(block.peak, s);
373 block.sumSq += static_cast<double>(s) * s;
374 ++block.frames;
375 }
376
377 if ((sampleCount % 2) != 0) {
378 const float s = absInt16(src[sampleCount - 1]);
379 block.peak = std::max(block.peak, s);
380 block.sumSq += static_cast<double>(s) * s;
381 ++block.frames;
382 }
383
384 return block;
385}
386
387float rmsFromLevelBlock(const LevelBlock& block)
388{

Callers 3

blockRmsFunction · 0.85

Calls 2

absInt16Function · 0.85
sizeMethod · 0.45

Tested by 2

blockRmsFunction · 0.68