diff options
author | Chris Robinson <[email protected]> | 2020-11-27 19:18:17 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2020-11-27 19:18:17 -0800 |
commit | b0919240ab73f2e340f26a913baf7524b35a4c85 (patch) | |
tree | 8a5bf22bf62fe9582af3d930c54f531c16e6b6f1 /core/devformat.h | |
parent | d86046d522f45804e28462db0c0e8e1a34a1cfe7 (diff) |
Move some sources to a separate directory
To begin separating the ALC interfaces from internal ones.
Diffstat (limited to 'core/devformat.h')
-rw-r--r-- | core/devformat.h | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/core/devformat.h b/core/devformat.h new file mode 100644 index 00000000..bcd42539 --- /dev/null +++ b/core/devformat.h @@ -0,0 +1,103 @@ +#ifndef CORE_DEVFORMAT_H +#define CORE_DEVFORMAT_H + +#include <cstdint> + + +using uint = unsigned int; + +enum Channel { + FrontLeft = 0, + FrontRight, + FrontCenter, + LFE, + BackLeft, + BackRight, + BackCenter, + SideLeft, + SideRight, + + TopFrontLeft, + TopFrontCenter, + TopFrontRight, + TopCenter, + TopBackLeft, + TopBackCenter, + TopBackRight, + + MaxChannels +}; + + +/* Device formats */ +enum DevFmtType : unsigned char { + DevFmtByte, + DevFmtUByte, + DevFmtShort, + DevFmtUShort, + DevFmtInt, + DevFmtUInt, + DevFmtFloat, + + DevFmtTypeDefault = DevFmtFloat +}; +enum DevFmtChannels : unsigned char { + DevFmtMono, + DevFmtStereo, + DevFmtQuad, + DevFmtX51, + DevFmtX61, + DevFmtX71, + DevFmtAmbi3D, + + /* Similar to 5.1, except using rear channels instead of sides */ + DevFmtX51Rear, + + DevFmtChannelsDefault = DevFmtStereo +}; +#define MAX_OUTPUT_CHANNELS 16 + +/* DevFmtType traits, providing the type, etc given a DevFmtType. */ +template<DevFmtType T> +struct DevFmtTypeTraits { }; + +template<> +struct DevFmtTypeTraits<DevFmtByte> { using Type = int8_t; }; +template<> +struct DevFmtTypeTraits<DevFmtUByte> { using Type = uint8_t; }; +template<> +struct DevFmtTypeTraits<DevFmtShort> { using Type = int16_t; }; +template<> +struct DevFmtTypeTraits<DevFmtUShort> { using Type = uint16_t; }; +template<> +struct DevFmtTypeTraits<DevFmtInt> { using Type = int32_t; }; +template<> +struct DevFmtTypeTraits<DevFmtUInt> { using Type = uint32_t; }; +template<> +struct DevFmtTypeTraits<DevFmtFloat> { using Type = float; }; + + +uint BytesFromDevFmt(DevFmtType type) noexcept; +uint ChannelsFromDevFmt(DevFmtChannels chans, uint ambiorder) noexcept; +inline uint FrameSizeFromDevFmt(DevFmtChannels chans, DevFmtType type, uint ambiorder) noexcept +{ return ChannelsFromDevFmt(chans, ambiorder) * BytesFromDevFmt(type); } + +const char *DevFmtTypeString(DevFmtType type) noexcept; +const char *DevFmtChannelsString(DevFmtChannels chans) noexcept; + +enum class DevAmbiLayout : bool { + FuMa, + ACN, + + Default = ACN +}; + +enum class DevAmbiScaling : unsigned char { + FuMa, + SN3D, + N3D, + + Default = SN3D +}; + +#endif /* CORE_DEVFORMAT_H */ |