pcm/Normalizer: add method Reset()

This commit is contained in:
Max Kellermann 2023-03-13 13:52:43 +01:00
parent f547a56b1d
commit bc51bc2933
3 changed files with 16 additions and 0 deletions

View File

@ -24,6 +24,10 @@ public:
NormalizeFilter &operator=(const NormalizeFilter &) = delete; NormalizeFilter &operator=(const NormalizeFilter &) = delete;
/* virtual methods from class Filter */ /* virtual methods from class Filter */
void Reset() noexcept override {
normalizer.Reset();
}
std::span<const std::byte> FilterPCM(std::span<const std::byte> src) override; std::span<const std::byte> FilterPCM(std::span<const std::byte> src) override;
}; };

View File

@ -8,6 +8,16 @@
#include "Traits.hxx" #include "Traits.hxx"
#include "util/Compiler.h" #include "util/Compiler.h"
#include <algorithm> // for std::fill_n()
void
PcmNormalizer::Reset() noexcept
{
prev_gain = 0;
pos = 0;
std::fill_n(peaks, bufsz, 0);
}
void void
PcmNormalizer::ProcessS16(int16_t *gcc_restrict dest, PcmNormalizer::ProcessS16(int16_t *gcc_restrict dest,
const std::span<const int16_t> src) noexcept const std::span<const int16_t> src) noexcept

View File

@ -37,6 +37,8 @@ public:
delete[] peaks; delete[] peaks;
} }
void Reset() noexcept;
//! Process 16-bit signed data //! Process 16-bit signed data
void ProcessS16(int16_t *dest, std::span<const int16_t> src) noexcept; void ProcessS16(int16_t *dest, std::span<const int16_t> src) noexcept;
}; };