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

Manages MIDI music playback with Win32 MIDI streaming for the LEGO Island engine. More...

#include <mxmusicmanager.h>

Inheritance diagram for MxMusicManager:
Collaboration diagram for MxMusicManager:

Public Member Functions

 MxMusicManager ()
 Constructs an instance and initializes member data. More...
 
 ~MxMusicManager () override
 Destructor, ensures proper cleanup of resources and MIDI deinitialization. More...
 
void Destroy () override
 Releases all resources and stops streaming. More...
 
void SetVolume (MxS32 p_volume) override
 Sets the music playback volume, taking into account multiplier for overall gain adjustment. More...
 
virtual MxResult Create (MxU32 p_frequencyMS, MxBool p_createThread)
 Initializes and starts MIDI playback. More...
 
MxBool GetMIDIInitialized ()
 Checks if the MIDI system is currently initialized and ready. More...
 
void GetMIDIVolume (DWORD &p_volume)
 Retrieves the current hardware MIDI out volume. More...
 
MxResult ResetStream ()
 Schedules and streams the next chunk of MIDI data; handles buffer looping and completion. More...
 
void ResetBuffer ()
 Resets the MIDI buffer to the starting offset and sets the buffer size to the full stream. More...
 
MxResult InitializeMIDI (MxU8 *p_data, MxS32 p_loopCount)
 Initializes streaming for a MIDI data buffer and begins playback. More...
 
void DeinitializeMIDI ()
 Stops playback and releases all MIDI streaming resources. More...
 
void SetMultiplier (MxS32 p_multiplier)
 Sets the volume multiplier for scaling volume output. More...
 
- Public Member Functions inherited from MxAudioManager
 MxAudioManager ()
 [AI] Constructs the audio manager and initializes default volume. More...
 
 ~MxAudioManager () override
 [AI] Destructs the audio manager and handles cleanup of resources. More...
 
MxResult Create () override
 [AI] Initializes audio subsystem resources and registers an instance for global audio management. More...
 
void Destroy () override
 [AI] Tears down the audio subsystem instance and unregisters it from global management. More...
 
virtual MxS32 GetVolume ()
 [AI] Gets the current global audio volume. More...
 
virtual void SetVolume (MxS32 p_volume)
 [AI] Sets the current global audio volume. More...
 
- Public Member Functions inherited from MxMediaManager
 MxMediaManager ()
 [AI] Constructor. More...
 
 ~MxMediaManager () override
 [AI] Destructor. More...
 
MxResult Tickle () override
 [AI] Called by the tickle manager to step through and update all presenters, and process their output data. More...
 
virtual MxResult Create ()
 [AI] Allocates and initializes the internal presenter list for this manager, ensuring thread safety. More...
 
virtual void Destroy ()
 [AI] Destroys all registered presenters and resets the internal state, ensuring safe resource disposal. More...
 
virtual void RegisterPresenter (MxPresenter &p_presenter)
 [AI] Register a new presenter for tickle management and playback coordination. More...
 
virtual void UnregisterPresenter (MxPresenter &p_presenter)
 [AI] Remove a presenter from tickle and managed output lists. More...
 
virtual void StopPresenters ()
 [AI] Stops/ends the action on all registered presenters, typically halting all playback and output. More...
 
MxResult Init ()
 [AI] Initializes all internal members to their default values. 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...
 

Protected Member Functions

void Init ()
 Initializes multipliers and buffer with default values; called from constructor/Destroy. More...
 
void InitData ()
 Initializes and zeros all associated MIDI-related member data. More...
 
- Protected Member Functions inherited from MxAudioManager
void Init ()
 [AI] Initializes audio manager state, setting default volume and other relevant fields. More...
 

Additional Inherited Members

- Protected Attributes inherited from MxAudioManager
MxS32 m_volume
 [AI] Holds the current global audio volume for the game. More...
 
- Protected Attributes inherited from MxMediaManager
MxPresenterListm_presenters
 [AI] Pointer to list of currently registered (active) presenters. More...
 
MxThreadm_thread
 [AI] Optional pointer to a worker thread used for media dispatch/IO (if multi-threaded operation is used, otherwise NULL). More...
 
MxCriticalSection m_criticalSection
 [AI] Critical section object used for guarding access to the presenter list and internal members for thread safety. More...
 

Detailed Description

Manages MIDI music playback with Win32 MIDI streaming for the LEGO Island engine.

[AI] Forward declaration for the music manager controlling soundtrack playback and music resources.

[AI]

MxMusicManager inherits from MxAudioManager and extends it with MIDI handling, including streaming, looping, MIDI hardware initialization, and volume/multiplier mixing controls. Designed for music playback, including looping, dynamic volume control, and integration with audio tickling threads for timing. [AI]

Definition at line 16 of file mxmusicmanager.h.

Constructor & Destructor Documentation

◆ MxMusicManager()

MxMusicManager::MxMusicManager ( )

