Handle the buffer's ambisonic properties
This commit is contained in:
+7
-1
@@ -2788,9 +2788,11 @@ START_API_FUNC
|
||||
ALbuffer *buffer{BufferList->mBuffer};
|
||||
voice->mFrequency = buffer->Frequency;
|
||||
voice->mFmtChannels = buffer->mFmtChannels;
|
||||
voice->mAmbiOrder = 1;
|
||||
voice->mNumChannels = ChannelsFromFmt(buffer->mFmtChannels);
|
||||
voice->mSampleSize = BytesFromFmt(buffer->mFmtType);
|
||||
voice->mAmbiLayout = static_cast<AmbiLayout>(buffer->AmbiLayout);
|
||||
voice->mAmbiScaling = static_cast<AmbiNorm>(buffer->AmbiScaling);
|
||||
voice->mAmbiOrder = 1;
|
||||
|
||||
/* Clear the stepping value so the mixer knows not to mix this until
|
||||
* the update gets applied.
|
||||
@@ -3136,6 +3138,10 @@ START_API_FUNC
|
||||
BufferFmt = buffer;
|
||||
else if(BufferFmt->Frequency != buffer->Frequency ||
|
||||
BufferFmt->mFmtChannels != buffer->mFmtChannels ||
|
||||
((BufferFmt->mFmtChannels == FmtBFormat2D ||
|
||||
BufferFmt->mFmtChannels == FmtBFormat3D) &&
|
||||
(BufferFmt->AmbiLayout != buffer->AmbiLayout ||
|
||||
BufferFmt->AmbiScaling != buffer->AmbiScaling)) ||
|
||||
BufferFmt->OriginalType != buffer->OriginalType)
|
||||
{
|
||||
context->setError(AL_INVALID_OPERATION, "Queueing buffer with mismatched format");
|
||||
|
||||
+24
-12
@@ -337,6 +337,26 @@ inline ALuint dither_rng(ALuint *seed) noexcept
|
||||
}
|
||||
|
||||
|
||||
auto GetAmbiScales(AmbiNorm scaletype) noexcept -> const std::array<float,MAX_AMBI_CHANNELS>&
|
||||
{
|
||||
if(scaletype == AmbiNorm::FuMa) return AmbiScale::FromFuMa;
|
||||
if(scaletype == AmbiNorm::SN3D) return AmbiScale::FromSN3D;
|
||||
return AmbiScale::FromN3D;
|
||||
}
|
||||
|
||||
auto GetAmbiLayout(AmbiLayout layouttype) noexcept -> const std::array<uint8_t,MAX_AMBI_CHANNELS>&
|
||||
{
|
||||
if(layouttype == AmbiLayout::FuMa) return AmbiIndex::FromFuMa;
|
||||
return AmbiIndex::FromACN;
|
||||
}
|
||||
|
||||
auto GetAmbi2DLayout(AmbiLayout layouttype) noexcept -> const std::array<uint8_t,MAX_AMBI2D_CHANNELS>&
|
||||
{
|
||||
if(layouttype == AmbiLayout::FuMa) return AmbiIndex::FromFuMa2D;
|
||||
return AmbiIndex::From2D;
|
||||
}
|
||||
|
||||
|
||||
inline alu::Vector aluCrossproduct(const alu::Vector &in1, const alu::Vector &in2)
|
||||
{
|
||||
return alu::Vector{
|
||||
@@ -875,18 +895,10 @@ void CalcPanningAndFilters(ALvoice *voice, const ALfloat xpos, const ALfloat ypo
|
||||
/* Convert the rotation matrix for FuMa input ordering and scaling,
|
||||
* and whether input is 2D or 3D.
|
||||
*/
|
||||
const uint8_t *index_map{};
|
||||
const float *scales{};
|
||||
if(voice->mFmtChannels == FmtBFormat2D)
|
||||
{
|
||||
index_map = AmbiIndex::FromFuMa2D.data();
|
||||
scales = AmbiScale::FromFuMa.data();
|
||||
}
|
||||
else
|
||||
{
|
||||
index_map = AmbiIndex::FromFuMa.data();
|
||||
scales = AmbiScale::FromFuMa.data();
|
||||
}
|
||||
const uint8_t *index_map{(voice->mFmtChannels == FmtBFormat2D) ?
|
||||
GetAmbi2DLayout(voice->mAmbiLayout).data() :
|
||||
GetAmbiLayout(voice->mAmbiLayout).data()};
|
||||
const float *scales{GetAmbiScales(voice->mAmbiScaling).data()};
|
||||
|
||||
static const uint8_t OrderFromChan[MAX_AMBI_CHANNELS]{
|
||||
0, 1,1,1, 2,2,2,2,2, 3,3,3,3,3,3,3,
|
||||
|
||||
+7
-2
@@ -9,6 +9,7 @@
|
||||
#include "al/buffer.h"
|
||||
#include "alspan.h"
|
||||
#include "alu.h"
|
||||
#include "devformat.h"
|
||||
#include "filters/biquad.h"
|
||||
#include "filters/nfc.h"
|
||||
#include "filters/splitter.h"
|
||||
@@ -211,10 +212,12 @@ struct ALvoice {
|
||||
|
||||
/* Properties for the attached buffer(s). */
|
||||
FmtChannels mFmtChannels;
|
||||
ALuint mAmbiOrder;
|
||||
ALuint mFrequency;
|
||||
ALuint mNumChannels;
|
||||
ALuint mSampleSize;
|
||||
AmbiLayout mAmbiLayout;
|
||||
AmbiNorm mAmbiScaling;
|
||||
ALuint mAmbiOrder;
|
||||
|
||||
/** Current target parameters used for mixing. */
|
||||
ALuint mStep;
|
||||
@@ -270,10 +273,12 @@ struct ALvoice {
|
||||
std::memory_order_relaxed);
|
||||
|
||||
mFmtChannels = rhs.mFmtChannels;
|
||||
mAmbiOrder = rhs.mAmbiOrder;
|
||||
mFrequency = rhs.mFrequency;
|
||||
mNumChannels = rhs.mNumChannels;
|
||||
mSampleSize = rhs.mSampleSize;
|
||||
mAmbiLayout = rhs.mAmbiLayout;
|
||||
mAmbiScaling = rhs.mAmbiScaling;
|
||||
mAmbiOrder = rhs.mAmbiOrder;
|
||||
|
||||
mStep = rhs.mStep;
|
||||
mResampler = rhs.mResampler;
|
||||
|
||||
Reference in New Issue
Block a user