3#include "mc/_HeaderOutputPredefine.h"
6#include "mc/client/sound/SoundMapping.h"
7#include "mc/client/sound/VolumeMultipliers.h"
8#include "mc/deps/audio/SoundEventRepository.h"
9#include "mc/deps/audio/SoundPauseSource.h"
10#include "mc/deps/audio/SoundPlayerInterface.h"
11#include "mc/deps/core/file/PathBuffer.h"
12#include "mc/deps/core/utility/NonOwnerPointer.h"
13#include "mc/deps/core/utility/pub_sub/Connector.h"
14#include "mc/deps/core/utility/pub_sub/Subscription.h"
39namespace Core {
class Path; }
46 enum class MusicVolumeSource : uint64 {
55 using SoundEventQueue = ::std::vector<::std::pair<::std::string, ::std::shared_ptr<::SoundEvent>>>;
57 using ListenerStatesSpan = ::gsl::span<::std::pair<int, ::ListenerState>>;
62 ::ll::TypedStorage<8, 8, ::gsl::not_null<::std::unique_ptr<::SoundSystemBase>>
const> mSoundSystem;
63 ::ll::TypedStorage<8, 64, ::std::unordered_set<uint64>> mFrameUniqueSoundSet;
64 ::ll::TypedStorage<8, 144, ::SoundEventRepository> mSoundEventRepository;
65 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::IReadWriteOptions>> mOptions;
66 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::TextToSpeechClient>> mTTSClient;
67 ::ll::TypedStorage<8, 16, ::Bedrock::PubSub::Subscription> mMainVolumeOptionSubscription;
68 ::ll::TypedStorage<8, 16, ::Bedrock::PubSub::Subscription> mSoundVolumeOptionSubscription;
69 ::ll::TypedStorage<8, 16, ::Bedrock::PubSub::Subscription> mMusicVolumeOptionSubscription;
70 ::ll::TypedStorage<8, 16, ::Bedrock::PubSub::Subscription> mTextToSpeechVolumeOptionSubscription;
71 ::ll::TypedStorage<8, 16, ::Bedrock::PubSub::Subscription> mOnPauseStateChangeSubscription;
72 ::ll::TypedStorage<8, 24, ::std::vector<::Bedrock::PubSub::Subscription>> mSoundCategoryVolumeOptionSubscriptions;
73 ::ll::TypedStorage<8, 24, ::Bedrock::NonOwnerPointer<::ResourcePackManager>> mResourceManager;
74 ::ll::TypedStorage<8, 24, ::Bedrock::NonOwnerPointer<::LinkedAssetValidator>> mLinkedAssetValidator;
75 ::ll::TypedStorage<4, 140, ::VolumeMultipliers<5>> mMusicVolumeMultipliers;
76 ::ll::TypedStorage<4, 4, float> mMainVolume;
77 ::ll::TypedStorage<4, 4, float> mTTSVolume;
78 ::ll::TypedStorage<1, 1, bool> mMuted;
79 ::ll::TypedStorage<1, 1, bool> mFadeToStopMusic;
80 ::ll::TypedStorage<8, 392, ::SoundMapping> mSounds;
81 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::Audio::OnlineAudioStreamManager>> mOnlineStreamManager;
82 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::StreamingAudioExperiment>
const> mStreamingExperiment;
83 ::ll::TypedStorage<8, 24, ::Bedrock::NonOwnerPointer<::Core::FileSystem>> mFileSystem;
84 ::ll::TypedStorage<8, 24, ::Bedrock::NonOwnerPointer<::IFileAccess>> mFileAccess;
85 ::ll::TypedStorage<8, 32, ::Core::PathBuffer<::std::string>> mDataPath;
86 ::ll::TypedStorage<8, 8, ::std::shared_mutex> mResourceLoadManagerMutex;
87 ::ll::TypedStorage<8, 24, ::Bedrock::NonOwnerPointer<::ResourceLoadManager>> mResourceLoadManager;
93 virtual ~SoundEngine() =
default;
95 virtual void pauseMusic(
bool state) ;
98 ::std::string
const& name,
102 ::std::optional<::ServerSoundHandle> serverSoundHandle
105 virtual uint64 play(::PlaySoundOptions options) ;
107 virtual void stop(::std::string
const& name) ;
109 virtual void stop(uint64 handle) ;
111 virtual void stop(::ServerSoundHandle serverSoundHandle) ;
113 virtual void setVolume(::ServerSoundHandle serverSoundHandle,
float volume) ;
115 virtual void setPitch(::ServerSoundHandle serverSoundHandle,
float pitch) ;
117 virtual void fade(::ServerSoundHandle serverSoundHandle,
float duration,
float targetVolume) ;
119 virtual void setPlaybackPosition(::ServerSoundHandle serverSoundHandle,
float seconds) ;
121 virtual void pause(::ServerSoundHandle serverSoundHandle, ::SoundPauseSource source) ;
123 virtual void resume(::ServerSoundHandle serverSoundHandle, ::SoundPauseSource source) ;
125 virtual void stopAllSounds() ;
127 virtual void pauseAllPlayingSounds(::SoundPauseSource source) ;
129 virtual void resumeAllPreviouslyPlayingSounds(::SoundPauseSource source) ;
131 virtual ::std::optional<::std::string> getSubtitle(::std::string
const& name)
const ;
133 virtual uint64 playUI(::std::string
const& name,
float volume,
float pitch) ;
135 virtual void playMusic(::std::string
const& eventName,
float volume, uint& playlistIndex) ;
137 virtual void playMusic(::std::string
const& eventName,
float volume) ;
139 virtual bool isLoadingMusic() const ;
141 virtual
bool isPlayingMusicEvent(::std::
string const& eventName) const ;
143 virtual
bool isPlayingMusic(::Core::PathView soundPath) const ;
145 virtual
void fadeToStopMusic(
float fadeSeconds) ;
147 virtual
void setMusicCommandVolumeMultiplier(
float volumeMultiplier) ;
149 virtual
void fadeOut(uint64 handle,
float duration) ;
151 virtual
void stopMusic() ;
153 virtual uint64 registerLoop(
154 ::std::
string const& name,
155 ::std::function<
void(::LoopingSoundState&)> getSoundState,
156 float fadeInDuration,
157 float fadeOutDuration
160 virtual
void unregisterLoop(uint64 handle,
bool hard) ;
162 virtual
bool isPlayingSound(uint64 handle) const ;
164 virtual
bool isPlayingSound(::Core::Path const& soundName) const ;
166 virtual
bool isPlayingSound(::ServerSoundHandle serverSoundHandle) const ;
168 virtual uint64 playAttached(
169 ::std::
string const& eventName,
170 ::std::function<
void(::SoundInstanceProperties&)>&& getSoundProperties
173 virtual
bool getItem(::std::
string const& eventName, ::Core::PathView soundPath, ::SoundItem& soundItem) const
176 virtual ::Core::PathBuffer<::std::
string> const& getCurrentlyPlayingMusicPath() ;
178 virtual
void displaySoundEngineStats(::std::
string& debugOutputFormat) const;
180 virtual ::std::optional<::PlayingSoundAttributes> tryGetPlayingSoundAttributes(uint64 handle) const ;
182 virtual ::std::optional<::LoopingSoundAttributes> tryGetLoopingSoundAttributes(uint64 handle) const ;
188 MCAPI
void _loadSoundEvents(
189 ::std::vector<::std::pair<::std::
string, ::std::shared_ptr<::SoundEvent>>>& soundEvents,
190 ::Bedrock::NonOwnerPointer<::LinkedAssetValidator> validator
194 _tryPlayMusicFromStreamingExperiment(::std::
string const& eventName, ::SoundItem const& soundItem,
float volume);
198 ::Bedrock::NonOwnerPointer<::LinkedAssetValidator> validator,
199 ::std::shared_ptr<::std::vector<::Bedrock::Resources::PreloadedPathHandle>> preloadHandles
202 MCAPI uint64 playFromMemory(
203 ::Core::Path const& soundName,
211 bool useLegacyMaxDistance,
215 MCAPI
void registerPauseManagerCallback(::Bedrock::PubSub::Connector<
void(
bool)>& connector);
217 MCAPI
void setOptions(::std::shared_ptr<::IReadWriteOptions> options);
219 MCAPI
void setTTSClient(::std::shared_ptr<::TextToSpeechClient> ttsClient);
221 MCAPI
void update(::gsl::span<::std::pair<
int, ::ListenerState>> listenerStates,
float elapsedTime);
227 MCAPI
void $pauseMusic(
bool state);
230 ::std::
string const& name,
234 ::std::optional<::ServerSoundHandle> serverSoundHandle
237 MCAPI uint64 $play(::PlaySoundOptions options);
239 MCAPI
void $stop(::std::
string const& name);
241 MCAPI
void $stop(uint64 handle);
243 MCAPI
void $stop(::ServerSoundHandle serverSoundHandle);
245 MCAPI
void $setVolume(::ServerSoundHandle serverSoundHandle,
float volume);
247 MCAPI
void $setPitch(::ServerSoundHandle serverSoundHandle,
float pitch);
249 MCAPI
void $fade(::ServerSoundHandle serverSoundHandle,
float duration,
float targetVolume);
251 MCAPI
void $setPlaybackPosition(::ServerSoundHandle serverSoundHandle,
float seconds);
253 MCAPI
void $pause(::ServerSoundHandle serverSoundHandle, ::SoundPauseSource source);
255 MCAPI
void $resume(::ServerSoundHandle serverSoundHandle, ::SoundPauseSource source);
257 MCAPI
void $stopAllSounds();
259 MCAPI
void $pauseAllPlayingSounds(::SoundPauseSource source);
261 MCAPI
void $resumeAllPreviouslyPlayingSounds(::SoundPauseSource source);
263 MCAPI ::std::optional<::std::
string> $getSubtitle(::std::
string const& name) const;
265 MCAPI uint64 $playUI(::std::
string const& name,
float volume,
float pitch);
267 MCAPI
void $playMusic(::std::
string const& eventName,
float volume, uint& playlistIndex);
269 MCAPI
void $playMusic(::std::
string const& eventName,
float volume);
271 MCAPI
bool $isLoadingMusic() const;
273 MCAPI
bool $isPlayingMusicEvent(::std::
string const& eventName) const;
275 MCAPI
bool $isPlayingMusic(::Core::PathView soundPath) const;
277 MCAPI
void $fadeToStopMusic(
float fadeSeconds);
279 MCAPI
void $setMusicCommandVolumeMultiplier(
float volumeMultiplier);
281 MCAPI
void $fadeOut(uint64 handle,
float duration);
283 MCAPI
void $stopMusic();
285 MCAPI uint64 $registerLoop(
286 ::std::
string const& name,
287 ::std::function<
void(::LoopingSoundState&)> getSoundState,
288 float fadeInDuration,
289 float fadeOutDuration
292 MCAPI
void $unregisterLoop(uint64 handle,
bool hard);
294 MCAPI
bool $isPlayingSound(uint64 handle) const;
296 MCAPI
bool $isPlayingSound(::Core::Path const& soundName) const;
298 MCAPI
bool $isPlayingSound(::ServerSoundHandle serverSoundHandle) const;
300 MCAPI uint64 $playAttached(
301 ::std::
string const& eventName,
302 ::std::function<
void(::SoundInstanceProperties&)>&& getSoundProperties
305 MCAPI
bool $getItem(::std::
string const& eventName, ::Core::PathView soundPath, ::SoundItem& soundItem) const;
307 MCAPI ::Core::PathBuffer<::std::
string> const& $getCurrentlyPlayingMusicPath();
309 MCAPI
void $displaySoundEngineStats(::std::
string& debugOutputFormat) const;
311 MCAPI ::std::optional<::PlayingSoundAttributes> $tryGetPlayingSoundAttributes(uint64 handle) const;
313 MCAPI ::std::optional<::LoopingSoundAttributes> $tryGetLoopingSoundAttributes(uint64 handle) const;
Definition OnlineAudioStreamManager.h:19
Definition PreloadedPathHandle.h:16
Definition FileSystem.h:28
Definition IFileAccess.h:15
Definition IReadWriteOptions.h:5
Definition LinkedAssetValidator.h:8
Definition ResourceLoadManager.h:18
Definition ResourcePackManager.h:38
Definition ServerSoundHandle.h:5
Definition SoundEngine.h:5
Definition SoundEvent.h:10
Definition SoundPlayerInterface.h:24
Definition SoundSystemBase.h:5
Definition StreamingAudioExperiment.h:5
Definition TextToSpeechClient.h:5
Definition ListenerState.h:5
Definition LoopingSoundAttributes.h:8
Definition LoopingSoundState.h:5
Definition PlaySoundOptions.h:5
Definition PlayingSoundAttributes.h:5
Definition SoundInstanceProperties.h:5