sfFDN
Loading...
Searching...
No Matches
filterbank.h
1// Copyright (C) 2025 Alexandre St-Onge
2// SPDX-License-Identifier: MIT
3#pragma once
4
5#include "audio_processor.h"
6#include "filter.h"
7
8#include <cstddef>
9#include <cstdint>
10#include <memory>
11#include <vector>
12
13namespace sfFDN
14{
19{
20 public:
23
25 void Clear() override;
26
31 void AddFilter(std::unique_ptr<AudioProcessor> filter);
32
39 void Process(const AudioBuffer& input, AudioBuffer& output) noexcept override;
40
45 uint32_t InputChannelCount() const override;
46
51 uint32_t OutputChannelCount() const override;
52
56 std::unique_ptr<AudioProcessor> Clone() const override;
57
58 private:
59 std::vector<std::unique_ptr<AudioProcessor>> filters_;
60};
61
68{
69 public:
72
73 IIRFilterBank(const IIRFilterBank&) = delete;
74 IIRFilterBank& operator=(const IIRFilterBank&) = delete;
75
82 IIRFilterBank& operator=(IIRFilterBank&&) noexcept;
83
85
87 void Clear() override;
88
94 void SetFilter(std::span<const FilterCoefficients> coeffs, uint32_t channel_count);
95
102 void Process(const AudioBuffer& input, AudioBuffer& output) noexcept override;
103
108 uint32_t InputChannelCount() const override;
109
114 uint32_t OutputChannelCount() const override;
115
119 std::unique_ptr<AudioProcessor> Clone() const override;
120
121 private:
122 class IIRFilterBankImpl;
123 std::unique_ptr<IIRFilterBankImpl> impl_;
124
125 std::vector<FilterCoefficients> coeffs_;
126};
127
128} // namespace sfFDN
A class representing an audio buffer with multiple channels of non-interleaved audio data.
Definition audio_buffer.h:18
Base class for audio processors.
Definition audio_processor.h:23
Implements a bank of filters.
Definition filterbank.h:19
uint32_t InputChannelCount() const override
Returns the number of input channels supported by this processor.
void Clear() override
Clears the filter bank.
void Process(const AudioBuffer &input, AudioBuffer &output) noexcept override
Processes a block of input samples through the filter bank.
uint32_t OutputChannelCount() const override
Returns the number of output channels produced by this processor.
void AddFilter(std::unique_ptr< AudioProcessor > filter)
Adds a filter to the filter bank.
FilterBank()
Constructs an empty filter bank.
std::unique_ptr< AudioProcessor > Clone() const override
Creates a copy of the filter bank.
Implements a bank of IIR filters.
Definition filterbank.h:68
std::unique_ptr< AudioProcessor > Clone() const override
Creates a copy of the filter bank.
void SetFilter(std::span< const FilterCoefficients > coeffs, uint32_t channel_count)
Sets the biquad coefficients for each stage.
IIRFilterBank()
Constructs an empty IIR filter bank.
void Process(const AudioBuffer &input, AudioBuffer &output) noexcept override
Processes a block of input samples through the filter bank.
IIRFilterBank(IIRFilterBank &&) noexcept
Move constructor for the IIR filter bank.
void Clear() override
Clears the internal state of the processor.
uint32_t OutputChannelCount() const override
Returns the number of output channels produced by this processor.
uint32_t InputChannelCount() const override
Returns the number of input channels supported by this processor.
Coefficients for a digital IIR filter.
Definition types.h:222