I guess -1 isn't allowed for the output
[openal-soft.git] / Alc / bformatdec.h
blobbaaecf40278cd314500100ba1c9c096aa712c92d
1 #ifndef BFORMATDEC_H
2 #define BFORMATDEC_H
4 #include "alMain.h"
7 /* These are the necessary scales for first-order HF responses to play over
8 * higher-order 2D (non-periphonic) decoders.
9 */
10 #define W_SCALE2D_SECOND 1.224744871f /* sqrt(1.5) */
11 #define XYZ_SCALE2D_SECOND 1.0f
12 #define W_SCALE2D_THIRD 1.414213562f /* sqrt(2) */
13 #define XYZ_SCALE2D_THIRD 1.082392196f
15 /* These are the necessary scales for first-order HF responses to play over
16 * higher-order 3D (periphonic) decoders.
18 #define W_SCALE3D_SECOND 1.341640787f /* sqrt(1.8) */
19 #define XYZ_SCALE3D_SECOND 1.0f
20 #define W_SCALE3D_THIRD 1.695486018f
21 #define XYZ_SCALE3D_THIRD 1.136697713f
24 struct AmbDecConf;
25 struct BFormatDec;
26 struct AmbiUpsampler;
29 struct BFormatDec *bformatdec_alloc();
30 void bformatdec_free(struct BFormatDec *dec);
31 void bformatdec_reset(struct BFormatDec *dec, const struct AmbDecConf *conf, ALsizei chancount, ALuint srate, const ALsizei chanmap[MAX_OUTPUT_CHANNELS]);
33 /* Decodes the ambisonic input to the given output channels. */
34 void bformatdec_process(struct BFormatDec *dec, ALfloat (*restrict OutBuffer)[BUFFERSIZE], ALsizei OutChannels, const ALfloat (*restrict InSamples)[BUFFERSIZE], ALsizei SamplesToDo);
36 /* Up-samples a first-order input to the decoder's configuration. */
37 void bformatdec_upSample(struct BFormatDec *dec, ALfloat (*restrict OutBuffer)[BUFFERSIZE], const ALfloat (*restrict InSamples)[BUFFERSIZE], ALsizei InChannels, ALsizei SamplesToDo);
40 /* Stand-alone first-order upsampler. Kept here because it shares some stuff
41 * with bformatdec.
43 struct AmbiUpsampler *ambiup_alloc();
44 void ambiup_free(struct AmbiUpsampler *ambiup);
45 void ambiup_reset(struct AmbiUpsampler *ambiup, const ALCdevice *device);
47 void ambiup_process(struct AmbiUpsampler *ambiup, ALfloat (*restrict OutBuffer)[BUFFERSIZE], ALsizei OutChannels, const ALfloat (*restrict InSamples)[BUFFERSIZE], ALsizei SamplesToDo);
50 /* Band splitter. Splits a signal into two phase-matching frequency bands. */
51 typedef struct BandSplitter {
52 ALfloat coeff;
53 ALfloat lp_z1;
54 ALfloat lp_z2;
55 ALfloat hp_z1;
56 } BandSplitter;
58 void bandsplit_init(BandSplitter *splitter, ALfloat freq_mult);
59 void bandsplit_clear(BandSplitter *splitter);
60 void bandsplit_process(BandSplitter *splitter, ALfloat *restrict hpout, ALfloat *restrict lpout,
61 const ALfloat *input, ALsizei count);
63 /* The all-pass portion of the band splitter. Applies the same phase shift
64 * without splitting the signal.
66 typedef struct SplitterAllpass {
67 ALfloat coeff;
68 ALfloat z1;
69 } SplitterAllpass;
71 void splitterap_init(SplitterAllpass *splitter, ALfloat freq_mult);
72 void splitterap_clear(SplitterAllpass *splitter);
73 void splitterap_process(SplitterAllpass *splitter, ALfloat *restrict samples, ALsizei count);
76 typedef struct FrontStablizer {
77 SplitterAllpass APFilter[MAX_OUTPUT_CHANNELS];
78 BandSplitter LFilter, RFilter;
79 alignas(16) ALfloat LSplit[2][BUFFERSIZE];
80 alignas(16) ALfloat RSplit[2][BUFFERSIZE];
81 } FrontStablizer;
83 #endif /* BFORMATDEC_H */