Kicking it Olde Sküül! Burgerlib on Github Follow Olde Sküül on Twitter Burgerbecky on LinkedIn Burgerbecky on LinkedIn
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
Burger::SoundManager Class Reference
Inheritance diagram for Burger::SoundManager:
Inheritance graph
[legend]
Collaboration diagram for Burger::SoundManager:
Collaboration graph
[legend]

Classes

class  Buffer
 Audio data class. More...
 
class  BufferDecoder
 
struct  BufferDescription_t
 
class  SoundCardDescription
 
class  Voice
 Audio playback class. More...
 

Public Types

enum  { FLAGDOUBLEBUFFER =0x4000 }
 
enum  eCodecCommand {
  CODECBUFFERSIZE , CODECINIT , CODECSHUTDOWN , CODECDECODE ,
  CODECRESET
}
 
enum  eDataType {
  TYPEBYTE , TYPECHAR , TYPELSHORT , TYPEBSHORT ,
  TYPEADPCM , TYPEDVIPCM , TYPEMP3 , TYPEULAW ,
  TYPEALAW , TYPEMACE3 , TYPEMACE6 , TYPEOGG ,
  TYPELFLOAT , TYPEBFLOAT , TYPEMASK = 0x3FFF , TYPESTEREO =0x8000 ,
  TYPESHORT =TYPEBSHORT , TYPEFLOAT =TYPEBFLOAT
}
 
typedef void(* CompletionProc) (void *)
 Function prototype for sound event callbacks.
 

Public Member Functions

const Burger::StaticRTTIget_StaticRTTI (void) const noexcept override
 Get the description to the class.
 
 SoundManager (GameApp *pGameApp)
 Constructor.
 
virtual ~SoundManager ()
 Release all resources.
 
uint_t Init (void)
 Initialize a SoundManager.
 
void Shutdown (void)
 Shut down a SoundManager.
 
uint_t Play (Buffer *pInput, Voice **ppCookie=0)
 Play a sound.
 
uint_t Stop (void)
 Stop all sound.
 
uint_t Pause (void)
 Pause sound.
 
uint_t Resume (void)
 Resume sound.
 
void SetMaxVoices (uint_t uMax)
 Set the maximum number of voices to mix.
 
uint_t GetMaxVoices (void) const
 
uint_t GetActiveVoiceCount (void) const
 Return the number of free voices.
 
uint_t IsStereoSupported (void) const
 
uint_t IsVolumeAdjustSupported (void) const
 
void SetVolume (uint_t uVolume)
 Set the master volume.
 
uint_t GetVolume (void) const
 
BufferNewBuffer (void *pWaveFile, uintptr_t uLength)
 Create a new sound buffer.
 
IXAudio2GetXAudio2 (void) const
 
IXAudio2MasteringVoiceGetXAudio2MasteringVoice (void) const
 
IDirectSound8GetDirectSound8 (void) const
 
IDirectSound3DListenerGetDirectSound3DListener (void) const
 
IDirectSoundBufferGetPrimaryDirectSoundBuffer (void) const
 
OpaqueAUGraphGetGraph (void) const
 
ComponentInstanceRecordGetAudioUnit (void) const
 
ComponentInstanceRecordGetMixerUnit (void) const
 
int32_t GetMixerNode (void) const
 
uint32_t GetDeviceID (void) const
 
- Public Member Functions inherited from Burger::Base
const charget_class_name (void) const noexcept
 Get the name of the class.
 
virtual ~Base () noexcept=default
 Destructor.
 

Static Public Member Functions

static SoundManagerNew (GameApp *pGameApp)
 Allocate and initialize a SoundManager.
 
static uint_t GetAudioModes (ClassArray< SoundCardDescription > *pOutput)
 Get a list of available audio modes.
 

Static Public Attributes

static const Burger::StaticRTTI g_StaticRTTI
 The global description of the class.
 
static const int16_t g_DirectSoundVolumes [256]
 
static const uint_t cMaxVoiceCount = 32
 Maximum number of simultaneous tones to mix for output.
 
static const uint_t cMaxVolume = 255
 Maximum volume value.
 
static const uint_t cPanLeft = 0x0000
 Pan left value.
 
static const uint_t cPanCenter = 0x8000U
 Pan center value.
 
