diff options
author | Clyne Sullivan <clyne@bitgloo.com> | 2024-06-10 13:25:48 -0400 |
---|---|---|
committer | Clyne Sullivan <clyne@bitgloo.com> | 2024-06-10 13:25:48 -0400 |
commit | e941048b066dc167ee870545d99532a8d1815e89 (patch) | |
tree | 4c63c86b1644b0175325f6b1b27a19fa5f2f5215 | |
parent | 686e00c9217f47ead88662ab6fd3eb00c6ee24de (diff) |
stop using stride term
-rw-r--r-- | main.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -34,7 +34,7 @@ static constexpr auto MIC_BITS = 18u; static constexpr auto SAMPLE_RATE = 48000u; static constexpr unsigned I2S_BUFSIZ = 1024; -static constexpr unsigned I2S_STRIDE = 32; +static constexpr unsigned I2S_USESIZ = 16; // Calculate reference amplitude value at compile time static const auto MIC_REF_AMPL = sos_t((1 << (MIC_BITS - 1)) - 1) * @@ -152,19 +152,19 @@ void i2sCallback(I2SDriver *i2s) const auto source = i2sBuffer.data() + (i2sIsBufferComplete(i2s) ? halfsize : 0); auto samples = reinterpret_cast<sos_t *>(source); std::ranges::copy( - std::views::counted(source, halfsize / I2S_STRIDE) + std::views::counted(source, I2S_USESIZ * 2) | std::ranges::views::stride(2) | std::views::transform([](uint32_t s) { return sos_t(qfp_int2float_asm(fixsample(s))); }), samples); - auto samps = std::views::counted(samples, halfsize / (2 * I2S_STRIDE)); + auto samps = std::views::counted(samples, I2S_USESIZ); // Accumulate Leq sum MIC_EQUALIZER.filter(samps); Leq_sum_sqr += WEIGHTING.filter_sum_sqr(samps); - Leq_samples += samps.size(); + Leq_samples += halfsize / 2; // Wakeup main thread for dB calculation every half second - if (Leq_samples >= SAMPLE_RATE / I2S_STRIDE / 2) { + if (Leq_samples >= SAMPLE_RATE / 2) { i2sReady.store(true); SCB->SCR &= ~SCB_SCR_SLEEPONEXIT_Msk; } |