Isle
Loading...
Searching...
No Matches
MxWavePresenter Class Reference

[AI] Presenter for streaming and managing PCM waveform audio via DirectSound buffer. More...

#include <mxwavepresenter.h>

Inheritance diagram for MxWavePresenter:
Collaboration diagram for MxWavePresenter:

Classes

struct  WaveFormat
 [AI] Holds WAVE PCM format info for DirectSound buffer creation and streaming. More...
 

Public Member Functions

 MxWavePresenter ()
 [AI] Constructs MxWavePresenter and initializes all members. More...
 
 ~MxWavePresenter () override
 [AI] Destroys the wave presenter and releases all associated resources, including sound buffers and memory. More...
 
void Destroy () override
 [AI] Explicit resource release. More...
 
virtual void Pause ()
 [AI] Pauses audio playback, halting sound buffer while keeping position for resume. More...
 
virtual void Resume ()
 [AI] Resumes audio playback after a pause, restarting sound from the current buffer position. More...
 
virtual MxBool IsPaused ()
 [AI] Returns pause state of the current audio playback. More...
 
const char * ClassName () const override
 [AI] Returns the class name string at runtime. More...
 
MxBool IsA (const char *p_name) const override
 [AI] Checks if this instance is of the given class or a parent class. More...
 
void ReadyTickle () override
 [AI] Handles the transition and setup for the Ready state. Parses extra action data and advances state. More...
 
void StartingTickle () override
 [AI] Handles actions required when first starting presentation. Advances to streaming state. More...
 
void StreamingTickle () override
 [AI] Per-frame update when streaming the media stream. More...
 
void DoneTickle () override
 [AI] Per-frame update for the "done" state; transitions this presenter to idle and ends the action. More...
 
void ParseExtra () override
 [AI] Parses additional data from the associated action for configuration or world interaction. More...
 
MxResult AddToManager () override
 [AI] Registers this presenter with the global MxSoundManager. More...
 
void EndAction () override
 [AI] Ends the media playback action, releasing all resources, notifying listeners if necessary. More...
 
MxResult PutData () override
 [AI] Allows the presenter to submit pending results or output to the engine. More...
 
void Enable (MxBool p_enable) override
 [AI] Enables or disables media stream playback and transitions state as needed. More...
 
void LoopChunk (MxStreamChunk *p_chunk) override
 [AI] Adds a chunk to the looping chunk list, making it available for repeated playback. More...
 
void SetVolume (MxS32 p_volume) override
 [AI] Sets the presentation volume for playback (0-100). More...
 
- Public Member Functions inherited from MxSoundPresenter
 ~MxSoundPresenter () override
 [AI] Destructor, ensures resource release and deregisters the presenter from MxSoundManager. More...
 
void Destroy () override
 [AI] Public destroy method called by the engine to clean up the presenter. More...
 
const char * ClassName () const override
 [AI] Returns the class name of this instance. More...
 
MxBool IsA (const char *p_name) const override
 [AI] Tests if this instance is a MxSoundPresenter or derived type. More...
 
MxResult AddToManager () override
 [AI] Registers this presenter with the global MxSoundManager. More...
 
- Public Member Functions inherited from MxAudioPresenter
 MxAudioPresenter ()
 [AI] Constructs an audio presenter with default volume at 100%. More...
 
virtual MxS32 GetVolume ()
 [AI] Returns the current runtime audio volume for this presenter (0-100). More...
 
virtual void SetVolume (MxS32 p_volume)
 [AI] Sets the presentation volume for playback (0-100). More...
 
const char * ClassName () const override
 [AI] Returns the run-time class name string. More...
 
MxBool IsA (const char *p_name) const override
 [AI] Checks if this object is or derives from the given class name. More...
 
- Public Member Functions inherited from MxMediaPresenter
 MxMediaPresenter ()
 [AI] Constructs the presenter, initializing all member variables. More...
 
 ~MxMediaPresenter () override
 [AI] Destructor; cleans up and optionally destroys all internal resources as well as the MxDSSubscriber and chunk list/cursor. More...
 
void Destroy () override
 [AI] Cleans up internal resources and resets the presenter to an uninitialized state. More...
 
MxResult Tickle () override
 [AI] Advances the presenter's state and media stream, if any, by tickling (i.e., updating) components. More...
 
const char * ClassName () const override
 [AI] Returns the class name for this presenter (see HandlerClassName()). More...
 
MxBool IsA (const char *p_name) const override
 [AI] Returns TRUE if the provided class name matches this class or any of its parents. More...
 
void StreamingTickle () override
 [AI] Per-frame update when streaming the media stream. More...
 
void RepeatingTickle () override
 [AI] Per-frame update while looping/repeating over known chunks. More...
 
void DoneTickle () override
 [AI] Per-frame update for the "done" state; transitions this presenter to idle and ends the action. More...
 
MxResult StartAction (MxStreamController *, MxDSAction *) override
 [AI] Begins a new media playback action, wiring up the stream and chunk lists as needed. More...
 
void EndAction () override
 [AI] Ends the media playback action, releasing all resources, notifying listeners if necessary. More...
 
void Enable (MxBool p_enable) override
 [AI] Enables or disables media stream playback and transitions state as needed. More...
 
virtual void LoopChunk (MxStreamChunk *p_chunk)
 [AI] Adds a chunk to the looping chunk list, making it available for repeated playback. More...
 
MxStreamChunkCurrentChunk ()
 [AI] Returns a pointer to the current data chunk at the head of the stream, without consuming it. More...
 
MxStreamChunkNextChunk ()
 [AI] Returns the next data chunk in the stream, removing it from the stream queue. More...
 
- Public Member Functions inherited from MxPresenter
 MxPresenter ()
 [AI] Constructor. Initializes internal tickle state and other members. More...
 
MxResult Tickle () override
 [AI] Main tickle handler, called periodically to progress presenter's internal state. More...
 
virtual void VTable0x14 ()
 [AI] Reserved for future or specialized use in derived classes. More...
 
virtual void ReadyTickle ()
 [AI] Handles the transition and setup for the Ready state. Parses extra action data and advances state. More...
 
virtual void StartingTickle ()
 [AI] Handles actions required when first starting presentation. Advances to streaming state. More...
 
virtual void StreamingTickle ()
 [AI] Handles periodic updates during the streaming/presentation stage. Advances to repeating state. More...
 
virtual void RepeatingTickle ()
 [AI] Handles updates when in a repeating (looping) stage. Advances to freezing state. More...
 
virtual void FreezingTickle ()
 [AI] Handles updates during the freezing/suspended state. Advances to done state. More...
 
 ~MxPresenter () override
 [AI] Destructor, cleans up resources (base class: does nothing beyond Init). More...
 
virtual MxResult AddToManager ()
 [AI] Optional registration with a manager (such as TickleManager); by default does nothing. More...
 
virtual void Destroy ()
 [AI] Resets presenter state or cleans up resources after completion/removal. More...
 
virtual MxResult StartAction (MxStreamController *, MxDSAction *)
 [AI] Initiates presenter for a new action, setting up context and state. More...
 
virtual void EndAction ()
 [AI] Terminates the current action, notifies listeners and resets state. More...
 
virtual void SetTickleState (TickleState p_tickleState)
 [AI] Forces the tickle state, advancing to the requested lifecycle stage. More...
 
virtual MxBool HasTickleStatePassed (TickleState p_tickleState)
 [AI] Checks if the specified tickle state has ever been passed since last reset. More...
 
virtual MxResult PutData ()
 [AI] Allows the presenter to submit pending results or output to the engine. More...
 
