aboutsummaryrefslogtreecommitdiffstats
path: root/al/filter.h
blob: b87e7f037a791f61d383bd8010a3af23638ccdec (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
#ifndef AL_FILTER_H
#define AL_FILTER_H

#include <string_view>
#include <variant>

#include "AL/al.h"
#include "AL/alc.h"
#include "AL/alext.h"

#include "almalloc.h"

#define LOWPASSFREQREF  5000.0f
#define HIGHPASSFREQREF  250.0f


template<typename T>
struct FilterTable {
    static void setParami(struct ALfilter*, ALenum, int);
    static void setParamiv(struct ALfilter*, ALenum, const int*);
    static void setParamf(struct ALfilter*, ALenum, float);
    static void setParamfv(struct ALfilter*, ALenum, const float*);

    static void getParami(const struct ALfilter*, ALenum, int*);
    static void getParamiv(const struct ALfilter*, ALenum, int*);
    static void getParamf(const struct ALfilter*, ALenum, float*);
    static void getParamfv(const struct ALfilter*, ALenum, float*);
};

struct NullFilterTable : public FilterTable<NullFilterTable> { };
struct LowpassFilterTable : public FilterTable<LowpassFilterTable> { };
struct HighpassFilterTable : public FilterTable<HighpassFilterTable> { };
struct BandpassFilterTable : public FilterTable<BandpassFilterTable> { };


struct ALfilter {
    ALenum type{AL_FILTER_NULL};

    float Gain{1.0f};
    float GainHF{1.0f};
    float HFReference{LOWPASSFREQREF};
    float GainLF{1.0f};
    float LFReference{HIGHPASSFREQREF};

    using TableTypes = std::variant<NullFilterTable,LowpassFilterTable,HighpassFilterTable,
        BandpassFilterTable>;
    TableTypes mTypeVariant;

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

    static void SetName(ALCcontext *context, ALuint id, std::string_view name);

    DISABLE_ALLOC
};

#endif