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

63 lines
1.6 KiB

  1. #include "config.h"
  2. #include "devformat.h"
  3. uint BytesFromDevFmt(DevFmtType type) noexcept
  4. {
  5. switch(type)
  6. {
  7. case DevFmtByte: return sizeof(int8_t);
  8. case DevFmtUByte: return sizeof(uint8_t);
  9. case DevFmtShort: return sizeof(int16_t);
  10. case DevFmtUShort: return sizeof(uint16_t);
  11. case DevFmtInt: return sizeof(int32_t);
  12. case DevFmtUInt: return sizeof(uint32_t);
  13. case DevFmtFloat: return sizeof(float);
  14. }
  15. return 0;
  16. }
  17. uint ChannelsFromDevFmt(DevFmtChannels chans, uint ambiorder) noexcept
  18. {
  19. switch(chans)
  20. {
  21. case DevFmtMono: return 1;
  22. case DevFmtStereo: return 2;
  23. case DevFmtQuad: return 4;
  24. case DevFmtX51: return 6;
  25. case DevFmtX61: return 7;
  26. case DevFmtX71: return 8;
  27. case DevFmtAmbi3D: return (ambiorder+1) * (ambiorder+1);
  28. }
  29. return 0;
  30. }
  31. const char *DevFmtTypeString(DevFmtType type) noexcept
  32. {
  33. switch(type)
  34. {
  35. case DevFmtByte: return "Int8";
  36. case DevFmtUByte: return "UInt8";
  37. case DevFmtShort: return "Int16";
  38. case DevFmtUShort: return "UInt16";
  39. case DevFmtInt: return "Int32";
  40. case DevFmtUInt: return "UInt32";
  41. case DevFmtFloat: return "Float32";
  42. }
  43. return "(unknown type)";
  44. }
  45. const char *DevFmtChannelsString(DevFmtChannels chans) noexcept
  46. {
  47. switch(chans)
  48. {
  49. case DevFmtMono: return "Mono";
  50. case DevFmtStereo: return "Stereo";
  51. case DevFmtQuad: return "Quadraphonic";
  52. case DevFmtX51: return "5.1 Surround";
  53. case DevFmtX61: return "6.1 Surround";
  54. case DevFmtX71: return "7.1 Surround";
  55. case DevFmtAmbi3D: return "Ambisonic 3D";
  56. }
  57. return "(unknown channels)";
  58. }