Etterna 0.74.4
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 }
40
41 std::string sFile;
42 const TimingData* pTiming;
43 bool bForceLoop;
44 float fStartSecond;
45 float fLengthSeconds;
46 float fFadeInLengthSeconds;
47 float fFadeOutLengthSeconds;
48 bool bAlignBeat;
49 bool bApplyMusicRate;
50 bool bAccurateSync;
51 };
52 void PlayMusic(PlayMusicParams params,
53 PlayMusicParams FallbackMusicParams = PlayMusicParams());
54 void PlayMusic(const std::string& sFile,
55 const TimingData* pTiming = nullptr,
56 bool force_loop = false,
57 float start_sec = 0,
58 float length_sec = -1,
59 float fFadeInLengthSeconds = 0,
60 float fade_len = 0,
61 bool align_beat = true,
62 bool bApplyMusicRate = false,
63 bool bAccurateSync = false);
64 void StopMusic() { PlayMusic(""); }
65 void DimMusic(float fVolume, float fDurationSeconds);
66 [[nodiscard]] auto GetMusicPath() const -> std::string;
67 void Flush();
68
69 void PlayOnce(const std::string& sPath);
70 void PlayOnceFromDir(const std::string& sDir);
71 void PlayOnceFromAnnouncer(const std::string& sFolderName);
72
73 void HandleSongTimer(bool on = true);
74
75 static auto GetPlayerBalance(PlayerNumber pn) -> float;
76 void WithRageSoundPlaying(std::function<void(RageSound*)> f);
77 auto GetPlayingMusicTiming() -> TimingData;
78
79 // Set a sound's position given its pointer
80 // Meant to avoid blocking the game execution (stutter)
81 void SetSoundPosition(RageSound* s, float fSeconds);
82
83 void SetPlayingMusicParams(RageSoundParams p);
84
85 const RageSoundParams& GetPlayingMusicParams();
86
87 void StartMusic(MusicToPlay& ToPlay);
88 void DoPlayOnce(std::string sPath);
89 void StartQueuedSounds();
90 void DoPlayOnceFromDir(std::string sPath);
91 auto SoundWaiting() -> bool;
92 void HandleSetPosition();
93
94 void HandleSetParams();
95
96 std::shared_ptr<LuaReference> soundPlayCallback;
97 unsigned int recentPCMSamplesBufferSize = 1024;
98 Screen* callbackOwningScreen{ nullptr };
99
100 void HandleMessage(const Message& msg) override;
101
102 void ResyncMusicPlaying();
103
104 // Lua
105 void PushSelf(lua_State* L);
106};
107
108extern GameSoundManager* SOUND;
109#endif
High-level sound utilities.
Definition GameSoundManager.h:20
A self-cleaning Lua reference.
Definition LuaReference.h:10
Definition MessageManager.h:177
Definition RageSound.h:130
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:96
Definition GameSoundManager.cpp:94
The parameters to play a sound.
Definition RageSound.h:51