Object responsible for processing audio streams and output to the platform.
The global instance is accessible through CYIFramework::GetAudioEngine. Used to register audio streams to be processed.
- Warning
- The CYIAudioEngine does not take ownership of the CYIAudioStream being passed in or registered. The user is responsible for holding on to a reference to the std::shared_ptr of the CYIAudioStream.
#include <audio/YiAudioEngine.h>
| virtual CYIAudioEngine::~CYIAudioEngine |
( |
| ) |
|
|
virtual |
| CYIAudioEngine::CYIAudioEngine |
( |
| ) |
|
|
protected |
| virtual void CYIAudioEngine::ClearCache |
( |
| ) |
|
|
virtual |
Clears the cache used by PlaySound(). All currently playing sound instances triggered by PlaySound() will be stopped immediately. This can be called if the application receives a memory warning.
Creates a sound instance that is not cached or reused by the audio engine.
Creates a sound instance that is not cached or reused by the audio engine.
| void CYIAudioEngine::Disable |
( |
| ) |
|
Disable the Audio Engine. Audio output will be muted, new sounds or CYIAudioStream won't start playing and all currently playing sounds will be stopped.
- Note
- Disabling the audio engine this way doesn't stop the thread or OS callbacks. To completely disable the Audio Engine, it has to be set from CYIFrameworkConfiguration at the application launch.
| void CYIAudioEngine::Enable |
( |
| ) |
|
Enable the Audio Engine. It is enabled by default.
| virtual uint32_t CYIAudioEngine::GetChannelCount |
( |
| ) |
const |
|
pure virtual |
Returns the channel count used by the audio engine. This is platform dependent and will not always be consistent with each run, but will remain constant for the life of the engine. Common channel counts are: mono (1), stereo (2), surround (8).
| virtual uint32_t CYIAudioEngine::GetSampleRate |
( |
| ) |
const |
|
pure virtual |
Returns the sample rate at which the audio engine is running. This is platform dependent and will not always be consistent with each run, but will remain constant for the life of the engine. Common sample rates are: 22050, 44100, 48000.
| bool CYIAudioEngine::IsEnabled |
( |
| ) |
const |
Returns whether the audio engine is currently enabled or disabled.
| virtual void CYIAudioEngine::PlaySound |
( |
const CYIString & |
name, |
|
|
float |
volume = 1.0f |
|
) |
| |
|
virtual |
Utility method to play a sound. It will cache the CYIAssetSound that matches the name. The sound will play at full volume by default, but a volume can be passed in the range [0, 1]. A volume value higher than 1 can be set, but sound output might be clipped.
| virtual void CYIAudioEngine::PlaySound |
( |
const std::shared_ptr< CYIAssetSound > & |
pAsset, |
|
|
float |
volume = 1.0f |
|
) |
| |
|
virtual |
Utility method to play a sound. The pAsset will be played and sound instances reused. The sound will play at full volume by default, but a volume can be passed in the range [0, 1] A volume value higher than 1 can be set, but sound output might be clipped.
| virtual void CYIAudioEngine::Process |
( |
float * |
pData, |
|
|
uint32_t |
uFrameCount |
|
) |
| |
|
protectedvirtual |
Processes 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 cummulative for all active CYIAudioStream instances. To start processing, a stream needs to be registered to the CYIAudioEngine. Unregister to stop processing.
- Note
- This is called from the audio thread.
| virtual void CYIAudioEngine::RegisterStream |
( |
const std::shared_ptr< CYIAudioStream > & |
pStreamToAdd | ) |
|
|
virtual |
Registers a CYIAudioStream for playback. pStream will start receiving CYIAudioStream::Process callback immediately.
- Warning
- The CYIAudioEngine will not take ownership of the stream being passed in and will only internally hold a CYIWeakPointer to the stream being registered. It is up to the user to hold on to a reference of the std::shared_ptr of the CYIAudioStream being passed in.
| virtual void CYIAudioEngine::UnregisterStream |
( |
const std::shared_ptr< CYIAudioStream > & |
pStreamToRemove | ) |
|
|
virtual |
The documentation for this class was generated from the following file: