From ecf30de36f6487c1f8a19ae0d03ba810078706f4 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Thu, 27 Aug 2020 23:02:17 -0700 Subject: Rename buffer_formats to buffer_storage --- alc/buffer_storage.cpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 alc/buffer_storage.cpp (limited to 'alc/buffer_storage.cpp') diff --git a/alc/buffer_storage.cpp b/alc/buffer_storage.cpp new file mode 100644 index 00000000..727cb281 --- /dev/null +++ b/alc/buffer_storage.cpp @@ -0,0 +1,37 @@ + +#include "config.h" + +#include "buffer_storage.h" + +#include + + +ALuint BytesFromFmt(FmtType type) noexcept +{ + switch(type) + { + case FmtUByte: return sizeof(uint8_t); + case FmtShort: return sizeof(int16_t); + case FmtFloat: return sizeof(float); + case FmtDouble: return sizeof(double); + case FmtMulaw: return sizeof(uint8_t); + case FmtAlaw: return sizeof(uint8_t); + } + return 0; +} +ALuint ChannelsFromFmt(FmtChannels chans, ALuint ambiorder) noexcept +{ + switch(chans) + { + case FmtMono: return 1; + case FmtStereo: return 2; + case FmtRear: return 2; + case FmtQuad: return 4; + case FmtX51: return 6; + case FmtX61: return 7; + case FmtX71: return 8; + case FmtBFormat2D: return (ambiorder*2) + 1; + case FmtBFormat3D: return (ambiorder+1) * (ambiorder+1); + } + return 0; +} -- cgit v1.2.3