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

Represents a single instance of a sound. More...

#include <SoundInstance.hpp>

Inheritance diagram for Engine3DRadSpace.Audio.SoundInstance:
Collaboration diagram for Engine3DRadSpace.Audio.SoundInstance:

Public Member Functions

unsafe SoundInstance (Sound sound, AudioSource source)
 SoundInstance (IntPtr ptrSI)
void Play ()
void Stop ()
void Pause ()
 SoundInstance (Sound *sound, const AudioSource &source)
 Constructs a space localized sound instance.
 SoundInstance (Sound *sound)
 Constructs a sound instance with default audio source settings.
 SoundInstance (SoundInstance &&other) noexcept
 Move constructor. Transfers ownership of the sound instance to this object.
SoundInstance & operator= (SoundInstance &&other) noexcept
 Move assignment operator. Transfers ownership of the sound instance to this object.
const AudioSource & GetSource () noexcept
 Gets the sound properties associated with this instance.
void SetSource (const AudioSource &source)
 Sets the sound properties associated with this instance.
SoundState GetState () const noexcept
 Gets the state of this sound instance.
void SetPitch (float pitch)
 Sets the pitch of this sound instance. Range is [0.5, 2.0]. Default is 1.0.
void SetGain (float gain)
 Sets the volume of this sound instance. Range is [0.0, 1.0]. Default is 1.0.
void SetMaxGain (float maxGain)
 Sets the maximum volume of this sound instance. Range is [0.0, 1.0]. Default is 1.0.
void SetMinGain (float minGain)
 Sets the minimum volume of this sound instance. Range is [0.0, 1.0]. Default is 0.0.
void SetPosition (const Math::Vector3 &pos)
 Sets the 3D position of this sound instance in world space. Default is (0, 0, 0).
void SetVelocity (const Math::Vector3 &vel)
 Sets the velocity of this sound instance, used for Doppler effect calculations. Default is (0, 0, 0).
void SetDirection (const Math::Vector3 &dir)
 Sets the direction this sound instance is facing, used for directional (cone) sound sources. Default is (0, 0, 0), meaning omnidirectional.
void SetMaxDistance (float distance)
 Sets the maximum distance beyond which this sound instance's volume is not attenuated further. Used with the Inverse Clamped Distance Model. Default is FLT_MAX.
void SetReferenceDistance (float refDistance)
 Sets the reference distance at which the volume would be unattenuated. Default is 1.0.
void SetRolloffFactor (float rolloff)
 Sets the rolloff factor, controlling how quickly the volume attenuates with distance. Default is 1.0.
void SetConeOuterGain (float outerGain)
 Sets the gain applied outside the sound cone's outer angle. Range is [0.0, 1.0]. Default is 0.0.
void SetConeInnerAngle (float angle)
 Sets the inner angle of the sound cone, in degrees, within which the sound is at full volume. Range is [0, 360]. Default is 360.
void SetConeOuterAngle (float angle)
 Sets the outer angle of the sound cone, in degrees, beyond which the sound is attenuated to the cone outer gain. Range is [0, 360]. Default is 360.
float GetPitch ()
 Gets the pitch of this sound instance.
float GetGain ()
 Gets the volume of this sound instance.
float GetMaxGain ()
 Gets the maximum volume of this sound instance.
float GetMinGain ()
 Gets the minimum volume of this sound instance.
Math::Vector3 GetPosition ()
 Gets the 3D position of this sound instance in world space.
Math::Vector3 GetVelocity ()
 Gets the velocity of this sound instance.
Math::Vector3 GetDirection ()
 Gets the direction this sound instance is facing.
float GetMaxDistance ()
 Gets the maximum distance beyond which this sound instance's volume is not attenuated further.
float GetReferenceDistance ()
 Gets the reference distance at which the volume would be unattenuated.
float GetRolloffFactor ()
 Gets the rolloff factor.
float GetConeOuterGain ()
 Gets the gain applied outside the sound cone's outer angle.
float GetConeInnerAngle ()
 Gets the inner angle of the sound cone, in degrees.
float GetConeOuterAngle ()
 Gets the outer angle of the sound cone, in degrees.
bool IsLooping ()
 Gets whether this sound instance is set to loop upon reaching the end of playback.
void SetLooping (bool looping)
 Sets whether this sound instance should loop upon reaching the end of playback. Default is false.
void Play (bool dontOverlap=true) const noexcept
 Starts or resumes playback of this sound instance.
void Stop () const noexcept
 Stops playback of this sound instance and resets its playback position.
void Pause () const noexcept
 Pauses playback of this sound instance, preserving its current playback position.
 ~SoundInstance ()
 Deletes the associated OpenAL sound source.
Public Member Functions inherited from Engine3DRadSpace.NatPtrWrapper
virtual void Dispose ()

Properties

