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
|
|
|
|
2018-12-08 02:50:34 -08:00
|
|
|
ALuint mEnabled; /* 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];
|
2018-12-08 02:50:34 -08: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 */
|
2018-12-08 02:50:34 -08:00
|
|
|
std::array<ALfloat,BUFFERSIZE> *mSamplesHF;
|
|
|
|
std::array<ALfloat,BUFFERSIZE> *mSamplesLF;
|
2016-03-26 17:52:42 -07:00
|
|
|
|
2018-12-08 02:50:34 -08:00
|
|
|
ALsizei mNumChannels;
|
|
|
|
ALboolean mDualBand;
|
2018-11-22 05:37:35 -08:00
|
|
|
|
2018-12-08 02:50:34 -08:00
|
|
|
public:
|
2019-01-05 19:21:25 -08:00
|
|
|
void reset(const AmbDecConf *conf, bool allow_2band, ALsizei inchans, ALuint srate, const ALsizei (&chanmap)[MAX_OUTPUT_CHANNELS]);
|
|
|
|
|
2019-02-22 22:35:37 -08:00
|
|
|
void reset(const ALsizei inchans, const ALsizei chancount, 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. */
|
2018-12-24 20:44:55 -08:00
|
|
|
void process(ALfloat (*OutBuffer)[BUFFERSIZE], const ALsizei OutChannels, const ALfloat (*InSamples)[BUFFERSIZE], 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-01-06 17:45:44 -08:00
|
|
|
static std::array<ALfloat,MAX_AMBI_ORDER+1> GetHFOrderScales(const ALsizei in_order, const ALsizei out_order) noexcept;
|
|
|
|
|
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 */
|