static const uint_t cPanRight = 0xFFFFU
 Pan right value.
 
static const uint_t cWAVHeaderSize = 0x2C
 Size in bytes of a WAV file header.
 
static const uint32_t cRIFFASCII = 0x52494646U
 'RIFF'
 
static const uint32_t cAIFFASCII = 0x41494646U
 'AIFF'
 
static const uint32_t cAIFCASCII = 0x41494643U
 'AIFC'
 
static const uint32_t cWAVEASCII = 0x57415645U
 'WAVE'
 
static const uint32_t cFORMASCII = 0x464F524DU
 'FORM'
 
static const uint32_t cDATAASCII = 0x64617461U
 'data'
 
static const uint32_t cMAC6ASCII = 0x4D414336U
 'MAC6'
 
static const uint32_t cMAC3ASCII = 0x4D414333U
 'MAC3'
 
static const uint32_t cOggSASCII = 0x4F676753U
 'OggS'
 
static const uint32_t cCOMMASCII = 0x434F4D4DU
 'COMM'
 
static const uint32_t cSSNDASCII = 0x53534E44U
 'SSND'
 
static const uint32_t calawASCII = 0x616C6177U
 'alaw'
 
static const uint32_t culawASCII = 0x756C6177U
 'ulaw'
 
static const uint32_t cfl32ASCII = 0x666C3332U
 'fl32'
 
- Static Public Attributes inherited from Burger::Base
static const Burger::StaticRTTI g_StaticRTTI
 The global description of the class.
 

Protected Member Functions

VoiceAllocVoice (void)
 Find a free voice channel.
 

Static Protected Member Functions

static unsigned long __stdcall ThreadCallback (void *pThis)
 

Protected Attributes

GameAppm_pGameApp
 Reference to the game application.
 
IXAudio2m_pIXAudio2
 XAudio2 object (Xbox 360, XBone, Windows Store)
 
IXAudio2MasteringVoicem_pIXAudio2MasteringVoice
 XAudio2 mastering voice buffer (Xbox 360, XBone, Windows Store)
 
IDirectSound8m_pDirectSound8Device
 Primary DirectSound Device (Windows Only)
 
IDirectSound3DListenerm_pDirectSound3DListener
 Object for 3D audio origin (Windows Only)
 
IDirectSoundBufferm_pDirectSoundBuffer
 Primary DirectSoundBuffer (Windows Only)
 
voidm_hCallback
 HANDLE of the callback thread (Windows only)
 
unsigned long m_uCallbackID
 ID of the callback thread (Windows only)
 
uint_t m_uBufferAllocationType
 Preferred method of allocating audio memory (Windows Only)
 
voidm_hEvents [cMaxVoiceCount]
 Events for DirectSound completion functions (Windows Only)
 
OpaqueAUGraphm_pGraph
 Main audio rendering graph.
 
ComponentInstanceRecordm_pOutputUnit
 Audio component instance.
 
ComponentInstanceRecordm_pMixerUnit
 Main mixer unit.
 
ComponentInstanceRecordm_pSoundUnits [cMaxVoiceCount]
 Waveform generator unit.
 
int32_t m_iSoundNodes [cMaxVoiceCount]
 Waveform node.
 
int32_t m_iOutputNode
 Audio output node index.
 
int32_t m_iMixerNode
 Mixer node index.
 
uint32_t m_uDeviceID
 Audio device ID.
 
Voice m_ActiveVoices [cMaxVoiceCount]
 Array of active sound buffers being played.
 
uint_t m_uMaxVoices
 Maximum number of voices supported for mixing.
 
uint_t m_uVolume
 Current volume.
 
uint_t m_bStereoAvailable
 TRUE if stereo is supported
 
uint_t m_bMasterVolumeAvailable
 TRUE if a master volume is supported
 
uint_t m_uBufferDepth
 Bits per sample the output DAC supports (8 or 16 bit)
 
uint_t m_uOutputSamplesPerSecond
 Maximum sample rate the mixer supports.
 

Private Member Functions

 SoundManager (const SoundManager &)=delete
 
SoundManageroperator= (const SoundManager &)=delete
 
 SoundManager (SoundManager &&)=delete
 
SoundManageroperator= (SoundManager &&)=delete
 

Detailed Description


