Don't inline the utf8 converters
[openal-soft.git] / alc / effects / base.h
blob6889308d4e5f6b7160a37dbd119c2dcfd6a5e309
1 #ifndef EFFECTS_BASE_H
2 #define EFFECTS_BASE_H
4 #include <cstddef>
6 #include "alcmain.h"
7 #include "almalloc.h"
8 #include "alspan.h"
9 #include "atomic.h"
10 #include "intrusive_ptr.h"
12 struct ALeffectslot;
15 union EffectProps {
16 struct {
17 // Shared Reverb Properties
18 ALfloat Density;
19 ALfloat Diffusion;
20 ALfloat Gain;
21 ALfloat GainHF;
22 ALfloat DecayTime;
23 ALfloat DecayHFRatio;
24 ALfloat ReflectionsGain;
25 ALfloat ReflectionsDelay;
26 ALfloat LateReverbGain;
27 ALfloat LateReverbDelay;
28 ALfloat AirAbsorptionGainHF;
29 ALfloat RoomRolloffFactor;
30 bool DecayHFLimit;
32 // Additional EAX Reverb Properties
33 ALfloat GainLF;
34 ALfloat DecayLFRatio;
35 ALfloat ReflectionsPan[3];
36 ALfloat LateReverbPan[3];
37 ALfloat EchoTime;
38 ALfloat EchoDepth;
39 ALfloat ModulationTime;
40 ALfloat ModulationDepth;
41 ALfloat HFReference;
42 ALfloat LFReference;
43 } Reverb;
45 struct {
46 ALfloat AttackTime;
47 ALfloat ReleaseTime;
48 ALfloat Resonance;
49 ALfloat PeakGain;
50 } Autowah;
52 struct {
53 ALint Waveform;
54 ALint Phase;
55 ALfloat Rate;
56 ALfloat Depth;
57 ALfloat Feedback;
58 ALfloat Delay;
59 } Chorus; /* Also Flanger */
61 struct {
62 bool OnOff;
63 } Compressor;
65 struct {
66 ALfloat Edge;
67 ALfloat Gain;
68 ALfloat LowpassCutoff;
69 ALfloat EQCenter;
70 ALfloat EQBandwidth;
71 } Distortion;
73 struct {
74 ALfloat Delay;
75 ALfloat LRDelay;
77 ALfloat Damping;
78 ALfloat Feedback;
80 ALfloat Spread;
81 } Echo;
83 struct {
84 ALfloat LowCutoff;
85 ALfloat LowGain;
86 ALfloat Mid1Center;
87 ALfloat Mid1Gain;
88 ALfloat Mid1Width;
89 ALfloat Mid2Center;
90 ALfloat Mid2Gain;
91 ALfloat Mid2Width;
92 ALfloat HighCutoff;
93 ALfloat HighGain;
94 } Equalizer;
96 struct {
97 ALfloat Frequency;
98 ALint LeftDirection;
99 ALint RightDirection;
100 } Fshifter;
102 struct {
103 ALfloat Frequency;
104 ALfloat HighPassCutoff;
105 ALint Waveform;
106 } Modulator;
108 struct {
109 ALint CoarseTune;
110 ALint FineTune;
111 } Pshifter;
113 struct {
114 ALfloat Rate;
115 ALint PhonemeA;
116 ALint PhonemeB;
117 ALint PhonemeACoarseTuning;
118 ALint PhonemeBCoarseTuning;
119 ALint Waveform;
120 } Vmorpher;
122 struct {
123 ALfloat Gain;
124 } Dedicated;
128 struct EffectVtable {
129 void (*const setParami)(EffectProps *props, ALCcontext *context, ALenum param, ALint val);
130 void (*const setParamiv)(EffectProps *props, ALCcontext *context, ALenum param, const ALint *vals);
131 void (*const setParamf)(EffectProps *props, ALCcontext *context, ALenum param, ALfloat val);
132 void (*const setParamfv)(EffectProps *props, ALCcontext *context, ALenum param, const ALfloat *vals);
134 void (*const getParami)(const EffectProps *props, ALCcontext *context, ALenum param, ALint *val);
135 void (*const getParamiv)(const EffectProps *props, ALCcontext *context, ALenum param, ALint *vals);
136 void (*const getParamf)(const EffectProps *props, ALCcontext *context, ALenum param, ALfloat *val);
137 void (*const getParamfv)(const EffectProps *props, ALCcontext *context, ALenum param, ALfloat *vals);
140 #define DEFINE_ALEFFECT_VTABLE(T) \
141 const EffectVtable T##_vtable = { \
142 T##_setParami, T##_setParamiv, \
143 T##_setParamf, T##_setParamfv, \
144 T##_getParami, T##_getParamiv, \
145 T##_getParamf, T##_getParamfv, \
149 struct EffectTarget {
150 MixParams *Main;
151 RealMixParams *RealOut;
154 struct EffectState : public al::intrusive_ref<EffectState> {
155 al::span<FloatBufferLine> mOutTarget;
158 virtual ~EffectState() = default;
160 virtual ALboolean deviceUpdate(const ALCdevice *device) = 0;
161 virtual void update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target) = 0;
162 virtual void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut) = 0;
166 struct EffectStateFactory {
167 virtual ~EffectStateFactory() { }
169 virtual EffectState *create() = 0;
170 virtual EffectProps getDefaultProps() const noexcept = 0;
171 virtual const EffectVtable *getEffectVtable() const noexcept = 0;
175 EffectStateFactory *NullStateFactory_getFactory(void);
176 EffectStateFactory *ReverbStateFactory_getFactory(void);
177 EffectStateFactory *StdReverbStateFactory_getFactory(void);
178 EffectStateFactory *AutowahStateFactory_getFactory(void);
179 EffectStateFactory *ChorusStateFactory_getFactory(void);
180 EffectStateFactory *CompressorStateFactory_getFactory(void);
181 EffectStateFactory *DistortionStateFactory_getFactory(void);
182 EffectStateFactory *EchoStateFactory_getFactory(void);
183 EffectStateFactory *EqualizerStateFactory_getFactory(void);
184 EffectStateFactory *FlangerStateFactory_getFactory(void);
185 EffectStateFactory *FshifterStateFactory_getFactory(void);
186 EffectStateFactory *ModulatorStateFactory_getFactory(void);
187 EffectStateFactory *PshifterStateFactory_getFactory(void);
188 EffectStateFactory* VmorpherStateFactory_getFactory(void);
190 EffectStateFactory *DedicatedStateFactory_getFactory(void);
193 #endif /* EFFECTS_BASE_H */