From 3f6fb17deddd1b366d16db5a2531c82407ced9db Mon Sep 17 00:00:00 2001 From: Osmium Sorcerer Date: Tue, 24 Mar 2026 02:56:23 +0000 Subject: Rewrite audio engine: replace BASS with miniaudio SFX and blip players largely remain the same. For the music player, we now have to implement network streaming natively, we no longer have a convenient function that did everything for us. I introduced QNetworkRequest to download the stream in memory and signal when it's ready to be decoded and played back. The size is guarded to prevent the client from accidentally downloading terabytes of audio. Delete QFutureWatcher, we no longer need it for concurrency. miniaudio uses a separate audio thread. Network donwloads and communication with the track name display are handled by Qt signals. Also, delete an odd "music.txt" feature. Its purpose was specifying offsets for loops in a text file per track, but it remained obscure and unused in practice. Unsupported: - Large streams, including unbounded ones (radio). We'll need a ring buffer for that, and a mechanism to write to it from the network and feed it to the audio thread. - Effect flags: fade in, fade out, sync pos. Ignored. - Audio device selection. --- src/aoblipplayer.h | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'src/aoblipplayer.h') diff --git a/src/aoblipplayer.h b/src/aoblipplayer.h index 92b43d2..d85cc36 100644 --- a/src/aoblipplayer.h +++ b/src/aoblipplayer.h @@ -2,9 +2,6 @@ #include "aoapplication.h" -#include -#include - #include #include #include @@ -17,6 +14,7 @@ public: static constexpr int STREAM_COUNT = 5; AOBlipPlayer(AOApplication *ao_app); + ~AOBlipPlayer(); void setVolume(int value); void setMuted(bool enabled); @@ -25,13 +23,13 @@ public: void playBlip(); + void updateInternalVolume(); + private: AOApplication *ao_app; - int m_volume = 0; + float m_volume = 0.0f; bool m_muted = false; - HSTREAM m_stream[STREAM_COUNT]{}; - int m_cycle = 0; - - void updateInternalVolume(); + bool m_initialized = false; + ma_sound m_stream[STREAM_COUNT]{}; }; -- cgit