Use a flexible array for the active effect slots
[openal-soft.git] / Alc / bformatdec.h
blob2f7ef612248b0b5ea74cc8e70da80a96e3ef195d
1 #ifndef BFORMATDEC_H
2 #define BFORMATDEC_H
4 #include "alMain.h"
5 #include "filters/splitter.h"
6 #include "ambidefs.h"
7 #include "almalloc.h"
10 struct AmbDecConf;
13 using ChannelDec = ALfloat[MAX_AMBI_COEFFS];
15 class BFormatDec {
16 static constexpr size_t sHFBand{0};
17 static constexpr size_t sLFBand{1};
18 static constexpr size_t sNumBands{2};
20 ALuint mEnabled; /* Bitfield of enabled channels. */
22 union MatrixU {
23 ALfloat Dual[MAX_OUTPUT_CHANNELS][sNumBands][MAX_AMBI_COEFFS];
24 ALfloat Single[MAX_OUTPUT_CHANNELS][MAX_AMBI_COEFFS];
25 } mMatrix;
27 /* NOTE: BandSplitter filters are unused with single-band decoding */
28 BandSplitter mXOver[MAX_AMBI_COEFFS];
30 al::vector<std::array<ALfloat,BUFFERSIZE>, 16> mSamples;
31 /* These two alias into Samples */
32 std::array<ALfloat,BUFFERSIZE> *mSamplesHF;
33 std::array<ALfloat,BUFFERSIZE> *mSamplesLF;
35 SplitterAllpass mUpAllpass[MAX_OUTPUT_CHANNELS];
36 struct {
37 BandSplitter Splitter;
38 ALfloat Gains[sNumBands];
39 } mUpsampler[4];
41 ALsizei mNumChannels;
42 ALboolean mDualBand;
44 public:
45 void reset(const AmbDecConf *conf, bool allow_2band, ALsizei inchans, ALuint srate, const ALsizei (&chanmap)[MAX_OUTPUT_CHANNELS]);
47 void reset(const ALsizei inchans, const ALfloat xover_norm, const ALsizei chancount, const ChannelDec (&chancoeffs)[MAX_OUTPUT_CHANNELS], const ALsizei (&chanmap)[MAX_OUTPUT_CHANNELS]);
49 /* Decodes the ambisonic input to the given output channels. */
50 void process(ALfloat (*OutBuffer)[BUFFERSIZE], const ALsizei OutChannels, const ALfloat (*InSamples)[BUFFERSIZE], const ALsizei SamplesToDo);
52 /* Up-samples a first-order input to the decoder's configuration. */
53 void upSample(ALfloat (*OutBuffer)[BUFFERSIZE], const ALsizei OutChannels, const ALfloat (*InSamples)[BUFFERSIZE], const ALsizei InChannels, const ALsizei SamplesToDo);
55 DEF_NEWDEL(BFormatDec)
59 /* Stand-alone first-order upsampler. Kept here because it shares some stuff
60 * with bformatdec.
62 class AmbiUpsampler {
63 static constexpr size_t sHFBand{0};
64 static constexpr size_t sLFBand{1};
65 static constexpr size_t sNumBands{2};
67 SplitterAllpass mAllpass[MAX_OUTPUT_CHANNELS];
68 alignas(16) ALfloat mSamples[sNumBands][BUFFERSIZE];
69 struct {
70 BandSplitter Splitter;
71 ALfloat Gains[sNumBands];
72 } mInput[4];
74 public:
75 void reset(const ALsizei out_order, const ALfloat xover_norm);
76 void process(ALfloat (*OutBuffer)[BUFFERSIZE], const ALsizei OutChannels, const ALfloat (*InSamples)[BUFFERSIZE], const ALsizei InChannels, const ALsizei SamplesToDo);
78 static std::array<ALfloat,MAX_AMBI_ORDER+1> GetHFOrderScales(const ALsizei in_order, const ALsizei out_order) noexcept;
80 DEF_NEWDEL(AmbiUpsampler)
83 #endif /* BFORMATDEC_H */