]> git.tdb.fi Git - ext/openal.git/blob - core/filters/splitter.h
Import OpenAL Soft 1.23.1 sources
[ext/openal.git] / core / filters / splitter.h
1 #ifndef CORE_FILTERS_SPLITTER_H
2 #define CORE_FILTERS_SPLITTER_H
3
4 #include <cstddef>
5
6 #include "alspan.h"
7
8
9 /* Band splitter. Splits a signal into two phase-matching frequency bands. */
10 template<typename Real>
11 class BandSplitterR {
12     Real mCoeff{0.0f};
13     Real mLpZ1{0.0f};
14     Real mLpZ2{0.0f};
15     Real mApZ1{0.0f};
16
17 public:
18     BandSplitterR() = default;
19     BandSplitterR(const BandSplitterR&) = default;
20     BandSplitterR(Real f0norm) { init(f0norm); }
21     BandSplitterR& operator=(const BandSplitterR&) = default;
22
23     void init(Real f0norm);
24     void clear() noexcept { mLpZ1 = mLpZ2 = mApZ1 = 0.0f; }
25     void process(const al::span<const Real> input, Real *hpout, Real *lpout);
26
27     void processHfScale(const al::span<const Real> input, Real *output, const Real hfscale);
28
29     void processHfScale(const al::span<Real> samples, const Real hfscale);
30     void processScale(const al::span<Real> samples, const Real hfscale, const Real lfscale);
31
32     /**
33      * The all-pass portion of the band splitter. Applies the same phase shift
34      * without splitting or scaling the signal.
35      */
36     void processAllPass(const al::span<Real> samples);
37 };
38 using BandSplitter = BandSplitterR<float>;
39
40 #endif /* CORE_FILTERS_SPLITTER_H */