Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adm: fix invalid index with m_hoaEncoders when using Binaural #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions include/AdmRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,14 @@ namespace admrender {
void ClearHoaBuffer();

/**
Find the element of a vector matching the input. If the track types do not match or no matching
Find the element of a vector matching the input key. If the track types do not match or no matching
elements then returns -1
*/
int GetMatchingKey(std::vector<std::pair<unsigned int, TypeDefinition>>, unsigned int nElement, TypeDefinition trackType);
/**
Find the element of a vector matching the input index. If the track types do not match or no matching
elements then returns -1
*/
int GetMatchingIndex(std::vector<std::pair<unsigned int, TypeDefinition>>, unsigned int nElement, TypeDefinition trackType);
};

}
22 changes: 19 additions & 3 deletions source/AdmRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ namespace admrender {
toPolar(metadata);

// Map from the track index to the corresponding panner index
int nObjectInd = GetMatchingIndex(m_pannerTrackInd, metadata.trackInd, TypeDefinition::Objects);
int nObjectInd = GetMatchingKey(m_pannerTrackInd, metadata.trackInd, TypeDefinition::Objects);

if (nObjectInd == -1) // this track was not declared at construction. Stopping here.
{
Expand Down Expand Up @@ -437,9 +437,9 @@ namespace admrender {
std::fill(m_speakerOutDiffuse[iCh].begin(), m_speakerOutDiffuse[iCh].end(), 0.f);
}

int CAdmRenderer::GetMatchingIndex(std::vector<std::pair<unsigned int, TypeDefinition>> vector, unsigned int nElement, TypeDefinition trackType)
int CAdmRenderer::GetMatchingKey(std::vector<std::pair<unsigned int, TypeDefinition>> vector, unsigned int nElement, TypeDefinition trackType)
{
// Map from the track index to the corresponding panner index
// Map from the track index to the corresponding panner key
int nInd = 0;
for (unsigned int i = 0; i < vector.size(); i++)
if (vector[i].first == nElement && vector[i].second == trackType) {
Expand All @@ -450,4 +450,20 @@ namespace admrender {
return -1;
}

int CAdmRenderer::GetMatchingIndex(std::vector<std::pair<unsigned int, TypeDefinition>> vector, unsigned int nElement, TypeDefinition trackType)
{
// Map from the track index to the corresponding panner index
int nInd = 0;
for (unsigned int i = 0; i < vector.size(); i++)
{
if (vector[i].second == trackType)
{
if (vector[i].first == nElement)
return nInd;
nInd++;
}
}
return -1;
}

}