Constructs an instance and initializes member data.

[AI]

Definition at line 12 of file mxmusicmanager.cpp.

◆ ~MxMusicManager()

MxMusicManager::~MxMusicManager ( )
override

Destructor, ensures proper cleanup of resources and MIDI deinitialization.

[AI]

Definition at line 18 of file mxmusicmanager.cpp.

Member Function Documentation

◆ Create()

MxResult MxMusicManager::Create ( MxU32  p_frequencyMS,
MxBool  p_createThread 
)
virtual

Initializes and starts MIDI playback.

[AI]

Optionally creates a tickle thread for timing, or registers this as a tickle client with the given tick interval (in ms). [AI]

Parameters
p_frequencyMSInterval in ms between tickle updates. [AI]
p_createThreadIf TRUE, creates a separate MxTickleThread for streaming. If FALSE, uses global TickleManager. [AI]
Returns
SUCCESS on initialization, FAILURE otherwise. [AI]

Definition at line 142 of file mxmusicmanager.cpp.

◆ DeinitializeMIDI()

void MxMusicManager::DeinitializeMIDI ( )

Stops playback and releases all MIDI streaming resources.

[AI]

Restores hardware volume to original, stops stream, unprepares header, and deletes buffer data. [AI]

Definition at line 279 of file mxmusicmanager.cpp.

◆ Destroy()

void MxMusicManager::Destroy ( )
overridevirtual

Releases all resources and stops streaming.

[AI]

Disables music playback and unregisters the tickle client. Called automatically from the destructor with p_fromDestructor=TRUE, or manually with p_fromDestructor=FALSE. [AI]

Parameters
p_fromDestructorTRUE if called from destructor (does not call base class Destroy if true). [AI]

Reimplemented from MxAudioManager.

Definition at line 177 of file mxmusicmanager.cpp.

◆ GetMIDIInitialized()

MxBool MxMusicManager::GetMIDIInitialized ( )
inline

Checks if the MIDI system is currently initialized and ready.

[AI]

Returns
TRUE if initialized, FALSE otherwise. [AI]

Definition at line 54 of file mxmusicmanager.h.

◆ GetMIDIVolume()

void MxMusicManager::GetMIDIVolume ( DWORD p_volume)
inline

Retrieves the current hardware MIDI out volume.

[AI]

If unable to get volume, sets to calculated value corresponding to 100%. [AI]

Parameters
p_volumeVariable to receive current MIDI volume (hardware format, two-channel 0x0000HHHH | 0x0000LLLL). [AI]

Definition at line 61 of file mxmusicmanager.h.

◆ Init()

void MxMusicManager::Init ( )
protected

Initializes multipliers and buffer with default values; called from constructor/Destroy.

[AI]

Definition at line 24 of file mxmusicmanager.cpp.

◆ InitData()

void MxMusicManager::InitData ( )
protected

Initializes and zeros all associated MIDI-related member data.

[AI]

Used to reinitialize this object after deallocation or streaming end. [AI]

Definition at line 31 of file mxmusicmanager.cpp.

◆ InitializeMIDI()

MxResult MxMusicManager::InitializeMIDI ( MxU8 p_data,
MxS32  p_loopCount 
)

Initializes streaming for a MIDI data buffer and begins playback.

[AI]

Parameters
p_dataPointer to MIDI data buffer, expected to be prepared for streaming. [AI]
p_loopCountNumber of times to loop playback, or -1 for infinite. [AI]
Returns
SUCCESS if initialization succeeds and playback starts, FAILURE otherwise. [AI]

Definition at line 208 of file mxmusicmanager.cpp.

◆ ResetBuffer()

void MxMusicManager::ResetBuffer ( )

Resets the MIDI buffer to the starting offset and sets the buffer size to the full stream.

[AI]

Definition at line 115 of file mxmusicmanager.cpp.

◆ ResetStream()

MxResult MxMusicManager::ResetStream ( )

Schedules and streams the next chunk of MIDI data; handles buffer looping and completion.

[AI]

Returns FAILURE on buffer underrun/error, or if looping/completion disables playback. [AI]

Definition at line 67 of file mxmusicmanager.cpp.

◆ SetMultiplier()

void MxMusicManager::SetMultiplier ( MxS32  p_multiplier)

Sets the volume multiplier for scaling volume output.

[AI]

Used for fade in/out or global gain controls on top of per-track volume. [AI]

Parameters
p_multiplierMultiplier value (percentage, where 100 = normal, 0 = muted). [AI]

Definition at line 192 of file mxmusicmanager.cpp.

◆ SetVolume()

void MxMusicManager::SetVolume ( MxS32  p_volume)
overridevirtual

Sets the music playback volume, taking into account multiplier for overall gain adjustment.

[AI]

Parameters
p_volumePercentage of the total volume (0-100). [AI]

Reimplemented from MxAudioManager.

Definition at line 183 of file mxmusicmanager.cpp.


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