27void LegoCacheSound::Init()
32 memset(&m_wfx, 0,
sizeof(m_wfx));
43 LPPCMWAVEFORMAT p_pwfx,
53 wfx.wFormatTag = p_pwfx->wf.wFormatTag;
54 wfx.nChannels = p_pwfx->wf.nChannels;
55 wfx.nSamplesPerSec = p_pwfx->wf.nSamplesPerSec;
56 wfx.nAvgBytesPerSec = p_pwfx->wf.nAvgBytesPerSec;
57 wfx.nBlockAlign = p_pwfx->wf.nBlockAlign;
58 wfx.wBitsPerSample = p_pwfx->wBitsPerSample;
62 memset(&desc, 0,
sizeof(desc));
63 desc.
dwSize =
sizeof(desc);
84 m_dsBuffer->SetVolume(attenuation);
87 m_dsBuffer->Release();
92 if (p_data !=
NULL && p_dataSize != 0) {
93 CopyData(p_data, p_dataSize);
96 m_unk0x48 = GetBaseFilename(p_mediaSrcPath);
103void LegoCacheSound::CopyData(
MxU8* p_data,
MxU32 p_dataSize)
109 m_dataSize = p_dataSize;
110 m_data =
new MxU8[m_dataSize];
111 memcpy(m_data, p_data, m_dataSize);
120 m_dsBuffer->Release();
135 MxResult result = pnew->
Create(&m_wfx, m_unk0x48, m_volume, m_data, m_dataSize);
151 if (m_data ==
NULL || m_dataSize == 0) {
158 if (p_name !=
NULL) {
163 m_dsBuffer->GetStatus(&dwStatus);
166 m_dsBuffer->Restore();
167 m_dsBuffer->GetStatus(&dwStatus);
171 LPVOID pvAudioPtr1, pvAudioPtr2;
172 DWORD dwAudioBytes1, dwAudioBytes2;
174 if (m_dsBuffer->Lock(0, m_dataSize, &pvAudioPtr1, &dwAudioBytes1, &pvAudioPtr2, &dwAudioBytes2, 0) ==
DS_OK) {
175 memcpy(pvAudioPtr1, m_data, dwAudioBytes1);
177 if (dwAudioBytes2 != 0) {
178 memcpy(pvAudioPtr2, m_data + dwAudioBytes1, dwAudioBytes2);
181 DWORD sts = m_dsBuffer->Unlock(pvAudioPtr1, dwAudioBytes1, pvAudioPtr2, dwAudioBytes2);
183 m_dsBuffer->SetCurrentPosition(0);
184 if (m_dsBuffer->Play(0, 0, p_looping)) {
196 if (p_looping ==
FALSE) {
213 m_dsBuffer->GetStatus(&dwStatus);
234 m_dsBuffer->GetStatus(&dwStatus);
267 else if (m_unk0x6a) {
268 m_dsBuffer->Play(0, 0, m_looping);
290 if (m_muted != p_muted) {
294 m_dsBuffer->SetVolume(-3000);
299 m_dsBuffer->SetVolume(attenuation);
308 if (m_muted != p_muted) {
315 m_dsBuffer->Play(0, 0, m_looping);
329 char* p = str + strlen(str);
void Reset()
[AI] Releases any in-world/actor/ROI associations and resets member pointers.
MxS32 SetDistance(MxS32 p_min, MxS32 p_max)
[AI] Sets the minimum and maximum 3D sound effective distances if 3D sound is enabled.
MxU32 UpdatePosition(LPDIRECTSOUNDBUFFER p_directSoundBuffer)
[AI] Recalculates and updates the sound position on the underlying DirectSound 3D buffer or the volum...
void FUN_10011a60(LPDIRECTSOUNDBUFFER p_directSoundBuffer, const char *p_name)
[AI] Associates a new in-world object to this sound, updating its 3D position tracking and (if applic...
MxResult Create(LPDIRECTSOUNDBUFFER p_directSoundBuffer, const char *p_name, MxS32 p_volume)
[AI] Initializes 3D sound for a given DirectSound buffer and associates it with a named game object.
Sound cache object managing DirectSound buffers and 3D positioning for preloaded sound data.
void SetDistance(MxS32 p_min, MxS32 p_max)
Sets minimum and maximum audible distances for 3D sound attenuation.
LegoCacheSound * Clone()
Creates an identical copy of this LegoCacheSound, including memory buffers, properties,...
MxResult Play(const char *p_name, MxBool p_looping)
Starts playback of the cached sound in this buffer.
void FUN_10006be0()
Handles sound updates per tick; manages stopping, buffer state, and 3D-position refreshes if sound is...
virtual MxResult Create(LPPCMWAVEFORMAT p_pwfx, MxString p_mediaSrcPath, MxS32 p_volume, MxU8 *p_data, MxU32 p_dataSize)
Creates the sound object with given audio format, source path, volume, and initializes DirectSound bu...
virtual void FUN_10006cd0(undefined4 param1, undefined4 param2)
Unknown legacy/function stub.
~LegoCacheSound() override
Destructor; releases owned sound resources and buffer, unmutes if needed.
void MuteStop(MxBool p_mute)
Mutes/unmutes by stopping (mute) or resuming playback.
void Stop()
Immediately stops playback and resets buffer, clearing event tag and position cues.
LegoCacheSound()
Constructs a new LegoCacheSound and initializes its members to default/empty state.
virtual void Destroy()
Releases allocated DirectSound buffer and internal data, resetting all fields.
void MuteSilence(MxBool p_muted)
Mutes/unmutes by scaling volume to minimum (muted) or restoring original volume.
virtual MxS32 GetVolume()
[AI] Gets the current global audio volume.
static MxBool IsSound3D()
[AI] Returns current state of 3D sound configuration.
MxS32 GetAttenuation(MxU32 p_volume)
[AI] Maps a percentage volume (1-100) to a DirectSound-specific attenuation value.
LPDIRECTSOUND GetDirectSound()
[AI] Gets pointer to internal DirectSound interface.
Mindscape custom string class for managing dynamic C-strings within the game engine.
char * GetData() const
Returns a pointer to the internal character buffer.
const MxU16 GetLength() const
Returns the length of the string (number of characters, not including null terminator).
typedef DWORD(FAR PASCAL *LPCLIPPERCALLBACK)(LPDIRECTDRAWCLIPPER lpDDClipper
#define DECOMP_SIZE_ASSERT(T, S)
#define DSBCAPS_CTRLVOLUME
#define DSBSTATUS_BUFFERLOST
#define DSBCAPS_LOCSOFTWARE
#define DSBCAPS_CTRLFREQUENCY
#define NULL
[AI] Null pointer value (C/C++ semantics).
#define FAILURE
[AI] Used to indicate a failed operation in result codes.
#define SUCCESS
[AI] Used to indicate a successful operation in result codes.
LegoSoundManager * SoundManager()
[AI] Accessor for the game's LegoSoundManager subsystem from the global LegoOmni instance....
LPWAVEFORMATEX lpwfxFormat