stmm-games-doc  0.32.0
Classes | Public Types | Public Member Functions | Protected Member Functions | List of all members
stmg::SoundEvent Class Reference

Sound event. More...

Inheritance diagram for stmg::SoundEvent:
Inheritance graph
[legend]

Classes

struct  Init
 
struct  LocalInit
 

Public Types

enum  MESSAGE_OP_TYPE_ENUM {
  MESSAGE_SET_SOUND_IDX = 100, MESSAGE_PRELOAD = 101, MESSAGE_PLAY = 102, MESSAGE_PLAY_FREE = 103,
  MESSAGE_PLAY_FREE_ONCE = 104, MESSAGE_PLAY_FREE_IDX = 105, MESSAGE_PLAY_FREE_IDX_ONCE = 106, MESSAGE_PAUSE = 110,
  MESSAGE_RESUME = 111, MESSAGE_STOP = 112, MESSAGE_SET_VOL = 120, MESSAGE_SET_POS_X = 150,
  MESSAGE_SET_POS_Y = 151, MESSAGE_SET_POS_Z = 152, MESSAGE_SET_POS_XY = 153, MESSAGE_ADD_TO_POS_X = 160,
  MESSAGE_ADD_TO_POS_Y = 161, MESSAGE_ADD_TO_POS_Z = 162, MESSAGE_ADD_PERC_TO_POS_X = 170, MESSAGE_ADD_PERC_TO_POS_Y = 171,
  MESSAGE_ADD_PERC_TO_POS_Z = 172, MESSAGE_RESTART = 200, MESSAGE_RESTART_RESET = 201
}
 
enum  { LISTENER_GROUP_SOUND_FINISHED = 20 }
 
- Public Types inherited from stmg::Event
enum  MSG_FILTER_VALUE_OP {
  MSG_FILTER_VALUE_OP_FIRST = 0, MSG_FILTER_VALUE_OP_UNCHANGED = 0, MSG_FILTER_VALUE_OP_SET = 1, MSG_FILTER_VALUE_OP_MULT_ADD = 2,
  MSG_FILTER_VALUE_OP_DIV_ADD = 3, MSG_FILTER_VALUE_OP_PERCENT_ADD = 4, MSG_FILTER_VALUE_OP_PERMILL_ADD = 5, MSG_FILTER_VALUE_OP_MOD_ADD = 6,
  MSG_FILTER_VALUE_OP_MIN_ADD = 7, MSG_FILTER_VALUE_OP_MAX_ADD = 8, MSG_FILTER_VALUE_OP_LAST = 8
}
 Value filter. More...
 
enum  { LISTENER_GROUP_FINISHED = 0 }
 

Public Member Functions

 SoundEvent (Init &&oInit) noexcept
 Constructor. More...
 
void trigger (int32_t nMsg, int32_t nValue, Event *p0TriggeringEvent) noexcept override
 The triggered function. More...
 
- Public Member Functions inherited from stmg::Event
virtual ~Event () noexcept=default
 
virtual void addMsgFilter (int32_t nInFromMsg, int32_t nInToMsg, int32_t nInFromValue, int32_t nInToValue, bool bOutMsgDefined, int32_t nOutMsg, MSG_FILTER_VALUE_OP eOutValueOperator, int32_t nOutValueOperand, int32_t nOutValueAdd) noexcept
 Add a message filter. More...
 
virtual void addListener (int32_t nGroupId, Event *p0ListenerEvent, int32_t nMsg) noexcept
 Adds a listener to the event. More...
 
bool isActive () const noexcept
 Tells whether the event is active. More...
 
int32_t getTriggerTime () const noexcept
 The triggering time. More...
 
int32_t getPriority () const noexcept
 The priority. More...
 
int32_t getDebugTag () const noexcept
 The debug tag. More...
 

Protected Member Functions

void reInit (Init &&oInit) noexcept
 Reinitialization. More...
 
- Protected Member Functions inherited from stmg::Event
 Event (Init &&oInit) noexcept
 Constructor. More...
 
void reInit (Init &&oInit) noexcept
 Reinitialization. More...
 
