OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4SoundModifier Class Reference

#include <C4SoundModifiers.h>

Inheritance diagram for C4SoundModifier:
[legend]

Public Types

enum  Type {
  C4SMT_None = 0x0, C4SMT_Reverb = 0x1, C4SMT_Echo = 0x4, C4SMT_Equalizer = 0xc,
  C4SMT_Max = 0xc
}
 

Public Member Functions

 C4SoundModifier (C4PropList *in_props)
 
virtual ~C4SoundModifier ()
 
virtual void Update ()
 
void Release ()
 
void AddRef ()
 
void DelRef ()
 
int32_t GetRefCount () const
 
const C4PropListGetProps () const
 
void ApplyTo (ALuint source)
 

Protected Member Functions

float GetFloatProp (C4PropertyName key, float ratio, float default_value)
 
bool GetBoolProp (C4PropertyName key, bool default_value)
 

Protected Attributes

ALuint effect
 
ALuint slot
 

Detailed Description

Definition at line 26 of file C4SoundModifiers.h.

Member Enumeration Documentation

Enumerator
C4SMT_None 
C4SMT_Reverb 
C4SMT_Echo 
C4SMT_Equalizer 
C4SMT_Max 

Definition at line 29 of file C4SoundModifiers.h.

Constructor & Destructor Documentation

C4SoundModifier::C4SoundModifier ( C4PropList in_props)

Definition at line 53 of file C4SoundModifiers.cpp.

References C4SoundModifierList::Add(), Application, effect, C4SoundSystem::Modifiers, C4Application::MusicSystem, C4MusicSystem::SelectContext(), C4Value::SetPropList(), slot, and C4Application::SoundSystem.

53  : instance_count(0)
54 #if (AUDIO_TK == AUDIO_TK_OPENAL) && defined(HAVE_ALEXT)
55  , effect(0u), slot(0u)
56 #endif
57 {
58  props.SetPropList(in_props);
60 #if (AUDIO_TK == AUDIO_TK_OPENAL) && defined(HAVE_ALEXT)
62  alGenEffects(1, &effect);
63  alGenAuxiliaryEffectSlots(1, &slot);
64 #endif
65 }
C4SoundSystem SoundSystem
Definition: C4Application.h:42
void SelectContext()
C4SoundModifierList Modifiers
Definition: C4SoundSystem.h:54
void Add(C4SoundModifier *new_modifier)
void SetPropList(C4PropList *PropList)
Definition: C4Value.h:141
C4Application Application
Definition: C4Globals.cpp:44
C4MusicSystem MusicSystem
Definition: C4Application.h:41

Here is the call graph for this function:

C4SoundModifier::~C4SoundModifier ( )
virtual

Definition at line 67 of file C4SoundModifiers.cpp.

References Application, effect, C4SoundSystem::Modifiers, C4SoundModifierList::Remove(), slot, and C4Application::SoundSystem.

68 {
69 #if (AUDIO_TK == AUDIO_TK_OPENAL) && defined(HAVE_ALEXT)
70  // failsafe effect removal
71  if (alIsEffect(effect))
72  alDeleteEffects(1, &effect);
73  if (alIsAuxiliaryEffectSlot(slot))
74  alDeleteAuxiliaryEffectSlots(1, &slot);
75 #endif
77 }
C4SoundSystem SoundSystem
Definition: C4Application.h:42
C4SoundModifierList Modifiers
Definition: C4SoundSystem.h:54
void Remove(C4SoundModifier *prev_modifier)
C4Application Application
Definition: C4Globals.cpp:44

Here is the call graph for this function:

Member Function Documentation

void C4SoundModifier::AddRef ( )
inline

Definition at line 69 of file C4SoundModifiers.h.

Referenced by C4SoundInstance::Create(), C4SoundModifierList::SetGlobalModifier(), and C4SoundInstance::SetModifier().

69 { ++instance_count; }

Here is the caller graph for this function:

void C4SoundModifier::ApplyTo ( ALuint  source)

Definition at line 93 of file C4SoundModifiers.cpp.

References slot.

Referenced by C4SoundInstance::SetModifier(), and C4SoundInstance::Start().

