1 #ifndef CORE_CONVERTER_H
2 #define CORE_CONVERTER_H
9 #include "mixer/defs.h"
11 using uint
= unsigned int;
14 struct SampleConverter
{
15 DevFmtType mSrcType
{};
16 DevFmtType mDstType
{};
25 ResamplerFunc mResample
{};
27 alignas(16) float mSrcSamples
[BufferLineSize
]{};
28 alignas(16) float mDstSamples
[BufferLineSize
]{};
31 alignas(16) float PrevSamples
[MaxResamplerPadding
];
33 al::FlexArray
<ChanSamples
> mChan
;
35 SampleConverter(size_t numchans
) : mChan
{numchans
} { }
37 uint
convert(const void **src
, uint
*srcframes
, void *dst
, uint dstframes
);
38 uint
availableOut(uint srcframes
) const;
40 DEF_FAM_NEWDEL(SampleConverter
, mChan
)
42 using SampleConverterPtr
= std::unique_ptr
<SampleConverter
>;
44 SampleConverterPtr
CreateSampleConverter(DevFmtType srcType
, DevFmtType dstType
, size_t numchans
,
45 uint srcRate
, uint dstRate
, Resampler resampler
);
48 struct ChannelConverter
{
49 DevFmtType mSrcType
{};
52 DevFmtChannels mDstChans
{};
54 bool is_active() const noexcept
{ return mChanMask
!= 0; }
56 void convert(const void *src
, float *dst
, uint frames
) const;
59 #endif /* CORE_CONVERTER_H */