DDraceNetwork Docs
CSound Class Reference

#include <sound.h>

Inheritance diagram for CSound:
[legend]
Collaboration diagram for CSound:
[legend]

Public Member Functions

int Init () override
 
int Update () override
 
void Shutdown () override REQUIRES(!m_SoundLock)
 
bool IsSoundEnabled () override
 
int LoadOpus (const char *pFilename, int StorageType=IStorage::TYPE_ALL) override REQUIRES(!m_SoundLock)
 
int LoadWV (const char *pFilename, int StorageType=IStorage::TYPE_ALL) override REQUIRES(!m_SoundLock)
 
int LoadOpusFromMem (const void *pData, unsigned DataSize, bool FromEditor) override REQUIRES(!m_SoundLock)
 
int LoadWVFromMem (const void *pData, unsigned DataSize, bool FromEditor) override REQUIRES(!m_SoundLock)
 
void UnloadSample (int SampleId) override REQUIRES(!m_SoundLock)
 
float GetSampleTotalTime (int SampleId) override
 
float GetSampleCurrentTime (int SampleId) override REQUIRES(!m_SoundLock)
 
void SetSampleCurrentTime (int SampleId, float Time) override REQUIRES(!m_SoundLock)
 
void SetChannel (int ChannelId, float Vol, float Pan) override
 
void SetListenerPosition (vec2 Position) override
 
void SetVoiceVolume (CVoiceHandle Voice, float Volume) override REQUIRES(!m_SoundLock)
 
void SetVoiceFalloff (CVoiceHandle Voice, float Falloff) override REQUIRES(!m_SoundLock)
 
void SetVoicePosition (CVoiceHandle Voice, vec2 Position) override REQUIRES(!m_SoundLock)
 
void SetVoiceTimeOffset (CVoiceHandle Voice, float TimeOffset) override REQUIRES(!m_SoundLock)
 
void SetVoiceCircle (CVoiceHandle Voice, float Radius) override REQUIRES(!m_SoundLock)
 
void SetVoiceRectangle (CVoiceHandle Voice, float Width, float Height) override REQUIRES(!m_SoundLock)
 
CVoiceHandle Play (int ChannelId, int SampleId, int Flags, float Volume, vec2 Position) REQUIRES(!m_SoundLock)
 
CVoiceHandle PlayAt (int ChannelId, int SampleId, int Flags, float Volume, vec2 Position) override REQUIRES(!m_SoundLock)
 
CVoiceHandle Play (int ChannelId, int SampleId, int Flags, float Volume) override REQUIRES(!m_SoundLock)
 
void Pause (int SampleId) override REQUIRES(!m_SoundLock)
 
void Stop (int SampleId) override REQUIRES(!m_SoundLock)
 
void StopAll () override REQUIRES(!m_SoundLock)
 
void StopVoice (CVoiceHandle Voice) override REQUIRES(!m_SoundLock)
 
bool IsPlaying (int SampleId) override REQUIRES(!m_SoundLock)
 
int MixingRate () const override
 
void Mix (short *pFinalOut, unsigned Frames) override REQUIRES(!m_SoundLock)
 
void PauseAudioDevice () override
 
void UnpauseAudioDevice () override
 
virtual int Init ()=0
 
virtual int Update ()=0
 
virtual void Shutdown () override=0
 
virtual bool IsSoundEnabled ()=0
 
virtual int LoadOpus (const char *pFilename, int StorageType=IStorage::TYPE_ALL)=0
 
virtual int LoadWV (const char *pFilename, int StorageType=IStorage::TYPE_ALL)=0
 
virtual int LoadOpusFromMem (const void *pData, unsigned DataSize, bool FromEditor=false)=0
 
virtual int LoadWVFromMem (const void *pData, unsigned DataSize, bool FromEditor=false)=0
 
virtual void UnloadSample (int SampleId)=0
 
virtual float GetSampleTotalTime (int SampleId)=0
 
virtual float GetSampleCurrentTime (int SampleId)=0
 
virtual void SetSampleCurrentTime (int SampleId, float Time)=0
 
virtual void SetChannel (int ChannelId, float Volume, float Panning)=0
 
virtual void SetListenerPosition (vec2 Position)=0
 
virtual void SetVoiceVolume (CVoiceHandle Voice, float Volume)=0
 
virtual void SetVoiceFalloff (CVoiceHandle Voice, float Falloff)=0
 
virtual void SetVoicePosition (CVoiceHandle Voice, vec2 Position)=0
 
virtual void SetVoiceTimeOffset (CVoiceHandle Voice, float TimeOffset)=0
 
virtual void SetVoiceCircle (CVoiceHandle Voice, float Radius)=0
 
virtual void SetVoiceRectangle (CVoiceHandle Voice, float Width, float Height)=0
 
virtual CVoiceHandle PlayAt (int ChannelId, int SampleId, int Flags, float Volume, vec2 Position)=0
 
