OpenClonk
C4SoundModifierEqualizer Class Reference

#include <C4SoundModifiers.h>

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

Public Types

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

Public Member Functions

 C4SoundModifierEqualizer (C4PropList *in_props)
 
void Update () override
 
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 102 of file C4SoundModifiers.h.

Member Enumeration Documentation

◆ Type

enum C4SoundModifier::Type
inherited
Enumerator
C4SMT_None 
C4SMT_Reverb 
C4SMT_Echo 
C4SMT_Equalizer 
C4SMT_Max 

Definition at line 29 of file C4SoundModifiers.h.

30  {
31  C4SMT_None = 0x0,
32  C4SMT_Reverb = 0x1,
33  C4SMT_Echo = 0x4,
34  C4SMT_Equalizer = 0xc,
35  C4SMT_Max = 0xc // value of largest type
36  };

Constructor & Destructor Documentation

◆ C4SoundModifierEqualizer()

C4SoundModifierEqualizer::C4SoundModifierEqualizer ( C4PropList in_props)

Definition at line 168 of file C4SoundModifiers.cpp.

169  : C4SoundModifier(in_props)
170 {
171 #if (AUDIO_TK == AUDIO_TK_OPENAL) && defined(HAVE_ALEXT)
172  alEffecti(effect, AL_EFFECT_TYPE, AL_EFFECT_EQUALIZER);
173 #endif
174 }
C4SoundModifier(C4PropList *in_props)

References C4SoundModifier::effect.

Member Function Documentation

◆ AddRef()

void C4SoundModifier::AddRef ( )
inlineinherited

Definition at line 69 of file C4SoundModifiers.h.

69 { ++instance_count; }

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

Here is the caller graph for this function:

◆ ApplyTo()

void C4SoundModifier::ApplyTo ( ALuint  source)
inherited

Definition at line 93 of file C4SoundModifiers.cpp.

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 }

References C4SoundModifier::slot.

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

Here is the caller graph for this function:

◆ DelRef()

void C4SoundModifier::DelRef ( )
inlineinherited

Definition at line 70 of file C4SoundModifiers.h.

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

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

Here is the caller graph for this function:

◆ GetBoolProp()

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

Definition at line 109 of file C4SoundModifiers.cpp.

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:855
C4PropList * _getPropList() const
Definition: C4Value.h:129

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

Referenced by C4SoundModifierReverb::Update().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetFloatProp()

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

Definition at line 102 of file C4SoundModifiers.cpp.

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 }

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

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetProps()

const C4PropList* C4SoundModifier::GetProps ( ) const
inlineinherited

Definition at line 73 of file C4SoundModifiers.h.

73 { return props._getPropList(); }

References C4Value::_getPropList().

Here is the call graph for this function:

◆ GetRefCount()

int32_t C4SoundModifier::GetRefCount ( ) const
inlineinherited

Definition at line 71 of file C4SoundModifiers.h.

71 { return instance_count; }

Referenced by C4SoundModifierList::Clear().

Here is the caller graph for this function:

◆ Release()

void C4SoundModifier::Release ( )
inlineinherited

Definition at line 66 of file C4SoundModifiers.h.

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

References C4Value::Set0().

Referenced by C4SoundModifierList::Clear().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Update()

void C4SoundModifierEqualizer::Update ( )
overridevirtual

Reimplemented from C4SoundModifier.

Definition at line 176 of file C4SoundModifiers.cpp.

177 {
178 #if (AUDIO_TK == AUDIO_TK_OPENAL) && defined(HAVE_ALEXT)
179  // use default OpenAL equalizer preset
181  alEffectf(effect, AL_EQUALIZER_LOW_GAIN, GetFloatProp(P_Equalizer_Low_Gain, 1000, 1.0f));
182  alEffectf(effect, AL_EQUALIZER_LOW_CUTOFF, GetFloatProp(P_Equalizer_Low_Cutoff, 1000, 200.0f));
183  alEffectf(effect, AL_EQUALIZER_MID1_GAIN, GetFloatProp(P_Equalizer_Mid1_Gain, 1000, 1.0f));
184  alEffectf(effect, AL_EQUALIZER_MID1_CENTER, GetFloatProp(P_Equalizer_Mid1_Center, 1000, 500.0f));
185  alEffectf(effect, AL_EQUALIZER_MID1_WIDTH, GetFloatProp(P_Equalizer_Mid1_Width, 1000, 1.0f));
186  alEffectf(effect, AL_EQUALIZER_MID2_GAIN, GetFloatProp(P_Equalizer_Mid2_Gain, 1000, 1.0f));
187  alEffectf(effect, AL_EQUALIZER_MID2_CENTER, GetFloatProp(P_Equalizer_Mid2_Center, 1000, 3000.0f));
188  alEffectf(effect, AL_EQUALIZER_MID2_WIDTH, GetFloatProp(P_Equalizer_Mid2_Width, 1000, 1.0f));
189  alEffectf(effect, AL_EQUALIZER_HIGH_GAIN, GetFloatProp(P_Equalizer_High_Gain, 1000, 1.0f));
190  alEffectf(effect, AL_EQUALIZER_HIGH_CUTOFF, GetFloatProp(P_Equalizer_High_Cutoff, 1000, 6000.0f));
191 #endif
193 }
C4Application Application
Definition: C4Globals.cpp:44
@ P_Equalizer_Low_Gain
@ P_Equalizer_Mid1_Gain
@ P_Equalizer_Mid2_Center
@ P_Equalizer_Mid2_Width
@ P_Equalizer_High_Gain
@ P_Equalizer_Mid1_Center
@ P_Equalizer_Mid2_Gain
@ P_Equalizer_Mid1_Width
@ P_Equalizer_Low_Cutoff
@ P_Equalizer_High_Cutoff
C4MusicSystem MusicSystem
Definition: C4Application.h:41
void SelectContext()
float GetFloatProp(C4PropertyName key, float ratio, float default_value)
virtual void Update()

References Application, C4SoundModifier::effect, C4SoundModifier::GetFloatProp(), C4Application::MusicSystem, P_Equalizer_High_Cutoff, P_Equalizer_High_Gain, P_Equalizer_Low_Cutoff, P_Equalizer_Low_Gain, P_Equalizer_Mid1_Center, P_Equalizer_Mid1_Gain, P_Equalizer_Mid1_Width, P_Equalizer_Mid2_Center, P_Equalizer_Mid2_Gain, P_Equalizer_Mid2_Width, C4MusicSystem::SelectContext(), and C4SoundModifier::Update().

Here is the call graph for this function:

Member Data Documentation

◆ effect

◆ slot

ALuint C4SoundModifier::slot
protectedinherited

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