Jopnal Engine  alpha 0.4
Simple Component Based 2D/3D Game Engine
Public Member Functions | List of all members
jop::SoundEffect Class Reference

#include <SoundEffect.hpp>

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

Public Member Functions

 SoundEffect (Object &object)
 Constructor. More...
 
 ~SoundEffect ()
 Destructor. More...
 
void update (const float deltaTime) override
 Update. More...
 
SoundEffectsetBuffer (const SoundBuffer &buffer)
 Set the sound buffer. More...
 
SoundEffectplay ()
 Play sound. More...
 
SoundEffectplayReset ()
 Play sound from start. More...
 
SoundEffectstop ()
 Stop playing sound. More...
 
SoundEffectpause ()
 Pause sound. More...
 
SoundEffectsetOffset (const float time)
 Set from which point the sound starts playing. More...
 
float getOffset () const
 Returns point where sound is playing. More...
 
SoundEffectsetLoop (const bool loop)
 Enable/disable looping. More...
 
bool isLooping () const
 Check if this sound is looping. More...
 
- Public Member Functions inherited from jop::SoundSource
 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...
 

Additional Inherited Members

- Public Types inherited from jop::SoundSource
enum  Status { Status::Stopped, Status::Paused, Status::Playing }
 
- Protected Member Functions inherited from jop::SoundSource
 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 inherited from jop::SoundSource
static bool isSpeedOfSound ()
 Private check is speed of sound calculated. More...
 
- Protected Attributes inherited from jop::SoundSource
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...
 

Detailed Description

Audio component that plays sound

Definition at line 36 of file SoundEffect.hpp.

Constructor & Destructor Documentation

jop::SoundEffect::SoundEffect ( Object object)

Constructor.

Parameters
objectReference to the object this component will be bound to
jop::SoundEffect::~SoundEffect ( )

Destructor.

Member Function Documentation

float jop::SoundEffect::getOffset ( ) const

Returns point where sound is playing.

Returns
The playing offset in seconds
bool jop::SoundEffect::isLooping ( ) const

Check if this sound is looping.

Returns
True if looping
SoundEffect& jop::SoundEffect::pause ( )

Pause sound.

The playing offset will be left at the current position.

Returns
Reference to self
See also
play()
stop()
This method is exposed as command named pauseEffect
SoundEffect& jop::SoundEffect::play ( )

Play sound.

Returns
Reference to self
This method is exposed as command named playEffect
SoundEffect& jop::SoundEffect::playReset ( )

Play sound from start.

Returns
Reference to self
See also
stop()
pause()
SoundEffect& jop::SoundEffect::setBuffer ( const SoundBuffer buffer)

Set the sound buffer.

Warning
The bound buffer has to stay alive as long as it's being used
Parameters
bufferReference to the buffer
Returns
Reference to self
SoundEffect& jop::SoundEffect::setLoop ( const bool  loop)

Enable/disable looping.

If looping is enabled, the sound will loop indefinitely until stopped.

Parameters
loopTrue to set this sound to loop
Returns
Reference to self
This method is exposed as command named setEffectLoop
SoundEffect& jop::SoundEffect::setOffset ( const float  time)

Set from which point the sound starts playing.

The value will be clamped to fit the buffer's length.

Parameters
timeThe time point as seconds
Returns
Reference to self
This method is exposed as command named setEffectOffset
SoundEffect& jop::SoundEffect::stop ( )

Stop playing sound.

After this call, the playing offset will be at the beginning.

Returns
Reference to self
See also
play()
pause()
This method is exposed as command named stopEffect
void jop::SoundEffect::update ( const float  deltaTime)
overridevirtual

Update.

Automatically updates position.

Parameters
deltaTimeThe delta time

Reimplemented from jop::Component.


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