5 #include "filters/splitter.h"
12 /* These are the necessary scales for first-order HF responses to play over
13 * higher-order 2D (non-periphonic) decoders.
15 #define W_SCALE_2H0P 1.224744871f /* sqrt(1.5) */
16 #define XYZ_SCALE_2H0P 1.0f
17 #define W_SCALE_3H0P 1.414213562f /* sqrt(2) */
18 #define XYZ_SCALE_3H0P 1.082392196f
20 /* These are the necessary scales for first-order HF responses to play over
21 * higher-order 3D (periphonic) decoders.
23 #define W_SCALE_2H2P 1.341640787f /* sqrt(1.8) */
24 #define XYZ_SCALE_2H2P 1.0f
25 #define W_SCALE_3H3P 1.695486018f
26 #define XYZ_SCALE_3H3P 1.136697713f
29 /* NOTE: These are scale factors as applied to Ambisonics content. Decoder
30 * coefficients should be divided by these values to get proper N3D scalings.
32 extern const ALfloat N3D2N3DScale
[MAX_AMBI_COEFFS
];
33 extern const ALfloat SN3D2N3DScale
[MAX_AMBI_COEFFS
];
34 extern const ALfloat FuMa2N3DScale
[MAX_AMBI_COEFFS
];
39 static constexpr size_t sNumBands
{2};
42 ALuint mEnabled
; /* Bitfield of enabled channels. */
45 alignas(16) ALfloat Dual
[MAX_OUTPUT_CHANNELS
][sNumBands
][MAX_AMBI_COEFFS
];
46 alignas(16) ALfloat Single
[MAX_OUTPUT_CHANNELS
][MAX_AMBI_COEFFS
];
49 /* NOTE: BandSplitter filters are unused with single-band decoding */
50 BandSplitter mXOver
[MAX_AMBI_COEFFS
];
52 al::vector
<std::array
<ALfloat
,BUFFERSIZE
>, 16> mSamples
;
53 /* These two alias into Samples */
54 std::array
<ALfloat
,BUFFERSIZE
> *mSamplesHF
;
55 std::array
<ALfloat
,BUFFERSIZE
> *mSamplesLF
;
57 alignas(16) ALfloat mChannelMix
[BUFFERSIZE
];
61 ALfloat Gains
[sNumBands
];
68 void reset(const AmbDecConf
*conf
, ALsizei chancount
, ALuint srate
, const ALsizei (&chanmap
)[MAX_OUTPUT_CHANNELS
]);
70 /* Decodes the ambisonic input to the given output channels. */
71 void process(ALfloat (*RESTRICT OutBuffer
)[BUFFERSIZE
], const ALsizei OutChannels
, const ALfloat (*RESTRICT InSamples
)[BUFFERSIZE
], const ALsizei SamplesToDo
);
73 /* Up-samples a first-order input to the decoder's configuration. */
74 void upSample(ALfloat (*RESTRICT OutBuffer
)[BUFFERSIZE
], const ALfloat (*RESTRICT InSamples
)[BUFFERSIZE
], const ALsizei InChannels
, const ALsizei SamplesToDo
);
76 DEF_NEWDEL(BFormatDec
)
80 /* Stand-alone first-order upsampler. Kept here because it shares some stuff
81 * with bformatdec. Assumes a periphonic (4-channel) input mix!
85 static constexpr size_t sNumBands
{2};
88 alignas(16) ALfloat mSamples
[sNumBands
][BUFFERSIZE
];
90 BandSplitter mXOver
[4];
92 ALfloat mGains
[4][MAX_OUTPUT_CHANNELS
][sNumBands
];
95 void reset(const ALCdevice
*device
, const ALfloat w_scale
, const ALfloat xyz_scale
);
96 void process(ALfloat (*RESTRICT OutBuffer
)[BUFFERSIZE
], const ALsizei OutChannels
, const ALfloat (*RESTRICT InSamples
)[BUFFERSIZE
], const ALsizei SamplesToDo
);
98 DEF_NEWDEL(AmbiUpsampler
)
101 #endif /* BFORMATDEC_H */