This class manages sound output to the application's speakers

All of the underlying code is system specific

Member Typedef Documentation

◆ CompletionProc

typedef void( * Burger::SoundManager::CompletionProc) (void *)

Function prototype for sound event callbacks.

Member Enumeration Documentation

◆ anonymous enum

Enumerator
FLAGDOUBLEBUFFER 

Double buffered.

◆ eCodecCommand

Enumerator
CODECBUFFERSIZE 

Size in byte for codec data.

CODECINIT 

Initialize a sound codec.

CODECSHUTDOWN 

Shut down a sound codec.

CODECDECODE 

Decode sound data.

CODECRESET 

Reset a sound codec.

◆ eDataType

Enumerator
TYPEBYTE 

Unsigned 8 bit data.

TYPECHAR 

Signed 8 bit data.

TYPELSHORT 

Little endian short.

TYPEBSHORT 

Big endian short.

TYPEADPCM 

MS ADPCM compression.

TYPEDVIPCM 

Intel DVI ADPCM compression.

TYPEMP3 

MP3 Audio.

TYPEULAW 

MuLaw.

TYPEALAW 

ALaw.

TYPEMACE3 

Mace 3:1.

TYPEMACE6 

Mace 6:1.

TYPEOGG 

OGG/Vorbis Audio.

TYPELFLOAT 

Little endian float.

TYPEBFLOAT 

Big endian float.

TYPEMASK 
TYPESTEREO 

Stereo sound.

TYPESHORT 

16 bit native endian

TYPEFLOAT 

32 bit native endian

Constructor & Destructor Documentation

◆ SoundManager() [1/3]

Burger::SoundManager::SoundManager ( const SoundManager & )
privatedelete

◆ SoundManager() [2/3]

Burger::SoundManager::SoundManager ( SoundManager && )
privatedelete

◆ SoundManager() [3/3]

Burger::SoundManager::SoundManager ( GameApp * pGameApp)

Constructor.


Initialize the variables to defaults. Follow up with a call to Init().

Parameters
pGameAppPointer to the parent game application
See also
Shutdown()

◆ ~SoundManager()

Burger::SoundManager::~SoundManager ( )
virtual

Release all resources.


Shut down the Sound class by calling Shutdown() to release all of the resources.

See also
Shutdown()

Member Function Documentation

◆ AllocVoice()

Burger::SoundManager::Voice *BURGER_API Burger::SoundManager::AllocVoice ( void )
protected

Find a free voice channel.


Scan the array of voices and locate a free slot

Returns
Pointer to a free slot or NULL if no voices are available

◆ get_StaticRTTI()

const Burger::StaticRTTI * Burger::SoundManager::get_StaticRTTI ( void ) const
overridevirtualnoexcept

Get the description to the class.


This virtual function will pull the pointer to the StaticRTTI instance that has the name of the class. Due to it being virtual, it will be the name of the most derived class.

Returns
Pointer to a global, read only instance of StaticRTTI for the true class

Reimplemented from Burger::Base.

◆ GetActiveVoiceCount()

uint_t BURGER_API Burger::SoundManager::GetActiveVoiceCount ( void ) const

Return the number of free voices.


Returns
Number of unallocated voices
See also
cMaxVoiceCount

◆ GetAudioModes()

uint_t BURGER_API Burger::SoundManager::GetAudioModes ( ClassArray< SoundCardDescription > * pOutput)
static

Get a list of available audio modes.


Parameters
pOutputPointer to array of SoundCardDescription entries
Returns
Zero if no error, non-zero on error

◆ GetAudioUnit()

ComponentInstanceRecord * Burger::SoundManager::GetAudioUnit ( void ) const
inline

◆ GetDeviceID()

uint32_t Burger::SoundManager::GetDeviceID ( void ) const
inline

◆ GetDirectSound3DListener()

IDirectSound3DListener * Burger::SoundManager::GetDirectSound3DListener ( void ) const
inline

◆ GetDirectSound8()

IDirectSound8 * Burger::SoundManager::GetDirectSound8 ( void ) const
inline

◆ GetGraph()

OpaqueAUGraph * Burger::SoundManager::GetGraph ( void ) const
inline

◆ GetMaxVoices()

uint_t Burger::SoundManager::GetMaxVoices ( void ) const
inline

