51 if (!p_fromDestructor) {
59 DWORD dwCurrentPlayCursor, dwCurrentWriteCursor;
60 MxS8 playedChunks = -1;
62 if (
m_dsBuffer->GetCurrentPosition(&dwCurrentPlayCursor, &dwCurrentWriteCursor) ==
DS_OK) {
103 if (
m_dsBuffer->Lock(dwOffset,
m_lockSize, &pvAudioPtr1, &dwAudioBytes1, &pvAudioPtr2, &dwAudioBytes2, 0) ==
105 memcpy(pvAudioPtr1, p_audioPtr, p_length);
137 WAVEFORMATEX waveFormatEx;
140 memset(&waveFormatEx, 0,
sizeof(waveFormatEx));
149 if (waveFormatEx.wBitsPerSample == 8) {
153 if (waveFormatEx.wBitsPerSample == 16) {
158 memset(&desc, 0,
sizeof(desc));
159 desc.
dwSize =
sizeof(desc);
219 DWORD dwCurrentPlayCursor, dwCurrentWriteCursor;
220 m_dsBuffer->GetCurrentPosition(&dwCurrentPlayCursor, &dwCurrentWriteCursor);
336 memcpy(extraCopy, extraData, extraLength);
337 extraCopy[extraLength] =
'\0';
339 char soundValue[512];
341 if (!strcmpi(soundValue,
"FALSE")) {
virtual MxS32 GetVolume()
[AI] Gets the current global audio volume.
virtual MxS32 GetVolume()
[AI] Returns the current runtime audio volume for this presenter (0-100).
MxS32 m_volume
[AI] Current playback volume, range 0-100 (percent).
void Enter()
[AI] Acquires/gains entry to the critical section or mutex, blocking if not available.
void Leave()
[AI] Releases/leaves the critical section or mutex.
MxU32 GetFlags()
[AI] Returns the flag field for this action (bitmask).
void GetExtra(MxU16 &p_extraLength, char *&p_extraData)
[AI] Retrieves the extra data and its length for this action.
MxS32 GetLoopCount()
[AI] Returns the loop count for this action.
virtual MxLong GetDuration()
[AI] Gets the duration for which this action is intended to run.
virtual MxLong GetElapsedTime()
[AI] Gets elapsed time for this action since the last time field 0x90 was set.
@ c_looping
[AI] Action or media should repeat in a loop [AI]
@ c_bit7
[AI] Unknown - possibly reserved [AI]
MxU32 GetLength()
[AI] Returns the length in bytes of the data payload. [AI]
MxLong GetTime()
[AI] Returns the time (timestamp or tick) associated with this chunk. [AI]
void SetData(MxU8 *p_data)
[AI] Sets the pointer to the raw payload data (may or may not be owned by chunk object).
MxU8 * GetData()
[AI] Returns a pointer to the start of the data payload. [AI]
void SetChunkFlags(MxU16 p_flags)
[AI] Sets all chunk header flag bits.
MxU16 GetChunkFlags()
[AI] Returns the chunk's flag bitfield. [AI]
void SetLength(MxU32 p_length)
[AI] Sets the payload data length for this chunk.
void SetTime(MxLong p_time)
[AI] Sets the time (timestamp/tick/frame) associated with this chunk.
[AI] Represents a sound action extracted from an SI script and used in the data-driven action system.
void FreeDataChunk(MxStreamChunk *p_chunk)
[AI] Frees (deletes) a data chunk if it's found in the consumed data list; also forcibly deletes sing...
static MxOmni * GetInstance()
[AI] Returns the singleton instance of the MxOmni subsystem coordinator.
MxSoundManager * GetSoundManager() const
[AI] Gets the engine's sound manager used for playing/controlling sounds.
virtual void ParseExtra()
[AI] Parses additional data from the associated action for configuration or world interaction.
void ProgressTickleState(TickleState p_tickleState)
[AI] Helper for advancing the presenter's tickle state and updating transition history.
MxBool IsEnabled()
[AI] Returns whether this presenter is logically enabled (based on the associated action's flags).
MxDSAction * m_action
[AI] The associated action currently being presented by this presenter.
TickleState m_currentTickleState
[AI] Current state in the tickle lifecycle.
@ e_repeating
[AI] Presentation is repeating (e.g., looping media).
@ e_done
[AI] Completed processing the current action.
@ e_starting
[AI] In the process of starting playback/presentation.
@ e_streaming
[AI] Streaming or rendering actively.
MxCriticalSection m_criticalSection
[AI] Thread synchronization for presenter state and data.
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.
void Destroy() override
[AI] Public destroy method called by the engine to clean up the presenter.
MxResult AddToManager() override
[AI] Registers this presenter with the global MxSoundManager.
[AI] Represents a streamable chunk of data, typically sourced from a media buffer and designed for no...
[AI] Presenter for streaming and managing PCM waveform audio via DirectSound buffer.
MxResult AddToManager() override
[AI] Registers this presenter with the global MxSoundManager.
virtual void Pause()
[AI] Pauses audio playback, halting sound buffer while keeping position for resume.
void Enable(MxBool p_enable) override
[AI] Enables or disables media stream playback and transitions state as needed.
MxU32 m_lockSize
[AI] Size in bytes for current buffer lock/write operation.
void ParseExtra() override
[AI] Parses additional data from the associated action for configuration or world interaction.
MxU8 m_writtenChunks
[AI] Number of chunks written into the DirectSound buffer.
MxS8 GetPlayedChunks()
[AI] Returns the index of the currently played chunk in the sound buffer.
void StartingTickle() override
[AI] Handles actions required when first starting presentation. Advances to streaming state.
void LoopChunk(MxStreamChunk *p_chunk) override
[AI] Adds a chunk to the looping chunk list, making it available for repeated playback.
void ReadyTickle() override
[AI] Handles the transition and setup for the Ready state. Parses extra action data and advances stat...
LPDIRECTSOUNDBUFFER m_dsBuffer
[AI] DirectSound buffer handling PCM sample playback.
void EndAction() override
[AI] Ends the media playback action, releasing all resources, notifying listeners if necessary.
void Destroy() override
[AI] Explicit resource release.
MxS8 m_silenceData
[AI] Value written as silence into buffer when needed (format-dependent, e.g., 0 or 0x7F).
void StreamingTickle() override
[AI] Per-frame update when streaming the media stream.
virtual void Resume()
[AI] Resumes audio playback after a pause, restarting sound from the current buffer position.
void SetVolume(MxS32 p_volume) override
[AI] Sets the presentation volume for playback (0-100).
void DoneTickle() override
[AI] Per-frame update for the "done" state; transitions this presenter to idle and ends the action.
void Init()
[AI] Initializes all member variables to safe/empty values.
MxBool FUN_100b1ba0()
[AI] Checks if more chunks can or should be streamed into buffer.
MxBool m_started
[AI] TRUE if audio playback has started on the buffer.
MxBool m_is3d
[AI] TRUE if buffer/audio is 3D spatialized.
MxResult PutData() override
[AI] Allows the presenter to submit pending results or output to the engine.
MxBool m_paused
[AI] TRUE if playback is currently paused.
MxU32 m_chunkLength
[AI] Size in bytes for one audio streaming chunk.
void WriteToSoundBuffer(void *p_audioPtr, MxU32 p_length)
[AI] Writes a block of audio data to the DirectSound buffer at the correct chunk offset.
WaveFormat * m_waveFormat
[AI] Pointer to the wave format struct for buffer description/allocation.
typedef DWORD(FAR PASCAL *LPCLIPPERCALLBACK)(LPDIRECTDRAWCLIPPER lpDDClipper
#define DECOMP_SIZE_ASSERT(T, S)
const char * g_strSOUND
[AI] Symbolic string used to reference sound effects or sound object properties in the scripting syst...
#define DSBCAPS_CTRLVOLUME
#define DSBSTATUS_BUFFERLOST
#define DSBCAPS_CTRLFREQUENCY
#define NULL
[AI] Null pointer value (C/C++ semantics).
#define SUCCESS
[AI] Used to indicate a successful operation in result codes.
#define AUTOLOCK(CS)
[AI] Macro for automatic locking using the MxAutoLock class. This macro instantiates an MxAutoLock ob...
#define DS_CHUNK_END_OF_STREAM
[AI] Flag bit indicating this chunk is the last in its stream.
#define DS_CHUNK_BIT1
[AI] Flag bit indicating that the data should be released (freed) when the chunk is destroyed.
#define DS_CHUNK_BIT16
[AI] Unspecified bit flag that may be used for platform- or feature- specific logic.
MxSoundManager * MSoundManager()
[AI] Returns the global sound manager responsible for sound FX/voice playback.
MxBool KeyValueStringParse(char *, const char *, const char *)
Searches p_string for a key command and copies its associated value to p_output.
LPWAVEFORMATEX lpwfxFormat