AME
ame_DcBlock.hpp
Go to the documentation of this file.
1
10#pragma once
11
12#include "ame_AudioBuffer.hpp"
13#include "ame_Math.hpp"
14#include "ame_Util.hpp"
15
16#include <array>
17#include <cassert>
18#include <cstdint>
19
20namespace ame::dsp
21{
29template <typename FloatType, size_t MaximumChannels>
31{
32public:
33 DcBlock() = default;
34 ~DcBlock() = default;
35
37 template <typename SampleType, size_t N>
39 {
40 assert (block.getNumChannels() <= MaximumChannels);
41
42 const auto numChannels = block.getNumChannels();
43 const auto bufferSize = block.getNumSamplesPerChannel();
44
45 uint_fast32_t i = 0;
46 for (uint_fast32_t samp = 0; samp < bufferSize; ++samp)
47 {
48 for (uint_fast32_t ch = 0; ch < numChannels; ++ch)
49 {
50 const FloatType input = block.view[i];
51 const FloatType y = input - x1[ch] + (y1[ch] * c);
52 x1[ch] = input;
53 y1[ch] = y;
54 block.view[i] = y;
55 ++i;
56 }
57 }
58 }
59
60private:
64 static constexpr FloatType c = (FloatType) 0.9997;
65
66 std::array<FloatType, MaximumChannels> x1 {};
67 std::array<FloatType, MaximumChannels> y1 {};
68};
69} // namespace ame::dsp
Audio buffer.
Math functions.
Some utilities functions.
A lightweight data structure that stores a pointer to an audio buffer.
Definition: ame_AudioBuffer.hpp:32
uint_fast32_t getNumChannels() const noexcept
Returns the number of channels.
Definition: ame_AudioBuffer.hpp:49
uint_fast32_t getNumSamplesPerChannel() const noexcept
Returns the number of samples per channel.
Definition: ame_AudioBuffer.hpp:55
DC block filter.
Definition: ame_DcBlock.hpp:31
void process(AudioBlockView< SampleType, N > &block)
Process audio effect.
Definition: ame_DcBlock.hpp:38