10 /* Encoding 2-channel UHJ from B-Format is done as:
12 * S = 0.9396926*W + 0.1855740*X
13 * D = j(-0.3420201*W + 0.5098604*X) + 0.6554516*Y
18 * where j is a wide-band +90 degree phase shift.
20 * The phase shift is done using a FIR filter derived from an FFT'd impulse
21 * with the desired shift.
25 /* A particular property of the filter allows it to cover nearly twice its
26 * length, so the filter size is also the effective delay (despite being
29 constexpr static size_t sFilterSize
{128};
31 /* Delays for the unfiltered signal. */
32 alignas(16) std::array
<float,sFilterSize
> mMidDelay
{};
33 alignas(16) std::array
<float,sFilterSize
> mSideDelay
{};
35 alignas(16) std::array
<float,BUFFERSIZE
+sFilterSize
> mMid
{};
36 alignas(16) std::array
<float,BUFFERSIZE
+sFilterSize
> mSide
{};
38 /* History for the FIR filter. */
39 alignas(16) std::array
<float,sFilterSize
*2 - 1> mSideHistory
{};
41 alignas(16) std::array
<float,BUFFERSIZE
+ sFilterSize
*2> mTemp
{};
44 * Encodes a 2-channel UHJ (stereo-compatible) signal from a B-Format input
45 * signal. The input must use FuMa channel ordering and scaling.
47 void encode(FloatBufferLine
&LeftOut
, FloatBufferLine
&RightOut
,
48 const FloatBufferLine
*InSamples
, const size_t SamplesToDo
);
50 DEF_NEWDEL(Uhj2Encoder
)
53 #endif /* UHJFILTER_H */