Isle
Loading...
Searching...
No Matches
mxmidipresenter.cpp
Go to the documentation of this file.
1#include "mxmidipresenter.h"
2
3#include "decomp.h"
4#include "mxautolock.h"
5#include "mxdssound.h"
6#include "mxdssubscriber.h"
7#include "mxmisc.h"
8#include "mxmusicmanager.h"
9
11
12// FUNCTION: LEGO1 0x100c25e0
14{
15 Init();
16}
17
18// FUNCTION: LEGO1 0x100c27c0
20{
22}
23
24// FUNCTION: LEGO1 0x100c2820
25void MxMIDIPresenter::Init()
26{
27 m_chunk = NULL;
28}
29
30// FUNCTION: LEGO1 0x100c2830
31void MxMIDIPresenter::Destroy(MxBool p_fromDestructor)
32{
33 if (MusicManager()) {
35 }
36
38
39 if (m_subscriber && m_chunk) {
41 }
42 Init();
43
45
46 if (!p_fromDestructor) {
48 }
49}
50
51// FUNCTION: LEGO1 0x100c2890
53{
54 MxStreamChunk* chunk = NextChunk();
55
56 if (chunk) {
58 ParseExtra();
60 }
61}
62
63// FUNCTION: LEGO1 0x100c28d0
65{
66 MxStreamChunk* chunk = CurrentChunk();
67
68 if (chunk && m_action->GetElapsedTime() >= chunk->GetTime()) {
70 }
71}
72
73// FUNCTION: LEGO1 0x100c2910
75{
76 if (m_chunk) {
78 }
79 else {
81 }
82}
83
84// FUNCTION: LEGO1 0x100c2940
86{
87 if (!MusicManager()->GetMIDIInitialized()) {
88 EndAction();
89 }
90}
91
92// FUNCTION: LEGO1 0x100c2960
94{
96}
97
98// FUNCTION: LEGO1 0x100c2970
100{
102
103 if (m_currentTickleState == e_streaming && m_chunk && !MusicManager()->GetMIDIInitialized()) {
105
106 if (MusicManager()->InitializeMIDI(m_chunk->GetData(), 1) != SUCCESS) {
107 EndAction();
108 }
109 }
110
112 return SUCCESS;
113}
114
115// FUNCTION: LEGO1 0x100c29e0
117{
118 if (m_action) {
120
123 }
124}
125
126// FUNCTION: LEGO1 0x100c2a60
128{
129 m_volume = p_volume;
130 MusicManager()->SetMultiplier(p_volume);
131}
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.
virtual MxLong GetElapsedTime()
[AI] Gets elapsed time for this action since the last time field 0x90 was set.
Definition: mxdsaction.cpp:159
MxLong GetTime()
[AI] Returns the time (timestamp or tick) associated with this chunk. [AI]
Definition: mxdschunk.h:102
MxU8 * GetData()
[AI] Returns a pointer to the start of the data payload. [AI]
Definition: mxdschunk.h:108
[AI] Represents a sound action extracted from an SI script and used in the data-driven action system.
Definition: mxdssound.h:14
void FreeDataChunk(MxStreamChunk *p_chunk)
[AI] Frees (deletes) a data chunk if it's found in the consumed data list; also forcibly deletes sing...
MIDI presenter class responsible for handling playback of MIDI music streams.
void DoneTickle() override
Tickle state signaling that playback is done.
void ReadyTickle() override
Tickle state for preparing the presenter before playback starts.
MxMIDIPresenter()
Constructs an MxMIDIPresenter object and initializes its data.
~MxMIDIPresenter() override
Destructor, ensures proper resource cleanup for MIDI playback.
void EndAction() override
Called when playback/action is finished or needs to be ended.
void SetVolume(MxS32 p_volume) override
Sets the playback volume for MIDI music.
MxStreamChunk * m_chunk
Current MIDI data chunk being streamed/played.
void Destroy() override
Cleanup resources, free MIDI data, and deinitialize MIDI.
MxResult PutData() override
Actually provides MIDI stream data to the playback system.
void StartingTickle() override
Tickle state for initializing MIDI playback of the current chunk.
void StreamingTickle() override
Tickle state for streaming (playing) the MIDI chunk.
MxStreamChunk * CurrentChunk()
[AI] Returns a pointer to the current data chunk at the head of the stream, without consuming it.
MxStreamChunk * NextChunk()
[AI] Returns the next data chunk in the stream, removing it from the stream queue.
void EndAction() override
[AI] Ends the media playback action, releasing all resources, notifying listeners if necessary.
MxDSSubscriber * m_subscriber
[AI] Subscriber that provides the stream data (e.g., audio/video chunks) for this presenter.
void DeinitializeMIDI()
Stops playback and releases all MIDI streaming resources.
void SetMultiplier(MxS32 p_multiplier)
Sets the volume multiplier for scaling volume output.
void Destroy() override
[AI] Destroys this presenter, safely unregisters from music manager.
virtual void ParseExtra()
[AI] Parses additional data from the associated action for configuration or world interaction.
Definition: mxpresenter.cpp:80
void ProgressTickleState(TickleState p_tickleState)
[AI] Helper for advancing the presenter's tickle state and updating transition history.
Definition: mxpresenter.h:72
MxDSAction * m_action
[AI] The associated action currently being presented by this presenter.
Definition: mxpresenter.h:211
TickleState m_currentTickleState
[AI] Current state in the tickle lifecycle.
Definition: mxpresenter.h:199
@ e_done
[AI] Completed processing the current action.
Definition: mxpresenter.h:30
@ e_starting
[AI] In the process of starting playback/presentation.
Definition: mxpresenter.h:26
@ e_streaming
[AI] Streaming or rendering actively.
Definition: mxpresenter.h:27
MxCriticalSection m_criticalSection
[AI] Thread synchronization for presenter state and data.
Definition: mxpresenter.h:214
[AI] Represents a streamable chunk of data, typically sourced from a media buffer and designed for no...
Definition: mxstreamchunk.h:19
#define TRUE
Definition: d3drmdef.h:28
#define FALSE
Definition: d3drmdef.h:27
#define DECOMP_SIZE_ASSERT(T, S)
Definition: decomp.h:19
#define NULL
[AI] Null pointer value (C/C++ semantics).
Definition: legotypes.h:26
#define SUCCESS
[AI] Used to indicate a successful operation in result codes.
Definition: legotypes.h:30
#define AUTOLOCK(CS)
[AI] Macro for automatic locking using the MxAutoLock class. This macro instantiates an MxAutoLock ob...
Definition: mxautolock.h:5
MxMusicManager * MusicManager()
[AI] Returns the music manager, controlling playback of background music tracks.
Definition: mxmisc.cpp:81
MxU8 MxBool
[AI]
Definition: mxtypes.h:124
MxLong MxResult
[AI]
Definition: mxtypes.h:106
signed int MxS32
[AI]
Definition: mxtypes.h:38