◆ GetMixerNode()

int32_t Burger::SoundManager::GetMixerNode ( void ) const
inline

◆ GetMixerUnit()

ComponentInstanceRecord * Burger::SoundManager::GetMixerUnit ( void ) const
inline

◆ GetPrimaryDirectSoundBuffer()

IDirectSoundBuffer * Burger::SoundManager::GetPrimaryDirectSoundBuffer ( void ) const
inline

◆ GetVolume()

uint_t Burger::SoundManager::GetVolume ( void ) const
inline

◆ GetXAudio2()

IXAudio2 * Burger::SoundManager::GetXAudio2 ( void ) const
inline

◆ GetXAudio2MasteringVoice()

IXAudio2MasteringVoice * Burger::SoundManager::GetXAudio2MasteringVoice ( void ) const
inline

◆ Init()

uint_t BURGER_API Burger::SoundManager::Init ( void )

Initialize a SoundManager.


Returns
Zero if no error, non-zero if an error occurred

◆ IsStereoSupported()

uint_t Burger::SoundManager::IsStereoSupported ( void ) const
inline

◆ IsVolumeAdjustSupported()

uint_t Burger::SoundManager::IsVolumeAdjustSupported ( void ) const
inline

◆ New()

Burger::SoundManager *BURGER_API Burger::SoundManager::New ( GameApp * pGameApp)
static

Allocate and initialize a SoundManager.


Parameters
pGameAppPointer to the parent game application
Returns
A pointer to a default SoundManager class or NULL if out of memory
See also
Delete(const T *)

◆ NewBuffer()

Burger::SoundManager::Buffer *BURGER_API Burger::SoundManager::NewBuffer ( void * pWaveFile,
uintptr_t uLength )

Create a new sound buffer.


◆ operator=() [1/2]

SoundManager & Burger::SoundManager::operator= ( const SoundManager & )
privatedelete

◆ operator=() [2/2]

SoundManager & Burger::SoundManager::operator= ( SoundManager && )
privatedelete

◆ Pause()

uint_t BURGER_API Burger::SoundManager::Pause ( void )

Pause sound.


Returns
Zero if no error, non-zero if an error occurred

◆ Play()

uint_t BURGER_API Burger::SoundManager::Play ( Buffer * pBuffer,
Voice ** ppCookie = 0 )

Play a sound.


Returns
Zero if no error, non-zero if an error occurred

◆ Resume()

uint_t BURGER_API Burger::SoundManager::Resume ( void )

Resume sound.


Returns
Zero if no error, non-zero if an error occurred

◆ SetMaxVoices()

void BURGER_API Burger::SoundManager::SetMaxVoices ( uint_t uMax)

Set the maximum number of voices to mix.


Parameters
uMaxNumber of voices to allow to use
See also
cMaxVoiceCount

◆ SetVolume()

void BURGER_API Burger::SoundManager::SetVolume ( uint_t uVolume)

Set the master volume.


Parameters
uVolumeMaster volume 0-255

◆ Shutdown()

void BURGER_API Burger::SoundManager::Shutdown ( void )

Shut down a SoundManager.


◆ Stop()

uint_t BURGER_API Burger::SoundManager::Stop ( void )

Stop all sound.


Returns
Zero if no error, non-zero if an error occurred

◆ ThreadCallback()

unsigned long __stdcall Burger::SoundManager::ThreadCallback ( void * pThis)
staticprotected

Member Data Documentation

◆ cAIFCASCII

const uint32_t Burger::SoundManager::cAIFCASCII = 0x41494643U
static

'AIFC'

◆ cAIFFASCII

const uint32_t Burger::SoundManager::cAIFFASCII = 0x41494646U
static

'AIFF'

◆ calawASCII

const uint32_t Burger::SoundManager::calawASCII = 0x616C6177U
static

'alaw'

◆ cCOMMASCII

const uint32_t Burger::SoundManager::cCOMMASCII = 0x434F4D4DU
static

'COMM'

◆ cDATAASCII

const uint32_t Burger::SoundManager::cDATAASCII = 0x64617461U
static

'data'

◆ cfl32ASCII

const uint32_t Burger::SoundManager::cfl32ASCII = 0x666C3332U
static

'fl32'