float Pitch [get, set]
float Gain [get, set]
float MaxGain [get, set]
float MinGain [get, set]
unsafe Vector3 Position [get, set]
unsafe Vector3 Velocity [get, set]
unsafe Vector3 Direction [get, set]
float MaxDistance [get, set]
float RerefenceDistance [get, set]
float RolloffFactor [get, set]
float ConeOuterGain [get, set]
float ConeInnerAngle [get, set]
float ConeOuterAngle [get, set]
bool IsLooping [get, set]
Properties inherited from Engine3DRadSpace.NatPtrWrapper
IntPtr Handle [get]

Additional Inherited Members

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 Attributes inherited from Engine3DRadSpace.NatPtrWrapper
IntPtr _handle
bool _disposed

Detailed Description

Represents a single instance of a sound.

Constructor & Destructor Documentation

◆ SoundInstance() [1/5]

unsafe Engine3DRadSpace.Audio.SoundInstance.SoundInstance ( Sound sound,
AudioSource source )
inline

◆ SoundInstance() [2/5]

Engine3DRadSpace.Audio.SoundInstance.SoundInstance ( IntPtr ptrSI)
inline

◆ SoundInstance() [3/5]

SoundInstance::SoundInstance ( Sound * sound,
const AudioSource & source )

Constructs a space localized sound instance.

Parameters
soundThe sound to be played
sourceThe audio source

◆ SoundInstance() [4/5]

SoundInstance::SoundInstance ( Sound * sound)
explicit

Constructs a sound instance with default audio source settings.

Parameters
soundThe sound to be played

◆ SoundInstance() [5/5]

Move constructor. Transfers ownership of the sound instance to this object.

Parameters
otherThe sound instance to move from

◆ ~SoundInstance()

SoundInstance::~SoundInstance ( )

Deletes the associated OpenAL sound source.

Member Function Documentation

◆ GetConeInnerAngle()

float SoundInstance::GetConeInnerAngle ( )

Gets the inner angle of the sound cone, in degrees.

Returns
inner cone angle, in degrees

◆ GetConeOuterAngle()

float SoundInstance::GetConeOuterAngle ( )

Gets the outer angle of the sound cone, in degrees.

Returns
outer cone angle, in degrees

◆ GetConeOuterGain()

float SoundInstance::GetConeOuterGain ( )

Gets the gain applied outside the sound cone's outer angle.

Returns
outer cone gain

◆ GetDirection()

Vector3 SoundInstance::GetDirection ( )

Gets the direction this sound instance is facing.

Returns
direction

◆ GetGain()

float SoundInstance::GetGain ( )

Gets the volume of this sound instance.

Returns
volume

◆ GetMaxDistance()

float SoundInstance::GetMaxDistance ( )

Gets the maximum distance beyond which this sound instance's volume is not attenuated further.

Returns
maximum distance

◆ GetMaxGain()

float SoundInstance::GetMaxGain ( )

Gets the maximum volume of this sound instance.

Returns
maximum volume

◆ GetMinGain()

float SoundInstance::GetMinGain ( )

Gets the minimum volume of this sound instance.

Returns
minimum volume

◆ GetPitch()

float SoundInstance::GetPitch ( )

Gets the pitch of this sound instance.

Returns
pitch

◆ GetPosition()

Vector3 SoundInstance::GetPosition ( )

Gets the 3D position of this sound instance in world space.

Returns
position

◆ GetReferenceDistance()

float SoundInstance::GetReferenceDistance ( )

Gets the reference distance at which the volume would be unattenuated.

Returns
reference distance

◆ GetRolloffFactor()

float SoundInstance::GetRolloffFactor ( )

Gets the rolloff factor.

Returns
rolloff factor

◆ GetSource()

const AudioSource & SoundInstance::GetSource ( )
noexcept

Gets the sound properties associated with this instance.

Returns
AudioSource

◆ GetState()

SoundState SoundInstance::GetState ( ) const
noexcept

Gets the state of this sound instance.

Returns
Sound state of this

◆ GetVelocity()

Vector3 SoundInstance::GetVelocity ( )

Gets the velocity of this sound instance.

Returns
velocity

◆ IsLooping()

Gets whether this sound instance is set to loop upon reaching the end of playback.

Returns
true if looping is enabled, false otherwise

◆ operator=()

SoundInstance & SoundInstance::operator= ( SoundInstance && other)
noexcept

Move assignment operator. Transfers ownership of the sound instance to this object.

Parameters
otherThe sound instance to move from
Returns
The sound instance with transferred ownership

◆ Pause() [1/2]

void Engine3DRadSpace.Audio.SoundInstance.Pause ( )
inline

◆ Pause() [2/2]

Pauses playback of this sound instance, preserving its current playback position.

◆ Play() [1/2]

void Engine3DRadSpace.Audio.SoundInstance.Play ( )
inline

◆ Play() [2/2]

void SoundInstance::Play ( bool dontOverlap = true) const
noexcept

Starts or resumes playback of this sound instance.

Parameters
dontOverlapif true, restarts playback from the beginning instead of overlapping with an already playing instance

◆ SetConeInnerAngle()

void SoundInstance::SetConeInnerAngle ( float angle)

Sets the inner angle of the sound cone, in degrees, within which the sound is at full volume. Range is [0, 360]. Default is 360.

Parameters
angleinner cone angle, in degrees

◆ SetConeOuterAngle()

void SoundInstance::SetConeOuterAngle ( float angle)

Sets the outer angle of the sound cone, in degrees, beyond which the sound is attenuated to the cone outer gain. Range is [0, 360]. Default is 360.

Parameters
angleouter cone angle, in degrees

◆ SetConeOuterGain()

void SoundInstance::SetConeOuterGain ( float outerGain)

Sets the gain applied outside the sound cone's outer angle. Range is [0.0, 1.0]. Default is 0.0.

Parameters
outerGainouter cone gain

◆ SetDirection()

void SoundInstance::SetDirection ( const Math::Vector3 & dir)

Sets the direction this sound instance is facing, used for directional (cone) sound sources. Default is (0, 0, 0), meaning omnidirectional.

Parameters
dirthe direction

◆ SetGain()

void SoundInstance::SetGain ( float gain)

Sets the volume of this sound instance. Range is [0.0, 1.0]. Default is 1.0.

Parameters
gainvolume

◆ SetLooping()

void SoundInstance::SetLooping ( bool looping)

Sets whether this sound instance should loop upon reaching the end of playback. Default is false.

Parameters
loopingtrue to enable looping, false to disable

◆ SetMaxDistance()

void SoundInstance::SetMaxDistance ( float distance)

Sets the maximum distance beyond which this sound instance's volume is not attenuated further. Used with the Inverse Clamped Distance Model. Default is FLT_MAX.

Parameters
distancemaximum distance

◆ SetMaxGain()

void SoundInstance::SetMaxGain ( float maxGain)

Sets the maximum volume of this sound instance. Range is [0.0, 1.0]. Default is 1.0.

Parameters
maxGainmaximum volume

◆ SetMinGain()

void SoundInstance::SetMinGain ( float minGain)

Sets the minimum volume of this sound instance. Range is [0.0, 1.0]. Default is 0.0.

Parameters
minGainminimum volume

◆ SetPitch()

void SoundInstance::SetPitch ( float pitch)

Sets the pitch of this sound instance. Range is [0.5, 2.0]. Default is 1.0.

Parameters
pitchThe pitch value to set

◆ SetPosition()

void SoundInstance::SetPosition ( const Math::Vector3 & pos)

Sets the 3D position of this sound instance in world space. Default is (0, 0, 0).

Parameters
posthe position

◆ SetReferenceDistance()

void SoundInstance::SetReferenceDistance ( float refDistance)

Sets the reference distance at which the volume would be unattenuated. Default is 1.0.

Parameters
refDistancereference distance

◆ SetRolloffFactor()

void SoundInstance::SetRolloffFactor ( float rolloff)

Sets the rolloff factor, controlling how quickly the volume attenuates with distance. Default is 1.0.

Parameters
rolloffrolloff factor

◆ SetSource()

void SoundInstance::SetSource ( const AudioSource & source)

Sets the sound properties associated with this instance.

Parameters
sourceThe audio source to set

◆ SetVelocity()

void SoundInstance::SetVelocity ( const Math::Vector3 & vel)

Sets the velocity of this sound instance, used for Doppler effect calculations. Default is (0, 0, 0).

Parameters
velthe velocity

◆ Stop() [1/2]

void Engine3DRadSpace.Audio.SoundInstance.Stop ( )
inline

◆ Stop() [2/2]

Stops playback of this sound instance and resets its playback position.

Property Documentation

◆ ConeInnerAngle

float Engine3DRadSpace.Audio.SoundInstance.ConeInnerAngle
getset

◆ ConeOuterAngle

float Engine3DRadSpace.Audio.SoundInstance.ConeOuterAngle
getset

◆ ConeOuterGain

float Engine3DRadSpace.Audio.SoundInstance.ConeOuterGain
getset

◆ Direction

unsafe Vector3 Engine3DRadSpace.Audio.SoundInstance.Direction
getset

◆ Gain

float Engine3DRadSpace.Audio.SoundInstance.Gain
getset

◆ IsLooping

bool SoundInstance.IsLooping
getset

◆ MaxDistance

float Engine3DRadSpace.Audio.SoundInstance.MaxDistance
getset

◆ MaxGain

float Engine3DRadSpace.Audio.SoundInstance.MaxGain
getset

◆ MinGain

float Engine3DRadSpace.Audio.SoundInstance.MinGain
getset

◆ Pitch

float Engine3DRadSpace.Audio.SoundInstance.Pitch
getset

◆ Position

unsafe Vector3 Engine3DRadSpace.Audio.SoundInstance.Position
getset

◆ RerefenceDistance

float Engine3DRadSpace.Audio.SoundInstance.RerefenceDistance
getset

◆ RolloffFactor

float Engine3DRadSpace.Audio.SoundInstance.RolloffFactor
getset

◆ Velocity

unsafe Vector3 Engine3DRadSpace.Audio.SoundInstance.Velocity
getset

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