3DRadSpace 0.1.0Alpha
3DRadSpace is a free, simple to use, rapid application development game engine.
Loading...
Searching...
No Matches
Engine3DRadSpace.Objects.SoundEffect Class Reference

Represents an 2D sound effect that can be played in the scene. More...

#include <SoundEffect.hpp>

Inheritance diagram for Engine3DRadSpace.Objects.SoundEffect:
Collaboration diagram for Engine3DRadSpace.Objects.SoundEffect:

Public Member Functions

 SoundEffect ()
Sound GetSound ()
SoundInstance GetSoundInstance ()
 SoundEffect ()
 Default constructor.
 SoundEffect (const std::string &name, bool enabled, RefSound sound)
 Constructs a sound effect from an numerical asset identifier.
 SoundEffect (const std::string &name, bool enabled, const std::filesystem::path &path)
 Constructs an sound effect from an file path.
 SoundEffect (SoundEffect &&) noexcept=default
SoundEffect & operator= (SoundEffect &&) noexcept=default
Audio::Sound * GetSound () const noexcept
 Gets the underlying sound asset used by this object.
Audio::SoundInstance * GetInstance () const noexcept
 Gets the underlying sound instance used by this object.
void Initialize () override
 Does nothing.
void Load () override
 Loads the sound asset.
void Load (const std::filesystem::path &path) override
 Loads a sound from an specified path.
void Update () override
 Does nothing.
void Enable () override
 Plays the sound.
void Disable () override
 Pauses the sound.
bool Switch () override
 Plays the sound if stopped, and vice-versa.
Reflection::UUID GetUUID () const noexcept override
 Gets the UUID of the SoundEffect type.
Gizmos::IGizmo * GetGizmo () const noexcept
 Returns the gizmo object of this object, used for editor/debug rendering.
float GetVolume () const noexcept
 Gets the gain of the sound effect.
void SetVolume (float f) noexcept
 Sets the gain of the sound effect. Range is [0.0, 1.0]. Default is 1.0.
float GetPitch () const noexcept
 Gets the pitch of the sound effect.
void SetPitch (float p) noexcept
 Sets the pitch of the sound effect. Default is 1.0. Range is [0.5, 2.0]. Values outside this range may cause audio distortion.
bool IsLooping () const noexcept
 Gets whether the sound effect is looping.
void SetLooping (bool looping) noexcept
 Sets whether the sound effect is looping.
 ~SoundEffect ()=default
Public Member Functions inherited from Engine3DRadSpace.Objects.InstIObject
 InstIObject (IntPtr handle)
IObject GetChild (int idx)
int GetChildrenCount ()
void Show ()
 Shows this object.
void Hide ()
 Hides this object.
bool SwitchVisibility ()
 Switches the visibility state of this object.
void Load (string path)
override void Dispose ()
Public Member Functions inherited from Engine3DRadSpace.IUpdateable
void Update ()
virtual ~IUpdateable ()=default
Public Member Functions inherited from Engine3DRadSpace.Objects.IObject
void Enable ()
void Disable ()
bool Switch ()
void Show ()
void Hide ()
bool SwitchVisibility ()
IObject GetChild (int idx)
int GetChildrenCount ()
void InternalInitialize (IGame *game)
 Called by ObjectsList to set the _game Game instance. If there are objects manually managed, this MUST be called before Initialize or EditorInitialize.
Graphics::IGraphicsDevice * GetGraphicsDeviceHandle () const noexcept
 Returns the graphics device handle associated with this object.
IGame * GetGame () const noexcept
 Gets the game that this object belongs to.
IObject * operator[] (size_t idxChild) const
 Returns the idx-th child of this object.
IObject * GetParent () const noexcept
 Returns the parent of this object.
void SetParent (IObject *newParent) noexcept
 Sets the parent of this object.
bool HasParent () const noexcept
 Checks if this object has a parent.
size_t GetChildrenCount () const noexcept
 Returns the number of children of this object.
void Uninitialize () override
 Called before the object has the destructor called.
virtual ~IObject ()
Public Member Functions inherited from Engine3DRadSpace.IInitializable
void Initialize ()
virtual ~IInitializable ()=default
Public Member Functions inherited from Engine3DRadSpace.ILoadable
void Load ()
void Load (string path)
virtual ~ILoadable ()=default

Public Attributes

RefSound Sound
 Numerical reference to the sound asset used by this object.
Public Attributes inherited from Engine3DRadSpace.Objects.IObject
std::string Name
 Name of the object.
ChildObjectCollection Children
 Children of this object.

Properties

uint SoundID [get, set]
float Volume [get, set]
float Pitch [get, set]
bool Looping [get, set]
Properties inherited from Engine3DRadSpace.Objects.InstIObject
IObject? Parent [get, set]
string Name [get, set]
bool Enabled [get, set]
bool Visible [get, set]
Reflection.UUID UUID [get]
IGame Game [get]
IGraphicsDevice GraphicsDevice [get]
IGizmo Gizmo [get]
ObjectCollection Children [get]
Properties inherited from Engine3DRadSpace.NatPtrWrapper
IntPtr Handle [get]
Properties inherited from Engine3DRadSpace.Objects.IObject
string Name [get, set]
bool Enabled [get, set]
 Is this object enabled?
bool Visible [get, set]
 Is this object visible?
Reflection.UUID UUID [get]
IGame Game [get]
IGraphicsDevice GraphicsDevice [get]
IGizmo Gizmo [get]
ObjectCollection Children [get]
IObject Parent [get, set]

Additional Inherited Members

Protected Member Functions inherited from Engine3DRadSpace.InstIUpdateable
 InstIUpdateable (IntPtr handle, bool ownsHandle)
Protected Member Functions inherited from Engine3DRadSpace.NatPtrWrapper
 NatPtrWrapper (IntPtr handle, Action< IntPtr > fnDestroy)
 NatPtrWrapper (Action< IntPtr > fnDestroy)
void Reset (IntPtr newObj)
void Dispose (bool disposing)
Protected Member Functions inherited from Engine3DRadSpace.IUpdateable
 IUpdateable ()=default
 IUpdateable (const IUpdateable &) noexcept=default
IUpdateable & operator= (const IUpdateable &) noexcept=default
 IUpdateable (IUpdateable &&) noexcept=default
IUpdateable & operator= (IUpdateable &&) noexcept=default
Protected Member Functions inherited from Engine3DRadSpace.Objects.IObject
 IObject (const std::string &name="Empty", bool enabled=false, bool visible=false)
 Default constructor used for reflection. Objects created with this constructor are initially invalid, until internalInitialize() is called.
 IObject (const IObject &) noexcept=delete
IObject & operator= (const IObject &) noexcept=delete
 IObject (IObject &&) noexcept=default
IObject & operator= (IObject &&) noexcept=default
Protected Member Functions inherited from Engine3DRadSpace.IInitializable
 IInitializable ()=default
 IInitializable (const IInitializable &) noexcept=default
IInitializable & operator= (const IInitializable &) noexcept=default
 IInitializable (IInitializable &&) noexcept=default
IInitializable & operator= (IInitializable &&) noexcept=default
Protected Member Functions inherited from Engine3DRadSpace.ILoadable
 ILoadable ()=default
 ILoadable (const ILoadable &) noexcept=default
ILoadable & operator= (const ILoadable &) noexcept=default
 ILoadable (ILoadable &&) noexcept=default
ILoadable & operator= (ILoadable &&) noexcept=default
Protected Attributes inherited from Engine3DRadSpace.NatPtrWrapper
IntPtr _handle
bool _disposed
Protected Attributes inherited from Engine3DRadSpace.Objects.IObject
IGame * _game = nullptr
Graphics::IGraphicsDevice * _device = nullptr
IObject * _parent = nullptr

Detailed Description

Represents an 2D sound effect that can be played in the scene.

Constructor & Destructor Documentation

◆ SoundEffect() [1/5]

SoundEffect.SoundEffect ( )
inline

◆ SoundEffect() [2/5]

◆ SoundEffect() [3/5]

Engine3DRadSpace.Objects.SoundEffect.SoundEffect ( const std::string & name,
bool enabled,
RefSound sound )

Constructs a sound effect from an numerical asset identifier.

Parameters
nameName of the object
enabledIs this object enabled?
soundNumerical asset identifier for the sound

◆ SoundEffect() [4/5]

Engine3DRadSpace.Objects.SoundEffect.SoundEffect ( const std::string & name,
bool enabled,
const std::filesystem::path & path )

Constructs an sound effect from an file path.

Parameters
nameName of the object
enabledIs this object enabled?
pathFile path to the sound(OGG or WAV)

◆ SoundEffect() [5/5]

◆ ~SoundEffect()

Engine3DRadSpace.Objects.SoundEffect.~SoundEffect ( )
default

Member Function Documentation

◆ Disable()

void SoundEffect::Disable ( )
overridevirtual

Pauses the sound.

Reimplemented from Engine3DRadSpace.Objects.InstIObject.

◆ Enable()

void SoundEffect::Enable ( )
overridevirtual

Plays the sound.

Reimplemented from Engine3DRadSpace.Objects.InstIObject.

◆ GetGizmo()

Gizmos::IGizmo * SoundEffect::GetGizmo ( ) const
virtualnoexcept

Returns the gizmo object of this object, used for editor/debug rendering.

Returns
Pointer to a gizmo instance. Null if no gizmo is associated with this object.

Implements Engine3DRadSpace.Objects.IObject.

◆ GetInstance()

SoundInstance * SoundEffect::GetInstance ( ) const
noexcept

Gets the underlying sound instance used by this object.

Returns
Pointer to the underlying sound instance

◆ GetPitch()

float SoundEffect::GetPitch ( ) const
noexcept

Gets the pitch of the sound effect.

Returns
Pitch

◆ GetSound() [1/2]

Sound Engine3DRadSpace.Objects.SoundEffect.GetSound ( )
inline

◆ GetSound() [2/2]

Sound * SoundEffect::GetSound ( ) const
noexcept

Gets the underlying sound asset used by this object.

Returns
Pointer to the underlying sound asset

◆ GetSoundInstance()

SoundInstance Engine3DRadSpace.Objects.SoundEffect.GetSoundInstance ( )
inline

◆ GetUUID()

Reflection::UUID SoundEffect::GetUUID ( ) const
overridevirtualnoexcept

Gets the UUID of the SoundEffect type.

Returns
{4C9A4E2A-99DC-4E61-B5CB-3D75B569531F}

Implements Engine3DRadSpace.Objects.IObject.

◆ GetVolume()

float SoundEffect::GetVolume ( ) const
noexcept

Gets the gain of the sound effect.

Returns
Volume

◆ Initialize()

void SoundEffect::Initialize ( )
overridevirtual

Does nothing.

Reimplemented from Engine3DRadSpace.Objects.InstIObject.

◆ IsLooping()

bool SoundEffect::IsLooping ( ) const
noexcept

Gets whether the sound effect is looping.

Returns
True if the sound effect is looping, false otherwise

◆ Load() [1/2]

void SoundEffect::Load ( )
overridevirtual

Loads the sound asset.

Reimplemented from Engine3DRadSpace.Objects.InstIObject.

◆ Load() [2/2]

void SoundEffect::Load ( const std::filesystem::path & path)
overridevirtual

Loads a sound from an specified path.

Parameters
pathWAV or OGG file

Implements Engine3DRadSpace.ILoadable.

◆ operator=()

SoundEffect & Engine3DRadSpace.Objects.SoundEffect.operator= ( SoundEffect && )
defaultnoexcept

◆ SetLooping()

void SoundEffect::SetLooping ( bool looping)
noexcept

Sets whether the sound effect is looping.

Parameters
loopingTrue to make the sound effect loop, false otherwise

◆ SetPitch()

void SoundEffect::SetPitch ( float p)
noexcept

Sets the pitch of the sound effect. Default is 1.0. Range is [0.5, 2.0]. Values outside this range may cause audio distortion.

Parameters
p

◆ SetVolume()

void SoundEffect::SetVolume ( float f)
noexcept

Sets the gain of the sound effect. Range is [0.0, 1.0]. Default is 1.0.

Parameters
fVolume

◆ Switch()

bool SoundEffect::Switch ( )
overridevirtual

Plays the sound if stopped, and vice-versa.

Reimplemented from Engine3DRadSpace.Objects.InstIObject.

◆ Update()

void SoundEffect::Update ( )
overridevirtual

Does nothing.

Reimplemented from Engine3DRadSpace.InstIUpdateable.

Member Data Documentation

◆ Sound

RefSound Engine3DRadSpace.Objects.SoundEffect.Sound

Numerical reference to the sound asset used by this object.

Property Documentation

◆ Looping

bool Engine3DRadSpace.Objects.SoundEffect.Looping
getset

◆ Pitch

float Engine3DRadSpace.Objects.SoundEffect.Pitch
getset

◆ SoundID

uint Engine3DRadSpace.Objects.SoundEffect.SoundID
getset

◆ Volume

float Engine3DRadSpace.Objects.SoundEffect.Volume
getset

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