You.i Engine
CYISoundInstance Class Reference

Detailed Description

Object representing a sound instance.

If two sounds need to be played at the same time, two instances need to be created. They will both be pointing to the same CYIAssetSound and share the PCM data.

#include <audio/YiSoundInstance.h>

Inheritance diagram for CYISoundInstance:

Public Member Functions

 CYISoundInstance ()
 
 CYISoundInstance (const std::shared_ptr< CYIAssetSound > &pAssetSound)
 
virtual ~CYISoundInstance ()
 
void Play ()
 
void Pause ()
 
void Stop ()
 
bool IsPlaying () const
 
void SetAsset (const std::shared_ptr< CYIAssetSound > &pAssetSound)
 
void SetLooping (bool bShouldLoop)
 
bool IsLooping () const
 
void SetVolume (float fVolume)
 
float GetVolume () const
 
virtual bool Process (CYIAudioEngine *pAudioEngine, float *pData, uint32_t uFrameCount) override
 
- Public Member Functions inherited from CYIAudioStream
 CYIAudioStream ()
 
virtual ~CYIAudioStream ()
 

Public Attributes

CYISignal PlaybackCompleted
 

Constructor & Destructor Documentation

CYISoundInstance::CYISoundInstance ( )
CYISoundInstance::CYISoundInstance ( const std::shared_ptr< CYIAssetSound > &  pAssetSound)
virtual CYISoundInstance::~CYISoundInstance ( )
virtual

Member Function Documentation

float CYISoundInstance::GetVolume ( ) const

Gets the current volume

bool CYISoundInstance::IsLooping ( ) const

Gets whether the sound instance is set to loop or not.

bool CYISoundInstance::IsPlaying ( ) const

Returns true if the sound is currently playing.

void CYISoundInstance::Pause ( )

Pauses playback. Can be resumed with Play().

void CYISoundInstance::Play ( )

Plays the sound. This will resume if the sound was paused with Pause().

virtual bool CYISoundInstance::Process ( CYIAudioEngine pAudioEngine,
float *  pData,
uint32_t  uFrameCount 
)
overridevirtual

Called by the CYIAudioEngine to process an audio buffer. pData is an array of size uFrameCount * CYIAudioEngine::GetChannelCount(). Each sample in pData is ranged from -1 to 1.

New samples processes by this callback should be added to pData, not overriden. It is cumulative for all active CYIAudioStream instances. To start processing, this stream needs to be registered to the CYIAudioEngine. Unregister to stop processing.

Note
This is called from the audio thread.

Implements CYIAudioStream.

void CYISoundInstance::SetAsset ( const std::shared_ptr< CYIAssetSound > &  pAssetSound)

Sets the CYIAssetSound to be used for this instance. The asset can be switched while the sound is playing without modifying its current playback position. The sound will stop playback if the new asset is shorter than the current playback position.

void CYISoundInstance::SetLooping ( bool  bShouldLoop)

Sets whether the sound instance will loop.

void CYISoundInstance::SetVolume ( float  fVolume)

Sets volume from 0 (muted) to 1 (full volume). A volume value higher than 1 can be set, but sound output might be clipped.

void CYISoundInstance::Stop ( )

Stops playback and resets playback position to the start of the sound.

Member Data Documentation

CYISignal CYISoundInstance::PlaybackCompleted

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