virtual MxBool IsHit (MxS32 p_x, MxS32 p_y)
 [AI] Returns TRUE if the given (x, y) falls within hit-test bounds for the presenter (e.g. More...
 
virtual void Enable (MxBool p_enable)
 [AI] Enables or disables this presenter (controls action flags accordingly). More...
 
const char * ClassName () const override
 [AI] Returns the run-time class name for this presenter. More...
 
MxBool IsA (const char *p_name) const override
 [AI] Determines if this object is of (or inherits) the specified named class. More...
 
MxEntityCreateEntity (const char *p_defaultName)
 [AI] Creates an entity based on action 'extra' data, or uses the provided default name. More...
 
void SendToCompositePresenter (MxOmni *p_omni)
 [AI] Notifies a composite presenter (if one exists) that this presenter wishes to join a group. More...
 
MxBool IsEnabled ()
 [AI] Returns whether this presenter is logically enabled (based on the associated action's flags). More...
 
MxS32 GetCurrentTickleState () const
 [AI] Returns the current tickle state. More...
 
MxPoint32 GetLocation () const
 [AI] Returns the presenter's screen location (in pixels). More...
 
MxS32 GetX () const
 [AI] Returns the X coordinate of screen location. More...
 
MxS32 GetY () const
 [AI] Returns the Y coordinate of screen location. More...
 
MxS32 GetDisplayZ () const
 [AI] Returns the display Z (depth) order. More...
 
MxDSActionGetAction () const
 [AI] Returns the current action being presented. More...
 
void SetAction (MxDSAction *p_action)
 [AI] Sets the action associated with this presenter. More...
 
void SetCompositePresenter (MxCompositePresenter *p_compositePresenter)
 [AI] Sets the composite presenter to notify/join on completion. More...
 
void SetDisplayZ (MxS32 p_displayZ)
 [AI] Sets the display Z (depth) order for the presenter. More...
 
- Public Member Functions inherited from MxCore
 MxCore ()
 [AI] Constructs a new MxCore object and assigns it a unique id. More...
 
virtual ~MxCore ()
 [AI] Virtual destructor. Required for correct polymorphic cleanup in derived classes. More...
 
virtual MxLong Notify (MxParam &p_param)
 [AI] Virtual callback notification mechanism. More...
 
virtual MxResult Tickle ()
 [AI] Called by tickle managers to allow the object to update itself. More...
 
virtual const char * ClassName () const
 [AI] Returns the runtime class name of this object. More...
 
virtual MxBool IsA (const char *p_name) const
 [AI] Checks whether this object's class type or parents match the given name. More...
 
MxU32 GetId ()
 [AI] Gets the unique (per-process) id assigned to this object instance. More...
 

Static Public Member Functions

static const char * HandlerClassName ()
 [AI] Returns the name identifying this presenter class. More...
 
- Static Public Member Functions inherited from MxSoundPresenter
static const char * HandlerClassName ()
 [AI] Returns the class name of the presenter as a static string. More...
 
- Static Public Member Functions inherited from MxAudioPresenter
static const char * HandlerClassName ()
 [AI] Returns the class handler name used for presenter type registration and lookup. More...
 
- Static Public Member Functions inherited from MxMediaPresenter
static const char * HandlerClassName ()
 [AI] Gets the class name string for handler dispatch and RTTI emulation. More...
 
- Static Public Member Functions inherited from MxPresenter
static const char * HandlerClassName ()
 [AI] Returns the handler class name for identification and reflection purposes. More...
 

Protected Member Functions

void Init ()
 [AI] Initializes all member variables to safe/empty values. More...
 
void Destroy (MxBool p_fromDestructor)
 [AI] Fully tears down/cleans up presenter state and releases resources. More...
 
MxS8 GetPlayedChunks ()
 [AI] Returns the index of the currently played chunk in the sound buffer. More...
 
MxBool FUN_100b1ba0 ()
 [AI] Checks if more chunks can or should be streamed into buffer. More...
 
void WriteToSoundBuffer (void *p_audioPtr, MxU32 p_length)
 [AI] Writes a block of audio data to the DirectSound buffer at the correct chunk offset. More...
 
- Protected Member Functions inherited from MxSoundPresenter
void Destroy (MxBool p_fromDestructor)
 [AI] Handles actual teardown logic for the presenter, including deregistration from manager. More...
 
- Protected Member Functions inherited from MxMediaPresenter
void Init ()
 [AI] Initializes all member variables to a known default state (NULL pointers, etc). More...
 
void Destroy (MxBool p_fromDestructor)
 [AI] Frees all managed resources, owned memory and pointers, optionally preventing destruction of the base class. More...
 
- Protected Member Functions inherited from MxPresenter
virtual void DoneTickle ()
 [AI] Handles any post-completion logic, resetting to idle state. More...
 
virtual void ParseExtra ()
 [AI] Parses additional data from the associated action for configuration or world interaction. More...
 
void ProgressTickleState (TickleState p_tickleState)
 [AI] Helper for advancing the presenter's tickle state and updating transition history. More...
 
void Init ()
 [AI] Initializes object state to post-construction defaults. More...
 

Protected Attributes

WaveFormatm_waveFormat
 [AI] Pointer to the wave format struct for buffer description/allocation. More...
 
LPDIRECTSOUNDBUFFER m_dsBuffer
 [AI] DirectSound buffer handling PCM sample playback. More...
 
MxU32 m_chunkLength
 [AI] Size in bytes for one audio streaming chunk. More...
 
MxU32 m_lockSize
 [AI] Size in bytes for current buffer lock/write operation. More...
 
MxU8 m_writtenChunks
 [AI] Number of chunks written into the DirectSound buffer. More...
 
MxBool m_started
 [AI] TRUE if audio playback has started on the buffer. More...
 
MxBool m_is3d
 [AI] TRUE if buffer/audio is 3D spatialized. More...
 
MxS8 m_silenceData
 [AI] Value written as silence into buffer when needed (format-dependent, e.g., 0 or 0x7F). More...
 
MxBool m_paused
 [AI] TRUE if playback is currently paused. More...
 
- Protected Attributes inherited from MxAudioPresenter
MxS32 m_volume
 [AI] Current playback volume, range 0-100 (percent). More...
 
- Protected Attributes inherited from MxMediaPresenter
MxDSSubscriberm_subscriber
 [AI] Subscriber that provides the stream data (e.g., audio/video chunks) for this presenter. More...
 
MxStreamChunkListm_loopingChunks
 [AI] Linked list of all chunks available for looping/repeating playback. More...
 
MxStreamChunkListCursorm_loopingChunkCursor
 [AI] Cursor used to iterate through the loopingChunk list during repeat mode. More...
 
MxStreamChunkm_currentChunk
 [AI] Currently active data chunk for playback or processing. More...
 
- Protected Attributes inherited from MxPresenter
TickleState m_currentTickleState
 [AI] Current state in the tickle lifecycle. More...
 
MxU32 m_previousTickleStates
 [AI] Bitfield representing all tickle states that have already occurred during this lifetime. More...
 
MxPoint32 m_location
 [AI] 2D display location for the presenter. More...
 
MxS32 m_displayZ
 [AI] Z-order value for display stacking. More...
 
MxDSActionm_action
 [AI] The associated action currently being presented by this presenter. More...
 
MxCriticalSection m_criticalSection
 [AI] Thread synchronization for presenter state and data. More...
 
MxCompositePresenterm_compositePresenter
 [AI] Owner composite presenter, if any. More...
 

Additional Inherited Members

- Public Types inherited from MxPresenter
enum  TickleState {
  e_idle = 0 , e_ready , e_starting , e_streaming ,
  e_repeating , e_freezing , e_done
}
 [AI] Represents the state of the presenter's tickle (update) lifecycle. More...
 

Detailed Description

[AI] Presenter for streaming and managing PCM waveform audio via DirectSound buffer.

[AI] This class handles reading, streaming, playing, and managing PCM audio data ("wave" format) using DirectSound buffers, facilitating sound playback features such as 3D sound, chunked streaming, pause/resume, volume management, and direct buffer operations. Used for WAV files in the LEGO Island engine.

Definition at line 17 of file mxwavepresenter.h.

Constructor & Destructor Documentation

◆ MxWavePresenter()

MxWavePresenter::MxWavePresenter ( )
inline

[AI] Constructs MxWavePresenter and initializes all members.

Definition at line 22 of file mxwavepresenter.h.

◆ ~MxWavePresenter()

MxWavePresenter::~MxWavePresenter ( )
inlineoverride

[AI] Destroys the wave presenter and releases all associated resources, including sound buffers and memory.

Definition at line 27 of file mxwavepresenter.h.

Member Function Documentation

◆ AddToManager()

MxResult MxWavePresenter::AddToManager ( )
overridevirtual

[AI] Registers this presenter with the global MxSoundManager.

[AI] Called when the object needs to participate in system sound management. Returns SUCCESS if registration was performed, FAILURE otherwise (e.g., no sound manager).

Returns
MxResult Operation result code (SUCCESS/FAILURE). [AI]

Reimplemented from MxSoundPresenter.

Definition at line 30 of file mxwavepresenter.cpp.

◆ ClassName()

const char * MxWavePresenter::ClassName ( ) const
inlineoverridevirtual

[AI] Returns the class name string at runtime.

[AI] Used for type identification and RTTI-like checks.

Reimplemented from MxSoundPresenter.

Definition at line 67 of file mxwavepresenter.h.

◆ Destroy() [1/2]

void MxWavePresenter::Destroy ( )
inlineoverridevirtual

[AI] Explicit resource release.

Optionally skips base class destruction depending on flag.

Parameters
p_fromDestructorIndicates if called from destructor or not. [AI]

Reimplemented from MxSoundPresenter.

Definition at line 33 of file mxwavepresenter.h.

◆ Destroy() [2/2]

void MxWavePresenter::Destroy ( MxBool  p_fromDestructor)
protected

[AI] Fully tears down/cleans up presenter state and releases resources.

Parameters
p_fromDestructorTRUE if called from destructor; used to decide whether to also destroy base class. [AI]

Definition at line 38 of file mxwavepresenter.cpp.

◆ DoneTickle()

void MxWavePresenter::DoneTickle ( )
overridevirtual

[AI] Per-frame update for the "done" state; transitions this presenter to idle and ends the action.

Reimplemented from MxMediaPresenter.

Definition at line 216 of file mxwavepresenter.cpp.

◆ Enable()

void MxWavePresenter::Enable ( MxBool  p_enable)
overridevirtual

[AI] Enables or disables media stream playback and transitions state as needed.

Parameters
p_enable[AI] TRUE to enable playback, FALSE to disable and reset.

Reimplemented from MxMediaPresenter.

Definition at line 310 of file mxwavepresenter.cpp.

◆ EndAction()

void MxWavePresenter::EndAction ( )
overridevirtual

[AI] Ends the media playback action, releasing all resources, notifying listeners if necessary.

Reimplemented from MxMediaPresenter.

Definition at line 282 of file mxwavepresenter.cpp.

◆ FUN_100b1ba0()

MxBool MxWavePresenter::FUN_100b1ba0 ( )
protected

[AI] Checks if more chunks can or should be streamed into buffer.

Returns
TRUE if buffer has room for or needs new chunk(s). [AI]

Definition at line 70 of file mxwavepresenter.cpp.

◆ GetPlayedChunks()

MxS8 MxWavePresenter::GetPlayedChunks ( )
protected

[AI] Returns the index of the currently played chunk in the sound buffer.

Returns
Index of current chunk, or -1 if unknown/error. [AI]

Definition at line 57 of file mxwavepresenter.cpp.

◆ HandlerClassName()

static const char * MxWavePresenter::HandlerClassName ( )
inlinestatic

[AI] Returns the name identifying this presenter class.

Returns
Static string representing handler class name. [AI]

Definition at line 57 of file mxwavepresenter.h.

◆ Init()

void MxWavePresenter::Init ( )
protected

[AI] Initializes all member variables to safe/empty values.

Definition at line 17 of file mxwavepresenter.cpp.

◆ IsA()

MxBool MxWavePresenter::IsA ( const char *  p_name) const
inlineoverridevirtual

[AI] Checks if this instance is of the given class or a parent class.

Parameters
p_nameClass name to check against. [AI]
Returns
TRUE if matches class or parent. [AI]

Reimplemented from MxSoundPresenter.

Definition at line 77 of file mxwavepresenter.h.

◆ IsPaused()

virtual MxBool MxWavePresenter::IsPaused ( )
inlinevirtual

[AI] Returns pause state of the current audio playback.

Returns
TRUE if audio is currently paused. [AI]

Definition at line 51 of file mxwavepresenter.h.

◆ LoopChunk()

void MxWavePresenter::LoopChunk ( MxStreamChunk p_chunk)
overridevirtual

[AI] Adds a chunk to the looping chunk list, making it available for repeated playback.

Parameters
p_chunk[AI] Chunk to duplicate and append to loopingChunk list.

Reimplemented from MxMediaPresenter.

Definition at line 235 of file mxwavepresenter.cpp.

◆ ParseExtra()

void MxWavePresenter::ParseExtra ( )
overridevirtual

[AI] Parses additional data from the associated action for configuration or world interaction.

Reimplemented from MxPresenter.

Definition at line 326 of file mxwavepresenter.cpp.

◆ Pause()

void MxWavePresenter::Pause ( )
virtual

[AI] Pauses audio playback, halting sound buffer while keeping position for resume.

[AI]

Definition at line 349 of file mxwavepresenter.cpp.

◆ PutData()

MxResult MxWavePresenter::PutData ( )
overridevirtual

[AI] Allows the presenter to submit pending results or output to the engine.

[AI] Placeholder implementation, always returns SUCCESS.

Reimplemented from MxPresenter.

Definition at line 244 of file mxwavepresenter.cpp.

◆ ReadyTickle()

void MxWavePresenter::ReadyTickle ( )
overridevirtual

[AI] Handles the transition and setup for the Ready state. Parses extra action data and advances state.

Reimplemented from MxPresenter.

Definition at line 117 of file mxwavepresenter.cpp.

◆ Resume()

void MxWavePresenter::Resume ( )
virtual

[AI] Resumes audio playback after a pause, restarting sound from the current buffer position.

[AI]

Definition at line 360 of file mxwavepresenter.cpp.

◆ SetVolume()

void MxWavePresenter::SetVolume ( MxS32  p_volume)
overridevirtual

[AI] Sets the presentation volume for playback (0-100).

Parameters
p_volumeThe desired audio volume (usually clamped between 0-100). [AI]

Reimplemented from MxAudioPresenter.

Definition at line 295 of file mxwavepresenter.cpp.

◆ StartingTickle()

void MxWavePresenter::StartingTickle ( )
overridevirtual

[AI] Handles actions required when first starting presentation. Advances to streaming state.

Reimplemented from MxPresenter.

Definition at line 131 of file mxwavepresenter.cpp.

◆ StreamingTickle()

void MxWavePresenter::StreamingTickle ( )
overridevirtual

[AI] Per-frame update when streaming the media stream.

[AI] Consumes and processes the next available chunk in the stream as data arrives.

Reimplemented from MxMediaPresenter.

Definition at line 189 of file mxwavepresenter.cpp.

◆ WriteToSoundBuffer()

void MxWavePresenter::WriteToSoundBuffer ( void *  p_audioPtr,
MxU32  p_length 
)
protected

[AI] Writes a block of audio data to the DirectSound buffer at the correct chunk offset.

Parameters
p_audioPtrPointer to audio data to write. [AI]
p_lengthNumber of bytes to write. [AI]

Definition at line 76 of file mxwavepresenter.cpp.

Member Data Documentation

◆ m_chunkLength

MxU32 MxWavePresenter::m_chunkLength
protected

[AI] Size in bytes for one audio streaming chunk.

Definition at line 141 of file mxwavepresenter.h.

◆ m_dsBuffer

LPDIRECTSOUNDBUFFER MxWavePresenter::m_dsBuffer
protected

[AI] DirectSound buffer handling PCM sample playback.

Definition at line 140 of file mxwavepresenter.h.

◆ m_is3d

MxBool MxWavePresenter::m_is3d
protected

[AI] TRUE if buffer/audio is 3D spatialized.

Definition at line 145 of file mxwavepresenter.h.

◆ m_lockSize

MxU32 MxWavePresenter::m_lockSize
protected

[AI] Size in bytes for current buffer lock/write operation.

Definition at line 142 of file mxwavepresenter.h.

◆ m_paused

MxBool MxWavePresenter::m_paused
protected

[AI] TRUE if playback is currently paused.

Definition at line 147 of file mxwavepresenter.h.

◆ m_silenceData

MxS8 MxWavePresenter::m_silenceData
protected

[AI] Value written as silence into buffer when needed (format-dependent, e.g., 0 or 0x7F).

Definition at line 146 of file mxwavepresenter.h.

◆ m_started

MxBool MxWavePresenter::m_started
protected

[AI] TRUE if audio playback has started on the buffer.

Definition at line 144 of file mxwavepresenter.h.

◆ m_waveFormat

WaveFormat* MxWavePresenter::m_waveFormat
protected

[AI] Pointer to the wave format struct for buffer description/allocation.

Definition at line 139 of file mxwavepresenter.h.

◆ m_writtenChunks

MxU8 MxWavePresenter::m_writtenChunks
protected

[AI] Number of chunks written into the DirectSound buffer.

Definition at line 143 of file mxwavepresenter.h.


The documentation for this class was generated from the following files: