aboutsummaryrefslogtreecommitdiffstats
path: root/core/buffer_storage.h
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2021-12-11 17:50:24 -0800
committerChris Robinson <[email protected]>2021-12-11 17:50:24 -0800
commit01dd34f305b9ad2c8e6bf0642cd976f9788fdf3a (patch)
tree75f50acecb284a587e13265efb14ed573af90245 /core/buffer_storage.h
parenta75d35bbb06f74e58cb2232d4ca2ce47950f08cd (diff)
Add an internal Super Stereo format
It's not available as an AL buffer format (yet) since I'm not sure how to expose it. Internally it seems fine as a separate channel configuration, but because OpenAL combines the channel configuration and sample type, a flag may work better there.
Diffstat (limited to 'core/buffer_storage.h')
-rw-r--r--core/buffer_storage.h28
1 files changed, 26 insertions, 2 deletions
diff --git a/core/buffer_storage.h b/core/buffer_storage.h
index 64943453..091882f9 100644
--- a/core/buffer_storage.h
+++ b/core/buffer_storage.h
@@ -4,6 +4,8 @@
#include <atomic>
#include "albyte.h"
+#include "alnumeric.h"
+#include "ambidefs.h"
using uint = unsigned int;
@@ -30,6 +32,7 @@ enum FmtChannels : unsigned char {
FmtUHJ2, /* 2-channel UHJ, aka "BHJ", stereo-compatible */
FmtUHJ3, /* 3-channel UHJ, aka "THJ" */
FmtUHJ4, /* 4-channel UHJ, aka "PHJ" */
+ FmtSuperStereo, /* Stereo processed with Super Stereo. */
};
enum class AmbiLayout : unsigned char {
@@ -48,6 +51,21 @@ uint ChannelsFromFmt(FmtChannels chans, uint ambiorder) noexcept;
inline uint FrameSizeFromFmt(FmtChannels chans, FmtType type, uint ambiorder) noexcept
{ return ChannelsFromFmt(chans, ambiorder) * BytesFromFmt(type); }
+constexpr bool IsBFormat(FmtChannels chans) noexcept
+{ return chans == FmtBFormat2D || chans == FmtBFormat3D; }
+
+/* Super Stereo is considered part of the UHJ family here, since it goes
+ * through similar processing as UHJ, both result in a B-Format signal, and
+ * needs the same consideration as BHJ (three channel result with only two
+ * channel input).
+ */
+constexpr bool IsUHJ(FmtChannels chans) noexcept
+{ return chans == FmtUHJ2 || chans == FmtUHJ3 || chans == FmtUHJ4 || chans == FmtSuperStereo; }
+
+/** Ambisonic formats are either B-Format or UHJ formats. */
+constexpr bool IsAmbisonic(FmtChannels chans) noexcept
+{ return IsBFormat(chans) || IsUHJ(chans); }
+
using CallbackType = int(*)(void*, void*, int);
@@ -69,8 +87,14 @@ struct BufferStorage {
{ return ChannelsFromFmt(mChannels, mAmbiOrder); }
inline uint frameSizeFromFmt() const noexcept { return channelsFromFmt() * bytesFromFmt(); }
- inline bool isBFormat() const noexcept
- { return mChannels == FmtBFormat2D || mChannels == FmtBFormat3D; }
+ inline uint mixerChannelsFromFmt() const noexcept
+ {
+ if(mChannels == FmtUHJ2 || mChannels == FmtSuperStereo) return 3;
+ return ChannelsFromFmt(mChannels, minu(mAmbiOrder, MaxAmbiOrder));
+ }
+
+ inline bool isBFormat() const noexcept { return IsBFormat(mChannels); }
+ inline bool isUhj() const noexcept { return IsUHJ(mChannels); }
};
#endif /* CORE_BUFFER_STORAGE_H */