Jopnal Engine  alpha 0.4
Simple Component Based 2D/3D Game Engine
Public Types | Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends | List of all members
jop::SoundSource Class Referenceabstract

#include <SoundSource.hpp>

Inheritance diagram for jop::SoundSource:
jop::Component jop::SoundEffect jop::SoundStream

Public Types

enum  Status { Status::Stopped, Status::Paused, Status::Playing }
 

Public Member Functions

 SoundSource (Object &object, const uint32 ID)
 Constructor. More...
 
virtual ~SoundSource () override=0
 Virtual destructor. More...
 
void update (const float deltaTime) override
 Update. More...
 
SoundSourcesetVolume (const float vol)
 Set sound's volume. More...
 
float getVolume () const
 Get the volume. More...
 
SoundSourcesetPitch (const float value)
 Set pitch. More...
 
float getPitch () const
 Get the pitch. More...
 
SoundSourcesetSpatialization (const bool toggle)
 Toggle listener on/off. More...
 
bool isSpatialized () const
 Returns relativity to listener. More...
 
SoundSourcesetAttenuation (const float at)
 Change sound's fade-out distance. More...
 
SoundSourcesetMinDistance (const float min)
 Change sound's distance when it is heard in max volume. More...
 
float getAttenuation () const
 Returns attenuation value. More...
 
float getMinDistance () const
 Returns distance of max volume. More...
 
Status getStatus () const
 Returns status of the sound (Stopped,Paused,Playing) More...
 
SoundSourceuseDirection (const bool use)
 Use object's direction for sound. More...
 
bool isDirection () const
 Check if sound has direction. More...
 
- Public Member Functions inherited from jop::Component
virtual ~Component ()=0
 Virtual destructor. More...
 
Message::Result sendMessage (const Message &message)
 Send a message to this component. More...
 
uint32 getID () const
 Get the identifier. More...
 
void setID (const uint32 ID)
 Set the identifier. More...
 
WeakReference< ObjectgetObject ()
 Get the object this component is bound to. More...
 
WeakReference< const ObjectgetObject () const
 Get the object this component is bound to. More...
 
bool isActive () const
 Check if this component is active. More...
 
void removeSelf ()
 Remove this component from its object. More...
 

Protected Member Functions

 SoundSource (const SoundSource &other, Object &newObj)
 Copy constructor. More...
 
 JOP_DISALLOW_COPY_MOVE (SoundSource)
 
- Protected Member Functions inherited from jop::Component
 Component (Object &object, const uint32 ID)
 Constructor. More...
 
 Component (const Component &other, Object &newObj)
 Copy constructor. More...
 
virtual Message::Result receiveMessage (const Message &message)
 Receive a message. More...
 

Static Protected Member Functions

static bool isSpeedOfSound ()
 Private check is speed of sound calculated. More...
 

Protected Attributes

unsigned int m_source
 Sound source. More...
 
float m_delayCounter
 Sound's propagation delay. More...
 
bool m_calculateDelay
 Check if delay should be calculated. More...
 

Friends

class Listener
 

Detailed Description

Base class for audio component

Definition at line 37 of file SoundSource.hpp.

Member Enumeration Documentation

Sound status

Enumerator
Stopped 

Sound is stopped.

Paused 

Sound is paused.

Playing 

Sound is playing.

Definition at line 58 of file SoundSource.hpp.

Constructor & Destructor Documentation

jop::SoundSource::SoundSource ( const SoundSource other,
Object newObj 
)
protected

Copy constructor.

Parameters
otherThe other sound source to be copied
newObjThe new object for this sound source
jop::SoundSource::SoundSource ( Object object,
const uint32  ID 
)

Constructor.

Parameters
objectReference to the object this component will be bound to
IDComponent identifier
virtual jop::SoundSource::~SoundSource ( )
overridepure virtual

Virtual destructor.

Member Function Documentation

float jop::SoundSource::getAttenuation ( ) const

Returns attenuation value.

Returns
Attenuation value
float jop::SoundSource::getMinDistance ( ) const

Returns distance of max volume.

Returns
Minimum distance
float jop::SoundSource::getPitch ( ) const

Get the pitch.

Returns
The pitch value
Status jop::SoundSource::getStatus ( ) const

Returns status of the sound (Stopped,Paused,Playing)

Returns
enum
float jop::SoundSource::getVolume ( ) const

Get the volume.

Returns
The volume
bool jop::SoundSource::isDirection ( ) const

Check if sound has direction.

Returns
Is direction calculated for sound
bool jop::SoundSource::isSpatialized ( ) const

Returns relativity to listener.

Returns
True if spatialized false if relative to listener
static bool jop::SoundSource::isSpeedOfSound ( )
staticprotected

Private check is speed of sound calculated.

Returns
Boolean if true speed is calculated
jop::SoundSource::JOP_DISALLOW_COPY_MOVE ( SoundSource  )
protected
SoundSource& jop::SoundSource::setAttenuation ( const float  at)

Change sound's fade-out distance.

Higher values mean that the sound will fade out more quickly.

Parameters
atAttenuation 0-100.0f
Returns
Reference to self
This method is exposed as command named setAttenuation
SoundSource& jop::SoundSource::setMinDistance ( const float  min)

Change sound's distance when it is heard in max volume.

Parameters
minMinDistance 1<x
Returns
Reference to self
This method is exposed as command named setMinDistance
SoundSource& jop::SoundSource::setPitch ( const float  value)

Set pitch.

Be careful with this function. Setting the pitch too high or low can lead to sound artifacts or even crashes. The safe range seems to be between 0.1 and 8.

Parameters
valueThe pitch value. Default is 1
Returns
Reference to self
This method is exposed as command named setPitch
SoundSource& jop::SoundSource::setSpatialization ( const bool  toggle)

Toggle listener on/off.

Parameters
toggleTrue enables spatialization (default) and makes sound relative to listener
Returns
Reference to self
This method is exposed as command named setListener
SoundSource& jop::SoundSource::setVolume ( const float  vol)

Set sound's volume.

The value will be clamped inside the appropriate range.

Parameters
volFloat 0-100.0f default is 100.0f
Returns
Reference to self
This method is exposed as command named setVolume
void jop::SoundSource::update ( const float  deltaTime)
overridevirtual

Update.

Automatically updates position.

Parameters
deltaTimeThe delta time

Reimplemented from jop::Component.

Reimplemented in jop::SoundStream.

SoundSource& jop::SoundSource::useDirection ( const bool  use)

Use object's direction for sound.

Parameters
usetrue will make sound to use direction

Friends And Related Function Documentation

friend class Listener
friend

Definition at line 41 of file SoundSource.hpp.

Member Data Documentation

bool jop::SoundSource::m_calculateDelay
protected

Check if delay should be calculated.

Definition at line 202 of file SoundSource.hpp.

float jop::SoundSource::m_delayCounter
protected

Sound's propagation delay.

Definition at line 201 of file SoundSource.hpp.

unsigned int jop::SoundSource::m_source
protected

Sound source.

Definition at line 200 of file SoundSource.hpp.


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