22 #ifndef EDSP_BIQUAD_CASCADE_HPP 23 #define EDSP_BIQUAD_CASCADE_HPP 25 #include <edsp/meta/expects.hpp> 26 #include <edsp/meta/ensure.hpp> 29 #include <edsp/meta/iterator.hpp> 31 namespace edsp {
namespace filter {
42 template <
typename T, std::
size_t N>
90 constexpr
void clear();
95 constexpr
void reset();
156 template <typename InputIt, typename OutputIt>
157 constexpr
void filter(InputIt first, InputIt last, OutputIt d_first);
164 constexpr T
tick(T value) noexcept;
176 template <typename... Arg>
180 std::
size_t num_stage_{0};
181 std::array<biquad<T>, N> cascade_{};
184 template <
typename T,
size_t N>
189 template <
typename T,
size_t N>
194 template <
typename T,
size_t N>
195 template <
typename... Arg>
197 meta::ensure(num_stage_ < N,
"No space available");
198 cascade_[num_stage_] =
biquad<T>(arg...);
202 template <
typename T,
size_t N>
204 meta::ensure(num_stage_ < N,
"No space available");
205 cascade_[num_stage_] = biquad;
209 template <
typename T,
size_t N>
211 for (
auto i = 0ul; i < num_stage_; ++i) {
212 value = cascade_[i].tick(value);
217 template <
typename T,
size_t N>
218 template <
typename InputIt,
typename OutputIt>
220 for (; first != last; ++first, ++d_first) {
221 *d_first =
tick(*first);
225 template <
typename T,
size_t N>
227 return std::cbegin(cascade_) +
size();
230 template <
typename T,
size_t N>
232 return std::cbegin(cascade_) +
size();
235 template <
typename T,
size_t N>
237 return std::cbegin(cascade_);
240 template <
typename T,
size_t N>
242 return std::cbegin(cascade_);
245 template <
typename T,
size_t N>
247 return std::begin(cascade_) +
size();
250 template <
typename T,
size_t N>
252 return std::begin(cascade_);
255 template <
typename T,
size_t N>
258 return cascade_[index];
261 template <
typename T,
size_t N>
264 return cascade_[index];
267 template <
typename T,
size_t N>
269 for (
auto i = 0ul; i < num_stage_; ++i) {
274 template <
typename T,
size_t N>
279 template <
typename T,
size_t N>
284 #endif // EDSP_BIQUAD_CASCADE_HPP constexpr const_iterator cbegin() const noexcept
Returns a constant iterator to the first element of the container.
Definition: biquad_cascade.hpp:241
constexpr iterator begin() noexcept
Returns an iterator to the first element of the container.
Definition: biquad_cascade.hpp:251
constexpr T tick(T value) noexcept
Computes the output of filtering one digital time-step.
Definition: biquad_cascade.hpp:210
constexpr biquad_cascade()=default
Creates an empty biquad_cascade.
constexpr const_reference operator[](size_type index) const noexcept
Returns a constant reference to the Biquad at specified location pos. No bounds checking is performed...
Definition: biquad_cascade.hpp:263
constexpr void clear()
Clear the contents of the BiquadCascade.
Definition: biquad_cascade.hpp:275
constexpr size_type max_size() const noexcept
Returns the maximum number of Biquads the BiquadCascade is able to hold.
Definition: biquad_cascade.hpp:190
constexpr iterator end() noexcept
Returns an iterator to the last element of the container.
Definition: biquad_cascade.hpp:246
This Biquad class implements a second-order recursive linear filter, containing two poles and two zer...
Definition: biquad.hpp:71
The BiquadCascade class implements a cascade of Biquad filters.
Definition: biquad_cascade.hpp:43
constexpr size_type capacity() const noexcept
Returns the capacity the BiquadCascade.
Definition: biquad_cascade.hpp:280
constexpr void emplace_back(Arg... arg)
Construct a Biquad in-place at the end.
Definition: biquad_cascade.hpp:196
constexpr void push_back(const biquad< T > &biquad)
Appends the given Biquad at the end.
Definition: biquad_cascade.hpp:203
constexpr const_iterator cend() const noexcept
Returns a constant iterator to the last element of the container.
Definition: biquad_cascade.hpp:231
~biquad_cascade()=default
Default destructor.
Definition: amplifier.hpp:29
std::size_t size_type
Definition: biquad_cascade.hpp:50
constexpr size_type size() const noexcept
Returns the number of Biquads.
Definition: biquad_cascade.hpp:185
constexpr void reset()
Reset all the internal Biquads to the original state.
Definition: biquad_cascade.hpp:268
constexpr void filter(InputIt first, InputIt last, OutputIt d_first)
Filters the signal in the range [first, last) and stores the result in another range, beginning at d_first.
Definition: biquad_cascade.hpp:219