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/UniqueOwnerPointer.h"
14#include "mc/deps/core/utility/pub_sub/Connector.h"
15#include "mc/deps/core/utility/pub_sub/Subscription.h"
16#include "mc/deps/game_refs/WeakRef.h"
45namespace Core {
class Path; }
52 enum class MusicVolumeSource : uint64 {
61 using SoundEventQueue = ::std::vector<::std::pair<::std::string, ::std::shared_ptr<::SoundEvent>>>;
63 using ListenerStatesSpan = ::gsl::span<::std::pair<int, ::ListenerState>>;
68 ::ll::TypedStorage<8, 8, ::gsl::not_null<::std::unique_ptr<::SoundSystemBase>>
const> mSoundSystem;
69 ::ll::TypedStorage<8, 64, ::std::unordered_set<uint64>> mFrameUniqueSoundSet;
70 ::ll::TypedStorage<8, 144, ::SoundEventRepository> mSoundEventRepository;
71 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::IReadWriteOptions>> mOptions;
72 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::TextToSpeechClient>> mTTSClient;
73 ::ll::TypedStorage<8, 16, ::Bedrock::PubSub::Subscription> mMainVolumeOptionSubscription;
74 ::ll::TypedStorage<8, 16, ::Bedrock::PubSub::Subscription> mSoundVolumeOptionSubscription;
75 ::ll::TypedStorage<8, 16, ::Bedrock::PubSub::Subscription> mMusicVolumeOptionSubscription;
76 ::ll::TypedStorage<8, 16, ::Bedrock::PubSub::Subscription> mTextToSpeechVolumeOptionSubscription;
77 ::ll::TypedStorage<8, 16, ::Bedrock::PubSub::Subscription> mOnPauseStateChangeSubscription;
78 ::ll::TypedStorage<8, 24, ::std::vector<::Bedrock::PubSub::Subscription>> mSoundCategoryVolumeOptionSubscriptions;
79 ::ll::TypedStorage<8, 24, ::Bedrock::NonOwnerPointer<::ResourcePackManager>> mResourceManager;
80 ::ll::TypedStorage<8, 24, ::Bedrock::NonOwnerPointer<::LinkedAssetValidator>> mLinkedAssetValidator;
81 ::ll::TypedStorage<4, 140, ::VolumeMultipliers<5>> mMusicVolumeMultipliers;
82 ::ll::TypedStorage<4, 4, float> mMainVolume;
83 ::ll::TypedStorage<4, 4, float> mTTSVolume;
84 ::ll::TypedStorage<1, 1, bool> mMuted;
85 ::ll::TypedStorage<1, 1, bool> mFadeToStopMusic;
86 ::ll::TypedStorage<1, 1, bool> mSoundsReady;
87 ::ll::TypedStorage<8, 392, ::SoundMapping> mSounds;
88 ::ll::TypedStorage<8, 16, ::Bedrock::UniqueOwnerPointer<::Audio::OnlineAudioStreamManager>> mOnlineStreamManager;
89 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::StreamingAudioExperiment>
const> mStreamingExperiment;
90 ::ll::TypedStorage<8, 24, ::Bedrock::NonOwnerPointer<::Core::FileSystem>> mFileSystem;
91 ::ll::TypedStorage<8, 24, ::Bedrock::NonOwnerPointer<::IFileAccess>> mFileAccess;
92 ::ll::TypedStorage<8, 32, ::Core::PathBuffer<::std::string>> mDataPath;
93 ::ll::TypedStorage<8, 8, ::gsl::not_null<::std::unique_ptr<::SoundLoadScheduler>>
const> mSoundLoadScheduler;
94 ::ll::TypedStorage<8, 8, ::std::shared_mutex> mResourceLoadManagerMutex;
95 ::ll::TypedStorage<8, 24, ::Bedrock::NonOwnerPointer<::ResourceLoadManager>> mResourceLoadManager;
101 virtual ~SoundEngine() =
default;
103 virtual void pauseMusic(
bool state) ;
106 ::std::string
const& name,
110 ::std::optional<::ServerSoundHandle> serverSoundHandle
113 virtual uint64 play(::PlaySoundOptions options) ;
115 virtual void stop(::std::string
const& name) ;
117 virtual void stop(uint64 handle) ;
119 virtual void stop(::ServerSoundHandle serverSoundHandle) ;
121 virtual void setVolume(::ServerSoundHandle serverSoundHandle,
float volume) ;
123 virtual void setPitch(::ServerSoundHandle serverSoundHandle,
float pitch) ;
125 virtual void fade(::ServerSoundHandle serverSoundHandle,
float duration,
float targetVolume) ;
127 virtual void setPlaybackPosition(::ServerSoundHandle serverSoundHandle,
float seconds) ;
129 virtual void pause(::ServerSoundHandle serverSoundHandle, ::SoundPauseSource source) ;
131 virtual void resume(::ServerSoundHandle serverSoundHandle, ::SoundPauseSource source) ;
133 virtual void stopAllSounds() ;
135 virtual void pauseAllPlayingSounds(::SoundPauseSource source) ;
137 virtual void resumeAllPreviouslyPlayingSounds(::SoundPauseSource source) ;
139 virtual ::std::optional<::std::string> getSubtitle(::std::string
const& name)
const ;
141 virtual uint64 playUI(::std::string
const& name,
float volume,
float pitch) ;
143 virtual void playMusic(::PlayMusicOptions options) ;
145 virtual void playMusic(::PlayMusicOptions options, uint& playlistIndex) ;
147 virtual bool isLoadingMusic() const ;
149 virtual
bool isPlayingMusicEvent(::std::
string const& eventName) const ;
151 virtual
bool isPlayingMusic(::Core::PathView soundPath) const ;
153 virtual
void fadeToStopMusic(
float fadeSeconds) ;
155 virtual
void setMusicCommandVolumeMultiplier(
float volumeMultiplier) ;
157 virtual
void fadeOut(uint64 handle,
float duration) ;
159 virtual
void stopMusic() ;
161 virtual uint64 registerLoop(
162 ::std::
string const& name,
163 ::std::function<
void(::LoopingSoundState&)> getSoundState,
164 float fadeInDuration,
165 float fadeOutDuration
168 virtual
void unregisterLoop(uint64 handle,
bool hard) ;
170 virtual
bool isPlayingSound(uint64 handle) const ;
172 virtual
bool isPlayingSound(::Core::Path const& soundName) const ;
174 virtual
bool isPlayingSound(::ServerSoundHandle serverSoundHandle) const ;
176 virtual
bool wasSoundStoppedExplicitly(::ServerSoundHandle serverSoundHandle) const ;
178 virtual uint64 playAttached(
179 ::std::
string const& eventName,
180 ::std::function<
void(::SoundInstanceProperties&)>&& getSoundProperties
183 virtual
bool getItem(::std::
string const& eventName, ::Core::PathView soundPath, ::SoundItem& soundItem) const
186 virtual ::Core::PathView getCurrentlyPlayingMusicPath() const ;
188 virtual
void displaySoundEngineStats(::std::
string& debugOutputFormat) const;
190 virtual ::std::optional<::PlayingSoundAttributes> tryGetPlayingSoundAttributes(uint64 handle) const ;
192 virtual ::std::optional<::PlayingSoundAttributes>
193 tryGetPlayingSoundAttributes(::ServerSoundHandle serverSoundHandle) const ;
195 virtual ::std::optional<::LoopingSoundAttributes> tryGetLoopingSoundAttributes(uint64 handle) const ;
206 ::
std::shared_ptr<::
std::vector<::Bedrock::Resources::PreloadedPathHandle>> preloadHandles
209 MCAPI uint64 playFromMemory(
210 ::Core::
Path const& soundName,
218 bool useLegacyMaxDistance,
223 ::
std::
string const& eventName,
224 ::
WeakRef<::Audio::OnlineAudioStream> stream,
226 ::Audio::SoundStartOptions startOptions
246 ::
std::
string const& name,
281 MCNAPI uint64
$playUI(::
std::
string const& name,
float volume,
float pitch);
297 MCNAPI
void $fadeOut(uint64 handle,
float duration);
301 MCAPI uint64 $registerLoop(
302 ::
std::
string const& name,
304 float fadeInDuration,
305 float fadeOutDuration
319 ::
std::
string const& eventName,
323 MCNAPI
bool $getItem(::
std::
string const& eventName, ::Core::PathView soundPath, ::
SoundItem& soundItem) const;
Definition OnlineAudioStreamManager.h:23
Definition OnlineAudioStream.h:7
Definition SoundStartOptions.h:7
Definition PreloadedPathHandle.h:16
Definition Connector.h:19
Definition FileSystem.h:28
Definition IFileAccess.h:15
Definition IReadWriteOptions.h:5
Definition LinkedAssetValidator.h:9
Definition ResourceLoadManager.h:22
Definition ResourcePackManager.h:29
Definition ServerSoundHandle.h:5
Definition SoundEngine.h:5
MCAPI void $pauseMusic(bool state)
MCAPI void $stop(::std::string const &name)
MCAPI bool $isPlayingSound(uint64 handle) const
MCAPI void $resume(::ServerSoundHandle serverSoundHandle, ::SoundPauseSource source)
MCAPI void update(::gsl::span<::std::pair< int, ::ListenerState > > listenerStates, float elapsedTime)
MCAPI uint64 $play(::std::string const &name, ::Vec3 const &pos, float volume, float pitch, ::std::optional<::ServerSoundHandle > serverSoundHandle)
MCAPI void $pauseAllPlayingSounds(::SoundPauseSource source)
MCAPI uint64 $playUI(::std::string const &name, float volume, float pitch)
MCAPI void _playMusic(::PlayMusicOptions options, ::SoundItem soundItem)
MCAPI ::std::optional<::PlayingSoundAttributes > $tryGetPlayingSoundAttributes(uint64 handle) const
MCAPI void $playMusic(::PlayMusicOptions options)
MCAPI void $fade(::ServerSoundHandle serverSoundHandle, float duration, float targetVolume)
MCAPI void $fadeToStopMusic(float fadeSeconds)
MCAPI void $pause(::ServerSoundHandle serverSoundHandle, ::SoundPauseSource source)
MCAPI bool $getItem(::std::string const &eventName, ::Core::PathView soundPath, ::SoundItem &soundItem) const
MCAPI uint64 $playAttached(::std::string const &eventName, ::std::function< void(::SoundInstanceProperties &)> &&getSoundProperties)
MCAPI void $setVolume(::ServerSoundHandle serverSoundHandle, float volume)
MCAPI void $fadeOut(uint64 handle, float duration)
MCAPI void $setPlaybackPosition(::ServerSoundHandle serverSoundHandle, float seconds)
MCAPI bool $isPlayingMusicEvent(::std::string const &eventName) const
MCAPI void $resumeAllPreviouslyPlayingSounds(::SoundPauseSource source)
MCAPI ::std::optional<::LoopingSoundAttributes > $tryGetLoopingSoundAttributes(uint64 handle) const
MCAPI void $unregisterLoop(uint64 handle, bool hard)
MCAPI bool $isLoadingMusic() const
MCAPI void setOptions(::std::shared_ptr<::IReadWriteOptions > options)
MCAPI uint64 playOnlineMusic(::std::string const &eventName, ::WeakRef<::Audio::OnlineAudioStream > stream, float volume, ::Audio::SoundStartOptions startOptions)
MCAPI void $setPitch(::ServerSoundHandle serverSoundHandle, float pitch)
MCAPI void load(bool, ::Bedrock::NonOwnerPointer<::LinkedAssetValidator > validator, ::std::shared_ptr<::std::vector<::Bedrock::Resources::PreloadedPathHandle > > preloadHandles)
MCAPI void $setMusicCommandVolumeMultiplier(float volumeMultiplier)
MCAPI bool $wasSoundStoppedExplicitly(::ServerSoundHandle serverSoundHandle) const
MCAPI void registerPauseManagerCallback(::Bedrock::PubSub::Connector< void(bool)> &connector)
MCAPI void $stopAllSounds()
MCAPI void releaseSoundFileHandles()
MCAPI bool $isPlayingMusic(::Core::PathView soundPath) const
MCAPI ::std::optional<::std::string > $getSubtitle(::std::string const &name) const
MCAPI void $displaySoundEngineStats(::std::string &debugOutputFormat) const
MCAPI::Core::PathView $getCurrentlyPlayingMusicPath() const
MCAPI void setTTSClient(::std::shared_ptr<::TextToSpeechClient > ttsClient)
Definition SoundEvent.h:10
Definition SoundLoadScheduler.h:5
Definition SoundPlayerInterface.h:24
Definition SoundSystemBase.h:31
Definition StreamingAudioExperiment.h:11
Definition TextToSpeechClient.h:5
Definition ListenerState.h:5
Definition LoopingSoundAttributes.h:8
Definition LoopingSoundState.h:5
Definition PlayMusicOptions.h:5
Definition PlaySoundOptions.h:10
Definition PlayingSoundAttributes.h:5
Definition SoundInstanceProperties.h:5