diff options
-rw-r--r-- | CMakeLists.txt | 6 | ||||
-rw-r--r-- | alc/alc.cpp | 62 | ||||
-rw-r--r-- | alc/alcmain.h | 7 | ||||
-rw-r--r-- | alc/alu.cpp | 2 | ||||
-rw-r--r-- | alc/bformatdec.h | 2 | ||||
-rw-r--r-- | alc/bufferline.h | 15 | ||||
-rw-r--r-- | alc/converter.h | 2 | ||||
-rw-r--r-- | alc/front_stablizer.h | 2 | ||||
-rw-r--r-- | alc/hrtf.h | 2 | ||||
-rw-r--r-- | alc/panning.cpp | 2 | ||||
-rw-r--r-- | alc/voice.cpp | 2 | ||||
-rw-r--r-- | alc/voice.h | 2 | ||||
-rw-r--r-- | core/bufferline.h | 14 | ||||
-rw-r--r-- | core/devformat.cpp | 65 | ||||
-rw-r--r-- | core/devformat.h (renamed from alc/devformat.h) | 9 |
15 files changed, 100 insertions, 94 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 59637da0..31ef66a9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -627,6 +627,10 @@ set(OPENAL_OBJS al/state.cpp ) set(ALC_OBJS + core/bufferline.h + core/devformat.cpp + core/devformat.h + alc/alc.cpp alc/alcmain.h alc/alu.cpp @@ -644,7 +648,6 @@ set(ALC_OBJS alc/bsinc_defs.h alc/bsinc_tables.cpp alc/bsinc_tables.h - alc/bufferline.h alc/buffer_storage.cpp alc/buffer_storage.h alc/compat.h @@ -652,7 +655,6 @@ set(ALC_OBJS alc/converter.h alc/cpu_caps.cpp alc/cpu_caps.h - alc/devformat.h alc/effectslot.cpp alc/effectslot.h alc/effects/base.h diff --git a/alc/alc.cpp b/alc/alc.cpp index 623fd688..7cf6c5a9 100644 --- a/alc/alc.cpp +++ b/alc/alc.cpp @@ -80,8 +80,8 @@ #include "bformatdec.h" #include "bs2b.h" #include "compat.h" +#include "core/devformat.h" #include "cpu_caps.h" -#include "devformat.h" #include "effects/base.h" #include "filters/nfc.h" #include "filters/splitter.h" @@ -1309,66 +1309,6 @@ BOOL APIENTRY DllMain(HINSTANCE module, DWORD reason, LPVOID /*reserved*/) /************************************************ * Device format information ************************************************/ -const ALCchar *DevFmtTypeString(DevFmtType type) noexcept -{ - switch(type) - { - case DevFmtByte: return "Int8"; - case DevFmtUByte: return "UInt8"; - case DevFmtShort: return "Int16"; - case DevFmtUShort: return "UInt16"; - case DevFmtInt: return "Int32"; - case DevFmtUInt: return "UInt32"; - case DevFmtFloat: return "Float32"; - } - return "(unknown type)"; -} -const ALCchar *DevFmtChannelsString(DevFmtChannels chans) noexcept -{ - switch(chans) - { - case DevFmtMono: return "Mono"; - case DevFmtStereo: return "Stereo"; - case DevFmtQuad: return "Quadraphonic"; - case DevFmtX51: return "5.1 Surround"; - case DevFmtX51Rear: return "5.1 Surround (Rear)"; - case DevFmtX61: return "6.1 Surround"; - case DevFmtX71: return "7.1 Surround"; - case DevFmtAmbi3D: return "Ambisonic 3D"; - } - return "(unknown channels)"; -} - -uint BytesFromDevFmt(DevFmtType type) noexcept -{ - switch(type) - { - case DevFmtByte: return sizeof(int8_t); - case DevFmtUByte: return sizeof(uint8_t); - case DevFmtShort: return sizeof(int16_t); - case DevFmtUShort: return sizeof(uint16_t); - case DevFmtInt: return sizeof(int32_t); - case DevFmtUInt: return sizeof(uint32_t); - case DevFmtFloat: return sizeof(float); - } - return 0; -} -uint ChannelsFromDevFmt(DevFmtChannels chans, uint ambiorder) noexcept -{ - switch(chans) - { - case DevFmtMono: return 1; - case DevFmtStereo: return 2; - case DevFmtQuad: return 4; - case DevFmtX51: return 6; - case DevFmtX51Rear: return 6; - case DevFmtX61: return 7; - case DevFmtX71: return 8; - case DevFmtAmbi3D: return (ambiorder+1) * (ambiorder+1); - } - return 0; -} - namespace { struct DevFmtPair { DevFmtChannels chans; DevFmtType type; }; diff --git a/alc/alcmain.h b/alc/alcmain.h index abeb0201..41906bde 100644 --- a/alc/alcmain.h +++ b/alc/alcmain.h @@ -23,8 +23,8 @@ #include "alspan.h" #include "ambidefs.h" #include "atomic.h" -#include "bufferline.h" -#include "devformat.h" +#include "core/bufferline.h" +#include "core/devformat.h" #include "filters/splitter.h" #include "hrtf.h" #include "inprogext.h" @@ -366,9 +366,6 @@ struct ALCdevice : public al::intrusive_ref<ALCdevice> { extern int RTPrioLevel; void SetRTPriority(void); -const ALCchar *DevFmtTypeString(DevFmtType type) noexcept; -const ALCchar *DevFmtChannelsString(DevFmtChannels chans) noexcept; - /** * Returns the index for the given channel name (e.g. FrontCenter), or * INVALID_CHANNEL_INDEX if it doesn't exist. diff --git a/alc/alu.cpp b/alc/alu.cpp index 7e7dabf9..10069fd1 100644 --- a/alc/alu.cpp +++ b/alc/alu.cpp @@ -59,8 +59,8 @@ #include "atomic.h" #include "bformatdec.h" #include "bs2b.h" +#include "core/devformat.h" #include "cpu_caps.h" -#include "devformat.h" #include "effects/base.h" #include "filters/biquad.h" #include "filters/nfc.h" diff --git a/alc/bformatdec.h b/alc/bformatdec.h index 03249c55..280ca2fc 100644 --- a/alc/bformatdec.h +++ b/alc/bformatdec.h @@ -11,7 +11,7 @@ #include "almalloc.h" #include "alspan.h" #include "ambidefs.h" -#include "devformat.h" +#include "core/devformat.h" #include "filters/splitter.h" struct AmbDecConf; diff --git a/alc/bufferline.h b/alc/bufferline.h deleted file mode 100644 index 79f0996c..00000000 --- a/alc/bufferline.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef ALC_BUFFERLINE_H -#define ALC_BUFFERLINE_H - -#include <array> - -/* Size for temporary storage of buffer data, in floats. Larger values need - * more memory, while smaller values may need more iterations. The value needs - * to be a sensible size, however, as it constrains the max stepping value used - * for mixing, as well as the maximum number of samples per mixing iteration. - */ -#define BUFFERSIZE 1024 - -using FloatBufferLine = std::array<float,BUFFERSIZE>; - -#endif /* ALC_BUFFERLINE_H */ diff --git a/alc/converter.h b/alc/converter.h index 17da3aae..a97d1ea5 100644 --- a/alc/converter.h +++ b/alc/converter.h @@ -10,7 +10,7 @@ #include "almalloc.h" #include "alnumeric.h" #include "alu.h" -#include "devformat.h" +#include "core/devformat.h" #include "voice.h" diff --git a/alc/front_stablizer.h b/alc/front_stablizer.h index 5e7c267f..066a70af 100644 --- a/alc/front_stablizer.h +++ b/alc/front_stablizer.h @@ -5,7 +5,7 @@ #include <memory> #include "almalloc.h" -#include "bufferline.h" +#include "core/bufferline.h" #include "filters/splitter.h" @@ -10,7 +10,7 @@ #include "alspan.h" #include "ambidefs.h" #include "atomic.h" -#include "bufferline.h" +#include "core/bufferline.h" #include "filters/splitter.h" #include "intrusive_ptr.h" #include "vector.h" diff --git a/alc/panning.cpp b/alc/panning.cpp index adc7db30..86a71a24 100644 --- a/alc/panning.cpp +++ b/alc/panning.cpp @@ -51,7 +51,7 @@ #include "ambidefs.h" #include "bformatdec.h" #include "bs2b.h" -#include "devformat.h" +#include "core/devformat.h" #include "front_stablizer.h" #include "hrtf.h" #include "logging.h" diff --git a/alc/voice.cpp b/alc/voice.cpp index 4fe84234..174e8545 100644 --- a/alc/voice.cpp +++ b/alc/voice.cpp @@ -46,8 +46,8 @@ #include "alspan.h" #include "alstring.h" #include "alu.h" +#include "core/devformat.h" #include "cpu_caps.h" -#include "devformat.h" #include "filters/biquad.h" #include "filters/nfc.h" #include "filters/splitter.h" diff --git a/alc/voice.h b/alc/voice.h index 5900d849..5ae7a945 100644 --- a/alc/voice.h +++ b/alc/voice.h @@ -7,7 +7,7 @@ #include "alspan.h" #include "alu.h" #include "buffer_storage.h" -#include "devformat.h" +#include "core/devformat.h" #include "filters/biquad.h" #include "filters/nfc.h" #include "filters/splitter.h" diff --git a/core/bufferline.h b/core/bufferline.h new file mode 100644 index 00000000..07983140 --- /dev/null +++ b/core/bufferline.h @@ -0,0 +1,14 @@ +#ifndef CORE_BUFFERLINE_H +#define CORE_BUFFERLINE_H + +#include <array> + +/* Size for temporary storage of buffer data, in floats. Larger values need + * more memory and are harder on cache, while smaller values may need more + * iterations for mixing. + */ +#define BUFFERSIZE 1024 + +using FloatBufferLine = std::array<float,BUFFERSIZE>; + +#endif /* CORE_BUFFERLINE_H */ diff --git a/core/devformat.cpp b/core/devformat.cpp new file mode 100644 index 00000000..d13ef3c6 --- /dev/null +++ b/core/devformat.cpp @@ -0,0 +1,65 @@ + +#include "config.h" + +#include "devformat.h" + + +uint BytesFromDevFmt(DevFmtType type) noexcept +{ + switch(type) + { + case DevFmtByte: return sizeof(int8_t); + case DevFmtUByte: return sizeof(uint8_t); + case DevFmtShort: return sizeof(int16_t); + case DevFmtUShort: return sizeof(uint16_t); + case DevFmtInt: return sizeof(int32_t); + case DevFmtUInt: return sizeof(uint32_t); + case DevFmtFloat: return sizeof(float); + } + return 0; +} +uint ChannelsFromDevFmt(DevFmtChannels chans, uint ambiorder) noexcept +{ + switch(chans) + { + case DevFmtMono: return 1; + case DevFmtStereo: return 2; + case DevFmtQuad: return 4; + case DevFmtX51: return 6; + case DevFmtX51Rear: return 6; + case DevFmtX61: return 7; + case DevFmtX71: return 8; + case DevFmtAmbi3D: return (ambiorder+1) * (ambiorder+1); + } + return 0; +} + +const char *DevFmtTypeString(DevFmtType type) noexcept +{ + switch(type) + { + case DevFmtByte: return "Int8"; + case DevFmtUByte: return "UInt8"; + case DevFmtShort: return "Int16"; + case DevFmtUShort: return "UInt16"; + case DevFmtInt: return "Int32"; + case DevFmtUInt: return "UInt32"; + case DevFmtFloat: return "Float32"; + } + return "(unknown type)"; +} +const char *DevFmtChannelsString(DevFmtChannels chans) noexcept +{ + switch(chans) + { + case DevFmtMono: return "Mono"; + case DevFmtStereo: return "Stereo"; + case DevFmtQuad: return "Quadraphonic"; + case DevFmtX51: return "5.1 Surround"; + case DevFmtX51Rear: return "5.1 Surround (Rear)"; + case DevFmtX61: return "6.1 Surround"; + case DevFmtX71: return "7.1 Surround"; + case DevFmtAmbi3D: return "Ambisonic 3D"; + } + return "(unknown channels)"; +} diff --git a/alc/devformat.h b/core/devformat.h index b02ad025..bcd42539 100644 --- a/alc/devformat.h +++ b/core/devformat.h @@ -1,5 +1,5 @@ -#ifndef ALC_DEVFORMAT_H -#define ALC_DEVFORMAT_H +#ifndef CORE_DEVFORMAT_H +#define CORE_DEVFORMAT_H #include <cstdint> @@ -82,6 +82,9 @@ uint ChannelsFromDevFmt(DevFmtChannels chans, uint ambiorder) noexcept; inline uint FrameSizeFromDevFmt(DevFmtChannels chans, DevFmtType type, uint ambiorder) noexcept { return ChannelsFromDevFmt(chans, ambiorder) * BytesFromDevFmt(type); } +const char *DevFmtTypeString(DevFmtType type) noexcept; +const char *DevFmtChannelsString(DevFmtChannels chans) noexcept; + enum class DevAmbiLayout : bool { FuMa, ACN, @@ -97,4 +100,4 @@ enum class DevAmbiScaling : unsigned char { Default = SN3D }; -#endif /* ALC_DEVFORMAT_H */ +#endif /* CORE_DEVFORMAT_H */ |