Cafu Engine
BufferT Class Referenceabstract

A BufferT encapsulates an audio resource such as a file or a capture device. More...

#include "Buffer.hpp"

Inheritance diagram for BufferT:

Public Member Functions

 BufferT (const std::string &ResName, bool ForceMono)
 The constructor. More...
 
virtual ~BufferT ()
 The virtual destructor, so that derived classes can safely be deleted via a BufferT (base class) pointer. More...
 
const std::string & GetName () const
 Returns the name of the resource (file or capture device) that this buffer was created from. More...
 
bool ForcesMono () const
 Returns whether the data from the resource is reduced to a single channel before use (mono output). More...
 
virtual unsigned int GetChannels () const =0
 Returns the number of audio channels in this buffer (1 is mono, 2 is stereo). More...
 
virtual bool CanShare () const =0
 Returns whether this buffer can be attached to multiple mixer tracks (resource sharing). More...
 
virtual void Update ()=0
 Updates the buffer. More...
 
virtual bool AttachToMixerTrack (MixerTrackT *MixerTrack)=0
 Attaches the buffer to a mixer track, so the mixer track can play this buffer. More...
 
virtual bool DetachFromMixerTrack (MixerTrackT *MixerTrack)=0
 Detaches the buffer from a mixer track. More...
 

Public Attributes

unsigned int References
 Number of references to this buffer (e.g. how many sound objects use this buffer). More...
 

Protected Member Functions

unsigned int ConvertToMono (unsigned char *Buffer, unsigned int Size)
 Converts signed 16 bit raw PCM data from stereo to mono. More...
 

Protected Attributes

ArrayT< MixerTrackT * > m_MixerTracks
 Mixer tracks this buffer is currently attached to. More...
 

Detailed Description

A BufferT encapsulates an audio resource such as a file or a capture device.

It is responsible for managing the OpenAL buffer(s) in an OpenAL source, such as creating and filling the buffer(s), assigning or queuing them to the source, etc.

Constructor & Destructor Documentation

BufferT::BufferT ( const std::string &  ResName,
bool  ForceMono 
)

The constructor.

Parameters
ResNameThe name of the resource (file or capture device) that this buffer is created from.
ForceMonoWhether the data from the resource should be reduced to a single channel before use (mono output).
virtual BufferT::~BufferT ( )
inlinevirtual

The virtual destructor, so that derived classes can safely be deleted via a BufferT (base class) pointer.

Member Function Documentation

virtual bool BufferT::AttachToMixerTrack ( MixerTrackT MixerTrack)
pure virtual

Attaches the buffer to a mixer track, so the mixer track can play this buffer.

Note that depending on the underlying buffer it is possible to attach one buffer to multiple mixer tracks. As for streaming buffers this is not possible since they are unique and can only be attached to one mixer track.

Parameters
MixerTrackThe mixer track this buffer should be attached to.
Returns
Whether the buffer could be attached to the mixer track.

Implemented in StreamingBufferT, and StaticBufferT.

virtual bool BufferT::CanShare ( ) const
pure virtual

Returns whether this buffer can be attached to multiple mixer tracks (resource sharing).

Implemented in StreamingBufferT, and StaticBufferT.

unsigned int BufferT::ConvertToMono ( unsigned char *  Buffer,
unsigned int  Size 
)
protected

Converts signed 16 bit raw PCM data from stereo to mono.

Parameters
BufferThe PCM data to convert to mono.
SizeSize of the data in bytes.
Returns
The resulting buffer size.
virtual bool BufferT::DetachFromMixerTrack ( MixerTrackT MixerTrack)
pure virtual

Detaches the buffer from a mixer track.

This method informs the mixer track as well as the buffer of the change.

Parameters
MixerTrackThe mixer track this buffer should be attached from.
Returns
Whether the buffer could be attached to the mixer track. False means usually that this buffer wasn't attached to the passed mixer track at all.

Implemented in StreamingBufferT, and StaticBufferT.

bool BufferT::ForcesMono ( ) const
inline

Returns whether the data from the resource is reduced to a single channel before use (mono output).

virtual unsigned int BufferT::GetChannels ( ) const
pure virtual

Returns the number of audio channels in this buffer (1 is mono, 2 is stereo).

Implemented in StreamingBufferT, and StaticBufferT.

const std::string& BufferT::GetName ( ) const
inline

Returns the name of the resource (file or capture device) that this buffer was created from.

virtual void BufferT::Update ( )
pure virtual

Updates the buffer.

Implemented in StreamingBufferT, and StaticBufferT.

Member Data Documentation

ArrayT<MixerTrackT*> BufferT::m_MixerTracks
protected

Mixer tracks this buffer is currently attached to.

unsigned int BufferT::References

Number of references to this buffer (e.g. how many sound objects use this buffer).


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