// 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_MUSIC_PLAYER_HPP__ #define __SRB2_AUDIO_MUSIC_PLAYER_HPP__ #include #include #include #include "source.hpp" struct stb_vorbis; namespace srb2::audio { enum class MusicType { kOgg, kGme, kMod }; class MusicPlayer : public Source<2> { public: MusicPlayer(); MusicPlayer(tcb::span data); MusicPlayer(const MusicPlayer& rhs) = delete; MusicPlayer(MusicPlayer&& rhs) noexcept; MusicPlayer& operator=(const MusicPlayer& rhs) = delete; MusicPlayer& operator=(MusicPlayer&& rhs) noexcept; virtual std::size_t generate(tcb::span> buffer) override final; void play(bool looping); void unpause(); void pause(); void stop(); void seek(float position_seconds); void fade_to(float gain, float seconds); void fade_from_to(float from, float to, float seconds); void internal_gain(float gain); void stop_fade(); void loop_point_seconds(float loop_point); bool playing() const; std::optional music_type() const; std::optional duration_seconds() const; std::optional loop_point_seconds() const; std::optional position_seconds() const; bool fading() const; virtual ~MusicPlayer() final; private: class Impl; std::unique_ptr impl_; }; } // namespace srb2::audio #endif // __SRB2_AUDIO_MUSIC_PLAYER_HPP__