// SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2022-2023 by Ronald "Eidolon" Kinard // // This program is free software distributed under the // terms of the GNU General Public License, version 2. // See the 'LICENSE' file for more details. //----------------------------------------------------------------------------- #ifndef __SRB2_AUDIO_WAV_HPP__ #define __SRB2_AUDIO_WAV_HPP__ #include #include #include #include #include #include #include "../io/streams.hpp" #include "sample.hpp" namespace srb2::audio { class Wav final { std::variant, std::vector> interleaved_samples_; std::size_t channels_ = 1; std::size_t sample_rate_ = 44100; public: Wav(); explicit Wav(tcb::span data); std::size_t get_samples(std::size_t offset, tcb::span> buffer) const noexcept; std::size_t interleaved_length() const noexcept; std::size_t length() const noexcept { return interleaved_length() / channels(); }; std::size_t channels() const noexcept { return channels_; }; std::size_t sample_rate() const noexcept { return sample_rate_; }; }; template , int> = 0> inline Wav load_wav(I& stream) { std::vector data = srb2::io::read_to_vec(stream); return Wav {data}; } } // namespace srb2::audio #endif // __SRB2_AUDIO_WAV_HPP__