aboutsummaryrefslogtreecommitdiffstats
path: root/core/buffer_storage.h
diff options
context:
space:
mode:
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 */