2016-03-15 05:08:05 -07:00
|
|
|
#ifndef BFORMATDEC_H
|
|
|
|
#define BFORMATDEC_H
|
|
|
|
|
|
|
|
#include "alMain.h"
|
2018-11-22 05:37:35 -08:00
|
|
|
#include "filters/splitter.h"
|
2019-01-05 19:21:25 -08:00
|
|
|
#include "ambidefs.h"
|
2018-11-22 05:37:35 -08:00
|
|
|
#include "almalloc.h"
|
|
|
|
|
|
|
|
|
|
|
|
struct AmbDecConf;
|
2016-03-15 05:08:05 -07:00
|
|
|
|
2017-01-24 19:03:51 -08:00
|
|
|
|
2019-02-19 15:39:33 -08:00
|
|
|
using ChannelDec = ALfloat[MAX_AMBI_CHANNELS];
|
2019-01-05 19:21:25 -08:00
|
|
|
|
2018-12-08 02:50:34 -08:00
|
|
|
class BFormatDec {
|
2019-01-07 21:48:48 -08:00
|
|
|
static constexpr size_t sHFBand{0};
|
|
|
|
static constexpr size_t sLFBand{1};
|
2018-12-08 02:50:34 -08:00
|
|
|
static constexpr size_t sNumBands{2};
|
2018-11-22 05:37:35 -08:00
|
|
|
|
2019-03-31 22:27:56 -07:00
|
|
|
ALuint mEnabled{0u}; /* Bitfield of enabled channels. */
|
2018-11-22 05:37:35 -08:00
|
|
|
|
2018-12-08 14:22:20 -08:00
|
|
|
union MatrixU {
|
2019-02-19 15:39:33 -08:00
|
|
|
ALfloat Dual[MAX_OUTPUT_CHANNELS][sNumBands][MAX_AMBI_CHANNELS];
|
|
|
|
ALfloat Single[MAX_OUTPUT_CHANNELS][MAX_AMBI_CHANNELS];
|
2019-03-31 22:27:56 -07:00
|
|
|
} mMatrix{};
|
2018-11-22 05:37:35 -08:00
|
|
|
|
|
|
|
/* NOTE: BandSplitter filters are unused with single-band decoding */
|
2019-02-19 15:39:33 -08:00
|
|
|
BandSplitter mXOver[MAX_AMBI_CHANNELS];
|
2016-03-15 05:08:05 -07:00
|
|
|
|
2018-12-08 02:50:34 -08:00
|
|
|
al::vector<std::array<ALfloat,BUFFERSIZE>, 16> mSamples;
|
2018-11-22 05:37:35 -08:00
|
|
|
/* These two alias into Samples */
|
2019-03-31 22:27:56 -07:00
|
|
|
std::array<ALfloat,BUFFERSIZE> *mSamplesHF{nullptr};
|
|
|
|
std::array<ALfloat,BUFFERSIZE> *mSamplesLF{nullptr};
|
2016-03-26 17:52:42 -07:00
|
|
|
|
2019-06-05 19:26:54 -07:00
|
|
|
ALuint mNumChannels{0u};
|
2019-03-31 22:27:56 -07:00
|
|
|
bool mDualBand{false};
|
2018-11-22 05:37:35 -08:00
|
|
|
|
2018-12-08 02:50:34 -08:00
|
|
|
public:
|
2019-06-05 19:26:54 -07:00
|
|
|
BFormatDec(const AmbDecConf *conf, const bool allow_2band, const ALuint inchans,
|
2019-02-23 00:01:38 -08:00
|
|
|
const ALuint srate, const ALsizei (&chanmap)[MAX_OUTPUT_CHANNELS]);
|
2019-06-05 19:26:54 -07:00
|
|
|
BFormatDec(const ALuint inchans, const ALsizei chancount,
|
2019-02-23 00:01:38 -08:00
|
|
|
const ChannelDec (&chancoeffs)[MAX_OUTPUT_CHANNELS],
|
|
|
|
const ALsizei (&chanmap)[MAX_OUTPUT_CHANNELS]);
|
2018-11-22 05:37:35 -08:00
|
|
|
|
2018-12-08 02:50:34 -08:00
|
|
|
/* Decodes the ambisonic input to the given output channels. */
|
2019-06-05 18:54:17 -07:00
|
|
|
void process(FloatBufferLine *OutBuffer, const ALuint OutChannels,
|
2019-05-28 16:22:36 -07:00
|
|
|
const FloatBufferLine *InSamples, const ALsizei SamplesToDo);
|
2016-03-23 12:53:36 -07:00
|
|
|
|
2019-02-22 22:35:37 -08:00
|
|
|
/* Retrieves per-order HF scaling factors for "upsampling" ambisonic data. */
|
2019-02-23 00:01:38 -08:00
|
|
|
static std::array<ALfloat,MAX_AMBI_ORDER+1> GetHFOrderScales(const ALsizei in_order,
|
|
|
|
const ALsizei out_order) noexcept;
|
2019-01-06 17:45:44 -08:00
|
|
|
|
2019-02-22 22:35:37 -08:00
|
|
|
DEF_NEWDEL(BFormatDec)
|
2018-11-22 05:37:35 -08:00
|
|
|
};
|
2016-07-30 09:29:21 -07:00
|
|
|
|
2016-03-15 05:08:05 -07:00
|
|
|
#endif /* BFORMATDEC_H */
|