94 {
95  // apply slot to source if valid
96 #if defined(HAVE_ALEXT)
97  if (slot) alSource3i(source, AL_AUXILIARY_SEND_FILTER, slot, 0, AL_FILTER_NULL);
98 #endif
99 }

Here is the caller graph for this function:

void C4SoundModifier::DelRef ( )
inline

Definition at line 70 of file C4SoundModifiers.h.

Referenced by C4SoundInstance::Clear(), C4SoundModifierList::SetGlobalModifier(), and C4SoundInstance::SetModifier().

70 { if (!--instance_count && released) delete this; }

Here is the caller graph for this function:

bool C4SoundModifier::GetBoolProp ( C4PropertyName  key,
bool  default_value 
)
protected

Definition at line 109 of file C4SoundModifiers.cpp.

References C4Value::_getPropList(), and C4PropList::GetPropertyInt().

Referenced by C4SoundModifierReverb::Update().

110 {
111  // get scaled property and fill in default value
112  C4PropList *p = props._getPropList();
113  return (p->GetPropertyInt(key, int32_t(default_value ? 1 : 0)) != 0);
114 }
int32_t GetPropertyInt(C4PropertyName k, int32_t default_val=0) const
Definition: C4PropList.cpp:882
C4PropList * _getPropList() const
Definition: C4Value.h:129

Here is the call graph for this function:

Here is the caller graph for this function:

float C4SoundModifier::GetFloatProp ( C4PropertyName  key,
float  ratio,
float  default_value 
)
protected

Definition at line 102 of file C4SoundModifiers.cpp.

References C4Value::_getPropList(), and C4PropList::GetPropertyInt().

Referenced by C4SoundModifierReverb::Update(), C4SoundModifierEcho::Update(), and C4SoundModifierEqualizer::Update().

103 {
104  // get scaled property and fill in default value
105  C4PropList *p = props._getPropList();
106  return float(p->GetPropertyInt(key, int32_t(default_value * ratio))) / ratio;
107 }
int32_t GetPropertyInt(C4PropertyName k, int32_t default_val=0) const
Definition: C4PropList.cpp:882
C4PropList * _getPropList() const
Definition: C4Value.h:129

Here is the call graph for this function:

Here is the caller graph for this function:

const C4PropList* C4SoundModifier::GetProps ( ) const
inline

Definition at line 73 of file C4SoundModifiers.h.

References C4Value::_getPropList().

73 { return props._getPropList(); }
C4PropList * _getPropList() const
Definition: C4Value.h:129

Here is the call graph for this function:

int32_t C4SoundModifier::GetRefCount ( ) const
inline

Definition at line 71 of file C4SoundModifiers.h.

Referenced by C4SoundModifierList::Clear().

71 { return instance_count; }

Here is the caller graph for this function:

void C4SoundModifier::Release ( )
inline

Definition at line 66 of file C4SoundModifiers.h.

References C4Value::Set0().

Referenced by C4SoundModifierList::Clear().

66  {
67  if (!instance_count) delete this; else { released = true; props.Set0(); }
68  }
void Set0()
Definition: C4Value.h:336

Here is the call graph for this function:

Here is the caller graph for this function:

void C4SoundModifier::Update ( )
virtual

Reimplemented in C4SoundModifierEqualizer, C4SoundModifierEcho, and C4SoundModifierReverb.

Definition at line 79 of file C4SoundModifiers.cpp.

References effect, and slot.

Referenced by C4SoundModifierList::Get(), C4SoundModifierReverb::Update(), C4SoundModifierEcho::Update(), and C4SoundModifierEqualizer::Update().

80 {
81 #if (AUDIO_TK == AUDIO_TK_OPENAL) && defined(HAVE_ALEXT)
82  // update AL effect slot
83  if (slot)
84  {
85  alAuxiliaryEffectSloti(slot, AL_EFFECTSLOT_EFFECT, effect);
86  }
87 #endif
88  // update from props and mark as not released
89  released = false;
90 }

Here is the caller graph for this function:

Member Data Documentation

ALuint C4SoundModifier::slot
protected

Definition at line 53 of file C4SoundModifiers.h.

Referenced by ApplyTo(), C4SoundModifier(), Update(), and ~C4SoundModifier().


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