You.i Engine
CYIAssetSound Class Reference

Detailed Description

Asset representing sound PCM data.

Contains raw PCM data used for audio playback. Like most assets, this asset type can be unloaded by calling CYIAsset::Unload().

#include <asset/YiAssetSound.h>

Inheritance diagram for CYIAssetSound:

Public Member Functions

 CYIAssetSound ()
 
 CYIAssetSound (const CYIString &fileName, PathType pathType=PathType::Relative)
 
virtual ~CYIAssetSound ()
 
void SetData (std::unique_ptr< float[]> pData, uint32_t frameCount, uint32_t channelCount)
 
void SetData (const std::vector< float > &data, uint32_t frameCount, uint32_t channelCount)
 
const float * GetData () const
 
uint32_t GetFrameCount () const
 
uint32_t GetChannelCount () const
 
- Public Member Functions inherited from CYIAsset
virtual ~CYIAsset ()
 
const CYIStringGetPath () const
 
CYIAssetLoadParamsGetLoadParameters () const
 
bool SetName (const CYIString &name)
 
const CYIStringGetName () const
 
bool Load ()
 
void Unload ()
 
bool IsLoaded () const
 
bool Equals (const std::shared_ptr< CYIAsset > &pAsset)
 
virtual bool Prepare ()
 

Protected Member Functions

virtual void OnUnload () override
 
virtual std::pair< size_t, size_tGetApproximateSize () const override
 
- Protected Member Functions inherited from CYIAsset
 CYIAsset ()
 
ssize_t GetID () const
 
void SetPath (const CYIString &path, PathType pathType)
 
void SetApproximateSize (size_t size)
 
void SetLoaded (bool assetLoaded)
 
void SetLoadParameters (std::unique_ptr< CYIAssetLoadParams > pParams)
 
virtual void OnLoad ()
 

Additional Inherited Members

- Public Types inherited from CYIAsset
enum  PathType {
  PathType::Absolute = 0,
  PathType::Relative
}
 
- Static Protected Attributes inherited from CYIAsset
static ssize_t INVALID_ID
 

Constructor & Destructor Documentation

◆ CYIAssetSound() [1/2]

CYIAssetSound::CYIAssetSound ( )

◆ CYIAssetSound() [2/2]

CYIAssetSound::CYIAssetSound ( const CYIString fileName,
PathType  pathType = PathType::Relative 
)

◆ ~CYIAssetSound()

virtual CYIAssetSound::~CYIAssetSound ( )
virtual

Member Function Documentation

◆ GetApproximateSize()

virtual std::pair<size_t, size_t> CYIAssetSound::GetApproximateSize ( ) const
overrideprotectedvirtual

Calculates and returns the approximate number of bytes currently used by this asset. The first item of the returned pair object represents the memory currently taken in the CPU main memory, and the second item of the returned pair object represents the memory currently taken in the GPU memory.

Note
This function only returns an approximate memory consumption as the exact memory consumption changes depending on the used C++ libraries and on the specific GPU infrastructure and drivers used by the system.

Reimplemented from CYIAsset.

◆ GetChannelCount()

uint32_t CYIAssetSound::GetChannelCount ( ) const

Gets the channel count. For a mono sound, this will return 1. For a Stereo sound, 2 is returned. etc..

◆ GetData()

const float* CYIAssetSound::GetData ( ) const

Returns the raw PCM data for this sound. Returned data is an array the size of GetFrameCount() * GetChannelCount(). Each sample in the returned data is ranged from -1 to 1.

◆ GetFrameCount()

uint32_t CYIAssetSound::GetFrameCount ( ) const

Gets the audio frame count for this sound. A frame is as big as GetChannelCount().

◆ OnUnload()

virtual void CYIAssetSound::OnUnload ( )
overrideprotectedvirtual

Reimplemented from CYIAsset.

◆ SetData() [1/2]

void CYIAssetSound::SetData ( std::unique_ptr< float[]>  pData,
uint32_t  frameCount,
uint32_t  channelCount 
)

Sets the raw PCM data for this sound. pData should be an array of size frameCount * channelCount. Each sample in pData is ranged from -1 to 1.

◆ SetData() [2/2]

void CYIAssetSound::SetData ( const std::vector< float > &  data,
uint32_t  frameCount,
uint32_t  channelCount 
)

Sets the raw PCM data for this sound. pData should be an vector of size frameCount * channelCount. Each sample in pData is ranged from -1 to 1.


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