diff options
author | Chris Robinson <[email protected]> | 2018-12-15 03:30:47 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-12-15 03:30:47 -0800 |
commit | e0f635b20d989a5083112aa70960cc89e6bc553c (patch) | |
tree | 9e8f2ca7b87159ad50342938bbe5ec5719c1abeb | |
parent | 0dd13a9dfed47660946fa9d37a1fc35e44b73687 (diff) |
Move some ambisonic-related macros to a separate header
-rw-r--r-- | Alc/ambdec.cpp | 7 | ||||
-rw-r--r-- | Alc/ambdec.h | 18 | ||||
-rw-r--r-- | Alc/ambidefs.h | 33 | ||||
-rw-r--r-- | Alc/logging.h | 8 | ||||
-rw-r--r-- | CMakeLists.txt | 1 | ||||
-rw-r--r-- | OpenAL32/Include/alMain.h | 38 |
6 files changed, 58 insertions, 47 deletions
diff --git a/Alc/ambdec.cpp b/Alc/ambdec.cpp index 8b251187..e37a5a09 100644 --- a/Alc/ambdec.cpp +++ b/Alc/ambdec.cpp @@ -12,11 +12,16 @@ #include <fstream> #include <sstream> +#include "logging.h" #include "compat.h" namespace { +template<typename T, std::size_t N> +constexpr inline std::size_t size(const T(&)[N]) noexcept +{ return N; } + int readline(std::istream &f, std::string &output) { while(f.good() && f.peek() == '\n') @@ -148,7 +153,7 @@ bool load_ambdec_matrix(float (&gains)[MAX_AMBI_ORDER+1], al::vector<AmbDecConf: buffer.c_str()+static_cast<std::size_t>(istr.tellg())); return false; } - if(curgain < countof(gains)) + if(curgain < size(gains)) gains[curgain++] = value; } std::fill(std::begin(gains)+curgain, std::end(gains), 0.0f); diff --git a/Alc/ambdec.h b/Alc/ambdec.h index 5ec5eb0c..1629c14d 100644 --- a/Alc/ambdec.h +++ b/Alc/ambdec.h @@ -4,7 +4,7 @@ #include <array> #include <string> -#include "alMain.h" +#include "ambidefs.h" #include "vector.h" /* Helpers to read .ambdec configuration files. */ @@ -16,14 +16,14 @@ enum class AmbDecScale { }; struct AmbDecConf { std::string Description; - int Version; /* Must be 3 */ + int Version{0}; /* Must be 3 */ - unsigned int ChanMask; - unsigned int FreqBands; /* Must be 1 or 2 */ - AmbDecScale CoeffScale; + unsigned int ChanMask{0u}; + unsigned int FreqBands{0u}; /* Must be 1 or 2 */ + AmbDecScale CoeffScale{}; - float XOverFreq; - float XOverRatio; + float XOverFreq{0.0f}; + float XOverRatio{0.0f}; struct SpeakerConf { std::string Name; @@ -36,10 +36,10 @@ struct AmbDecConf { using CoeffArray = std::array<float,MAX_AMBI_COEFFS>; /* Unused when FreqBands == 1 */ - float LFOrderGain[MAX_AMBI_ORDER+1]; + float LFOrderGain[MAX_AMBI_ORDER+1]{}; al::vector<CoeffArray> LFMatrix; - float HFOrderGain[MAX_AMBI_ORDER+1]; + float HFOrderGain[MAX_AMBI_ORDER+1]{}; al::vector<CoeffArray> HFMatrix; int load(const char *fname) noexcept; diff --git a/Alc/ambidefs.h b/Alc/ambidefs.h new file mode 100644 index 00000000..124a0c8e --- /dev/null +++ b/Alc/ambidefs.h @@ -0,0 +1,33 @@ +#ifndef AMBIDEFS_H +#define AMBIDEFS_H + +/* The maximum number of Ambisonics coefficients. For a given order (o), the + * size needed will be (o+1)**2, thus zero-order has 1, first-order has 4, + * second-order has 9, third-order has 16, and fourth-order has 25. + */ +#define MAX_AMBI_ORDER 3 +#define MAX_AMBI_COEFFS ((MAX_AMBI_ORDER+1) * (MAX_AMBI_ORDER+1)) + +/* A bitmask of ambisonic channels for 0 to 4th order. This only specifies up + * to 4th order, which is the highest order a 32-bit mask value can specify (a + * 64-bit mask could handle up to 7th order). + */ +#define AMBI_0ORDER_MASK 0x00000001 +#define AMBI_1ORDER_MASK 0x0000000f +#define AMBI_2ORDER_MASK 0x000001ff +#define AMBI_3ORDER_MASK 0x0000ffff +#define AMBI_4ORDER_MASK 0x01ffffff + +/* A bitmask of ambisonic channels with height information. If none of these + * channels are used/needed, there's no height (e.g. with most surround sound + * speaker setups). This is ACN ordering, with bit 0 being ACN 0, etc. + */ +#define AMBI_PERIPHONIC_MASK (0xfe7ce4) + +/* The maximum number of Ambisonic coefficients for 2D (non-periphonic) + * representation. This is 2 per each order above zero-order, plus 1 for zero- + * order. Or simply, o*2 + 1. + */ +#define MAX_AMBI2D_COEFFS (MAX_AMBI_ORDER*2 + 1) + +#endif /* AMBIDEFS_H */ diff --git a/Alc/logging.h b/Alc/logging.h index f493d973..41f64f77 100644 --- a/Alc/logging.h +++ b/Alc/logging.h @@ -4,6 +4,14 @@ #include <stdio.h> +#if defined(_WIN64) +#define SZFMT "%I64u" +#elif defined(_WIN32) +#define SZFMT "%u" +#else +#define SZFMT "%zu" +#endif + #ifdef __GNUC__ #define DECL_FORMAT(x, y, z) __attribute__((format(x, (y), (z)))) #else diff --git a/CMakeLists.txt b/CMakeLists.txt index 25392911..4e1d0081 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -730,6 +730,7 @@ SET(ALC_OBJS Alc/alconfig.cpp Alc/alconfig.h Alc/alcontext.h + Alc/ambidefs.h Alc/bs2b.cpp Alc/bs2b.h Alc/converter.cpp diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index 8eafa6a4..9d2e7bfc 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -33,6 +33,7 @@ #include "vector.h" #include "almalloc.h" #include "threads.h" +#include "ambidefs.h" template<typename T, size_t N> @@ -40,13 +41,6 @@ constexpr inline size_t countof(const T(&)[N]) noexcept { return N; } #define COUNTOF countof -#if defined(_WIN64) -#define SZFMT "%I64u" -#elif defined(_WIN32) -#define SZFMT "%u" -#else -#define SZFMT "%zu" -#endif #ifdef __has_builtin #define HAS_BUILTIN __has_builtin @@ -543,36 +537,6 @@ enum RenderMode { }; -/* The maximum number of Ambisonics coefficients. For a given order (o), the - * size needed will be (o+1)**2, thus zero-order has 1, first-order has 4, - * second-order has 9, third-order has 16, and fourth-order has 25. - */ -#define MAX_AMBI_ORDER 3 -#define MAX_AMBI_COEFFS ((MAX_AMBI_ORDER+1) * (MAX_AMBI_ORDER+1)) - -/* A bitmask of ambisonic channels for 0 to 4th order. This only specifies up - * to 4th order, which is the highest order a 32-bit mask value can specify (a - * 64-bit mask could handle up to 7th order). - */ -#define AMBI_0ORDER_MASK 0x00000001 -#define AMBI_1ORDER_MASK 0x0000000f -#define AMBI_2ORDER_MASK 0x000001ff -#define AMBI_3ORDER_MASK 0x0000ffff -#define AMBI_4ORDER_MASK 0x01ffffff - -/* A bitmask of ambisonic channels with height information. If none of these - * channels are used/needed, there's no height (e.g. with most surround sound - * speaker setups). This is ACN ordering, with bit 0 being ACN 0, etc. - */ -#define AMBI_PERIPHONIC_MASK (0xfe7ce4) - -/* The maximum number of Ambisonic coefficients for 2D (non-periphonic) - * representation. This is 2 per each order above zero-order, plus 1 for zero- - * order. Or simply, o*2 + 1. - */ -#define MAX_AMBI2D_COEFFS (MAX_AMBI_ORDER*2 + 1) - - typedef ALfloat ChannelConfig[MAX_AMBI_COEFFS]; typedef struct BFChannelConfig { ALfloat Scale; |