aboutsummaryrefslogtreecommitdiffstats
path: root/al/effect.h
blob: 5b5e4b03a96eef375ff46d7e9b4cb4c539f1f1ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#ifndef AL_EFFECT_H
#define AL_EFFECT_H

#include "AL/al.h"
#include "AL/efx.h"

#include "al/effects/effects.h"
#include "alc/effects/base.h"

#if ALSOFT_EAX
#include <memory>

#include "eax_effect.h"
#endif // ALSOFT_EAX


enum {
    EAXREVERB_EFFECT = 0,
    REVERB_EFFECT,
    AUTOWAH_EFFECT,
    CHORUS_EFFECT,
    COMPRESSOR_EFFECT,
    DISTORTION_EFFECT,
    ECHO_EFFECT,
    EQUALIZER_EFFECT,
    FLANGER_EFFECT,
    FSHIFTER_EFFECT,
    MODULATOR_EFFECT,
    PSHIFTER_EFFECT,
    VMORPHER_EFFECT,
    DEDICATED_EFFECT,
    CONVOLUTION_EFFECT,

    MAX_EFFECTS
};
extern bool DisabledEffects[MAX_EFFECTS];

extern float ReverbBoost;

struct EffectList {
    const char name[16];
    int type;
    ALenum val;
};
extern const EffectList gEffectList[16];


struct ALeffect {
    // Effect type (AL_EFFECT_NULL, ...)
    ALenum type{AL_EFFECT_NULL};

    EffectProps Props{};

    const EffectVtable *vtab{nullptr};

    /* Self ID */
    ALuint id{0u};

    DISABLE_ALLOC()


#if ALSOFT_EAX
public:
    EaxEffectUPtr eax_effect{};


    void eax_initialize();

    void eax_al_set_effect(
        ALenum al_effect_type);


private:
    [[noreturn]]
    static void eax_fail(
        const char* message);
#endif // ALSOFT_EAX
};

void InitEffect(ALeffect *effect);

void LoadReverbPreset(const char *name, ALeffect *effect);

#if ALSOFT_EAX
class EaxAlEffectDeleter
{
public:
    EaxAlEffectDeleter() noexcept = default;

    EaxAlEffectDeleter(
        ALCcontext& context) noexcept;

    void operator()(
        ALeffect* effect) const;


private:
    ALCcontext* context_{};
}; // EaxAlEffectDeleter

using EaxAlEffectUPtr = std::unique_ptr<ALeffect, EaxAlEffectDeleter>;


EaxAlEffectUPtr eax_create_al_effect(
    ALCcontext& context,
    ALenum effect_type);

void eax_al_delete_effect(
    ALCcontext& context,
    ALeffect& effect);
#endif // ALSOFT_EAX

#endif