StevEngine
StevEngine is a customizable C++ game engine.
Loading...
Searching...
No Matches
StevEngine::Audio::Emitter Class Reference

Component for playing sound effects from game objects. More...

#include <audio/Emitter.hpp>

Inheritance diagram for StevEngine::Audio::Emitter:
StevEngine::Component

Public Member Functions

 Emitter (std::string audioPath, bool loop=false, double volume=1)
 Create a new audio emitter.
 
 Emitter (Utilities::Stream &stream)
 Create emitter from text serialized data.
 
std::string GetType () const
 Get component type.
 
Utilities::Stream Export (Utilities::StreamType type) const
 Serialize component to a stream.
 
void Play ()
 Play the sound.
 
void ChangeSource (std::string path)
 Change the audio source file.
 
Mix_Chunk * GetData () const
 Get the raw audio data.
 
bool isPlaying () const
 Check if sound is currently playing.
 
- Public Member Functions inherited from StevEngine::Component
 Component ()
 Create new component.
 
virtual ~Component ()
 Clean up component resources.
 
GameObjectGetParent () const
 Get parent GameObject.
 
SceneGetScene () const
 Get containing Scene.
 
virtual void Start ()
 Initialize component after creation.
 

Public Attributes

bool loop
 Whether the sound should loop when playing.
 
double volume
 Volume level from 0.0 to 1.0.
 
int channel
 Current audio channel ID, or -1 if not playing.
 

Friends

class StevEngine::GameObject
 

Additional Inherited Members

- Protected Attributes inherited from StevEngine::Component
std::vector< std::pair< Utilities::ID, std::string > > handlers
 Event handler registrations.
 

Detailed Description

Component for playing sound effects from game objects.

The Emitter component allows game objects to play audio files. It supports one-shot and looping sounds with configurable volume levels.

Constructor & Destructor Documentation

◆ Emitter() [1/2]

StevEngine::Audio::Emitter::Emitter ( std::string audioPath,
bool loop = false,
double volume = 1 )

Create a new audio emitter.

Parameters
audioPathPath to the audio file to play
loopWhether the sound should loop
volumeInitial volume level from 0.0 to 1.0

◆ Emitter() [2/2]

StevEngine::Audio::Emitter::Emitter ( Utilities::Stream & stream)

Create emitter from text serialized data.

Parameters
streamStream containing serialized component data

Member Function Documentation

◆ ChangeSource()

void StevEngine::Audio::Emitter::ChangeSource ( std::string path)

Change the audio source file.

Parameters
pathPath to new audio file

Loads a new audio file, freeing the previous one if loaded.

◆ Export()

Utilities::Stream StevEngine::Audio::Emitter::Export ( Utilities::StreamType type) const
virtual

Serialize component to a stream.

Parameters
typeType of stream to export to
Returns
Serialized stream

Implements StevEngine::Component.

◆ GetData()

Mix_Chunk * StevEngine::Audio::Emitter::GetData ( ) const
inline

Get the raw audio data.

Returns
Pointer to loaded audio chunk

◆ GetType()

std::string StevEngine::Audio::Emitter::GetType ( ) const
inlinevirtual

Get component type.

Returns
Type identifier string

Implements StevEngine::Component.

◆ isPlaying()

bool StevEngine::Audio::Emitter::isPlaying ( ) const
inline

Check if sound is currently playing.

Returns
true if sound is playing, false otherwise

◆ Play()

void StevEngine::Audio::Emitter::Play ( )

Play the sound.

Starts playing the loaded audio file. If the sound is already playing, it will be stopped and restarted.


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