🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

103 lines
2.1 KiB

  1. #ifndef CORE_DEVFORMAT_H
  2. #define CORE_DEVFORMAT_H
  3. #include <cstdint>
  4. using uint = unsigned int;
  5. enum Channel : unsigned char {
  6. FrontLeft = 0,
  7. FrontRight,
  8. FrontCenter,
  9. LFE,
  10. BackLeft,
  11. BackRight,
  12. BackCenter,
  13. SideLeft,
  14. SideRight,
  15. TopCenter,
  16. TopFrontLeft,
  17. TopFrontCenter,
  18. TopFrontRight,
  19. TopBackLeft,
  20. TopBackCenter,
  21. TopBackRight,
  22. MaxChannels
  23. };
  24. /* Device formats */
  25. enum DevFmtType : unsigned char {
  26. DevFmtByte,
  27. DevFmtUByte,
  28. DevFmtShort,
  29. DevFmtUShort,
  30. DevFmtInt,
  31. DevFmtUInt,
  32. DevFmtFloat,
  33. DevFmtTypeDefault = DevFmtFloat
  34. };
  35. enum DevFmtChannels : unsigned char {
  36. DevFmtMono,
  37. DevFmtStereo,
  38. DevFmtQuad,
  39. DevFmtX51,
  40. DevFmtX61,
  41. DevFmtX71,
  42. DevFmtAmbi3D,
  43. DevFmtChannelsDefault = DevFmtStereo
  44. };
  45. #define MAX_OUTPUT_CHANNELS 16
  46. /* DevFmtType traits, providing the type, etc given a DevFmtType. */
  47. template<DevFmtType T>
  48. struct DevFmtTypeTraits { };
  49. template<>
  50. struct DevFmtTypeTraits<DevFmtByte> { using Type = int8_t; };
  51. template<>
  52. struct DevFmtTypeTraits<DevFmtUByte> { using Type = uint8_t; };
  53. template<>
  54. struct DevFmtTypeTraits<DevFmtShort> { using Type = int16_t; };
  55. template<>
  56. struct DevFmtTypeTraits<DevFmtUShort> { using Type = uint16_t; };
  57. template<>
  58. struct DevFmtTypeTraits<DevFmtInt> { using Type = int32_t; };
  59. template<>
  60. struct DevFmtTypeTraits<DevFmtUInt> { using Type = uint32_t; };
  61. template<>
  62. struct DevFmtTypeTraits<DevFmtFloat> { using Type = float; };
  63. template<DevFmtType T>
  64. using DevFmtType_t = typename DevFmtTypeTraits<T>::Type;
  65. uint BytesFromDevFmt(DevFmtType type) noexcept;
  66. uint ChannelsFromDevFmt(DevFmtChannels chans, uint ambiorder) noexcept;
  67. inline uint FrameSizeFromDevFmt(DevFmtChannels chans, DevFmtType type, uint ambiorder) noexcept
  68. { return ChannelsFromDevFmt(chans, ambiorder) * BytesFromDevFmt(type); }
  69. const char *DevFmtTypeString(DevFmtType type) noexcept;
  70. const char *DevFmtChannelsString(DevFmtChannels chans) noexcept;
  71. enum class DevAmbiLayout : bool {
  72. FuMa,
  73. ACN,
  74. Default = ACN
  75. };
  76. enum class DevAmbiScaling : unsigned char {
  77. FuMa,
  78. SN3D,
  79. N3D,
  80. Default = SN3D
  81. };
  82. #endif /* CORE_DEVFORMAT_H */