Capycore Engine  0.1.0
A simple and lightweight game engine written in C++ based on the Unity API architecture.
Loading...
Searching...
No Matches
SoundInstance Class Reference

Represents an instance of a generic sound within the audio system. The reason for separating SoundInstance from SoundResource is to allow multiple instances of the same sound resource to be played simultaneously with different settings (e.g., volume, loop). More...

#include <sound_instance.h>

Inheritance diagram for SoundInstance:
[legend]

Public Member Functions

 SoundInstance (std::shared_ptr< SoundResource > resource, float volume=1.0f)
 
virtual ~SoundInstance ()=default
 
virtual void play ()
 
virtual void pause ()
 
virtual void resume ()
 
virtual void stop ()
 
virtual bool is_playing () const noexcept
 
virtual bool is_paused () const noexcept
 
virtual bool is_finished ()
 
const std::shared_ptr< SoundResource > & resource () const noexcept
 
float volume () const noexcept
 
void volume (float volume) noexcept
 
bool finished () const noexcept
 
void finished (bool finished) noexcept
 
bool loop () const noexcept
 
void loop (bool loop) noexcept
 

Protected Attributes

std::shared_ptr< SoundResourceresource_
 
bool loop_ {false}
 
bool playing_ {false}
 
bool paused_ {false}
 
bool finished_ {false}
 
float volume_ {1.0f}
 

Detailed Description

Represents an instance of a generic sound within the audio system. The reason for separating SoundInstance from SoundResource is to allow multiple instances of the same sound resource to be played simultaneously with different settings (e.g., volume, loop).

Constructor & Destructor Documentation

◆ SoundInstance()

SoundInstance::SoundInstance ( std::shared_ptr< SoundResource resource,
float  volume = 1.0f 
)
explicit

◆ ~SoundInstance()

virtual SoundInstance::~SoundInstance ( )
virtualdefault

Member Function Documentation

◆ finished() [1/2]

bool SoundInstance::finished ( ) const
noexcept

◆ finished() [2/2]

void SoundInstance::finished ( bool  finished)
noexcept

◆ is_finished()

virtual bool SoundInstance::is_finished ( )
virtual

Reimplemented in GenericSoundInstance, and SDLSoundInstance.

◆ is_paused()

virtual bool SoundInstance::is_paused ( ) const
virtualnoexcept

Reimplemented in GenericSoundInstance, and SDLSoundInstance.

◆ is_playing()

virtual bool SoundInstance::is_playing ( ) const
virtualnoexcept

Reimplemented in GenericSoundInstance, and SDLSoundInstance.

◆ loop() [1/2]

bool SoundInstance::loop ( ) const
noexcept

◆ loop() [2/2]

void SoundInstance::loop ( bool  loop)
noexcept

◆ pause()

virtual void SoundInstance::pause ( )
inlinevirtual

Reimplemented in GenericSoundInstance, and SDLSoundInstance.

◆ play()

virtual void SoundInstance::play ( )
inlinevirtual

Reimplemented in GenericSoundInstance, and SDLSoundInstance.

◆ resource()

const std::shared_ptr< SoundResource > & SoundInstance::resource ( ) const
noexcept

◆ resume()

virtual void SoundInstance::resume ( )
inlinevirtual

Reimplemented in GenericSoundInstance, and SDLSoundInstance.

◆ stop()

virtual void SoundInstance::stop ( )
inlinevirtual

Reimplemented in GenericSoundInstance, and SDLSoundInstance.

◆ volume() [1/2]

float SoundInstance::volume ( ) const
noexcept

◆ volume() [2/2]

void SoundInstance::volume ( float  volume)
noexcept

Member Data Documentation

◆ finished_

bool SoundInstance::finished_ {false}
protected

◆ loop_

bool SoundInstance::loop_ {false}
protected

◆ paused_

bool SoundInstance::paused_ {false}
protected

◆ playing_

bool SoundInstance::playing_ {false}
protected

◆ resource_

std::shared_ptr<SoundResource> SoundInstance::resource_
protected

◆ volume_

float SoundInstance::volume_ {1.0f}
protected

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