virtual CVoiceHandle Play (int ChannelId, int SampleId, int Flags, float Volume)=0
 
virtual void Pause (int SampleId)=0
 
virtual void Stop (int SampleId)=0
 
virtual void StopAll ()=0
 
virtual void StopVoice (CVoiceHandle Voice)=0
 
virtual bool IsPlaying (int SampleId)=0
 
virtual int MixingRate () const =0
 
virtual void Mix (short *pFinalOut, unsigned Frames)=0
 
virtual void PauseAudioDevice ()=0
 
virtual void UnpauseAudioDevice ()=0
 
- Public Member Functions inherited from IInterface
 IInterface ()
 
virtual void Shutdown ()
 
virtual ~IInterface ()
 

Private Types

enum  { NUM_SAMPLES = 512 , NUM_VOICES = 256 , NUM_CHANNELS = 16 }
 

Private Member Functions

CSampleAllocSample ()
 
void RateConvert (CSample &Sample) const
 
bool DecodeOpus (CSample &Sample, const void *pData, unsigned DataSize) const
 
bool DecodeWV (CSample &Sample, const void *pData, unsigned DataSize) const
 
void UpdateVolume ()
 

Private Attributes

bool m_SoundEnabled = false
 
SDL_AudioDeviceID m_Device = 0
 
CLock m_SoundLock
 
CSample m_aSamples [NUM_SAMPLES] = {{0}}
 
int m_FirstFreeSampleIndex = 0
 
CVoice m_aVoices [NUM_VOICES] = {{0}}
 
CChannel m_aChannels [NUM_CHANNELS] = {{255, 0}}
 
int m_NextVoice = 0
 
uint32_t m_MaxFrames = 0
 
std::atomic< float > m_ListenerPositionX = 0.0f
 
std::atomic< float > m_ListenerPositionY = 0.0f
 
std::atomic< int > m_SoundVolume = 100
 
int m_MixingRate = 48000
 
class IEngineGraphicsm_pGraphics = nullptr
 
IStoragem_pStorage = nullptr
 
int * m_pMixBuffer = nullptr
 

Additional Inherited Members

- Public Types inherited from ISound
enum  {
  FLAG_LOOP = 1 << 0 , FLAG_POS = 1 << 1 , FLAG_NO_PANNING = 1 << 2 , FLAG_PREVIEW = 1 << 3 ,
  FLAG_ALL = FLAG_LOOP | FLAG_POS | FLAG_NO_PANNING | FLAG_PREVIEW
}
 
enum  { SHAPE_CIRCLE , SHAPE_RECTANGLE }
 
- Protected Member Functions inherited from ISound
CVoiceHandle CreateVoiceHandle (int Index, int Age)
 
- Protected Member Functions inherited from IInterface
IKernelKernel ()
 

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
NUM_SAMPLES 
NUM_VOICES 
NUM_CHANNELS 

Member Function Documentation

◆ AllocSample()

CSample * CSound::AllocSample ( )
private

◆ DecodeOpus()

bool CSound::DecodeOpus ( CSample Sample,
const void *  pData,
unsigned  DataSize 
) const
private

◆ DecodeWV()

bool CSound::DecodeWV ( CSample Sample,
const void *  pData,
unsigned  DataSize 
) const
private

◆ GetSampleCurrentTime()

float CSound::GetSampleCurrentTime ( int  SampleId)
overridevirtual

Implements ISound.

◆ GetSampleTotalTime()

float CSound::GetSampleTotalTime ( int  SampleId)
overridevirtual

Implements ISound.

◆ Init()

int CSound::Init ( )
overridevirtual

Implements IEngineSound.

◆ IsPlaying()

bool CSound::IsPlaying ( int  SampleId)
overridevirtual

Implements ISound.

◆ IsSoundEnabled()

bool CSound::IsSoundEnabled ( )
inlineoverridevirtual

Implements ISound.

◆ LoadOpus()

int CSound::LoadOpus ( const char *  pFilename,
int  StorageType = IStorage::TYPE_ALL 
)
overridevirtual

Implements ISound.

◆ LoadOpusFromMem()

int CSound::LoadOpusFromMem ( const void *  pData,
unsigned  DataSize,
bool  FromEditor = false 
)
overridevirtual

Implements ISound.

◆ LoadWV()

int CSound::LoadWV ( const char *  pFilename,
int  StorageType = IStorage::TYPE_ALL 
)
overridevirtual

Implements ISound.

◆ LoadWVFromMem()

int CSound::LoadWVFromMem ( const void *  pData,
unsigned  DataSize,
bool  FromEditor = false 
)
overridevirtual

Implements ISound.

◆ Mix()

void CSound::Mix ( short *  pFinalOut,
unsigned  Frames 
)
overridevirtual

Implements ISound.

◆ MixingRate()

int CSound::MixingRate ( ) const
inlineoverridevirtual

