From c9f52b7223685d2e7fca925594171f94dd8c6e3b Mon Sep 17 00:00:00 2001 From: TrickyLeifa Date: Wed, 15 May 2024 00:00:17 +0200 Subject: Ported to CMake, ... * Ported the project to CMake * Android and Mac support dropped for the time being. * Tests, BASS and Discord-RPC are now options * Restructured and reformated the project. * Merged `include` and `src` * Renamed `resource` to `data` * Renamed various files * External libraries headers are no longer included in `src` * Replaced header guards with #pragma once * Multiple refactors (keywords, headers) * Added Qt6 compatibility * Removed various unused functions and headers * Reworked AOPacket * When content is passed to AOPacket, it should be ensured that the content is already decoded. * Encoding/decoding are now static methods. * Fixed various memory leaks * Removed animation code for AOImage * AOImage is always using static images * Simplified ChatLogPiece --- src/aomusicplayer.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/aomusicplayer.h (limited to 'src/aomusicplayer.h') diff --git a/src/aomusicplayer.h b/src/aomusicplayer.h new file mode 100644 index 0000000..248a45e --- /dev/null +++ b/src/aomusicplayer.h @@ -0,0 +1,44 @@ +#pragma once + +#include "aoapplication.h" + +#include + +class AOMusicPlayer +{ +public: + // Channel 0 = music + // Channel 1 = ambience + static constexpr int CHANNEL_COUNT = 2; + + AOMusicPlayer(AOApplication *p_ao_app); + virtual ~AOMusicPlayer(); + + void set_volume(int p_value, int channel = -1); + void set_looping(bool loop_song, int channel = 0); + void set_muted(bool toggle); + + QFutureWatcher music_watcher; + +public Q_SLOTS: + QString play(QString p_song, int channel = 0, bool loop = false, int effect_flags = 0); + void stop(int channel = 0); + +private: + AOApplication *ao_app; + + bool m_muted = false; + int m_volume[CHANNEL_COUNT] = {0, 0}; + HSTREAM m_stream_list[CHANNEL_COUNT]; + HSYNC m_loop_sync[CHANNEL_COUNT]; + + /** + * @brief The starting sample of the AB-Loop. + */ + unsigned int m_loop_start[CHANNEL_COUNT] = {0, 0}; + + /** + * @brief The end sample of the AB-Loop. + */ + unsigned int m_loop_end[CHANNEL_COUNT] = {0, 0}; +}; -- cgit From 1ef96383c8f7ed136a0e028aef0835b4838b5e95 Mon Sep 17 00:00:00 2001 From: TrickyLeifa Date: Fri, 17 May 2024 16:39:30 +0200 Subject: Lightly reworked `NetworkManager`, ... * Lightly reworked `NetworkManager` * Added new modules to handle various connection types. * TCP * WebSocket * Added general string splitter alias based on Qt version. * Replaced `lobby_constructed` and `courtroom_constructed` * Refactored and partially reimplemented the following classes: * `AOBlipPlayer` * `AOEmotePreview` * `AOMusicPlayer` * `AOSfxPlayer` * `AOTextArea` --- src/aomusicplayer.h | 42 ++++++++++++++++++------------------------ 1 file changed, 18 insertions(+), 24 deletions(-) (limited to 'src/aomusicplayer.h') diff --git a/src/aomusicplayer.h b/src/aomusicplayer.h index 248a45e..707d64a 100644 --- a/src/aomusicplayer.h +++ b/src/aomusicplayer.h @@ -7,38 +7,32 @@ class AOMusicPlayer { public: - // Channel 0 = music - // Channel 1 = ambience - static constexpr int CHANNEL_COUNT = 2; + // 0 = music + // 1 = ambience + static constexpr int STREAM_COUNT = 2; - AOMusicPlayer(AOApplication *p_ao_app); + explicit AOMusicPlayer(AOApplication *ao_app); virtual ~AOMusicPlayer(); - void set_volume(int p_value, int channel = -1); - void set_looping(bool loop_song, int channel = 0); - void set_muted(bool toggle); + void setMuted(bool enabled); - QFutureWatcher music_watcher; + QString playStream(QString song, int streamId, bool loopEnabled, int effectFlags); -public Q_SLOTS: - QString play(QString p_song, int channel = 0, bool loop = false, int effect_flags = 0); - void stop(int channel = 0); + void setStreamVolume(int value, int streamId); + void setStreamLooping(bool enabled, int streamId); + + QFutureWatcher m_watcher; private: AOApplication *ao_app; bool m_muted = false; - int m_volume[CHANNEL_COUNT] = {0, 0}; - HSTREAM m_stream_list[CHANNEL_COUNT]; - HSYNC m_loop_sync[CHANNEL_COUNT]; - - /** - * @brief The starting sample of the AB-Loop. - */ - unsigned int m_loop_start[CHANNEL_COUNT] = {0, 0}; - - /** - * @brief The end sample of the AB-Loop. - */ - unsigned int m_loop_end[CHANNEL_COUNT] = {0, 0}; + + int m_volume[STREAM_COUNT]{}; + HSTREAM m_stream_list[STREAM_COUNT]{}; + HSYNC m_loop_sync[STREAM_COUNT]{}; + quint32 m_loop_start[STREAM_COUNT]{}; + quint32 m_loop_end[STREAM_COUNT]{}; + + bool ensureValidStreamId(int streamId); }; -- cgit