Gateware Libraries  R6.5A
Beta Build
GW::AUDIO::GAudio Class Referenceabstract
Inheritance diagram for GW::AUDIO::GAudio:
Collaboration diagram for GW::AUDIO::GAudio:

Public Member Functions

virtual GReturn Init (int _numOfOutputs=2)=0
 Initializes all neccassary data for GAudio based on platform. More...
 
virtual GReturn CreateSound (const char *_path, GSound **_outSound)=0
 Fills out a GSound with data from provided .wav file. More...
 
virtual GReturn CreateMusicStream (const char *_path, GMusic **_outMusic)=0
 Fills out a GMusic with data from provided .wav file. More...
 
virtual GReturn SetMasterVolume (float _value)=0
 Sets Master Volume for all sounds and music. More...
 
virtual GReturn SetMasterChannelVolumes (const float *_values, int _numChannels)=0
 Sets Master Volume for all sounds and music for specifc speakers. More...
 
virtual GReturn PauseAll ()=0
 Sets Pauses all sounds and music. More...
 
virtual GReturn ResumeAll ()=0
 Resumes all paused/stoped sounds and music. More...
 
virtual GReturn StopAll ()=0
 Stops all paused/playing sounds and music. More...
 
virtual GReturn GetCount (unsigned int &_outCount)=0
 Return the total number of active references to this object. More...
 
virtual GReturn IncrementCount ()=0
 Increase the total number of active references to this object. More...
 
virtual GReturn DecrementCount ()=0
 Decrease the total number of active references to this object. More...
 
virtual GReturn RequestInterface (const GUUIID &_interfaceID, void **_outputInterface)=0
 Requests an interface that may or may not be supported by this object. More...
 

Member Function Documentation

◆ CreateMusicStream()

virtual GReturn GW::AUDIO::GAudio::CreateMusicStream ( const char *  _path,
GMusic **  _outMusic 
)
pure virtual

Fills out a GMusic with data from provided .wav file.

Creates a GMusic to return, attempts to initallize internal variables, and loads header information from .wav file for setup.

