Avoid static constexpr for arrays iterated over at run-time
[openal-soft.git] / alc / devformat.h
blob402fb8bdf958ac73f6f391e3705ad0d4e63b9745
1 #ifndef ALC_DEVFORMAT_H
2 #define ALC_DEVFORMAT_H
4 #include <cstdint>
6 #include "AL/al.h"
7 #include "AL/alext.h"
9 #include "inprogext.h"
12 enum Channel {
13 FrontLeft = 0,
14 FrontRight,
15 FrontCenter,
16 LFE,
17 BackLeft,
18 BackRight,
19 BackCenter,
20 SideLeft,
21 SideRight,
23 UpperFrontLeft,
24 UpperFrontRight,
25 UpperBackLeft,
26 UpperBackRight,
27 LowerFrontLeft,
28 LowerFrontRight,
29 LowerBackLeft,
30 LowerBackRight,
32 Aux0,
33 Aux1,
34 Aux2,
35 Aux3,
36 Aux4,
37 Aux5,
38 Aux6,
39 Aux7,
40 Aux8,
41 Aux9,
42 Aux10,
43 Aux11,
44 Aux12,
45 Aux13,
46 Aux14,
47 Aux15,
49 MaxChannels
53 /* Device formats */
54 enum DevFmtType : ALenum {
55 DevFmtByte = ALC_BYTE_SOFT,
56 DevFmtUByte = ALC_UNSIGNED_BYTE_SOFT,
57 DevFmtShort = ALC_SHORT_SOFT,
58 DevFmtUShort = ALC_UNSIGNED_SHORT_SOFT,
59 DevFmtInt = ALC_INT_SOFT,
60 DevFmtUInt = ALC_UNSIGNED_INT_SOFT,
61 DevFmtFloat = ALC_FLOAT_SOFT,
63 DevFmtTypeDefault = DevFmtFloat
65 enum DevFmtChannels : ALenum {
66 DevFmtMono = ALC_MONO_SOFT,
67 DevFmtStereo = ALC_STEREO_SOFT,
68 DevFmtQuad = ALC_QUAD_SOFT,
69 DevFmtX51 = ALC_5POINT1_SOFT,
70 DevFmtX61 = ALC_6POINT1_SOFT,
71 DevFmtX71 = ALC_7POINT1_SOFT,
72 DevFmtAmbi3D = ALC_BFORMAT3D_SOFT,
74 /* Similar to 5.1, except using rear channels instead of sides */
75 DevFmtX51Rear = 0x70000000,
77 DevFmtChannelsDefault = DevFmtStereo
79 #define MAX_OUTPUT_CHANNELS (16)
81 /* DevFmtType traits, providing the type, etc given a DevFmtType. */
82 template<DevFmtType T>
83 struct DevFmtTypeTraits { };
85 template<>
86 struct DevFmtTypeTraits<DevFmtByte> { using Type = int8_t; };
87 template<>
88 struct DevFmtTypeTraits<DevFmtUByte> { using Type = uint8_t; };
89 template<>
90 struct DevFmtTypeTraits<DevFmtShort> { using Type = int16_t; };
91 template<>
92 struct DevFmtTypeTraits<DevFmtUShort> { using Type = uint16_t; };
93 template<>
94 struct DevFmtTypeTraits<DevFmtInt> { using Type = int32_t; };
95 template<>
96 struct DevFmtTypeTraits<DevFmtUInt> { using Type = uint32_t; };
97 template<>
98 struct DevFmtTypeTraits<DevFmtFloat> { using Type = float; };
101 ALuint BytesFromDevFmt(DevFmtType type) noexcept;
102 ALuint ChannelsFromDevFmt(DevFmtChannels chans, ALuint ambiorder) noexcept;
103 inline ALuint FrameSizeFromDevFmt(DevFmtChannels chans, DevFmtType type, ALuint ambiorder) noexcept
104 { return ChannelsFromDevFmt(chans, ambiorder) * BytesFromDevFmt(type); }
106 enum class AmbiLayout {
107 FuMa = ALC_FUMA_SOFT, /* FuMa channel order */
108 ACN = ALC_ACN_SOFT, /* ACN channel order */
110 Default = ACN
113 enum class AmbiNorm {
114 FuMa = ALC_FUMA_SOFT, /* FuMa normalization */
115 SN3D = ALC_SN3D_SOFT, /* SN3D normalization */
116 N3D = ALC_N3D_SOFT, /* N3D normalization */
118 Default = SN3D
121 #endif /* ALC_DEVFORMAT_H */