Gorgon Game Engine
BasicController Class Reference

Basic controller, allows non-positional playback of data buffer. More...

Inheritance diagram for BasicController:
[legend]

Public Member Functions

 BasicController ()=default
 Default constructor. More...
 
 BasicController (const Containers::Wave &wavedata)
 Filling constructor. More...
 
float GetCurrentFraction () const
 Returns the fraction of the audio that is played. More...
 
float GetCurrentTime () const
 Returns the current playback time in seconds. More...
 
float GetDuration () const
 Returns the duration of the audio buffer in seconds. This function will return 0 if data is not set. More...
 
float GetVolume () const
 Returns the current volume of the playback. More...
 
bool HasData () const
 Returns whether this controller has data. More...
 
bool IsFinished () const
 Whether the audio is finished playing. More...
 
bool IsLooping () const
 Whether the audio is being looped. More...
 
bool IsPlaying () const
 Whether the audio is being played right now. More...
 
BasicControllerLoop ()
 Plays this sound. More...
 
BasicControllerPause ()
 Pauses the playback. More...
 
BasicControllerPlay ()
 Plays this sound. More...
 
void ReleaseData ()
 Releases the data being played by this controller. More...
 
BasicControllerReset ()
 Resets the playback to the beginning of the buffer. This function will not stop the playback. More...
 
BasicControllerSeek (float target)
 Changes the point of playback to the given time in seconds. More...
 
BasicControllerSeekTo (float target)
 Changes the point of playback to the given time in fraction: 1 would be the end of buffer. More...
 
void SetData (const Containers::Wave &wavedata)
 Sets the data to be played by this controller. More...
 
BasicControllerSetVolume (float volume)
 Changes the volume of the playback. More...
 
virtual ControllerType Type () const override
 Returns the type of the controller. More...
 
- Public Member Functions inherited from Controller
 Controller ()
 Default constructor. More...
 
virtual ~Controller ()
 

Protected Member Functions

virtual void datachanged ()
 Override this function to detect changes in the wave data. More...
 

Protected Attributes

const Containers::Wavewavedata
 Contains the data for this controller. More...
 

Detailed Description

Basic controller, allows non-positional playback of data buffer.

Timing is stored in seconds.

Constructor & Destructor Documentation

◆ BasicController() [1/2]

BasicController ( )
default

Default constructor.

◆ BasicController() [2/2]

BasicController ( const Containers::Wave wavedata)

Filling constructor.

References BasicController::datachanged().

Member Function Documentation

◆ datachanged()

virtual void datachanged ( )
protectedvirtual

Override this function to detect changes in the wave data.

It will be called if the constructor sets wavedata

◆ GetCurrentFraction()

float GetCurrentFraction ( ) const

Returns the fraction of the audio that is played.

References Wave::GetLength(), and BasicController::wavedata.

◆ GetCurrentTime()

float GetCurrentTime ( ) const

Returns the current playback time in seconds.

◆ GetDuration()

float GetDuration ( ) const

Returns the duration of the audio buffer in seconds. This function will return 0 if data is not set.

References Wave::GetLength(), and BasicController::wavedata.

◆ GetVolume()

float GetVolume ( ) const

Returns the current volume of the playback.

◆ HasData()

bool HasData ( ) const

Returns whether this controller has data.

References BasicController::wavedata.

◆ IsFinished()

bool IsFinished ( ) const

Whether the audio is finished playing.

References Wave::GetLength(), and BasicController::wavedata.

◆ IsLooping()

bool IsLooping ( ) const

Whether the audio is being looped.

◆ IsPlaying()

bool IsPlaying ( ) const

Whether the audio is being played right now.

◆ Loop()

BasicController & Loop ( )

Plays this sound.

When called, this function will set looping flag. If there is no wavedata associated with this controller, nothing happens until the data is set, after data is set, it starts playing immediately.

◆ Pause()

BasicController & Pause ( )

Pauses the playback.

Next time when a play or loop is called, the playback will continue from where it left off. Use Reset to start over.

◆ Play()

BasicController & Play ( )

Plays this sound.

When called, this function will unset looping flag. If there is no wavedata associated with this controller, nothing happens until the data is set, after data is set, it starts playing immediately.

References Wave::GetLength(), and BasicController::wavedata.

◆ ReleaseData()

void ReleaseData ( )

Releases the data being played by this controller.

References Gorgon::Audio::internal::ControllerMtx, BasicController::datachanged(), and BasicController::wavedata.

◆ Reset()

BasicController & Reset ( )

Resets the playback to the beginning of the buffer. This function will not stop the playback.

◆ Seek()

BasicController & Seek ( float  target)

Changes the point of playback to the given time in seconds.

This function will not start or stop the playback

◆ SeekTo()

BasicController & SeekTo ( float  target)

Changes the point of playback to the given time in fraction: 1 would be the end of buffer.

This function will not start or stop the playback

References Wave::GetLength(), and BasicController::wavedata.

◆ SetData()

void SetData ( const Containers::Wave wavedata)

Sets the data to be played by this controller.

Timing might be percent based, thus, when an audio data is swapped with another, playback position can be moved. Additionally, if the timing is stored in seconds, swapping wavedata might cause playback to stop or loop to the start immediately.

References Gorgon::Audio::internal::ControllerMtx, BasicController::datachanged(), and BasicController::wavedata.

◆ SetVolume()

BasicController & SetVolume ( float  volume)

Changes the volume of the playback.

1 would mean the volume is not modified. While its possible to use higher values, it might cause distortion in the sound.

◆ Type()

virtual ControllerType Type ( ) const
overridevirtual

Returns the type of the controller.

Implements Controller.

Reimplemented in PositionalController.

Member Data Documentation

◆ wavedata

const Containers::Wave* wavedata
protected

Contains the data for this controller.


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