Return values
FAILUREAn error occurred durring loading of header information.
FAILUREInternal objects could not be created. (On Windows these are the source voice and submix voice, on other platforms this is all in GSound's init).
FAILUREFailed to initialize internal variables. See Below for Platform On Linux pa_main_loop or pa_context could not be created, pa_context could not be connected, pa_channel_map could not be created, pa_stream could not be created, or pa_stream could not be connected. On Mac AvAudioPlayerNode could not be created or AvAudioPCMBuffers could not be initialized
SUCCESSNone of the above errors occured.

◆ CreateSound()

virtual GReturn GW::AUDIO::GAudio::CreateSound ( const char *  _path,
GSound **  _outSound 
)
pure virtual

Fills out a GSound with data from provided .wav file.

Creates a GSound to return, attempts to initallize internal variables, and loads audio fully into memeory.

Return values
FAILUREAn error occurred durring loading of file.
FAILUREInternal objects could not be created. (On Windows these are the source voice and submix voice, on other platforms this is all in GSound's init).
FAILUREFailed to initialize internal variables. See Below for Platform On Linux pa_main_loop or pa_context could not be created, pa_context could not be connected, pa_channel_map could not be created, pa_stream could not be created, or pa_stream could not be connected. On Mac AvAudioPlayerNode could not be created or could not read in file.
SUCCESSNone of the above errors occured.

◆ DecrementCount()

virtual GReturn GW::AUDIO::GAudio::DecrementCount ( )
pure virtual

Decrease the total number of active references to this object.

Once the internal count reaches zero this object will be deallocated and your pointer will become invalid.

Return values
SUCCESSSuccessfully decremented the internal reference count.
FAILUREDecrementing of internal reference count would underflow the value.

Implements GW::CORE::GInterface.

◆ GetCount()

virtual GReturn GW::AUDIO::GAudio::GetCount ( unsigned int &  _outCount)
pure virtual

Return the total number of active references to this object.

Parameters
[out]_outCountThe total number of active references of this object.
Return values
SUCCESSSuccessfully ran.
FAILUREEither class does not exist or the internal reference count is corrupt.

Implements GW::CORE::GInterface.

◆ IncrementCount()

virtual GReturn GW::AUDIO::GAudio::IncrementCount ( )
pure virtual

Increase the total number of active references to this object.

End users should only call this operation if they are familiar with reference counting behavior.

Return values
SUCCESSSuccessfully incremented the internal reference count.
FAILUREIncrementation of internal reference count would overflow the value.

Implements GW::CORE::GInterface.

◆ Init()

virtual GReturn GW::AUDIO::GAudio::Init ( int  _numOfOutputs = 2)
pure virtual

Initializes all neccassary data for GAudio based on platform.

On Windows, initilaizes XAudio2 pointers IXAudio2 and IXAudio2MasteringVoice. On Mac, initilaizes AVAudioEngine and starts the engine.

Parameters
[in]_numOfOutputsThe number of outputs (i.e. channels or speakers) GAudio should have control over. Default is two. Will be two on Mac and Linux currently.
Return values
FAILUREon if _numOfOutputs greater than
SUCCESSon Windows if xAudio2 is able to setup correctly.
FAILUREon Windows if it cannot coinitilaize.
FAILUREon Windows if it xAudio2Create fails.
FAILUREon Windows if it xAudio fails to create mastering voice.
SUCCESSon Mac if AVAudioEngine is able to setup correctly.
FAILUREon Mac if AVAudioEngine is able to setup correctly.
SUCCESSon Linux Always.
REDUNDANT_OPERATIONtbd

◆ PauseAll()

virtual GReturn GW::AUDIO::GAudio::PauseAll ( )
pure virtual

Sets Pauses all sounds and music.

Calls each created sound's and music pause function.

Return values
FAILUREA sound or Music returned FAILURE
SUCCESSSuccessfully ran without running into any of the above issues.

◆ RequestInterface()

virtual GReturn GW::AUDIO::GAudio::RequestInterface ( const GUUIID _interfaceID,
void **  _outputInterface 
)
pure virtual

Requests an interface that may or may not be supported by this object.

Can be used by the end-user to query for a new interface using the unique ID of the interface they want and implement an interface update.

Parameters
[in]_interfaceIDThe GUUIID of the interface you are requesting.
[out]_outputInterfaceWhere the interface will be stored if function is successful.
Return values
SUCCESSThe interface is supported and function succeded.
INTERFACE_UNSUPPORTEDThe requested interface is not supported.

Implements GW::CORE::GInterface.

◆ ResumeAll()

virtual GReturn GW::AUDIO::GAudio::ResumeAll ( )
pure virtual

Resumes all paused/stoped sounds and music.

Calls each created sound's and music resume function.

Return values
FAILUREA sound or Music returned FAILURE
SUCCESSSuccessfully ran without running into any of the above issues.

◆ SetMasterChannelVolumes()

virtual GReturn GW::AUDIO::GAudio::SetMasterChannelVolumes ( const float *  _values,
int  _numChannels 
)
pure virtual

Sets Master Volume for all sounds and music for specifc speakers.

The amount of values in _values that will be used is based on _numChannels. After setting this, created sounds and music will check if their current volumes are higher than passed in values and will set them to the new master volumes if they are above. If you attempt to set the volume of an output your hardware does not support, it will be ignored.

Channels: Supports up to 6 channels AKA 5.1 Audio: INDEX[0] = Left, INDEX[1] = Right, INDEX[2] = Front Center, INDEX[3] = LFE, INDEX[4] = Rear Left, INDEX[5] = Rear Right,

Parameters
[in]_valuesThe output volumes to be set.
[in]_numChannelsThe number of channels affected.
Return values
FAILURE_numChannels is less than 1.
FAILURE_values is NULL
SUCCESSSuccessfully ran without running into any of the above issues.

◆ SetMasterVolume()

virtual GReturn GW::AUDIO::GAudio::SetMasterVolume ( float  _value)
pure virtual

Sets Master Volume for all sounds and music.

After setting this, created sounds and music will check if their current volume are higher than passed in value and will set them to the new master volume if they are above.

Parameters
[in]_valueThe output master volume to be set.
Return values
FAILURE_newVolume is less than Zero.
SUCCESSSuccessfully ran without running into any of the above issues.

◆ StopAll()

virtual GReturn GW::AUDIO::GAudio::StopAll ( )
pure virtual

Stops all paused/playing sounds and music.

Calls each created sound's and music stop function.

Return values
FAILUREA sound or Music returned FAILURE
SUCCESSSuccessfully ran without running into any of the above issues.

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