// SPDX-License-Identifier: MPL-2.0 // Copyright © 2020 Skyline Team and Contributors (https://github.com/skyline-emu/) #pragma once #include namespace skyline::audio { /** * @brief The AdpcmDecoder class handles decoding single channel ADPCM (Adaptive Differential Pulse-Code Modulation) data */ class AdpcmDecoder { private: union FrameHeader { u8 raw; struct { u8 scale : 4; //!< The scale factor for this frame u8 coefficientIndex : 3; u8 _pad_ : 1; }; }; static_assert(sizeof(FrameHeader) == 0x1); std::array history{}; //!< The previous samples for decoding the ADPCM stream std::vector> coefficients; //!< The coefficients for decoding the ADPCM stream public: AdpcmDecoder(std::vector> coefficients); /** * @brief Decodes a buffer of ADPCM data into I16 PCM */ std::vector Decode(span adpcmData); }; }