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
|
#ifndef ALC_BUFFER_FORMATS_H
#define ALC_BUFFER_FORMATS_H
#include "AL/al.h"
#include "AL/alext.h"
#include "albyte.h"
#include "inprogext.h"
#include "vector.h"
/* Storable formats */
enum FmtType : unsigned char {
FmtUByte,
FmtShort,
FmtFloat,
FmtDouble,
FmtMulaw,
FmtAlaw,
};
enum FmtChannels : unsigned char {
FmtMono,
FmtStereo,
FmtRear,
FmtQuad,
FmtX51, /* (WFX order) */
FmtX61, /* (WFX order) */
FmtX71, /* (WFX order) */
FmtBFormat2D,
FmtBFormat3D,
};
enum class AmbiLayout : unsigned char {
FuMa = AL_FUMA_SOFT,
ACN = AL_ACN_SOFT,
};
enum class AmbiScaling : unsigned char {
FuMa = AL_FUMA_SOFT,
SN3D = AL_SN3D_SOFT,
N3D = AL_N3D_SOFT,
};
ALuint BytesFromFmt(FmtType type) noexcept;
ALuint ChannelsFromFmt(FmtChannels chans, ALuint ambiorder) noexcept;
inline ALuint FrameSizeFromFmt(FmtChannels chans, FmtType type, ALuint ambiorder) noexcept
{ return ChannelsFromFmt(chans, ambiorder) * BytesFromFmt(type); }
struct BufferStorage {
al::vector<al::byte,16> mData;
LPALBUFFERCALLBACKTYPESOFT mCallback{nullptr};
void *mUserData{nullptr};
ALuint mSampleRate{0u};
FmtChannels mChannels{};
FmtType mType{};
ALuint mSampleLen{0u};
AmbiLayout mAmbiLayout{AmbiLayout::FuMa};
AmbiScaling mAmbiScaling{AmbiScaling::FuMa};
ALuint mAmbiOrder{0u};
inline ALuint bytesFromFmt() const noexcept { return BytesFromFmt(mType); }
inline ALuint channelsFromFmt() const noexcept
{ return ChannelsFromFmt(mChannels, mAmbiOrder); }
inline ALuint frameSizeFromFmt() const noexcept { return channelsFromFmt() * bytesFromFmt(); }
inline bool isBFormat() const noexcept
{ return mChannels == FmtBFormat2D || mChannels == FmtBFormat3D; }
};
#endif /* ALC_BUFFER_FORMATS_H */
|