◆ cFORMASCII

const uint32_t Burger::SoundManager::cFORMASCII = 0x464F524DU
static

'FORM'

◆ cMAC3ASCII

const uint32_t Burger::SoundManager::cMAC3ASCII = 0x4D414333U
static

'MAC3'

◆ cMAC6ASCII

const uint32_t Burger::SoundManager::cMAC6ASCII = 0x4D414336U
static

'MAC6'

◆ cMaxVoiceCount

const uint_t Burger::SoundManager::cMaxVoiceCount = 32
static

Maximum number of simultaneous tones to mix for output.

◆ cMaxVolume

const uint_t Burger::SoundManager::cMaxVolume = 255
static

Maximum volume value.

◆ cOggSASCII

const uint32_t Burger::SoundManager::cOggSASCII = 0x4F676753U
static

'OggS'

◆ cPanCenter

const uint_t Burger::SoundManager::cPanCenter = 0x8000U
static

Pan center value.

◆ cPanLeft

const uint_t Burger::SoundManager::cPanLeft = 0x0000
static

Pan left value.

◆ cPanRight

const uint_t Burger::SoundManager::cPanRight = 0xFFFFU
static

Pan right value.

◆ cRIFFASCII

const uint32_t Burger::SoundManager::cRIFFASCII = 0x52494646U
static

'RIFF'

◆ cSSNDASCII

const uint32_t Burger::SoundManager::cSSNDASCII = 0x53534E44U
static

'SSND'

◆ culawASCII

const uint32_t Burger::SoundManager::culawASCII = 0x756C6177U
static

'ulaw'

◆ cWAVEASCII

const uint32_t Burger::SoundManager::cWAVEASCII = 0x57415645U
static

'WAVE'

◆ cWAVHeaderSize

const uint_t Burger::SoundManager::cWAVHeaderSize = 0x2C
static

Size in bytes of a WAV file header.

◆ g_DirectSoundVolumes

const int16_t Burger::SoundManager::g_DirectSoundVolumes
static
Initial value:
= {-10000, -8000, -7000, -6415, -6000, -5678, -5415, -5192, -5000,
-4830, -4678, -4540, -4415, -4299, -4192, -4093, -4000, -3912, -3830, -3752,
-3678, -3607, -3540, -3476, -3415, -3356, -3299, -3245, -3192, -3142, -3093,
-3045, -3000, -2955, -2912, -2870, -2830, -2790, -2752, -2714, -2678, -2642,
-2607, -2573, -2540, -2508, -2476, -2445, -2415, -2385, -2356, -2327, -2299,
-2272, -2245, -2218, -2192, -2167, -2142, -2117, -2093, -2069, -2045, -2022,
-2000, -1977, -1955, -1933, -1912, -1891, -1870, -1850, -1830, -1810, -1790,
-1771, -1752, -1733, -1714, -1696, -1678, -1660, -1642, -1624, -1607, -1590,
-1573, -1557, -1540, -1524, -1508, -1492, -1476, -1460, -1445, -1430, -1415,
-1400, -1385, -1370, -1356, -1341, -1327, -1313, -1299, -1285, -1272, -1258,
-1245, -1231, -1218, -1205, -1192, -1179, -1167, -1154, -1142, -1129, -1117,
-1105, -1093, -1081, -1069, -1057, -1045, -1034, -1022, -1011, -1000, -988,
-977, -966, -955, -944, -933, -923, -912, -901, -891, -881, -870, -860,
-850, -840, -830, -820, -810, -800, -790, -780, -771, -761, -752, -742,
-733, -723, -714, -705, -696, -687, -678, -669, -660, -651, -642, -633,
-624, -616, -607, -599, -590, -582, -573, -565, -557, -548, -540, -532,
-524, -516, -508, -500, -492, -484, -476, -468, -460, -453, -445, -437,
-430, -422, -415, -407, -400, -392, -385, -377, -370, -363, -356, -348,
-341, -334, -327, -320, -313, -306, -299, -292, -285, -278, -272, -265,
-258, -251, -245, -238, -231, -225, -218, -212, -205, -199, -192, -186,
-179, -173, -167, -160, -154, -148, -142, -135, -129, -123, -117, -111,
-105, -99, -93, -87, -81, -75, -69, -63, -57, -51, -45, -39, -34, -28, -22,
-17, -11, 0}