virtual void informListeners (int32_t nGroupId, int32_t nValue) noexcept
 Calls the trigger function of a group of listeners. More...
 
const Levellevel () const noexcept
 The level this event belongs to. More...
 
Levellevel () noexcept
 The level this event belongs to. More...
 

Detailed Description

Sound event.

Instances of this class create a sound and optionally pause, resume, stop, change the position and change the volume of it.

The sound listener is the center of the show area or, in subshow mode, the center of the subshow area.

This class can also play a sound passed as nValue to the trigger function. The value is the index into Named::sounds(). Free sounds can also ignore the LocalInit::m_bLooping value and be played once.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
LISTENER_GROUP_SOUND_FINISHED 

Listener group triggered when the played sound is finished playing.

◆ MESSAGE_OP_TYPE_ENUM

Enumerator
MESSAGE_SET_SOUND_IDX 

Sets the sound to play.

nValue is the index into Named::sounds().

MESSAGE_PRELOAD 

Preloads the sound so that when MESSAGE_PLAY or MESSAGE_PLAY_FREE are triggered it's faster.

MESSAGE_PLAY 

Plays the sound if not already playing.

MESSAGE_PLAY_FREE 

Plays the sound without keeping a reference to it (cannot pause, set position, etc.).

MESSAGE_PLAY_FREE_ONCE 

Plays the sound without keeping a reference to it (cannot pause, set position, etc.) without (potential) looping.

MESSAGE_PLAY_FREE_IDX 

Plays the sound identified by nValue without keeping a reference to it (cannot pause, set position, etc.).

MESSAGE_PLAY_FREE_IDX_ONCE 

Plays the sound identified by nValue without keeping a reference to it (cannot pause, set position, etc.) without (potential) looping.

MESSAGE_PAUSE 

Pauses the sound if not already paused.

MESSAGE_RESUME 

Resumes the sound if it was paused.

MESSAGE_STOP 

Stops the sound.

MESSAGE_SET_VOL 

Sets the volume of the sound the sound.

The nValue 0 is inaudible, 1000 max volume.

MESSAGE_SET_POS_X 

The sound x position is set to nValue.

MESSAGE_SET_POS_Y 

The sound y position is set to nValue.

MESSAGE_SET_POS_Z 

The sound z position is set to nValue.

MESSAGE_SET_POS_XY 

The sound xy position is set to Util::unpackPointFromInt32(nValue).

MESSAGE_ADD_TO_POS_X 

Add nValue to the current x position.

MESSAGE_ADD_TO_POS_Y 

Add nValue to the current y position.

MESSAGE_ADD_TO_POS_Z 

Add nValue to the current y position.

MESSAGE_ADD_PERC_TO_POS_X 

Add nValue divided by 100 to the current x position.

MESSAGE_ADD_PERC_TO_POS_Y 

Add nValue divided by 100 to the current y position.

MESSAGE_ADD_PERC_TO_POS_Z 

Add nValue divided by 100 to the current y position.

MESSAGE_RESTART 

Restarts the sound.

MESSAGE_RESTART_RESET 

Restarts the sound by resetting the initial values for position and volume.

Constructor & Destructor Documentation

◆ SoundEvent()

stmg::SoundEvent::SoundEvent ( Init &&  oInit)
explicitnoexcept

Constructor.

Parameters
oInitThe initialization data.

Member Function Documentation

◆ reInit()

void stmg::SoundEvent::reInit ( Init &&  oInit)
protectednoexcept

Reinitialization.

Parameters
oInitThe initialization data.

◆ trigger()

void stmg::SoundEvent::trigger ( int32_t  nMsg,
int32_t  nValue,
Event p0TriggeringEvent 
)
overridevirtualnoexcept

The triggered function.

Parameters
nMsgIf one MESSAGE_OP_TYPE_ENUM then operation is performed otherwise nDefaultIncBy (see constructor).
nValueThe triggered add value. Is only used if nMsg is MESSAGE_OP_TYPE_ENUM.
p0TriggeringEventThe triggering event or null if event activated itself.

Implements stmg::Event.