1 #ifndef CORE_UHJFILTER_H 2 #define CORE_UHJFILTER_H 3 4 #include <array> 5 6 #include "almalloc.h" 7 #include "bufferline.h" 8 9 10 struct Uhj2Encoder { 11 /* A particular property of the filter allows it to cover nearly twice its 12 * length, so the filter size is also the effective delay (despite being 13 * center-aligned). 14 */ 15 constexpr static size_t sFilterSize{128}; 16 17 /* Delays for the unfiltered signal. */ 18 alignas(16) std::array<float,sFilterSize> mMidDelay{}; 19 alignas(16) std::array<float,sFilterSize> mSideDelay{}; 20 21 alignas(16) std::array<float,BufferLineSize+sFilterSize> mMid{}; 22 alignas(16) std::array<float,BufferLineSize+sFilterSize> mSide{}; 23 24 /* History for the FIR filter. */ 25 alignas(16) std::array<float,sFilterSize*2 - 1> mSideHistory{}; 26 27 alignas(16) std::array<float,BufferLineSize + sFilterSize*2> mTemp{}; 28 29 /** 30 * Encodes a 2-channel UHJ (stereo-compatible) signal from a B-Format input 31 * signal. The input must use FuMa channel ordering and scaling. 32 */ 33 void encode(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, 34 const FloatBufferLine *InSamples, const size_t SamplesToDo); 35 36 DEF_NEWDEL(Uhj2Encoder) 37 }; 38 39 #endif /* CORE_UHJFILTER_H */ 40