DDraceNetwork Documentation
Loading...
Searching...
No Matches
CSound Class Referenceabstract

#include <sound.h>

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

Public Member Functions

int Init () override REQUIRES(!m_SoundLock)
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 ForceLoad, const char *pContextName) override REQUIRES(!m_SoundLock)
int LoadWVFromMem (const void *pData, unsigned DataSize, bool ForceLoad, const char *pContextName) override REQUIRES(!m_SoundLock)
void UnloadSample (int SampleId) override REQUIRES(!m_SoundLock)
float GetSampleTotalTime (int SampleId) override REQUIRES(!m_SoundLock)
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 REQUIRES(!m_SoundLock)
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
Public Member Functions inherited from IInterface
 IInterface ()
virtual ~IInterface ()=default

Private Types

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

Private Member Functions

CSample m_aSamples[NUM_SAMPLESGUARDED_BY (m_SoundLock)
int m_FirstFreeSampleIndex GUARDED_BY (m_SoundLock)=0
CVoice m_aVoices[NUM_VOICESGUARDED_BY (m_SoundLock)
CChannel m_aChannels[NUM_CHANNELSGUARDED_BY (m_SoundLock)
int m_NextVoice GUARDED_BY (m_SoundLock)=0
CSampleAllocSample () REQUIRES(!m_SoundLock)
void RateConvert (CSample &Sample) const
bool DecodeOpus (CSample &Sample, const void *pData, unsigned DataSize, const char *pContextName) const
bool DecodeWV (CSample &Sample, const void *pData, unsigned DataSize, const char *pContextName) const
void UpdateVolume ()

Private Attributes

bool m_SoundEnabled = false
SDL_AudioDeviceID m_Device = 0
CLock m_SoundLock
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 char * pContextName ) const
private

◆ DecodeWV()

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

◆ GetSampleCurrentTime()

float CSound::GetSampleCurrentTime ( int SampleId)
overridevirtual

Implements ISound.

◆ GetSampleTotalTime()

float CSound::GetSampleTotalTime ( int SampleId)
overridevirtual

Implements ISound.

◆ GUARDED_BY() [1/5]

CChannel m_aChannels[NUM_CHANNELS] CSound::GUARDED_BY ( m_SoundLock )
private

◆ GUARDED_BY() [2/5]

CVoice m_aVoices[NUM_VOICES] CSound::GUARDED_BY ( m_SoundLock )
private

◆ GUARDED_BY() [3/5]

CSample m_aSamples[NUM_SAMPLES] CSound::GUARDED_BY ( m_SoundLock )
private

◆ GUARDED_BY() [4/5]

int m_NextVoice CSound::GUARDED_BY ( m_SoundLock )
privatepure virtual

◆ GUARDED_BY() [5/5]

int m_FirstFreeSampleIndex CSound::GUARDED_BY ( m_SoundLock )
privatepure virtual

◆ 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 ForceLoad,
const char * pContextName )
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 ForceLoad,
const char * pContextName )
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_Device

SDL_AudioDeviceID CSound::m_Device = 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_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: