Tramway SDK
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
tram::AudioComponent Class Reference

Plays back Sounds. More...

#include <components/audio.h>

Inheritance diagram for tram::AudioComponent:
tram::EntityComponent

Public Member Functions

 AudioComponent ()
 
 ~AudioComponent ()
 
void Start ()
 
void SetLocation (vec3 location)
 Sets the location from which the sound will play. More...
 
void SetSound (name_t name)
 Sets the sound that the component will play. More...
 
void SetRepeating (bool is_repeating)
 Sets whether the component will repeat its sound. More...
 
bool IsPlaying ()
 Checks if component is playing a sound. More...
 
void Play ()
 Plays the sound. More...
 
void Pause ()
 Pauses the sound. More...
 
void Stop ()
 Stops the sound. More...
 
void EventHandler (Event &event)
 
- Public Member Functions inherited from tram::EntityComponent
 EntityComponent ()=default
 
virtual ~EntityComponent ()=default
 
virtual void Init ()
 Initializes an entity component. More...
 
bool IsReady ()
 Returns the component's readiness. More...
 
bool IsInit ()
 Returns the component's init status. More...
 
EntityGetParent ()
 
void SetParent (Entity *parent)
 

Static Public Member Functions

static bool IsSourceDraw ()
 Checks whether the audio source is drawn. More...
 
static bool IsDebugInfoDraw ()
 Checks whether the debug text is drawn. More...
 
static void SetSourceDraw (bool)
 Sets the drawing of audio sources. More...
 
static void SetDebugInfoDraw (bool)
 Sets the drawing of debug info. More...
 

Protected Member Functions

void SetupModel ()
 
- Protected Member Functions inherited from tram::EntityComponent
void ResourceReady ()
 Notifies the component of a streamed-in resource. More...
 

Protected Attributes

ResourceProxy< Audio::Soundsound
 
Audio::audiosource_t source = {}
 
vec3 location = {0.0f, 0.0f, 0.0f}
 
bool repeat = false
 
bool play_on_start = false
 
Component< RenderComponentmodel
 
- Protected Attributes inherited from tram::EntityComponent
size_t resources_waiting = 0
 
bool is_ready = false
 
bool is_init = false
 
Entityparent = nullptr
 

Detailed Description

Plays back Sounds.

See also
https://racenis.github.io/tram-sdk/documentation/components/audio.html

Constructor & Destructor Documentation

◆ AudioComponent()

tram::AudioComponent::AudioComponent ( )
inline

◆ ~AudioComponent()

tram::AudioComponent::~AudioComponent ( )

Member Function Documentation

◆ EventHandler()

void tram::AudioComponent::EventHandler ( Event event)
inlinevirtual

Implements tram::EntityComponent.

◆ IsDebugInfoDraw()

bool tram::AudioComponent::IsDebugInfoDraw ( )
static

Checks whether the debug text is drawn.

Check SetDebugInfoDraw() for more info.

◆ IsPlaying()

bool tram::AudioComponent::IsPlaying ( )

Checks if component is playing a sound.

Returns
True, if a sound is playing, false if it hasn't started or has stopped.

◆ IsSourceDraw()

bool tram::AudioComponent::IsSourceDraw ( )
static

Checks whether the audio source is drawn.

Check SetSourceDraw() for more info.

◆ Pause()

void tram::AudioComponent::Pause ( )

Pauses the sound.

Pauses the sound that the component is playing, or does nothing, if no sound is playing.

◆ Play()

void tram::AudioComponent::Play ( )

Plays the sound.

Plays the sound that the component has been set to play.

◆ SetDebugInfoDraw()

void tram::AudioComponent::SetDebugInfoDraw ( bool  draw)
static

Sets the drawing of debug info.

If set to true, each frame some debug text will be drawn for each audio source. This is useful for debugging.

◆ SetLocation()

void tram::AudioComponent::SetLocation ( vec3  location)

Sets the location from which the sound will play.

◆ SetRepeating()

void tram::AudioComponent::SetRepeating ( bool  is_repeating)

Sets whether the component will repeat its sound.

◆ SetSound()

void tram::AudioComponent::SetSound ( name_t  name)

Sets the sound that the component will play.

◆ SetSourceDraw()

void tram::AudioComponent::SetSourceDraw ( bool  draw)
static

Sets the drawing of audio sources.

If set to true, each audio component will initialize a 3D model, which will allow you to see the posiiton of the audio sources. Useful for debugging.

◆ SetupModel()

void tram::AudioComponent::SetupModel ( )
protected

◆ Start()

void tram::AudioComponent::Start ( )
virtual

Implements tram::EntityComponent.

◆ Stop()

void tram::AudioComponent::Stop ( )

Stops the sound.

Stops the sound that the component is playing, or does nothing, if no sound is playing.

Member Data Documentation

◆ location

vec3 tram::AudioComponent::location = {0.0f, 0.0f, 0.0f}
protected

◆ model

Component<RenderComponent> tram::AudioComponent::model
protected

◆ play_on_start

bool tram::AudioComponent::play_on_start = false
protected

◆ repeat

bool tram::AudioComponent::repeat = false
protected

◆ sound

ResourceProxy<Audio::Sound> tram::AudioComponent::sound
protected

◆ source

Audio::audiosource_t tram::AudioComponent::source = {}
protected

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