🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.8 KiB

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