Table used for quick Direct sound volume conversion from 0-255 to Decibels

See also
convert_to_DirectSound_volume(uint_t) of convert_to_DirectSound_volume(float)

◆ g_StaticRTTI

const Burger::StaticRTTI Burger::SoundManager::g_StaticRTTI
static

The global description of the class.


This record contains the name of this class and a reference to the parent


This record contains the name of this class and a reference to the parent

◆ m_ActiveVoices

Voice Burger::SoundManager::m_ActiveVoices[cMaxVoiceCount]
protected

Array of active sound buffers being played.

◆ m_bMasterVolumeAvailable

uint_t Burger::SoundManager::m_bMasterVolumeAvailable
protected

TRUE if a master volume is supported

◆ m_bStereoAvailable

uint_t Burger::SoundManager::m_bStereoAvailable
protected

TRUE if stereo is supported

◆ m_hCallback

void* Burger::SoundManager::m_hCallback
protected

HANDLE of the callback thread (Windows only)

◆ m_hEvents

void* Burger::SoundManager::m_hEvents[cMaxVoiceCount]
protected

Events for DirectSound completion functions (Windows Only)

◆ m_iMixerNode

int32_t Burger::SoundManager::m_iMixerNode
protected

Mixer node index.

◆ m_iOutputNode

int32_t Burger::SoundManager::m_iOutputNode
protected

Audio output node index.

◆ m_iSoundNodes

int32_t Burger::SoundManager::m_iSoundNodes[cMaxVoiceCount]
protected

Waveform node.

◆ m_pDirectSound3DListener

IDirectSound3DListener* Burger::SoundManager::m_pDirectSound3DListener
protected

Object for 3D audio origin (Windows Only)

◆ m_pDirectSound8Device

IDirectSound8* Burger::SoundManager::m_pDirectSound8Device
protected

Primary DirectSound Device (Windows Only)

◆ m_pDirectSoundBuffer

IDirectSoundBuffer* Burger::SoundManager::m_pDirectSoundBuffer
protected

Primary DirectSoundBuffer (Windows Only)

◆ m_pGameApp

GameApp* Burger::SoundManager::m_pGameApp
protected

Reference to the game application.

◆ m_pGraph

OpaqueAUGraph* Burger::SoundManager::m_pGraph
protected

Main audio rendering graph.

◆ m_pIXAudio2

IXAudio2* Burger::SoundManager::m_pIXAudio2
protected

XAudio2 object (Xbox 360, XBone, Windows Store)

◆ m_pIXAudio2MasteringVoice

IXAudio2MasteringVoice* Burger::SoundManager::m_pIXAudio2MasteringVoice
protected

XAudio2 mastering voice buffer (Xbox 360, XBone, Windows Store)

◆ m_pMixerUnit

ComponentInstanceRecord* Burger::SoundManager::m_pMixerUnit
protected

Main mixer unit.

◆ m_pOutputUnit

ComponentInstanceRecord* Burger::SoundManager::m_pOutputUnit
protected

Audio component instance.

◆ m_pSoundUnits

ComponentInstanceRecord* Burger::SoundManager::m_pSoundUnits[cMaxVoiceCount]
protected

Waveform generator unit.

◆ m_uBufferAllocationType

uint_t Burger::SoundManager::m_uBufferAllocationType
protected

Preferred method of allocating audio memory (Windows Only)

◆ m_uBufferDepth

uint_t Burger::SoundManager::m_uBufferDepth
protected

Bits per sample the output DAC supports (8 or 16 bit)

◆ m_uCallbackID

unsigned long Burger::SoundManager::m_uCallbackID
protected

ID of the callback thread (Windows only)

◆ m_uDeviceID

uint32_t Burger::SoundManager::m_uDeviceID
protected

Audio device ID.

◆ m_uMaxVoices

uint_t Burger::SoundManager::m_uMaxVoices
protected

Maximum number of voices supported for mixing.

◆ m_uOutputSamplesPerSecond

uint_t Burger::SoundManager::m_uOutputSamplesPerSecond
protected

Maximum sample rate the mixer supports.

◆ m_uVolume

uint_t Burger::SoundManager::m_uVolume
protected

Current volume.