]> git.tdb.fi Git - ext/openal.git/blob - core/devformat.h
Import OpenAL Soft 1.23.1 sources
[ext/openal.git] / core / devformat.h
1 #ifndef CORE_DEVFORMAT_H
2 #define CORE_DEVFORMAT_H
3
4 #include <cstdint>
5
6
7 using uint = unsigned int;
8
9 enum Channel : unsigned char {
10     FrontLeft = 0,
11     FrontRight,
12     FrontCenter,
13     LFE,
14     BackLeft,
15     BackRight,
16     BackCenter,
17     SideLeft,
18     SideRight,
19
20     TopCenter,
21     TopFrontLeft,
22     TopFrontCenter,
23     TopFrontRight,
24     TopBackLeft,
25     TopBackCenter,
26     TopBackRight,
27
28     Aux0,
29     Aux1,
30     Aux2,
31     Aux3,
32     Aux4,
33     Aux5,
34     Aux6,
35     Aux7,
36     Aux8,
37     Aux9,
38     Aux10,
39     Aux11,
40     Aux12,
41     Aux13,
42     Aux14,
43     Aux15,
44
45     MaxChannels
46 };
47
48
49 /* Device formats */
50 enum DevFmtType : unsigned char {
51     DevFmtByte,
52     DevFmtUByte,
53     DevFmtShort,
54     DevFmtUShort,
55     DevFmtInt,
56     DevFmtUInt,
57     DevFmtFloat,
58
59     DevFmtTypeDefault = DevFmtFloat
60 };
61 enum DevFmtChannels : unsigned char {
62     DevFmtMono,
63     DevFmtStereo,
64     DevFmtQuad,
65     DevFmtX51,
66     DevFmtX61,
67     DevFmtX71,
68     DevFmtX714,
69     DevFmtX3D71,
70     DevFmtAmbi3D,
71
72     DevFmtChannelsDefault = DevFmtStereo
73 };
74 #define MAX_OUTPUT_CHANNELS  16
75
76 /* DevFmtType traits, providing the type, etc given a DevFmtType. */
77 template<DevFmtType T>
78 struct DevFmtTypeTraits { };
79
80 template<>
81 struct DevFmtTypeTraits<DevFmtByte> { using Type = int8_t; };
82 template<>
83 struct DevFmtTypeTraits<DevFmtUByte> { using Type = uint8_t; };
84 template<>
85 struct DevFmtTypeTraits<DevFmtShort> { using Type = int16_t; };
86 template<>
87 struct DevFmtTypeTraits<DevFmtUShort> { using Type = uint16_t; };
88 template<>
89 struct DevFmtTypeTraits<DevFmtInt> { using Type = int32_t; };
90 template<>
91 struct DevFmtTypeTraits<DevFmtUInt> { using Type = uint32_t; };
92 template<>
93 struct DevFmtTypeTraits<DevFmtFloat> { using Type = float; };
94
95 template<DevFmtType T>
96 using DevFmtType_t = typename DevFmtTypeTraits<T>::Type;
97
98
99 uint BytesFromDevFmt(DevFmtType type) noexcept;
100 uint ChannelsFromDevFmt(DevFmtChannels chans, uint ambiorder) noexcept;
101 inline uint FrameSizeFromDevFmt(DevFmtChannels chans, DevFmtType type, uint ambiorder) noexcept
102 { return ChannelsFromDevFmt(chans, ambiorder) * BytesFromDevFmt(type); }
103
104 const char *DevFmtTypeString(DevFmtType type) noexcept;
105 const char *DevFmtChannelsString(DevFmtChannels chans) noexcept;
106
107 enum class DevAmbiLayout : bool {
108     FuMa,
109     ACN,
110
111     Default = ACN
112 };
113
114 enum class DevAmbiScaling : unsigned char {
115     FuMa,
116     SN3D,
117     N3D,
118
119     Default = SN3D
120 };
121
122 #endif /* CORE_DEVFORMAT_H */