Implements ISound.

◆ Pause()

void CSound::Pause ( int  SampleId)
overridevirtual

Implements ISound.

◆ PauseAudioDevice()

void CSound::PauseAudioDevice ( )
overridevirtual

Implements ISound.

◆ Play() [1/2]

ISound::CVoiceHandle CSound::Play ( int  ChannelId,
int  SampleId,
int  Flags,
float  Volume 
)
overridevirtual

Implements ISound.

◆ Play() [2/2]

ISound::CVoiceHandle CSound::Play ( int  ChannelId,
int  SampleId,
int  Flags,
float  Volume,
vec2  Position 
)

◆ PlayAt()

ISound::CVoiceHandle CSound::PlayAt ( int  ChannelId,
int  SampleId,
int  Flags,
float  Volume,
vec2  Position 
)
overridevirtual

Implements ISound.

◆ RateConvert()

void CSound::RateConvert ( CSample Sample) const
private

◆ SetChannel()

void CSound::SetChannel ( int  ChannelId,
float  Vol,
float  Pan 
)
overridevirtual

Implements ISound.

◆ SetListenerPosition()

void CSound::SetListenerPosition ( vec2  Position)
overridevirtual

Implements ISound.

◆ SetSampleCurrentTime()

void CSound::SetSampleCurrentTime ( int  SampleId,
float  Time 
)
overridevirtual

Implements ISound.

◆ SetVoiceCircle()

void CSound::SetVoiceCircle ( CVoiceHandle  Voice,
float  Radius 
)
overridevirtual

Implements ISound.

◆ SetVoiceFalloff()

void CSound::SetVoiceFalloff ( CVoiceHandle  Voice,
float  Falloff 
)
overridevirtual

Implements ISound.

◆ SetVoicePosition()

void CSound::SetVoicePosition ( CVoiceHandle  Voice,
vec2  Position 
)
overridevirtual

Implements ISound.

◆ SetVoiceRectangle()

void CSound::SetVoiceRectangle ( CVoiceHandle  Voice,
float  Width,
float  Height 
)
overridevirtual

Implements ISound.

◆ SetVoiceTimeOffset()

void CSound::SetVoiceTimeOffset ( CVoiceHandle  Voice,
float  TimeOffset 
)
overridevirtual

Implements ISound.

◆ SetVoiceVolume()

void CSound::SetVoiceVolume ( CVoiceHandle  Voice,
float  Volume 
)
overridevirtual

Implements ISound.

◆ Shutdown()

void CSound::Shutdown ( )
overridevirtual

Implements IEngineSound.

◆ Stop()

void CSound::Stop ( int  SampleId)
overridevirtual

Implements ISound.

◆ StopAll()

void CSound::StopAll ( )
overridevirtual

Implements ISound.

◆ StopVoice()

void CSound::StopVoice ( CVoiceHandle  Voice)
overridevirtual

Implements ISound.

◆ UnloadSample()

void CSound::UnloadSample ( int  SampleId)
overridevirtual

Implements ISound.

◆ UnpauseAudioDevice()

void CSound::UnpauseAudioDevice ( )
overridevirtual

Implements ISound.

◆ Update()

int CSound::Update ( )
overridevirtual

Implements IEngineSound.

◆ UpdateVolume()

void CSound::UpdateVolume ( )
private

Member Data Documentation

◆ m_aChannels

CChannel CSound::m_aChannels[NUM_CHANNELS] = {{255, 0}}
private

◆ m_aSamples

CSample CSound::m_aSamples[NUM_SAMPLES] = {{0}}
private

◆ m_aVoices

CVoice CSound::m_aVoices[NUM_VOICES] = {{0}}
private

◆ m_Device

SDL_AudioDeviceID CSound::m_Device = 0
private

◆ m_FirstFreeSampleIndex

int CSound::m_FirstFreeSampleIndex = 0
private

◆ m_ListenerPositionX

std::atomic<float> CSound::m_ListenerPositionX = 0.0f
private

◆ m_ListenerPositionY

std::atomic<float> CSound::m_ListenerPositionY = 0.0f
private

◆ m_MaxFrames

uint32_t CSound::m_MaxFrames = 0
private

◆ m_MixingRate

int CSound::m_MixingRate = 48000
private

◆ m_NextVoice

int CSound::m_NextVoice = 0
private

◆ m_pGraphics

class IEngineGraphics* CSound::m_pGraphics = nullptr
private

◆ m_pMixBuffer

int* CSound::m_pMixBuffer = nullptr
private

◆ m_pStorage

IStorage* CSound::m_pStorage = nullptr
private

◆ m_SoundEnabled

bool CSound::m_SoundEnabled = false
private

◆ m_SoundLock

CLock CSound::m_SoundLock
private

◆ m_SoundVolume

std::atomic<int> CSound::m_SoundVolume = 100
private

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