Etterna 0.75.1
Loading...
Searching...
No Matches
GameSoundManager.h
1#ifndef RAGE_SOUNDS_H
2#define RAGE_SOUNDS_H
3
4#include <functional>
5#include "Etterna/Models/Misc/PlayerNumber.h"
6#include "MessageManager.h"
7
8struct RageSoundParams;
9class TimingData;
10class Screen;
11class RageSound;
12struct lua_State;
13struct MusicToPlay;
14
15auto
16MusicThread_start(void* p) -> int;
17
20{
21 public:
23 ~GameSoundManager() override;
24 void Update(float fDeltaTime);
25
27 {
29 {
30 pTiming = nullptr;
31 bForceLoop = false;
32 fStartSecond = 0;
33 fLengthSeconds = -1;
34 fFadeInLengthSeconds = 0;
35 fFadeOutLengthSeconds = 0;
36 bAlignBeat = true;
37 bApplyMusicRate = false;
38 bAccurateSync = false;
39 bIsBGM = false;
40 }
41
42 std::string sFile;
43 const TimingData* pTiming;
44 bool bForceLoop;
45 float fStartSecond;
46 float fLengthSeconds;
47 float fFadeInLengthSeconds;
48 float fFadeOutLengthSeconds;
49 bool bAlignBeat;
50 bool bApplyMusicRate;
51 bool bAccurateSync;
52 bool bIsBGM;
53 };
54 void PlayMusic(PlayMusicParams params,
55 PlayMusicParams FallbackMusicParams = PlayMusicParams());
56 void PlayMusic(const std::string& sFile,
57 const TimingData* pTiming = nullptr,
58 bool force_loop = false,
59 float start_sec = 0,
60 float length_sec = -1,
61 float fFadeInLengthSeconds = 0,
62 float fade_len = 0,
63 bool align_beat = true,
64 bool bApplyMusicRate = false,
65 bool bAccurateSync = false);
66 void StopMusic()
67 {
68 MESSAGEMAN->Broadcast("StoppedMusic");
69 PlayMusic("");
70 }
71 void DimMusic(float fVolume, float fDurationSeconds);
72 [[nodiscard]] auto GetMusicPath() const -> std::string;
73 void Flush();
74
75 void PlayOnce(const std::string& sPath);
76 void PlayOnceFromDir(const std::string& sDir);
77 void PlayOnceFromAnnouncer(const std::string& sFolderName);
78
79 void HandleSongTimer(bool on = true);
80
81 static auto GetPlayerBalance(PlayerNumber pn) -> float;
82 void WithRageSoundPlaying(std::function<void(RageSound*)> f);
83 auto GetPlayingMusicTiming() -> TimingData;
84
85 // Set a sound's position given its pointer
86 // Meant to avoid blocking the game execution (stutter)
87 void SetSoundPosition(RageSound* s, float fSeconds);
88
89 void SetPlayingMusicParams(RageSoundParams p);
90
91 const RageSoundParams& GetPlayingMusicParams();
92
93 void StartMusic(MusicToPlay& ToPlay);
94 void DoPlayOnce(std::string sPath);
95 void StartQueuedSounds();
96 void DoPlayOnceFromDir(std::string sPath);
97 auto SoundWaiting() -> bool;
98 void HandleSetPosition();
99
100 void HandleSetParams();
101
102 std::shared_ptr<LuaReference> soundPlayCallback;
103 unsigned int recentPCMSamplesBufferSize = 1024;
104 Screen* callbackOwningScreen{ nullptr };
105
106 void HandleMessage(const Message& msg) override;
107
108 void ResyncMusicPlaying();
109
110 // Lua
111 void PushSelf(lua_State* L);
112};
113
114extern GameSoundManager* SOUND;
115#endif
High-level sound utilities.
Definition GameSoundManager.h:20
A self-cleaning Lua reference.
Definition LuaReference.h:10
Definition MessageManager.h:182
Definition RageSound.h:135
Class that holds a screen-full of Actors.
Definition Screen.h:64
Holds data for translating beats<->seconds.
Definition TimingData.h:54
Definition GameSoundManager.h:27
Definition MessageManager.h:101
Definition GameSoundManager.cpp:94
The parameters to play a sound.
Definition RageSound.h:51