bformatdec.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #ifndef BFORMATDEC_H
  2. #define BFORMATDEC_H
  3. #include "alMain.h"
  4. /* These are the necessary scales for first-order HF responses to play over
  5. * higher-order 2D (non-periphonic) decoders.
  6. */
  7. #define W_SCALE2D_SECOND 1.224744871f /* sqrt(1.5) */
  8. #define XYZ_SCALE2D_SECOND 1.0f
  9. #define W_SCALE2D_THIRD 1.414213562f /* sqrt(2) */
  10. #define XYZ_SCALE2D_THIRD 1.082392196f
  11. /* These are the necessary scales for first-order HF responses to play over
  12. * higher-order 3D (periphonic) decoders.
  13. */
  14. #define W_SCALE3D_SECOND 1.341640787f /* sqrt(1.8) */
  15. #define XYZ_SCALE3D_SECOND 1.0f
  16. #define W_SCALE3D_THIRD 1.695486018f
  17. #define XYZ_SCALE3D_THIRD 1.136697713f
  18. struct AmbDecConf;
  19. struct BFormatDec;
  20. struct AmbiUpsampler;
  21. struct BFormatDec *bformatdec_alloc();
  22. void bformatdec_free(struct BFormatDec *dec);
  23. void bformatdec_reset(struct BFormatDec *dec, const struct AmbDecConf *conf, ALsizei chancount, ALuint srate, const ALsizei chanmap[MAX_OUTPUT_CHANNELS]);
  24. /* Decodes the ambisonic input to the given output channels. */
  25. void bformatdec_process(struct BFormatDec *dec, ALfloat (*restrict OutBuffer)[BUFFERSIZE], ALsizei OutChannels, const ALfloat (*restrict InSamples)[BUFFERSIZE], ALsizei SamplesToDo);
  26. /* Up-samples a first-order input to the decoder's configuration. */
  27. void bformatdec_upSample(struct BFormatDec *dec, ALfloat (*restrict OutBuffer)[BUFFERSIZE], const ALfloat (*restrict InSamples)[BUFFERSIZE], ALsizei InChannels, ALsizei SamplesToDo);
  28. /* Stand-alone first-order upsampler. Kept here because it shares some stuff
  29. * with bformatdec.
  30. */
  31. struct AmbiUpsampler *ambiup_alloc();
  32. void ambiup_free(struct AmbiUpsampler *ambiup);
  33. void ambiup_reset(struct AmbiUpsampler *ambiup, const ALCdevice *device);
  34. void ambiup_process(struct AmbiUpsampler *ambiup, ALfloat (*restrict OutBuffer)[BUFFERSIZE], ALsizei OutChannels, const ALfloat (*restrict InSamples)[BUFFERSIZE], ALsizei SamplesToDo);
  35. /* Band splitter. Splits a signal into two phase-matching frequency bands. */
  36. typedef struct BandSplitter {
  37. ALfloat coeff;
  38. ALfloat lp_z1;
  39. ALfloat lp_z2;
  40. ALfloat hp_z1;
  41. } BandSplitter;
  42. void bandsplit_init(BandSplitter *splitter, ALfloat freq_mult);
  43. void bandsplit_clear(BandSplitter *splitter);
  44. void bandsplit_process(BandSplitter *splitter, ALfloat *restrict hpout, ALfloat *restrict lpout,
  45. const ALfloat *input, ALsizei count);
  46. /* The all-pass portion of the band splitter. Applies the same phase shift
  47. * without splitting the signal.
  48. */
  49. typedef struct SplitterAllpass {
  50. ALfloat coeff;
  51. ALfloat z1;
  52. } SplitterAllpass;
  53. void splitterap_init(SplitterAllpass *splitter, ALfloat freq_mult);
  54. void splitterap_clear(SplitterAllpass *splitter);
  55. void splitterap_process(SplitterAllpass *splitter, ALfloat *restrict samples, ALsizei count);
  56. #endif /* BFORMATDEC_H */