🛠️🐜 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.

121 lines
2.3 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. Aux0,
  23. Aux1,
  24. Aux2,
  25. Aux3,
  26. Aux4,
  27. Aux5,
  28. Aux6,
  29. Aux7,
  30. Aux8,
  31. Aux9,
  32. Aux10,
  33. Aux11,
  34. Aux12,
  35. Aux13,
  36. Aux14,
  37. Aux15,
  38. MaxChannels
  39. };
  40. /* Device formats */
  41. enum DevFmtType : unsigned char {
  42. DevFmtByte,
  43. DevFmtUByte,
  44. DevFmtShort,
  45. DevFmtUShort,
  46. DevFmtInt,
  47. DevFmtUInt,
  48. DevFmtFloat,
  49. DevFmtTypeDefault = DevFmtFloat
  50. };
  51. enum DevFmtChannels : unsigned char {
  52. DevFmtMono,
  53. DevFmtStereo,
  54. DevFmtQuad,
  55. DevFmtX51,
  56. DevFmtX61,
  57. DevFmtX71,
  58. DevFmtX3D71,
  59. DevFmtAmbi3D,
  60. DevFmtChannelsDefault = DevFmtStereo
  61. };
  62. #define MAX_OUTPUT_CHANNELS 16
  63. /* DevFmtType traits, providing the type, etc given a DevFmtType. */
  64. template<DevFmtType T>
  65. struct DevFmtTypeTraits { };
  66. template<>
  67. struct DevFmtTypeTraits<DevFmtByte> { using Type = int8_t; };
  68. template<>
  69. struct DevFmtTypeTraits<DevFmtUByte> { using Type = uint8_t; };
  70. template<>
  71. struct DevFmtTypeTraits<DevFmtShort> { using Type = int16_t; };
  72. template<>
  73. struct DevFmtTypeTraits<DevFmtUShort> { using Type = uint16_t; };
  74. template<>
  75. struct DevFmtTypeTraits<DevFmtInt> { using Type = int32_t; };
  76. template<>
  77. struct DevFmtTypeTraits<DevFmtUInt> { using Type = uint32_t; };
  78. template<>
  79. struct DevFmtTypeTraits<DevFmtFloat> { using Type = float; };
  80. template<DevFmtType T>
  81. using DevFmtType_t = typename DevFmtTypeTraits<T>::Type;
  82. uint BytesFromDevFmt(DevFmtType type) noexcept;
  83. uint ChannelsFromDevFmt(DevFmtChannels chans, uint ambiorder) noexcept;
  84. inline uint FrameSizeFromDevFmt(DevFmtChannels chans, DevFmtType type, uint ambiorder) noexcept
  85. { return ChannelsFromDevFmt(chans, ambiorder) * BytesFromDevFmt(type); }
  86. const char *DevFmtTypeString(DevFmtType type) noexcept;
  87. const char *DevFmtChannelsString(DevFmtChannels chans) noexcept;
  88. enum class DevAmbiLayout : bool {
  89. FuMa,
  90. ACN,
  91. Default = ACN
  92. };
  93. enum class DevAmbiScaling : unsigned char {
  94. FuMa,
  95. SN3D,
  96. N3D,
  97. Default = SN3D
  98. };
  99. #endif /* CORE_DEVFORMAT_H */